Skip to content

Commit ef1938b

Browse files
committed
Make the number of invocations per thread configurable.
1 parent ea5ca74 commit ef1938b

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

integration/src/test/java/test/wsdl/multithread/Invoker.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ class Invoker implements Runnable {
3535
private final CountDownLatch readyLatch;
3636
private final CountDownLatch startLatch;
3737
private final Report report;
38+
private final int numInvocations;
3839

39-
Invoker(AddressBook binding, CountDownLatch readyLatch, CountDownLatch startLatch, Report report) {
40+
Invoker(AddressBook binding, CountDownLatch readyLatch, CountDownLatch startLatch, Report report,
41+
int numInvocations) {
4042
this.binding = binding;
4143
this.readyLatch = readyLatch;
4244
this.startLatch = startLatch;
4345
this.report = report;
46+
this.numInvocations = numInvocations;
4447
}
4548

4649
public void run() {
@@ -50,7 +53,7 @@ public void run() {
5053
readyLatch.countDown();
5154
startLatch.await();
5255

53-
for (int i = 0; i < 4; ++i) {
56+
for (int i = 0; i < numInvocations; ++i) {
5457
Address address = new Address();
5558
Phone phone = new Phone();
5659
address.setStreetNum(i);

integration/src/test/java/test/wsdl/multithread/MultithreadTestCase.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ public AddressBook getStub() throws Exception {
4545

4646
private void testMultithreading(StubSupplier stubSupplier) throws Throwable {
4747
Report report = new Report();
48-
int NUM_THREADS = 50;
49-
CountDownLatch readyLatch = new CountDownLatch(NUM_THREADS);
48+
final int numThreads = 50;
49+
final int numInvocations = 4;
50+
CountDownLatch readyLatch = new CountDownLatch(numThreads);
5051
CountDownLatch startLatch = new CountDownLatch(1);
51-
Thread[] threads = new Thread[NUM_THREADS];
52-
for (int i = 0; i < NUM_THREADS; ++i) {
53-
threads[i] = new Thread(new Invoker(stubSupplier.getStub(), readyLatch, startLatch, report));
52+
Thread[] threads = new Thread[numThreads];
53+
for (int i = 0; i < numThreads; ++i) {
54+
threads[i] = new Thread(new Invoker(stubSupplier.getStub(), readyLatch, startLatch, report, numInvocations));
5455
threads[i].start();
5556
}
5657
readyLatch.await();
5758
startLatch.countDown();
58-
for (int i = 0; i < NUM_THREADS; ++i) {
59+
for (int i = 0; i < numThreads; ++i) {
5960
threads[i].join(30000);
6061
StackTraceElement[] stack = threads[i].getStackTrace();
6162
if (stack.length > 0) {
@@ -68,7 +69,7 @@ private void testMultithreading(StubSupplier stubSupplier) throws Throwable {
6869
if (error != null) {
6970
throw error;
7071
}
71-
assertEquals("number of successes", NUM_THREADS * 4, report.getSuccessCount());
72+
assertEquals("number of successes", numThreads * numInvocations, report.getSuccessCount());
7273
} // testMultithreading
7374
} // class MultithreadTestCase
7475

0 commit comments

Comments
 (0)