From f24178a39f73f8879bf7d2b7d20e799ccb30332a Mon Sep 17 00:00:00 2001 From: amit2103 Date: Fri, 30 Aug 2019 00:53:00 +0530 Subject: [PATCH] [BAEL-16768] - Fixed the integrations tests in spring-boot-persistence-mongodb --- .../MongoDbAutoGeneratedFieldIntegrationTest.java | 9 ++++++--- .../baeldung/mongodb/MongoDbSpringIntegrationTest.java | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java index cec1ad5fea..e20a229f36 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java @@ -1,18 +1,21 @@ package com.baeldung.mongodb; -import com.baeldung.mongodb.daos.UserRepository; -import com.baeldung.mongodb.models.User; +import static org.assertj.core.api.Assertions.assertThat; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; -import static org.assertj.core.api.Assertions.assertThat; +import com.baeldung.mongodb.daos.UserRepository; +import com.baeldung.mongodb.models.User; @RunWith(SpringRunner.class) @SpringBootTest +@DirtiesContext public class MongoDbAutoGeneratedFieldIntegrationTest { @Autowired diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbSpringIntegrationTest.java b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbSpringIntegrationTest.java index 954bae3684..cbb2bf45d7 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbSpringIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbSpringIntegrationTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -18,6 +19,7 @@ import com.mongodb.DBObject; @ContextConfiguration(classes = SpringBootPersistenceApplication.class) @DataMongoTest @ExtendWith(SpringExtension.class) +@DirtiesContext public class MongoDbSpringIntegrationTest { @DisplayName("Given object When save object using MongoDB template Then object can be found") @Test