Skip to content

Commit d54e134

Browse files
committed
test(gax-httpjson): use @EnabledIf instead of Assumptions in Tls13 test
Assumptions.assumeTrue requires opentest4j (TestAbortedException), which is not on the Bazel test classpath, breaking the sdk-platform-java integration jobs. A class-level @EnabledIf condition has the same skip semantics without that dependency.
1 parent 33f5808 commit d54e134

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎sdk-platform-java/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/InstantiatingHttpJsonChannelProviderTls13Test.java‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
package com.google.api.gax.httpjson;
3131

3232
import static com.google.common.truth.Truth.assertThat;
33-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
3433

3534
import com.google.api.client.http.GenericUrl;
3635
import com.google.api.client.http.HttpResponse;
@@ -62,6 +61,7 @@
6261
import org.junit.jupiter.api.AfterEach;
6362
import org.junit.jupiter.api.BeforeEach;
6463
import org.junit.jupiter.api.Test;
64+
import org.junit.jupiter.api.condition.EnabledIf;
6565
import org.junit.jupiter.api.io.TempDir;
6666
import org.mockito.Mockito;
6767

@@ -80,6 +80,9 @@
8080
* javax.net.ssl.trustStore} at a temporary store containing only the test CA, and restores the
8181
* previous value afterwards.
8282
*/
83+
@EnabledIf(
84+
value = "isConscryptAndTls13Available",
85+
disabledReason = "Conscrypt native library or TLS 1.3 is unavailable on this platform")
8386
class InstantiatingHttpJsonChannelProviderTls13Test {
8487

8588
private static final String RESOURCE_DIR = "com/google/api/gax/httpjson/";
@@ -93,13 +96,13 @@ class InstantiatingHttpJsonChannelProviderTls13Test {
9396
private String previousTrustStorePassword;
9497
private ExecutorService serverExecutor;
9598

99+
/** Condition for {@link EnabledIf}; must be static because it is used at class level. */
100+
static boolean isConscryptAndTls13Available() {
101+
return HttpJsonConscryptUtils.getConscryptProvider() != null && isTls13Supported();
102+
}
103+
96104
@BeforeEach
97105
void setUp() throws Exception {
98-
assumeTrue(
99-
HttpJsonConscryptUtils.getConscryptProvider() != null,
100-
"Conscrypt native library is unavailable on this platform");
101-
assumeTrue(isTls13Supported(), "TLS 1.3 is unavailable on this JDK");
102-
103106
previousTrustStore = System.getProperty(TRUST_STORE_PROPERTY);
104107
previousTrustStorePassword = System.getProperty(TRUST_STORE_PASSWORD_PROPERTY);
105108
File trustStoreFile = writeTrustStoreWithTestCa();

0 commit comments

Comments
 (0)