Skip to content

Commit f65ab68

Browse files
committed
Some minor refactorings.
1 parent cd41778 commit f65ab68

5 files changed

Lines changed: 27 additions & 24 deletions

File tree

‎modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/dispatch/StringDispatchTests.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.apache.axis2.jaxws.dispatch;
2121

2222
import org.apache.axis2.jaxws.TestLogger;
23-
import org.apache.axis2.jaxws.framework.AbstractTestCase;
2423
import org.apache.axis2.testutils.Axis2Server;
2524
import org.apache.axis2.testutils.Junit4ClassRunnerWithRuntimeIgnore;
2625
import org.junit.ClassRule;
@@ -33,6 +32,7 @@
3332
import javax.xml.ws.Service;
3433
import javax.xml.ws.WebServiceException;
3534

35+
import static org.apache.axis2.jaxws.framework.TestUtils.checkUnknownHostURL;
3636
import static org.junit.Assert.assertNotNull;
3737
import static org.junit.Assert.assertTrue;
3838
import static org.junit.Assert.fail;
@@ -42,7 +42,7 @@
4242
import java.util.concurrent.Future;
4343

4444
@RunWith(Junit4ClassRunnerWithRuntimeIgnore.class)
45-
public class StringDispatchTests extends AbstractTestCase {
45+
public class StringDispatchTests {
4646
@ClassRule
4747
public static final Axis2Server server = new Axis2Server("target/repo");
4848

modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/framework/AbstractTestCase.java renamed to modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/framework/TestUtils.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
import org.apache.axis2.testutils.RuntimeIgnoreException;
2828

29-
public class AbstractTestCase {
29+
public final class TestUtils {
30+
private TestUtils() {}
31+
3032
/**
3133
* Check that the given URL refers to an unknown host. More precisely, this method checks that
3234
* the DNS resolver will not be able to resolve the host name. If the expectation is not met,
@@ -41,7 +43,7 @@ public class AbstractTestCase {
4143
* @param url
4244
* @throws MalformedURLException
4345
*/
44-
protected static void checkUnknownHostURL(String url) throws MalformedURLException {
46+
public static void checkUnknownHostURL(String url) throws MalformedURLException {
4547
String host = new URL(url).getHost();
4648
InetAddress addr;
4749
try {
@@ -52,4 +54,20 @@ protected static void checkUnknownHostURL(String url) throws MalformedURLExcepti
5254
}
5355
throw new RuntimeIgnoreException(host + " resolves to " + addr.getHostAddress() + "; skipping test case");
5456
}
57+
58+
public static void withRetry(Runnable runnable) throws InterruptedException {
59+
int retries = 0;
60+
while (true) {
61+
try {
62+
runnable.run();
63+
return;
64+
} catch (AssertionError ex) {
65+
if (retries++ > 60) {
66+
throw ex;
67+
} else {
68+
Thread.sleep(500);
69+
}
70+
}
71+
}
72+
}
5573
}

‎modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/AsyncExecutorTests.java‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import javax.xml.ws.BindingProvider;
3333
import javax.xml.ws.Response;
3434

35+
import static org.apache.axis2.jaxws.framework.TestUtils.withRetry;
3536
import static org.junit.Assert.assertEquals;
3637
import static org.junit.Assert.assertNotNull;
3738
import static org.junit.Assert.assertNull;
@@ -349,22 +350,6 @@ public void sendClientRequest() throws Exception {
349350
}
350351
}
351352

352-
static void withRetry(Runnable runnable) throws InterruptedException {
353-
int retries = 0;
354-
while (true) {
355-
try {
356-
runnable.run();
357-
return;
358-
} catch (AssertionError ex) {
359-
if (retries++ > 60) {
360-
throw ex;
361-
} else {
362-
Thread.sleep(500);
363-
}
364-
}
365-
}
366-
}
367-
368353
/**
369354
* Thread that verifies the request sent by a different thread was recieved by the service and
370355
* then verify the response. Another thread will have previously sent the request. Note that

‎modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
package org.apache.axis2.jaxws.sample;
2424

2525
import org.apache.axis2.jaxws.TestLogger;
26-
import org.apache.axis2.jaxws.framework.AbstractTestCase;
2726
import org.apache.axis2.jaxws.sample.faults.FaultyWebServiceFault_Exception;
2827
import org.apache.axis2.jaxws.sample.faults.FaultyWebServicePortType;
2928
import org.apache.axis2.jaxws.sample.faults.FaultyWebServiceService;
@@ -42,6 +41,7 @@
4241
import javax.xml.ws.WebServiceException;
4342
import javax.xml.ws.soap.SOAPFaultException;
4443

44+
import static org.apache.axis2.jaxws.framework.TestUtils.checkUnknownHostURL;
4545
import static org.junit.Assert.assertEquals;
4646
import static org.junit.Assert.assertNotNull;
4747
import static org.junit.Assert.assertTrue;
@@ -52,7 +52,7 @@
5252
import java.util.concurrent.Future;
5353

5454
@RunWith(Junit4ClassRunnerWithRuntimeIgnore.class)
55-
public class FaultyWebServiceTests extends AbstractTestCase {
55+
public class FaultyWebServiceTests {
5656
@ClassRule
5757
public static final Axis2Server server = new Axis2Server("target/repo");
5858

‎modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/RuntimeExceptionsAsyncMepTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.axis2.jaxws.sample;
2020

21+
import static org.apache.axis2.jaxws.framework.TestUtils.checkUnknownHostURL;
2122
import static org.junit.Assert.assertNotNull;
2223
import static org.junit.Assert.assertTrue;
2324
import static org.junit.Assert.fail;
@@ -38,7 +39,6 @@
3839
import org.apache.axis2.addressing.AddressingConstants;
3940
import org.apache.axis2.deployment.FileSystemConfigurator;
4041
import org.apache.axis2.jaxws.ClientConfigurationFactory;
41-
import org.apache.axis2.jaxws.framework.AbstractTestCase;
4242
import org.apache.axis2.jaxws.sample.asyncdoclit.client.AsyncClient;
4343
import org.apache.axis2.jaxws.sample.asyncdoclit.client.AsyncPort;
4444
import org.apache.axis2.jaxws.sample.asyncdoclit.client.AsyncService;
@@ -57,7 +57,7 @@
5757
* Test for varios async exceptions whern AsyncMEP is enabled
5858
*/
5959
@RunWith(Junit4ClassRunnerWithRuntimeIgnore.class)
60-
public class RuntimeExceptionsAsyncMepTest extends AbstractTestCase {
60+
public class RuntimeExceptionsAsyncMepTest {
6161
@ClassRule
6262
public static final Axis2Server server = new Axis2Server("target/addressing-repo");
6363

0 commit comments

Comments
 (0)