Skip to content

Commit 5a95da3

Browse files
pesseSamuel Nitsche
authored andcommitted
Added Unit-Tests for TestRunnerStatementProvider
Made test on skipCompatibilityCheck only run on database versions >= 3.0.3 or it will fail due to SQL Exception
1 parent c2520c5 commit 5a95da3

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

src/test/java/org/utplsql/api/TestRunnerTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@ public void runWithDefaultParameters() {
3030
}
3131

3232
@Test
33+
/** This can only be run against versions >= 3.0.3
34+
*/
3335
public void runWithoutCompatibilityCheck() {
3436
try {
3537
Connection conn = db.newConnection();
36-
new TestRunner()
37-
.skipCompatibilityCheck(true)
38-
.run(conn);
39-
} catch (SQLException e) {
38+
CompatibilityProxy proxy = new CompatibilityProxy(conn);
39+
40+
if ( proxy.getDatabaseVersion().isGreaterOrEqualThan(new Version("3.0.3"))) {
41+
new TestRunner()
42+
.skipCompatibilityCheck(true)
43+
.run(conn);
44+
}
45+
} catch (Exception e) {
4046
Assert.fail(e.getMessage());
4147
}
4248
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.utplsql.api.testRunner;
2+
3+
import org.junit.Assert;
4+
import org.junit.Rule;
5+
import org.junit.Test;
6+
import org.utplsql.api.TestRunnerOptions;
7+
import org.utplsql.api.Version;
8+
import org.utplsql.api.rules.DatabaseRule;
9+
10+
import java.sql.SQLException;
11+
12+
public class TestRunnerStatementProviderTest {
13+
14+
@Rule
15+
public final DatabaseRule db = new DatabaseRule();
16+
17+
@Test
18+
public void testGettingPre303Version() {
19+
try {
20+
TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(new Version("3.0.2"), new TestRunnerOptions(), db.newConnection());
21+
22+
Assert.assertEquals(Pre303TestRunnerStatement.class, stmt.getClass());
23+
} catch (SQLException e) {
24+
e.printStackTrace();
25+
Assert.fail();
26+
}
27+
}
28+
29+
30+
@Test
31+
public void testGettingActualVersion() {
32+
try {
33+
TestRunnerStatement stmt = TestRunnerStatementProvider.getCompatibleTestRunnerStatement(new Version("3.0.3"), new TestRunnerOptions(), db.newConnection());
34+
35+
Assert.assertEquals(ActualTestRunnerStatement.class, stmt.getClass());
36+
} catch (SQLException e) {
37+
e.printStackTrace();
38+
Assert.fail();
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)