@@ -188,18 +188,14 @@ public void testDollarOutOnSecondary() throws UnknownHostException {
188
188
assumeTrue (isReplicaSet (cleanupMongo ));
189
189
190
190
ServerAddress primary = new ServerAddress (getPrimaryAsString (cleanupMongo ));
191
- MongoClient rsClient = new MongoClient (getMongoClientURI ());
192
- DB rsDatabase = rsClient .getDB (database .getName ());
193
- DBCollection aggCollection = rsDatabase .getCollection (collection .getName ());
194
- aggCollection .drop ();
195
191
196
192
final List <DBObject > pipeline = new ArrayList <DBObject >(prepareData ());
197
193
pipeline .add (new BasicDBObject ("$out" , "aggCollection" ));
198
194
AggregationOptions options = AggregationOptions .builder ()
199
195
.outputMode (OutputMode .CURSOR )
200
196
.build ();
201
- Cursor cursor = verify (pipeline , options , ReadPreference .secondary (), aggCollection );
202
- assertEquals (2 , rsDatabase .getCollection ("aggCollection" ).count ());
197
+ Cursor cursor = verify (pipeline , options , ReadPreference .secondary (), collection );
198
+ assertEquals (2 , database .getCollection ("aggCollection" ).count ());
203
199
assertEquals (primary .getSocketAddress (), cursor .getServerAddress ().getSocketAddress ());
204
200
}
205
201
@@ -209,21 +205,15 @@ public void testAggregateOnSecondary() throws UnknownHostException {
209
205
assumeTrue (isReplicaSet (cleanupMongo ));
210
206
211
207
ServerAddress primary = new ServerAddress (getPrimaryAsString (cleanupMongo ));
212
- ServerAddress secondary = new ServerAddress (getASecondaryAsString (cleanupMongo ));
213
- MongoClient rsClient = new MongoClient (asList (primary , secondary ));
214
- DB rsDatabase = rsClient .getDB (database .getName ());
215
- rsDatabase .dropDatabase ();
216
- DBCollection aggCollection = rsDatabase .getCollection (collection .getName ());
217
- aggCollection .drop ();
218
208
219
209
List <DBObject > pipeline = new ArrayList <DBObject >(prepareData ());
220
210
AggregationOptions options = AggregationOptions .builder ()
221
211
.outputMode (OutputMode .INLINE )
222
212
.build ();
223
- Cursor cursor = aggCollection .aggregate (pipeline , options , ReadPreference .secondary ());
213
+ Cursor cursor = collection .aggregate (pipeline , options , ReadPreference .secondary ());
224
214
assertNotEquals (primary , cursor .getServerAddress ());
225
215
226
- AggregationOutput aggregationOutput = aggCollection .aggregate (pipeline , ReadPreference .secondary ());
216
+ AggregationOutput aggregationOutput = collection .aggregate (pipeline , ReadPreference .secondary ());
227
217
assertNotEquals (primary , aggregationOutput .getServerUsed ());
228
218
}
229
219
@@ -280,7 +270,7 @@ public void testInvalidPipelineThrowsError() {
280
270
}
281
271
}
282
272
283
- public List <DBObject > prepareData () {
273
+ private List <DBObject > prepareData () {
284
274
collection .remove (new BasicDBObject ());
285
275
286
276
final DBObject foo = new BasicDBObject ("name" , "foo" ).append ("count" , 5 );
0 commit comments