File tree Expand file tree Collapse file tree 3 files changed +52
-3
lines changed
test/java/com/opentok/test Expand file tree Collapse file tree 3 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -420,7 +420,7 @@ public Archive stopArchive(String archiveId) throws OpenTokException {
420
420
*
421
421
* @param archiveId The archive ID of the archive you want to delete.
422
422
*/
423
- // public void deleteArchive(String archiveId) throws OpenTokException {
424
- // HttpClient.makeDeleteRequest("/v2/partner/" + this.apiKey + "/archive/" + archiveId);
425
- // }
423
+ public void deleteArchive (String archiveId ) throws OpenTokException {
424
+ this .client . deleteArchive ( archiveId );
425
+ }
426
426
}
Original file line number Diff line number Diff line change @@ -208,6 +208,36 @@ public String stopArchive(String archiveId) {
208
208
return responseString ;
209
209
}
210
210
211
+ public String deleteArchive (String archiveId ) {
212
+ String responseString = null ;
213
+ Future <Response > request = null ;
214
+ String url = this .apiUrl +"/v2/partner/" +this .apiKey +"/archive/" +archiveId ;
215
+
216
+ try {
217
+ request = this .prepareDelete (url ).execute ();
218
+ } catch (IOException e ) {
219
+ // TODO: throw OpenTokException
220
+ e .printStackTrace ();
221
+ }
222
+
223
+ try {
224
+ Response response = request .get ();
225
+ // TODO: check response code
226
+ responseString = response .getResponseBody ();
227
+ } catch (InterruptedException e ) {
228
+ // TODO: throw OpenTokException
229
+ e .printStackTrace ();
230
+ } catch (ExecutionException e ) {
231
+ // TODO: throw OpenTokException
232
+ e .printStackTrace ();
233
+ } catch (IOException e ) {
234
+ // TODO: throw OpenTokException
235
+ e .printStackTrace ();
236
+ }
237
+
238
+ return responseString ;
239
+ }
240
+
211
241
// protected static String makeDeleteRequest(String resource) throws OpenTokException {
212
242
// BoundRequestBuilder get = client.prepareDelete(apiUrl + resource);
213
243
// addCommonHeaders(get);
Original file line number Diff line number Diff line change @@ -494,6 +494,8 @@ public void testStartArchive() throws OpenTokException {
494
494
assertNotNull (archive .getId ());
495
495
496
496
verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" ))
497
+ // TODO: find a way to match JSON without caring about spacing
498
+ //.withRequestBody(matching(".*"+".*"))
497
499
.withHeader ("X-TB-PARTNER-AUTH" , matching (this .apiKey +":" +this .apiSecret ))
498
500
.withHeader ("User-Agent" , matching (".*Opentok-Java-SDK/" + Version .VERSION +".*" )));
499
501
}
@@ -533,4 +535,21 @@ public void testStopArchive() throws OpenTokException {
533
535
.withHeader ("User-Agent" , matching (".*Opentok-Java-SDK/" + Version .VERSION +".*" )));
534
536
}
535
537
538
+ // TODO: test stop archive failure scenarios
539
+
540
+ @ Test
541
+ public void testDeleteArchive () throws OpenTokException {
542
+ String archiveId = "ARCHIVEID" ;
543
+ stubFor (delete (urlEqualTo ("/v2/partner/" +this .apiKey +"/archive/" +archiveId ))
544
+ .willReturn (aResponse ()
545
+ .withStatus (204 )
546
+ .withHeader ("Content-Type" , "application/json" )));
547
+
548
+ sdk .deleteArchive (archiveId );
549
+
550
+ verify (deleteRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive/" +archiveId ))
551
+ .withHeader ("X-TB-PARTNER-AUTH" , matching (this .apiKey +":" +this .apiSecret ))
552
+ .withHeader ("User-Agent" , matching (".*Opentok-Java-SDK/" + Version .VERSION +".*" )));
553
+ }
554
+
536
555
}
You can’t perform that action at this time.
0 commit comments