11import io .codenotary .immudb4j .Entry ;
22import io .codenotary .immudb4j .ImmuClient ;
33import io .codenotary .immudb4j .exceptions .VerificationException ;
4- import org .junit .After ;
5- import org .junit .Assert ;
6- import org .junit .Before ;
7- import org .junit .ClassRule ;
8- import org .junit .Test ;
4+ import org .junit .jupiter .api .AfterEach ;
5+ import org .junit .jupiter .api .Assertions ;
6+ import org .junit .jupiter .api .BeforeEach ;
7+ import org .junit .jupiter .api .Test ;
98import org .testcontainers .containers .GenericContainer ;
109import org .testcontainers .containers .wait .strategy .Wait ;
10+ import org .testcontainers .junit .jupiter .Container ;
11+ import org .testcontainers .junit .jupiter .Testcontainers ;
1112
1213import static org .assertj .core .api .Assertions .assertThat ;
1314
1415/**
1516 * Test class for the ImmuDbClient.
1617 */
17- public class ImmuDbTest {
18+ @ Testcontainers
19+ class ImmuDbTest {
1820
1921 // Default port for the ImmuDb server
2022 private static final int IMMUDB_PORT = 3322 ;
@@ -29,16 +31,16 @@ public class ImmuDbTest {
2931 private final String IMMUDB_DATABASE = "defaultdb" ;
3032
3133 // Test container for the ImmuDb database, with the latest version of the image and exposed port
32- @ ClassRule
34+ @ Container
3335 public static final GenericContainer <?> immuDbContainer = new GenericContainer <>("codenotary/immudb:1.3" )
3436 .withExposedPorts (IMMUDB_PORT )
3537 .waitingFor (Wait .forLogMessage (".*Web API server enabled.*" , 1 ));
3638
3739 // ImmuClient used to interact with the DB
3840 private ImmuClient immuClient ;
3941
40- @ Before
41- public void setUp () {
42+ @ BeforeEach
43+ void setUp () {
4244 this .immuClient =
4345 ImmuClient
4446 .newBuilder ()
@@ -48,13 +50,13 @@ public void setUp() {
4850 this .immuClient .openSession (IMMUDB_DATABASE , IMMUDB_USER , IMMUDB_PASSWORD );
4951 }
5052
51- @ After
52- public void tearDown () {
53+ @ AfterEach
54+ void tearDown () {
5355 this .immuClient .closeSession ();
5456 }
5557
5658 @ Test
57- public void testGetValue () {
59+ void testGetValue () {
5860 try {
5961 immuClient .set ("test1" , "test2" .getBytes ());
6062
@@ -64,10 +66,10 @@ public void testGetValue() {
6466 byte [] value = entry .getValue ();
6567 assertThat (new String (value )).isEqualTo ("test2" );
6668 } else {
67- Assert .fail ();
69+ Assertions .fail ();
6870 }
6971 } catch (VerificationException e ) {
70- Assert .fail ();
72+ Assertions .fail ();
7173 }
7274 }
7375}
0 commit comments