Author: richard.opalka(a)jboss.com
Date: 2010-02-02 10:18:21 -0500 (Tue, 02 Feb 2010)
New Revision: 11528
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointReferenceTestCase.java
Removed:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java
Log:
[JBWS-2914] refactoring test case name + extending it to cover more usecases
Deleted:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java 2010-02-02
13:31:34 UTC (rev 11527)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java 2010-02-02
15:18:21 UTC (rev 11528)
@@ -1,155 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.test.ws.jaxws.endpointReference;
-
-import java.net.URL;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Dispatch;
-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;
-
-import junit.framework.Test;
-
-import org.jboss.util.NotImplementedException;
-import org.jboss.wsf.common.DOMUtils;
-import org.jboss.wsf.test.JBossWSTest;
-import org.jboss.wsf.test.JBossWSTestSetup;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * Test EPR related methods
- *
- * @author alessio.soldano(a)jboss.com
- * @since 13-Jan-2009
- */
-public class BindingProviderTestCase extends JBossWSTest
-{
- public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-endpointReference";
-
- public static Test suite()
- {
- return new JBossWSTestSetup(BindingProviderTestCase.class,
"jaxws-endpointReference.jar");
- }
-
- public void testClient() 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);
- }
-
- String retObj = port.echo("Hello");
- assertEquals("Hello", retObj);
- }
-
- public void testDispatch() throws Exception
- {
- innerTestDispatch();
- }
-
- private void innerTestDispatch(WebServiceFeature... features) 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;
- assertEndpointReference(bp.getEndpointReference());
- assertEndpointReference(bp.getEndpointReference(W3CEndpointReference.class));
- try
- {
- bp.getEndpointReference(MyEndpointReference.class);
- fail("WebServiceException expected");
- }
- catch (WebServiceException e)
- {
- //NOP: the provided EndpointReference is not supported by the implementation
- }
- catch (Throwable t)
- {
- fail("WebServiceException expected, got " + t);
- }
- }
-
- public void testDispatchWithFeatures() throws Exception
- {
- innerTestDispatch(new AddressingFeature(false, false));
- }
-
- private void assertEndpointReference(EndpointReference epr) throws Exception
- {
- assertEquals(W3CEndpointReference.class.getName(), epr.getClass().getName());
- Element endpointReference = DOMUtils.parse(epr.toString());
- assertEquals("EndpointReference", endpointReference.getNodeName());
-
assertEquals("http://www.w3.org/2005/08/addressing",
endpointReference.getAttribute("xmlns"));
- NodeList addresses = endpointReference.getElementsByTagName("Address");
- 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);
- }
-
- private class MyEndpointReference extends EndpointReference
- {
- @Override
- public void writeTo(Result result)
- {
- throw new NotImplementedException();
- }
-
- }
-}
Added:
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
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointReferenceTestCase.java 2010-02-02
15:18:21 UTC (rev 11528)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.endpointReference;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+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;
+
+import junit.framework.Test;
+
+import org.jboss.util.NotImplementedException;
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Test EPR related methods
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @author ropalka(a)redhat.com
+ * @since 13-Jan-2009
+ */
+public class EndpointReferenceTestCase extends JBossWSTest
+{
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-endpointReference";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(EndpointReferenceTestCase.class,
"jaxws-endpointReference.jar");
+ }
+
+ public void testClient() 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);
+ }
+
+ public void testDispatch() throws Exception
+ {
+ innerTestDispatch();
+ }
+
+ private void innerTestDispatch(WebServiceFeature... features) 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;
+ assertEndpointReference(bp.getEndpointReference());
+ assertEndpointReference(bp.getEndpointReference(W3CEndpointReference.class));
+ try
+ {
+ bp.getEndpointReference(MyEndpointReference.class);
+ fail("WebServiceException expected");
+ }
+ catch (WebServiceException e)
+ {
+ //NOP: the provided EndpointReference is not supported by the implementation
+ }
+ catch (Throwable t)
+ {
+ fail("WebServiceException expected, got " + t);
+ }
+
+ Endpoint 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);
+ }
+
+ public void testDispatchWithFeatures() throws Exception
+ {
+ innerTestDispatch(new AddressingFeature(false, false));
+ }
+
+ private void assertEndpointReference(EndpointReference epr) throws Exception
+ {
+ assertEquals(W3CEndpointReference.class.getName(), epr.getClass().getName());
+ Element endpointReference = DOMUtils.parse(epr.toString());
+ assertEquals("EndpointReference", endpointReference.getNodeName());
+
assertEquals("http://www.w3.org/2005/08/addressing",
endpointReference.getAttribute("xmlns"));
+ NodeList addresses = endpointReference.getElementsByTagName("Address");
+ 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);
+ }
+
+ private class MyEndpointReference extends EndpointReference
+ {
+ @Override
+ public void writeTo(Result result)
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+}