Skip to content

Commit e9da449

Browse files
committed
DATAMONGO-1559 - Drop collections used in ReactiveMongoTemplateExecuteTests before tests.
We now drop the collections used in ReactiveMongoTemplateExecuteTests on test start to create a clean state for the tests. Previously, collections were dropped after the tests only so existing data in the collections could interfere with the tests themselves.
1 parent 6bc72a6 commit e9da449

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/ReactiveMongoTemplateExecuteTests.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.data.mongodb.core;
1717

18-
import static com.sun.prism.impl.Disposer.*;
1918
import static org.hamcrest.Matchers.*;
2019
import static org.junit.Assert.*;
2120
import static org.junit.Assume.*;
@@ -24,7 +23,6 @@
2423
import reactor.test.StepVerifier;
2524

2625
import org.bson.Document;
27-
import org.junit.After;
2826
import org.junit.Before;
2927
import org.junit.Rule;
3028
import org.junit.Test;
@@ -62,7 +60,13 @@ public class ReactiveMongoTemplateExecuteTests {
6260

6361
@Before
6462
public void setUp() {
65-
cleanUp();
63+
64+
Flux<Void> cleanup = operations.dropCollection("person") //
65+
.mergeWith(operations.dropCollection("execute_test")) //
66+
.mergeWith(operations.dropCollection("execute_test1")) //
67+
.mergeWith(operations.dropCollection("execute_test2"));
68+
69+
StepVerifier.create(cleanup).verifyComplete();
6670

6771
if (mongoVersion == null) {
6872
mongoVersion = operations.executeCommand("{ buildInfo: 1 }") //
@@ -72,19 +76,6 @@ public void setUp() {
7276
}
7377
}
7478

75-
@After
76-
public void tearDown() {
77-
78-
Flux<Void> cleanup = operations.dropCollection("person") //
79-
.mergeWith(operations.dropCollection(Person.class)) //
80-
.mergeWith(operations.dropCollection("execute_test")) //
81-
.mergeWith(operations.dropCollection("execute_test1")) //
82-
.mergeWith(operations.dropCollection("execute_test2")) //
83-
.mergeWith(operations.dropCollection("execute_index_test"));
84-
85-
StepVerifier.create(cleanup).verifyComplete();
86-
}
87-
8879
@Test // DATAMONGO-1444
8980
public void executeCommandJsonCommandShouldReturnSingleResponse() {
9081

0 commit comments

Comments
 (0)