diff --git a/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/CircuitBreakerTimeoutTest.java b/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/CircuitBreakerTimeoutTest.java index 54b2ab1b..e7d3d90d 100644 --- a/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/CircuitBreakerTimeoutTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/CircuitBreakerTimeoutTest.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (c) 2018 Contributors to the Eclipse Foundation + * Copyright (c) 2018-2020 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -22,6 +22,7 @@ import javax.inject.Inject; import org.eclipse.microprofile.fault.tolerance.tck.circuitbreaker.clientserver.CircuitBreakerClientWithTimeout; +import org.eclipse.microprofile.fault.tolerance.tck.config.ConfigAnnotationAsset; import org.eclipse.microprofile.fault.tolerance.tck.util.Exceptions; import org.eclipse.microprofile.fault.tolerance.tck.util.Packages; import org.jboss.arquillian.container.test.api.Deployment; @@ -41,11 +42,15 @@ public class CircuitBreakerTimeoutTest extends Arquillian { @Deployment public static WebArchive deploy() { + ConfigAnnotationAsset config = new ConfigAnnotationAsset() + .autoscaleMethod(CircuitBreakerClientWithTimeout.class, "serviceWithTimeout") + .autoscaleMethod(CircuitBreakerClientWithTimeout.class, "serviceWithTimeoutWithoutFailOn"); + JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "ftCircuitBreakerTimeout.jar") .addClasses(CircuitBreakerClientWithTimeout.class) .addPackage(Packages.UTILS) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .as(JavaArchive.class); + .addAsManifestResource(config, "microprofile-config.properties"); WebArchive war = ShrinkWrap.create(WebArchive.class, "ftCircuitBreakerTimeout.war") .addAsLibrary(testJar); diff --git a/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/circuitbreaker/clientserver/CircuitBreakerClientWithTimeout.java b/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/circuitbreaker/clientserver/CircuitBreakerClientWithTimeout.java index c1853212..59116d97 100644 --- a/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/circuitbreaker/clientserver/CircuitBreakerClientWithTimeout.java +++ b/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/circuitbreaker/clientserver/CircuitBreakerClientWithTimeout.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (c) 2018 Contributors to the Eclipse Foundation + * Copyright (c) 2018-2020 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -23,6 +23,7 @@ import javax.enterprise.context.RequestScoped; +import org.eclipse.microprofile.fault.tolerance.tck.util.TCKConfig; import org.eclipse.microprofile.faulttolerance.CircuitBreaker; import org.eclipse.microprofile.faulttolerance.Timeout; import org.eclipse.microprofile.faulttolerance.exceptions.BulkheadException; @@ -38,10 +39,10 @@ public class CircuitBreakerClientWithTimeout { * @return should always throw TimeoutException, unless CircuitBreaker prevents execution */ @CircuitBreaker(successThreshold = 2, requestVolumeThreshold = 2, failureRatio = 0.75, delay = 50000) - @Timeout(500) + @Timeout(500) // Adjusted by config public String serviceWithTimeout() { try { - Thread.sleep(1000); + Thread.sleep(TCKConfig.getConfig().getTimeoutInMillis(1000)); fail("Thread not interrupted by timeout"); } catch (InterruptedException e) { @@ -60,10 +61,10 @@ public String serviceWithTimeout() { * @return should always throw TimeoutException */ @CircuitBreaker(successThreshold = 2, requestVolumeThreshold = 2, failureRatio = 0.75, delay = 50000, failOn = BulkheadException.class) - @Timeout(500) + @Timeout(500) // Adjusted by config public String serviceWithTimeoutWithoutFailOn() { try { - Thread.sleep(1000); + Thread.sleep(TCKConfig.getConfig().getTimeoutInMillis(1000)); fail("Thread not interrupted by timeout"); } catch (InterruptedException e) {