Fix MongoDB tests compatibility with Spring Data
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertNull;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bson.Document;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@@ -45,6 +44,8 @@ import org.springframework.test.annotation.DirtiesContext;
|
|||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
import com.mongodb.BasicDBObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oleg Zhurakousky
|
* @author Oleg Zhurakousky
|
||||||
* @author Artem Bilan
|
* @author Artem Bilan
|
||||||
@@ -104,7 +105,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@MongoDbAvailable
|
@MongoDbAvailable
|
||||||
public void testWithDefaultMongoFactory() throws Exception {
|
public void testWithDefaultMongoFactory() {
|
||||||
this.mongoTemplate.save(createPerson("Bob"), "data");
|
this.mongoTemplate.save(createPerson("Bob"), "data");
|
||||||
|
|
||||||
this.mongoInboundAdapter.start();
|
this.mongoInboundAdapter.start();
|
||||||
@@ -121,13 +122,13 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@MongoDbAvailable
|
@MongoDbAvailable
|
||||||
public void testWithNamedMongoFactory() throws Exception {
|
public void testWithNamedMongoFactory() {
|
||||||
this.mongoTemplate.save(this.createPerson("Bob"), "data");
|
this.mongoTemplate.save(this.createPerson("Bob"), "data");
|
||||||
|
|
||||||
this.mongoInboundAdapterNamedFactory.start();
|
this.mongoInboundAdapterNamedFactory.start();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Message<List<Document>> message = (Message<List<Document>>) replyChannel.receive(10000);
|
Message<List<BasicDBObject>> message = (Message<List<BasicDBObject>>) replyChannel.receive(10000);
|
||||||
assertNotNull(message);
|
assertNotNull(message);
|
||||||
assertEquals("Bob", message.getPayload().get(0).get("name"));
|
assertEquals("Bob", message.getPayload().get(0).get("name"));
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@MongoDbAvailable
|
@MongoDbAvailable
|
||||||
public void testWithMongoTemplate() throws Exception {
|
public void testWithMongoTemplate() {
|
||||||
this.mongoTemplate.save(this.createPerson("Bob"), "data");
|
this.mongoTemplate.save(this.createPerson("Bob"), "data");
|
||||||
|
|
||||||
this.mongoInboundAdapterWithTemplate.start();
|
this.mongoInboundAdapterWithTemplate.start();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007-2019 the original author or authors.
|
* Copyright 2007-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bson.Document;
|
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
@@ -91,9 +90,9 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
|||||||
messageSource.setBeanFactory(mock(BeanFactory.class));
|
messageSource.setBeanFactory(mock(BeanFactory.class));
|
||||||
messageSource.afterPropertiesSet();
|
messageSource.afterPropertiesSet();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Document> results = ((List<Document>) messageSource.receive().getPayload());
|
List<BasicDBObject> results = ((List<BasicDBObject>) messageSource.receive().getPayload());
|
||||||
assertEquals(1, results.size());
|
assertEquals(1, results.size());
|
||||||
Document resultObject = results.get(0);
|
BasicDBObject resultObject = results.get(0);
|
||||||
|
|
||||||
assertEquals("Oleg", resultObject.get("name"));
|
assertEquals("Oleg", resultObject.get("name"));
|
||||||
}
|
}
|
||||||
@@ -288,11 +287,11 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
|||||||
messageSource.setExpectSingleResult(true);
|
messageSource.setExpectSingleResult(true);
|
||||||
messageSource.setBeanFactory(mock(BeanFactory.class));
|
messageSource.setBeanFactory(mock(BeanFactory.class));
|
||||||
messageSource.afterPropertiesSet();
|
messageSource.afterPropertiesSet();
|
||||||
Document result = (Document) messageSource.receive().getPayload();
|
BasicDBObject result = (BasicDBObject) messageSource.receive().getPayload();
|
||||||
Object id = result.get("_id");
|
Object id = result.get("_id");
|
||||||
result.put("company", "PepBoys");
|
result.put("company", "PepBoys");
|
||||||
template.save(result, "data");
|
template.save(result, "data");
|
||||||
result = (Document) messageSource.receive().getPayload();
|
result = (BasicDBObject) messageSource.receive().getPayload();
|
||||||
assertEquals(id, result.get("_id"));
|
assertEquals(id, result.get("_id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user