Skip to content

Commit

Permalink
UcanaccessBaseFileTest should not be parametrized by access source
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Oct 24, 2024
1 parent d5d7618 commit a14b06f
Show file tree
Hide file tree
Showing 22 changed files with 131 additions and 177 deletions.
26 changes: 11 additions & 15 deletions src/test/java/net/ucanaccess/jdbc/AccessLikeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@

import static net.ucanaccess.type.SqlConstants.*;

import net.ucanaccess.test.AccessDefaultVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import net.ucanaccess.util.Sql;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;

import java.sql.SQLException;
import java.util.List;

class AccessLikeTest extends UcanaccessBaseFileTest {

@ParameterizedTest(name = "[{index}] {0}")
@AccessDefaultVersionSource
void testLike(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testLike() throws SQLException {
init();

checkQuery(Sql.of(SELECT, "*", FROM, "q_like2", ORDER_BY, "campo2"), singleRec("dd1"));
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessDefaultVersionSource
void testLikeExternal(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testLikeExternal() throws SQLException {
init();

String tbl = "t_like3";
try (UcanaccessStatement st = ucanaccess.createStatement()) {
Expand Down Expand Up @@ -56,10 +53,9 @@ void testLikeExternal(AccessVersion _accessVersion) throws SQLException {
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessDefaultVersionSource
void testNotLikeExternal(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testNotLikeExternal() throws SQLException {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
st.executeUpdate("CREATE TABLE " + "t_like4" + " (id COUNTER PRIMARY KEY, descr MEMO)");
Expand Down
11 changes: 4 additions & 7 deletions src/test/java/net/ucanaccess/jdbc/AliasNamingTest.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package net.ucanaccess.jdbc;

import net.ucanaccess.test.AccessDefaultVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;

import java.sql.SQLException;

class AliasNamingTest extends UcanaccessBaseFileTest {

@ParameterizedTest(name = "[{index}] {0}")
@AccessDefaultVersionSource
void testRegex2(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testRegex2() throws SQLException {
init();
executeStatements("SELECT SUM(category_id) AS `SUM(categories abc:category_id)` FROM `categories abc`");
dumpQueryResult("SELECT SUM(category_id) AS `SUM(categories abc:category_id)` FROM `categories abc`");
}
Expand Down
58 changes: 25 additions & 33 deletions src/test/java/net/ucanaccess/jdbc/AlterTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import io.github.spannm.jackcess.*;
import io.github.spannm.jackcess.Index.Column;
import net.ucanaccess.exception.UcanaccessSQLException;
import net.ucanaccess.test.AccessVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import net.ucanaccess.util.HibernateSupport;
import net.ucanaccess.util.Sql;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.lang.System.Logger.Level;
Expand All @@ -25,17 +23,16 @@
class AlterTableTest extends UcanaccessBaseFileTest {

@Override
protected void init(AccessVersion _accessVersion) throws SQLException {
super.init(_accessVersion);
protected void init() throws SQLException {
super.init();
executeStatements(
Sql.of(CREATE, TABLE, "AAAn (baaaa TEXT(3) PRIMARY KEY, A INTEGER, C TEXT(4))"),
Sql.of(CREATE, TABLE, "[AAA n] (baaaa TEXT(3), A INTEGER, C TEXT(4), b YESNO, d DATETIME DEFAULT NOW(), e NUMERIC(8,3), [f f] TEXT)"));
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2007")
void testRename(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testRename() throws SQLException {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
st.execute("ALTER TABLE [??###] RENAME TO [1GIà GIà]");
Expand All @@ -49,10 +46,9 @@ void testRename(AccessVersion _accessVersion) throws SQLException {
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2007")
void testAddColumn(AccessVersion _accessVersion) throws SQLException, IOException {
init(_accessVersion);
@Test
void testAddColumn() throws SQLException, IOException {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
executeStatements(st,
Expand Down Expand Up @@ -102,10 +98,9 @@ void testAddColumn(AccessVersion _accessVersion) throws SQLException, IOExceptio
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2007")
void testCreateIndex(AccessVersion _accessVersion) throws SQLException, IOException {
init(_accessVersion);
@Test
void testCreateIndex() throws SQLException, IOException {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
String tbl = "AAA n";
Expand Down Expand Up @@ -135,10 +130,10 @@ void testCreateIndex(AccessVersion _accessVersion) throws SQLException, IOExcept
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2007")
void testCreatePk(AccessVersion _accessVersion) throws SQLException, IOException {
init(_accessVersion);
@Test

void testCreatePk() throws SQLException, IOException {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
st.execute("ALTER TABLE [AAA n] ADD PRIMARY KEY (baaaa, a)");
Expand Down Expand Up @@ -197,10 +192,9 @@ void createFK() throws SQLException, IOException {
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2007")
void testDoubleRelationship(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testDoubleRelationship() throws SQLException {
init();

// repro code from https://stackoverflow.com/q/49160150/2144390
try (UcanaccessStatement st = ucanaccess.createStatement()) {
Expand All @@ -227,10 +221,9 @@ void testDoubleRelationship(AccessVersion _accessVersion) throws SQLException {
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2007")
void testMiscellaneous(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testMiscellaneous() throws SQLException {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
st.execute("ALTER TABLE tx ADD CONSTRAINT pk PRIMARY KEY ([i d]) ");
Expand Down Expand Up @@ -269,10 +262,9 @@ void testMiscellaneous(AccessVersion _accessVersion) throws SQLException {
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2007")
void testSqlErrors(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testSqlErrors() throws SQLException {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
st.execute("CREATE TABLE tx2 (id COUNTER, [my best friend] LONG, [my worst friend] SINGLE, [Is Pippo] TEXT(100), "
Expand Down
11 changes: 4 additions & 7 deletions src/test/java/net/ucanaccess/jdbc/BlobOleLazyLoadingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import static org.assertj.core.api.Assertions.assertThat;

import net.ucanaccess.test.AccessVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
Expand All @@ -19,10 +17,9 @@
class BlobOleLazyLoadingTest extends UcanaccessBaseFileTest {

// It only works with JRE 1.6 and later (JDBC 3)
@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2010")
void testBlobOLE(AccessVersion _accessVersion) throws SQLException, IOException {
init(_accessVersion);
@Test
void testBlobOLE() throws SQLException, IOException {
init();

final long binaryFileSize = 32718;
byte[] initialBlobBytes = getBlobBytes();
Expand Down
10 changes: 4 additions & 6 deletions src/test/java/net/ucanaccess/jdbc/BooleanTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package net.ucanaccess.jdbc;

import net.ucanaccess.test.AccessVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;

import java.sql.SQLException;

Expand All @@ -19,10 +18,9 @@ protected void init(AccessVersion _accessVersion) throws SQLException {
"INSERT INTO t (pk) VALUES('pippo')");
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource
void testCreate(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testCreate() throws SQLException {
init();
dumpQueryResult("SELECT * FROM tblMain");
dumpQueryResult("SELECT * FROM t");
checkQuery("SELECT * FROM tblMain");
Expand Down
18 changes: 7 additions & 11 deletions src/test/java/net/ucanaccess/jdbc/CalculatedFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import net.ucanaccess.exception.UcanaccessSQLException;
import net.ucanaccess.test.AccessVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;

import java.sql.ResultSet;

class CalculatedFieldTest extends UcanaccessBaseFileTest {

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2010")
void testFunctionBuiltInCall(AccessVersion _accessVersion) throws Exception {
init(_accessVersion);
@Test
void testFunctionBuiltInCall() throws Exception {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
// definition of calculated columns:
Expand Down Expand Up @@ -46,10 +43,9 @@ void testFunctionBuiltInCall(AccessVersion _accessVersion) throws Exception {
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2010")
void testCalculatedFieldNameContainsPercentSign(AccessVersion _accessVersion) throws Exception {
init(_accessVersion);
@Test
void testCalculatedFieldNameContainsPercentSign() throws Exception {
init();

try (UcanaccessStatement st = ucanaccess.createStatement()) {
// definition of calculated column [%markup]: ([retail]/[wholesale]-1)*100
Expand Down
11 changes: 4 additions & 7 deletions src/test/java/net/ucanaccess/jdbc/ColumnOrderTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package net.ucanaccess.jdbc;

import net.ucanaccess.test.AccessDefaultVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.Date;
Expand All @@ -17,10 +15,9 @@ protected UcanaccessConnectionBuilder buildConnection() {
.withColumnOrderDisplay();
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessDefaultVersionSource
void testColumnOrder1(AccessVersion _accessVersion) throws Exception {
init(_accessVersion);
@Test
void testColumnOrder1() throws Exception {
init();

try (Connection uca = createUcanaccessConnection();
PreparedStatement ps = uca.prepareStatement("INSERT INTO t_columnorder values (?, ?, ?)")) {
Expand Down
18 changes: 7 additions & 11 deletions src/test/java/net/ucanaccess/jdbc/ComplexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import net.ucanaccess.complex.SingleValue;
import net.ucanaccess.exception.UcanaccessRuntimeException;
import net.ucanaccess.exception.UcanaccessSQLException;
import net.ucanaccess.test.AccessVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.sql.PreparedStatement;
Expand All @@ -19,10 +17,9 @@

class ComplexTest extends UcanaccessBaseFileTest {

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2010")
void testComplex(AccessVersion _accessVersion) throws Exception {
init(_accessVersion);
@Test
void testComplex() throws Exception {
init();

complex0();
complex1();
Expand Down Expand Up @@ -108,10 +105,9 @@ private void complex1() throws SQLException {
}
}

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2010")
void testComplexRollback(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);
@Test
void testComplexRollback() throws SQLException {
init();

ucanaccess = Mockito.spy(ucanaccess);
Mockito.doThrow(new UcanaccessRuntimeException(getTestMethodName()))
Expand Down
11 changes: 4 additions & 7 deletions src/test/java/net/ucanaccess/jdbc/CorruptedTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package net.ucanaccess.jdbc;

import net.ucanaccess.test.AccessVersionSource;
import net.ucanaccess.test.UcanaccessBaseFileTest;
import net.ucanaccess.type.AccessVersion;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
Expand All @@ -16,15 +14,14 @@

class CorruptedTest extends UcanaccessBaseFileTest {

@ParameterizedTest(name = "[{index}] {0}")
@AccessVersionSource(include = "V2007")
void testCorrupted(AccessVersion _accessVersion) throws SQLException {
@Test
void testCorrupted() throws SQLException {
ByteArrayOutputStream errContent = new ByteArrayOutputStream();
try (PrintStream ps = new PrintStream(errContent)) {

PrintStream prevSysOut = System.out;
System.setOut(ps);
init(_accessVersion);
init();
System.setOut(prevSysOut);
}

Expand Down
Loading

0 comments on commit a14b06f

Please sign in to comment.