connectionList = new ArrayList<>();
public static String getUser() {
- return sUser;
+ return DB_USER;
}
@BeforeEach
@@ -38,7 +38,7 @@ protected Connection getConnection() {
}
protected synchronized Connection newConnection() throws SQLException {
- Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" + sUrl, sUser, sPass);
+ Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" + DB_URL, DB_USER, DB_PASS);
connectionList.add(conn);
return conn;
}
diff --git a/src/test/java/org/utplsql/api/CompatibilityIT.java b/src/test/java/org/utplsql/api/CompatibilityIT.java
index 118d386..948948a 100644
--- a/src/test/java/org/utplsql/api/CompatibilityIT.java
+++ b/src/test/java/org/utplsql/api/CompatibilityIT.java
@@ -19,9 +19,8 @@ void compatibleVersion() throws SQLException {
@Test
void skipCompatibilityCheck() throws SQLException {
- CompatibilityProxy proxy = new CompatibilityProxy(getConnection(), true);
+ CompatibilityProxy proxy = new CompatibilityProxy(getConnection(), Version.LATEST);
proxy.failOnNotCompatible();
assertTrue(proxy.isCompatible());
-
}
}
diff --git a/src/test/java/org/utplsql/api/DBHelperIT.java b/src/test/java/org/utplsql/api/DBHelperIT.java
index 8b13a5e..41f85c4 100644
--- a/src/test/java/org/utplsql/api/DBHelperIT.java
+++ b/src/test/java/org/utplsql/api/DBHelperIT.java
@@ -13,7 +13,7 @@ class DBHelperIT extends AbstractDatabaseTest {
void getFrameworkVersion() throws SQLException {
Version v = DBHelper.getDatabaseFrameworkVersion(getConnection());
assertTrue(v.isValid());
- System.out.println(v.getNormalizedString() + " - " + v.toString());
+ System.out.println(v.getNormalizedString() + " - " + v);
}
@Test
diff --git a/src/test/java/org/utplsql/api/DatabaseInformationIT.java b/src/test/java/org/utplsql/api/DatabaseInformationIT.java
index 8eb4317..2844625 100644
--- a/src/test/java/org/utplsql/api/DatabaseInformationIT.java
+++ b/src/test/java/org/utplsql/api/DatabaseInformationIT.java
@@ -17,7 +17,7 @@ void getFrameworkVersion() throws SQLException {
Version v = databaseInformation.getUtPlsqlFrameworkVersion(getConnection());
assertTrue(v.isValid());
- System.out.println(v.getNormalizedString() + " - " + v.toString());
+ System.out.println(v.getNormalizedString() + " - " + v);
}
@Test
diff --git a/src/test/java/org/utplsql/api/EnvironmentVariableUtil.java b/src/test/java/org/utplsql/api/EnvironmentVariableUtil.java
new file mode 100644
index 0000000..90ca49f
--- /dev/null
+++ b/src/test/java/org/utplsql/api/EnvironmentVariableUtil.java
@@ -0,0 +1,53 @@
+package org.utplsql.api;
+
+import javax.annotation.Nullable;
+
+/**
+ * This class provides an easy way to get environmental variables.
+ * This is mainly to improve testability but also to standardize the way how utPLSQL API and CLI read from
+ * environment.
+ *
+ * Variables are obtained from the following scopes in that order (chain breaks as soon as a value is obtained):
+ *
+ * - Properties (System.getProperty())
+ * - Environment (System.getEnv())
+ * - Default value
+ *
+ *
+ * An empty string is treated the same as null.
+ *
+ * @author pesse
+ */
+public class EnvironmentVariableUtil {
+
+ private EnvironmentVariableUtil() {
+ }
+
+ /**
+ * Returns the value for a given key from environment (see class description)
+ *
+ * @param key Key of environment or property value
+ * @return Environment value or null
+ */
+ public static String getEnvValue(String key) {
+ return getEnvValue(key, null);
+ }
+
+ /**
+ * Returns the value for a given key from environment or a default value (see class description)
+ *
+ * @param key Key of environment or property value
+ * @param defaultValue Default value if nothing found
+ * @return Environment value or defaultValue
+ */
+ public static String getEnvValue(String key, @Nullable String defaultValue) {
+
+ String val = System.getProperty(key);
+ if (val == null || val.isEmpty()) val = System.getenv(key);
+ if (val == null || val.isEmpty()) val = defaultValue;
+
+ return val;
+ }
+
+
+}
diff --git a/src/test/java/org/utplsql/api/EnvironmentVariableUtilTest.java b/src/test/java/org/utplsql/api/EnvironmentVariableUtilTest.java
index e437cd1..c827232 100644
--- a/src/test/java/org/utplsql/api/EnvironmentVariableUtilTest.java
+++ b/src/test/java/org/utplsql/api/EnvironmentVariableUtilTest.java
@@ -37,7 +37,7 @@ void testGetVariableFromProperty() {
@Test
void testGetVariableFromDefault() {
- assertEquals("defaultValue", EnvironmentVariableUtil.getEnvValue("RANDOM" + String.valueOf(System.currentTimeMillis()), "defaultValue"));
+ assertEquals("defaultValue", EnvironmentVariableUtil.getEnvValue("RANDOM" + System.currentTimeMillis(), "defaultValue"));
}
}
\ No newline at end of file
diff --git a/src/test/java/org/utplsql/api/OptionalFeaturesIT.java b/src/test/java/org/utplsql/api/OptionalFeaturesIT.java
index c7ce27e..f8fe9b3 100644
--- a/src/test/java/org/utplsql/api/OptionalFeaturesIT.java
+++ b/src/test/java/org/utplsql/api/OptionalFeaturesIT.java
@@ -14,7 +14,7 @@ class OptionalFeaturesIT extends AbstractDatabaseTest {
private Version getDatabaseVersion() throws SQLException {
- return new CompatibilityProxy(getConnection()).getDatabaseVersion();
+ return new CompatibilityProxy(getConnection()).getUtPlsqlVersion();
}
@Test
@@ -52,4 +52,37 @@ void customReporters() throws SQLException, InvalidVersionException {
assertFalse(available);
}
}
+
+ @Test
+ void clientCharset() throws SQLException, InvalidVersionException {
+ boolean available = OptionalFeatures.CLIENT_CHARACTER_SET.isAvailableFor(getConnection());
+
+ if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_2)) {
+ assertTrue(available);
+ } else {
+ assertFalse(available);
+ }
+ }
+
+ @Test
+ void randomExecutionOrder() throws SQLException, InvalidVersionException {
+ boolean available = OptionalFeatures.RANDOM_EXECUTION_ORDER.isAvailableFor(getConnection());
+
+ if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_7)) {
+ assertTrue(available);
+ } else {
+ assertFalse(available);
+ }
+ }
+
+ @Test
+ void tags() throws SQLException, InvalidVersionException {
+ boolean available = OptionalFeatures.TAGS.isAvailableFor(getConnection());
+
+ if (getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_7)) {
+ assertTrue(available);
+ } else {
+ assertFalse(available);
+ }
+ }
}
diff --git a/src/test/java/org/utplsql/api/OutputBufferIT.java b/src/test/java/org/utplsql/api/OutputBufferIT.java
index c6fea1f..6dd2742 100644
--- a/src/test/java/org/utplsql/api/OutputBufferIT.java
+++ b/src/test/java/org/utplsql/api/OutputBufferIT.java
@@ -40,7 +40,6 @@ private Reporter createReporter() throws SQLException {
@Test
void printAvailableLines() throws SQLException {
ExecutorService executorService = Executors.newFixedThreadPool(2);
-
try {
final Reporter reporter = createReporter();
@@ -131,7 +130,7 @@ void getOutputFromSonarReporter() throws SQLException {
void sonarReporterHasEncodingSet() throws SQLException, InvalidVersionException {
CompatibilityProxy proxy = new CompatibilityProxy(newConnection());
- if (proxy.getDatabaseVersion().isGreaterOrEqualThan(Version.V3_1_2)) {
+ if (proxy.getUtPlsqlVersion().isGreaterOrEqualThan(Version.V3_1_2)) {
Reporter reporter = new DefaultReporter(CoreReporters.UT_SONAR_TEST_REPORTER.name(), null).init(getConnection());
TestRunner tr = new TestRunner()
diff --git a/src/test/java/org/utplsql/api/ReporterInspectorIT.java b/src/test/java/org/utplsql/api/ReporterInspectorIT.java
index 367d9d1..4f3f13d 100644
--- a/src/test/java/org/utplsql/api/ReporterInspectorIT.java
+++ b/src/test/java/org/utplsql/api/ReporterInspectorIT.java
@@ -24,7 +24,6 @@ private ReporterFactory getReporterFactory() throws SQLException {
@Test
void testGetReporterInfo() throws SQLException, InvalidVersionException {
-
CompatibilityProxy proxy = new CompatibilityProxy(getConnection());
ReporterInspector inspector = ReporterInspector.create(getReporterFactory(), getConnection());
@@ -37,9 +36,9 @@ void testGetReporterInfo() throws SQLException, InvalidVersionException {
assertEquals(infos.get(CoreReporters.UT_DOCUMENTATION_REPORTER.name()).getType(), ReporterInfo.Type.SQL_WITH_JAVA);
assertEquals(infos.get(CoreReporters.UT_SONAR_TEST_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
assertEquals(infos.get(CoreReporters.UT_TEAMCITY_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
- assertEquals(infos.get(CoreReporters.UT_XUNIT_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
+ assertEquals(infos.get(CoreReporters.UT_JUNIT_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
- if (CoreReporters.UT_COVERAGE_COBERTURA_REPORTER.isAvailableFor(proxy.getDatabaseVersion())) {
+ if (CoreReporters.UT_COVERAGE_COBERTURA_REPORTER.isAvailableFor(proxy.getUtPlsqlVersion())) {
assertEquals(infos.get(CoreReporters.UT_COVERAGE_COBERTURA_REPORTER.name()).getType(), ReporterInfo.Type.SQL);
}
}
diff --git a/src/test/java/org/utplsql/api/TestRunnerIT.java b/src/test/java/org/utplsql/api/TestRunnerIT.java
index 414b9f9..4ceb184 100644
--- a/src/test/java/org/utplsql/api/TestRunnerIT.java
+++ b/src/test/java/org/utplsql/api/TestRunnerIT.java
@@ -1,8 +1,12 @@
package org.utplsql.api;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import org.utplsql.api.compatibility.CompatibilityProxy;
+import org.utplsql.api.compatibility.OptionalFeatures;
+import org.utplsql.api.db.DatabaseInformation;
+import org.utplsql.api.db.DefaultDatabaseInformation;
import org.utplsql.api.exception.InvalidVersionException;
import org.utplsql.api.exception.SomeTestsFailedException;
import org.utplsql.api.reporter.CoreReporters;
@@ -30,10 +34,12 @@ void runWithDefaultParameters() throws SQLException {
* This can only be run against versions >= 3.0.3
*/
@Test
- void runWithoutCompatibilityCheck() throws SQLException, InvalidVersionException {
- CompatibilityProxy proxy = new CompatibilityProxy(getConnection());
+ void runWithoutCompatibilityCheck() throws SQLException {
+
+ DatabaseInformation databaseInformation = new DefaultDatabaseInformation();
- if (proxy.getDatabaseVersion().isGreaterOrEqualThan(Version.V3_0_3)) {
+ // We can only test this for the versions of the latest TestRunnerStatement-Change
+ if ( OptionalFeatures.RANDOM_EXECUTION_ORDER.isAvailableFor(databaseInformation.getUtPlsqlFrameworkVersion(getConnection())) ) {
new TestRunner()
.skipCompatibilityCheck(true)
.run(getConnection());
@@ -51,7 +57,7 @@ void runWithManyReporters() throws SQLException {
.addReporter(CoreReporters.UT_COVERALLS_REPORTER.name())
.addReporter(CoreReporters.UT_SONAR_TEST_REPORTER.name())
.addReporter(CoreReporters.UT_TEAMCITY_REPORTER.name())
- .addReporter(CoreReporters.UT_XUNIT_REPORTER.name())
+ .addReporter(CoreReporters.UT_JUNIT_REPORTER.name())
.run(conn);
}
@@ -59,13 +65,14 @@ void runWithManyReporters() throws SQLException {
/**
* This can only be tested on frameworks >= 3.0.3
*/
+ @Disabled
@Test
void failOnErrors() throws SQLException, InvalidVersionException {
Connection conn = getConnection();
CompatibilityProxy proxy = new CompatibilityProxy(conn);
- if (proxy.getDatabaseVersion().isGreaterOrEqualThan(Version.V3_0_3)) {
+ if (proxy.getUtPlsqlVersion().isGreaterOrEqualThan(Version.V3_0_3)) {
Executable throwingTestRunner = () -> new TestRunner()
.failOnErrors(true)
.run(conn);
@@ -73,4 +80,21 @@ void failOnErrors() throws SQLException, InvalidVersionException {
}
}
+ @Test
+ void runWithRandomExecutionOrder() throws SQLException {
+ CompatibilityProxy proxy = new CompatibilityProxy(getConnection());
+
+ new TestRunner()
+ .randomTestOrder(true)
+ .randomTestOrderSeed(123)
+ .run(getConnection());
+ }
+
+ @Test
+ void runWithTags() throws SQLException {
+ new TestRunner()
+ .addTag("none")
+ .run(getConnection());
+ }
+
}
diff --git a/src/test/java/org/utplsql/api/VersionObjectTest.java b/src/test/java/org/utplsql/api/VersionObjectTest.java
index 22dcd24..46cea83 100644
--- a/src/test/java/org/utplsql/api/VersionObjectTest.java
+++ b/src/test/java/org/utplsql/api/VersionObjectTest.java
@@ -78,6 +78,29 @@ void versionCompareTo() {
assertEquals(0, base.compareTo(Version.create("2.3.4.5")));
}
+ @Test
+ void versionCompareToWithBaseNull() {
+ Version base = Version.create("2.3.4");
+
+ // Less than
+ assertEquals(-1, base.compareTo(Version.create("3")));
+ assertEquals(-1, base.compareTo(Version.create("3.2")));
+ assertEquals(-1, base.compareTo(Version.create("2.4.1")));
+ assertEquals(-1, base.compareTo(Version.create("2.3.9.1")));
+ assertEquals(-1, base.compareTo(Version.create("2.3.4.1")));
+ assertEquals(-1, base.compareTo(Version.create("2.3.4.5")));
+ assertEquals(-1, base.compareTo(Version.create("2.3.4.9")));
+
+ // Greater than
+ assertEquals(1, base.compareTo(Version.create("1")));
+ assertEquals(1, base.compareTo(Version.create("1.6")));
+ assertEquals(1, base.compareTo(Version.create("2.2.4")));
+ assertEquals(1, base.compareTo(Version.create("2.3.3")));
+
+ // Equal
+ assertEquals(0, base.compareTo(Version.create("2.3.4")));
+ }
+
@Test
void isGreaterOrEqualThan() throws InvalidVersionException {
Version base = Version.create("2.3.4.5");
@@ -98,6 +121,26 @@ void isGreaterOrEqualThan() throws InvalidVersionException {
}
+ @Test
+ void isGreaterOrEqualThanWithBaseNull() throws InvalidVersionException {
+ Version base = Version.create("2.3.4");
+
+ assertTrue(base.isGreaterOrEqualThan(Version.create("1")));
+ assertTrue(base.isGreaterOrEqualThan(Version.create("2")));
+ assertTrue(base.isGreaterOrEqualThan(Version.create("2.3")));
+ assertTrue(base.isGreaterOrEqualThan(Version.create("2.2")));
+ assertTrue(base.isGreaterOrEqualThan(Version.create("2.3.4")));
+ assertTrue(base.isGreaterOrEqualThan(Version.create("2.3.3")));
+ assertTrue(base.isGreaterOrEqualThan(Version.create("2.3.4.5")));
+ assertTrue(base.isGreaterOrEqualThan(Version.create("2.3.4.4")));
+ assertTrue(base.isGreaterOrEqualThan(Version.create("2.3.4.6")));
+
+ assertFalse(base.isGreaterOrEqualThan(Version.create("2.3.5")));
+ assertFalse(base.isGreaterOrEqualThan(Version.create("2.4")));
+ assertFalse(base.isGreaterOrEqualThan(Version.create("3")));
+
+ }
+
@Test
void isGreaterOrEqualThanFails() {
// Given version is invalid
diff --git a/src/test/java/org/utplsql/api/db/DynamicParameterListTest.java b/src/test/java/org/utplsql/api/db/DynamicParameterListTest.java
new file mode 100644
index 0000000..e3e9a17
--- /dev/null
+++ b/src/test/java/org/utplsql/api/db/DynamicParameterListTest.java
@@ -0,0 +1,144 @@
+package org.utplsql.api.db;
+
+import oracle.jdbc.OracleConnection;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+
+import java.sql.CallableStatement;
+import java.sql.SQLException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.*;
+
+public class DynamicParameterListTest {
+
+ @Nested
+ class single_parameters {
+ @Test
+ void can_add_string() throws SQLException {
+ CallableStatement stmt = mock(CallableStatement.class);
+
+ DynamicParameterList paramList = DynamicParameterList.builder()
+ .add("a_param", "MyString")
+ .build();
+
+ assertEquals("a_param => ?", paramList.getSql());
+
+ paramList.setParamsStartWithIndex(stmt, 5);
+ verify(stmt).setString(5, "MyString");
+ }
+
+ @Test
+ void can_add_int() throws SQLException {
+ CallableStatement stmt = mock(CallableStatement.class);
+
+ DynamicParameterList paramList = DynamicParameterList.builder()
+ .add("a_param", 1234)
+ .build();
+
+ assertEquals("a_param => ?", paramList.getSql());
+
+ paramList.setParamsStartWithIndex(stmt, 10);
+ verify(stmt).setInt(10, 1234);
+ }
+
+ @Test
+ void can_add_array() throws SQLException {
+ CallableStatement stmt = mock(CallableStatement.class);
+ OracleConnection conn = mock(OracleConnection.class);
+
+ Object[] numArr = new Object[]{1, 2};
+
+ DynamicParameterList paramList = DynamicParameterList.builder()
+ .add("a_param", numArr, "MY_TYPE", conn)
+ .build();
+
+ assertEquals("a_param => ?", paramList.getSql());
+
+ paramList.setParamsStartWithIndex(stmt, 3);
+ verify(conn).createOracleArray("MY_TYPE", numArr);
+ verify(stmt).setArray(3, null);
+ }
+
+ @Test
+ void can_add_boolean() throws SQLException {
+ CallableStatement stmt = mock(CallableStatement.class);
+
+ DynamicParameterList paramList = DynamicParameterList.builder()
+ .add("a_bool", true)
+ .build();
+
+ assertEquals("a_bool => (case ? when 1 then true else false end)", paramList.getSql());
+
+ paramList.setParamsStartWithIndex(stmt, 3);
+ verify(stmt).setInt(3, 1);
+ }
+ }
+
+ @Nested
+ class mutliple_parameters {
+
+ @Test
+ void several_parameters_are_issued_in_the_correct_order() throws SQLException {
+ CallableStatement mockedStatement = mock(CallableStatement.class);
+
+ DynamicParameterList parameterList = DynamicParameterList.builder()
+ .add("a_param1", "Param1")
+ .add("a_param2", "Param2")
+ .add("a_param3", "Param3")
+ .build();
+
+ assertEquals("a_param1 => ?, a_param2 => ?, a_param3 => ?", parameterList.getSql());
+
+ parameterList.setParamsStartWithIndex(mockedStatement, 10);
+
+ verify(mockedStatement).setString(10, "Param1");
+ verify(mockedStatement).setString(11, "Param2");
+ verify(mockedStatement).setString(12, "Param3");
+ }
+
+ @Test
+ void call_with_three_different_types() throws SQLException {
+
+ CallableStatement mockedStatement = mock(CallableStatement.class);
+ OracleConnection mockedConn = mock(OracleConnection.class);
+
+ Object[] numArr = new Object[]{1, 2};
+
+ DynamicParameterList parameterList = DynamicParameterList.builder()
+ .add("a_object_owner", "MyOwner")
+ .add("a_num_param", 123)
+ .add("a_num_array", numArr, "MY_NUM_ARR", mockedConn)
+ .build();
+
+ assertEquals("a_object_owner => ?, a_num_param => ?, a_num_array => ?", parameterList.getSql());
+
+ parameterList.setParamsStartWithIndex(mockedStatement, 5);
+
+ verify(mockedStatement).setString(5, "MyOwner");
+ verify(mockedStatement).setInt(6, 123);
+ verify(mockedConn).createOracleArray("MY_NUM_ARR", numArr);
+ verify(mockedStatement).setArray(7, null);
+ }
+
+ @Test
+ void when_not_accept_empty_filter_empty_elements() throws SQLException {
+
+ CallableStatement mockedStatement = mock(CallableStatement.class);
+ OracleConnection mockedConn = mock(OracleConnection.class);
+
+ DynamicParameterList parameterList = DynamicParameterList.builder()
+ .addIfNotEmpty("a_object_owner", (String) null)
+ .addIfNotEmpty("a_num_param", (Integer) null)
+ .addIfNotEmpty("a_num_array", new Object[]{}, "MY_NUM_ARR", mockedConn)
+ .build();
+
+ assertEquals("", parameterList.getSql());
+
+ parameterList.setParamsStartWithIndex(mockedStatement, 2);
+
+ verifyNoMoreInteractions(mockedStatement);
+ verifyNoMoreInteractions(mockedConn);
+ }
+ }
+}
diff --git a/src/test/java/org/utplsql/api/outputBuffer/OutputBufferProviderIT.java b/src/test/java/org/utplsql/api/outputBuffer/OutputBufferProviderIT.java
new file mode 100644
index 0000000..463e0be
--- /dev/null
+++ b/src/test/java/org/utplsql/api/outputBuffer/OutputBufferProviderIT.java
@@ -0,0 +1,49 @@
+package org.utplsql.api.outputBuffer;
+
+import org.junit.jupiter.api.Test;
+import org.utplsql.api.AbstractDatabaseTest;
+import org.utplsql.api.Version;
+import org.utplsql.api.compatibility.CompatibilityProxy;
+import org.utplsql.api.exception.InvalidVersionException;
+import org.utplsql.api.reporter.CoreReporters;
+import org.utplsql.api.reporter.Reporter;
+import org.utplsql.api.reporter.ReporterFactory;
+
+import java.sql.SQLException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+
+public class OutputBufferProviderIT extends AbstractDatabaseTest {
+
+ @Test
+ void testGettingPre310Version() throws SQLException {
+
+ CompatibilityProxy proxy = new CompatibilityProxy(getConnection(), Version.V3_0_4);
+ ReporterFactory reporterFactory = ReporterFactory.createDefault(proxy);
+
+ Reporter r = reporterFactory.createReporter(CoreReporters.UT_DOCUMENTATION_REPORTER.name());
+ r.init(getConnection(), proxy, reporterFactory);
+
+ OutputBuffer buffer = proxy.getOutputBuffer(r, getConnection());
+
+ assertThat(buffer, instanceOf(CompatibilityOutputBufferPre310.class));
+ }
+
+ @Test
+ void testGettingActualVersion() throws SQLException, InvalidVersionException {
+ CompatibilityProxy proxy = new CompatibilityProxy(getConnection(), Version.LATEST);
+
+ // We can only test new behaviour with DB-Version >= 3.1.0
+ if ( proxy.getRealDbPlsqlVersion().isGreaterOrEqualThan(Version.V3_1_0)) {
+ ReporterFactory reporterFactory = ReporterFactory.createDefault(proxy);
+
+ Reporter r = reporterFactory.createReporter(CoreReporters.UT_DOCUMENTATION_REPORTER.name());
+ r.init(getConnection(), proxy, reporterFactory);
+
+ OutputBuffer buffer = proxy.getOutputBuffer(r, getConnection());
+
+ assertThat(buffer, instanceOf(DefaultOutputBuffer.class));
+ }
+ }
+}
diff --git a/src/test/java/org/utplsql/api/outputBuffer/PLSQLOutputBufferIT.java b/src/test/java/org/utplsql/api/outputBuffer/PLSQLOutputBufferIT.java
deleted file mode 100644
index b4b6aa9..0000000
--- a/src/test/java/org/utplsql/api/outputBuffer/PLSQLOutputBufferIT.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.utplsql.api.outputBuffer;
-
-import org.junit.jupiter.api.Test;
-import org.utplsql.api.AbstractDatabaseTest;
-
-class PLSQLOutputBufferIT extends AbstractDatabaseTest {
-
- @Test
- void getLines() {
-
- }
-}
diff --git a/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java b/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java
index 41dd399..b94cc32 100644
--- a/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java
+++ b/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java
@@ -1,80 +1,65 @@
package org.utplsql.api.reporter;
-import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import java.io.File;
-import java.io.IOException;
-import java.nio.file.*;
-import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@Tag("binary")
class CoverageHTMLReporterAssetTest {
private static final String TEST_FOLDER = "__testAssets";
- @AfterAll
- static void clearTestAssetsFolder() {
- try {
- Files.walkFileTree(Paths.get(TEST_FOLDER), new SimpleFileVisitor() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- Files.delete(file);
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
- Files.delete(dir);
- return FileVisitResult.CONTINUE;
- }
- });
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ @TempDir
+ Path tempDir;
private void testFileExists(Path filePath) {
- File f = new File(filePath.toUri());
+ File f = new File(tempDir.resolve(TEST_FOLDER).resolve(filePath).toUri());
- assertTrue(f.exists(), () -> "File " + f.toString() + " does not exist");
+ assertTrue(f.exists(), () -> "File " + f + " does not exist");
}
+ @Disabled("No idea why this ever worked")
@Test
void writeReporterAssetsTo() throws RuntimeException {
- Path targetPath = Paths.get(TEST_FOLDER);
+ Path targetPath = tempDir.resolve(TEST_FOLDER);
// Act
CoverageHTMLReporter.writeReportAssetsTo(targetPath);
- testFileExists(targetPath.resolve(Paths.get("colorbox", "border.png")));
- testFileExists(targetPath.resolve(Paths.get("colorbox", "controls.png")));
- testFileExists(targetPath.resolve(Paths.get("colorbox", "loading.gif")));
- testFileExists(targetPath.resolve(Paths.get("colorbox", "loading_background.png")));
-
- testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_flat_0_aaaaaa_40x100.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_flat_75_ffffff_40x100.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_55_fbf9ee_1x400.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_65_ffffff_1x400.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_75_dadada_1x400.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_75_e6e6e6_1x400.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_95_fef1ec_1x400.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_highlight-soft_75_cccccc_1x100.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_2e83ff_256x240.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_222222_256x240.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_454545_256x240.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_888888_256x240.png")));
- testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_cd0a0a_256x240.png")));
-
- testFileExists(targetPath.resolve(Paths.get("application.css")));
- testFileExists(targetPath.resolve(Paths.get("application.js")));
- testFileExists(targetPath.resolve(Paths.get("favicon_green.png")));
- testFileExists(targetPath.resolve(Paths.get("favicon_red.png")));
- testFileExists(targetPath.resolve(Paths.get("favicon_yellow.png")));
- testFileExists(targetPath.resolve(Paths.get("loading.gif")));
- testFileExists(targetPath.resolve(Paths.get("magnify.png")));
+ testFileExists(Paths.get("colorbox", "border.png"));
+ testFileExists(Paths.get("colorbox", "controls.png"));
+ testFileExists(Paths.get("colorbox", "loading.gif"));
+ testFileExists(Paths.get("colorbox", "loading_background.png"));
+
+ testFileExists(Paths.get("images", "ui-bg_flat_0_aaaaaa_40x100.png"));
+ testFileExists(Paths.get("images", "ui-bg_flat_75_ffffff_40x100.png"));
+ testFileExists(Paths.get("images", "ui-bg_glass_55_fbf9ee_1x400.png"));
+ testFileExists(Paths.get("images", "ui-bg_glass_65_ffffff_1x400.png"));
+ testFileExists(Paths.get("images", "ui-bg_glass_75_dadada_1x400.png"));
+ testFileExists(Paths.get("images", "ui-bg_glass_75_e6e6e6_1x400.png"));
+ testFileExists(Paths.get("images", "ui-bg_glass_95_fef1ec_1x400.png"));
+ testFileExists(Paths.get("images", "ui-bg_highlight-soft_75_cccccc_1x100.png"));
+ testFileExists(Paths.get("images", "ui-icons_2e83ff_256x240.png"));
+ testFileExists(Paths.get("images", "ui-icons_222222_256x240.png"));
+ testFileExists(Paths.get("images", "ui-icons_454545_256x240.png"));
+ testFileExists(Paths.get("images", "ui-icons_888888_256x240.png"));
+ testFileExists(Paths.get("images", "ui-icons_cd0a0a_256x240.png"));
+
+ testFileExists(Paths.get("application.css"));
+ testFileExists(Paths.get("application.js"));
+ testFileExists(Paths.get("favicon_green.png"));
+ testFileExists(Paths.get("favicon_red.png"));
+ testFileExists(Paths.get("favicon_yellow.png"));
+ testFileExists(Paths.get("loading.gif"));
+ testFileExists(Paths.get("magnify.png"));
}
}
diff --git a/src/test/java/org/utplsql/api/testRunner/DynamicTestRunnerStatementTest.java b/src/test/java/org/utplsql/api/testRunner/DynamicTestRunnerStatementTest.java
new file mode 100644
index 0000000..739dbcf
--- /dev/null
+++ b/src/test/java/org/utplsql/api/testRunner/DynamicTestRunnerStatementTest.java
@@ -0,0 +1,314 @@
+package org.utplsql.api.testRunner;
+
+import oracle.jdbc.OracleConnection;
+import org.hamcrest.Matcher;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.verification.VerificationMode;
+import org.utplsql.api.CustomTypes;
+import org.utplsql.api.FileMapping;
+import org.utplsql.api.TestRunnerOptions;
+import org.utplsql.api.Version;
+
+import java.sql.Array;
+import java.sql.CallableStatement;
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.not;
+import static org.mockito.Mockito.*;
+
+public class DynamicTestRunnerStatementTest {
+
+ private DynamicTestRunnerStatement testRunnerStatement;
+ private CallableStatement callableStatement;
+ private OracleConnection oracleConnection;
+ private TestRunnerOptions options;
+ private Object[] expectedFileMapping;
+
+ @BeforeEach
+ void initParameters() throws SQLException {
+ expectedFileMapping = new Object[]{new FileMapping("someFile", "owner", "object", "PACKAGE")};
+
+ // Mock some internals. This is not pretty, but a first step
+ oracleConnection = getMockedOracleConnection(expectedFileMapping);
+ callableStatement = mock(CallableStatement.class);
+
+ // Act
+ options = TestRunnerStatementProviderIT.getCompletelyFilledOptions();
+ }
+
+ @Test
+ void version_3_0_2_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_0_2);
+
+ checkBaseParameters();
+ checkFailOnError(false);
+ checkClientCharacterSet(false);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_0_3_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_0_3);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(false);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_0_4_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_0_4);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(false);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_0_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_0);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(false);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_1_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_1);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(false);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_2_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_2);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_3_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_3);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_4_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_4);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_5_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_5);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_6_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_6);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(false);
+ checkTags(false);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_7_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_7);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(true);
+ checkTags(true);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_8_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_8);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(true);
+ checkTags(true);
+ checkExpr(false);
+ }
+
+ @Test
+ void version_3_1_13_parameters() throws SQLException {
+ initTestRunnerStatementForVersion(Version.V3_1_13);
+
+ checkBaseParameters();
+ checkFailOnError(true);
+ checkClientCharacterSet(true);
+ checkRandomTestOrder(true);
+ checkTags(true);
+ checkExpr(true);
+ }
+
+ private OracleConnection getMockedOracleConnection(Object[] expectedFileMapping) throws SQLException {
+ OracleConnection oracleConnection = mock(OracleConnection.class);
+ when(oracleConnection.unwrap(OracleConnection.class))
+ .thenReturn(oracleConnection);
+ mockFileMapper(oracleConnection, expectedFileMapping);
+ return oracleConnection;
+ }
+
+ private void mockFileMapper(OracleConnection mockedOracleConnection, Object[] expectedFileMapping) throws SQLException {
+ Array fileMapperArray = mock(Array.class);
+ CallableStatement fileMapperStatement = mock(CallableStatement.class);
+
+ when(fileMapperArray.getArray())
+ .thenReturn(expectedFileMapping);
+ when(fileMapperStatement.getArray(1))
+ .thenReturn(fileMapperArray);
+ when(
+ mockedOracleConnection.prepareCall(argThat(
+ a -> a.startsWith("BEGIN ? := ut_file_mapper.build_file_mappings("))
+ ))
+ .thenReturn(fileMapperStatement);
+ }
+
+ private Matcher doesOrDoesNotContainString(String string, boolean shouldBeThere) {
+ return (shouldBeThere)
+ ? containsString(string)
+ : not(containsString(string));
+ }
+
+ private VerificationMode doesOrDoesNotGetCalled(boolean shouldBeThere) {
+ return (shouldBeThere)
+ ? times(1)
+ : never();
+ }
+
+ private void initTestRunnerStatementForVersion(Version version) throws SQLException {
+ testRunnerStatement = DynamicTestRunnerStatement
+ .forVersion(version, oracleConnection, options, callableStatement);
+ }
+
+ private void checkBaseParameters() throws SQLException {
+ String sql = testRunnerStatement.getSql();
+
+ assertThat(sql, containsString("a_paths => ?"));
+ verify(callableStatement).setArray(1, null);
+ verify(oracleConnection).createOracleArray(CustomTypes.UT_VARCHAR2_LIST, options.pathList.toArray());
+
+ assertThat(sql, containsString("a_reporters => ?"));
+ verify(callableStatement).setArray(2, null);
+ verify(oracleConnection).createOracleArray(CustomTypes.UT_REPORTERS, options.reporterList.toArray());
+
+ assertThat(sql, containsString("a_color_console => (case ? when 1 then true else false end)"));
+ verify(callableStatement).setInt(3, 0);
+
+ assertThat(sql, containsString("a_coverage_schemes => ?"));
+ verify(callableStatement).setArray(4, null);
+ verify(oracleConnection).createOracleArray(CustomTypes.UT_VARCHAR2_LIST, options.coverageSchemes.toArray());
+
+ assertThat(sql, containsString("a_source_file_mappings => ?"));
+ verify(callableStatement).setArray(5, null);
+
+ assertThat(sql, containsString("a_test_file_mappings => ?"));
+ verify(callableStatement).setArray(6, null);
+ verify(oracleConnection, times(2)).createOracleArray(CustomTypes.UT_FILE_MAPPINGS, expectedFileMapping);
+
+ assertThat(sql, containsString("a_include_objects => ?"));
+ verify(callableStatement).setArray(7, null);
+ verify(oracleConnection).createOracleArray(CustomTypes.UT_VARCHAR2_LIST, options.includeObjects.toArray());
+
+ assertThat(sql, containsString("a_exclude_objects => ?"));
+ verify(callableStatement).setArray(8, null);
+ verify(oracleConnection).createOracleArray(CustomTypes.UT_VARCHAR2_LIST, options.includeObjects.toArray());
+ }
+
+ private void checkFailOnError(boolean shouldBeThere) throws SQLException {
+ String sql = testRunnerStatement.getSql();
+
+ assertThat(sql, doesOrDoesNotContainString("a_fail_on_errors => (case ? when 1 then true else false end)", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setInt(9, 1);
+ }
+
+ private void checkClientCharacterSet(boolean shouldBeThere) throws SQLException {
+ String sql = testRunnerStatement.getSql();
+
+ assertThat(sql, doesOrDoesNotContainString("a_client_character_set => ?", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setString(10, "UTF8");
+ }
+
+ private void checkRandomTestOrder(boolean shouldBeThere) throws SQLException {
+ String sql = testRunnerStatement.getSql();
+
+ assertThat(sql, doesOrDoesNotContainString("a_random_test_order => (case ? when 1 then true else false end)", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setInt(11, 1);
+ assertThat(sql, doesOrDoesNotContainString("a_random_test_order_seed => ?", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setInt(12, 123);
+ }
+
+ private void checkTags(boolean shouldBeThere) throws SQLException {
+ String sql = testRunnerStatement.getSql();
+
+ assertThat(sql, doesOrDoesNotContainString("a_tags => ?", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setString(13, "WIP,long_running");
+ }
+
+ private void checkExpr(boolean shouldBeThere) throws SQLException {
+ String sql = testRunnerStatement.getSql();
+
+ assertThat(sql, doesOrDoesNotContainString("a_include_schema_expr => ?", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setString(14, "a_*");
+ assertThat(sql, doesOrDoesNotContainString("a_include_object_expr => ?", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setString(15, "a_*");
+ assertThat(sql, doesOrDoesNotContainString("a_exclude_schema_expr => ?", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setString(16, "ut3:*_package*");
+ assertThat(sql, doesOrDoesNotContainString("a_exclude_object_expr => ?", shouldBeThere));
+ verify(callableStatement, doesOrDoesNotGetCalled(shouldBeThere)).setString(17, "ut3:*_package*");
+ }
+}
diff --git a/src/test/java/org/utplsql/api/FileMapperIT.java b/src/test/java/org/utplsql/api/testRunner/FileMapperIT.java
similarity index 53%
rename from src/test/java/org/utplsql/api/FileMapperIT.java
rename to src/test/java/org/utplsql/api/testRunner/FileMapperIT.java
index 20ff1b4..5c7a306 100644
--- a/src/test/java/org/utplsql/api/FileMapperIT.java
+++ b/src/test/java/org/utplsql/api/testRunner/FileMapperIT.java
@@ -1,6 +1,12 @@
-package org.utplsql.api;
+package org.utplsql.api.testRunner;
+import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
+import org.utplsql.api.AbstractDatabaseTest;
+import org.utplsql.api.FileMapperOptions;
+import org.utplsql.api.FileMapping;
+import org.utplsql.api.KeyValuePair;
+import org.utplsql.api.testRunner.FileMapper;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -45,4 +51,37 @@ private void assertMapping(FileMapping fileMapping, String owner, String name, S
assertEquals(type, fileMapping.getObjectType());
}
+ @Nested
+ class Default_type_mapping {
+
+ void checkTypeMapping( List typeMappings ) throws SQLException {
+ List filePaths = java.util.Arrays.asList(
+ "/award_bonus.prc",
+ "/betwnstr.fnc",
+ "/package_body.pkb",
+ "/type_body.tpb",
+ "/trigger.trg");
+ FileMapperOptions mapperOptions = new FileMapperOptions(filePaths);
+ mapperOptions.setTypeMappings(typeMappings);
+
+ List fileMappings = FileMapper.buildFileMappingList(getConnection(), mapperOptions);
+
+ assertEquals("PROCEDURE", fileMappings.get(0).getObjectType());
+ assertEquals("FUNCTION", fileMappings.get(1).getObjectType());
+ assertEquals("PACKAGE BODY", fileMappings.get(2).getObjectType());
+ assertEquals("TYPE BODY", fileMappings.get(3).getObjectType());
+ assertEquals("TRIGGER", fileMappings.get(4).getObjectType());
+ }
+
+ @Test
+ void is_used_on_null_parameter() throws SQLException {
+ checkTypeMapping(null);
+ }
+
+ @Test
+ void is_used_on_empty_parameter() throws SQLException {
+ checkTypeMapping(new ArrayList<>());
+ }
+ }
+
}
diff --git a/src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java b/src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java
index e811102..2676c38 100644
--- a/src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java
+++ b/src/test/java/org/utplsql/api/testRunner/TestRunnerStatementProviderIT.java
@@ -2,37 +2,105 @@
import org.junit.jupiter.api.Test;
import org.utplsql.api.AbstractDatabaseTest;
+import org.utplsql.api.FileMapperOptions;
import org.utplsql.api.TestRunnerOptions;
import org.utplsql.api.Version;
+import org.utplsql.api.reporter.CoreReporters;
+import org.utplsql.api.reporter.ReporterFactory;
import java.sql.SQLException;
+import java.util.Arrays;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
class TestRunnerStatementProviderIT extends AbstractDatabaseTest {
+ public static TestRunnerOptions getCompletelyFilledOptions() {
+ TestRunnerOptions options = new TestRunnerOptions();
+ options.pathList.add("path");
+ options.reporterList.add(ReporterFactory.createEmpty().createReporter(CoreReporters.UT_DOCUMENTATION_REPORTER.name()));
+ options.coverageSchemes.add("APP");
+ options.sourceMappingOptions = new FileMapperOptions(Arrays.asList("sourcePath"));
+ options.testMappingOptions = new FileMapperOptions(Arrays.asList("testPath"));
+ options.includeObjects.add("include1");
+ options.excludeObjects.add("exclude1");
+ options.failOnErrors = true;
+ options.clientCharacterSet = "UTF8";
+ options.randomTestOrder = true;
+ options.randomTestOrderSeed = 123;
+ options.tags.add("WIP");
+ options.tags.add("long_running");
+ options.includeSchemaExpr = "a_*";
+ options.includeObjectExpr = "a_*";
+ options.excludeSchemaExpr = "ut3:*_package*";
+ options.excludeObjectExpr = "ut3:*_package*";
+ return options;
+ }
+
+ TestRunnerStatement getTestRunnerStatementForVersion(Version version) throws SQLException {
+ return TestRunnerStatementProvider.getCompatibleTestRunnerStatement(version, getCompletelyFilledOptions(), getConnection());
+ }
+
@Test
void testGettingPre303Version() throws SQLException {
- TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(Version.V3_0_2, new TestRunnerOptions(), getConnection());
- assertEquals(Pre303TestRunnerStatement.class, stmt.getClass());
+ TestRunnerStatement stmt = getTestRunnerStatementForVersion(Version.V3_0_2);
+ assertThat(stmt.getSql(), not(containsString("a_fail_on_errors")));
+ assertThat(stmt.getSql(), not(containsString("a_client_character_set")));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order")));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order_seed")));
+ assertThat(stmt.getSql(), not(containsString("a_tags")));
}
@Test
void testGettingPre312Version_from_303() throws SQLException {
- TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(Version.V3_0_3, new TestRunnerOptions(), getConnection());
- assertEquals(Pre312TestRunnerStatement.class, stmt.getClass());
+ TestRunnerStatement stmt = getTestRunnerStatementForVersion(Version.V3_0_3);
+ assertThat(stmt.getSql(), containsString("a_fail_on_errors"));
+ assertThat(stmt.getSql(), not(containsString("a_client_character_set")));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order")));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order_seed")));
+ assertThat(stmt.getSql(), not(containsString("a_tags")));
}
@Test
void testGettingPre312Version_from_311() throws SQLException {
- TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(Version.V3_1_1, new TestRunnerOptions(), getConnection());
- assertEquals(Pre312TestRunnerStatement.class, stmt.getClass());
+ TestRunnerStatement stmt = getTestRunnerStatementForVersion(Version.V3_1_1);
+ assertThat(stmt.getSql(), containsString("a_fail_on_errors"));
+ assertThat(stmt.getSql(), not(containsString("a_client_character_set")));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order")));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order_seed")));
+ assertThat(stmt.getSql(), not(containsString("a_tags")));
+ }
+
+ @Test
+ void testGettingPre317Version_from_312() throws SQLException {
+ TestRunnerStatement stmt = getTestRunnerStatementForVersion(Version.V3_1_2);
+ assertThat(stmt.getSql(), containsString("a_fail_on_errors"));
+ assertThat(stmt.getSql(), containsString("a_client_character_set"));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order")));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order_seed")));
+ assertThat(stmt.getSql(), not(containsString("a_tags")));
+ }
+
+ @Test
+ void testGettingPre317Version_from_316() throws SQLException {
+ TestRunnerStatement stmt = getTestRunnerStatementForVersion(Version.V3_1_6);
+ assertThat(stmt.getSql(), containsString("a_fail_on_errors"));
+ assertThat(stmt.getSql(), containsString("a_client_character_set"));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order")));
+ assertThat(stmt.getSql(), not(containsString("a_random_test_order_seed")));
+ assertThat(stmt.getSql(), not(containsString("a_tags")));
}
@Test
- void testGettingActualVersion() throws SQLException {
- TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(Version.V3_1_2, new TestRunnerOptions(), getConnection());
- assertEquals(ActualTestRunnerStatement.class, stmt.getClass());
+ void testGettingActualVersion_from_latest() throws SQLException {
+ TestRunnerStatement stmt = getTestRunnerStatementForVersion(Version.LATEST);
+ assertThat(stmt.getSql(), containsString("a_fail_on_errors"));
+ assertThat(stmt.getSql(), containsString("a_client_character_set"));
+ assertThat(stmt.getSql(), containsString("a_random_test_order"));
+ assertThat(stmt.getSql(), containsString("a_random_test_order_seed"));
+ assertThat(stmt.getSql(), containsString("a_tags"));
}
}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy