mirror of
https://github.com/google/nomulus.git
synced 2025-07-08 20:23:24 +02:00
Add testcontainers' Junit5 support dependency (#640)
* Add testcontainers' Junit5 support dependency Also updated guava, dagger, hibernate, postgresql, and cloud socket factory to latest version. Migrated PersistenceModuleTest as an example. Real changes: - dependencies.gradle - core/build.gradle - PersistenceModuleTest.java
This commit is contained in:
parent
df8ce38796
commit
2c243a7d5f
143 changed files with 2387 additions and 2316 deletions
|
@ -18,24 +18,25 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
/** Unit tests for {@link PersistenceModule}. */
|
||||
@RunWith(JUnit4.class)
|
||||
@Testcontainers
|
||||
public class PersistenceModuleTest {
|
||||
@Rule
|
||||
public PostgreSQLContainer database = new PostgreSQLContainer(NomulusPostgreSql.getDockerTag());
|
||||
|
||||
@Container
|
||||
private final PostgreSQLContainer database =
|
||||
new PostgreSQLContainer(NomulusPostgreSql.getDockerTag());
|
||||
|
||||
private EntityManagerFactory emf;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void init() {
|
||||
emf =
|
||||
PersistenceModule.create(
|
||||
database.getJdbcUrl(),
|
||||
|
@ -44,8 +45,8 @@ public class PersistenceModuleTest {
|
|||
PersistenceModule.providesDefaultDatabaseConfigs());
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() {
|
||||
@AfterEach
|
||||
void destroy() {
|
||||
if (emf != null) {
|
||||
emf.close();
|
||||
}
|
||||
|
@ -53,7 +54,7 @@ public class PersistenceModuleTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConnectToDatabase_success() {
|
||||
void testConnectToDatabase_success() {
|
||||
EntityManager em = emf.createEntityManager();
|
||||
assertThat(em.isOpen()).isTrue();
|
||||
em.close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue