Author: veithen
Date: Sun Oct 12 05:42:18 2008
New Revision: 703812
URL: http://svn.apache.org/viewvc?rev=703812&view=rev
Log:
* Added a TransportErrorListener infrastructure and instrumented the mail
transport listener with this.
* Changed the testkit to detect transport errors in the listeners without
waiting for timeout.
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/EndpointErrorListener.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpoint.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpointSupport.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/InterruptingEndpointErrorListener.java
Modified:
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisAsyncEndpoint.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisEchoEndpoint.java
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/endpoint/AsyncEndpoint.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEchoEndpoint.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEndpoint.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/RequestResponseMessageTestCase.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLRequestResponseMessageTestCase.java
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/misc/MinConcurrencyTest.java
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java?rev=703812&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java
Sun Oct 12 05:42:18 2008
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.base.event;
+
+import org.apache.axis2.description.AxisService;
+
+public class TransportError {
+ private final Object source;
+ private final AxisService service;
+ private final Throwable exception;
+
+ public TransportError(Object source, AxisService service, Throwable
exception) {
+ this.source = source;
+ this.service = service;
+ this.exception = exception;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+ public AxisService getService() {
+ return service;
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+}
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java?rev=703812&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java
Sun Oct 12 05:42:18 2008
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.base.event;
+
+public interface TransportErrorListener {
+ void error(TransportError error);
+}
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java?rev=703812&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java
Sun Oct 12 05:42:18 2008
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.base.event;
+
+public interface TransportErrorSource {
+ void addErrorListener(TransportErrorListener listener);
+ void removeErrorListener(TransportErrorListener listener);
+}
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java?rev=703812&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java
Sun Oct 12 05:42:18 2008
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.base.event;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.axis2.description.AxisService;
+
+public class TransportErrorSourceSupport implements TransportErrorSource {
+ private final Object source;
+ private final List<TransportErrorListener> listeners = new
LinkedList<TransportErrorListener>();
+
+ public TransportErrorSourceSupport(Object source) {
+ this.source = source;
+ }
+
+ public synchronized void addErrorListener(TransportErrorListener listener)
{
+ listeners.add(listener);
+ }
+
+ public synchronized void removeErrorListener(TransportErrorListener
listener) {
+ listeners.remove(listener);
+ }
+
+ public synchronized void error(AxisService service, Throwable ex) {
+ if (!listeners.isEmpty()) {
+ TransportError error = new TransportError(source, service, ex);
+ for (TransportErrorListener listener : listeners) {
+ listener.error(error);
+ }
+ }
+ }
+}
Modified:
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
Sun Oct 12 05:42:18 2008
@@ -36,6 +36,9 @@
import org.apache.axis2.transport.base.BaseUtils;
import org.apache.axis2.transport.base.ManagementSupport;
import org.apache.axis2.transport.base.ParamUtils;
+import org.apache.axis2.transport.base.event.TransportErrorListener;
+import org.apache.axis2.transport.base.event.TransportErrorSource;
+import org.apache.axis2.transport.base.event.TransportErrorSourceSupport;
import javax.mail.Flags;
import javax.mail.Folder;
@@ -71,10 +74,12 @@
*/
public class MailTransportListener extends
AbstractPollingTransportListener<PollTableEntry>
- implements ManagementSupport {
+ implements ManagementSupport, TransportErrorSource {
public static final String DELETE = "DELETE";
public static final String MOVE = "MOVE";
+
+ private final TransportErrorSourceSupport tess = new
TransportErrorSourceSupport(this);
/**
* Initializes the Mail transport
@@ -216,6 +221,7 @@
log.error("Failed to process message", e);
entry.setLastPollState(PollTableEntry.FAILED);
metrics.incrementFaultsReceiving();
+ tess.error(entry.getService(), e);
}
moveOrDeleteAfterProcessing(entry, store, folder,
messages[i]);
@@ -629,4 +635,12 @@
return entry;
}
}
+
+ public void addErrorListener(TransportErrorListener listener) {
+ tess.addErrorListener(listener);
+ }
+
+ public void removeErrorListener(TransportErrorListener listener) {
+ tess.removeErrorListener(listener);
+ }
}
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
Sun Oct 12 05:42:18 2008
@@ -34,6 +34,7 @@
import org.apache.axis2.transport.testkit.client.AsyncTestClient;
import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
import org.apache.axis2.transport.testkit.endpoint.TestEndpoint;
import org.apache.axis2.transport.testkit.message.AxisMessage;
import org.apache.axis2.transport.testkit.message.MessageDecoder;
@@ -122,7 +123,7 @@
private final
ResourceList<RequestResponseTestClient<XMLMessage,XMLMessage>>
xmlRequestResponseClients = new
ResourceList<RequestResponseTestClient<XMLMessage,XMLMessage>>();
- private final ResourceList<TestEndpoint> echoEndpoints = new
ResourceList<TestEndpoint>();
+ private final ResourceList<InOutEndpoint> echoEndpoints = new
ResourceList<InOutEndpoint>();
public TransportTestSuiteBuilder(ManagedTestSuite suite) {
this.suite = suite;
@@ -196,7 +197,7 @@
xmlRequestResponseClients.add(adapt(client,
MessageEncoder.XML_TO_STRING, MessageDecoder.STRING_TO_XML), relatedResources);
}
- public void addEchoEndpoint(TestEndpoint endpoint, Object...
relatedResources) {
+ public void addEchoEndpoint(InOutEndpoint endpoint, Object...
relatedResources) {
echoEndpoints.add(endpoint, relatedResources);
}
@@ -251,7 +252,7 @@
}
for (ResourceRelation<RequestResponseChannel> channel :
requestResponseChannels) {
for
(ResourceRelation<RequestResponseTestClient<XMLMessage,XMLMessage>> client :
xmlRequestResponseClients) {
- for (ResourceRelation<TestEndpoint> endpoint : echoEndpoints) {
+ for (ResourceRelation<InOutEndpoint> endpoint : echoEndpoints)
{
Object[] resources = merge(env, channel, client, endpoint);
for (MessageTestData data : messageTestData) {
for (XMLMessage.Type type : XMLMessage.Type.values()) {
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisAsyncEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisAsyncEndpoint.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisAsyncEndpoint.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisAsyncEndpoint.java
Sun Oct 12 05:42:18 2008
@@ -37,7 +37,7 @@
import org.apache.axis2.transport.testkit.message.AxisMessage;
import org.apache.axis2.transport.testkit.message.IncomingMessage;
-public class AxisAsyncEndpoint extends AxisTestEndpoint implements
AsyncEndpoint<AxisMessage>, MessageReceiver /*, TransportErrorListener*/ {
+public class AxisAsyncEndpoint extends AxisTestEndpoint implements
AsyncEndpoint<AxisMessage>, MessageReceiver {
private interface Event {
IncomingMessage<AxisMessage> process() throws Throwable;
}
@@ -46,7 +46,7 @@
private BlockingQueue<Event> queue;
@SuppressWarnings("unused")
- private void setUp(MessageContextValidator[] validators) {
+ private void setUp(AxisTestEndpointContext context,
MessageContextValidator[] validators) {
this.validators = validators;
queue = new LinkedBlockingQueue<Event>();
}
@@ -82,13 +82,14 @@
});
}
-// public void error(final TransportError error) {
-// queue.add(new Event() {
-// public MessageData process() throws Throwable {
-// throw error.getException();
-// }
-// });
-// }
+ @Override
+ protected void onTransportError(final Throwable ex) {
+ queue.add(new Event() {
+ public IncomingMessage<AxisMessage> process() throws Throwable {
+ throw ex;
+ }
+ });
+ }
public void clear() throws Exception {
queue.clear();
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisEchoEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisEchoEndpoint.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisEchoEndpoint.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisEchoEndpoint.java
Sun Oct 12 05:42:18 2008
@@ -26,8 +26,13 @@
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.InOutAxisOperation;
import org.apache.axis2.receivers.AbstractInOutMessageReceiver;
+import org.apache.axis2.transport.testkit.endpoint.EndpointErrorListener;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpointSupport;
-public class AxisEchoEndpoint extends AxisTestEndpoint {
+public class AxisEchoEndpoint extends AxisTestEndpoint implements
InOutEndpoint {
+ private final InOutEndpointSupport support = new InOutEndpointSupport();
+
@Override
protected AxisOperation createOperation() {
AxisOperation operation = new InOutAxisOperation(new QName("echo"));
@@ -39,4 +44,17 @@
});
return operation;
}
+
+ @Override
+ protected void onTransportError(Throwable ex) {
+ support.fireEndpointError(ex);
+ }
+
+ public void addEndpointErrorListener(EndpointErrorListener listener) {
+ support.addEndpointErrorListener(listener);
+ }
+
+ public void removeEndpointErrorListener(EndpointErrorListener listener) {
+ support.removeEndpointErrorListener(listener);
+ }
}
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=703812&r1=703811&r2=703812&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 Oct 12 05:42:18 2008
@@ -24,19 +24,32 @@
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.base.event.TransportError;
+import org.apache.axis2.transport.base.event.TransportErrorListener;
+import org.apache.axis2.transport.base.event.TransportErrorSource;
import org.apache.axis2.transport.testkit.axis2.AxisServiceConfigurator;
import org.apache.axis2.transport.testkit.channel.Channel;
-import org.apache.axis2.transport.testkit.endpoint.TestEndpoint;
import org.apache.axis2.transport.testkit.name.Name;
@Name("axis")
-public abstract class AxisTestEndpoint implements TestEndpoint {
+public abstract class AxisTestEndpoint implements TransportErrorListener {
private AxisTestEndpointContext context;
+ private TransportErrorSource transportErrorSource;
private AxisService service;
@SuppressWarnings("unused")
private void setUp(AxisTestEndpointContext context, Channel channel,
AxisServiceConfigurator[] configurators) throws Exception {
this.context = context;
+
+ TransportListener listener = context.getTransportListener();
+ if (listener instanceof TransportErrorSource) {
+ transportErrorSource = (TransportErrorSource)listener;
+ transportErrorSource.addErrorListener(this);
+ } else {
+ transportErrorSource = null;
+ }
+
String path = new
URI(channel.getEndpointReference().getAddress()).getPath();
String serviceName;
if (path != null && path.startsWith(Channel.CONTEXT_PATH + "/")) {
@@ -58,10 +71,23 @@
@SuppressWarnings("unused")
private void tearDown() throws Exception {
+ if (transportErrorSource != null) {
+ transportErrorSource.removeErrorListener(this);
+ transportErrorSource = null;
+ }
context.getAxisConfiguration().removeService(service.getName());
context = null;
service = null;
}
+ public void error(TransportError error) {
+ AxisService s = error.getService();
+ if (s == null || s == service) {
+ onTransportError(error.getException());
+ }
+ }
+
protected abstract AxisOperation createOperation();
+
+ protected abstract void onTransportError(Throwable ex);
}
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=703812&r1=703811&r2=703812&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 Oct 12 05:42:18 2008
@@ -85,6 +85,10 @@
return server.getAxisConfiguration();
}
+ public TransportListener getTransportListener() {
+ return listener;
+ }
+
public String getEPR(AxisService service) throws AxisFault {
EndpointReference[] endpointReferences =
listener.getEPRsForService(service.getName(), "localhost");
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpoint.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpoint.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/AsyncEndpoint.java
Sun Oct 12 05:42:18 2008
@@ -20,8 +20,10 @@
package org.apache.axis2.transport.testkit.endpoint;
import org.apache.axis2.transport.testkit.message.IncomingMessage;
+import org.apache.axis2.transport.testkit.name.Key;
-public interface AsyncEndpoint<M> extends TestEndpoint {
[EMAIL PROTECTED]("endpoint")
+public interface AsyncEndpoint<M> {
/**
* Discard any pending messages.
*/
Added:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/EndpointErrorListener.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/EndpointErrorListener.java?rev=703812&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/EndpointErrorListener.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/EndpointErrorListener.java
Sun Oct 12 05:42:18 2008
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.testkit.endpoint;
+
+public interface EndpointErrorListener {
+ void error(Throwable ex);
+}
Added:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpoint.java?rev=703812&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpoint.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpoint.java
Sun Oct 12 05:42:18 2008
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.testkit.endpoint;
+
+import org.apache.axis2.transport.testkit.name.Key;
+
[EMAIL PROTECTED]("endpoint")
+public interface InOutEndpoint {
+ void addEndpointErrorListener(EndpointErrorListener listener);
+ void removeEndpointErrorListener(EndpointErrorListener listener);
+}
Added:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpointSupport.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpointSupport.java?rev=703812&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpointSupport.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/endpoint/InOutEndpointSupport.java
Sun Oct 12 05:42:18 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.testkit.endpoint;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class InOutEndpointSupport {
+ private final List<EndpointErrorListener> listeners = new
LinkedList<EndpointErrorListener>();
+
+ public void fireEndpointError(Throwable ex) {
+ for (EndpointErrorListener listener : listeners) {
+ listener.error(ex);
+ }
+ }
+
+ public void addEndpointErrorListener(EndpointErrorListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeEndpointErrorListener(EndpointErrorListener listener) {
+ listeners.remove(listener);
+ }
+}
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEchoEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEchoEndpoint.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEchoEndpoint.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEchoEndpoint.java
Sun Oct 12 05:42:18 2008
@@ -26,12 +26,14 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.testkit.axis2.MessageContextValidator;
+import org.apache.axis2.transport.testkit.endpoint.EndpointErrorListener;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
import org.apache.commons.io.IOUtils;
import org.mortbay.http.HttpException;
import org.mortbay.http.HttpRequest;
import org.mortbay.http.HttpResponse;
-public class JettyEchoEndpoint extends JettyEndpoint implements
MessageContextValidator {
+public class JettyEchoEndpoint extends JettyEndpoint implements InOutEndpoint,
MessageContextValidator {
@Override
protected void handle(String pathParams, HttpRequest request,
HttpResponse response) throws HttpException, IOException {
@@ -46,4 +48,12 @@
Assert.assertNotNull(trpHeaders);
Assert.assertEquals("test value", trpHeaders.get("X-Test-Header"));
}
+
+ public void addEndpointErrorListener(EndpointErrorListener listener) {
+ // Ignore this as endpoint errors are not detected yet
+ }
+
+ public void removeEndpointErrorListener(EndpointErrorListener listener) {
+ // Ignore this as endpoint errors are not detected yet
+ }
}
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEndpoint.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEndpoint.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyEndpoint.java
Sun Oct 12 05:42:18 2008
@@ -21,14 +21,13 @@
import java.io.IOException;
-import org.apache.axis2.transport.testkit.endpoint.TestEndpoint;
import org.mortbay.http.HttpException;
import org.mortbay.http.HttpHandler;
import org.mortbay.http.HttpRequest;
import org.mortbay.http.HttpResponse;
import org.mortbay.http.handler.AbstractHttpHandler;
-public abstract class JettyEndpoint implements TestEndpoint {
+public abstract class JettyEndpoint {
private JettyServer server;
private HttpHandler handler;
Added:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/InterruptingEndpointErrorListener.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/InterruptingEndpointErrorListener.java?rev=703812&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/InterruptingEndpointErrorListener.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/InterruptingEndpointErrorListener.java
Sun Oct 12 05:42:18 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.testkit.tests.echo;
+
+import org.apache.axis2.transport.testkit.endpoint.EndpointErrorListener;
+
+public class InterruptingEndpointErrorListener implements
EndpointErrorListener {
+ private final Thread thread;
+ private Throwable ex;
+
+ public InterruptingEndpointErrorListener(Thread thread) {
+ this.thread = thread;
+ }
+
+ public void error(Throwable ex) {
+ this.ex = ex;
+ thread.interrupt();
+ }
+
+ public Throwable getException() {
+ return ex;
+ }
+}
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/RequestResponseMessageTestCase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/RequestResponseMessageTestCase.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/RequestResponseMessageTestCase.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/RequestResponseMessageTestCase.java
Sun Oct 12 05:42:18 2008
@@ -23,16 +23,18 @@
import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.endpoint.TestEndpoint;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
import org.apache.axis2.transport.testkit.tests.MessageTestCase;
public abstract class RequestResponseMessageTestCase<M,N> extends
MessageTestCase {
private final RequestResponseTestClient<M,N> client;
+ private final InOutEndpoint endpoint;
// TODO: maybe we don't need an explicit RequestResponseChannel
- public RequestResponseMessageTestCase(RequestResponseChannel channel,
RequestResponseTestClient<M,N> client, TestEndpoint endpoint, ContentType
contentType, String charset, Object... resources) {
+ public RequestResponseMessageTestCase(RequestResponseChannel channel,
RequestResponseTestClient<M,N> client, InOutEndpoint endpoint, ContentType
contentType, String charset, Object... resources) {
super(contentType, charset, resources);
this.client = client;
+ this.endpoint = endpoint;
addResource(channel);
addResource(client);
addResource(endpoint);
@@ -41,7 +43,20 @@
@Override
protected void runTest() throws Throwable {
M request = prepareRequest();
- N response = client.sendMessage(options, options.getBaseContentType(),
request).getData();
+ InterruptingEndpointErrorListener listener = new
InterruptingEndpointErrorListener(Thread.currentThread());
+ N response;
+ endpoint.addEndpointErrorListener(listener);
+ try {
+ response = client.sendMessage(options,
options.getBaseContentType(), request).getData();
+ } catch (Throwable ex) {
+ if (listener.getException() != null) {
+ throw listener.getException();
+ } else {
+ throw ex;
+ }
+ } finally {
+ endpoint.removeEndpointErrorListener(listener);
+ }
checkResponse(request, response);
}
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLRequestResponseMessageTestCase.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLRequestResponseMessageTestCase.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLRequestResponseMessageTestCase.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLRequestResponseMessageTestCase.java
Sun Oct 12 05:42:18 2008
@@ -27,7 +27,7 @@
import org.apache.axis2.transport.testkit.MessageTestData;
import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
-import org.apache.axis2.transport.testkit.endpoint.TestEndpoint;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
import org.apache.axis2.transport.testkit.message.XMLMessage;
import org.apache.axis2.transport.testkit.name.Key;
import org.apache.axis2.transport.testkit.name.Name;
@@ -38,7 +38,7 @@
private final XMLMessage.Type xmlMessageType;
private final MessageTestData data;
- public XMLRequestResponseMessageTestCase(RequestResponseChannel channel,
RequestResponseTestClient<XMLMessage,XMLMessage> client, TestEndpoint endpoint,
XMLMessage.Type xmlMessageType, MessageTestData data, Object... resources) {
+ public XMLRequestResponseMessageTestCase(RequestResponseChannel channel,
RequestResponseTestClient<XMLMessage,XMLMessage> client, InOutEndpoint
endpoint, XMLMessage.Type xmlMessageType, MessageTestData data, Object...
resources) {
super(channel, client, endpoint, xmlMessageType.getContentType(),
data.getCharset(), resources);
this.xmlMessageType = xmlMessageType;
this.data = data;
Modified:
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/misc/MinConcurrencyTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/misc/MinConcurrencyTest.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/misc/MinConcurrencyTest.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/misc/MinConcurrencyTest.java
Sun Oct 12 05:42:18 2008
@@ -110,6 +110,11 @@
operation.setMessageReceiver(messageReceiver);
return operation;
}
+
+ @Override
+ protected void onTransportError(Throwable ex) {
+ // TODO Auto-generated method stub
+ }
});
if (!preloadMessages) {
Modified:
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java?rev=703812&r1=703811&r2=703812&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/MockEchoEndpoint.java
Sun Oct 12 05:42:18 2008
@@ -29,14 +29,15 @@
import javax.jms.Session;
import javax.jms.TextMessage;
-import org.apache.axis2.transport.testkit.endpoint.TestEndpoint;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpointSupport;
import org.apache.axis2.transport.testkit.name.Name;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@Name("mock")
-public class MockEchoEndpoint implements TestEndpoint {
+public class MockEchoEndpoint extends InOutEndpointSupport implements
InOutEndpoint {
static Log log = LogFactory.getLog(MockEchoEndpoint.class);
private Connection connection;
@@ -71,9 +72,8 @@
Thread.sleep(50);
producer.send(reply);
log.info("Message sent: ID = " + reply.getJMSMessageID());
- } catch (Throwable e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (Throwable ex) {
+ fireEndpointError(ex);
}
}
});