Skip to content

Commit 7c06b6c

Browse files
committed
chore: Upgrade tests to use JUnit 5
1 parent 875f577 commit 7c06b6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1820
-2010
lines changed

google-cloud-bigquerystorage/pom.xml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@
7373
<groupId>io.grpc</groupId>
7474
<artifactId>grpc-protobuf</artifactId>
7575
</dependency>
76-
<dependency>
77-
<groupId>io.grpc</groupId>
78-
<artifactId>grpc-util</artifactId>
79-
</dependency>
8076
<dependency>
8177
<groupId>com.google.api</groupId>
8278
<artifactId>api-common</artifactId>
@@ -197,6 +193,23 @@
197193
<artifactId>junit</artifactId>
198194
<scope>test</scope>
199195
</dependency>
196+
<dependency>
197+
<groupId>org.junit.jupiter</groupId>
198+
<artifactId>junit-jupiter-api</artifactId>
199+
<scope>test</scope>
200+
</dependency>
201+
<dependency>
202+
<groupId>org.junit.jupiter</groupId>
203+
<artifactId>junit-jupiter-engine</artifactId>
204+
<scope>test</scope>
205+
</dependency>
206+
<!-- The generated tests from gapic-generator are still generated with JUnit4. -->
207+
<!-- Remove once they are migrated to JUnit 5.x+ -->
208+
<dependency>
209+
<groupId>org.junit.vintage</groupId>
210+
<artifactId>junit-vintage-engine</artifactId>
211+
<scope>test</scope>
212+
</dependency>
200213
<dependency>
201214
<groupId>com.google.http-client</groupId>
202215
<artifactId>google-http-client</artifactId>
@@ -237,12 +250,6 @@
237250
<artifactId>protobuf-java-util</artifactId>
238251
<scope>test</scope>
239252
</dependency>
240-
241-
<dependency>
242-
<groupId>io.grpc</groupId>
243-
<artifactId>grpc-testing</artifactId>
244-
<scope>test</scope>
245-
</dependency>
246253
<dependency>
247254
<groupId>com.google.cloud</groupId>
248255
<artifactId>google-cloud-bigquery</artifactId>
@@ -332,6 +339,10 @@
332339
<artifactId>opentest4j</artifactId>
333340
<version>${opentest4j.version}</version>
334341
</dependency>
342+
<dependency>
343+
<groupId>org.junit.jupiter</groupId>
344+
<artifactId>junit-jupiter-engine</artifactId>
345+
</dependency>
335346
<dependency>
336347
<groupId>org.junit.vintage</groupId>
337348
<artifactId>junit-vintage-engine</artifactId>
@@ -345,6 +356,11 @@
345356
<artifactId>maven-surefire-plugin</artifactId>
346357
<version>${surefire.version}</version>
347358
<dependencies>
359+
<dependency>
360+
<groupId>org.junit.jupiter</groupId>
361+
<artifactId>junit-jupiter-engine</artifactId>
362+
<version>${junit-vintage-engine.version}</version>
363+
</dependency>
348364
<dependency>
349365
<groupId>org.junit.vintage</groupId>
350366
<artifactId>junit-vintage-engine</artifactId>

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/util/ErrorsTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,22 @@
1515
*/
1616
package com.google.cloud.bigquery.storage.util;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertFalse;
20-
import static org.junit.Assert.assertNull;
21-
import static org.junit.Assert.assertTrue;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
import static org.junit.jupiter.api.Assertions.assertFalse;
20+
import static org.junit.jupiter.api.Assertions.assertNull;
21+
import static org.junit.jupiter.api.Assertions.assertTrue;
2222

2323
import com.google.protobuf.Duration;
2424
import com.google.protobuf.Parser;
2525
import com.google.rpc.RetryInfo;
2626
import io.grpc.Metadata;
2727
import io.grpc.Status;
28-
import org.junit.Test;
29-
import org.junit.runner.RunWith;
30-
import org.junit.runners.JUnit4;
28+
import org.junit.jupiter.api.Test;
3129

32-
@RunWith(JUnit4.class)
33-
public class ErrorsTest {
30+
class ErrorsTest {
3431

3532
@Test
36-
public void testRetryableInternalForRstErrors() {
33+
void testRetryableInternalForRstErrors() {
3734
assertTrue(
3835
Errors.isRetryableInternalStatus(
3936
Status.INTERNAL.withDescription(
@@ -46,21 +43,21 @@ public void testRetryableInternalForRstErrors() {
4643
}
4744

4845
@Test
49-
public void testNonRetryableInternalError() {
46+
void testNonRetryableInternalError() {
5047
assertFalse(Errors.isRetryableInternalStatus(Status.INTERNAL));
5148
assertFalse(Errors.isRetryableInternalStatus(Status.INTERNAL.withDescription("Server error.")));
5249
}
5350

5451
@Test
55-
public void testNonRetryableOtherError() {
52+
void testNonRetryableOtherError() {
5653
assertFalse(
5754
Errors.isRetryableInternalStatus(
5855
Status.DATA_LOSS.withDescription(
5956
"RST_STREAM closed stream. HTTP/2 error code: INTERNAL_ERROR")));
6057
}
6158

6259
@Test
63-
public void testIsRetryableStatus() {
60+
void testIsRetryableStatus() {
6461
Errors.IsRetryableStatusResult result =
6562
Errors.isRetryableStatus(
6663
Status.INTERNAL.withDescription(

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/BQTableSchemaToProtoDescriptorTest.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
package com.google.cloud.bigquery.storage.v1;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertNotNull;
20-
import static org.junit.Assert.assertTrue;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
import static org.junit.jupiter.api.Assertions.assertNotNull;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
2121

2222
import com.google.cloud.bigquery.storage.test.JsonTest;
2323
import com.google.cloud.bigquery.storage.test.SchemaTest;
@@ -29,12 +29,9 @@
2929
import com.google.protobuf.Int64Value;
3030
import java.util.HashMap;
3131
import java.util.Map;
32-
import org.junit.Test;
33-
import org.junit.runner.RunWith;
34-
import org.junit.runners.JUnit4;
32+
import org.junit.jupiter.api.Test;
3533

36-
@RunWith(JUnit4.class)
37-
public class BQTableSchemaToProtoDescriptorTest {
34+
class BQTableSchemaToProtoDescriptorTest {
3835
// This is a map between the TableFieldSchema.Type and the descriptor it is supposed to
3936
// produce. The produced descriptor will be used to check against the entry values here.
4037
private static Map<TableFieldSchema.Type, Descriptor> BQTableTypeToCorrectProtoDescriptorTest =
@@ -82,7 +79,7 @@ private void assertDescriptorsAreEqual(Descriptor expected, Descriptor actual) {
8279
// Check type
8380
FieldDescriptor.Type convertedType = convertedField.getType();
8481
FieldDescriptor.Type originalType = expectedField.getType();
85-
assertEquals(convertedField.getName(), convertedType, originalType);
82+
assertEquals(convertedType, originalType, convertedField.getName());
8683
// Check mode
8784
assertEquals(expectedField.isRepeated(), convertedField.isRepeated());
8885
assertEquals(expectedField.isRequired(), convertedField.isRequired());
@@ -95,7 +92,7 @@ private void assertDescriptorsAreEqual(Descriptor expected, Descriptor actual) {
9592
}
9693

9794
@Test
98-
public void testSimpleTypes() throws Exception {
95+
void testSimpleTypes() throws Exception {
9996
for (Map.Entry<TableFieldSchema.Type, Descriptor> entry :
10097
BQTableTypeToCorrectProtoDescriptorTest.entrySet()) {
10198
final TableFieldSchema tableFieldSchema =
@@ -114,7 +111,7 @@ public void testSimpleTypes() throws Exception {
114111

115112
// BQ Timestamp field with higher precision (12) is mapped to a String protobuf type (not int64)
116113
@Test
117-
public void testTimestampType_higherTimestampPrecision()
114+
void testTimestampType_higherTimestampPrecision()
118115
throws Descriptors.DescriptorValidationException {
119116
TableFieldSchema tableFieldSchema =
120117
TableFieldSchema.newBuilder()
@@ -130,7 +127,7 @@ public void testTimestampType_higherTimestampPrecision()
130127
}
131128

132129
@Test
133-
public void testRange() throws Exception {
130+
void testRange() throws Exception {
134131
final TableSchema tableSchema =
135132
TableSchema.newBuilder()
136133
.addFields(
@@ -200,7 +197,7 @@ public void testRange() throws Exception {
200197
}
201198

202199
@Test
203-
public void testStructSimple() throws Exception {
200+
void testStructSimple() throws Exception {
204201
final TableFieldSchema stringType =
205202
TableFieldSchema.newBuilder()
206203
.setType(TableFieldSchema.Type.STRING)
@@ -221,7 +218,7 @@ public void testStructSimple() throws Exception {
221218
}
222219

223220
@Test
224-
public void testStructComplex() throws Exception {
221+
void testStructComplex() throws Exception {
225222
final TableFieldSchema test_int =
226223
TableFieldSchema.newBuilder()
227224
.setType(TableFieldSchema.Type.INT64)
@@ -467,7 +464,7 @@ public void testStructComplex() throws Exception {
467464
}
468465

469466
@Test
470-
public void testCasingComplexStruct() throws Exception {
467+
void testCasingComplexStruct() throws Exception {
471468
final TableFieldSchema required =
472469
TableFieldSchema.newBuilder()
473470
.setType(TableFieldSchema.Type.INT64)
@@ -547,7 +544,7 @@ public void testCasingComplexStruct() throws Exception {
547544
}
548545

549546
@Test
550-
public void testOptions() throws Exception {
547+
void testOptions() throws Exception {
551548
final TableFieldSchema required =
552549
TableFieldSchema.newBuilder()
553550
.setType(TableFieldSchema.Type.INT64)
@@ -578,7 +575,7 @@ public void testOptions() throws Exception {
578575
}
579576

580577
@Test
581-
public void testDescriptorReuseDuringCreation() throws Exception {
578+
void testDescriptorReuseDuringCreation() throws Exception {
582579
final TableFieldSchema test_int =
583580
TableFieldSchema.newBuilder()
584581
.setType(TableFieldSchema.Type.INT64)
@@ -635,7 +632,7 @@ public void testDescriptorReuseDuringCreation() throws Exception {
635632
}
636633

637634
@Test
638-
public void testNestedFlexibleFieldName() throws Exception {
635+
void testNestedFlexibleFieldName() throws Exception {
639636
final TableFieldSchema stringField =
640637
TableFieldSchema.newBuilder()
641638
.setType(TableFieldSchema.Type.STRING)
@@ -663,7 +660,7 @@ public void testNestedFlexibleFieldName() throws Exception {
663660
}
664661

665662
@Test
666-
public void timestampField_defaultPrecision() throws Exception {
663+
void timestampField_defaultPrecision() throws Exception {
667664
TableFieldSchema timestampField =
668665
TableFieldSchema.newBuilder()
669666
.setType(TableFieldSchema.Type.TIMESTAMP)
@@ -676,7 +673,7 @@ public void timestampField_defaultPrecision() throws Exception {
676673
}
677674

678675
@Test
679-
public void timestampField_picosecondPrecision() throws Exception {
676+
void timestampField_picosecondPrecision() throws Exception {
680677
TableFieldSchema timestampField =
681678
TableFieldSchema.newBuilder()
682679
.setType(TableFieldSchema.Type.TIMESTAMP)
@@ -690,7 +687,7 @@ public void timestampField_picosecondPrecision() throws Exception {
690687
}
691688

692689
@Test
693-
public void timestampField_unexpectedPrecision() throws Exception {
690+
void timestampField_unexpectedPrecision() throws Exception {
694691
TableFieldSchema timestampField =
695692
TableFieldSchema.newBuilder()
696693
.setType(TableFieldSchema.Type.TIMESTAMP)

0 commit comments

Comments
 (0)