Author: alessio.soldano(a)jboss.com
Date: 2011-06-03 11:31:05 -0400 (Fri, 03 Jun 2011)
New Revision: 14465
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/helper/ClientHelper.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/helper/TestServlet.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionEJB3Helper.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionHelper.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionServletTestCase.java
Modified:
shared-testsuite/trunk/testsuite/src/test/ant-import/build-samples-jaxws.xml
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionEJB3TestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionTestCase.java
Log:
[JBWS-3306] Adding testcase
Modified: shared-testsuite/trunk/testsuite/src/test/ant-import/build-samples-jaxws.xml
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/ant-import/build-samples-jaxws.xml 2011-06-03
14:20:11 UTC (rev 14464)
+++
shared-testsuite/trunk/testsuite/src/test/ant-import/build-samples-jaxws.xml 2011-06-03
15:31:05 UTC (rev 14465)
@@ -103,6 +103,14 @@
<include
name="org/jboss/test/ws/jaxws/samples/exception/server/jaxws-handlers-server.xml"/>
</fileset>
</jar>
+ <war
warfile="${tests.output.dir}/test-libs/jaxws-samples-exception-client.war"
needxmlfile='false'>
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/exception/client/**"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/exception/ExceptionHelper.class"/>
+ <include name="org/jboss/test/helper/ClientHelper.class"/>
+ <include name="org/jboss/test/helper/TestServlet.class"/>
+ </classes>
+ </war>
<!-- jaxws-samples-handlerchain -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-handlerchain.war"
webxml="${tests.output.dir}/test-resources/jaxws/samples/handlerchain/WEB-INF/web.xml">
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/helper/ClientHelper.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/helper/ClientHelper.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/helper/ClientHelper.java 2011-06-03
15:31:05 UTC (rev 14465)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.helper;
+
+public interface ClientHelper
+{
+ public void setTargetEndpoint(String address);
+}
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/helper/TestServlet.java
===================================================================
--- shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/helper/TestServlet.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/helper/TestServlet.java 2011-06-03
15:31:05 UTC (rev 14465)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.helper;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 01-Apr-2011
+ *
+ */
+@WebServlet(name = "TestServlet", urlPatterns = "/*")
+public class TestServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
+ {
+ String helperClassName = req.getParameter("helper");
+ if (helperClassName == null || helperClassName.length() == 0)
+ throw new ServletException("helper not specified!");
+ String path = req.getParameter("path");
+ if (path == null || path.length() == 0)
+ throw new ServletException("path not specified!");
+ try
+ {
+ ClientHelper helper = (ClientHelper)
Class.forName(helperClassName).newInstance();
+ helper.setTargetEndpoint("http://" +
System.getProperty("jboss.bind.address", "localhost") +
":8080" + path);
+ List<String> failedTests = new LinkedList<String>();
+ List<String> errorTests = new LinkedList<String>();
+ Method[] methods = helper.getClass().getMethods();
+ String methodName = req.getParameter("method");
+ int testsRun = 0;
+ if (methodName != null && methodName.length() > 0)
+ {
+ Method m = null;
+ m = helper.getClass().getMethod(methodName);
+ testsRun++;
+ invokeMethod(m, helper, failedTests, errorTests);
+ }
+ else
+ {
+ for (Method m : methods)
+ {
+ if (m.getName().startsWith("test") &&
m.getParameterTypes().length == 0
+ && m.getReturnType().equals(boolean.class))
+ {
+ testsRun++;
+ invokeMethod(m, helper, failedTests, errorTests);
+ }
+ }
+ }
+ if (failedTests.isEmpty() && errorTests.isEmpty())
+ {
+ res.getWriter().print(testsRun);
+ }
+ else
+ {
+ PrintWriter w = res.getWriter();
+ w.print("# Failed tests: ");
+ for (Iterator<String> it = failedTests.iterator(); it.hasNext();)
+ {
+ w.print(it.next());
+ if (it.hasNext())
+ w.print(", ");
+ }
+ res.getWriter().print(" # Error tests: ");
+ for (Iterator<String> it = errorTests.iterator(); it.hasNext();)
+ {
+ w.print(it.next());
+ if (it.hasNext())
+ w.print(", ");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ServletException(e);
+ }
+ }
+
+ private void invokeMethod(Method m, ClientHelper helper, List<String>
failedTests, List<String> errorTests) throws ServletException
+ {
+ try
+ {
+ Object obj = m.invoke(helper);
+ if (obj != null && !(Boolean)obj)
+ {
+ failedTests.add(m.getName());
+ }
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable thrownException = e.getTargetException();
+ errorTests.add(m.getName() + ": " +
thrownException.getClass().getName() + " " + thrownException.getMessage());
+ thrownException.printStackTrace();
+ }
+ catch (Exception e)
+ {
+ throw new ServletException(e);
+ }
+ }
+}
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionEJB3Helper.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionEJB3Helper.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionEJB3Helper.java 2011-06-03
15:31:05 UTC (rev 14465)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.exception;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.jboss.test.ws.jaxws.samples.exception.client.ExceptionEndpoint;
+
+public class ExceptionEJB3Helper extends ExceptionHelper
+{
+ public ExceptionEJB3Helper(String targetEndpoint)
+ {
+ super(targetEndpoint);
+ }
+
+ public ExceptionEJB3Helper()
+ {
+ super();
+ }
+
+ protected ExceptionEndpoint getProxy() throws Exception
+ {
+ QName serviceName = new QName(targetNS,
"ExceptionEndpointEJB3ImplService");
+ URL wsdlURL = new URL(targetEndpoint + "?wsdl");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ return service.getPort(ExceptionEndpoint.class);
+ }
+}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionEJB3TestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionEJB3TestCase.java 2011-06-03
14:20:11 UTC (rev 14464)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionEJB3TestCase.java 2011-06-03
15:31:05 UTC (rev 14465)
@@ -21,14 +21,8 @@
*/
package org.jboss.test.ws.jaxws.samples.exception;
-import java.net.URL;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-
import junit.framework.Test;
-import org.jboss.test.ws.jaxws.samples.exception.client.ExceptionEndpoint;
import org.jboss.wsf.test.JBossWSTestSetup;
/**
@@ -44,13 +38,8 @@
return new JBossWSTestSetup(ExceptionEJB3TestCase.class,
"jaxws-samples-exception.jar");
}
- @Override
- protected ExceptionEndpoint getProxy() throws Exception
+ protected ExceptionHelper getHelper()
{
- QName serviceName = new QName(targetNS,
"ExceptionEndpointEJB3ImplService");
- URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-samples-exception/ExceptionEndpointEJB3Impl?wsdl");
-
- Service service = Service.create(wsdlURL, serviceName);
- return service.getPort(ExceptionEndpoint.class);
+ return new ExceptionEJB3Helper("http://" + getServerHost() +
":8080/jaxws-samples-exception/ExceptionEndpointEJB3Impl");
}
}
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionHelper.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionHelper.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionHelper.java 2011-06-03
15:31:05 UTC (rev 14465)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.exception;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.jboss.test.helper.ClientHelper;
+import org.jboss.test.ws.jaxws.samples.exception.client.ExceptionEndpoint;
+import org.jboss.test.ws.jaxws.samples.exception.client.UserException;
+import org.jboss.test.ws.jaxws.samples.exception.client.UserException_Exception;
+import org.w3c.dom.Element;
+
+public class ExceptionHelper implements ClientHelper
+{
+ protected String targetEndpoint;
+ protected String targetNS =
"http://server.exception.samples.jaxws.ws.test.jboss.org/";
+
+ public ExceptionHelper(String targetEndpoint)
+ {
+ this.targetEndpoint = targetEndpoint;
+ }
+
+ public ExceptionHelper()
+ {
+ //NOOP
+ }
+
+ protected ExceptionEndpoint getProxy() throws Exception
+ {
+ QName serviceName = new QName(targetNS, "ExceptionEndpointImplService");
+ URL wsdlURL = new URL(targetEndpoint + "?wsdl");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ return service.getPort(ExceptionEndpoint.class);
+ }
+
+ /*
+ * 10.2.2.3
+ *
+ * faultcode (Subcode in SOAP 1.2, Code set to env:Receiver)
+ * 1. SOAPFaultException.getFault().getFaultCodeAsQName()
+ * 2. env:Server (Subcode omitted for SOAP 1.2).
+ * faultstring (Reason/Text)
+ * 1. SOAPFaultException.getFault().getFaultString()
+ * 2. Exception.getMessage()
+ * 3. Exception.toString()
+ * faultactor (Role in SOAP 1.2)
+ * 1. SOAPFaultException.getFault().getFaultActor()
+ * 2. Empty
+ * detail (Detail in SOAP 1.2)
+ * 1. Serialized service specific exception (see WrapperException.getFaultInfo() in
section 2.5)
+ * 2. SOAPFaultException.getFault().getDetail()
+ */
+ public void testRuntimeException() throws Exception
+ {
+ try
+ {
+ getProxy().throwRuntimeException();
+ fail("Expected SOAPFaultException");
+ }
+ catch (SOAPFaultException e)
+ {
+ String faultString = e.getFault().getFaultString();
+ assertTrue(faultString.indexOf("OH NO, A RUNTIME EXCEPTION OCCURED.")
>= 0);
+ }
+ }
+
+ public void testSoapFaultException() throws Exception
+ {
+ try
+ {
+ getProxy().throwSoapFaultException();
+ fail("Expected SOAPFaultException");
+ }
+ catch (SOAPFaultException e)
+ {
+ assertEquals("THIS IS A FAULT STRING!",
e.getFault().getFaultString());
+ assertEquals("mr.actor", e.getFault().getFaultActor());
+ assertEquals("FooCode",
e.getFault().getFaultCodeAsName().getLocalName());
+ assertEquals("http://foo",
e.getFault().getFaultCodeAsName().getURI());
+ assertEquals("test",
((Element)e.getFault().getDetail().getChildElements().next()).getLocalName());
+ }
+ }
+
+ public void testApplicationException() throws Exception
+ {
+ try
+ {
+ getProxy().throwApplicationException();
+ fail("Expected UserException");
+ }
+ catch (UserException_Exception e)
+ {
+ UserException ue = e.getFaultInfo();
+ assertEquals("SOME VALIDATION ERROR", ue.getMessage());
+ assertEquals("validation", ue.getErrorCategory());
+ assertEquals(123, ue.getErrorCode());
+ }
+ }
+
+ private static void fail(String s) throws Exception
+ {
+ throw new Exception(s);
+ }
+
+ private static void assertEquals(Object exp, Object actual) throws Exception
+ {
+ if (!(exp.equals(actual)))
+ {
+ throw new Exception("Expected #" + exp + "# but was #" +
actual + "#");
+ }
+ }
+
+ private static void assertTrue(boolean actual) throws Exception
+ {
+ if (!(actual))
+ {
+ throw new Exception("Expected true");
+ }
+ }
+
+ @Override
+ public void setTargetEndpoint(String address)
+ {
+ targetEndpoint = address;
+ }
+}
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionServletTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionServletTestCase.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionServletTestCase.java 2011-06-03
15:31:05 UTC (rev 14465)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.exception;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+public class ExceptionServletTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(ExceptionServletTestCase.class,
"jaxws-samples-exception.war, jaxws-samples-exception-client.war");
+ }
+
+ public void testRuntimeException() throws Exception
+ {
+ assertEquals("1", runTestInContainer("testRuntimeException"));
+ }
+
+ public void testSoapFaultException() throws Exception
+ {
+ assertEquals("1",
runTestInContainer("testSoapFaultException"));
+ }
+
+ public void testApplicationException() throws Exception
+ {
+ assertEquals("1",
runTestInContainer("testApplicationException"));
+ }
+
+ private String runTestInContainer(String test) throws Exception
+ {
+ URL url = new URL("http://" + getServerHost()
+ +
":8080/jaxws-samples-exception-client?path=/jaxws-samples-exception/ExceptionEndpointService&method="
+ test
+ + "&helper=" + ExceptionHelper.class.getName());
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ return br.readLine();
+ }
+}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionTestCase.java 2011-06-03
14:20:11 UTC (rev 14464)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionTestCase.java 2011-06-03
15:31:05 UTC (rev 14465)
@@ -21,20 +21,10 @@
*/
package org.jboss.test.ws.jaxws.samples.exception;
-import java.net.URL;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-import javax.xml.ws.soap.SOAPFaultException;
-
import junit.framework.Test;
-import org.jboss.test.ws.jaxws.samples.exception.client.ExceptionEndpoint;
-import org.jboss.test.ws.jaxws.samples.exception.client.UserException;
-import org.jboss.test.ws.jaxws.samples.exception.client.UserException_Exception;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
-import org.w3c.dom.Element;
/**
* Test JAX-WS exception handling
@@ -43,50 +33,20 @@
*/
public class ExceptionTestCase extends JBossWSTest
{
- protected String targetNS =
"http://server.exception.samples.jaxws.ws.test.jboss.org/";
-
public static Test suite()
{
return new JBossWSTestSetup(ExceptionTestCase.class,
"jaxws-samples-exception.war");
}
- protected ExceptionEndpoint getProxy() throws Exception
- {
- QName serviceName = new QName(targetNS, "ExceptionEndpointImplService");
- URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-samples-exception/ExceptionEndpointService?wsdl");
-
- Service service = Service.create(wsdlURL, serviceName);
- return service.getPort(ExceptionEndpoint.class);
- }
-
- /*
- * 10.2.2.3
- *
- * faultcode (Subcode in SOAP 1.2, Code set to env:Receiver)
- * 1. SOAPFaultException.getFault().getFaultCodeAsQName()
- * 2. env:Server (Subcode omitted for SOAP 1.2).
- * faultstring (Reason/Text)
- * 1. SOAPFaultException.getFault().getFaultString()
- * 2. Exception.getMessage()
- * 3. Exception.toString()
- * faultactor (Role in SOAP 1.2)
- * 1. SOAPFaultException.getFault().getFaultActor()
- * 2. Empty
- * detail (Detail in SOAP 1.2)
- * 1. Serialized service specific exception (see WrapperException.getFaultInfo() in
section 2.5)
- * 2. SOAPFaultException.getFault().getDetail()
- */
public void testRuntimeException() throws Exception
{
try
{
- getProxy().throwRuntimeException();
- fail("Expected SOAPFaultException");
+ getHelper().testRuntimeException();
}
- catch (SOAPFaultException e)
+ catch (Exception e)
{
- String faultString = e.getFault().getFaultString();
- assertTrue(faultString.indexOf("OH NO, A RUNTIME EXCEPTION OCCURED.")
>= 0);
+ fail(e.getMessage());
}
}
@@ -94,16 +54,11 @@
{
try
{
- getProxy().throwSoapFaultException();
- fail("Expected SOAPFaultException");
+ getHelper().testSoapFaultException();
}
- catch (SOAPFaultException e)
+ catch (Exception e)
{
- assertEquals("THIS IS A FAULT STRING!",
e.getFault().getFaultString());
- assertEquals("mr.actor", e.getFault().getFaultActor());
- assertEquals("FooCode",
e.getFault().getFaultCodeAsName().getLocalName());
- assertEquals("http://foo",
e.getFault().getFaultCodeAsName().getURI());
- assertEquals("test",
((Element)e.getFault().getDetail().getChildElements().next()).getLocalName());
+ fail(e.getMessage());
}
}
@@ -111,15 +66,16 @@
{
try
{
- getProxy().throwApplicationException();
- fail("Expected UserException");
+ getHelper().testApplicationException();
}
- catch (UserException_Exception e)
+ catch (Exception e)
{
- UserException ue = e.getFaultInfo();
- assertEquals("SOME VALIDATION ERROR", ue.getMessage());
- assertEquals("validation", ue.getErrorCategory());
- assertEquals(123, ue.getErrorCode());
+ fail(e.getMessage());
}
}
+
+ protected ExceptionHelper getHelper()
+ {
+ return new ExceptionHelper("http://" + getServerHost() +
":8080/jaxws-samples-exception/ExceptionEndpointService");
+ }
}