@@ -59,7 +59,7 @@ public void testAggregation() {
59
59
60
60
@ Test
61
61
public void testOldAggregationWithOut () {
62
- checkServerVersion (2.5 );
62
+ checkServerVersion (2.6 );
63
63
List <DBObject > pipeline = new ArrayList <DBObject >(buildPipeline ());
64
64
pipeline .add (new BasicDBObject ("$out" , "aggCollection" ));
65
65
final AggregationOutput out = collection .aggregate (pipeline );
@@ -70,7 +70,7 @@ public void testOldAggregationWithOut() {
70
70
71
71
@ Test
72
72
public void testExplain () {
73
- checkServerVersion (2.5 );
73
+ checkServerVersion (2.6 );
74
74
List <DBObject > pipeline = new ArrayList <DBObject >(buildPipeline ());
75
75
pipeline .add (new BasicDBObject ("$out" , "aggCollection" ));
76
76
final CommandResult out = collection .explainAggregate (pipeline , AggregationOptions .builder ()
@@ -126,7 +126,7 @@ private List<DBObject> buildPipeline() {
126
126
127
127
@ Test
128
128
public void testAggregationCursor () {
129
- checkServerVersion (2.5 );
129
+ checkServerVersion (2.6 );
130
130
final List <DBObject > pipeline = prepareData ();
131
131
132
132
verify (pipeline , AggregationOptions .builder ()
@@ -149,7 +149,7 @@ public void testAggregationCursor() {
149
149
150
150
@ Test
151
151
public void testInlineAndDollarOut () {
152
- checkServerVersion (2.5 );
152
+ checkServerVersion (2.6 );
153
153
String aggCollection = "aggCollection" ;
154
154
database .getCollection (aggCollection )
155
155
.drop ();
@@ -168,7 +168,7 @@ public void testInlineAndDollarOut() {
168
168
169
169
@ Test
170
170
public void testDollarOut () {
171
- checkServerVersion (2.5 );
171
+ checkServerVersion (2.6 );
172
172
String aggCollection = "aggCollection" ;
173
173
database .getCollection (aggCollection )
174
174
.drop ();
@@ -185,7 +185,7 @@ public void testDollarOut() {
185
185
186
186
@ Test
187
187
public void testDollarOutOnSecondary () throws UnknownHostException {
188
- checkServerVersion (2.5 );
188
+ checkServerVersion (2.6 );
189
189
assumeTrue (isReplicaSet (cleanupMongo ));
190
190
191
191
ServerAddress primary = new ServerAddress ("localhost" );
@@ -207,7 +207,7 @@ public void testDollarOutOnSecondary() throws UnknownHostException {
207
207
@ Test
208
208
@ Ignore
209
209
public void testAggregateOnSecondary () throws UnknownHostException {
210
- checkServerVersion (2.5 );
210
+ checkServerVersion (2.6 );
211
211
assumeTrue (isReplicaSet (cleanupMongo ));
212
212
213
213
ServerAddress primary = new ServerAddress ("localhost" );
@@ -229,7 +229,7 @@ public void testAggregateOnSecondary() throws UnknownHostException {
229
229
@ Test
230
230
public void testMaxTime () {
231
231
assumeFalse (isSharded (getMongoClient ()));
232
- checkServerVersion (2.5 );
232
+ checkServerVersion (2.6 );
233
233
enableMaxTimeFailPoint ();
234
234
DBCollection collection = database .getCollection ("testMaxTime" );
235
235
try {
@@ -242,6 +242,26 @@ public void testMaxTime() {
242
242
}
243
243
}
244
244
245
+ @ Test
246
+ public void testInvalidPipelineThrowsError () {
247
+ checkServerVersion (2.6 );
248
+ DBCollection collection = database .getCollection ("testInvalidPipeline" );
249
+ List <DBObject > invalidPipeline = asList ((DBObject ) new BasicDBObject ("name" , "foo" ));
250
+ try {
251
+ collection .aggregate (invalidPipeline );
252
+ fail ("Show have thrown" );
253
+ } catch (CommandFailureException e ) {
254
+ // continue
255
+ }
256
+
257
+ try {
258
+ collection .aggregate (invalidPipeline , AggregationOptions .builder ().build ());
259
+ fail ("Show have thrown" );
260
+ } catch (CommandFailureException e ) {
261
+ // continue
262
+ }
263
+ }
264
+
245
265
public List <DBObject > prepareData () {
246
266
collection .remove (new BasicDBObject ());
247
267
0 commit comments