Copied: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java (from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java) URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java?p2=axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java&p1=axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java&r1=1230452&r2=1341384&rev=1341384&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java Tue May 22 10:10:01 2012 @@ -296,23 +296,19 @@ public class HTTPSenderImpl extends HTTP return; } int statusCode = method.getStatusCode(); + HTTPStatusCodeFamily family = getHTTPStatusCodeFamily(statusCode); log.trace("Handling response - " + statusCode); - if (statusCode == HttpStatus.SC_OK) { - // Save the HttpMethod so that we can release the connection when - // cleaning up - msgContext.setProperty(HTTPConstants.HTTP_METHOD, method); - processResponse(method, msgContext); - } else if (statusCode == HttpStatus.SC_ACCEPTED) { - /* - * When an HTTP 202 Accepted code has been received, this will be - * the case of an execution of an in-only operation. In such a - * scenario, the HTTP response headers should be returned, i.e. - * session cookies. - */ + if (statusCode == HttpStatus.SC_ACCEPTED) { + /* When an HTTP 202 Accepted code has been received, this will be the case of an execution + * of an in-only operation. In such a scenario, the HTTP response headers should be returned, + * i.e. session cookies. */ obtainHTTPHeaderInformation(method, msgContext); - // Since we don't expect any content with a 202 response, we must - // release the connection - method.releaseConnection(); + // Since we don't expect any content with a 202 response, we must release the connection + method.releaseConnection(); + } else if (HTTPStatusCodeFamily.SUCCESSFUL.equals(family)) { + // Save the HttpMethod so that we can release the connection when cleaning up + msgContext.setProperty(HTTPConstants.HTTP_METHOD, method); + processResponse(method, msgContext); } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR || statusCode == HttpStatus.SC_BAD_REQUEST) { // Save the HttpMethod so that we can release the connection when @@ -542,11 +538,11 @@ public class HTTPSenderImpl extends HTTP } // proxy configuration - if (HTTPProxcyConfigurator.isProxyEnabled(msgCtx, targetURL)) { + if (HTTPProxyConfigurator.isProxyEnabled(msgCtx, targetURL)) { if (log.isDebugEnabled()) { log.debug("Configuring HTTP proxy."); } - HTTPProxcyConfigurator.configure(msgCtx, client, config); + HTTPProxyConfigurator.configure(msgCtx, client, config); } return config;
Copied: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java (from r1332141, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java) URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java?p2=axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java&p1=axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java&r1=1332141&r2=1341384&rev=1341384&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java Tue May 22 10:10:01 2012 @@ -87,6 +87,9 @@ public class HTTPProxyConfigurator { if (proxyPassword == null) { proxyPassword = ""; } + + proxyCredentials = new UsernamePasswordCredentials(proxyUser, proxyPassword); + int proxyUserDomainIndex = proxyUser.indexOf("\\"); if (proxyUserDomainIndex > 0) { String domain = proxyUser.substring(0, proxyUserDomainIndex); @@ -96,9 +99,7 @@ public class HTTPProxyConfigurator { domain); } } - proxyCredentials = new UsernamePasswordCredentials(proxyUser, proxyPassword); } - } // If there is runtime proxy settings, these settings will override Copied: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java (from r1332141, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java) URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java?p2=axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java&p1=axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java&r1=1332141&r2=1341384&rev=1341384&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java Tue May 22 10:10:01 2012 @@ -58,6 +58,8 @@ import org.apache.http.client.methods.Ht import org.apache.http.client.params.AuthPolicy; import org.apache.http.client.params.ClientPNames; import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.params.ConnManagerPNames; +import org.apache.http.conn.params.ConnPerRouteBean; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; @@ -318,21 +320,21 @@ public class HTTPSenderImpl extends HTTP int statusCode = response.getStatusLine().getStatusCode(); HTTPStatusCodeFamily family = getHTTPStatusCodeFamily(statusCode); log.trace("Handling response - " + statusCode); - if (HTTPStatusCodeFamily.SUCCESSFUL.equals(family)) { + if (statusCode == HttpStatus.SC_ACCEPTED) { + /* + * When an HTTP 202 Accepted code has been received, this will be + * the case of an execution of an in-only operation. In such a + * scenario, the HTTP response headers should be returned, i.e. + * session cookies. + */ + obtainHTTPHeaderInformation(response, msgContext); + + } else if (HTTPStatusCodeFamily.SUCCESSFUL.equals(family)) { // Save the HttpMethod so that we can release the connection when // cleaning up // TODO : Do we need to save the http method // msgContext.setProperty(HTTPConstants.HTTP_METHOD, method); - processResponse(response, msgContext); - } else if (statusCode == HttpStatus.SC_ACCEPTED) { - /* - * When an HTTP 202 Accepted code has been received, this will be - * the case of an execution of an in-only operation. In such a - * scenario, the HTTP response headers should be returned, i.e. - * session cookies. - */ - obtainHTTPHeaderInformation(response.getEntity(), msgContext); } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR || statusCode == HttpStatus.SC_BAD_REQUEST) { @@ -813,7 +815,11 @@ public class HTTPSenderImpl extends HTTP schemeRegistry.register( new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); - connManager = new ThreadSafeClientConnManager(new BasicHttpParams(), + HttpParams params = new BasicHttpParams(); + params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30); + params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, + new ConnPerRouteBean(30)); + connManager = new ThreadSafeClientConnManager(params, schemeRegistry); configContext.setProperty( HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, connManager); @@ -824,7 +830,9 @@ public class HTTPSenderImpl extends HTTP * Create a new instance of HttpClient since the way it is used here * it's not fully thread-safe. */ - httpClient = new DefaultHttpClient(connManager, null); + HttpParams clientParams = new BasicHttpParams(); + clientParams.setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET, "UTF-8"); + httpClient = new DefaultHttpClient(connManager, clientParams); //We don't need to set timeout for connection manager, since we are doing it below // and its enough Copied: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java (from r1327468, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java) URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java?p2=axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java&p1=axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java&r1=1327468&r2=1341384&rev=1341384&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java Tue May 22 10:10:01 2012 @@ -56,7 +56,6 @@ public class HttpTransportPropertiesImpl public static final String NTLM = AuthPolicy.NTLM; public static final String DIGEST = AuthPolicy.DIGEST; public static final String BASIC = AuthPolicy.BASIC; - public static final String SPNEGO = AuthPolicy.SPNEGO; public int getPort() { return port; @@ -82,8 +81,6 @@ public class HttpTransportPropertiesImpl return AuthPolicy.NTLM; } else if (DIGEST.equals(scheme)) { return AuthPolicy.DIGEST; - } else if (SPNEGO.equals(scheme)) { - return AuthPolicy.SPNEGO; } return null; } Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/HTTPProxyConfigurationUtil.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/HTTPProxyConfigurationUtil.java?rev=1341384&r1=1341383&r2=1341384&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/HTTPProxyConfigurationUtil.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/HTTPProxyConfigurationUtil.java Tue May 22 10:10:01 2012 @@ -42,6 +42,7 @@ import java.util.StringTokenizer; /** * Contains utility functions used when configuring HTTP Proxy for HTTP Sender. */ +@Deprecated public class HTTPProxyConfigurationUtil { private static Log log = LogFactory.getLog(HTTPProxyConfigurationUtil.class); Modified: axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java?rev=1341384&r1=1341383&r2=1341384&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java Tue May 22 10:10:01 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/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java?rev=1341384&r1=1341383&r2=1341384&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java Tue May 22 10:10:01 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); Modified: axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java?rev=1341384&r1=1341383&r2=1341384&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java Tue May 22 10:10:01 2012 @@ -19,10 +19,6 @@ package org.apache.axis2.transport.http; -import java.io.IOException; -import java.net.URL; - -import javax.mail.MessagingException; import org.apache.axis2.Constants; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; @@ -31,51 +27,64 @@ import org.apache.axis2.context.Operatio import org.apache.axis2.transport.http.mock.server.AbstractHTTPServerTest; import org.apache.axis2.transport.http.mock.server.BasicHttpServer; +import javax.mail.MessagingException; +import javax.ws.rs.core.HttpHeaders; +import java.io.IOException; +import java.net.URL; + /** * 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) + protected 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", @@ -84,17 +93,18 @@ public class HTTPSenderTest extends Abst getHeaders().get("SOAPAction")); assertEquals("Not the expected HTTP Header value", "application/x-www-form-urlencoded;action=\"urn:getService\";", - getHeaders().get("Content-Type")); + getHeaders().get(HttpHeaders.CONTENT_TYPE)); assertEquals("Not the expected HTTP Header value", "localhost:" + port, - getHeaders().get("Host")); + getHeaders().get(HttpHeaders.HOST)); assertEquals("Not the expected HTTP Header value", "Axis2", - getHeaders().get("User-Agent")); + 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 @@ -108,11 +118,11 @@ public class HTTPSenderTest extends Abst assertEquals("Not the expected HTTP Header value", "urn:postService", getHeaders().get("SOAPAction")); assertEquals("Not the expected HTTP Header value", "application/xml", - getHeaders().get("Content-Type")); + getHeaders().get(HttpHeaders.CONTENT_TYPE)); assertEquals("Not the expected HTTP Header value", "localhost:" + port, - getHeaders().get("Host")); + getHeaders().get(HttpHeaders.HOST)); assertEquals("Not the expected HTTP Header value", "Axis2", - getHeaders().get("User-Agent")); + getHeaders().get(HttpHeaders.USER_AGENT)); // test with SOAP payload. sendViaHTTP(Constants.Configuration.HTTP_METHOD_POST, "urn:postService", @@ -123,23 +133,24 @@ public class HTTPSenderTest extends Abst assertEquals("Not the expected HTTP Header value", "urn:postService", getHeaders().get("SOAPAction").replace("\"", "")); assertEquals("Not the expected HTTP Header value", "text/xml", - getHeaders().get("Content-Type")); + getHeaders().get(HttpHeaders.CONTENT_TYPE)); assertEquals("Not the expected HTTP Header value", "localhost:" + port, - getHeaders().get("Host")); + getHeaders().get(HttpHeaders.HOST)); assertEquals("Not the expected HTTP Header value", "Axis2", - getHeaders().get("User-Agent")); + getHeaders().get(HttpHeaders.USER_AGENT)); } /** * 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() @@ -147,32 +158,33 @@ public class HTTPSenderTest extends Abst assertEquals("Not the expected HTTP Header value", "urn:putService", getHeaders().get("SOAPAction")); assertEquals("Not the expected HTTP Header value", "application/xml", - getHeaders().get("Content-Type")); + getHeaders().get(HttpHeaders.CONTENT_TYPE)); assertEquals("Not the expected HTTP Header value", "localhost:" + port, - getHeaders().get("Host")); + getHeaders().get(HttpHeaders.HOST)); assertEquals("Not the expected HTTP Header value", "Axis2", - getHeaders().get("User-Agent")); + 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()); assertEquals("Not the expected HTTP Header value", "urn:putService", getHeaders().get("SOAPAction").replace("\"", "")); assertEquals("Not the expected HTTP Header value", "text/xml", - getHeaders().get("Content-Type")); + getHeaders().get(HttpHeaders.CONTENT_TYPE)); assertEquals("Not the expected HTTP Header value", "localhost:" + port, - getHeaders().get("Host")); + getHeaders().get(HttpHeaders.HOST)); assertEquals("Not the expected HTTP Header value", "Axis2", - getHeaders().get("User-Agent")); + getHeaders().get(HttpHeaders.USER_AGENT)); } /** * Test send via delete. - * - * @throws Exception the exception + * + * @throws Exception + * the exception */ public void testSendViaDelete() throws Exception { // test with REST payload @@ -185,18 +197,19 @@ public class HTTPSenderTest extends Abst getStringContent()); assertEquals("Not the expected HTTP Header value", "application/x-www-form-urlencoded;action=\"urn:deleteService\";", getHeaders() - .get("Content-Type")); + .get(HttpHeaders.CONTENT_TYPE)); assertEquals("Not the expected HTTP Header value", "localhost:" + port, - getHeaders().get("Host")); + getHeaders().get(HttpHeaders.HOST)); assertEquals("Not the expected HTTP Header value", "Axis2", - getHeaders().get("User-Agent")); + getHeaders().get(HttpHeaders.USER_AGENT)); } /** * Test send via head. - * - * @throws Exception the exception + * + * @throws Exception + * the exception */ public void testSendViaHead() throws Exception { @@ -208,18 +221,19 @@ public class HTTPSenderTest extends Abst assertEquals("Not the expected content", getEnvelope().getFirstElement().getFirstElement() .toString(), getStringContent()); assertEquals("Not the expected HTTP Header value", "application/xml", - getHeaders().get("Content-Type")); + getHeaders().get(HttpHeaders.CONTENT_TYPE)); assertEquals("Not the expected HTTP Header value", "localhost:" + port, - getHeaders().get("Host")); + getHeaders().get(HttpHeaders.HOST)); assertEquals("Not the expected HTTP Header value", "Axis2", - getHeaders().get("User-Agent")); + getHeaders().get(HttpHeaders.USER_AGENT)); } /** * Test send nohttp method. - * - * @throws Exception the exception + * + * @throws Exception + * the exception */ public void testSendNOHTTPMethod() throws Exception { @@ -232,16 +246,15 @@ public class HTTPSenderTest extends Abst assertEquals("Not the expected HTTP Header value", "urn:noService", getHeaders().get("SOAPAction")); assertEquals("Not the expected HTTP Header value", "application/xml", - getHeaders().get("Content-Type")); + getHeaders().get(HttpHeaders.CONTENT_TYPE)); assertEquals("Not the expected HTTP Header value", "localhost:" + port, - getHeaders().get("Host")); + getHeaders().get(HttpHeaders.HOST)); assertEquals("Not the expected HTTP Header value", "Axis2", - getHeaders().get("User-Agent")); + getHeaders().get(HttpHeaders.USER_AGENT)); - } - + } public void testHandleResponseHTTPStatusCode200() throws Exception { - httpSender = new HTTPSender(); + httpSender = getHTTPSender(); int port = getBasicHttpServer().getPort(); getBasicHttpServer().setResponseTemplate(BasicHttpServer.RESPONSE_HTTP_200); sendViaHTTP(Constants.Configuration.HTTP_METHOD_POST, "urn:postService", @@ -249,7 +262,7 @@ public class HTTPSenderTest extends Abst } public void testHandleResponseHTTPStatusCode201() throws Exception { - httpSender = new HTTPSender(); + httpSender = getHTTPSender(); int port = getBasicHttpServer().getPort(); getBasicHttpServer().setResponseTemplate(BasicHttpServer.RESPONSE_HTTP_201); sendViaHTTP(Constants.Configuration.HTTP_METHOD_POST, "urn:postService", @@ -257,7 +270,7 @@ public class HTTPSenderTest extends Abst } public void testHandleResponseHTTPStatusCode202() throws Exception { - httpSender = new HTTPSender(); + httpSender = getHTTPSender(); int port = getBasicHttpServer().getPort(); getBasicHttpServer().setResponseTemplate(BasicHttpServer.RESPONSE_HTTP_202); sendViaHTTP(Constants.Configuration.HTTP_METHOD_POST, "urn:postService", @@ -265,7 +278,7 @@ public class HTTPSenderTest extends Abst } public void testHandleResponseHTTPStatusCode400() throws Exception { - httpSender = new HTTPSender(); + httpSender = getHTTPSender(); int port = getBasicHttpServer().getPort(); getBasicHttpServer().setResponseTemplate(BasicHttpServer.RESPONSE_HTTP_400); sendViaHTTP(Constants.Configuration.HTTP_METHOD_POST, "urn:postService", @@ -273,7 +286,7 @@ public class HTTPSenderTest extends Abst } public void testHandleResponseHTTPStatusCode500() throws Exception { - httpSender = new HTTPSender(); + httpSender = getHTTPSender(); int port = getBasicHttpServer().getPort(); getBasicHttpServer().setResponseTemplate(BasicHttpServer.RESPONSE_HTTP_500); sendViaHTTP(Constants.Configuration.HTTP_METHOD_POST, "urn:postService", @@ -281,5 +294,4 @@ public class HTTPSenderTest extends Abst } - }