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 se...@apache.org on 2009/01/03 07:33:41 UTC
svn commit: r730924 [6/9] - in
/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules:
base/src/main/java/org/apache/axis2/format/
base/src/main/java/org/apache/axis2/transport/base/
base/src/main/java/org/apache/axis2/transport/base/data...
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetRESTClient.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetRESTClient.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetRESTClient.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JavaNetRESTClient.java Fri Jan 2 22:33:39 2009
@@ -1,64 +1,64 @@
-/*
- * 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.http;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.message.RESTMessage;
-import org.apache.axis2.transport.testkit.name.Name;
-import org.apache.axis2.transport.testkit.tests.Setup;
-import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.commons.io.IOUtils;
-
-@Name("java.net")
-public class JavaNetRESTClient implements AsyncTestClient<RESTMessage> {
- private @Transient HttpChannel channel;
-
- @Setup @SuppressWarnings("unused")
- private void setUp(HttpChannel channel) {
- this.channel = channel;
- }
-
- public ContentType getContentType(ClientOptions options, ContentType contentType) {
- return contentType;
- }
-
- public void sendMessage(ClientOptions options, ContentType contentType, RESTMessage message) throws Exception {
- StringBuilder url = new StringBuilder();
- url.append(channel.getEndpointReference().getAddress());
- url.append("/default");
- String queryString = message.getQueryString();
- if (queryString.length() > 0) {
- url.append('?');
- url.append(queryString);
- }
- URLConnection connection = new URL(url.toString()).openConnection();
- connection.setDoInput(true);
- InputStream in = connection.getInputStream();
- IOUtils.copy(in, System.out);
- in.close();
- }
-}
+/*
+ * 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.http;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.mail.internet.ContentType;
+
+import org.apache.axis2.transport.testkit.client.AsyncTestClient;
+import org.apache.axis2.transport.testkit.client.ClientOptions;
+import org.apache.axis2.transport.testkit.message.RESTMessage;
+import org.apache.axis2.transport.testkit.name.Name;
+import org.apache.axis2.transport.testkit.tests.Setup;
+import org.apache.axis2.transport.testkit.tests.Transient;
+import org.apache.commons.io.IOUtils;
+
+@Name("java.net")
+public class JavaNetRESTClient implements AsyncTestClient<RESTMessage> {
+ private @Transient HttpChannel channel;
+
+ @Setup @SuppressWarnings("unused")
+ private void setUp(HttpChannel channel) {
+ this.channel = channel;
+ }
+
+ public ContentType getContentType(ClientOptions options, ContentType contentType) {
+ return contentType;
+ }
+
+ public void sendMessage(ClientOptions options, ContentType contentType, RESTMessage message) throws Exception {
+ StringBuilder url = new StringBuilder();
+ url.append(channel.getEndpointReference().getAddress());
+ url.append("/default");
+ String queryString = message.getQueryString();
+ if (queryString.length() > 0) {
+ url.append('?');
+ url.append(queryString);
+ }
+ URLConnection connection = new URL(url.toString()).openConnection();
+ connection.setDoInput(true);
+ InputStream in = connection.getInputStream();
+ IOUtils.copy(in, System.out);
+ in.close();
+ }
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyAsyncEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyAsyncEndpoint.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyAsyncEndpoint.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyAsyncEndpoint.java Fri Jan 2 22:33:39 2009
@@ -20,11 +20,9 @@
package org.apache.axis2.transport.testkit.http;
import java.io.IOException;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
+import org.apache.axis2.transport.testkit.endpoint.InOnlyEndpointSupport;
import org.apache.axis2.transport.testkit.message.IncomingMessage;
import org.apache.axis2.transport.testkit.name.Name;
import org.apache.axis2.transport.testkit.tests.Setup;
@@ -35,27 +33,27 @@
@Name("jetty")
public abstract class JettyAsyncEndpoint<M> extends JettyEndpoint implements AsyncEndpoint<M> {
- private @Transient BlockingQueue<IncomingMessage<M>> queue;
+ private @Transient InOnlyEndpointSupport<M> support;
@Setup @SuppressWarnings("unused")
private void setUp() throws Exception {
- queue = new LinkedBlockingQueue<IncomingMessage<M>>();
+ support = new InOnlyEndpointSupport<M>();
}
@Override
protected void handle(String pathParams, HttpRequest request, HttpResponse response)
throws HttpException, IOException {
- queue.add(handle(request));
+ support.putMessage(handle(request));
}
protected abstract IncomingMessage<M> handle(HttpRequest request) throws HttpException, IOException;
public void clear() throws Exception {
- queue.clear();
+ support.clear();
}
public IncomingMessage<M> waitForMessage(int timeout) throws Throwable {
- return queue.poll(timeout, TimeUnit.MILLISECONDS);
+ return support.waitForMessage(timeout);
}
}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java Fri Jan 2 22:33:39 2009
@@ -66,24 +66,6 @@
return baos.toByteArray();
}
};
-
- MessageDecoder<AxisMessage,Map> AXIS_TO_MAP =
- new MessageDecoder<AxisMessage,Map>() {
-
- public Map decode(ContentType contentType, AxisMessage message) throws Exception {
- SOAPEnvelope envelope = message.getEnvelope();
- OMElement wrapper = envelope.getBody().getFirstElement();
- Assert.assertEquals(BaseConstants.DEFAULT_MAP_WRAPPER, wrapper.getQName());
- OMNode firstChild = wrapper.getFirstOMChild();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- firstChild.serialize(baos);
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- XMLDecoder decoder = new XMLDecoder(bais);
- Object result = decoder.readObject();
- decoder.close();
- return (Map)result;
- }
- };
MessageDecoder<AxisMessage,String> AXIS_TO_STRING =
new MessageDecoder<AxisMessage,String>() {
@@ -136,6 +118,24 @@
}
};
+ MessageDecoder<AxisMessage,Map> AXIS_TO_MAP =
+ new MessageDecoder<AxisMessage,Map>() {
+
+ public Map decode(ContentType contentType, AxisMessage message) throws Exception {
+ SOAPEnvelope envelope = message.getEnvelope();
+ OMElement wrapper = envelope.getBody().getFirstElement();
+ Assert.assertEquals(BaseConstants.DEFAULT_MAP_WRAPPER, wrapper.getQName());
+ OMNode firstChild = wrapper.getFirstOMChild();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ firstChild.serialize(baos);
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ XMLDecoder decoder = new XMLDecoder(bais);
+ Object result = decoder.readObject();
+ decoder.close();
+ return (Map)result;
+ }
+ };
+
MessageDecoder<byte[],XMLMessage> BYTE_TO_XML =
new MessageDecoder<byte[],XMLMessage>() {
@@ -162,19 +162,6 @@
}
}
};
-
- MessageDecoder<Map,XMLMessage> MAP_TO_XML =
- new MessageDecoder<Map,XMLMessage>() {
-
- public XMLMessage decode(ContentType contentType, Map message) throws Exception {
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- QName wrapperQName = BaseConstants.DEFAULT_MAP_WRAPPER;
- OMElement wrapper = factory.createOMElement(new MapDataSource(message, wrapperQName.getLocalPart(),
- factory.createOMNamespace(wrapperQName.getNamespaceURI(), wrapperQName.getPrefix())), wrapperQName.getLocalPart(),
- factory.createOMNamespace(wrapperQName.getNamespaceURI(), wrapperQName.getPrefix()));
- return new XMLMessage(wrapper, XMLMessage.Type.SOAP11);
- }
- };
MessageDecoder<String,XMLMessage> STRING_TO_XML =
new MessageDecoder<String,XMLMessage>() {
@@ -195,6 +182,19 @@
}
};
+ MessageDecoder<Map,XMLMessage> MAP_TO_XML =
+ new MessageDecoder<Map,XMLMessage>() {
+
+ public XMLMessage decode(ContentType contentType, Map message) throws Exception {
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ QName wrapperQName = BaseConstants.DEFAULT_MAP_WRAPPER;
+ OMElement wrapper = factory.createOMElement(new MapDataSource(message, wrapperQName.getLocalPart(),
+ factory.createOMNamespace(wrapperQName.getNamespaceURI(), wrapperQName.getPrefix())), wrapperQName.getLocalPart(),
+ factory.createOMNamespace(wrapperQName.getNamespaceURI(), wrapperQName.getPrefix()));
+ return new XMLMessage(wrapper, XMLMessage.Type.SOAP11);
+ }
+ };
+
MessageDecoder<byte[],String> BYTE_TO_STRING =
new MessageDecoder<byte[],String>() {
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java Fri Jan 2 22:33:39 2009
@@ -163,48 +163,48 @@
return result;
}
};
-
- MessageEncoder<Map,AxisMessage> MAP_WRAPPER =
- new MessageEncoder<Map,AxisMessage>() {
+
+ MessageEncoder<String,AxisMessage> TEXT_WRAPPER =
+ new MessageEncoder<String,AxisMessage>() {
public ContentType getContentType(ClientOptions options, ContentType contentType) {
return contentType;
}
- public AxisMessage encode(ClientOptions options, Map message) throws Exception {
+ public AxisMessage encode(ClientOptions options, String message) throws Exception {
AxisMessage result = new AxisMessage();
- result.setMessageType(null);
+ result.setMessageType("text/plain");
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
- QName wrapperQName = BaseConstants.DEFAULT_MAP_WRAPPER;
- OMElement wrapper = factory.createOMElement(new MapDataSource(message), wrapperQName.getLocalPart(),
- factory.createOMNamespace(wrapperQName.getNamespaceURI(), wrapperQName.getPrefix()));
+ OMElement wrapper = factory.createOMElement(BaseConstants.DEFAULT_TEXT_WRAPPER);
+ wrapper.addChild(factory.createOMText(message));
envelope.getBody().addChild(wrapper);
result.setEnvelope(envelope);
return result;
}
};
-
- MessageEncoder<String,AxisMessage> TEXT_WRAPPER =
- new MessageEncoder<String,AxisMessage>() {
+
+ MessageEncoder<Map,AxisMessage> MAP_WRAPPER =
+ new MessageEncoder<Map,AxisMessage>() {
public ContentType getContentType(ClientOptions options, ContentType contentType) {
return contentType;
}
- public AxisMessage encode(ClientOptions options, String message) throws Exception {
+ public AxisMessage encode(ClientOptions options, Map message) throws Exception {
AxisMessage result = new AxisMessage();
- result.setMessageType("text/plain");
+ result.setMessageType(null);
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
- OMElement wrapper = factory.createOMElement(BaseConstants.DEFAULT_TEXT_WRAPPER);
- wrapper.addChild(factory.createOMText(message));
+ QName wrapperQName = BaseConstants.DEFAULT_MAP_WRAPPER;
+ OMElement wrapper = factory.createOMElement(new MapDataSource(message), wrapperQName.getLocalPart(),
+ factory.createOMNamespace(wrapperQName.getNamespaceURI(), wrapperQName.getPrefix()));
envelope.getBody().addChild(wrapper);
result.setEnvelope(envelope);
return result;
}
- };
-
+ };
+
MessageEncoder<String,byte[]> STRING_TO_BYTE =
new MessageEncoder<String,byte[]>() {
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/RESTMessage.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/RESTMessage.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/RESTMessage.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/RESTMessage.java Fri Jan 2 22:33:39 2009
@@ -1,93 +1,93 @@
-/*
- * 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.message;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-
-public class RESTMessage {
- public static class Parameter {
- private final String key;
- private final String value;
-
- public Parameter(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getValue() {
- return value;
- }
-
- @Override
- public boolean equals(Object _obj) {
- if (_obj instanceof Parameter) {
- Parameter obj = (Parameter)_obj;
- return ObjectUtils.equals(key, obj.key) && ObjectUtils.equals(value, obj.value);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(key).append(value).toHashCode();
- }
-
- @Override
- public String toString() {
- return key + "=" + value;
- }
- }
-
- private final Parameter[] parameters;
-
- public RESTMessage(Parameter[] parameters) {
- this.parameters = parameters;
- }
-
- public Parameter[] getParameters() {
- return parameters;
- }
-
- public String getQueryString() {
- StringBuilder buffer = new StringBuilder();
- for (Parameter parameter : parameters) {
- if (buffer.length() > 0) {
- buffer.append('&');
- }
- buffer.append(parameter.getKey());
- buffer.append('=');
- try {
- buffer.append(URLEncoder.encode(parameter.getValue(), "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new Error("JRE doesn't know UTF-8!", e);
- }
- }
- return buffer.toString();
- }
-}
+/*
+ * 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.message;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+public class RESTMessage {
+ public static class Parameter {
+ private final String key;
+ private final String value;
+
+ public Parameter(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object _obj) {
+ if (_obj instanceof Parameter) {
+ Parameter obj = (Parameter)_obj;
+ return ObjectUtils.equals(key, obj.key) && ObjectUtils.equals(value, obj.value);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(key).append(value).toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return key + "=" + value;
+ }
+ }
+
+ private final Parameter[] parameters;
+
+ public RESTMessage(Parameter[] parameters) {
+ this.parameters = parameters;
+ }
+
+ public Parameter[] getParameters() {
+ return parameters;
+ }
+
+ public String getQueryString() {
+ StringBuilder buffer = new StringBuilder();
+ for (Parameter parameter : parameters) {
+ if (buffer.length() > 0) {
+ buffer.append('&');
+ }
+ buffer.append(parameter.getKey());
+ buffer.append('=');
+ try {
+ buffer.append(URLEncoder.encode(parameter.getValue(), "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new Error("JRE doesn't know UTF-8!", e);
+ }
+ }
+ return buffer.toString();
+ }
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/XMLMessage.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/XMLMessage.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/XMLMessage.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/XMLMessage.java Fri Jan 2 22:33:39 2009
@@ -1,109 +1,109 @@
-/*
- * 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.message;
-
-import javax.mail.internet.ContentType;
-import javax.mail.internet.ParseException;
-
-import org.apache.axiom.attachments.Attachments;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAP11Constants;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axis2.transport.http.HTTPConstants;
-
-public class XMLMessage {
- public enum Type {
- SOAP11(SOAP11Constants.SOAP_11_CONTENT_TYPE),
- SOAP12(SOAP12Constants.SOAP_12_CONTENT_TYPE),
- POX("application/xml"),
- SWA(HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED);
-
- private final String contentType;
-
- private Type(String contentType) {
- this.contentType = contentType;
- }
-
- public ContentType getContentType() {
- try {
- return new ContentType(contentType);
- } catch (ParseException ex) {
- throw new Error(ex);
- }
- }
- }
-
- private final Type type;
- private final OMElement payload;
- private final Attachments attachments;
-
- public XMLMessage(OMElement payload, Type type, Attachments attachments) {
- this.payload = payload;
- this.type = type;
- this.attachments = attachments;
- }
-
- public XMLMessage(OMElement payload, Type type) {
- this(payload, type, null);
- }
-
- public Type getType() {
- return type;
- }
-
- public OMElement getPayload() {
- return payload;
- }
-
- public OMElement getMessageElement() {
- if (type == Type.POX) {
- return payload;
- } else {
- SOAPFactory factory;
- if (type == Type.SOAP11) {
- factory = OMAbstractFactory.getSOAP11Factory();
- } else {
- factory = OMAbstractFactory.getSOAP12Factory();
- }
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- envelope.getBody().addChild(payload);
- return envelope;
- }
- }
-
- public Attachments getAttachments() {
- return attachments;
- }
-
- public static Type getTypeFromContentType(ContentType contentType) {
- String baseType = contentType.getBaseType();
- Type type = null;
- for (Type candidate : Type.values()) {
- if (candidate.getContentType().getBaseType().equalsIgnoreCase(baseType)) {
- type = candidate;
- break;
- }
- }
- return type;
- }
-}
+/*
+ * 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.message;
+
+import javax.mail.internet.ContentType;
+import javax.mail.internet.ParseException;
+
+import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.transport.http.HTTPConstants;
+
+public class XMLMessage {
+ public enum Type {
+ SOAP11(SOAP11Constants.SOAP_11_CONTENT_TYPE),
+ SOAP12(SOAP12Constants.SOAP_12_CONTENT_TYPE),
+ POX("application/xml"),
+ SWA(HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED);
+
+ private final String contentType;
+
+ private Type(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public ContentType getContentType() {
+ try {
+ return new ContentType(contentType);
+ } catch (ParseException ex) {
+ throw new Error(ex);
+ }
+ }
+ }
+
+ private final Type type;
+ private final OMElement payload;
+ private final Attachments attachments;
+
+ public XMLMessage(OMElement payload, Type type, Attachments attachments) {
+ this.payload = payload;
+ this.type = type;
+ this.attachments = attachments;
+ }
+
+ public XMLMessage(OMElement payload, Type type) {
+ this(payload, type, null);
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public OMElement getPayload() {
+ return payload;
+ }
+
+ public OMElement getMessageElement() {
+ if (type == Type.POX) {
+ return payload;
+ } else {
+ SOAPFactory factory;
+ if (type == Type.SOAP11) {
+ factory = OMAbstractFactory.getSOAP11Factory();
+ } else {
+ factory = OMAbstractFactory.getSOAP12Factory();
+ }
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ envelope.getBody().addChild(payload);
+ return envelope;
+ }
+ }
+
+ public Attachments getAttachments() {
+ return attachments;
+ }
+
+ public static Type getTypeFromContentType(ContentType contentType) {
+ String baseType = contentType.getBaseType();
+ Type type = null;
+ for (Type candidate : Type.values()) {
+ if (candidate.getContentType().getBaseType().equalsIgnoreCase(baseType)) {
+ type = candidate;
+ break;
+ }
+ }
+ return type;
+ }
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java Fri Jan 2 22:33:39 2009
@@ -1,128 +1,128 @@
-/*
- * 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;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.axis2.transport.testkit.name.Key;
-import org.apache.axis2.transport.testkit.name.NameUtils;
-import org.apache.axis2.transport.testkit.util.LogManager;
-
-@Key("test")
-public abstract class ManagedTestCase extends TestCase {
- private final TestResourceSet resourceSet = new TestResourceSet();
-
- private Map<String,String> nameComponents;
-
- private String id;
- private boolean managed;
- private Class<?> testClass;
-
- public ManagedTestCase(Object... resources) {
- resourceSet.addResources(resources);
- addResource(LogManager.INSTANCE);
- }
-
- protected void addResource(Object resource) {
- resourceSet.addResource(resource);
- }
-
- public Map<String,String> getNameComponents() {
- if (nameComponents == null) {
- nameComponents = new LinkedHashMap<String,String>();
- NameUtils.getNameComponents(nameComponents, this);
- resourceSet.resolve();
- for (Object resource : resourceSet.getResources()) {
- NameUtils.getNameComponents(nameComponents, resource);
- }
- }
- return nameComponents;
- }
-
- // TODO: TransportTestCase should be in the same package as TransportTestSuite and this
- // method should have package access
- public void init(String id, boolean managed, Class<?> testClass) {
- this.id = id;
- this.managed = managed;
- this.testClass = testClass;
- }
-
- public String getId() {
- return id != null ? id : getName();
- }
-
- public Class<?> getTestClass() {
- return testClass != null ? testClass : getClass();
- }
-
- @Override
- public String getName() {
- String testName = super.getName();
- if (testName == null) {
- StringBuilder buffer = new StringBuilder();
- if (id != null) {
- buffer.append(id);
- buffer.append(':');
- }
- boolean first = true;
- for (Map.Entry<String,String> entry : getNameComponents().entrySet()) {
- if (first) {
- first = false;
- } else {
- buffer.append(',');
- }
- buffer.append(entry.getKey());
- buffer.append('=');
- buffer.append(entry.getValue());
- }
- testName = buffer.toString();
- setName(testName);
- }
- return testName;
- }
-
- public TestResourceSet getResourceSet() {
- return resourceSet;
- }
-
- @Override
- protected void setUp() throws Exception {
- if (!managed) {
- LogManager.INSTANCE.setTestCase(this);
- resourceSet.setUp();
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (!managed) {
- resourceSet.tearDown();
- LogManager.INSTANCE.setTestCase(null);
- }
- }
-
- @Override
- public String toString() {
- return getName() + "(" + testClass.getName() + ")";
- }
+/*
+ * 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;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.transport.testkit.name.Key;
+import org.apache.axis2.transport.testkit.name.NameUtils;
+import org.apache.axis2.transport.testkit.util.LogManager;
+
+@Key("test")
+public abstract class ManagedTestCase extends TestCase {
+ private final TestResourceSet resourceSet = new TestResourceSet();
+
+ private Map<String,String> nameComponents;
+
+ private String id;
+ private boolean managed;
+ private Class<?> testClass;
+
+ public ManagedTestCase(Object... resources) {
+ resourceSet.addResources(resources);
+ addResource(LogManager.INSTANCE);
+ }
+
+ protected void addResource(Object resource) {
+ resourceSet.addResource(resource);
+ }
+
+ public Map<String,String> getNameComponents() {
+ if (nameComponents == null) {
+ nameComponents = new LinkedHashMap<String,String>();
+ NameUtils.getNameComponents(nameComponents, this);
+ resourceSet.resolve();
+ for (Object resource : resourceSet.getResources()) {
+ NameUtils.getNameComponents(nameComponents, resource);
+ }
+ }
+ return nameComponents;
+ }
+
+ // TODO: TransportTestCase should be in the same package as TransportTestSuite and this
+ // method should have package access
+ public void init(String id, boolean managed, Class<?> testClass) {
+ this.id = id;
+ this.managed = managed;
+ this.testClass = testClass;
+ }
+
+ public String getId() {
+ return id != null ? id : getName();
+ }
+
+ public Class<?> getTestClass() {
+ return testClass != null ? testClass : getClass();
+ }
+
+ @Override
+ public String getName() {
+ String testName = super.getName();
+ if (testName == null) {
+ StringBuilder buffer = new StringBuilder();
+ if (id != null) {
+ buffer.append(id);
+ buffer.append(':');
+ }
+ boolean first = true;
+ for (Map.Entry<String,String> entry : getNameComponents().entrySet()) {
+ if (first) {
+ first = false;
+ } else {
+ buffer.append(',');
+ }
+ buffer.append(entry.getKey());
+ buffer.append('=');
+ buffer.append(entry.getValue());
+ }
+ testName = buffer.toString();
+ setName(testName);
+ }
+ return testName;
+ }
+
+ public TestResourceSet getResourceSet() {
+ return resourceSet;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ if (!managed) {
+ LogManager.INSTANCE.setTestCase(this);
+ resourceSet.setUp();
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (!managed) {
+ resourceSet.tearDown();
+ LogManager.INSTANCE.setTestCase(null);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getName() + "(" + testClass.getName() + ")";
+ }
}
\ No newline at end of file
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/MessageTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/MessageTestCase.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/MessageTestCase.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/MessageTestCase.java Fri Jan 2 22:33:39 2009
@@ -1,69 +1,69 @@
-/*
- * 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;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.Adapter;
-import org.apache.axis2.transport.testkit.MessageExchangeValidator;
-import org.apache.axis2.transport.testkit.client.ClientOptions;
-import org.apache.axis2.transport.testkit.client.TestClient;
-
-public abstract class MessageTestCase extends ManagedTestCase {
- protected final ContentType contentType;
- protected final ClientOptions options;
- private @Transient MessageExchangeValidator[] validators;
-
- public MessageTestCase(TestClient client, ContentType contentType, String charset, Object... resources) {
- super(resources);
- if (client instanceof Adapter) {
- addResource(((Adapter)client).getTarget());
- } else {
- addResource(client);
- }
- this.contentType = contentType;
- try {
- options = new ClientOptions(client, contentType, charset);
- } catch (Exception ex) {
- // TODO: handle this in a better way
- throw new Error(ex);
- }
- addResource(options);
- addResource(this);
- }
-
- @Setup @SuppressWarnings("unused")
- private void setUp(MessageExchangeValidator[] validators) {
- this.validators = validators;
- }
-
- @Override
- protected void runTest() throws Throwable {
- for (MessageExchangeValidator validator : validators) {
- validator.beforeSend();
- }
- doRunTest();
- for (MessageExchangeValidator validator : validators) {
- validator.afterReceive();
- }
- }
-
- protected abstract void doRunTest() throws Throwable;
-}
+/*
+ * 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;
+
+import javax.mail.internet.ContentType;
+
+import org.apache.axis2.transport.testkit.Adapter;
+import org.apache.axis2.transport.testkit.MessageExchangeValidator;
+import org.apache.axis2.transport.testkit.client.ClientOptions;
+import org.apache.axis2.transport.testkit.client.TestClient;
+
+public abstract class MessageTestCase extends ManagedTestCase {
+ protected final ContentType contentType;
+ protected final ClientOptions options;
+ private @Transient MessageExchangeValidator[] validators;
+
+ public MessageTestCase(TestClient client, ContentType contentType, String charset, Object... resources) {
+ super(resources);
+ if (client instanceof Adapter) {
+ addResource(((Adapter)client).getTarget());
+ } else {
+ addResource(client);
+ }
+ this.contentType = contentType;
+ try {
+ options = new ClientOptions(client, contentType, charset);
+ } catch (Exception ex) {
+ // TODO: handle this in a better way
+ throw new Error(ex);
+ }
+ addResource(options);
+ addResource(this);
+ }
+
+ @Setup @SuppressWarnings("unused")
+ private void setUp(MessageExchangeValidator[] validators) {
+ this.validators = validators;
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ for (MessageExchangeValidator validator : validators) {
+ validator.beforeSend();
+ }
+ doRunTest();
+ for (MessageExchangeValidator validator : validators) {
+ validator.afterReceive();
+ }
+ }
+
+ protected abstract void doRunTest() throws Throwable;
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Setup.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Setup.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Setup.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Setup.java Fri Jan 2 22:33:39 2009
@@ -1,33 +1,33 @@
-/*
- * 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;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation identifying methods to be called when a resource is set up.
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Setup {
-}
+/*
+ * 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;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation identifying methods to be called when a resource is set up.
+ */
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Setup {
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TearDown.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TearDown.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TearDown.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TearDown.java Fri Jan 2 22:33:39 2009
@@ -1,33 +1,33 @@
-/*
- * 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;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation identifying methods to be called when a resource is torn down.
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface TearDown {
-}
+/*
+ * 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;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation identifying methods to be called when a resource is torn down.
+ */
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TearDown {
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResource.java Fri Jan 2 22:33:39 2009
@@ -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;
+ }
+ }
}
}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSet.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSet.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSet.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSet.java Fri Jan 2 22:33:39 2009
@@ -1,177 +1,177 @@
-/*
- * 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;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class TestResourceSet {
- enum Status { UNRESOLVED, RESOLVED, SETUP, RECYCLED };
-
- private static Log log = LogFactory.getLog(TestResourceSet.class);
-
- private final TestResourceSet parent;
- private final List<TestResource> unresolvedResources = new LinkedList<TestResource>();
- final List<TestResource> resolvedResources = new LinkedList<TestResource>();
- Status status = Status.UNRESOLVED;
-
- public TestResourceSet(TestResourceSet parent) {
- this.parent = parent;
- }
-
- public TestResourceSet() {
- this(null);
- }
-
- public void addResource(Object resource) {
- if (status != Status.UNRESOLVED) {
- throw new IllegalStateException();
- }
- unresolvedResources.add(new TestResource(resource));
- }
-
- public void addResources(Object... resources) {
- for (Object resource : resources) {
- addResource(resource);
- }
- }
-
- public Object[] getResources() {
- if (status == Status.UNRESOLVED) {
- throw new IllegalStateException();
- }
- Object[] result = new Object[resolvedResources.size()];
- int i = 0;
- for (TestResource resource : resolvedResources) {
- result[i++] = resource.getInstance();
- }
- return result;
- }
-
- public void resolve() {
- if (status == Status.UNRESOLVED) {
- while (!unresolvedResources.isEmpty()) {
- resolveResource(unresolvedResources.get(0));
- }
- status = Status.RESOLVED;
- }
- }
-
- private void resolveResource(TestResource resource) {
- unresolvedResources.remove(resource);
- resource.resolve(this);
- resolvedResources.add(resource);
- }
-
- TestResource[] findResources(Class<?> clazz, boolean allowAutoCreate) {
- List<TestResource> result = new LinkedList<TestResource>();
- if (parent != null) {
- result.addAll(Arrays.asList(parent.findResources(clazz, false)));
- }
- for (TestResource resource : resolvedResources) {
- if (clazz.isInstance(resource.getInstance())) {
- result.add(resource);
- }
- }
- List<TestResource> unresolvedMatchingResources = new LinkedList<TestResource>();
- for (TestResource resource : unresolvedResources) {
- if (clazz.isInstance(resource.getInstance())) {
- unresolvedMatchingResources.add(resource);
- }
- }
- for (TestResource resource : unresolvedMatchingResources) {
- resolveResource(resource);
- result.add(resource);
- }
- if (allowAutoCreate && result.isEmpty()) {
- TestResource resource;
- try {
- Field field = clazz.getField("INSTANCE");
- resource = new TestResource(field.get(null));
- } catch (Throwable ex) {
- resource = null;
- }
- if (resource != null) {
- unresolvedResources.add(resource);
- resolveResource(resource);
- result.add(resource);
- }
- }
- return result.toArray(new TestResource[result.size()]);
- }
-
- public void setUp() throws Exception {
- resolve();
- if (status != Status.RESOLVED) {
- throw new IllegalStateException();
- }
- setUp(resolvedResources);
- status = Status.SETUP;
- }
-
- static List<TestResource> filterOnHasLifecycle(List<TestResource> resources) {
- List<TestResource> result = new ArrayList<TestResource>(resources.size());
- for (TestResource resource : resources) {
- if (resource.hasLifecycle()) {
- result.add(resource);
- }
- }
- return result;
- }
-
- static void setUp(List<TestResource> resources) throws Exception {
- resources = filterOnHasLifecycle(resources);
- if (!resources.isEmpty()) {
- log.info("Setting up: " + resources);
- for (TestResource resource : resources) {
- resource.setUp();
- }
- }
- }
-
- public void tearDown() throws Exception {
- if (status != Status.SETUP) {
- throw new IllegalStateException();
- }
- tearDown(resolvedResources);
- }
-
- static void tearDown(List<TestResource> resources) throws Exception {
- resources = filterOnHasLifecycle(resources);
- if (!resources.isEmpty()) {
- log.info("Tearing down: " + resources);
- for (ListIterator<TestResource> it = resources.listIterator(resources.size()); it.hasPrevious(); ) {
- it.previous().tearDown();
- }
- }
- }
-
- @Override
- public String toString() {
- return resolvedResources.toString();
- }
-}
+/*
+ * 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;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TestResourceSet {
+ enum Status { UNRESOLVED, RESOLVED, SETUP, RECYCLED };
+
+ private static Log log = LogFactory.getLog(TestResourceSet.class);
+
+ private final TestResourceSet parent;
+ private final List<TestResource> unresolvedResources = new LinkedList<TestResource>();
+ final List<TestResource> resolvedResources = new LinkedList<TestResource>();
+ Status status = Status.UNRESOLVED;
+
+ public TestResourceSet(TestResourceSet parent) {
+ this.parent = parent;
+ }
+
+ public TestResourceSet() {
+ this(null);
+ }
+
+ public void addResource(Object resource) {
+ if (status != Status.UNRESOLVED) {
+ throw new IllegalStateException();
+ }
+ unresolvedResources.add(new TestResource(resource));
+ }
+
+ public void addResources(Object... resources) {
+ for (Object resource : resources) {
+ addResource(resource);
+ }
+ }
+
+ public Object[] getResources() {
+ if (status == Status.UNRESOLVED) {
+ throw new IllegalStateException();
+ }
+ Object[] result = new Object[resolvedResources.size()];
+ int i = 0;
+ for (TestResource resource : resolvedResources) {
+ result[i++] = resource.getInstance();
+ }
+ return result;
+ }
+
+ public void resolve() {
+ if (status == Status.UNRESOLVED) {
+ while (!unresolvedResources.isEmpty()) {
+ resolveResource(unresolvedResources.get(0));
+ }
+ status = Status.RESOLVED;
+ }
+ }
+
+ private void resolveResource(TestResource resource) {
+ unresolvedResources.remove(resource);
+ resource.resolve(this);
+ resolvedResources.add(resource);
+ }
+
+ TestResource[] findResources(Class<?> clazz, boolean allowAutoCreate) {
+ List<TestResource> result = new LinkedList<TestResource>();
+ if (parent != null) {
+ result.addAll(Arrays.asList(parent.findResources(clazz, false)));
+ }
+ for (TestResource resource : resolvedResources) {
+ if (clazz.isInstance(resource.getInstance())) {
+ result.add(resource);
+ }
+ }
+ List<TestResource> unresolvedMatchingResources = new LinkedList<TestResource>();
+ for (TestResource resource : unresolvedResources) {
+ if (clazz.isInstance(resource.getInstance())) {
+ unresolvedMatchingResources.add(resource);
+ }
+ }
+ for (TestResource resource : unresolvedMatchingResources) {
+ resolveResource(resource);
+ result.add(resource);
+ }
+ if (allowAutoCreate && result.isEmpty()) {
+ TestResource resource;
+ try {
+ Field field = clazz.getField("INSTANCE");
+ resource = new TestResource(field.get(null));
+ } catch (Throwable ex) {
+ resource = null;
+ }
+ if (resource != null) {
+ unresolvedResources.add(resource);
+ resolveResource(resource);
+ result.add(resource);
+ }
+ }
+ return result.toArray(new TestResource[result.size()]);
+ }
+
+ public void setUp() throws Exception {
+ resolve();
+ if (status != Status.RESOLVED) {
+ throw new IllegalStateException();
+ }
+ setUp(resolvedResources);
+ status = Status.SETUP;
+ }
+
+ static List<TestResource> filterOnHasLifecycle(List<TestResource> resources) {
+ List<TestResource> result = new ArrayList<TestResource>(resources.size());
+ for (TestResource resource : resources) {
+ if (resource.hasLifecycle()) {
+ result.add(resource);
+ }
+ }
+ return result;
+ }
+
+ static void setUp(List<TestResource> resources) throws Exception {
+ resources = filterOnHasLifecycle(resources);
+ if (!resources.isEmpty()) {
+ log.info("Setting up: " + resources);
+ for (TestResource resource : resources) {
+ resource.setUp();
+ }
+ }
+ }
+
+ public void tearDown() throws Exception {
+ if (status != Status.SETUP) {
+ throw new IllegalStateException();
+ }
+ tearDown(resolvedResources);
+ }
+
+ static void tearDown(List<TestResource> resources) throws Exception {
+ resources = filterOnHasLifecycle(resources);
+ if (!resources.isEmpty()) {
+ log.info("Tearing down: " + resources);
+ for (ListIterator<TestResource> it = resources.listIterator(resources.size()); it.hasPrevious(); ) {
+ it.previous().tearDown();
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return resolvedResources.toString();
+ }
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSetTransition.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSetTransition.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSetTransition.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/TestResourceSetTransition.java Fri Jan 2 22:33:39 2009
@@ -1,82 +1,82 @@
-/*
- * 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;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.axis2.transport.testkit.tests.TestResourceSet.Status;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class TestResourceSetTransition {
- private static final Log log = LogFactory.getLog(TestResourceSetTransition.class);
-
- private final TestResourceSet old;
- private final TestResourceSet target;
- private final List<TestResource> oldResourcesToTearDown;
- private final List<TestResource> resourcesToSetUp;
- private final List<TestResource> resourcesToKeep;
-
- public TestResourceSetTransition(TestResourceSet old, TestResourceSet target) {
- this.old = old;
- this.target = target;
- target.resolve();
- if (target.status != TestResourceSet.Status.RESOLVED) {
- throw new IllegalStateException();
- }
- if (old.status != Status.SETUP) {
- throw new IllegalStateException();
- }
- oldResourcesToTearDown = new LinkedList<TestResource>();
- resourcesToSetUp = new LinkedList<TestResource>(target.resolvedResources);
- resourcesToKeep = new LinkedList<TestResource>();
- outer: for (TestResource oldResource : TestResourceSet.filterOnHasLifecycle(old.resolvedResources)) {
- for (Iterator<TestResource> it = resourcesToSetUp.iterator(); it.hasNext(); ) {
- TestResource resource = it.next();
- if (resource.equals(oldResource)) {
- it.remove();
- resource.recycle(oldResource);
- resourcesToKeep.add(oldResource);
- continue outer;
- }
- }
- oldResourcesToTearDown.add(oldResource);
- }
- }
-
- public void tearDown() throws Exception {
- if (old.status != Status.SETUP) {
- throw new IllegalStateException();
- }
- TestResourceSet.tearDown(oldResourcesToTearDown);
- old.status = Status.RECYCLED;
- }
-
- public void setUp() throws Exception {
- if (target.status != TestResourceSet.Status.RESOLVED) {
- throw new IllegalStateException();
- }
- log.debug("Keeping: " + resourcesToKeep);
- TestResourceSet.setUp(resourcesToSetUp);
- target.status = Status.SETUP;
- }
-}
+/*
+ * 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;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.axis2.transport.testkit.tests.TestResourceSet.Status;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TestResourceSetTransition {
+ private static final Log log = LogFactory.getLog(TestResourceSetTransition.class);
+
+ private final TestResourceSet old;
+ private final TestResourceSet target;
+ private final List<TestResource> oldResourcesToTearDown;
+ private final List<TestResource> resourcesToSetUp;
+ private final List<TestResource> resourcesToKeep;
+
+ public TestResourceSetTransition(TestResourceSet old, TestResourceSet target) {
+ this.old = old;
+ this.target = target;
+ target.resolve();
+ if (target.status != TestResourceSet.Status.RESOLVED) {
+ throw new IllegalStateException();
+ }
+ if (old.status != Status.SETUP) {
+ throw new IllegalStateException();
+ }
+ oldResourcesToTearDown = new LinkedList<TestResource>();
+ resourcesToSetUp = new LinkedList<TestResource>(target.resolvedResources);
+ resourcesToKeep = new LinkedList<TestResource>();
+ outer: for (TestResource oldResource : TestResourceSet.filterOnHasLifecycle(old.resolvedResources)) {
+ for (Iterator<TestResource> it = resourcesToSetUp.iterator(); it.hasNext(); ) {
+ TestResource resource = it.next();
+ if (resource.equals(oldResource)) {
+ it.remove();
+ resource.recycle(oldResource);
+ resourcesToKeep.add(oldResource);
+ continue outer;
+ }
+ }
+ oldResourcesToTearDown.add(oldResource);
+ }
+ }
+
+ public void tearDown() throws Exception {
+ if (old.status != Status.SETUP) {
+ throw new IllegalStateException();
+ }
+ TestResourceSet.tearDown(oldResourcesToTearDown);
+ old.status = Status.RECYCLED;
+ }
+
+ public void setUp() throws Exception {
+ if (target.status != TestResourceSet.Status.RESOLVED) {
+ throw new IllegalStateException();
+ }
+ log.debug("Keeping: " + resourcesToKeep);
+ TestResourceSet.setUp(resourcesToSetUp);
+ target.status = Status.SETUP;
+ }
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Transient.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Transient.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Transient.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/Transient.java Fri Jan 2 22:33:39 2009
@@ -1,33 +1,33 @@
-/*
- * 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;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation identifying fields to be reset when a resource is torn down.
- */
-@Target({ElementType.TYPE, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Transient {
-}
+/*
+ * 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;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation identifying fields to be reset when a resource is torn down.
+ */
+@Target({ElementType.TYPE, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Transient {
+}
Modified: webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/AsyncMessageTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/AsyncMessageTestCase.java?rev=730924&r1=730923&r2=730924&view=diff
==============================================================================
--- webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/AsyncMessageTestCase.java (original)
+++ webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/AsyncMessageTestCase.java Fri Jan 2 22:33:39 2009
@@ -1,61 +1,61 @@
-/*
- * 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.async;
-
-import javax.mail.internet.ContentType;
-
-import org.apache.axis2.transport.testkit.channel.AsyncChannel;
-import org.apache.axis2.transport.testkit.client.AsyncTestClient;
-import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
-import org.apache.axis2.transport.testkit.message.IncomingMessage;
-import org.apache.axis2.transport.testkit.tests.MessageTestCase;
-
-public abstract class AsyncMessageTestCase<M> extends MessageTestCase {
- private final AsyncTestClient<M> client;
- private final AsyncEndpoint<M> endpoint;
-
- // TODO: maybe we don't need an explicit AsyncChannel
- public AsyncMessageTestCase(AsyncChannel channel, AsyncTestClient<M> client, AsyncEndpoint<M> endpoint, ContentType contentType, String charset, Object... resources) {
- super(client, contentType, charset, resources);
- this.client = client;
- this.endpoint = endpoint;
- addResource(channel);
- addResource(endpoint);
- }
-
- @Override
- protected void doRunTest() throws Throwable {
- endpoint.clear();
- M expected = prepareMessage();
-
- // Run the test.
-// contentTypeMode == ContentTypeMode.TRANSPORT ? contentType : null);
- client.sendMessage(options, contentType, expected);
- IncomingMessage<M> actual = endpoint.waitForMessage(8000);
- if (actual == null) {
- fail("Failed to get message");
- }
-
- checkMessageData(expected, actual.getData());
- }
-
- protected abstract M prepareMessage() throws Exception;
- protected abstract void checkMessageData(M expected, M actual) throws Exception;
+/*
+ * 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.async;
+
+import javax.mail.internet.ContentType;
+
+import org.apache.axis2.transport.testkit.channel.AsyncChannel;
+import org.apache.axis2.transport.testkit.client.AsyncTestClient;
+import org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint;
+import org.apache.axis2.transport.testkit.message.IncomingMessage;
+import org.apache.axis2.transport.testkit.tests.MessageTestCase;
+
+public abstract class AsyncMessageTestCase<M> extends MessageTestCase {
+ private final AsyncTestClient<M> client;
+ private final AsyncEndpoint<M> endpoint;
+
+ // TODO: maybe we don't need an explicit AsyncChannel
+ public AsyncMessageTestCase(AsyncChannel channel, AsyncTestClient<M> client, AsyncEndpoint<M> endpoint, ContentType contentType, String charset, Object... resources) {
+ super(client, contentType, charset, resources);
+ this.client = client;
+ this.endpoint = endpoint;
+ addResource(channel);
+ addResource(endpoint);
+ }
+
+ @Override
+ protected void doRunTest() throws Throwable {
+ endpoint.clear();
+ M expected = prepareMessage();
+
+ // Run the test.
+// contentTypeMode == ContentTypeMode.TRANSPORT ? contentType : null);
+ client.sendMessage(options, contentType, expected);
+ IncomingMessage<M> actual = endpoint.waitForMessage(8000);
+ if (actual == null) {
+ fail("Failed to get message");
+ }
+
+ checkMessageData(expected, actual.getData());
+ }
+
+ protected abstract M prepareMessage() throws Exception;
+ protected abstract void checkMessageData(M expected, M actual) throws Exception;
}
\ No newline at end of file