[jbossws-commits] JBossWS SVN: r18810 - in stack/cxf/trunk/modules/testsuite/cxf-tests/src/test: java/org/jboss/test/ws/jaxws/cxf/jbws3628 and 4 other directories.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Mon Jul 21 16:50:55 EDT 2014
Author: asoldano
Date: 2014-07-21 16:50:55 -0400 (Mon, 21 Jul 2014)
New Revision: 18810
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/CheckInterceptor.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOne.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOneImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/JBWS3628TestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3628/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3628/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3628/WEB-INF/wsdl/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3628/WEB-INF/wsdl/service.wsdl
Log:
[JBWS-3628] Adding testcase
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/CheckInterceptor.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/CheckInterceptor.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/CheckInterceptor.java 2014-07-21 20:50:55 UTC (rev 18810)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.cxf.jbws3628;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+/**
+ * A server side interceptor that verifies every incoming message has WS-Addressing stuff
+ */
+public class CheckInterceptor extends AbstractPhaseInterceptor<Message>
+{
+ public CheckInterceptor()
+ {
+ super(Phase.RECEIVE);
+ }
+
+ public void handleMessage(Message message) throws Fault
+ {
+ String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
+ if (!method.equals("POST"))
+ {
+ return;
+ }
+ StringBuilder sb = new StringBuilder();
+ InputStream is = message.getContent(InputStream.class);
+ if (is != null)
+ {
+ CachedOutputStream bos = new CachedOutputStream();
+ try
+ {
+ copy(is, bos, 4096);
+ bos.flush();
+ is.close();
+ message.setContent(InputStream.class, bos.getInputStream());
+ bos.writeCacheTo(sb);
+ bos.close();
+ }
+ catch (IOException e)
+ {
+ throw new Fault(e);
+ }
+ }
+ if (!sb.toString().contains("http://www.w3.org/2005/08/addressing"))
+ {
+ throw new Fault("Could not find any reference to namespace 'http://www.w3.org/2005/08/addressing' in handled message.",
+ java.util.logging.Logger.getLogger(CheckInterceptor.class.getName()));
+ }
+ }
+
+ public static int copy(final InputStream input, final OutputStream output, int bufferSize) throws IOException
+ {
+ int avail = input.available();
+ if (avail > 262144)
+ {
+ avail = 262144;
+ }
+ if (avail > bufferSize)
+ {
+ bufferSize = avail;
+ }
+ final byte[] buffer = new byte[bufferSize];
+ int n = 0;
+ n = input.read(buffer);
+ int total = 0;
+ while (-1 != n)
+ {
+ if (n == 0)
+ {
+ throw new IOException("0 bytes read in violation of InputStream.read(byte[])");
+ }
+ output.write(buffer, 0, n);
+ total += n;
+ n = input.read(buffer);
+ }
+ return total;
+ }
+
+}
Property changes on: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/CheckInterceptor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOne.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOne.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOne.java 2014-07-21 20:50:55 UTC (rev 18810)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.cxf.jbws3628;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+ at WebService(name = "EndpointOne", targetNamespace = "http://org.jboss.ws.jaxws.cxf/jbws3628", serviceName = "ServiceOne")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface EndpointOne
+{
+ String echo(String input);
+}
Property changes on: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOne.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOneImpl.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOneImpl.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOneImpl.java 2014-07-21 20:50:55 UTC (rev 18810)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.cxf.jbws3628;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.cxf.interceptor.InInterceptors;
+import org.jboss.logging.Logger;
+
+ at WebService(name = "EndpointOne", targetNamespace = "http://org.jboss.ws.jaxws.cxf/jbws3628", serviceName = "ServiceOne", wsdlLocation = "WEB-INF/wsdl/service.wsdl")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+ at InInterceptors(interceptors="org.jboss.test.ws.jaxws.cxf.jbws3628.CheckInterceptor")
+public class EndpointOneImpl
+{
+ @WebMethod
+ public String echo(String input)
+ {
+ Logger.getLogger(this.getClass()).info("echo: " + input);
+ return input;
+ }
+}
Property changes on: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/EndpointOneImpl.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/JBWS3628TestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/JBWS3628TestCase.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/JBWS3628TestCase.java 2014-07-21 20:50:55 UTC (rev 18810)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.cxf.jbws3628;
+
+import java.io.File;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.ws.common.IOUtils;
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
+import org.jboss.wsf.test.JBossWSTestHelper.BaseDeployment;
+
+/**
+ * Testcase for system property expansion support in WSDL documents.
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 21-Jul-2014
+ */
+public class JBWS3628TestCase extends JBossWSTest
+{
+ private static final String POLICY_NAME = "WS-Addressing_policy";
+
+ public static BaseDeployment<?>[] createDeployments() {
+ List<BaseDeployment<?>> list = new LinkedList<BaseDeployment<?>>();
+ list.add(new JBossWSTestHelper.WarDeployment("jaxws-cxf-jbws3628.war") { {
+ archive
+ .setManifest(new StringAsset("Manifest-Version: 1.0\n"
+ + "Dependencies: org.apache.cxf\n"))
+ .addClass(org.jboss.test.ws.jaxws.cxf.jbws3628.EndpointOneImpl.class)
+ .addClass(org.jboss.test.ws.jaxws.cxf.jbws3628.CheckInterceptor.class)
+ .addAsWebInfResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws3628/WEB-INF/wsdl/service.wsdl"), "wsdl/service.wsdl");
+ }
+ });
+ return list.toArray(new BaseDeployment<?>[list.size()]);
+ }
+
+ public static Test suite()
+ {
+ TestSetup setup = new JBossWSCXFTestSetup(JBWS3628TestCase.class, JBossWSTestHelper.writeToFile(createDeployments())) {
+
+ private static final String PROPERTY_NAME = "org.jboss.wsf.test.JBWS3628TestCase.policy";
+ private String formerValue;
+
+ @Override
+ public void setUp() throws Exception {
+ formerValue = JBossWSTestHelper.setSystemProperty(PROPERTY_NAME, POLICY_NAME);
+ super.setUp();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ JBossWSTestHelper.setSystemProperty(PROPERTY_NAME, formerValue);
+ formerValue = null;
+ }
+ };
+ return setup;
+ }
+
+ public void testWSDL() throws Exception {
+ URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-cxf-jbws3628/ServiceOne" + "?wsdl");
+ checkPolicyReference(wsdlURL, POLICY_NAME);
+ }
+
+ public void testInvocation() throws Exception {
+ URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-cxf-jbws3628/ServiceOne" + "?wsdl");
+ Service service = Service.create(wsdlURL, new QName("http://org.jboss.ws.jaxws.cxf/jbws3628", "ServiceOne"));
+ EndpointOne port = service.getPort(new QName("http://org.jboss.ws.jaxws.cxf/jbws3628", "EndpointOnePort"), EndpointOne.class);
+ assertEquals("Foo", port.echo("Foo"));
+ }
+
+ private void checkPolicyReference(URL wsdlURL, String refId) throws Exception {
+ final String wsdl = IOUtils.readAndCloseStream(wsdlURL.openStream());
+ assertTrue("WSDL does not contain policy reference to '" + refId + "'", wsdl.contains("<wsp:PolicyReference URI=\"#" + refId + "\"/>"));
+ }
+
+}
Property changes on: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3628/JBWS3628TestCase.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3628/WEB-INF/wsdl/service.wsdl
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3628/WEB-INF/wsdl/service.wsdl (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3628/WEB-INF/wsdl/service.wsdl 2014-07-21 20:50:55 UTC (rev 18810)
@@ -0,0 +1,51 @@
+<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://org.jboss.ws.jaxws.cxf/jbws3628" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="ServiceOne" targetNamespace="http://org.jboss.ws.jaxws.cxf/jbws3628">
+ <wsdl:message name="echoResponse">
+ <wsdl:part name="return" type="xsd:string">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="echo">
+ <wsdl:part name="arg0" type="xsd:string">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="EndpointOne">
+ <wsdl:operation name="echo">
+ <wsdl:input message="tns:echo" name="echo">
+ </wsdl:input>
+ <wsdl:output message="tns:echoResponse" name="echoResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="ServiceOneSoapBinding" type="tns:EndpointOne">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsp:PolicyReference URI="#@org.jboss.wsf.test.JBWS3628TestCase.policy@"/>
+ <wsdl:operation name="echo">
+ <soap:operation soapAction="" style="rpc"/>
+ <wsdl:input name="echo">
+ <soap:body namespace="http://org.jboss.ws.jaxws.cxf/jbws3628" use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="echoResponse">
+ <soap:body namespace="http://org.jboss.ws.jaxws.cxf/jbws3628" use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="ServiceOne">
+ <wsdl:port binding="tns:ServiceOneSoapBinding" name="EndpointOnePort">
+ <soap:address location="http://localhost:8080/jaxws-cxf-jbws3628/ServiceOne"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" wsu:Id="WS-RM_Policy">
+ <wsrmp:RMAssertion xmlns:wsrmp="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
+ <wsrmp:InactivityTimeout Milliseconds="600000"/>
+ <wsrmp:BaseRetransmissionInterval Milliseconds="3000"/>
+ <wsrmp:ExponentialBackoff/>
+ <wsrmp:AcknowledgementInterval Milliseconds="200"/>
+ </wsrmp:RMAssertion>
+ </wsp:Policy>
+
+ <wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" wsu:Id="WS-Addressing_policy">
+ <wsam:Addressing>
+ <wsp:Policy/>
+ </wsam:Addressing>
+ </wsp:Policy>
+</wsdl:definitions>
\ No newline at end of file
Property changes on: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3628/WEB-INF/wsdl/service.wsdl
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
More information about the jbossws-commits
mailing list