From 297d195e338259238bd41458f35e3589267ba15f Mon Sep 17 00:00:00 2001 From: nnegrey Date: Mon, 26 Mar 2018 16:31:06 -0700 Subject: [PATCH] Add timeout for tests --- video/beta/src/main/java/com/example/video/Detect.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/video/beta/src/main/java/com/example/video/Detect.java b/video/beta/src/main/java/com/example/video/Detect.java index 6a986b70dda..25512b7466e 100644 --- a/video/beta/src/main/java/com/example/video/Detect.java +++ b/video/beta/src/main/java/com/example/video/Detect.java @@ -35,6 +35,7 @@ import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient; import com.google.cloud.videointelligence.v1p1beta1.WordInfo; import java.io.IOException; +import java.util.concurrent.TimeUnit; public class Detect { /** @@ -117,7 +118,8 @@ public static void analyzeFacesBoundingBoxes(String gcsUri) throws Exception { System.out.println("Waiting for operation to complete..."); boolean faceFound = false; // Display the results - for (VideoAnnotationResults results : response.get().getAnnotationResultsList()) { + for (VideoAnnotationResults results : response.get(900, TimeUnit.SECONDS) + .getAnnotationResultsList()) { int faceCount = 0; // Display the results for each face for (FaceDetectionAnnotation faceAnnotation : results.getFaceDetectionAnnotationsList()) { @@ -194,7 +196,8 @@ public static void analyzeFaceEmotions(String gcsUri) throws Exception { System.out.println("Waiting for operation to complete..."); boolean faceFound = false; // Display the results - for (VideoAnnotationResults results : response.get().getAnnotationResultsList()) { + for (VideoAnnotationResults results : response.get(600, TimeUnit.SECONDS) + .getAnnotationResultsList()) { int faceCount = 0; // Display the results for each face for (FaceDetectionAnnotation faceAnnotation : results.getFaceDetectionAnnotationsList()) { @@ -271,7 +274,8 @@ public static void speechTranscription(String gcsUri) throws Exception { System.out.println("Waiting for operation to complete..."); // Display the results - for (VideoAnnotationResults results : response.get().getAnnotationResultsList()) { + for (VideoAnnotationResults results : response.get(180, TimeUnit.SECONDS) + .getAnnotationResultsList()) { for (SpeechTranscription speechTranscription : results.getSpeechTranscriptionsList()) { try { // Print the transcription