Skip to content

Commit e9dfaf9

Browse files
authored
chore: migrate tests in oauth2_http module from JUnit4 to JUnit5 - third iteration (#756) (#764)
1 parent d045247 commit e9dfaf9

File tree

4 files changed

+264
-277
lines changed

4 files changed

+264
-277
lines changed

oauth2_http/javatests/com/google/auth/oauth2/IdTokenCredentialsTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@
3131

3232
package com.google.auth.oauth2;
3333

34-
import static org.junit.Assert.assertEquals;
34+
import static org.junit.jupiter.api.Assertions.assertEquals;
3535

3636
import java.io.IOException;
37-
import org.junit.Test;
38-
import org.junit.runner.RunWith;
39-
import org.junit.runners.JUnit4;
37+
import org.junit.jupiter.api.Test;
4038

4139
/** Test case for {@link IdTokenCredentials}. */
42-
@RunWith(JUnit4.class)
43-
public class IdTokenCredentialsTest extends BaseSerializationTest {
40+
class IdTokenCredentialsTest extends BaseSerializationTest {
4441

4542
@Test
46-
public void hashCode_equals() throws IOException {
43+
void hashCode_equals() throws IOException {
4744
ComputeEngineCredentialsTest.MockMetadataServerTransportFactory transportFactory =
4845
new ComputeEngineCredentialsTest.MockMetadataServerTransportFactory();
4946
transportFactory.transport.setIdToken(ComputeEngineCredentialsTest.STANDARD_ID_TOKEN);
@@ -69,7 +66,7 @@ public void hashCode_equals() throws IOException {
6966
}
7067

7168
@Test
72-
public void toString_equals() throws IOException {
69+
void toString_equals() throws IOException {
7370
ComputeEngineCredentialsTest.MockMetadataServerTransportFactory transportFactory =
7471
new ComputeEngineCredentialsTest.MockMetadataServerTransportFactory();
7572
transportFactory.transport.setIdToken(ComputeEngineCredentialsTest.STANDARD_ID_TOKEN);
@@ -95,7 +92,7 @@ public void toString_equals() throws IOException {
9592
}
9693

9794
@Test
98-
public void serialize() throws IOException, ClassNotFoundException {
95+
void serialize() throws IOException, ClassNotFoundException {
9996

10097
ComputeEngineCredentialsTest.MockMetadataServerTransportFactory transportFactory =
10198
new ComputeEngineCredentialsTest.MockMetadataServerTransportFactory();

oauth2_http/javatests/com/google/auth/oauth2/IdTokenTest.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@
3131

3232
package com.google.auth.oauth2;
3333

34-
import static org.junit.Assert.assertEquals;
35-
import static org.junit.Assert.assertFalse;
36-
import static org.junit.Assert.assertTrue;
34+
import static org.junit.jupiter.api.Assertions.assertEquals;
35+
import static org.junit.jupiter.api.Assertions.assertFalse;
36+
import static org.junit.jupiter.api.Assertions.assertTrue;
3737

3838
import java.io.IOException;
3939
import java.util.Date;
40-
import org.junit.Test;
41-
import org.junit.runner.RunWith;
42-
import org.junit.runners.JUnit4;
40+
import org.junit.jupiter.api.Test;
4341

4442
/** Unit tests for AccessToken */
45-
@RunWith(JUnit4.class)
46-
public class IdTokenTest extends BaseSerializationTest {
43+
class IdTokenTest extends BaseSerializationTest {
4744

4845
private static final String TOKEN_1 =
4946
"eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0OTRiMWU3ODZjZGFkMDkyZTQyMzc2NmJiZTM3ZjU0ZWQ4N2IyMmQiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhdWQiOiJodHRwczovL2Zvby5iYXIiLCJhenAiOiJzdmMtMi00MjlAbWluZXJhbC1taW51dGlhLTgyMC5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbSIsInN1YiI6IjEwMDE0NzEwNjk5Njc2NDQ3OTA4NSIsImVtYWlsIjoic3ZjLTItNDI5QG1pbmVyYWwtbWludXRpYS04MjAuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaWF0IjoxNTY1Mzg3NTM4LCJleHAiOjE1NjUzOTExMzh9.foo";
@@ -52,30 +49,30 @@ public class IdTokenTest extends BaseSerializationTest {
5249
private static final Date EXPIRATION_DATE = new Date((long) 1565391138 * 1000);
5350

5451
@Test
55-
public void constructor() throws IOException {
52+
void constructor() throws IOException {
5653
IdToken idToken = IdToken.create(TOKEN_1);
5754
assertEquals(TOKEN_1, idToken.getTokenValue());
5855
assertEquals(EXPIRATION_DATE, idToken.getExpirationTime());
5956
}
6057

6158
@Test
62-
public void equals_true() throws IOException {
59+
void equals_true() throws IOException {
6360
IdToken accessToken = IdToken.create(TOKEN_1);
6461
IdToken otherAccessToken = IdToken.create(TOKEN_1);
6562
assertTrue(accessToken.equals(otherAccessToken));
6663
assertTrue(otherAccessToken.equals(accessToken));
6764
}
6865

6966
@Test
70-
public void equals_false_token() throws IOException {
67+
void equals_false_token() throws IOException {
7168
IdToken accessToken = IdToken.create(TOKEN_1);
7269
IdToken otherAccessToken = IdToken.create(TOKEN_2);
7370
assertFalse(accessToken.equals(otherAccessToken));
7471
assertFalse(otherAccessToken.equals(accessToken));
7572
}
7673

7774
@Test
78-
public void toString_test() throws IOException {
75+
void toString_test() throws IOException {
7976
IdToken accessToken = IdToken.create(TOKEN_1);
8077
String expectedToString =
8178
String.format(
@@ -85,14 +82,14 @@ public void toString_test() throws IOException {
8582
}
8683

8784
@Test
88-
public void hashCode_equals() throws IOException {
85+
void hashCode_equals() throws IOException {
8986
IdToken accessToken = IdToken.create(TOKEN_1);
9087
IdToken otherAccessToken = IdToken.create(TOKEN_1);
9188
assertEquals(accessToken.hashCode(), otherAccessToken.hashCode());
9289
}
9390

9491
@Test
95-
public void serialize() throws IOException, ClassNotFoundException {
92+
void serialize() throws IOException, ClassNotFoundException {
9693
IdToken accessToken = IdToken.create(TOKEN_1);
9794
IdToken deserializedAccessToken = serializeAndDeserialize(accessToken);
9895
assertEquals(accessToken, deserializedAccessToken);

0 commit comments

Comments
 (0)