You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2008/11/09 15:09:33 UTC
svn commit: r712500 - in
/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit:
axis2/endpoint/AxisTestEndpoint.java
axis2/endpoint/AxisTestEndpointContext.java tests/TestResource.java
Author: veithen
Date: Sun Nov 9 06:09:32 2008
New Revision: 712500
URL: http://svn.apache.org/viewvc?rev=712500&view=rev
Log:
Transport test kit: fail directly if the transport disables the service.
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java
Modified: webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java?rev=712500&r1=712499&r2=712500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java (original)
+++ webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java Sun Nov 9 06:09:32 2008
@@ -19,18 +19,19 @@
package org.apache.axis2.transport.testkit.axis2.endpoint;
-import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Iterator;
import java.util.List;
import java.util.UUID;
+import junit.framework.Assert;
+
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.base.BaseUtils;
import org.apache.axis2.transport.base.event.TransportError;
import org.apache.axis2.transport.base.event.TransportErrorListener;
import org.apache.axis2.transport.base.event.TransportErrorSource;
@@ -101,6 +102,11 @@
service.addParameter(AxisService.SUPPORT_SINGLE_OP, true);
context.getAxisConfiguration().addService(service);
+
+ // The transport may disable the service. In that case, fail directly.
+ if (!BaseUtils.isUsingTransport(service, context.getTransportName())) {
+ Assert.fail("The service has been disabled by the transport");
+ }
}
@TearDown @SuppressWarnings("unused")
Modified: webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java?rev=712500&r1=712499&r2=712500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java (original)
+++ webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java Sun Nov 9 06:09:32 2008
@@ -48,7 +48,7 @@
public class AxisTestEndpointContext {
public static final AxisTestEndpointContext INSTANCE = new AxisTestEndpointContext();
- private @Transient TransportListener listener;
+ private @Transient TransportInDescription trpInDesc;
private @Transient UtilsTransportServer server;
private AxisTestEndpointContext() {}
@@ -59,8 +59,7 @@
server = new UtilsTransportServer();
TransportOutDescription trpOutDesc = tdf.createTransportOutDescription();
- TransportInDescription trpInDesc = tdf.createTransportInDescription();
- listener = trpInDesc.getReceiver();
+ trpInDesc = tdf.createTransportInDescription();
server.addTransport(trpInDesc, trpOutDesc);
for (AxisTestEndpointContextConfigurator configurator : configurators) {
@@ -87,12 +86,16 @@
}
public TransportListener getTransportListener() {
- return listener;
+ return trpInDesc.getReceiver();
+ }
+
+ public String getTransportName() {
+ return trpInDesc.getName();
}
public String getEPR(AxisService service) throws AxisFault {
EndpointReference[] endpointReferences =
- listener.getEPRsForService(service.getName(), "localhost");
+ trpInDesc.getReceiver().getEPRsForService(service.getName(), "localhost");
return endpointReferences != null && endpointReferences.length > 0
? endpointReferences[0].getAddress() : null;
}
Modified: webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java?rev=712500&r1=712499&r2=712500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java (original)
+++ webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java Sun Nov 9 06:09:32 2008
@@ -21,6 +21,7 @@
import java.lang.reflect.Array;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.HashSet;
@@ -48,7 +49,18 @@
}
public void execute(Object object) throws Exception {
- method.invoke(object, args);
+ try {
+ method.invoke(object, args);
+ } catch (InvocationTargetException ex) {
+ Throwable cause = ex.getCause();
+ if (cause instanceof Error) {
+ throw (Error)cause;
+ } else if (cause instanceof Exception) {
+ throw (Exception)cause;
+ } else {
+ throw ex;
+ }
+ }
}
}