Author: richard.opalka(a)jboss.com
Date: 2010-02-04 04:33:08 -0500 (Thu, 04 Feb 2010)
New Revision: 11535
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointReferenceTestCase.java
Log:
[JBWS-2914] refactoring test
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointReferenceTestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointReferenceTestCase.java 2010-02-03
12:58:46 UTC (rev 11534)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointReferenceTestCase.java 2010-02-04
09:33:08 UTC (rev 11535)
@@ -31,7 +31,6 @@
import javax.xml.ws.EndpointReference;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
-import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
@@ -54,68 +53,44 @@
*/
public class EndpointReferenceTestCase extends JBossWSTest
{
- public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-endpointReference";
+ private static final String ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-endpointReference";
+ private static final String ENDPOINT_WSDL = ENDPOINT_ADDRESS + "?wsdl";
+ private static final String WSDL_NS =
"http://org.jboss.ws/endpointReference";
+ private static final QName SERVICE_QNAME = new QName(WSDL_NS,
"EndpointService");
+ private static final QName PORT_QNAME = new QName(WSDL_NS, "EndpointPort");
+ private Service service;
+
public static Test suite()
{
return new JBossWSTestSetup(EndpointReferenceTestCase.class,
"jaxws-endpointReference.jar");
}
- public void testClient() throws Exception
+ public void setUp() throws Exception
{
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- QName serviceName = new QName("http://org.jboss.ws/endpointReference",
"EndpointService");
- Endpoint port = Service.create(wsdlURL, serviceName).getPort(Endpoint.class);
-
- BindingProvider bp = (BindingProvider)port;
- assertEndpointReference(bp.getEndpointReference());
- assertEndpointReference(bp.getEndpointReference(W3CEndpointReference.class));
- try
- {
- bp.getEndpointReference(MyEndpointReference.class);
- fail("Exception expected");
- }
- catch (WebServiceException e)
- {
- //NOP: the provided EndpointReference is not supported by the implementation
- }
- catch (Throwable t)
- {
- fail("WebServiceException expected, got " + t);
- }
-
- port = bp.getEndpointReference().getPort(Endpoint.class);
- assertNotNull(port);
- String retObj = port.echo("Hello");
- assertEquals("Hello", retObj);
-
- port =
bp.getEndpointReference(W3CEndpointReference.class).getPort(Endpoint.class);
- assertNotNull(port);
- retObj = port.echo("Hello");
- assertEquals("Hello", retObj);
+ this.service = Service.create(new URL(ENDPOINT_WSDL), SERVICE_QNAME);
}
public void testDispatch() throws Exception
{
- innerTestDispatch();
+ final Dispatch<Source> dispatch = this.service.createDispatch(PORT_QNAME,
Source.class, Mode.PAYLOAD);
+ this.validateEndpointReferences(dispatch);
}
- private void innerTestDispatch(WebServiceFeature... features) throws Exception
+ public void testDispatchWithFeatures() throws Exception
{
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- QName serviceName = new QName("http://org.jboss.ws/endpointReference",
"EndpointService");
- Service service = Service.create(wsdlURL, serviceName);
- Dispatch<Source> dispatch = null;
- if (features != null && features.length > 0) //test both createDispatch
methods
- {
- dispatch = service.createDispatch(new
QName("http://org.jboss.ws/endpointReference", "EndpointPort"),
Source.class, Mode.PAYLOAD, features);
- }
- else
- {
- dispatch = service.createDispatch(new
QName("http://org.jboss.ws/endpointReference", "EndpointPort"),
Source.class, Mode.PAYLOAD);
- }
-
- BindingProvider bp = (BindingProvider)dispatch;
+ final Dispatch<Source> dispatch = this.service.createDispatch(PORT_QNAME,
Source.class, Mode.PAYLOAD, new AddressingFeature(false, false));
+ this.validateEndpointReferences(dispatch);
+ }
+
+ public void testPort() throws Exception
+ {
+ final Endpoint port = this.service.getPort(Endpoint.class);
+ this.validateEndpointReferences((BindingProvider)port);
+ }
+
+ private void validateEndpointReferences(final BindingProvider bp) throws Exception
+ {
assertEndpointReference(bp.getEndpointReference());
assertEndpointReference(bp.getEndpointReference(W3CEndpointReference.class));
try
@@ -143,11 +118,6 @@
assertEquals("Hello", retObj);
}
- public void testDispatchWithFeatures() throws Exception
- {
- innerTestDispatch(new AddressingFeature(false, false));
- }
-
private void assertEndpointReference(EndpointReference epr) throws Exception
{
assertEquals(W3CEndpointReference.class.getName(), epr.getClass().getName());
@@ -158,10 +128,10 @@
assertEquals(1, addresses.getLength());
String eprAddress = addresses.item(0).getFirstChild().getNodeValue();
eprAddress = eprAddress.replace("127.0.0.1", "localhost");
- assertEquals(TARGET_ENDPOINT_ADDRESS.replace("127.0.0.1",
"localhost"), eprAddress);
+ assertEquals(ENDPOINT_ADDRESS.replace("127.0.0.1",
"localhost"), eprAddress);
}
- private class MyEndpointReference extends EndpointReference
+ private static class MyEndpointReference extends EndpointReference
{
@Override
public void writeTo(Result result)
Show replies by date