use of com.mongodb.WriteConcern in project spring-data-mongodb by spring-projects.
the class MongoDbFactoryParserIntegrationTests method parsesCustomWriteConcern.
// DATAMONGO-2199
@Test
public void parsesCustomWriteConcern() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("namespace/db-factory-bean-custom-write-concern.xml");
assertWriteConcern(ctx, new WriteConcern("rack1"));
}
use of com.mongodb.WriteConcern in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testSecondMongoTemplateFactory.
// DATAMONGO-140
@Test
public void testSecondMongoTemplateFactory() {
assertThat(ctx.containsBean("anotherMongoTemplate")).isTrue();
MongoOperations operations = (MongoOperations) ctx.getBean("anotherMongoTemplate");
MongoDatabaseFactory dbf = (MongoDatabaseFactory) getField(operations, "mongoDbFactory");
assertThat(getField(dbf, "databaseName")).isEqualTo("database");
WriteConcern writeConcern = (WriteConcern) getField(operations, "writeConcern");
assertThat(writeConcern).isEqualTo(WriteConcern.ACKNOWLEDGED);
}
use of com.mongodb.WriteConcern in project spring-data-mongodb by spring-projects.
the class WriteConcernPropertyEditorUnitTests method createsWriteConcernForUnknownConstants.
@Test
public void createsWriteConcernForUnknownConstants() {
editor.setAsText("-1");
assertThat(editor.getValue()).isEqualTo(new WriteConcern("-1"));
}
use of com.mongodb.WriteConcern in project spring-data-mongodb by spring-projects.
the class ReactivePerformanceTests method executeWithWriteConcerns.
private void executeWithWriteConcerns(WriteConcernCallback callback) {
Constants constants = new Constants(WriteConcern.class);
for (String constantName : constants.getNames(null)) {
if (IGNORED_WRITE_CONCERNS.contains(constantName)) {
continue;
}
WriteConcern writeConcern = (WriteConcern) constants.asObject(constantName);
setupCollections();
callback.doWithWriteConcern(constantName, writeConcern);
}
}
use of com.mongodb.WriteConcern in project spring-data-mongodb by spring-projects.
the class ReactivePerformanceTests method writingObjectsUsingPlainDriver.
private long writingObjectsUsingPlainDriver(int numberOfPersons, WriteConcern concern) {
MongoCollection<Document> collection = mongo.getDatabase(DATABASE_NAME).getCollection("driver").withWriteConcern(concern);
List<Person> persons = getPersonObjects(numberOfPersons);
executeWatched(() -> persons.stream().map(it -> Mono.from(collection.insertOne(new Document(it.toDocument()))).block()));
return watch.getLastTaskTimeMillis();
}
Aggregations