Skip to content

Commit bc1427e

Browse files
authored
chore: removed all catch clauses which were causing error stack trace not appearing in the test result (#464)
1 parent bb52e8a commit bc1427e

12 files changed

+40
-82
lines changed

video/pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,12 @@
6060
<version>1.1.2</version>
6161
<scope>test</scope>
6262
</dependency>
63+
<dependency>
64+
<groupId>com.google.cloud</groupId>
65+
<artifactId>google-cloud-core</artifactId>
66+
<version>1.94.0</version>
67+
<scope>test</scope>
68+
<classifier>tests</classifier>
69+
</dependency>
6370
</dependencies>
6471
</project>

video/src/main/java/beta/video/StreamingAnnotationToStorage.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@
2727
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;
2828
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
2929
import com.google.protobuf.ByteString;
30+
import io.grpc.StatusRuntimeException;
3031
import java.io.IOException;
3132
import java.nio.file.Files;
3233
import java.nio.file.Path;
3334
import java.nio.file.Paths;
3435
import java.util.Arrays;
36+
import java.util.concurrent.TimeoutException;
3537

3638
public class StreamingAnnotationToStorage {
3739

3840
// Perform streaming video detection for explicit content
39-
static void streamingAnnotationToStorage(String filePath, String gcsUri) {
41+
static void streamingAnnotationToStorage(String filePath, String gcsUri)
42+
throws IOException, TimeoutException, StatusRuntimeException {
4043
// String filePath = "path_to_your_video_file";
4144
// String gcsUri = "gs://BUCKET_ID";
4245

@@ -89,8 +92,6 @@ static void streamingAnnotationToStorage(String filePath, String gcsUri) {
8992
for (StreamingAnnotateVideoResponse response : call) {
9093
System.out.format("Storage Uri: %s\n", response.getAnnotationResultsUri());
9194
}
92-
} catch (IOException e) {
93-
e.printStackTrace();
9495
}
9596
}
9697
}

video/src/main/java/beta/video/StreamingAutoMlClassification.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@
3535
import java.nio.file.Path;
3636
import java.nio.file.Paths;
3737
import java.util.Arrays;
38+
import java.util.concurrent.TimeoutException;
3839

3940
class StreamingAutoMlClassification {
4041

4142
// Perform streaming video classification with an AutoML Model
4243
static void streamingAutoMlClassification(String filePath, String projectId, String modelId)
43-
throws StatusRuntimeException, IOException {
44+
throws TimeoutException, StatusRuntimeException, IOException {
4445
// String filePath = "path_to_your_video_file";
4546
// String projectId = "YOUR_GCP_PROJECT_ID";
4647
// String modelId = "YOUR_AUTO_ML_CLASSIFICATION_MODEL_ID";

video/src/main/java/beta/video/StreamingExplicitContentDetection.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@
2828
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;
2929
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
3030
import com.google.protobuf.ByteString;
31+
import io.grpc.StatusRuntimeException;
3132
import java.io.IOException;
3233
import java.nio.file.Files;
3334
import java.nio.file.Path;
3435
import java.nio.file.Paths;
3536
import java.util.Arrays;
37+
import java.util.concurrent.TimeoutException;
3638

3739
class StreamingExplicitContentDetection {
3840

3941
// Perform streaming video detection for explicit content
40-
static void streamingExplicitContentDetection(String filePath) {
42+
static void streamingExplicitContentDetection(String filePath)
43+
throws IOException, TimeoutException, StatusRuntimeException {
4144
// String filePath = "path_to_your_video_file";
4245

4346
try (StreamingVideoIntelligenceServiceClient client =
@@ -92,8 +95,6 @@ static void streamingExplicitContentDetection(String filePath) {
9295
System.out.format("\tPornography: %s", frame.getPornographyLikelihood());
9396
}
9497
}
95-
} catch (IOException e) {
96-
e.printStackTrace();
9798
}
9899
}
99100
}

video/src/main/java/beta/video/StreamingLabelDetection.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@
2929
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;
3030
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
3131
import com.google.protobuf.ByteString;
32+
import io.grpc.StatusRuntimeException;
3233
import java.io.IOException;
3334
import java.nio.file.Files;
3435
import java.nio.file.Path;
3536
import java.nio.file.Paths;
3637
import java.util.Arrays;
38+
import java.util.concurrent.TimeoutException;
3739

3840
class StreamingLabelDetection {
3941

4042
// Perform streaming video label detection
41-
static void streamingLabelDetection(String filePath) {
43+
static void streamingLabelDetection(String filePath)
44+
throws IOException, TimeoutException, StatusRuntimeException {
4245
// String filePath = "path_to_your_video_file";
4346

4447
try (StreamingVideoIntelligenceServiceClient client =
@@ -95,8 +98,6 @@ static void streamingLabelDetection(String filePath) {
9598
System.out.format("%fs: %s (%f)\n", offset, entity, confidence);
9699
}
97100
}
98-
} catch (IOException e) {
99-
e.printStackTrace();
100101
}
101102
}
102103
}

video/src/main/java/beta/video/StreamingObjectTracking.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@
2929
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;
3030
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
3131
import com.google.protobuf.ByteString;
32+
import io.grpc.StatusRuntimeException;
3233
import java.io.IOException;
3334
import java.nio.file.Files;
3435
import java.nio.file.Path;
3536
import java.nio.file.Paths;
3637
import java.util.Arrays;
38+
import java.util.concurrent.TimeoutException;
3739

3840
class StreamingObjectTracking {
3941

4042
// Perform streaming video object tracking
41-
static void streamingObjectTracking(String filePath) {
43+
static void streamingObjectTracking(String filePath)
44+
throws IOException, TimeoutException, StatusRuntimeException {
4245
// String filePath = "path_to_your_video_file";
4346

4447
try (StreamingVideoIntelligenceServiceClient client =
@@ -104,8 +107,6 @@ static void streamingObjectTracking(String filePath) {
104107
System.out.format("\tBottom: %f\n", frame.getNormalizedBoundingBox().getBottom());
105108
}
106109
}
107-
} catch (IOException e) {
108-
e.printStackTrace();
109110
}
110111
}
111112
}

video/src/test/java/beta/video/StreamingAnnotationToStorageIT.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import com.google.cloud.storage.Storage.BlobListOption;
2525
import com.google.cloud.storage.StorageOptions;
2626
import java.io.ByteArrayOutputStream;
27+
import java.io.IOException;
2728
import java.io.PrintStream;
29+
import java.util.concurrent.TimeoutException;
2830
import org.junit.After;
2931
import org.junit.Before;
3032
import org.junit.Test;
@@ -58,7 +60,7 @@ public void tearDown() {
5860
}
5961

6062
@Test
61-
public void testStreamingAnnotationToStorage() {
63+
public void testStreamingAnnotationToStorage() throws IOException, TimeoutException {
6264
String gcsUri = String.format("gs://%s/%s", PROJECT_ID, OUTPUT_PREFIX);
6365
StreamingAnnotationToStorage.streamingAnnotationToStorage("resources/cat.mp4", gcsUri);
6466
String got = bout.toString();

video/src/test/java/beta/video/StreamingExplicitContentDetectionIT.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020

2121
import java.io.ByteArrayOutputStream;
22+
import java.io.IOException;
2223
import java.io.PrintStream;
24+
import java.util.concurrent.TimeoutException;
2325
import org.junit.After;
2426
import org.junit.Before;
2527
import org.junit.Test;
@@ -50,7 +52,7 @@ public void tearDown() {
5052
}
5153

5254
@Test
53-
public void testStreamingExplicitContent() {
55+
public void testStreamingExplicitContent() throws IOException, TimeoutException {
5456
StreamingExplicitContentDetection.streamingExplicitContentDetection("resources/cat.mp4");
5557
String got = bout.toString();
5658

video/src/test/java/beta/video/StreamingLabelDetectionIT.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020

2121
import java.io.ByteArrayOutputStream;
22+
import java.io.IOException;
2223
import java.io.PrintStream;
24+
import java.util.concurrent.TimeoutException;
2325
import org.junit.After;
2426
import org.junit.Before;
2527
import org.junit.Test;
@@ -50,7 +52,7 @@ public void tearDown() {
5052
}
5153

5254
@Test
53-
public void testStreamingLabelDetection() {
55+
public void testStreamingLabelDetection() throws IOException, TimeoutException {
5456
StreamingLabelDetection.streamingLabelDetection("resources/cat.mp4");
5557
String got = bout.toString();
5658

video/src/test/java/beta/video/StreamingObjectTrackingIT.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020

2121
import java.io.ByteArrayOutputStream;
22+
import java.io.IOException;
2223
import java.io.PrintStream;
24+
import java.util.concurrent.TimeoutException;
2325
import org.junit.After;
2426
import org.junit.Before;
2527
import org.junit.Test;
@@ -50,7 +52,7 @@ public void tearDown() {
5052
}
5153

5254
@Test
53-
public void testStreamingObjectTracking() {
55+
public void testStreamingObjectTracking() throws IOException, TimeoutException {
5456
StreamingObjectTracking.streamingObjectTracking("resources/cat.mp4");
5557
String got = bout.toString();
5658

video/src/test/java/video/DetectTextTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

21+
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
2122
import com.google.cloud.videointelligence.v1.TextAnnotation;
2223
import com.google.cloud.videointelligence.v1.VideoAnnotationResults;
2324
import java.io.ByteArrayOutputStream;
@@ -46,7 +47,8 @@ public class DetectTextTest {
4647
"METRO",
4748
"RUE",
4849
"CARLO");
49-
@Rule public Retry retry = new Retry(3);
50+
@Rule
51+
public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);
5052
private ByteArrayOutputStream bout;
5153
private PrintStream out;
5254
private PrintStream originalPrintStream;

video/src/test/java/video/Retry.java

-64
This file was deleted.

0 commit comments

Comments
 (0)