Skip to content

Commit 84b2470

Browse files
authored
Replacing @theory annotated test case to @parameterized test case (#3015)
1 parent ed824ff commit 84b2470

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

http-clients/aws-crt-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
<value>false</value>
188188
</property>
189189
</properties>
190-
<threadCountClasses>1</threadCountClasses>
190+
<threadCount>1</threadCount>
191191
</configuration>
192192
<dependencies>
193193
<dependency>

http-clients/aws-crt-client/src/it/java/software/amazon/awssdk/http/crt/AwsCrtClientCallingPatternIntegrationTest.java

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818
import static software.amazon.awssdk.testutils.service.AwsTestBase.CREDENTIALS_PROVIDER_CHAIN;
1919

2020
import java.util.ArrayList;
21+
import java.util.Arrays;
2122
import java.util.List;
2223
import java.util.concurrent.CompletableFuture;
2324
import java.util.concurrent.CountDownLatch;
2425
import java.util.concurrent.ExecutorService;
2526
import java.util.concurrent.Executors;
2627
import java.util.concurrent.TimeUnit;
2728
import java.util.concurrent.atomic.AtomicBoolean;
29+
import java.util.stream.Stream;
2830
import org.junit.Assert;
29-
import org.junit.experimental.theories.DataPoints;
30-
import org.junit.experimental.theories.FromDataPoints;
31-
import org.junit.experimental.theories.Theories;
32-
import org.junit.experimental.theories.Theory;
33-
import org.junit.runner.RunWith;
31+
import org.junit.jupiter.api.Timeout;
32+
import org.junit.jupiter.params.ParameterizedTest;
33+
import org.junit.jupiter.params.provider.Arguments;
34+
import org.junit.jupiter.params.provider.MethodSource;
3435
import software.amazon.awssdk.crt.CrtResource;
3536
import software.amazon.awssdk.http.SdkHttpConfigurationOption;
3637
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
@@ -40,11 +41,9 @@
4041
import software.amazon.awssdk.services.kms.model.GenerateRandomResponse;
4142
import software.amazon.awssdk.utils.AttributeMap;
4243

43-
4444
/**
4545
* Test many possible different calling patterns that users might do, and make sure everything works.
4646
*/
47-
@RunWith(Theories.class)
4847
public class AwsCrtClientCallingPatternIntegrationTest {
4948
private final static String KEY_ALIAS = "alias/aws-sdk-java-v2-integ-test";
5049
private final static Region REGION = Region.US_EAST_1;
@@ -109,38 +108,31 @@ private boolean testWithNewClient(int eventLoopSize, int numberOfRequests) {
109108
}
110109
}
111110

112-
@DataPoints("EventLoop")
113-
public static int[] eventLoopValues(){
114-
return new int[]{1, 4};
115-
}
116-
117-
@DataPoints("ConnectionPool")
118-
public static int[] connectionsValues(){
119-
/* Don't use 1 connection Pool of size 1, otherwise test takes too long */
120-
return new int[]{10, 100};
121-
}
122-
123-
@DataPoints("NumRequests")
124-
public static int[] requestValues(){
125-
return new int[]{1, 25, 250};
126-
}
127-
128-
@DataPoints("ParallelClients")
129-
public static int[] parallelClientValues(){
130-
return new int[]{1, 2, 8};
131-
}
132-
133-
@DataPoints("SharedClient")
134-
public static boolean[] sharedClientValue(){
135-
return new boolean[]{true, false};
111+
static Integer[] eventLoopValues = {1, 4};
112+
/* Don't use 1 connection Pool of size 1, otherwise test takes too long */
113+
static Integer[] connectionsValues = {10, 100};
114+
static Integer[] requestValues = {1, 25, 250};
115+
static Integer[] parallelClientValues = {1, 2, 8};
116+
static Boolean[] sharedClientValue = {true, false};
117+
118+
private static Stream<Arguments> permutationsOfCrtCallParameters() {
119+
return Arrays.stream(eventLoopValues).flatMap(
120+
eventLoops -> Arrays.stream(connectionsValues).flatMap(
121+
connections -> Arrays.stream(requestValues).flatMap(
122+
requests -> Arrays.stream(parallelClientValues).flatMap(
123+
parallelClients -> Arrays.stream(sharedClientValue).map(
124+
sharedClients -> Arguments.of(eventLoops, connections, requests, parallelClients, sharedClients))))));
136125
}
137126

138-
@Theory
139-
public void checkAllCombinations(@FromDataPoints("EventLoop") int eventLoopSize,
140-
@FromDataPoints("ConnectionPool") int connectionPoolSize,
141-
@FromDataPoints("NumRequests") int numberOfRequests,
142-
@FromDataPoints("ParallelClients") int numberOfParallelClients,
143-
@FromDataPoints("SharedClient") boolean useSharedClient) throws Exception {
127+
// Timeout set to 4 times of Avg execution of this test 4*150
128+
@Timeout(600)
129+
@ParameterizedTest
130+
@MethodSource("permutationsOfCrtCallParameters")
131+
public void checkAllCombinations(int eventLoopSize,
132+
int connectionPoolSize,
133+
int numberOfRequests,
134+
int numberOfParallelClients,
135+
boolean useSharedClient) {
144136

145137
try {
146138

0 commit comments

Comments
 (0)