Skip to content

Commit 5137ce2

Browse files
committed
chore: Revert Junit5 changes in samples directory
1 parent 5190866 commit 5137ce2

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-38
lines changed

samples/snippets/pom.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,6 @@
7777
<groupId>software.amazon.awssdk</groupId>
7878
<artifactId>regions</artifactId>
7979
</dependency>
80-
<dependency>
81-
<groupId>com.google.truth</groupId>
82-
<artifactId>truth</artifactId>
83-
<version>1.4.5</version>
84-
</dependency>
85-
<dependency>
86-
<groupId>org.junit.jupiter</groupId>
87-
<artifactId>junit-jupiter-api</artifactId>
88-
<version>5.11.4</version>
89-
<scope>test</scope>
90-
</dependency>
91-
<dependency>
92-
<groupId>org.junit.jupiter</groupId>
93-
<artifactId>junit-jupiter-engine</artifactId>
94-
<version>5.11.4</version>
95-
<scope>test</scope>
96-
</dependency>
9780
</dependencies>
9881

9982
</project>
100-

samples/snippets/src/test/java/SnippetsIT.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,30 @@
2727
import java.security.GeneralSecurityException;
2828
import java.util.Arrays;
2929
import java.util.List;
30-
import org.junit.jupiter.api.AfterEach;
31-
import org.junit.jupiter.api.AfterAll;
32-
import org.junit.jupiter.api.BeforeEach;
33-
import org.junit.jupiter.api.BeforeAll;
34-
import org.junit.jupiter.api.Test;
30+
import org.junit.After;
31+
import org.junit.AfterClass;
32+
import org.junit.Before;
33+
import org.junit.BeforeClass;
34+
import org.junit.Test;
35+
import org.junit.runner.RunWith;
36+
import org.junit.runners.JUnit4;
3537

36-
class SnippetsIT {
38+
@RunWith(JUnit4.class)
39+
public class SnippetsIT {
3740

3841
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
3942
private static final String CREDENTIALS = System.getenv("GOOGLE_APPLICATION_CREDENTIALS");
4043
private ByteArrayOutputStream stdOut;
4144

4245
// Check if the required environment variables are set.
43-
static void requireEnvVar(String envVarName) {
46+
public static void requireEnvVar(String envVarName) {
4447
assertWithMessage(String.format("Missing environment variable '%s' ", envVarName))
4548
.that(System.getenv(envVarName))
4649
.isNotEmpty();
4750
}
4851

49-
@BeforeAll
50-
static void setup() throws IOException {
52+
@BeforeClass
53+
public static void setup() throws IOException {
5154
final PrintStream out = System.out;
5255
ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
5356
System.setOut(new PrintStream(stdOut));
@@ -58,17 +61,17 @@ static void setup() throws IOException {
5861
System.setOut(out);
5962
}
6063

61-
@AfterAll
62-
static void cleanup() {}
64+
@AfterClass
65+
public static void cleanup() {}
6366

64-
@BeforeEach
65-
void beforeEach() {
67+
@Before
68+
public void beforeEach() {
6669
stdOut = new ByteArrayOutputStream();
6770
System.setOut(new PrintStream(stdOut));
6871
}
6972

70-
@AfterEach
71-
void afterEach() {
73+
@After
74+
public void afterEach() {
7275
stdOut = null;
7376
System.setOut(null);
7477
}
@@ -91,33 +94,33 @@ private static String getIdTokenFromServiceAccount(
9194
}
9295

9396
@Test
94-
void testIdTokenFromServiceAccount() throws IOException {
97+
public void testIdTokenFromServiceAccount() throws IOException {
9598
IdTokenFromServiceAccount.getIdTokenFromServiceAccount(CREDENTIALS, "https://example.com");
9699
assertThat(stdOut.toString()).contains("Generated ID token.");
97100
}
98101

99102
@Test
100-
void testVerifyGoogleIdToken() throws IOException {
103+
public void testVerifyGoogleIdToken() throws IOException {
101104
String idToken = getIdTokenFromServiceAccount(CREDENTIALS, "https://example.com");
102105

103106
VerifyGoogleIdToken.verifyGoogleIdToken(
104107
idToken, "https://example.com", "https://www.googleapis.com/oauth2/v3/certs");
105108
}
106109

107110
@Test
108-
void testIdTokenFromMetadataServer() throws GeneralSecurityException, IOException {
111+
public void testIdTokenFromMetadataServer() throws GeneralSecurityException, IOException {
109112
IdTokenFromMetadataServer.getIdTokenFromMetadataServer("https://www.google.com");
110113
assertThat(stdOut.toString()).contains("Generated ID token.");
111114
}
112115

113116
@Test
114-
void testAuthenticateImplicitWithAdc() throws IOException {
117+
public void testAuthenticateImplicitWithAdc() throws IOException {
115118
AuthenticateImplicitWithAdc.authenticateImplicitWithAdc(PROJECT_ID);
116119
assertThat(stdOut.toString()).contains("Listed all storage buckets.");
117120
}
118121

119122
@Test
120-
void testAuthenticateExplicit() throws IOException {
123+
public void testAuthenticateExplicit() throws IOException {
121124
AuthenticateExplicit.authenticateExplicit(PROJECT_ID);
122125
assertThat(stdOut.toString()).contains("Listed all storage buckets.");
123126
}

0 commit comments

Comments
 (0)