Skip to content

Commit

Permalink
use junit-pioneer
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeWang1127 committed May 22, 2024
1 parent 15862fe commit 315952e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion gax-java/gax/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djava.util.logging.SimpleFormatter.format="%1$tY %1$tl:%1$tM:%1$tS.%1$tL %2$s %4$s: %5$s%6$s%n"</argLine>
<argLine>
-Djava.util.logging.SimpleFormatter.format="%1$tY %1$tl:%1$tM:%1$tS.%1$tL %2$s %4$s: %5$s%6$s%n"
<!-- workaround setup for using junit-pioneer with Java 17 or above,
see https://junit-pioneer.org/docs/environment-variables/#warnings-for-reflective-access -->
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.io.IOException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetEnvironmentVariable;
import org.mockito.Mockito;

class EndpointContextTest {
Expand Down Expand Up @@ -339,6 +340,7 @@ void endpointContextBuild_gdchFlow_noUniverseDomain_customEndpoint() throws IOEx
// For this test running locally or in CI, check that the Env Var is set properly.
// This test should only run when the maven profile `EnvVarTest` is enabled.
@Test
@SetEnvironmentVariable(key = "GOOGLE_CLOUD_UNIVERSE_DOMAIN", value = "random.com")
void endpointContextBuild_universeDomainEnvVarSet() throws IOException {
String envVarUniverseDomain = "random.com";
EndpointContext endpointContext =
Expand All @@ -354,9 +356,9 @@ void endpointContextBuild_universeDomainEnvVarSet() throws IOException {
// For this test running locally or in CI, check that the Env Var is set properly.
// This test should only run when the maven profile `EnvVarTest` is enabled.
@Test
@SetEnvironmentVariable(key = "GOOGLE_CLOUD_UNIVERSE_DOMAIN", value = "random.com")
void endpointContextBuild_multipleUniverseDomainConfigurations_clientSettingsHasPriority()
throws IOException {
// This test has `GOOGLE_CLOUD_UNIVERSE_DOMAIN` = `random.com`
String clientSettingsUniverseDomain = "clientSettingsUniverseDomain.com";
EndpointContext endpointContext =
defaultEndpointContextBuilder
Expand Down
6 changes: 6 additions & 0 deletions gax-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down

0 comments on commit 315952e

Please sign in to comment.