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.
This commit is contained in:
Mark Paluch
2017-03-27 08:40:10 +02:00
parent 6bc72a654f
commit e9da449667

View File

@@ -15,7 +15,6 @@
*/ */
package org.springframework.data.mongodb.core; package org.springframework.data.mongodb.core;
import static com.sun.prism.impl.Disposer.*;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.junit.Assume.*; import static org.junit.Assume.*;
@@ -24,7 +23,6 @@ import reactor.core.publisher.Flux;
import reactor.test.StepVerifier; import reactor.test.StepVerifier;
import org.bson.Document; import org.bson.Document;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@@ -62,7 +60,13 @@ public class ReactiveMongoTemplateExecuteTests {
@Before @Before
public void setUp() { public void setUp() {
cleanUp();
Flux<Void> cleanup = operations.dropCollection("person") //
.mergeWith(operations.dropCollection("execute_test")) //
.mergeWith(operations.dropCollection("execute_test1")) //
.mergeWith(operations.dropCollection("execute_test2"));
StepVerifier.create(cleanup).verifyComplete();
if (mongoVersion == null) { if (mongoVersion == null) {
mongoVersion = operations.executeCommand("{ buildInfo: 1 }") // mongoVersion = operations.executeCommand("{ buildInfo: 1 }") //
@@ -72,19 +76,6 @@ public class ReactiveMongoTemplateExecuteTests {
} }
} }
@After
public void tearDown() {
Flux<Void> cleanup = operations.dropCollection("person") //
.mergeWith(operations.dropCollection(Person.class)) //
.mergeWith(operations.dropCollection("execute_test")) //
.mergeWith(operations.dropCollection("execute_test1")) //
.mergeWith(operations.dropCollection("execute_test2")) //
.mergeWith(operations.dropCollection("execute_index_test"));
StepVerifier.create(cleanup).verifyComplete();
}
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void executeCommandJsonCommandShouldReturnSingleResponse() { public void executeCommandJsonCommandShouldReturnSingleResponse() {