-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package net.ucanaccess.jdbc; | ||
|
||
import net.ucanaccess.exception.UcanaccessSQLException; | ||
import net.ucanaccess.test.UcanaccessBaseTest; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.Statement; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Disabled | ||
class HsqlDb272Test extends UcanaccessBaseTest { | ||
|
||
@Test | ||
void testUCanAccessAndHsqldb() throws Exception { | ||
try (Connection conn = DriverManager.getConnection("jdbc:ucanaccess://" + getDatabaseFile() + ";newDatabaseVersion=V2016;immediatelyReleaseResources=true"); | ||
|
||
Statement stmt = conn.createStatement()) { | ||
|
||
stmt.executeUpdate("CREATE TABLE Tbl (Txt VARCHAR(42) NOT NULL PRIMARY KEY)"); | ||
stmt.executeUpdate("INSERT INTO Tbl (Txt) VALUES ('Insert')"); | ||
|
||
String sqlUpdate = "UPDATE Tbl SET Txt = 'Update'"; | ||
|
||
UcanaccessSQLException ex = assertThrows(UcanaccessSQLException.class, () -> stmt.executeUpdate(sqlUpdate)); | ||
assertInstanceOf(NullPointerException.class, ex.getCause()); | ||
} | ||
} | ||
|
||
@Test | ||
void testHsqldbOnly() throws Exception { | ||
try (Connection conn = DriverManager.getConnection("jdbc:hsqldb:file:" + getDatabaseFile() + ";hsqldb.log_data=false;shutdown=true"); | ||
Statement stmt = conn.createStatement()) { | ||
|
||
stmt.executeUpdate("CREATE TABLE Tbl (Txt VARCHAR(42) NOT NULL PRIMARY KEY)"); | ||
Class<? extends org.hsqldb.Trigger> trigger = net.ucanaccess.triggers.TriggerUpdate.class; | ||
stmt.executeUpdate("CREATE TRIGGER triggerUpdate_Tbl AFTER UPDATE ON Tbl FOR EACH ROW CALL \"" + trigger.getName() + "\""); | ||
stmt.executeUpdate("INSERT INTO Tbl (Txt) VALUES ('Insert')"); | ||
stmt.executeUpdate("UPDATE Tbl SET Txt = 'Update'"); | ||
} | ||
} | ||
|
||
String getDatabaseFile() { | ||
return new File(getTestTempDir(), getShortTestMethodName()).getAbsolutePath(); | ||
} | ||
|
||
@AfterEach | ||
void cleanUp() throws Exception { | ||
Optional.ofNullable(getTestTempDir().listFiles()).map(Arrays::asList).orElse(List.of()) | ||
.stream() | ||
.filter(f -> f.getName().startsWith(getShortTestMethodName())) | ||
.forEach(File::delete); | ||
} | ||
|
||
} |