You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/22 13:47:49 UTC
svn commit: r1779815 [2/2] - in
/axis/axis2/java/core/branches/hermetic-tests: ./
modules/kernel/src/org/apache/axis2/transport/http/
modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/
modules/transport/http/src/...
Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java Sun Jan 22 13:47:49 2017
@@ -19,28 +19,42 @@
package org.apache.axis2.transport.http.impl.httpclient4;
import java.io.IOException;
+import java.io.InputStream;
+import java.net.URISyntaxException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+import org.apache.axiom.mime.Header;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.NamedValue;
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.transport.http.AxisRequestEntity;
+import org.apache.axis2.transport.http.HTTPAuthenticator;
import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.HTTPTransportConstants;
import org.apache.axis2.transport.http.Request;
+import org.apache.axis2.util.Utils;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.NTCredentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.auth.params.AuthPNames;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.params.AuthPolicy;
import org.apache.http.client.params.ClientPNames;
+import org.apache.http.impl.auth.NTLMSchemeFactory;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.params.HttpParams;
@@ -56,22 +70,47 @@ final class RequestImpl implements Reque
protected final URL url;
protected final HttpRequestBase method;
protected final AbstractHttpClient httpClient;
+ private final HttpHost httpHost;
+ private HttpResponse response;
- RequestImpl(HTTPSenderImpl sender, MessageContext msgContext, URL url, AxisRequestEntity requestEntity, HttpRequestBase method) throws AxisFault {
+ RequestImpl(HTTPSenderImpl sender, MessageContext msgContext, final String methodName, URL url,
+ AxisRequestEntity requestEntity) throws AxisFault {
this.sender = sender;
this.msgContext = msgContext;
this.url = url;
- this.method = method;
httpClient = sender.getHttpClient(msgContext);
- sender.populateCommonProperties(msgContext, url, method, httpClient);
- if (requestEntity != null) {
- AxisRequestEntityImpl requestEntityAdapter = new AxisRequestEntityImpl(requestEntity);
- ((HttpEntityEnclosingRequest)method).setEntity(requestEntityAdapter);
-
- if (!sender.getHttpVersion().equals(HTTPConstants.HEADER_PROTOCOL_10) && sender.isChunked()) {
- requestEntity.setChunked(sender.isChunked());
+ if (requestEntity == null) {
+ method = new HttpRequestBase() {
+ @Override
+ public String getMethod() {
+ return methodName;
+ }
+ };
+ } else {
+ HttpEntityEnclosingRequestBase entityEnclosingRequest = new HttpEntityEnclosingRequestBase() {
+ @Override
+ public String getMethod() {
+ return methodName;
+ }
+ };
+ entityEnclosingRequest.setEntity(new AxisRequestEntityImpl(requestEntity));
+ method = entityEnclosingRequest;
+ }
+ try {
+ method.setURI(url.toURI());
+ } catch (URISyntaxException ex) {
+ throw AxisFault.makeFault(ex);
+ }
+ int port = url.getPort();
+ String protocol = url.getProtocol();
+ if (port == -1) {
+ if (HTTPTransportConstants.PROTOCOL_HTTP.equals(protocol)) {
+ port = 80;
+ } else if (HTTPTransportConstants.PROTOCOL_HTTPS.equals(protocol)) {
+ port = 443;
}
}
+ httpHost = new HttpHost(url.getHost(), port, url.getProtocol());
}
@Override
@@ -90,32 +129,47 @@ final class RequestImpl implements Reque
method.addHeader(name, value);
}
- @Override
- public NamedValue[] getRequestHeaders() {
- Header[] headers = method.getAllHeaders();
- NamedValue[] result = new NamedValue[headers.length];
+ private static Header[] convertHeaders(org.apache.http.Header[] headers) {
+ Header[] result = new Header[headers.length];
for (int i=0; i<headers.length; i++) {
- result[i] = new NamedValue(headers[i].getName(), headers[i].getValue());
+ result[i] = new Header(headers[i].getName(), headers[i].getValue());
}
return result;
}
@Override
+ public Header[] getRequestHeaders() {
+ return convertHeaders(method.getAllHeaders());
+ }
+
+ @Override
+ public int getStatusCode() {
+ return response.getStatusLine().getStatusCode();
+ }
+
+ @Override
+ public String getStatusText() {
+ return response.getStatusLine().getReasonPhrase();
+ }
+
+ @Override
+ public Header[] getResponseHeaders() {
+ return convertHeaders(response.getAllHeaders());
+ }
+
+ @Override
public void execute() throws AxisFault {
- HttpResponse response = null;
try {
- response = executeMethod();
- handleResponse(response);
+ executeMethod();
+ handleResponse();
} catch (IOException e) {
log.info("Unable to send to url[" + url + "]", e);
throw AxisFault.makeFault(e);
- } finally {
- cleanup(response);
}
}
- private HttpResponse executeMethod() throws IOException {
- HttpHost httpHost = sender.getHostConfiguration(httpClient, msgContext, url);
+ private void executeMethod() throws IOException {
+ populateHostConfiguration();
// add compression headers if needed
if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
@@ -123,11 +177,6 @@ final class RequestImpl implements Reque
HTTPConstants.COMPRESSION_GZIP);
}
- if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
- method.addHeader(HTTPConstants.HEADER_CONTENT_ENCODING,
- HTTPConstants.COMPRESSION_GZIP);
- }
-
if (msgContext.getProperty(HTTPConstants.HTTP_METHOD_PARAMS) != null) {
HttpParams params = (HttpParams) msgContext
.getProperty(HTTPConstants.HTTP_METHOD_PARAMS);
@@ -142,73 +191,168 @@ final class RequestImpl implements Reque
sender.setTimeouts(msgContext, method);
HttpContext localContext = new BasicHttpContext();
// Why do we have add context here
- return httpClient.execute(httpHost, method, localContext);
+ response = httpClient.execute(httpHost, method, localContext);
}
- private void handleResponse(HttpResponse response)
- throws IOException {
- int statusCode = response.getStatusLine().getStatusCode();
- log.trace("Handling response - " + statusCode);
- if (statusCode == HttpStatus.SC_ACCEPTED) {
- msgContext.setProperty(HTTPConstants.CLEANUP_RESPONSE, Boolean.TRUE);
- /*
- * 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.
- */
- sender.obtainHTTPHeaderInformation(response, msgContext);
-
- } else if (statusCode >= 200 && statusCode < 300) {
- // We don't clean the response here because the response will be used afterwards
- msgContext.setProperty(HTTPConstants.CLEANUP_RESPONSE, Boolean.FALSE);
- sender.processResponse(response, msgContext);
-
- } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR
- || statusCode == HttpStatus.SC_BAD_REQUEST) {
- msgContext.setProperty(HTTPConstants.CLEANUP_RESPONSE, Boolean.TRUE);
- Header contentTypeHeader = response.getFirstHeader(HTTPConstants.HEADER_CONTENT_TYPE);
- String value = null;
- if (contentTypeHeader != null) {
- value = contentTypeHeader.getValue();
- }
- OperationContext opContext = msgContext.getOperationContext();
- if (opContext != null) {
- MessageContext inMessageContext = opContext
- .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- if (inMessageContext != null) {
- inMessageContext.setProcessingFault(true);
+ private void handleResponse() throws IOException {
+ boolean cleanup = true;
+ try {
+ int statusCode = getStatusCode();
+ log.trace("Handling response - " + statusCode);
+ boolean processResponse;
+ boolean fault;
+ if (statusCode == HttpStatus.SC_ACCEPTED) {
+ processResponse = false;
+ fault = false;
+ } else if (statusCode >= 200 && statusCode < 300) {
+ processResponse = true;
+ fault = false;
+ } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR
+ || statusCode == HttpStatus.SC_BAD_REQUEST) {
+ processResponse = true;
+ fault = true;
+ } else {
+ throw new AxisFault(Messages.getMessage("transportError", String.valueOf(statusCode),
+ getStatusText()));
+ }
+ sender.obtainHTTPHeaderInformation(this, response, msgContext);
+ if (processResponse) {
+ OperationContext opContext = msgContext.getOperationContext();
+ MessageContext inMessageContext = opContext == null ? null
+ : opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ if (opContext != null) {
+ HttpEntity httpEntity = response.getEntity();
+ if (httpEntity != null) {
+ InputStream in = httpEntity.getContent();
+ org.apache.http.Header contentEncoding = httpEntity.getContentEncoding();
+ if (contentEncoding != null) {
+ if (contentEncoding.getValue().equalsIgnoreCase(HTTPConstants.COMPRESSION_GZIP)) {
+ in = new GZIPInputStream(in);
+ // If the content-encoding is identity we can basically ignore
+ // it.
+ } else if (!"identity".equalsIgnoreCase(contentEncoding.getValue())) {
+ throw new AxisFault("HTTP :" + "unsupported content-encoding of '"
+ + contentEncoding.getValue() + "' found");
+ }
+ }
+ opContext.setProperty(MessageContext.TRANSPORT_IN, in);
+ cleanup = false;
+ }
+ }
+ if (fault) {
+ if (inMessageContext != null) {
+ inMessageContext.setProcessingFault(true);
+ }
+ if (Utils.isClientThreadNonBlockingPropertySet(msgContext)) {
+ throw new AxisFault(Messages.
+ getMessage("transportError",
+ String.valueOf(statusCode),
+ getStatusText()));
+ }
}
}
- if (value != null) {
- msgContext.setProperty(HTTPConstants.CLEANUP_RESPONSE, Boolean.FALSE);
- sender.processResponse(response, msgContext);
+ } finally {
+ if (cleanup) {
+ cleanup(response);
}
+ }
- if (org.apache.axis2.util.Utils.isClientThreadNonBlockingPropertySet(msgContext)) {
- throw new AxisFault(Messages.
- getMessage("transportError",
- String.valueOf(statusCode),
- response.getStatusLine().toString()));
+ }
+
+ private void cleanup(HttpResponse response) {
+ log.trace("Cleaning response : " + response);
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ try {
+ EntityUtils.consume(entity);
+ } catch (IOException e) {
+ log.error("Error while cleaning response : " + response, e);
}
- } else {
- msgContext.setProperty(HTTPConstants.CLEANUP_RESPONSE, Boolean.TRUE);
- throw new AxisFault(Messages.getMessage("transportError", String.valueOf(statusCode),
- response.getStatusLine().toString()));
}
}
- private void cleanup(HttpResponse response) {
- if (msgContext.isPropertyTrue(HTTPConstants.CLEANUP_RESPONSE)) {
- log.trace("Cleaning response : " + response);
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- try {
- EntityUtils.consume(entity);
- } catch (IOException e) {
- log.error("Error while cleaning response : " + response, e);
+ /**
+ * getting host configuration to support standard http/s, proxy and NTLM
+ * support
+ *
+ * @return a HostConfiguration set up with proxy information
+ * @throws org.apache.axis2.AxisFault if problems occur
+ */
+ private void populateHostConfiguration() throws AxisFault {
+ // proxy configuration
+
+ if (HTTPProxyConfigurator.isProxyEnabled(msgContext, url)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Configuring HTTP proxy.");
+ }
+ HTTPProxyConfigurator.configure(msgContext, httpClient);
+ }
+ }
+
+ /*
+ * This will handle server Authentication, It could be either NTLM, Digest
+ * or Basic Authentication. Apart from that user can change the priory or
+ * add a custom authentication scheme.
+ */
+ @Override
+ public void enableAuthentication(HTTPAuthenticator authenticator) {
+ method.getParams().setBooleanParameter(ClientPNames.HANDLE_AUTHENTICATION, true);
+
+ String username = authenticator.getUsername();
+ String password = authenticator.getPassword();
+ String host = authenticator.getHost();
+ String domain = authenticator.getDomain();
+
+ int port = authenticator.getPort();
+ String realm = authenticator.getRealm();
+
+ Credentials creds;
+
+ // TODO : Set preemptive authentication, but its not recommended in HC 4
+
+ if (host != null) {
+ if (domain != null) {
+ /* Credentials for NTLM Authentication */
+ httpClient.getAuthSchemes().register("ntlm",new NTLMSchemeFactory());
+ creds = new NTCredentials(username, password, host, domain);
+ } else {
+ /* Credentials for Digest and Basic Authentication */
+ creds = new UsernamePasswordCredentials(username, password);
+ }
+ httpClient.getCredentialsProvider().
+ setCredentials(new AuthScope(host, port, realm), creds);
+ } else {
+ if (domain != null) {
+ /*
+ * Credentials for NTLM Authentication when host is
+ * ANY_HOST
+ */
+ httpClient.getAuthSchemes().register("ntlm",new NTLMSchemeFactory());
+ creds = new NTCredentials(username, password, AuthScope.ANY_HOST, domain);
+ httpClient.getCredentialsProvider().
+ setCredentials(new AuthScope(AuthScope.ANY_HOST, port, realm),
+ creds);
+ } else {
+ /* Credentials only for Digest and Basic Authentication */
+ creds = new UsernamePasswordCredentials(username, password);
+ httpClient.getCredentialsProvider().
+ setCredentials(new AuthScope(AuthScope.ANY), creds);
+ }
+ }
+ /* Customizing the priority Order */
+ List schemes = authenticator.getAuthSchemes();
+ if (schemes != null && schemes.size() > 0) {
+ List authPrefs = new ArrayList(3);
+ for (int i = 0; i < schemes.size(); i++) {
+ if (schemes.get(i) instanceof AuthPolicy) {
+ authPrefs.add(schemes.get(i));
+ continue;
}
+ String scheme = (String) schemes.get(i);
+ authPrefs.add(authenticator.getAuthPolicyPref(scheme));
+
}
+ httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authPrefs);
}
}
}
Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4SenderTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4SenderTest.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4SenderTest.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4SenderTest.java Sun Jan 22 13:47:49 2017
@@ -19,159 +19,12 @@
package org.apache.axis2.transport.http;
-import org.apache.axis2.Constants;
import org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl;
-import static com.google.common.truth.Truth.assertAbout;
-import static org.apache.axiom.truth.xml.XMLTruth.xml;
-
-import javax.ws.rs.core.HttpHeaders;
-
public class HTTPClient4SenderTest extends HTTPSenderTest {
@Override
protected HTTPSender getHTTPSender() {
return new HTTPSenderImpl();
}
-
- @Override
- public void testSendViaGet() throws Exception {
- int port = getBasicHttpServer().getPort();
- 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",
- getStringContent());
- assertNull("Not the expected HTTP Header value", getHeaders().get("SOAPAction"));
- assertEquals("Not the expected HTTP Header value",
- "application/x-www-form-urlencoded;action=\"urn:getService\";",
- getHeaders().get(HttpHeaders.CONTENT_TYPE));
- assertEquals("Not the expected HTTP Header value", "localhost",
- getHeaders().get(HttpHeaders.HOST));
- assertEquals("Not the expected HTTP Header value", "Axis2",
- getHeaders().get(HttpHeaders.USER_AGENT));
- }
-
- @Override
- public void testSendViaPost() throws Exception {
- // test with REST payload
- int port = getBasicHttpServer().getPort();
- sendViaHTTP(Constants.Configuration.HTTP_METHOD_POST, "urn:postService",
- "http://localhost:" + port + "/postService", true);
- assertEquals("Not the expected HTTP Method", Constants.Configuration.HTTP_METHOD_POST,
- getHTTPMethod());
- assertEquals("Not the expected content", getEnvelope().getFirstElement().getFirstElement()
- .toString(), getStringContent());
- assertNull("Not the expected HTTP Header value", getHeaders().get("SOAPAction"));
- assertEquals("Not the expected HTTP Header value", "application/xml",
- getHeaders().get(HttpHeaders.CONTENT_TYPE));
- assertEquals("Not the expected HTTP Header value", "localhost",
- getHeaders().get(HttpHeaders.HOST));
- assertEquals("Not the expected HTTP Header value", "Axis2",
- getHeaders().get(HttpHeaders.USER_AGENT));
-
- // test with SOAP payload.
- sendViaHTTP(Constants.Configuration.HTTP_METHOD_POST, "urn:postService",
- "http://localhost:" + port + "/postService", false);
- assertEquals("Not the expected HTTP Method", Constants.Configuration.HTTP_METHOD_POST,
- getHTTPMethod());
- assertAbout(xml()).that(getStringContent()).hasSameContentAs(getEnvelope().toString());
- assertEquals("Not the expected HTTP Header value", "urn:postService",
- getHeaders().get("SOAPAction").replace("\"", ""));
- assertEquals("Not the expected HTTP Header value", "text/xml",
- getHeaders().get(HttpHeaders.CONTENT_TYPE));
- assertEquals("Not the expected HTTP Header value", "localhost",
- getHeaders().get(HttpHeaders.HOST));
- assertEquals("Not the expected HTTP Header value", "Axis2",
- getHeaders().get(HttpHeaders.USER_AGENT));
- }
-
- @Override
- 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);
- assertEquals("Not the expected HTTP Method", Constants.Configuration.HTTP_METHOD_PUT,
- getHTTPMethod());
- assertEquals("Not the expected content", getEnvelope().getFirstElement().getFirstElement()
- .toString(), getStringContent());
- assertNull("Not the expected HTTP Header value", getHeaders().get("SOAPAction"));
- assertEquals("Not the expected HTTP Header value", "application/xml",
- getHeaders().get(HttpHeaders.CONTENT_TYPE));
- assertEquals("Not the expected HTTP Header value", "localhost",
- getHeaders().get(HttpHeaders.HOST));
- assertEquals("Not the expected HTTP Header value", "Axis2",
- getHeaders().get(HttpHeaders.USER_AGENT));
-
- // test with SOAP payload.
- 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());
- assertAbout(xml()).that(getStringContent()).hasSameContentAs(getEnvelope().toString());
- assertEquals("Not the expected HTTP Header value", "urn:putService",
- getHeaders().get("SOAPAction").replace("\"", ""));
- assertEquals("Not the expected HTTP Header value", "text/xml",
- getHeaders().get(HttpHeaders.CONTENT_TYPE));
- assertEquals("Not the expected HTTP Header value", "localhost",
- getHeaders().get(HttpHeaders.HOST));
- assertEquals("Not the expected HTTP Header value", "Axis2",
- getHeaders().get(HttpHeaders.USER_AGENT));
- }
-
- @Override
- public void testSendViaDelete() throws Exception {
- // test with REST payload
- int port = getBasicHttpServer().getPort();
- sendViaHTTP(Constants.Configuration.HTTP_METHOD_DELETE, "urn:deleteService",
- "http://localhost:" + port + "/deleteService", true);
- assertEquals("Not the expected HTTP Method", Constants.Configuration.HTTP_METHOD_DELETE,
- getHTTPMethod());
- assertEquals("Not the expected content", "/deleteService?part=sample%20data",
- getStringContent());
- assertEquals("Not the expected HTTP Header value",
- "application/x-www-form-urlencoded;action=\"urn:deleteService\";", getHeaders()
- .get(HttpHeaders.CONTENT_TYPE));
- assertEquals("Not the expected HTTP Header value", "localhost",
- getHeaders().get(HttpHeaders.HOST));
- assertEquals("Not the expected HTTP Header value", "Axis2",
- getHeaders().get(HttpHeaders.USER_AGENT));
- }
-
- @Override
- public void testSendViaHead() throws Exception {
- int port = getBasicHttpServer().getPort();
- sendViaHTTP(Constants.Configuration.HTTP_METHOD_HEAD, "urn:deleteService",
- "http://localhost:" + port + "/deleteService", true);
- assertEquals("Not the expected HTTP Method", Constants.Configuration.HTTP_METHOD_POST,
- getHTTPMethod());
- assertEquals("Not the expected content", getEnvelope().getFirstElement().getFirstElement()
- .toString(), getStringContent());
- assertEquals("Not the expected HTTP Header value", "application/xml",
- getHeaders().get(HttpHeaders.CONTENT_TYPE));
- assertEquals("Not the expected HTTP Header value", "localhost",
- getHeaders().get(HttpHeaders.HOST));
- assertEquals("Not the expected HTTP Header value", "Axis2",
- getHeaders().get(HttpHeaders.USER_AGENT));
-
- }
-
- @Override
- public void testSendNOHTTPMethod() throws Exception {
- int port = getBasicHttpServer().getPort();
- sendViaHTTP(null, "urn:noService", "http://localhost:" + port + "/noService", true);
- assertEquals("Not the expected HTTP Method", Constants.Configuration.HTTP_METHOD_POST,
- getHTTPMethod());
- assertEquals("Not the expected content", getEnvelope().getFirstElement().getFirstElement()
- .toString(), getStringContent());
- assertNull("Not the expected HTTP Header value", getHeaders().get("SOAPAction"));
- assertEquals("Not the expected HTTP Header value", "application/xml",
- getHeaders().get(HttpHeaders.CONTENT_TYPE));
- assertEquals("Not the expected HTTP Header value", "localhost",
- getHeaders().get(HttpHeaders.HOST));
- assertEquals("Not the expected HTTP Header value", "Axis2",
- getHeaders().get(HttpHeaders.USER_AGENT));
- }
}
Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java Sun Jan 22 13:47:49 2017
@@ -212,7 +212,8 @@ public abstract class HTTPSenderTest ext
* @throws Exception
* the exception
*/
- public void testSendViaHead() throws Exception {
+ // This is test is bullshit; if we send a HEAD request, we shouldn't expect the method to be POST
+ public void _testSendViaHead() throws Exception {
int port = getBasicHttpServer().getPort();
sendViaHTTP(Constants.Configuration.HTTP_METHOD_HEAD, "urn:deleteService",