Author: sagara
Date: Thu Mar  1 12:52:26 2012
New Revision: 1295542

URL: http://svn.apache.org/viewvc?rev=1295542&view=rev
Log:
AXIS2-4318 - Refactored  test cases. 

Added:
    
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
   (with props)
    
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
   (with props)
Modified:
    
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
    
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
    
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java

Modified: 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java?rev=1295542&r1=1295541&r2=1295542&view=diff
==============================================================================
--- 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
 (original)
+++ 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
 Thu Mar  1 12:52:26 2012
@@ -11,6 +11,7 @@ import org.apache.axis2.client.ServiceCl
 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 CommonsHTTPTransportSenderC
         // 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) {
         }

Modified: 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java?rev=1295542&r1=1295541&r2=1295542&view=diff
==============================================================================
--- 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
 (original)
+++ 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
 Thu Mar  1 12:52:26 2012
@@ -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 CommonsHTTPTransportSenderT
         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 CommonsHTTPTransportSenderT
     }
 
     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 CommonsHTTPTransportSenderT
         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 CommonsHTTPTransportSenderT
         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);

Added: 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java?rev=1295542&view=auto
==============================================================================
--- 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
 (added)
+++ 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
 Thu Mar  1 12:52:26 2012
@@ -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();
+    }
+
+}

Propchange: 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java?rev=1295542&view=auto
==============================================================================
--- 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
 (added)
+++ 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
 Thu Mar  1 12:52:26 2012
@@ -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();
+    }
+
+}

Propchange: 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java?rev=1295542&r1=1295541&r2=1295542&view=diff
==============================================================================
--- 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
 (original)
+++ 
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
 Thu Mar  1 12:52:26 2012
@@ -35,48 +35,56 @@ import org.apache.axis2.transport.http.m
 /**
  * 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 Abst
         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 Abst
 
     /**
      * 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 Abst
                 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 Abst
 
     /**
      * 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 Abst
 
     /**
      * 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 Abst
 
     /**
      * 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 Abst
         assertEquals("Not the expected HTTP Header value", "Axis2",
                 getHeaders().get(HttpHeaders.USER_AGENT));
 
-    }   
-    
+    }
 
-   
 }


Reply via email to