@ -18,11 +18,7 @@ package org.springframework.data.mongodb.config;
@@ -18,11 +18,7 @@ package org.springframework.data.mongodb.config;
import static org.hamcrest.Matchers.* ;
import static org.junit.Assert.* ;
import java.net.UnknownHostException ;
import java.util.List ;
import org.junit.Test ;
import org.springframework.beans.PropertyValue ;
import org.springframework.beans.factory.config.BeanDefinition ;
import org.springframework.beans.factory.config.ConstructorArgumentValues ;
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder ;
@ -36,7 +32,6 @@ import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
@@ -36,7 +32,6 @@ import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
import com.mongodb.DB ;
import com.mongodb.Mongo ;
import com.mongodb.MongoException ;
import com.mongodb.MongoURI ;
import com.mongodb.WriteConcern ;
@ -47,12 +42,11 @@ import com.mongodb.WriteConcern;
@@ -47,12 +42,11 @@ import com.mongodb.WriteConcern;
* /
public class MongoDbFactoryParserIntegrationTests {
@Test
public void testWriteConcern ( ) throws Exception {
SimpleMongoDbFactory dbFactory = new SimpleMongoDbFactory ( new Mongo ( "localhost" ) , "database" ) ;
dbFactory . setWriteConcern ( WriteConcern . SAFE ) ;
DB db = dbFactory . getDb ( ) ;
dbFactory . getDb ( ) ;
assertThat ( WriteConcern . SAFE , is ( dbFactory . getWriteConcern ( ) ) ) ;
}
@ -68,6 +62,19 @@ public class MongoDbFactoryParserIntegrationTests {
@@ -68,6 +62,19 @@ public class MongoDbFactoryParserIntegrationTests {
assertWriteConcern ( ctx , new WriteConcern ( "rack1" ) ) ;
}
/ * *
* @see DATAMONGO - 331
* /
@Test
public void readsReplicasWriteConcernCorrectly ( ) {
ApplicationContext ctx = new ClassPathXmlApplicationContext ( "namespace/db-factory-bean-custom-write-concern.xml" ) ;
MongoDbFactory factory = ctx . getBean ( "second" , MongoDbFactory . class ) ;
DB db = factory . getDb ( ) ;
assertThat ( db . getWriteConcern ( ) , is ( WriteConcern . REPLICAS_SAFE ) ) ;
}
private void assertWriteConcern ( ClassPathXmlApplicationContext ctx , WriteConcern expectedWriteConcern ) {
SimpleMongoDbFactory dbFactory = ctx . getBean ( "first" , SimpleMongoDbFactory . class ) ;
DB db = dbFactory . getDb ( ) ;