How to use runTest method of org.testcontainers.junit.oracle.SimpleOracleTest class

Best Testcontainers-java code snippet using org.testcontainers.junit.oracle.SimpleOracleTest.runTest

Source:SimpleOracleTest.java Github

copy

Full Screen

...8import java.sql.ResultSet;9import java.sql.SQLException;10public class SimpleOracleTest extends AbstractContainerDatabaseTest {11 public static final DockerImageName ORACLE_DOCKER_IMAGE_NAME = DockerImageName.parse("gvenzl/oracle-xe:18.4.0-slim");12 private void runTest(OracleContainer container, String databaseName, String username, String password) throws SQLException {13 //Test config was honored14 assertEquals(databaseName, container.getDatabaseName());15 assertEquals(username, container.getUsername());16 assertEquals(password, container.getPassword());17 18 //Test we can get a connection19 container.start();20 ResultSet resultSet = performQuery(container, "SELECT 1 FROM dual");21 int resultSetInt = resultSet.getInt(1);22 assertEquals("A basic SELECT query succeeds", 1, resultSetInt);23 }24 @Test25 public void testDefaultSettings() throws SQLException {26 try (27 OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME);28 ) {29 runTest(oracle, "xepdb1", "test", "test");30 // Match against the last '/'31 String urlSuffix = oracle.getJdbcUrl().split("(\\/)(?!.*\\/)", 2)[1];32 assertEquals("xepdb1", urlSuffix);33 }34 }35 @Test36 public void testPluggableDatabase() throws SQLException {37 try (38 OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME)39 .withDatabaseName("testDB")40 ) {41 runTest(oracle, "testDB", "test", "test");42 }43 }44 @Test45 public void testPluggableDatabaseAndCustomUser() throws SQLException {46 try (47 OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME)48 .withDatabaseName("testDB")49 .withUsername("testUser")50 .withPassword("testPassword")51 ) {52 runTest(oracle, "testDB", "testUser", "testPassword");53 }54 }55 @Test56 public void testCustomUser() throws SQLException {57 try (58 OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME)59 .withUsername("testUser")60 .withPassword("testPassword")61 ) {62 runTest(oracle, "xepdb1", "testUser", "testPassword");63 }64 }65 @Test66 public void testSID() throws SQLException {67 try (68 OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME)69 .usingSid();70 ) {71 runTest(oracle, "xepdb1", "system", "test");72 // Match against the last ':'73 String urlSuffix = oracle.getJdbcUrl().split("(\\:)(?!.*\\:)", 2)[1];74 assertEquals("xe", urlSuffix);75 }76 }77 @Test78 public void testSIDAndCustomPassword() throws SQLException {79 try (80 OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME)81 .usingSid()82 .withPassword("testPassword");83 ) {84 runTest(oracle, "xepdb1", "system", "testPassword");85 }86 }87 @Test88 public void testErrorPaths() throws SQLException {89 try (OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME)) {90 try {91 oracle.withDatabaseName("XEPDB1");92 fail("Should not have been able to set database name to xepdb1.");93 } catch (IllegalArgumentException e) {94 //expected95 }96 try {97 oracle.withDatabaseName("");98 fail("Should not have been able to set database name to nothing.");...

Full Screen

Full Screen

runTest

Using AI Code Generation

copy

Full Screen

1def testOracle = new SimpleOracleTest()2testOracle.runTest()3def testOracle = new SimpleOracleTest()4testOracle.withCustomOracleImage("wnameless/oracle-xe-11g")5testOracle.runTest()6def testOracle = new SimpleOracleTest()7testOracle.withCustomOracleImage("wnameless/oracle-xe-11g")8testOracle.withCustomJdbcUrl("jdbc:oracle:thin:@localhost:1521:xe")9testOracle.runTest()10def testOracle = new SimpleOracleTest()11testOracle.withCustomOracleImage("wnameless/oracle-xe-11g")12testOracle.withCustomJdbcUrl("jdbc:oracle:thin:@localhost:1521:xe")13testOracle.withCustomJdbcUsername("system")14testOracle.runTest()15def testOracle = new SimpleOracleTest()16testOracle.withCustomOracleImage("wnameless/oracle-xe-11g")17testOracle.withCustomJdbcUrl("jdbc:oracle:thin:@localhost:1521:xe")18testOracle.withCustomJdbcUsername("system")19testOracle.withCustomJdbcPassword("oracle")20testOracle.runTest()21def testOracle = new SimpleOracleTest()22testOracle.withCustomOracleImage("wnameless/oracle-xe-11g")23testOracle.withCustomJdbcUrl("jdbc:oracle:thin:@localhost:1521:xe")24testOracle.withCustomJdbcUsername("system")

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcontainers-java automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful