diff --git a/src/test/java/net/ucanaccess/test/integration/MetaDataTest.java b/src/test/java/net/ucanaccess/test/integration/MetaDataTest.java index 2fd4b3e5..be595e96 100644 --- a/src/test/java/net/ucanaccess/test/integration/MetaDataTest.java +++ b/src/test/java/net/ucanaccess/test/integration/MetaDataTest.java @@ -20,36 +20,35 @@ protected String getAccessPath() { @Override protected void init(AccessVersion _accessVersion) throws SQLException { super.init(_accessVersion); - executeStatements("CREATE TABLE AAAn ( baaaa TEXT(3) PRIMARY KEY,A INTEGER , C TEXT(4)) "); + executeStatements("CREATE TABLE t_metadata ( baaaa TEXT(3) PRIMARY KEY, A INTEGER, C TEXT(4))"); } @AfterEach void afterEachTest() throws SQLException { - dropTable("AAAn"); + dropTable("t_metadata"); } void createSimple(String a, Object[][] ver) throws SQLException, IOException { try (Statement st = ucanaccess.createStatement()) { - st.execute("INSERT INTO AAAn VALUES ('33A',11,'" + a + "' )"); - st.execute("INSERT INTO AAAn VALUES ('33B',111,'" + a + "' )"); - checkQuery("SELECT * FROM AAAn", ver); + st.execute("INSERT INTO t_metadata VALUES ('33A', 11, '" + a + "' )"); + st.execute("INSERT INTO t_metadata VALUES ('33B', 111, '" + a + "' )"); } + checkQuery("SELECT * FROM t_metadata", ver); } @ParameterizedTest(name = "[{index}] {0}") @MethodSource("net.ucanaccess.test.util.AccessVersion#getDefaultAccessVersion()") void testDrop(AccessVersion _accessVersion) throws SQLException, IOException { init(_accessVersion); - Statement st = null; ucanaccess.setAutoCommit(false); createSimple("a", new Object[][] {{"33A", 11, "a"}, {"33B", 111, "a"}}); - st = ucanaccess.createStatement(); - st.executeUpdate("DROP TABLE AAAn"); + try (Statement st = ucanaccess.createStatement()) { + st.executeUpdate("DROP TABLE t_metadata"); - st.execute("CREATE TABLE AAAn ( baaaa TEXT(3) PRIMARY KEY,A INTEGER , C TEXT(4)) "); - createSimple("b", new Object[][] {{"33A", 11, "b"}, {"33B", 111, "b"}}); + st.execute("CREATE TABLE t_metadata (baaaa TEXT(3) PRIMARY KEY, A INTEGER, C TEXT(4))"); + createSimple("b", new Object[][] {{"33A", 11, "b"}, {"33B", 111, "b"}}); - ucanaccess.commit(); - st.close(); + ucanaccess.commit(); + } } } diff --git a/src/test/java/net/ucanaccess/test/integration/NoRomanCharacterTest.java b/src/test/java/net/ucanaccess/test/integration/NoRomanCharacterTest.java index cf44809b..f724e8e1 100644 --- a/src/test/java/net/ucanaccess/test/integration/NoRomanCharacterTest.java +++ b/src/test/java/net/ucanaccess/test/integration/NoRomanCharacterTest.java @@ -19,18 +19,16 @@ protected String getAccessPath() { @EnumSource(value = AccessVersion.class) void testNoRomanCharactersInColumnName(AccessVersion _accessVersion) throws Exception { init(_accessVersion); - dumpQueryResult("SELECT * FROM NOROMAN"); - - Statement st = ucanaccess.createStatement(); - - st.execute("INSERT INTO NOROMAN ([end],[q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]) VALUES( 'the end','yeeep')"); - st.execute("UPDATE NOROMAN SET [q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]='NOOOp' WHERE [end]='the end' "); - ResultSet rs = st.executeQuery("SELECT * FROM NOROMAN"); - while (rs.next()) { - getLogger().info(rs.getString("q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß")); + dumpQueryResult("SELECT * FROM t_noroman"); + + try (Statement st = ucanaccess.createStatement()) { + st.execute("INSERT INTO t_noroman ([end],[q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]) VALUES( 'the end','yeeep')"); + st.execute("UPDATE t_noroman SET [q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]='NOOOp' WHERE [end]='the end' "); + ResultSet rs = st.executeQuery("SELECT * FROM t_noroman"); + while (rs.next()) { + getLogger().debug(rs.getString("q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß")); + } } - - checkQuery("SELECT * FROM NOROMAN"); - st.close(); + checkQuery("SELECT * FROM t_noroman"); } } diff --git a/src/test/java/net/ucanaccess/test/integration/RomanCharacterTest.java b/src/test/java/net/ucanaccess/test/integration/RomanCharacterTest.java index 62755d09..b02a35bb 100644 --- a/src/test/java/net/ucanaccess/test/integration/RomanCharacterTest.java +++ b/src/test/java/net/ucanaccess/test/integration/RomanCharacterTest.java @@ -18,13 +18,12 @@ protected String getAccessPath() { @MethodSource("net.ucanaccess.test.util.AccessVersion#getDefaultAccessVersion()") void testNoRomanCharactersInColumnName(AccessVersion _accessVersion) throws Exception { init(_accessVersion); - dumpQueryResult("SELECT * FROM NOROMAN"); - getLogger().info("q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß"); + dumpQueryResult("SELECT * FROM t_noroman"); try (Statement st = ucanaccess.createStatement()) { - st.execute("INSERT INTO NOROMAN ([end],[q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]) VALUES('the end', 'yeeep')"); - st.execute("UPDATE NOROMAN SET [q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]='NOOOp' WHERE [end]='the end' "); + st.execute("INSERT INTO t_noroman ([end],[q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]) VALUES('the end', 'yeeep')"); + st.execute("UPDATE t_noroman SET [q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]='NOOOp' WHERE [end]='the end' "); } - checkQuery("SELECT * FROM NOROMAN"); + checkQuery("SELECT * FROM t_noroman"); } } diff --git a/src/test/java/net/ucanaccess/test/integration/UnproperExecuteQueryTest.java b/src/test/java/net/ucanaccess/test/integration/UnproperExecuteQueryTest.java index 18d6ced0..16c8f4c4 100644 --- a/src/test/java/net/ucanaccess/test/integration/UnproperExecuteQueryTest.java +++ b/src/test/java/net/ucanaccess/test/integration/UnproperExecuteQueryTest.java @@ -1,5 +1,8 @@ package net.ucanaccess.test.integration; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.test.util.AccessVersion; import net.ucanaccess.test.util.UcanaccessBaseTest; import org.junit.jupiter.params.ParameterizedTest; @@ -19,19 +22,18 @@ protected String getAccessPath() { @EnumSource(value = AccessVersion.class) void testExecute(AccessVersion _accessVersion) throws Exception { init(_accessVersion); - execute("INSERT INTO NOROMAN ([end],[q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]) VALUES( 'the end','yeeep')"); - execute("UPDATE NOROMAN SET [ENd]='BLeah'"); - execute("DELETE FROM NOROMAN"); + execute("INSERT INTO t_noroman ([end],[q3¹²³¼½¾ß€Ð×ÝÞðýþäüöß]) VALUES('the end', 'yeeep')"); + execute("UPDATE t_noroman SET [ENd]='BLeah'"); + execute("DELETE FROM t_noroman"); } - private void execute(String s) throws SQLException { - Statement st = ucanaccess.createStatement(); - try { - st.executeQuery(s); - fail("Should not get here"); - } catch (Exception _ex) { - getLogger().info(_ex.getMessage()); + private void execute(String _sql) throws SQLException { + try (Statement st = ucanaccess.createStatement()) { + assertThatThrownBy(() -> st.executeQuery(_sql)) + .isInstanceOf(UcanaccessSQLException.class) + .hasMessageMatching("UCAExc:::[0-9\\.]+ General error"); + + assertDoesNotThrow(() -> st.execute(_sql)); } - st.execute(s); } } diff --git a/src/test/resources/testdbs/noroman.mdb b/src/test/resources/testdbs/noroman.mdb index 29e1ef0f..e6bee014 100644 Binary files a/src/test/resources/testdbs/noroman.mdb and b/src/test/resources/testdbs/noroman.mdb differ