Author: alessio.soldano(a)jboss.com
Date: 2009-01-15 04:59:07 -0500 (Thu, 15 Jan 2009)
New Revision: 9041
Added:
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/Endpoint.java
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointImpl.java
Modified:
framework/branches/jaxws21/testsuite/test/ant-import/build-jars-jaxws.xml
Log:
[JBWS-2452] EPR tests
Modified: framework/branches/jaxws21/testsuite/test/ant-import/build-jars-jaxws.xml
===================================================================
--- framework/branches/jaxws21/testsuite/test/ant-import/build-jars-jaxws.xml 2009-01-15
09:58:06 UTC (rev 9040)
+++ framework/branches/jaxws21/testsuite/test/ant-import/build-jars-jaxws.xml 2009-01-15
09:59:07 UTC (rev 9041)
@@ -61,6 +61,14 @@
<exclude
name="org/jboss/test/ws/jaxws/complex/*TestCase.class"/>
</classes>
</war>
+
+ <!-- jaxws-endpointReference -->
+ <jar
destfile="${tests.output.dir}/test-libs/jaxws-endpointReference.jar">
+ <fileset dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/endpointReference/Endpoint.class"/>
+ <include
name="org/jboss/test/ws/jaxws/endpointReference/EndpointImpl.class"/>
+ </fileset>
+ </jar>
<!-- jaxws-handlerscope -->
<war warfile="${tests.output.dir}/test-libs/jaxws-handlerscope.war"
webxml="${tests.output.dir}/test-resources/jaxws/handlerscope/WEB-INF/web.xml">
Added:
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java
===================================================================
---
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java
(rev 0)
+++
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java 2009-01-15
09:59:07 UTC (rev 9041)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.InetAddress;
+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.Service.Mode;
+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 (Exception e)
+ {
+ //NOP: the provided EndpointReference is not supported by the implementation
+ }
+
+ String retObj = port.echo("Hello");
+ assertEquals("Hello", retObj);
+ }
+
+ public void testDispatch() 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 = 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("Exception expected");
+ }
+ catch (Exception e)
+ {
+ //NOP: the provided EndpointReference is not supported by the implementation
+ }
+ }
+
+ 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 targetEndpointAddress = "localhost".equals(getServerHost()) ?
"http://127.0.0.1:8080/jaxws-endpointReference" : TARGET_ENDPOINT_ADDRESS;
+ assertEquals(targetEndpointAddress,
addresses.item(0).getFirstChild().getNodeValue());
+ }
+
+ private class MyEndpointReference extends EndpointReference
+ {
+ @Override
+ public void writeTo(Result result)
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+}
Property changes on:
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/BindingProviderTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/Endpoint.java
===================================================================
---
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/Endpoint.java
(rev 0)
+++
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/Endpoint.java 2009-01-15
09:59:07 UTC (rev 9041)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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 javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(name = "Endpoint", targetNamespace =
"http://org.jboss.ws/endpointReference")
+public interface Endpoint
+{
+ String echo(String input);
+}
Property changes on:
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/Endpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointImpl.java
===================================================================
---
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointImpl.java
(rev 0)
+++
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointImpl.java 2009-01-15
09:59:07 UTC (rev 9041)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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 javax.ejb.Stateless;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jboss.wsf.spi.annotation.WebContext;
+
+@Stateless
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebContext(contextRoot="jaxws-endpointReference", urlPattern="/*")
+@WebService
+(
+ name = "Endpoint",
+ serviceName = "EndpointService",
+ targetNamespace = "http://org.jboss.ws/endpointReference"
+)
+public class EndpointImpl implements Endpoint
+{
+ @WebMethod
+ public String echo(String input)
+ {
+ return input;
+ }
+}
Property changes on:
framework/branches/jaxws21/testsuite/test/java/org/jboss/test/ws/jaxws/endpointReference/EndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF