Skip to content

Commit 7fa4a72

Browse files
committed
Improvement of tests
1 parent 41fa06b commit 7fa4a72

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

src/test/java/org/utplsql/cli/DataSourceProviderIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ void connectToDatabase() throws SQLException {
2020
assertNotNull(dataSource);
2121
}
2222

23+
//@Test
24+
void connectAsSysdba() throws SQLException {
25+
ConnectionConfig config = new ConnectionConfig("sys as sysdba/oracle@localhost:1522/ORCLPDB1");
26+
DataSource dataSource = new TestedDataSourceProvider(config).getDataSource();
27+
28+
assertNotNull(dataSource);
29+
}
30+
2331
@Test
2432
void initNlsLang() throws SQLException {
2533
System.setProperty("NLS_LANG", "BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1");

src/test/java/org/utplsql/cli/RunCommandIT.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.utplsql.api.reporter.CoreReporters;
66

77
import java.nio.file.Paths;
8+
import java.sql.SQLException;
89

910
import static org.junit.jupiter.api.Assertions.assertEquals;
1011

@@ -13,6 +14,14 @@
1314
*/
1415
class RunCommandIT extends AbstractFileOutputTest {
1516

17+
private void assertValidReturnCode(int returnCode) throws SQLException {
18+
// Only expect failure-exit-code to work on several framework versions
19+
if (OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(TestHelper.getFrameworkVersion()))
20+
assertEquals(2, returnCode);
21+
else
22+
assertEquals(0, returnCode);
23+
}
24+
1625
@Test
1726
void run_Default() throws Exception {
1827

@@ -23,21 +32,18 @@ void run_Default() throws Exception {
2332
"-c",
2433
"--failure-exit-code=2");
2534

26-
// Only expect failure-exit-code to work on several framework versions
27-
if (OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(TestHelper.getFrameworkVersion()))
28-
assertEquals(2, result);
29-
else
30-
assertEquals(0, result);
35+
assertValidReturnCode(result);
3136
}
3237

3338
@Test
3439
void run_Debug() throws Exception {
3540

3641
int result = TestHelper.runApp("run",
3742
TestHelper.getConnectionString(),
38-
"--debug");
43+
"--debug",
44+
"--failure-exit-code=2");
3945

40-
assertEquals(1, result);
46+
assertValidReturnCode(result);
4147
}
4248

4349
@Test
@@ -55,11 +61,7 @@ void run_MultipleReporters() throws Exception {
5561
"-c",
5662
"--failure-exit-code=2");
5763

58-
// Only expect failure-exit-code to work on several framework versions
59-
if (OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(TestHelper.getFrameworkVersion()))
60-
assertEquals(2, result);
61-
else
62-
assertEquals(0, result);
64+
assertValidReturnCode(result);
6365
}
6466

6567

src/test/java/org/utplsql/cli/TestHelper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,16 @@ static Version getFrameworkVersion() throws SQLException {
4545
static String getConnectionString() {
4646
return sUser + "/" + sPass + "@" + sUrl;
4747
}
48+
49+
static String getUser() {
50+
return sUser;
51+
}
52+
53+
static String getPass() {
54+
return sPass;
55+
}
56+
57+
static String getUrl() {
58+
return sUrl;
59+
}
4860
}

0 commit comments

Comments
 (0)