Subject | New test library: firebird-testcontainers-java |
---|---|
Author | Mark Rotteveel |
Post date | 2019-06-02T12:11:19Z |
I have just release org.firebirdsql:firebird-testcontainers-java:1.0.0.
This library allows you to start a Firebird docker container for a JUnit
4 or 5 test or manually from your code. This can be useful for
JUnit-based integration tests.
For a very example, add to your pom.xml:
<dependency>
<groupId>org.firebirdsql</groupId>
<artifactId>firebird-testcontainers-java</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.firebirdsql.jdbc</groupId>
<artifactId>jaybird-jdk18</artifactId>
<version>3.0.6</version>
<scope>test</scope>
</dependency>
And create a test:
/**
* Simple test demonstrating use of {@code @Rule}.
*/
public class ContainerExampleTest {
@Rule
public final FirebirdContainer container = new FirebirdContainer();
@Test
public void canConnectToContainer() throws Exception {
try (Connection connection = DriverManager
.getConnection(container.getJdbcUrl(),
container.getUsername(), container.getPassword());
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select CURRENT_USER from
RDB$DATABASE")) {
assertTrue("has row", rs.next());
assertEquals("user name",
container.getUsername().toUpperCase(), rs.getString(1));
}
}
}
See https://github.com/FirebirdSQL/firebird-testcontainers-java and
https://www.testcontainers.org/ for details.
--
Mark Rotteveel
This library allows you to start a Firebird docker container for a JUnit
4 or 5 test or manually from your code. This can be useful for
JUnit-based integration tests.
For a very example, add to your pom.xml:
<dependency>
<groupId>org.firebirdsql</groupId>
<artifactId>firebird-testcontainers-java</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.firebirdsql.jdbc</groupId>
<artifactId>jaybird-jdk18</artifactId>
<version>3.0.6</version>
<scope>test</scope>
</dependency>
And create a test:
/**
* Simple test demonstrating use of {@code @Rule}.
*/
public class ContainerExampleTest {
@Rule
public final FirebirdContainer container = new FirebirdContainer();
@Test
public void canConnectToContainer() throws Exception {
try (Connection connection = DriverManager
.getConnection(container.getJdbcUrl(),
container.getUsername(), container.getPassword());
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select CURRENT_USER from
RDB$DATABASE")) {
assertTrue("has row", rs.next());
assertEquals("user name",
container.getUsername().toUpperCase(), rs.getString(1));
}
}
}
See https://github.com/FirebirdSQL/firebird-testcontainers-java and
https://www.testcontainers.org/ for details.
--
Mark Rotteveel