Author: jim.ma
Date: 2009-11-20 02:38:42 -0500 (Fri, 20 Nov 2009)
New Revision: 11137
Added:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2820/
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2820/InvokerEJB3Test.java
Modified:
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/InvokerEJB3.java
stack/metro/trunk/modules/testsuite/metro-tests/pom.xml
Log:
[JBWS-2820]:Applied Andreas Wuest's patch. Thanks Andreas
Modified:
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/InvokerEJB3.java
===================================================================
---
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/InvokerEJB3.java 2009-11-19
15:50:30 UTC (rev 11136)
+++
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/InvokerEJB3.java 2009-11-20
07:38:42 UTC (rev 11137)
@@ -24,6 +24,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import javax.ejb.EJBAccessException;
import javax.ejb.EJBException;
import javax.xml.ws.Provider;
import javax.xml.ws.WebFault;
@@ -109,9 +110,11 @@
return retObj;
}
- private void handleException(Exception ex)
+ protected void handleException(Exception ex)
throws InvocationTargetException, IllegalAccessException
{
+ final Exception originalException = ex;
+
//Unwrap EJBException
if (ex instanceof EJBException)
ex = ((EJBException)ex).getCausedByException();
@@ -122,6 +125,10 @@
if (ex instanceof IllegalAccessException)
throw (IllegalAccessException)ex;
+ if (ex == null && originalException instanceof EJBAccessException)
+ throw new IllegalAccessException(originalException.getMessage());
+
+
//check if this is a declared fault; Metro expects an InvocationTargetException
//for declared faults also when calling an EJB3 endpoint
if (ex.getClass().isAnnotationPresent(WebFault.class))
Modified: stack/metro/trunk/modules/testsuite/metro-tests/pom.xml
===================================================================
--- stack/metro/trunk/modules/testsuite/metro-tests/pom.xml 2009-11-19 15:50:30 UTC (rev
11136)
+++ stack/metro/trunk/modules/testsuite/metro-tests/pom.xml 2009-11-20 07:38:42 UTC (rev
11137)
@@ -20,6 +20,11 @@
<artifactId>jbossws-metro-client</artifactId>
<version>${version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.ws.metro</groupId>
+ <artifactId>jbossws-metro-server</artifactId>
+ <version>${version}</version>
+ </dependency>
</dependencies>
<!-- Profiles -->
Added:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2820/InvokerEJB3Test.java
===================================================================
---
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2820/InvokerEJB3Test.java
(rev 0)
+++
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2820/InvokerEJB3Test.java 2009-11-20
07:38:42 UTC (rev 11137)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.jbws2820;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.ejb.EJBAccessException;
+
+import org.jboss.wsf.stack.metro.InvokerEJB3;
+
+import junit.framework.TestCase;
+
+import com.sun.xml.ws.api.server.InstanceResolver;
+
+/**
+ * @author Andreas Wuest
+ *
+ */
+public class InvokerEJB3Test extends TestCase
+{
+
+ public void testHandleException()
+ {
+ CustomInvokerEJB3 invoker = new CustomInvokerEJB3(null);
+ try
+ {
+ invoker.runHandleException(new EJBAccessException("authentication
failure."));
+ fail("expect InvokerEjB3 throws exception");
+ }
+ catch (InvocationTargetException e)
+ {
+ fail("InvocationTargetException is not expected");
+ }
+ catch (IllegalAccessException e)
+ {
+ assertTrue("authentication failure.".equals(e.getMessage()));
+ }
+ }
+
+ private final class CustomInvokerEJB3 extends InvokerEJB3
+ {
+ public CustomInvokerEJB3(InstanceResolver resolver)
+ {
+ super(resolver);
+ }
+
+ public void runHandleException(Exception ex) throws InvocationTargetException,
IllegalAccessException
+ {
+ super.handleException(ex);
+ }
+ }
+
+}