use of com.mongodb.MongoClient in project spring-data-mongodb by spring-projects.
the class TailableCursorTests method setUp.
@Before
public void setUp() {
template = new MongoTemplate(new MongoClient(), "tailable-cursor-tests");
template.dropCollection(User.class);
template.createCollection(User.class, CollectionOptions.empty().capped().maxDocuments(10000).size(10000));
container = new DefaultMessageListenerContainer(template, executor);
container.start();
jellyBelly = new User();
jellyBelly.id = "id-1";
jellyBelly.userName = "jellyBelly";
jellyBelly.age = 7;
huffyFluffy = new User();
huffyFluffy.id = "id-2";
huffyFluffy.userName = "huffyFluffy";
huffyFluffy.age = 7;
sugarSplashy = new User();
sugarSplashy.id = "id-3";
sugarSplashy.userName = "sugarSplashy";
sugarSplashy.age = 5;
}
use of com.mongodb.MongoClient in project spring-data-mongodb by spring-projects.
the class ReactiveFindOperationSupportTests method setUp.
@Before
public void setUp() {
blocking = new MongoTemplate(new SimpleMongoDbFactory(new MongoClient(), "ExecutableFindOperationSupportTests"));
blocking.dropCollection(STAR_WARS);
han = new Person();
han.firstname = "han";
han.lastname = "solo";
han.id = "id-1";
luke = new Person();
luke.firstname = "luke";
luke.lastname = "skywalker";
luke.id = "id-2";
blocking.save(han);
blocking.save(luke);
template = new ReactiveMongoTemplate(MongoClients.create(), "ExecutableFindOperationSupportTests");
}
use of com.mongodb.MongoClient in project spring-data-mongodb by spring-projects.
the class ReactiveRemoveOperationSupportTests method setUp.
@Before
public void setUp() {
blocking = new MongoTemplate(new SimpleMongoDbFactory(new MongoClient(), "ExecutableRemoveOperationSupportTests"));
blocking.dropCollection(STAR_WARS);
han = new Person();
han.firstname = "han";
han.id = "id-1";
luke = new Person();
luke.firstname = "luke";
luke.id = "id-2";
blocking.save(han);
blocking.save(luke);
template = new ReactiveMongoTemplate(MongoClients.create(), "ExecutableRemoveOperationSupportTests");
}
use of com.mongodb.MongoClient in project spring-data-mongodb by spring-projects.
the class MongoClientParserIntegrationTests method createsMongoClientWithDefaultsCorrectly.
// DATAMONGO-1158
@Test
public void createsMongoClientWithDefaultsCorrectly() {
reader.loadBeanDefinitions(new ClassPathResource("namespace/mongoClient-bean.xml"));
AbstractApplicationContext context = new GenericApplicationContext(factory);
context.refresh();
try {
MongoClient client = context.getBean("mongoClient", MongoClient.class);
assertThat(client.getAddress().getHost(), is("127.0.0.1"));
assertThat(client.getAddress().getPort(), is(27017));
} finally {
context.close();
}
}
use of com.mongodb.MongoClient in project spring-data-mongodb by spring-projects.
the class MongoNamespaceReplicaSetTests method testMongoWithReplicaSets.
@Test
@Ignore("CI infrastructure does not yet support replica sets")
public void testMongoWithReplicaSets() {
MongoClient mongo = ctx.getBean(MongoClient.class);
assertEquals(2, mongo.getAllAddress().size());
List<ServerAddress> servers = mongo.getAllAddress();
assertEquals("127.0.0.1", servers.get(0).getHost());
assertEquals("localhost", servers.get(1).getHost());
assertEquals(10001, servers.get(0).getPort());
assertEquals(10002, servers.get(1).getPort());
MongoTemplate template = new MongoTemplate(mongo, "admin");
Document result = template.executeCommand("{replSetGetStatus : 1}");
assertEquals("blort", result.get("set").toString());
}
Aggregations