Author: alessio.soldano(a)jboss.com
Date: 2008-02-21 09:22:18 -0500 (Thu, 21 Feb 2008)
New Revision: 5758
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/CustomException.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/SimpleException.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpoint.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpointImpl.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java
stack/native/trunk/src/test/resources/jaxws/webfault/
stack/native/trunk/src/test/resources/jaxws/webfault/WEB-INF/
stack/native/trunk/src/test/resources/jaxws/webfault/WEB-INF/web.xml
Modified:
stack/native/trunk/ant-import-tests/build-jars-jaxws.xml
Log:
[JBWS-1211] Adding required test case
Modified: stack/native/trunk/ant-import-tests/build-jars-jaxws.xml
===================================================================
--- stack/native/trunk/ant-import-tests/build-jars-jaxws.xml 2008-02-21 10:42:56 UTC (rev
5757)
+++ stack/native/trunk/ant-import-tests/build-jars-jaxws.xml 2008-02-21 14:22:18 UTC (rev
5758)
@@ -659,6 +659,16 @@
<include
name="org/jboss/test/ws/jaxws/holder/HolderServiceImpl.class"/>
</classes>
</war>
+
+ <!-- jaxws-samples-webfault -->
+ <war warfile="${tests.output.dir}/libs/jaxws-webfault.war"
webxml="${tests.output.dir}/resources/jaxws/webfault/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/classes">
+ <include
name="org/jboss/test/ws/jaxws/webfault/TestEndpoint.class"/>
+ <include
name="org/jboss/test/ws/jaxws/webfault/TestEndpointImpl.class"/>
+ <include
name="org/jboss/test/ws/jaxws/webfault/CustomException.class"/>
+ <include
name="org/jboss/test/ws/jaxws/webfault/SimpleException.class"/>
+ </classes>
+ </war>
<!-- jaxws-wsdd -->
<war warfile="${tests.output.dir}/libs/jaxws-wsdd.war"
webxml="${tests.output.dir}/resources/jaxws/wsdd/WEB-INF/web.xml">
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/CustomException.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/CustomException.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/CustomException.java 2008-02-21
14:22:18 UTC (rev 5758)
@@ -0,0 +1,52 @@
+/*
+ * 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.webfault;
+
+import javax.xml.ws.WebFault;
+
+/**
+ * A custom exception
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 21-Feb-2008
+ */
+@WebFault(name = "myCustomFault", targetNamespace=
"org.jboss.test.ws.jaxws.webfault.exceptions")
+public class CustomException extends Exception
+{
+ private Integer number;
+
+ public CustomException(String message, Integer number)
+ {
+ super(message);
+ this.number = number;
+ }
+
+ public Integer getNumber()
+ {
+ return number;
+ }
+
+ public void setNumber(Integer number)
+ {
+ this.number = number;
+ }
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/CustomException.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/SimpleException.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/SimpleException.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/SimpleException.java 2008-02-21
14:22:18 UTC (rev 5758)
@@ -0,0 +1,52 @@
+/*
+ * 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.webfault;
+
+import javax.xml.ws.WebFault;
+
+/**
+ * A simple exception using @WebFault defaults
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 21-Feb-2008
+ */
+@WebFault
+public class SimpleException extends Exception
+{
+ private Integer number;
+
+ public SimpleException(String message, Integer number)
+ {
+ super(message);
+ this.number = number;
+ }
+
+ public Integer getNumber()
+ {
+ return number;
+ }
+
+ public void setNumber(Integer number)
+ {
+ this.number = number;
+ }
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/SimpleException.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpoint.java
===================================================================
--- stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpoint.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpoint.java 2008-02-21
14:22:18 UTC (rev 5758)
@@ -0,0 +1,34 @@
+/*
+ * 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.webfault;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService (name="TestEndpoint")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface TestEndpoint
+{
+ public void throwCustomException(String input) throws CustomException;
+
+ public void throwSimpleException(String input) throws SimpleException;
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpointImpl.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpointImpl.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpointImpl.java 2008-02-21
14:22:18 UTC (rev 5758)
@@ -0,0 +1,51 @@
+/*
+ * 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.webfault;
+
+import javax.jws.WebService;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Test the JSR-181 annotation: javax.jws.WebFault
+ *
+ * @author alessio.soldano(a)jboss.org
+ * @since 21-Feb-2008
+ */
+@WebService(name="TestEndpoint", serviceName="TestEndpointService",
endpointInterface = "org.jboss.test.ws.jaxws.webfault.TestEndpoint")
+public class TestEndpointImpl
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(TestEndpointImpl.class);
+
+ public void throwCustomException(String input) throws CustomException
+ {
+ log.info("throwCustomException: " + input);
+ throw new CustomException("This is a @WebFault test", (input != null ?
input.length() : 0));
+ }
+
+ public void throwSimpleException(String input) throws SimpleException
+ {
+ log.info("throwSimpleException: " + input);
+ throw new SimpleException("This is a @WebFault test", (input != null ?
input.length() : 0));
+ }
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/TestEndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java 2008-02-21
14:22:18 UTC (rev 5758)
@@ -0,0 +1,118 @@
+/*
+ * 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.webfault;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLUtils;
+import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
+import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Test the JSR-181 annotation: javax.jws.WebFault
+ *
+ * @author alessio.soldano(a)jboss.org
+ * @since 21-Feb-2008
+ */
+public class WebFaultTestCase extends JBossWSTest
+{
+ private String endpointURL = "http://" + getServerHost() +
":8080/jaxws-webfault";
+ private static final String TARGET_NS =
"http://webfault.jaxws.ws.test.jboss.org/";
+ private static final String CUSTOM_FAULT_NS =
"org.jboss.test.ws.jaxws.webfault.exceptions";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(WebFaultTestCase.class,
"jaxws-webfault.war");
+ }
+
+ /**
+ * Tests whether the @WebFault annotation correctly sets the fault element's name
and namespace
+ * (the type doesn't depend on @WebFault, see [JBWS-1904] about this)
+ *
+ * @throws Exception
+ */
+ public void testWebFaultElement() throws Exception
+ {
+ JBossXSModel xsModel = getSchemaModel();
+ XSElementDeclaration myCustomFaultElement =
xsModel.getElementDeclaration("myCustomFault", CUSTOM_FAULT_NS);
+ assertNotNull(myCustomFaultElement);
+ myCustomFaultElement = xsModel.getElementDeclaration("myCustomFault",
TARGET_NS);
+ assertNull(myCustomFaultElement);
+ myCustomFaultElement = xsModel.getElementDeclaration("CustomException",
CUSTOM_FAULT_NS);
+ assertNull(myCustomFaultElement);
+ XSElementDeclaration simpleExceptiontElement =
xsModel.getElementDeclaration("SimpleException", TARGET_NS); //default to
exception simple class name
+ assertNotNull(simpleExceptiontElement);
+ }
+
+ private JBossXSModel getSchemaModel() throws Exception
+ {
+ URL wsdlURL = new URL(endpointURL + "?wsdl");
+ WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
+ WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
+ return WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
+ }
+
+ public void testInvocation() throws Exception
+ {
+ URL wsdlURL = new URL(endpointURL + "?wsdl");
+ QName serviceName = new QName(TARGET_NS, "TestEndpointService");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ TestEndpoint port = (TestEndpoint)service.getPort(TestEndpoint.class);
+
+ try
+ {
+ port.throwCustomException("Hello");
+ fail("Exception expected!");
+ }
+ catch (CustomException e)
+ {
+ assertEquals(new Integer(5), e.getNumber());
+ }
+ catch (Exception e)
+ {
+ fail("Wrong exception catched!");
+ }
+ try
+ {
+ port.throwSimpleException("World");
+ fail("Exception expected!");
+ }
+ catch (SimpleException e)
+ {
+ assertEquals(new Integer(5), e.getNumber());
+ }
+ catch (Exception e)
+ {
+ fail("Wrong exception catched!");
+ }
+ }
+}
\ No newline at end of file
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/test/resources/jaxws/webfault/WEB-INF/web.xml
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/webfault/WEB-INF/web.xml
(rev 0)
+++ stack/native/trunk/src/test/resources/jaxws/webfault/WEB-INF/web.xml 2008-02-21
14:22:18 UTC (rev 5758)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>TestService</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.webfault.TestEndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Property changes on: stack/native/trunk/src/test/resources/jaxws/webfault/WEB-INF/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF