forked from utPLSQL/utPLSQL-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestHelper.java
More file actions
60 lines (47 loc) · 1.53 KB
/
TestHelper.java
File metadata and controls
60 lines (47 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.utplsql.cli;
import com.beust.jcommander.JCommander;
import org.utplsql.api.DBHelper;
import org.utplsql.api.EnvironmentVariableUtil;
import org.utplsql.api.Version;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
class TestHelper {
private static String sUrl;
private static String sUser;
private static String sPass;
static {
sUrl = EnvironmentVariableUtil.getEnvValue("DB_URL", "192.168.99.100:1521:XE");
sUser = EnvironmentVariableUtil.getEnvValue("DB_USER", "app");
sPass = EnvironmentVariableUtil.getEnvValue("DB_PASS", "app");
}
static RunCommand createRunCommand(String... args) {
RunCommand runCmd = new RunCommand();
JCommander.newBuilder()
.addObject(runCmd)
.args(args)
.build();
return runCmd;
}
static int runApp(String... args) {
return Cli.runWithExitCode(args);
}
static Version getFrameworkVersion() throws SQLException {
DataSource ds = DataSourceProvider.getDataSource(new ConnectionInfo(TestHelper.getConnectionString()), 1);
try (Connection con = ds.getConnection() ) {
return DBHelper.getDatabaseFrameworkVersion(con);
}
}
static String getConnectionString() {
return sUser + "/" + sPass + "@" + sUrl;
}
static String getUser() {
return sUser;
}
static String getPass() {
return sPass;
}
static String getUrl() {
return sUrl;
}
}