@@ -131,7 +131,7 @@ void cleanUpGeneratedDatabases() throws DocumentClientException {
131
131
new SqlParameterCollection (new SqlParameter ("@id" , id ))),
132
132
null ).getQueryIterable ().iterator ().next ();
133
133
if (database != null ) {
134
- client .deleteDatabase (database .getSelfLink (), null );
134
+ client .deleteDatabase (database .getSelfLink (), null ). close (); ;
135
135
}
136
136
}
137
137
}
@@ -332,11 +332,11 @@ public void testDatabaseCrud() throws DocumentClientException {
332
332
Database oneDbFromRead = client .readDatabase (replacedDb .getSelfLink (), null ).getResource ();
333
333
Assert .assertEquals (replacedDb .getId (), oneDbFromRead .getId ());
334
334
// Delete database.
335
- client .deleteDatabase (replacedDb .getSelfLink (), null );
335
+ client .deleteDatabase (replacedDb .getSelfLink (), null ). close () ;
336
336
337
337
// Read database after deletion.
338
338
try {
339
- client .readDatabase (createdDb .getSelfLink (), null );
339
+ client .readDatabase (createdDb .getSelfLink (), null ). close () ;
340
340
Assert .fail ("Exception didn't happen." );
341
341
} catch (DocumentClientException e ) {
342
342
Assert .assertEquals (404 , e .getStatusCode ());
@@ -372,11 +372,11 @@ public void testCollectionCrud() throws DocumentClientException {
372
372
null ).getQueryIterable ().toList ();
373
373
Assert .assertTrue (collections .size () > 0 );
374
374
// Delete collection.
375
- client .deleteCollection (createdCollection .getSelfLink (), null );
375
+ client .deleteCollection (createdCollection .getSelfLink (), null ). close () ;
376
376
// Read collection after deletion.
377
377
378
378
try {
379
- client .readCollection (createdCollection .getSelfLink (), null );
379
+ client .readCollection (createdCollection .getSelfLink (), null ). close () ;
380
380
Assert .fail ("Exception didn't happen." );
381
381
} catch (DocumentClientException e ) {
382
382
Assert .assertEquals (404 , e .getStatusCode ());
@@ -397,7 +397,7 @@ public void testQueryIterableCrud() throws DocumentClientException {
397
397
// Create 10 documents.
398
398
for (int i = 0 ; i < numOfDocuments ; ++i ) {
399
399
Document documentDefinition = new Document ("{ 'name': 'For paging test' }" );
400
- client .createDocument (this .collectionForTest .getSelfLink (), documentDefinition , null , false );
400
+ client .createDocument (this .collectionForTest .getSelfLink (), documentDefinition , null , false ). close () ;
401
401
}
402
402
403
403
int numOfDocumentsPerPage = numOfDocuments / 5 ;
@@ -471,7 +471,7 @@ public void testCollectionIndexingPolicy() throws DocumentClientException {
471
471
" 'indexingMode': 'Lazy'" +
472
472
" }" +
473
473
"}" );
474
- client .deleteCollection (this .collectionForTest .getSelfLink (), null );
474
+ client .deleteCollection (this .collectionForTest .getSelfLink (), null ). close () ;
475
475
DocumentCollection lazyCollection = client .createCollection (this .databaseForTest .getSelfLink (),
476
476
lazyCollectionDefinition ,
477
477
null ).getResource ();
@@ -485,7 +485,7 @@ public void testCollectionIndexingPolicy() throws DocumentClientException {
485
485
" 'indexingMode': 'Consistent'" +
486
486
" }" +
487
487
"}" );
488
- client .deleteCollection (lazyCollection .getSelfLink (), null );
488
+ client .deleteCollection (lazyCollection .getSelfLink (), null ). close () ;
489
489
DocumentCollection consistentCollection = client .createCollection (this .databaseForTest .getSelfLink (),
490
490
consistentCollectionDefinition ,
491
491
null ).getResource ();
@@ -509,7 +509,7 @@ public void testCollectionIndexingPolicy() throws DocumentClientException {
509
509
" ]" +
510
510
" }" +
511
511
"}" );
512
- client .deleteCollection (consistentCollection .getSelfLink (), null );
512
+ client .deleteCollection (consistentCollection .getSelfLink (), null ). close () ;
513
513
DocumentCollection collectionWithSecondaryIndex = client .createCollection (this .databaseForTest .getSelfLink (),
514
514
collectionDefinition ,
515
515
null ).getResource ();
@@ -592,11 +592,11 @@ public void testDocumentCrud() throws DocumentClientException {
592
592
Assert .assertEquals (rr .getStatusCode (), HttpStatus .SC_NOT_MODIFIED );
593
593
594
594
// delete document
595
- client .deleteDocument (replacedDocument .getSelfLink (), null );
595
+ client .deleteDocument (replacedDocument .getSelfLink (), null ). close () ;
596
596
597
597
// read documents after deletion
598
598
try {
599
- client .readDocument (replacedDocument .getSelfLink (), null );
599
+ client .readDocument (replacedDocument .getSelfLink (), null ). close () ;
600
600
Assert .fail ("Exception didn't happen." );
601
601
} catch (DocumentClientException e ) {
602
602
Assert .assertEquals (404 , e .getStatusCode ());
@@ -738,7 +738,7 @@ public int read() throws IOException {
738
738
// Create attachment with invalid content type.
739
739
ReadableStream mediaStream = new ReadableStream ("stream content." );
740
740
try {
741
- client .createAttachment (document .getSelfLink (), mediaStream , invalidMediaOptions );
741
+ client .createAttachment (document .getSelfLink (), mediaStream , invalidMediaOptions ). close () ;
742
742
Assert .assertTrue (false ); // This line shouldn't execute.
743
743
} catch (DocumentClientException e ) {
744
744
Assert .assertEquals (400 , e .getStatusCode ());
@@ -755,7 +755,7 @@ public int read() throws IOException {
755
755
mediaStream = new ReadableStream ("stream content" );
756
756
// Create colliding attachment.
757
757
try {
758
- client .createAttachment (document .getSelfLink (), mediaStream , validMediaOptions );
758
+ client .createAttachment (document .getSelfLink (), mediaStream , validMediaOptions ). close () ;
759
759
Assert .fail ("Exception didn't happen." );
760
760
} catch (DocumentClientException e ) {
761
761
Assert .assertEquals (409 , e .getStatusCode ());
@@ -786,7 +786,7 @@ public int read() throws IOException {
786
786
attachment .set ("Author" , "new author" );
787
787
788
788
// Replace the attachment.
789
- client .replaceAttachment (attachment , null );
789
+ client .replaceAttachment (attachment , null ). close () ;
790
790
Assert .assertEquals ("Book" , attachment .getString ("MediaType" ));
791
791
Assert .assertEquals ("new author" , attachment .getString ("Author" ));
792
792
// Read attachment media.
@@ -829,7 +829,7 @@ public int read() throws IOException {
829
829
Assert .assertEquals (validAttachment .getMediaLink (), attachment .getMediaLink ());
830
830
Assert .assertEquals (validAttachment .getContentType (), attachment .getContentType ());
831
831
// Deleting attachment.
832
- client .deleteAttachment (attachment .getSelfLink (), null );
832
+ client .deleteAttachment (attachment .getSelfLink (), null ). close () ;
833
833
// read attachments after deletion
834
834
attachments = client .readAttachments (document .getSelfLink (), null ).getQueryIterable ().toList ();
835
835
Assert .assertEquals (0 , attachments .size ());
@@ -861,7 +861,7 @@ public void testTriggerCrud() throws DocumentClientException {
861
861
862
862
Document document = new Document ();
863
863
document .setId ("noname" );
864
- client .createDocument (this .collectionForTest .getSelfLink (), document , options , false );
864
+ client .createDocument (this .collectionForTest .getSelfLink (), document , options , false ). close () ;
865
865
866
866
// replace...
867
867
String id = GatewayTests .getUID ();
@@ -892,7 +892,7 @@ public void testTriggerCrud() throws DocumentClientException {
892
892
Assert .fail ("Query fail to find trigger" );
893
893
}
894
894
895
- client .deleteTrigger (newTrigger .getSelfLink (), null );
895
+ client .deleteTrigger (newTrigger .getSelfLink (), null ). close () ;
896
896
}
897
897
898
898
@ Test
@@ -942,7 +942,7 @@ public void testStoredProcedureCrud() throws DocumentClientException {
942
942
Assert .fail ("Query fail to find StoredProcedure" );
943
943
}
944
944
945
- client .deleteStoredProcedure (newStoredProcedure .getSelfLink (), null );
945
+ client .deleteStoredProcedure (newStoredProcedure .getSelfLink (), null ). close () ;
946
946
}
947
947
948
948
@ Test
@@ -1088,7 +1088,7 @@ public void testUserDefinedFunctionCrud() throws DocumentClientException {
1088
1088
Assert .fail ("Query fail to find UserDefinedFunction" );
1089
1089
}
1090
1090
}
1091
- client .deleteUserDefinedFunction (newUdf .getSelfLink (), null );
1091
+ client .deleteUserDefinedFunction (newUdf .getSelfLink (), null ). close () ;
1092
1092
}
1093
1093
1094
1094
@ Test
@@ -1126,10 +1126,10 @@ public void testUserCrud() throws DocumentClientException {
1126
1126
user = client .readUser (replacedUser .getSelfLink (), null ).getResource ();
1127
1127
Assert .assertEquals (replacedUser .getId (), user .getId ());
1128
1128
// Delete user.
1129
- client .deleteUser (user .getSelfLink (), null );
1129
+ client .deleteUser (user .getSelfLink (), null ). close () ;
1130
1130
// Read user after deletion.
1131
1131
try {
1132
- client .readUser (user .getSelfLink (), null );
1132
+ client .readUser (user .getSelfLink (), null ). close () ;
1133
1133
Assert .fail ("Exception didn't happen." );
1134
1134
} catch (DocumentClientException e ) {
1135
1135
Assert .assertEquals (404 , e .getStatusCode ());
@@ -1183,10 +1183,10 @@ public void testPermissionCrud() throws DocumentClientException {
1183
1183
permission = client .readPermission (replacedPermission .getSelfLink (), null ).getResource ();
1184
1184
Assert .assertEquals (replacedPermission .getId (), permission .getId ());
1185
1185
// Delete permission.
1186
- client .deletePermission (replacedPermission .getSelfLink (), null );
1186
+ client .deletePermission (replacedPermission .getSelfLink (), null ). close () ;
1187
1187
// Read permission after deletion.
1188
1188
try {
1189
- client .readPermission (permission .getSelfLink (), null );
1189
+ client .readPermission (permission .getSelfLink (), null ). close () ;
1190
1190
Assert .fail ("Exception didn't happen." );
1191
1191
} catch (DocumentClientException e ) {
1192
1192
Assert .assertEquals (404 , e .getStatusCode ());
@@ -1297,7 +1297,7 @@ public void testAuthorization() throws DocumentClientException {
1297
1297
clientForCollection1 .readCollection (collectionForTest .getSelfLink (), null ).getResource ();
1298
1298
// 2. Failure-- Use Col1 Permission to delete
1299
1299
try {
1300
- clientForCollection1 .deleteCollection (obtainedCollection1 .getSelfLink (), null );
1300
+ clientForCollection1 .deleteCollection (obtainedCollection1 .getSelfLink (), null ). close () ;
1301
1301
Assert .fail ("Exception didn't happen." );
1302
1302
} catch (DocumentClientException e ) {
1303
1303
Assert .assertEquals (403 , e .getStatusCode ());
0 commit comments