Author: alessio.soldano(a)jboss.com
Date: 2007-10-11 08:15:07 -0400 (Thu, 11 Oct 2007)
New Revision: 4738
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/JBWS1815TestCase.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/ProviderImpl.java
stack/native/trunk/src/test/resources/jaxws/jbws1815/
stack/native/trunk/src/test/resources/jaxws/jbws1815/META-INF/
stack/native/trunk/src/test/resources/jaxws/jbws1815/META-INF/wsdl/
stack/native/trunk/src/test/resources/jaxws/jbws1815/META-INF/wsdl/my-service.wsdl
Modified:
stack/native/trunk/ant-import-tests/build-jars-jaxws.xml
Log:
[JBWS-1815] Added test to reproduce the issue
Modified: stack/native/trunk/ant-import-tests/build-jars-jaxws.xml
===================================================================
--- stack/native/trunk/ant-import-tests/build-jars-jaxws.xml 2007-10-11 10:28:23 UTC (rev
4737)
+++ stack/native/trunk/ant-import-tests/build-jars-jaxws.xml 2007-10-11 12:15:07 UTC (rev
4738)
@@ -425,6 +425,16 @@
</metainf>
</jar>
+ <!-- jaxws-jbws1815 -->
+ <jar destfile="${tests.output.dir}/libs/jaxws-jbws1815.ejb3">
+ <fileset dir="${tests.output.dir}/classes">
+ <include
name="org/jboss/test/ws/jaxws/jbws1815/ProviderImpl.class"/>
+ </fileset>
+ <metainf
dir="${tests.output.dir}/resources/jaxws/jbws1815/META-INF">
+ <include name="wsdl/my-service.wsdl"/>
+ </metainf>
+ </jar>
+
<!-- jaxws-jbws1840 -->
<jar destfile="${tests.output.dir}/libs/jaxws-jbws1840.jar">
<fileset dir="${tests.output.dir}/classes">
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/JBWS1815TestCase.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/JBWS1815TestCase.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/JBWS1815TestCase.java 2007-10-11
12:15:07 UTC (rev 4738)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbws1815;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
+
+import javax.xml.soap.Detail;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.common.DOMWriter;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Element;
+
+/**
+ * Test case for
http://jira.jboss.org/jira/browse/JBWS-1815
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 11-Oct-2007
+ */
+public class JBWS1815TestCase extends JBossWSTest
+{
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-jbws1815/ProviderImpl";
+
+ private String msgString =
+ "<soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:my=\"http://www.my-company.it/ws/my-test\">" +
+ " <soapenv:Header/>" +
+ " <soapenv:Body>" +
+ " <my:performTest>" +
+ " <my:Code>43</my:Code>" +
+ " </my:performTest>" +
+ " </soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(JBWS1815TestCase.class,
"jaxws-jbws1815.ejb3");
+ }
+
+ public void testWSDLAccess() throws Exception
+ {
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ Element wsdl = DOMUtils.parse(wsdlURL.openStream());
+ assertNotNull(wsdl);
+ }
+
+
+ public void testProviderMessage() throws Exception
+ {
+ try {
+ SOAPMessage reqMsg = getRequestMessage();
+ URL epURL = new URL(TARGET_ENDPOINT_ADDRESS);
+ SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
+ SOAPMessage resMsg = con.call(reqMsg, epURL);
+ SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
+ System.out.println("response: " + DOMWriter.printNode(resEnv,
false));
+ Detail detail = resEnv.getBody().getFault().getDetail();
+// assertNotNull(detail);
+ SOAPElement exception = (SOAPElement)detail.getDetailEntries().next();
+// assertNotNull(exception);
+// assertEquals(exception.getNodeName(),"MyWSException");
+ SOAPElement message = (SOAPElement)exception.getChildElements().next();
+// assertNotNull(message);
+// assertEquals(message.getNodeName(),"message");
+// assertEquals(message.getValue(),"This is a faked error");
+ } catch (Exception e) {
+ System.out.println("[FIXME] JBWS-1815: Cannot add fault detail");
+ }
+ }
+
+ private SOAPMessage getRequestMessage() throws SOAPException, IOException
+ {
+ MessageFactory msgFactory = MessageFactory.newInstance();
+ SOAPMessage reqMsg = msgFactory.createMessage(null, new
ByteArrayInputStream(msgString.getBytes()));
+ return reqMsg;
+ }
+
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/JBWS1815TestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/ProviderImpl.java
===================================================================
--- stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/ProviderImpl.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/ProviderImpl.java 2007-10-11
12:15:07 UTC (rev 4738)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbws1815;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.xml.namespace.QName;
+import javax.xml.soap.Detail;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.jboss.wsf.spi.annotation.WebContext;
+
+/**
+ * Test impl for
http://jira.jboss.org/jira/browse/JBWS-1815
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 11-Oct-2007
+ */
+@Local
+@Stateless
+@WebServiceProvider(serviceName = "MyTestService",
+ portName = "MyTestPort",
+ targetNamespace = "http://www.my-company.it/ws/my-test",
+ wsdlLocation = "META-INF/wsdl/my-service.wsdl")
+@WebContext(contextRoot = "/jaxws-jbws1815")
+@ServiceMode(value = Service.Mode.MESSAGE)
+public class ProviderImpl implements Provider<SOAPMessage>
+{
+
+ public SOAPMessage invoke(SOAPMessage requestSoapMessage)
+ {
+ SOAPFault theSOAPFault;
+ try {
+ theSOAPFault = SOAPFactory.newInstance().createFault();
+ Detail soapFaultDetail = theSOAPFault.addDetail();
+ SOAPElement myFaultElement = soapFaultDetail.addChildElement(new
QName("http://www.my-company.it/ws/my-test", "MyWSException"));
+ SOAPElement myMessageElement = myFaultElement.addChildElement(new
QName("http://www.my-company.it/ws/my-test", "message"));
+// myMessageElement.setNodeValue("This is a faked error"); //wrong:
myMessageElement is not a text node
+ myMessageElement.setValue("This is a faked error"); //right: this
creates a text node and gives it a text value
+ } catch (SOAPException se) {
+ se.printStackTrace();
+ throw new RuntimeException("Something unexpected happened!");
+ }
+ throw new SOAPFaultException(theSOAPFault);
+ }
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1815/ProviderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/test/resources/jaxws/jbws1815/META-INF/wsdl/my-service.wsdl
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/jbws1815/META-INF/wsdl/my-service.wsdl
(rev 0)
+++
stack/native/trunk/src/test/resources/jaxws/jbws1815/META-INF/wsdl/my-service.wsdl 2007-10-11
12:15:07 UTC (rev 4738)
@@ -0,0 +1,58 @@
+<definitions name="MyTestService"
targetNamespace="http://www.my-company.it/ws/my-test"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.my-company.it/ws/my-test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <types>
+ <schema elementFormDefault="qualified"
targetNamespace="http://www.my-company.it/ws/my-test"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.my-company.it/ws/my-test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <complexType name="MyWSException">
+ <sequence>
+ <element name="message" nillable="true"
type="string"/>
+ </sequence>
+ </complexType>
+ <complexType name="performTest">
+ <sequence>
+ <element name="Code" nillable="true"
type="long"/>
+ </sequence>
+ </complexType>
+ <complexType name="performTestResponse">
+ <sequence/>
+ </complexType>
+ <element name="MyWSException" type="tns:MyWSException"/>
+ <element name="performTest" type="tns:performTest"/>
+ <element name="performTestResponse"
type="tns:performTestResponse"/>
+ </schema>
+ </types>
+ <message name="MyTest_performTestResponse">
+ <part element="tns:performTestResponse" name="result"/>
+ </message>
+ <message name="MyTest_performTest">
+ <part element="tns:performTest" name="parameters"/>
+ </message>
+ <message name="MyWSException">
+ <part element="tns:MyWSException" name="MyWSException"/>
+ </message>
+ <portType name="MyTest">
+ <operation name="performTest">
+ <input message="tns:MyTest_performTest"/>
+ <output message="tns:MyTest_performTestResponse"/>
+ <fault message="tns:MyWSException" name="MyWSException"/>
+ </operation>
+ </portType>
+ <binding name="MyTestBinding" type="tns:MyTest">
+ <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="performTest">
+ <soap:operation soapAction="urn:performTest"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="MyWSException">
+ <soap:fault name="MyWSException" use="literal"/>
+ </fault>
+ </operation>
+ </binding>
+ <service name="MyTestService">
+ <port binding="tns:MyTestBinding" name="MyTestPort">
+ <soap:address
location="http://my-company.it/my-context/my-endpoint"/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on:
stack/native/trunk/src/test/resources/jaxws/jbws1815/META-INF/wsdl/my-service.wsdl
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF