Best Testcontainers-java code snippet using org.testcontainers.junit.cockroachdb.SimpleCockroachDBTest.testSimple
Source:SimpleCockroachDBTest.java
...15 // Postgres JDBC driver uses JUL; disable it to avoid annoying, irrelevant, stderr logs during connection testing16 LogManager.getLogManager().getLogger("").setLevel(Level.OFF);17 }18 @Test19 public void testSimple() throws SQLException {20 try (CockroachContainer cockroach = new CockroachContainer(COCKROACHDB_IMAGE)) {21 cockroach.start();22 ResultSet resultSet = performQuery(cockroach, "SELECT 1");23 int resultSetInt = resultSet.getInt(1);24 assertEquals("A basic SELECT query succeeds", 1, resultSetInt);25 }26 }27 @Test28 public void testExplicitInitScript() throws SQLException {29 try (CockroachContainer cockroach = new CockroachContainer(COCKROACHDB_IMAGE)30 .withInitScript("somepath/init_postgresql.sql")) { // CockroachDB is expected to be compatible with Postgres31 cockroach.start();32 ResultSet resultSet = performQuery(cockroach, "SELECT foo FROM bar");33 String firstColumnValue = resultSet.getString(1);...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!