Search in sources :

Example 1 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project commons-dao by reportportal.

the class TestConfig method mongoDbFactory.

@Bean
@Primary
public MongoDbFactory mongoDbFactory() {
    final Fongo fongo = new Fongo("InMemoryMongo");
    SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(MockMongoClient.create(fongo), "reportportal");
    mongoDbFactory.setWriteConcern(WriteConcern.ACKNOWLEDGED);
    return mongoDbFactory;
}
Also used : Fongo(com.github.fakemongo.Fongo) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory)

Example 2 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project service-authorization by reportportal.

the class FakeMongoConfig method mongoDbFactory.

@Bean
@Primary
public MongoDbFactory mongoDbFactory() {
    final Fongo fongo = new Fongo("InMemoryMongo");
    SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(MockMongoClient.create(fongo), "reportportal");
    mongoDbFactory.setWriteConcern(WriteConcern.ACKNOWLEDGED);
    return mongoDbFactory;
}
Also used : Fongo(com.github.fakemongo.Fongo) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory)

Example 3 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project spring-data-mongodb by spring-projects.

the class DefaultMessageListenerContainerTests method setUp.

@Before
public void setUp() {
    dbFactory = new SimpleMongoDbFactory(new MongoClient(), DATABASE_NAME);
    template = new MongoTemplate(dbFactory);
    template.dropCollection(COLLECTION_NAME);
    collection = template.getCollection(COLLECTION_NAME);
    messageListener = new CollectingMessageListener<>();
}
Also used : MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) Before(org.junit.Before)

Example 4 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project spring-integration-samples by spring-projects.

the class DemoUtils method prepareMongoFactory.

public static MongoDbFactory prepareMongoFactory(String... additionalCollectionToDrop) throws Exception {
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
    MongoTemplate template = new MongoTemplate(mongoDbFactory);
    template.dropCollection("messages");
    template.dropCollection("data");
    for (String additionalCollection : additionalCollectionToDrop) {
        template.dropCollection(additionalCollection);
    }
    return mongoDbFactory;
}
Also used : MongoClient(com.mongodb.MongoClient) MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate)

Example 5 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project ocvn by devgateway.

the class MongoTemplateConfig method mongoTemplate.

@Bean(autowire = Autowire.BY_NAME, name = "mongoTemplate")
public MongoTemplate mongoTemplate() throws Exception {
    MongoTemplate template = new MongoTemplate(new SimpleMongoDbFactory(new MongoClientURI(properties.getUri())));
    ((MappingMongoConverter) template.getConverter()).setCustomConversions(customConversions);
    return template;
}
Also used : SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MongoClientURI(com.mongodb.MongoClientURI) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) Bean(org.springframework.context.annotation.Bean)

Aggregations

SimpleMongoDbFactory (org.springframework.data.mongodb.core.SimpleMongoDbFactory)51 MongoClient (com.mongodb.MongoClient)38 Test (org.junit.Test)28 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)28 AbstractBatchingMessageGroupStore (org.springframework.integration.store.AbstractBatchingMessageGroupStore)16 MessageGroupStore (org.springframework.integration.store.MessageGroupStore)16 GenericMessage (org.springframework.messaging.support.GenericMessage)14 MessageGroup (org.springframework.integration.store.MessageGroup)12 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)10 Bean (org.springframework.context.annotation.Bean)9 MongoDbFactory (org.springframework.data.mongodb.MongoDbFactory)8 MappingMongoConverter (org.springframework.data.mongodb.core.convert.MappingMongoConverter)8 MessageStore (org.springframework.integration.store.MessageStore)8 MongoClientURI (com.mongodb.MongoClientURI)6 Net (de.flapdoodle.embed.mongo.config.Net)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)4 ClaimCheckInTransformer (org.springframework.integration.transformer.ClaimCheckInTransformer)4 ClaimCheckOutTransformer (org.springframework.integration.transformer.ClaimCheckOutTransformer)4 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3