File tree Expand file tree Collapse file tree 6 files changed +32
-9
lines changed
main/resources/org/springframework/data/mongodb/config
java/org/springframework/data/mongodb/config
resources/org/springframework/data/mongodb Expand file tree Collapse file tree 6 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ The MongoClientURI string.]]></xsd:documentation>
137137</xsd : documentation >
138138</xsd : annotation >
139139</xsd : attribute >
140- <xsd : attribute name =" create-query-indexes" type =" xsd:boolean " default =" false" >
140+ <xsd : attribute name =" create-query-indexes" type =" xsd:string " default =" false" >
141141<xsd : annotation >
142142<xsd : documentation >
143143Enables creation of indexes for queries that get derived from the method name
@@ -541,7 +541,7 @@ This controls if the driver is allowed to read from secondaries or slaves. Defa
541541]]> </xsd : documentation >
542542</xsd : annotation >
543543</xsd : attribute >
544- <xsd : attribute name =" ssl" type =" xsd:boolean " >
544+ <xsd : attribute name =" ssl" type =" xsd:string " >
545545<xsd : annotation >
546546<xsd : documentation ><![CDATA[
547547This controls if the driver should us an SSL connection. Defaults to false.
@@ -739,7 +739,7 @@ The socket timeout for connections used for the cluster heartbeat.
739739]]> </xsd : documentation >
740740</xsd : annotation >
741741</xsd : attribute >
742- <xsd : attribute name =" ssl" type =" xsd:boolean " >
742+ <xsd : attribute name =" ssl" type =" xsd:string " >
743743<xsd : annotation >
744744<xsd : documentation ><![CDATA[
745745This controls if the driver should us an SSL connection. Defaults to false.
Original file line number Diff line number Diff line change 2929import org .springframework .context .ApplicationContext ;
3030import org .springframework .data .authentication .UserCredentials ;
3131import org .springframework .data .mongodb .MongoDbFactory ;
32+ import org .springframework .data .mongodb .core .MongoClientFactoryBean ;
3233import org .springframework .data .mongodb .core .MongoFactoryBean ;
3334import org .springframework .data .mongodb .core .MongoOperations ;
3435import org .springframework .data .mongodb .core .ReflectiveMongoOptionsInvokerTestUtil ;
3839import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
3940
4041import com .mongodb .Mongo ;
42+ import com .mongodb .MongoClientOptions ;
4143import com .mongodb .MongoOptions ;
4244import com .mongodb .WriteConcern ;
4345
@@ -101,6 +103,19 @@ public void testMongoSingletonWithSslEnabled() throws Exception {
101103assertTrue ("socketFactory should be a SSLSocketFactory" , options .getSocketFactory () instanceof SSLSocketFactory );
102104}
103105
106+ /**
107+ * @see DATAMONGO-1490
108+ */
109+ @ Test
110+ public void testMongoClientSingletonWithSslEnabled () {
111+
112+ assertTrue (ctx .containsBean ("mongoClientSsl" ));
113+ MongoClientFactoryBean mfb = (MongoClientFactoryBean ) ctx .getBean ("&mongoClientSsl" );
114+
115+ MongoClientOptions options = (MongoClientOptions ) getField (mfb , "mongoClientOptions" );
116+ assertTrue ("socketFactory should be a SSLSocketFactory" , options .getSocketFactory () instanceof SSLSocketFactory );
117+ }
118+
104119/**
105120 * @see DATAMONGO-764
106121 */
Original file line number Diff line number Diff line change 2929
3030<mongo : db-factory dbname =" database" mongo-ref =" mongo" />
3131
32+ <mongo : mongo-client id =" mongoClientSsl" >
33+ <mongo : client-options ssl =" ${mongoSsl.ssl}" />
34+ </mongo : mongo-client >
3235
33-
3436<mongo : db-factory id =" secondMongoDbFactory"
3537 host =" localhost"
3638 port =" 27017"
4951<mongo : mongo id =" defaultMongo" host =" localhost" port =" 27017" />
5052
5153<mongo : mongo id =" mongoSsl" host =" localhost" port =" 27017" >
52- <mongo : options ssl =" true " />
54+ <mongo : options ssl =" ${mongoSsl.ssl} " />
5355</mongo : mongo >
5456
5557<mongo : mongo id =" mongoSslWithCustomSslFactory" host =" localhost" port =" 27017" >
Original file line number Diff line number Diff line change @@ -10,3 +10,5 @@ mongo.socketKeepAlive=true
1010mongo.fsync =true
1111mongo.slaveOk =true
1212
13+ mongoSsl.ssl =true
14+
Original file line number Diff line number Diff line change 22<beans xmlns =" http://www.springframework.org/schema/beans"
33xmlns:mongo=" http://www.springframework.org/schema/data/mongo"
44xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
5- xmlns:util =" http://www.springframework.org/schema/util "
5+ xmlns:context =" http://www.springframework.org/schema/context "
66xsi:schemaLocation=" http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
77http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
8- http://www.springframework.org/schema/util http://www.springframework.org/schema/util /spring-util .xsd" >
8+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context /spring-context .xsd" >
99
10- <mongo : db-factory dbname =" repositories" />
10+ <context : property-placeholder
11+ location=" classpath:/org/springframework/data/mongodb/repository/mongo.properties" />
12+
13+ <mongo : db-factory dbname =" repositories" />
1114<mongo : mapping-converter base-package =" org.springframework.data.mongodb.repository" />
1215
1316<bean id =" mongoTemplate" class =" org.springframework.data.mongodb.core.MongoTemplate" >
1417<constructor-arg ref =" mongoDbFactory" />
1518<constructor-arg ref =" mappingConverter" />
1619</bean >
1720
18- <mongo : repositories base-package =" org.springframework.data.mongodb.repository" create-query-indexes =" true " />
21+ <mongo : repositories base-package =" org.springframework.data.mongodb.repository" create-query-indexes =" ${mongo.create-query-indexes} " />
1922
2023</beans >
Original file line number Diff line number Diff line change 1+ mongo.create-query-indexes =true
You can’t perform that action at this time.
0 commit comments