This is an automated email from the ASF dual-hosted git repository.

billblough pushed a commit to branch AXIS2-4318
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git

commit 57f7acc6e7b8237fc71887620112939569f51dff
Author: Sagara Gunathunga <sag...@apache.org>
AuthorDate: Thu Mar 1 12:52:26 2012 +0000

    AXIS2-4318 - Refactored  test cases.
---
 .../CommonsHTTPTransportSenderClientSideTest.java  |  3 +-
 .../http/CommonsHTTPTransportSenderTest.java       | 17 +++--
 .../transport/http/HTTPClient3SenderTest.java      | 31 ++++++++
 .../http/HTTPClient3TransportSenderTest.java       | 32 ++++++++
 .../axis2/transport/http/HTTPSenderTest.java       | 85 ++++++++++++----------
 5 files changed, 122 insertions(+), 46 deletions(-)

diff --git 
a/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
 
b/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
index 658f5ca..671f49e 100644
--- 
a/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
+++ 
b/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
@@ -11,6 +11,7 @@ import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.transport.OutTransportInfo;
+import 
org.apache.axis2.transport.http.impl.httpclient3.HTTPClient3TransportSender;
 import org.apache.axis2.transport.http.mock.MockAxisHttpResponse;
 import org.apache.axis2.transport.http.mock.MockHTTPResponse;
 import org.apache.axis2.transport.http.mock.server.AbstractHTTPServerTest;
@@ -31,7 +32,7 @@ public class CommonsHTTPTransportSenderClientSideTest extends 
AbstractHTTPServer
         // client hence ignore the processing of response at client side.
         try {
             httpResponse = (MockAxisHttpResponse) 
CommonsHTTPTransportSenderTest.configAndRun(
-                    httpResponse, (OutTransportInfo) httpResponse, 
"http://localhost:"; + port);
+                    httpResponse, (OutTransportInfo) httpResponse, 
"http://localhost:"; + port,  new HTTPClient3TransportSender());
 
         } catch (Exception e) {
         }
diff --git 
a/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
 
b/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
index ec07b69..e3820bd 100644
--- 
a/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
+++ 
b/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
@@ -54,14 +54,16 @@ import org.apache.http.ProtocolVersion;
 import org.apache.http.RequestLine;
 import org.apache.http.message.BasicRequestLine;
 
-public class CommonsHTTPTransportSenderTest extends TestCase  {
+public abstract class CommonsHTTPTransportSenderTest extends TestCase  {
+    
+    protected abstract TransportSender getTransportSender();
 
     public void testInvokeWithServletBasedOutTransportInfo() throws Exception {
         MockHTTPResponse httpResponse = new MockHttpServletResponse();
         ServletBasedOutTransportInfo info = new ServletBasedOutTransportInfo(
                 (HttpServletResponse) httpResponse);
         SOAPEnvelope envelope = getEnvelope();
-        httpResponse = configAndRun(httpResponse, info, null);
+        httpResponse = configAndRun(httpResponse, info, null, 
getTransportSender());
 
         assertEquals("Not the expected Header value", "application/xml", 
httpResponse.getHeaders()
                 .get("Content-Type"));
@@ -76,7 +78,7 @@ public class CommonsHTTPTransportSenderTest extends TestCase  
{
         MockHTTPResponse httpResponse = new MockAxisHttpResponse(line);
         SOAPEnvelope envelope = getEnvelope();
         httpResponse = (MockAxisHttpResponse) configAndRun(httpResponse,
-                (OutTransportInfo) httpResponse, null);
+                (OutTransportInfo) httpResponse, null, getTransportSender());
 
         assertEquals("Not the expected Header value", "application/xml", 
httpResponse.getHeaders()
                 .get("Content-Type"));
@@ -87,7 +89,7 @@ public class CommonsHTTPTransportSenderTest extends TestCase  
{
     }
 
     public void testCleanup() throws AxisFault {
-        TransportSender sender = new CommonsHTTPTransportSender();
+        TransportSender sender = getTransportSender();
         MessageContext msgContext = new MessageContext();
         HttpMethod httpMethod = new GetMethod();
         msgContext.setProperty(HTTPConstants.HTTP_METHOD, httpMethod);
@@ -102,13 +104,13 @@ public class CommonsHTTPTransportSenderTest extends 
TestCase  {
         ConfigurationContext confContext = ConfigurationContextFactory
                 .createEmptyConfigurationContext();
         TransportOutDescription transportOut = new 
TransportOutDescription("http");
-        TransportSender sender = new CommonsHTTPTransportSender();
+        TransportSender sender = getTransportSender();
         sender.init(confContext, transportOut);
 
     }
 
     public static MockHTTPResponse configAndRun(MockHTTPResponse outResponse,
-            OutTransportInfo outTransportInfo, String epr) throws Exception {
+            OutTransportInfo outTransportInfo, String epr, TransportSender 
sender) throws Exception {
         MockHTTPResponse response = outResponse;
         ConfigurationContext confContext = ConfigurationContextFactory
                 .createEmptyConfigurationContext();
@@ -116,8 +118,7 @@ public class CommonsHTTPTransportSenderTest extends 
TestCase  {
         Parameter param = new Parameter(HTTPConstants.OMIT_SOAP_12_ACTION, 
false);
         SOAPEnvelope envelope = getEnvelope();
         MessageContext msgContext = new MessageContext();
-
-        TransportSender sender = new CommonsHTTPTransportSender();
+        
         transportOut.addParameter(param);
         // create dummy SOAPEnvelope
         msgContext.setEnvelope(envelope);
diff --git 
a/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
 
b/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
new file mode 100644
index 0000000..dff8b6f
--- /dev/null
+++ 
b/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.http;
+
+import org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl;
+
+public class HTTPClient3SenderTest extends HTTPSenderTest {
+
+    @Override
+    protected HTTPSender getHTTPSender() {
+        return new HTTPSenderImpl();
+    }
+
+}
diff --git 
a/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
 
b/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
new file mode 100644
index 0000000..058b62b
--- /dev/null
+++ 
b/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.http;
+
+import org.apache.axis2.transport.TransportSender;
+import 
org.apache.axis2.transport.http.impl.httpclient3.HTTPClient3TransportSender;
+
+public class HTTPClient3TransportSenderTest extends 
CommonsHTTPTransportSenderTest {
+
+    @Override
+    protected TransportSender getTransportSender() {
+        return new HTTPClient3TransportSender();
+    }
+
+}
diff --git 
a/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
 
b/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
index ad7d9d0..dd77c51 100644
--- 
a/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
+++ 
b/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
@@ -35,48 +35,56 @@ import 
org.apache.axis2.transport.http.mock.server.AbstractHTTPServerTest;
 /**
  * The Class HTTPSenderTest.
  */
-public class HTTPSenderTest extends AbstractHTTPServerTest {
-   
+public abstract class HTTPSenderTest extends AbstractHTTPServerTest {
+
     private HTTPSender httpSender;
 
+    protected abstract HTTPSender getHTTPSender();
+
     /**
      * Send via http.
-     *
-     * @param httpMethod the http method
-     * @param soapAction the soap action
-     * @param address the address
-     * @param rest the rest
-     * @throws IOException Signals that an I/O exception has occurred.
-     * @throws MessagingException the messaging exception
+     * 
+     * @param httpMethod
+     *            the http method
+     * @param soapAction
+     *            the soap action
+     * @param address
+     *            the address
+     * @param rest
+     *            the rest
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     * @throws MessagingException
+     *             the messaging exception
      */
     private void sendViaHTTP(String httpMethod, String soapAction, String 
address, boolean rest)
             throws IOException, MessagingException {
-        httpSender = new HTTPSender();
+        httpSender = getHTTPSender();
         MessageContext msgContext = new MessageContext();
         ConfigurationContext configContext = ConfigurationContextFactory
                 .createEmptyConfigurationContext();
         OperationContext opContext = new OperationContext();
-        
+
         msgContext.setConfigurationContext(configContext);
         msgContext.setEnvelope(getEnvelope());
         msgContext.setDoingREST(rest);
-        msgContext.setProperty(Constants.Configuration.HTTP_METHOD, 
httpMethod);      
-        msgContext.setOperationContext(opContext );
-        URL url = new URL(address);        
+        msgContext.setProperty(Constants.Configuration.HTTP_METHOD, 
httpMethod);
+        msgContext.setOperationContext(opContext);
+        URL url = new URL(address);
         httpSender.send(msgContext, url, soapAction);
-       
 
     }
 
     /**
      * Test send via get.
-     *
-     * @throws Exception the exception
+     * 
+     * @throws Exception
+     *             the exception
      */
     public void testSendViaGet() throws Exception {
         int port = getBasicHttpServer().getPort();
-        sendViaHTTP(Constants.Configuration.HTTP_METHOD_GET, "urn:getService",
-                "http://localhost:"; + port + "/getService", true);
+        sendViaHTTP(Constants.Configuration.HTTP_METHOD_GET, "urn:getService", 
"http://localhost:";
+                + port + "/getService", true);
         assertEquals("Not the expected HTTP Method", 
Constants.Configuration.HTTP_METHOD_GET,
                 getHTTPMethod());
         assertEquals("Not the expected content", 
"/getService?part=sample%20data",
@@ -91,11 +99,12 @@ public class HTTPSenderTest extends AbstractHTTPServerTest {
         assertEquals("Not the expected HTTP Header value", "Axis2",
                 getHeaders().get(HttpHeaders.USER_AGENT));
     }
-    
+
     /**
      * Test send via post.
-     *
-     * @throws Exception the exception
+     * 
+     * @throws Exception
+     *             the exception
      */
     public void testSendViaPost() throws Exception {
         // test with REST payload
@@ -133,14 +142,15 @@ public class HTTPSenderTest extends 
AbstractHTTPServerTest {
 
     /**
      * Test send via put.
-     *
-     * @throws Exception the exception
+     * 
+     * @throws Exception
+     *             the exception
      */
     public void testSendViaPut() throws Exception {
         // test with REST payload
         int port = getBasicHttpServer().getPort();
-        sendViaHTTP(Constants.Configuration.HTTP_METHOD_PUT, "urn:putService",
-                "http://localhost:"; + port + "/putService", true);
+        sendViaHTTP(Constants.Configuration.HTTP_METHOD_PUT, "urn:putService", 
"http://localhost:";
+                + port + "/putService", true);
         assertEquals("Not the expected HTTP Method", 
Constants.Configuration.HTTP_METHOD_PUT,
                 getHTTPMethod());
         assertEquals("Not the expected content", 
getEnvelope().getFirstElement().getFirstElement()
@@ -155,8 +165,8 @@ public class HTTPSenderTest extends AbstractHTTPServerTest {
                 getHeaders().get(HttpHeaders.USER_AGENT));
 
         // test with SOAP payload.
-        sendViaHTTP(Constants.Configuration.HTTP_METHOD_PUT, "urn:putService",
-                "http://localhost:"; + port + "/putService", false);
+        sendViaHTTP(Constants.Configuration.HTTP_METHOD_PUT, "urn:putService", 
"http://localhost:";
+                + port + "/putService", false);
         assertEquals("Not the expected HTTP Method", 
Constants.Configuration.HTTP_METHOD_PUT,
                 getHTTPMethod());
         assertEquals("Not the expected content", getEnvelope().toString(), 
getStringContent());
@@ -172,8 +182,9 @@ public class HTTPSenderTest extends AbstractHTTPServerTest {
 
     /**
      * Test send via delete.
-     *
-     * @throws Exception the exception
+     * 
+     * @throws Exception
+     *             the exception
      */
     public void testSendViaDelete() throws Exception {
         // test with REST payload
@@ -196,8 +207,9 @@ public class HTTPSenderTest extends AbstractHTTPServerTest {
 
     /**
      * Test send via head.
-     *
-     * @throws Exception the exception
+     * 
+     * @throws Exception
+     *             the exception
      */
     public void testSendViaHead() throws Exception {
 
@@ -219,8 +231,9 @@ public class HTTPSenderTest extends AbstractHTTPServerTest {
 
     /**
      * Test send nohttp method.
-     *
-     * @throws Exception the exception
+     * 
+     * @throws Exception
+     *             the exception
      */
     public void testSendNOHTTPMethod() throws Exception {
 
@@ -239,8 +252,6 @@ public class HTTPSenderTest extends AbstractHTTPServerTest {
         assertEquals("Not the expected HTTP Header value", "Axis2",
                 getHeaders().get(HttpHeaders.USER_AGENT));
 
-    }   
-    
+    }
 
-   
 }

Reply via email to