Example on how to use OracleContainer Xe of Test container.
There is two usage:
The OracleContainer instantiation can be scoped:
@ClassRule
public static OracleContainer oracle = new OracleContainer("wnameless/oracle-xe-11g-r2")
.withUsername("system")
.withPassword("oracle")
.withExposedPorts(1521)
.withEnv("ORACLE_ALLOW_REMOTE", "true");
@BeforeClass
public static void setUp() {
String url = oracle.getJdbcUrl();
String username =oracle.getUsername();
String password = oracle.getPassword();
// Make your connection
}
public abstract class OracleTestContainer {
static final OracleContainer ORACLE_CONTAINER;
static {
ORACLE_CONTAINER = new OracleContainer("wnameless/oracle-xe-11g-r2")
.withUsername("system")
.withPassword("oracle")
.withExposedPorts(1521)
.withEnv("ORACLE_ALLOW_REMOTE", "true");
}
}
@Test
public static void setUp() {
String url = ORACLE_CONTAINER.getJdbcUrl();
String username =ORACLE_CONTAINER.getUsername();
String password = ORACLE_CONTAINER.getPassword();
// Make your connection
}
In this case, you just modify the Jdbc Url and use your code as it. You do it in tow steps
oracle.container.image=wnameless/oracle-xe-11g-r2
@BeforeClass
public static void setUp() {
String url = "jdbc:tc:oracle:thin:@///ORCL";
String username = "system";
String password = "oracle";
// Make your connection
}