Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This PR replaces all expected RuntimeExceptions with TestException. T… #619

Merged
merged 3 commits into from Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.microprofile.fault.tolerance.tck.asynctimeout.clientserver.AsyncTimeoutClient;
import org.eclipse.microprofile.fault.tolerance.tck.config.ConfigAnnotationAsset;
import org.eclipse.microprofile.fault.tolerance.tck.util.Connection;
import org.eclipse.microprofile.fault.tolerance.tck.util.TestException;
import org.eclipse.microprofile.faulttolerance.Timeout;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.testng.Arquillian;
Expand Down Expand Up @@ -78,7 +79,8 @@ public static WebArchive deploy() {

JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "ftAsyncTimeout.jar")
.addClasses(AsyncTimeoutClient.class, AsyncClassLevelTimeoutClient.class, Connection.class)
.addClasses(AsyncTimeoutClient.class, AsyncClassLevelTimeoutClient.class, Connection.class,
TestException.class)
benjamin-confino marked this conversation as resolved.
Show resolved Hide resolved
.addAsManifestResource(config, "microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.as(JavaArchive.class);
Expand Down
Expand Up @@ -22,6 +22,7 @@
import static org.eclipse.microprofile.fault.tolerance.tck.Misc.Ints.contains;

import org.eclipse.microprofile.fault.tolerance.tck.circuitbreaker.clientserver.CircuitBreakerClientDefaultSuccessThreshold;
import org.eclipse.microprofile.fault.tolerance.tck.util.TestException;
import org.eclipse.microprofile.faulttolerance.exceptions.CircuitBreakerOpenException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.testng.Arquillian;
Expand Down Expand Up @@ -49,7 +50,8 @@ public class CircuitBreakerInitialSuccessTest extends Arquillian {
public static WebArchive deploy() {
JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "ftCircuitBreakerInitialSuccess.jar")
.addClasses(CircuitBreakerClientDefaultSuccessThreshold.class,
Misc.class)
Misc.class,
TestException.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.as(JavaArchive.class);

Expand All @@ -63,12 +65,12 @@ public static WebArchive deploy() {
*
* With requestVolumeThreshold = 4, failureRatio=0.75 and successThreshold = 1 the expected behaviour is,
*
* Execution Behaviour ========= ========= 1 SUCCESS 2 RunTimeException 3 RunTimeException 4 RunTimeException 5
* Execution Behaviour ========= ========= 1 SUCCESS 2 TestException 3 TestException 4 TestException 5
* CircuitBreakerOpenException Pause for longer than CircuitBreaker delay, so that it transitions to half-open 6
* SUCCEED (CircuitBreaker will be re-closed as successThreshold is 1. The impact of the success of the service and
* the closure of the Circuit is to reset the rolling failure window to an empty state. Therefore another 4 requests
* need to be made - of which at least 3 need to fail - for the Circuit to open again) 7 SUCCESS 8 RunTimeException
* 9 RunTimeException 10 RuntimeException 11 CircuitBreakerOpenException
* need to be made - of which at least 3 need to fail - for the Circuit to open again) 7 SUCCESS 8 TestException 9
* TestException 10 TestException 11 CircuitBreakerOpenException
*
*/
@Test
Expand Down Expand Up @@ -97,15 +99,15 @@ public void testCircuitInitialSuccessDefaultSuccessThreshold() {
e.printStackTrace();
}
}
} catch (RuntimeException ex) {
} catch (TestException ex) {
// Expected
if (!contains(new int[]{2, 3, 4, 8, 9, 10}, i)) {
Assert.fail("serviceA should not throw a RuntimeException on iteration " + i);
Assert.fail("serviceA should not throw a TestException on iteration " + i);
}
} catch (Exception ex) {
// Not Expected
Assert.fail(
"serviceA should throw a RuntimeException or CircuitBreakerOpenException in testCircuitDefaultSuccessThreshold "
"serviceA should throw a TestException or CircuitBreakerOpenException in testCircuitDefaultSuccessThreshold "
+ "on iteration " + i);
}
}
Expand Down
Expand Up @@ -22,6 +22,7 @@
import static org.eclipse.microprofile.fault.tolerance.tck.Misc.Ints.contains;

import org.eclipse.microprofile.fault.tolerance.tck.circuitbreaker.clientserver.CircuitBreakerClientDefaultSuccessThreshold;
import org.eclipse.microprofile.fault.tolerance.tck.util.TestException;
import org.eclipse.microprofile.faulttolerance.exceptions.CircuitBreakerOpenException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.testng.Arquillian;
Expand Down Expand Up @@ -49,7 +50,8 @@ public class CircuitBreakerLateSuccessTest extends Arquillian {
public static WebArchive deploy() {
JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "ftCircuitBreakerLateSuccess.jar")
.addClasses(CircuitBreakerClientDefaultSuccessThreshold.class,
Misc.class)
Misc.class,
TestException.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.as(JavaArchive.class);

Expand Down Expand Up @@ -99,10 +101,10 @@ public void testCircuitLateSuccessDefaultSuccessThreshold() {
e.printStackTrace();
}
}
} catch (RuntimeException ex) {
} catch (TestException ex) {
// Expected
if (!contains(new int[]{1, 2, 3, 7, 8, 9}, i)) {
Assert.fail("serviceA should not throw a RuntimeException on iteration " + i);
Assert.fail("serviceA should not throw a RuntimeException on iteration " + i, ex);
}
} catch (Exception ex) {
// Not Expected
Expand Down
Expand Up @@ -81,7 +81,8 @@ public static WebArchive deploy() {
JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "ftCircuitBreakerRetry.jar")
.addClasses(CircuitBreakerClientWithRetry.class,
CircuitBreakerClassLevelClientWithRetry.class,
CircuitBreakerClientWithRetryAsync.class)
CircuitBreakerClientWithRetryAsync.class,
TestException.class)
.addPackage(Packages.UTILS)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsManifestResource(config, "microprofile-config.properties")
Expand Down Expand Up @@ -128,7 +129,7 @@ public void testCircuitOpenWithMoreRetries() {

/**
* A test to exercise Circuit Breaker thresholds with insufficient retries to open the Circuit so that the Circuit
* remains closed and a RuntimeException is caught.
* remains closed and a TestException is caught.
*/
@Test
public void testCircuitOpenWithFewRetries() {
Expand All @@ -145,10 +146,10 @@ public void testCircuitOpenWithFewRetries() {
// Not Expected
invokeCounter = clientForCBWithRetry.getCounterForInvokingServiceB();
Assert.fail(
"serviceB should retry or throw a RuntimeException (not a CBOE) in testCircuitOpenWithFewRetries on iteration "
"serviceB should retry or throw a TestException (not a CBOE) in testCircuitOpenWithFewRetries on iteration "
+ invokeCounter);

} catch (RuntimeException ex) {
} catch (TestException ex) {
// Expected on iteration 3
invokeCounter = clientForCBWithRetry.getCounterForInvokingServiceB();
if (invokeCounter < 3) {
Expand All @@ -159,7 +160,7 @@ public void testCircuitOpenWithFewRetries() {
// Not Expected
invokeCounter = clientForCBWithRetry.getCounterForInvokingServiceB();
Assert.fail(
"serviceB should retry or throw a RuntimeException in testCircuitOpenWithFewRetries on iteration "
"serviceB should retry or throw a TestException in testCircuitOpenWithFewRetries on iteration "
+ invokeCounter);
}

Expand Down Expand Up @@ -220,10 +221,10 @@ public void testClassLevelCircuitOpenWithFewRetries() {
// Not Expected
invokeCounter = clientForClassLevelCBWithRetry.getCounterForInvokingServiceB();
Assert.fail(
"serviceB should retry or throw a RuntimeException (not a CBOE) in testClassLevelCircuitOpenWithFewRetries on iteration "
"serviceB should retry or throw a TestException (not a CBOE) in testClassLevelCircuitOpenWithFewRetries on iteration "
+ invokeCounter);

} catch (RuntimeException ex) {
} catch (TestException ex) {
// Expected on iteration 3
invokeCounter = clientForClassLevelCBWithRetry.getCounterForInvokingServiceB();
if (invokeCounter < 3) {
Expand All @@ -234,7 +235,7 @@ public void testClassLevelCircuitOpenWithFewRetries() {
// Not Expected
invokeCounter = clientForClassLevelCBWithRetry.getCounterForInvokingServiceB();
Assert.fail(
"serviceB should retry or throw a RuntimeException in testClassLevelCircuitOpenWithFewRetries on iteration "
"serviceB should retry or throw a TestException in testClassLevelCircuitOpenWithFewRetries on iteration "
+ invokeCounter);
}

Expand Down Expand Up @@ -407,7 +408,7 @@ public void testCircuitOpenWithMoreRetriesAsync() {

/**
* A test to exercise Circuit Breaker thresholds with insufficient retries to open the Circuit so that the Circuit
* remains closed and a RuntimeException is caught when using an Asynchronous call.
* remains closed and a TestException is caught when using an Asynchronous call.
*/
@Test
public void testCircuitOpenWithFewRetriesAsync() {
Expand Down Expand Up @@ -437,7 +438,7 @@ public void testCircuitOpenWithFewRetriesAsync() {
// Not Expected
invokeCounter = clientForCBWithRetryAsync.getCounterForInvokingServiceB();
Assert.fail(
"serviceB should retry or throw a RuntimeException in testCircuitOpenWithFewRetries on iteration "
"serviceB should retry or throw a TestException in testCircuitOpenWithFewRetries on iteration "
+ invokeCounter);
}

Expand Down