Author: alessio.soldano(a)jboss.com
Date: 2013-05-07 13:27:56 -0400 (Tue, 07 May 2013)
New Revision: 17536
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/AnotherServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/ServiceIface.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/ServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/WSDiscoveryTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsdd/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsdd/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsdd/WEB-INF/jboss-webservices.xml
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/pom.xml
Log:
[JBWS-3596] Adding WS-Discovery testcase - currently disabled waiting for CXF-5005 to be
included in a release
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2013-05-07
17:24:29 UTC (rev 17535)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2013-05-07
17:27:56 UTC (rev 17536)
@@ -107,6 +107,28 @@
</classes>
</war>
+ <!-- jaxws-samples-wsdd -->
+ <war
+ warfile="${tests.output.dir}/test-libs/jaxws-samples-wsdd.war"
needxmlfile='false'>
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/wsdd/ServiceIface.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsdd/ServiceImpl.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/samples/wsdd/WEB-INF">
+ <include name="jboss-webservices.xml"/>
+ </webinf>
+ </war>
+ <war
+ warfile="${tests.output.dir}/test-libs/jaxws-samples-wsdd2.war"
needxmlfile='false'>
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/wsdd/ServiceIface.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsdd/*ServiceImpl.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/samples/wsdd/WEB-INF">
+ <include name="jboss-webservices.xml"/>
+ </webinf>
+ </war>
+
<!-- jaxws-samples-wsrm -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsrm-api.war"
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/AnotherServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/AnotherServiceImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/AnotherServiceImpl.java 2013-05-07
17:27:56 UTC (rev 17536)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.samples.wsdd;
+
+import javax.jws.WebService;
+
+@WebService
+(
+ portName = "AnotherWSDDPort",
+ serviceName = "AnotherWSDDService",
+ targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsdd",
+ endpointInterface = "org.jboss.test.ws.jaxws.samples.wsdd.ServiceIface"
+)
+public class AnotherServiceImpl implements ServiceIface
+{
+ public String greet(String name)
+ {
+ System.out.println("Hi " + name);
+ return "Hi " + name;
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/ServiceIface.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/ServiceIface.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/ServiceIface.java 2013-05-07
17:27:56 UTC (rev 17536)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.samples.wsdd;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService
+(
+ targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsdd"
+)
+public interface ServiceIface
+{
+ @WebMethod
+ String greet(String name);
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/ServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/ServiceImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/ServiceImpl.java 2013-05-07
17:27:56 UTC (rev 17536)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.samples.wsdd;
+
+import javax.jws.WebService;
+
+@WebService
+(
+ portName = "WSDDPort",
+ serviceName = "WSDDService",
+ targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsdd",
+ endpointInterface = "org.jboss.test.ws.jaxws.samples.wsdd.ServiceIface"
+)
+public class ServiceImpl implements ServiceIface
+{
+ public String greet(String name)
+ {
+ System.out.println("Greetings " + name);
+ return "Greetings " + name;
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/WSDiscoveryTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/WSDiscoveryTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsdd/WSDiscoveryTestCase.java 2013-05-07
17:27:56 UTC (rev 17536)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.samples.wsdd;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+
+import junit.framework.Test;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.ws.discovery.WSDiscoveryClient;
+import org.apache.cxf.ws.discovery.wsdl.ProbeMatchType;
+import org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType;
+import org.apache.cxf.ws.discovery.wsdl.ProbeType;
+import org.apache.cxf.ws.discovery.wsdl.ResolveMatchType;
+import org.apache.cxf.ws.discovery.wsdl.ScopesType;
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * WS-Discovery 1.1 sample
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 07-May-2013
+ */
+public final class WSDiscoveryTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(WSDiscoveryTestCase.class,
"jaxws-samples-wsdd.war,jaxws-samples-wsdd2.war");
+ }
+
+ public void testProbeAndResolve() throws Exception
+ {
+ Bus bus = null;
+ try {
+ bus = BusFactory.newInstance().createBus();
+
+ WSDiscoveryClient client = new WSDiscoveryClient(bus);
+ ProbeType pt = new ProbeType();
+ ScopesType scopes = new ScopesType();
+ pt.setScopes(scopes);
+ ProbeMatchesType pmts = client.probe(pt);
+ assertNotNull(pmts);
+ assertEquals(3, pmts.getProbeMatch().size());
+ List<ResolveMatchType> rmts = new LinkedList<ResolveMatchType>();
+ for (ProbeMatchType pmt : pmts.getProbeMatch()) {
+ rmts.add(client.resolve(pmt.getEndpointReference()));
+ }
+
+ final QName typeName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wsdd",
"ServiceIface");
+ checkResolveMatches(rmts, "http://" + getServerHost() +
":8080/jaxws-samples-wsdd/WSDDService", typeName);
+ checkResolveMatches(rmts, "http://" + getServerHost() +
":8080/jaxws-samples-wsdd2/WSDDService", typeName);
+ checkResolveMatches(rmts, "http://" + getServerHost() +
":8080/jaxws-samples-wsdd2/AnotherWSDDService", typeName);
+ } finally {
+ bus.shutdown(true);
+ }
+ }
+
+ public void testInvocation() throws Exception
+ {
+ Bus bus = null;
+ try {
+ bus = BusFactory.newInstance().createBus();
+
+ WSDiscoveryClient client = new WSDiscoveryClient(bus);
+ ProbeType pt = new ProbeType();
+ ScopesType scopes = new ScopesType();
+ pt.setScopes(scopes);
+ ProbeMatchesType pmts = client.probe(pt);
+ assertNotNull(pmts);
+ assertEquals(3, pmts.getProbeMatch().size());
+ List<ResolveMatchType> rmts = new LinkedList<ResolveMatchType>();
+ for (ProbeMatchType pmt : pmts.getProbeMatch()) {
+ rmts.add(client.resolve(pmt.getEndpointReference()));
+ }
+
+ int i = 0;
+ for (ResolveMatchType rmt : rmts) {
+ i++;
+ ServiceIface port = rmt.getEndpointReference().getPort(ServiceIface.class);
+ String address = rmt.getXAddrs().iterator().next();
+
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
address);
+ String expected = address.contains("AnotherWSDDService") ? "Hi
" : "Greetings ";
+ assertEquals(expected + "Alice" + i, port.greet("Alice"
+ i));
+ }
+ } finally {
+ bus.shutdown(true);
+ }
+ }
+
+ private void checkResolveMatches(List<ResolveMatchType> rmts, String address,
QName type) {
+ List<ResolveMatchType> rmtList = getByAddress(rmts, address);
+ assertEquals(1, rmtList.size());
+ assertEquals(type, rmtList.get(0).getTypes().iterator().next());
+ }
+
+ private List<ResolveMatchType> getByAddress(List<ResolveMatchType> rmts,
String address)
+ {
+ List<ResolveMatchType> list = new LinkedList<ResolveMatchType>();
+ for (ResolveMatchType rmt : rmts)
+ {
+ for (String addr : rmt.getXAddrs())
+ {
+ if (address.equals(addr))
+ {
+ list.add(rmt);
+ }
+ }
+ }
+ return list;
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsdd/WEB-INF/jboss-webservices.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsdd/WEB-INF/jboss-webservices.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsdd/WEB-INF/jboss-webservices.xml 2013-05-07
17:27:56 UTC (rev 17536)
@@ -0,0 +1,13 @@
+<?xml version="1.1" encoding="UTF-8"?>
+<webservices
+
xmlns="http://www.jboss.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="1.2"
+
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee">
+
+ <property>
+ <name>cxf.ws-discovery.enabled</name>
+ <value>true</value>
+ </property>
+
+</webservices>
\ No newline at end of file
Modified: stack/cxf/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/pom.xml 2013-05-07 17:24:29 UTC (rev 17535)
+++ stack/cxf/trunk/modules/testsuite/pom.xml 2013-05-07 17:27:56 UTC (rev 17536)
@@ -641,6 +641,9 @@
<!--# [CXF-2006] RespectBinding feature and not understood required
extensibility elements-->
<exclude>org/jboss/test/ws/jaxws/jbws2449/**</exclude>
+ <!--# [CXF-5005] Wrong EPR match in
WSDiscoveryProvider::handleResolve -->
+
<exclude>org/jboss/test/ws/jaxws/samples/wsdd/WSDiscoveryTestCase**</exclude>
+
<!--# [JBWS-2561] XOP request not properly inlined-->
<exclude>org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.*</exclude>
@@ -702,6 +705,9 @@
<!--# [CXF-2006] RespectBinding feature and not understood required
extensibility elements-->
<exclude>org/jboss/test/ws/jaxws/jbws2449/**</exclude>
+ <!--# [CXF-5005] Wrong EPR match in
WSDiscoveryProvider::handleResolve -->
+
<exclude>org/jboss/test/ws/jaxws/samples/wsdd/WSDiscoveryTestCase**</exclude>
+
<!--# [JBWS-2561] XOP request not properly inlined-->
<exclude>org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.*</exclude>
@@ -763,6 +769,9 @@
<!--# [CXF-2006] RespectBinding feature and not understood required
extensibility elements-->
<exclude>org/jboss/test/ws/jaxws/jbws2449/**</exclude>
+ <!--# [CXF-5005] Wrong EPR match in
WSDiscoveryProvider::handleResolve -->
+
<exclude>org/jboss/test/ws/jaxws/samples/wsdd/WSDiscoveryTestCase**</exclude>
+
<!--# [JBWS-2561] XOP request not properly inlined-->
<exclude>org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.*</exclude>
@@ -825,6 +834,9 @@
<!--# [CXF-2006] RespectBinding feature and not understood required
extensibility elements-->
<exclude>org/jboss/test/ws/jaxws/jbws2449/**</exclude>
+ <!--# [CXF-5005] Wrong EPR match in
WSDiscoveryProvider::handleResolve -->
+
<exclude>org/jboss/test/ws/jaxws/samples/wsdd/WSDiscoveryTestCase**</exclude>
+
<!--# [JBWS-2561] XOP request not properly inlined-->
<exclude>org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.*</exclude>