Author: davsclaus
Date: Wed Dec 29 16:40:56 2010
New Revision: 1053671
URL: http://svn.apache.org/viewvc?rev=1053671&view=rev
Log:
CAMEL-3218: Ported changes from camel-http to camel-http4 from rev 1053667
Added:
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
(contents, props changed)
- copied, changed from r1053350,
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpProducerHelperTest.java
Removed:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpProducerHelper.java
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpProducerHelperTest.java
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/GZIPHelper.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java?rev=1053671&r1=1053670&r2=1053671&view=diff
==============================================================================
---
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
(original)
+++
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
Wed Dec 29 16:40:56 2010
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
+import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Enumeration;
@@ -101,10 +102,10 @@ public class DefaultHttpBinding implemen
throw new RuntimeCamelException("Cannot read request parameters
due " + e.getMessage(), e);
}
- // reset the stream cache
- StreamCache cache = message.getBody(StreamCache.class);
- if (cache != null) {
- cache.reset();
+ Object body = message.getBody();
+ // reset the stream cache if the body is the instance of StreamCache
+ if (body instanceof StreamCache) {
+ ((StreamCache) body).reset();
}
// store the method and query and other info in headers
@@ -115,6 +116,19 @@ public class DefaultHttpBinding implemen
headers.put(Exchange.HTTP_PATH, request.getPathInfo());
headers.put(Exchange.CONTENT_TYPE, request.getContentType());
+ // if content type is serialized java object, then de-serialize it to
a Java object
+ if (request.getContentType() != null &&
HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(request.getContentType()))
{
+ try {
+ InputStream is =
endpoint.getCamelContext().getTypeConverter().mandatoryConvertTo(InputStream.class,
body);
+ Object object = HttpHelper.deserializeJavaObjectFromStream(is);
+ if (object != null) {
+ message.setBody(object);
+ }
+ } catch (Exception e) {
+ throw new RuntimeCamelException("Cannot deserialize body to
Java object", e);
+ }
+ }
+
populateAttachments(request, message);
}
@@ -242,6 +256,20 @@ public class DefaultHttpBinding implemen
}
protected void doWriteDirectResponse(Message message, HttpServletResponse
response, Exchange exchange) throws IOException {
+ // if content type is serialized Java object, then serialize and write
it to the response
+ String contentType = message.getHeader(Exchange.CONTENT_TYPE,
String.class);
+ if (contentType != null &&
HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) {
+ try {
+ Object object = message.getMandatoryBody(Serializable.class);
+ HttpHelper.writeObjectToServletResponse(response, object);
+ // object is written so return
+ return;
+ } catch (InvalidPayloadException e) {
+ throw IOHelper.createIOException(e);
+ }
+ }
+
+ // other kind of content type
InputStream is = null;
if (checkChunked(message, exchange)) {
is = message.getBody(InputStream.class);
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java?rev=1053671&r1=1053670&r2=1053671&view=diff
==============================================================================
---
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
(original)
+++
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
Wed Dec 29 16:40:56 2010
@@ -16,24 +16,24 @@
*/
package org.apache.camel.component.http4;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.ObjectInputStream;
+import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
+import org.apache.camel.CamelExchangeException;
import org.apache.camel.Exchange;
import org.apache.camel.InvalidPayloadException;
import org.apache.camel.Message;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.http4.helper.GZIPHelper;
import org.apache.camel.component.http4.helper.HttpHelper;
-import org.apache.camel.component.http4.helper.HttpProducerHelper;
import org.apache.camel.converter.IOConverter;
import org.apache.camel.converter.stream.CachedOutputStream;
import org.apache.camel.impl.DefaultProducer;
@@ -49,6 +49,7 @@ import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.FileEntity;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.entity.StringEntity;
@@ -67,6 +68,7 @@ public class HttpProducer extends Defaul
super(endpoint);
this.httpClient = endpoint.getHttpClient();
this.throwException = endpoint.isThrowExceptionOnFailure();
+ this.transferException = endpoint.isTransferException();
}
public void process(Exchange exchange) throws Exception {
@@ -78,7 +80,7 @@ public class HttpProducer extends Defaul
String httpProtocolVersion =
in.getHeader(Exchange.HTTP_PROTOCOL_VERSION, String.class);
if (httpProtocolVersion != null) {
// set the HTTP protocol version
-
httpRequest.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpProducerHelper.parserHttpVersion(httpProtocolVersion));
+
httpRequest.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpHelper.parserHttpVersion(httpProtocolVersion));
}
HeaderFilterStrategy strategy =
getEndpoint().getHeaderFilterStrategy();
@@ -237,31 +239,14 @@ public class HttpProducer extends Defaul
HttpHelper.setCharsetFromContentType(contentType, exchange);
}
InputStream response = doExtractResponseBodyAsStream(is, exchange);
+ // if content type is a serialized java object then de-serialize it
back to a Java object
if (contentType != null &&
contentType.equals(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT)) {
- return doDeserializeJavaObjectFromResponse(response);
+ return HttpHelper.deserializeJavaObjectFromStream(response);
} else {
return response;
}
}
- private static Object doDeserializeJavaObjectFromResponse(InputStream
response) throws ClassNotFoundException, IOException {
- if (response == null) {
- LOG.debug("Cannot deserialize response body as java object as
there are no response body.");
- return null;
- }
-
- Object answer = null;
- ObjectInputStream ois = new ObjectInputStream(response);
- try {
- answer = ois.readObject();
- } finally {
- IOHelper.close(ois);
- }
-
- return answer;
- }
-
-
private static InputStream doExtractResponseBodyAsStream(InputStream is,
Exchange exchange) throws IOException {
// As httpclient is using a AutoCloseInputStream, it will be closed
when the connection is closed
// we need to cache the stream for it.
@@ -282,16 +267,14 @@ public class HttpProducer extends Defaul
* @param exchange the exchange
* @return the created method as either GET or POST
* @throws URISyntaxException is thrown if the URI is invalid
- * @throws org.apache.camel.InvalidPayloadException
- * is thrown if message body cannot
- * be converted to a type supported by
HttpClient
+ * @throws CamelExchangeException is thrown if error creating RequestEntity
*/
- protected HttpRequestBase createMethod(Exchange exchange) throws
URISyntaxException, InvalidPayloadException {
- String url = HttpProducerHelper.createURL(exchange, getEndpoint());
+ protected HttpRequestBase createMethod(Exchange exchange) throws
URISyntaxException, CamelExchangeException {
+ String url = HttpHelper.createURL(exchange, getEndpoint());
URI uri = new URI(url);
HttpEntity requestEntity = createRequestEntity(exchange);
- HttpMethods methodToUse = HttpProducerHelper.createMethod(exchange,
getEndpoint(), requestEntity != null);
+ HttpMethods methodToUse = HttpHelper.createMethod(exchange,
getEndpoint(), requestEntity != null);
// is a query string provided in the endpoint URI or in a header
(header overrules endpoint)
String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY,
String.class);
@@ -333,11 +316,9 @@ public class HttpProducer extends Defaul
*
* @param exchange the exchange with the IN message with data to send
* @return the data holder
- * @throws org.apache.camel.InvalidPayloadException
- * is thrown if message body cannot
- * be converted to a type supported by HttpClient
+ * @throws CamelExchangeException is thrown if error creating RequestEntity
*/
- protected HttpEntity createRequestEntity(Exchange exchange) throws
InvalidPayloadException {
+ protected HttpEntity createRequestEntity(Exchange exchange) throws
CamelExchangeException {
Message in = exchange.getIn();
if (in.getBody() == null) {
return null;
@@ -350,8 +331,18 @@ public class HttpProducer extends Defaul
if (data != null) {
String contentType =
ExchangeHelper.getContentType(exchange);
- // file based (could potentially also be a FTP file etc)
- if (data instanceof File || data instanceof GenericFile) {
+ if (contentType != null &&
HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) {
+ // serialized java object
+ Serializable obj =
in.getMandatoryBody(Serializable.class);
+ // write object to output stream
+ ByteArrayOutputStream bos = new
ByteArrayOutputStream();
+ HttpHelper.writeObjectToStream(bos, obj);
+ ByteArrayEntity entity = new
ByteArrayEntity(bos.toByteArray());
+
entity.setContentType(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
+ IOHelper.close(bos);
+ answer = entity;
+ } else if (data instanceof File || data instanceof
GenericFile) {
+ // file based (could potentially also be a FTP file
etc)
File file = in.getBody(File.class);
if (file != null) {
answer = new FileEntity(file, contentType);
@@ -362,24 +353,24 @@ public class HttpProducer extends Defaul
// do not fallback to use the default charset as it
can influence the request
// (for example application/x-www-form-urlencoded
forms being sent)
String charset = IOConverter.getCharsetName(exchange,
false);
- answer = new StringEntity((String) data, charset);
- if (contentType != null) {
- ((StringEntity)
answer).setContentType(contentType);
- }
+ StringEntity entity = new StringEntity((String) data,
charset);
+ entity.setContentType(contentType);
+ answer = entity;
}
// fallback as input stream
if (answer == null) {
// force the body as an input stream since this is the
fallback
- in.getMandatoryBody(InputStream.class);
- answer = new
InputStreamEntity(in.getBody(InputStream.class), -1);
- if (contentType != null) {
- ((InputStreamEntity)
answer).setContentType(contentType);
- }
+ InputStream is =
in.getMandatoryBody(InputStream.class);
+ InputStreamEntity entity = new InputStreamEntity(is,
-1);
+ entity.setContentType(contentType);
+ answer = entity;
}
}
} catch (UnsupportedEncodingException e) {
- throw new RuntimeCamelException(e);
+ throw new CamelExchangeException("Error creating RequestEntity
from message body", exchange, e);
+ } catch (IOException e) {
+ throw new CamelExchangeException("Error serializing message
body", exchange, e);
}
}
return answer;
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java?rev=1053671&r1=1053670&r2=1053671&view=diff
==============================================================================
---
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
(original)
+++
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
Wed Dec 29 16:40:56 2010
@@ -22,7 +22,7 @@ import javax.activation.FileDataSource;
import javax.activation.FileTypeMap;
public class CamelFileDataSource extends FileDataSource {
- private String fileName;
+ private final String fileName;
private FileTypeMap typeMap;
public CamelFileDataSource(File file, String fileName) {
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/GZIPHelper.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/GZIPHelper.java?rev=1053671&r1=1053670&r2=1053671&view=diff
==============================================================================
---
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/GZIPHelper.java
(original)
+++
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/GZIPHelper.java
Wed Dec 29 16:40:56 2010
@@ -53,8 +53,8 @@ public final class GZIPHelper {
gzip.finish();
return new ByteArrayInputStream(os.toByteArray());
} finally {
- IOHelper.close(gzip, "gzip", null);
- IOHelper.close(os, "byte array output stream", null);
+ IOHelper.close(gzip, "gzip");
+ IOHelper.close(os, "byte array output stream");
}
} else {
return in;
@@ -73,8 +73,8 @@ public final class GZIPHelper {
gzip.finish();
return new ByteArrayInputStream(os.toByteArray());
} finally {
- IOHelper.close(gzip, "gzip", null);
- IOHelper.close(os, "byte array", null);
+ IOHelper.close(gzip, "gzip");
+ IOHelper.close(os, "byte array output stream");
}
} else {
return new ByteArrayInputStream(data);
@@ -89,8 +89,8 @@ public final class GZIPHelper {
gzip.finish();
return os.toByteArray();
} finally {
- gzip.close();
- os.close();
+ IOHelper.close(gzip, "gzip");
+ IOHelper.close(os, "byte array output stream");
}
}
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java?rev=1053671&r1=1053670&r2=1053671&view=diff
==============================================================================
---
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
(original)
+++
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
Wed Dec 29 16:40:56 2010
@@ -18,16 +18,24 @@ package org.apache.camel.component.http4
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.URI;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.http4.HttpConstants;
import org.apache.camel.component.http4.HttpConverter;
+import org.apache.camel.component.http4.HttpEndpoint;
+import org.apache.camel.component.http4.HttpMethods;
import org.apache.camel.converter.IOConverter;
import org.apache.camel.converter.stream.CachedOutputStream;
import org.apache.camel.util.IOHelper;
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolException;
public final class HttpHelper {
@@ -58,12 +66,48 @@ public final class HttpHelper {
public static void writeObjectToServletResponse(ServletResponse response,
Object target) throws IOException {
response.setContentType(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
ObjectOutputStream oos = new
ObjectOutputStream(response.getOutputStream());
+ writeObjectToStream(response.getOutputStream(), target);
+ }
+
+ /**
+ * Writes the given object as response body to the output stream
+ *
+ * @param stream output stream
+ * @param target object to write
+ * @throws IOException is thrown if error writing
+ */
+ public static void writeObjectToStream(OutputStream stream, Object target)
throws IOException {
+ ObjectOutputStream oos = new ObjectOutputStream(stream);
oos.writeObject(target);
oos.flush();
IOHelper.close(oos);
}
/**
+ * Deserializes the input stream to a Java object
+ *
+ * @param is input stream for the Java object
+ * @return the java object, or <tt>null</tt> if input stream was
<tt>null</tt>
+ * @throws ClassNotFoundException is thrown if class not found
+ * @throws IOException can be thrown
+ */
+ public static Object deserializeJavaObjectFromStream(InputStream is)
throws ClassNotFoundException, IOException {
+ if (is == null) {
+ return null;
+ }
+
+ Object answer = null;
+ ObjectInputStream ois = new ObjectInputStream(is);
+ try {
+ answer = ois.readObject();
+ } finally {
+ IOHelper.close(ois);
+ }
+
+ return answer;
+ }
+
+ /**
* Reads the response body from the given http servlet request.
*
* @param request http servlet request
@@ -99,4 +143,123 @@ public final class HttpHelper {
}
}
+ /**
+ * Creates the URL to invoke.
+ *
+ * @param exchange the exchange
+ * @param endpoint the endpoint
+ * @return the URL to invoke
+ */
+ public static String createURL(Exchange exchange, HttpEndpoint endpoint) {
+ String uri = null;
+ if (!(endpoint.isBridgeEndpoint())) {
+ uri = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
+ }
+ if (uri == null) {
+ uri = endpoint.getHttpUri().toASCIIString();
+ }
+
+ // append HTTP_PATH to HTTP_URI if it is provided in the header
+ String path = exchange.getIn().getHeader(Exchange.HTTP_PATH,
String.class);
+ if (path != null) {
+ if (path.startsWith("/")) {
+ URI baseURI;
+ String baseURIString =
exchange.getIn().getHeader(Exchange.HTTP_BASE_URI, String.class);
+ try {
+ if (baseURIString == null) {
+ if (exchange.getFromEndpoint() != null) {
+ baseURIString =
exchange.getFromEndpoint().getEndpointUri();
+ } else {
+ // will set a default one for it
+ baseURIString = "/";
+ }
+ }
+ baseURI = new URI(baseURIString);
+ String basePath = baseURI.getRawPath();
+ if (path.startsWith(basePath)) {
+ path = path.substring(basePath.length());
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+ } else {
+ throw new RuntimeCamelException("Cannot analyze the
Exchange.HTTP_PATH header, due to: cannot find the right HTTP_BASE_URI");
+ }
+ } catch (Throwable t) {
+ throw new RuntimeCamelException("Cannot analyze the
Exchange.HTTP_PATH header, due to: "
+ + t.getMessage(), t);
+ }
+
+ }
+ if (path.length() > 0) {
+ // make sure that there is exactly one "/" between HTTP_URI and
+ // HTTP_PATH
+ if (!uri.endsWith("/")) {
+ uri = uri + "/";
+ }
+ uri = uri.concat(path);
+ }
+ }
+ return uri;
+ }
+
+ /**
+ * Creates the HttpMethod to use to call the remote server, often either
its GET or POST.
+ *
+ * @param exchange the exchange
+ * @return the created method
+ */
+ public static HttpMethods createMethod(Exchange exchange, HttpEndpoint
endpoint, boolean hasPayload) {
+ // is a query string provided in the endpoint URI or in a header
(header
+ // overrules endpoint)
+ String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY,
String.class);
+ if (queryString == null) {
+ queryString = endpoint.getHttpUri().getRawQuery();
+ }
+
+ // compute what method to use either GET or POST
+ HttpMethods answer;
+ HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD,
HttpMethods.class);
+ if (m != null) {
+ // always use what end-user provides in a header
+ answer = m;
+ } else if (queryString != null) {
+ // if a query string is provided then use GET
+ answer = HttpMethods.GET;
+ } else {
+ // fallback to POST if we have payload, otherwise GET
+ answer = hasPayload ? HttpMethods.POST : HttpMethods.GET;
+ }
+
+ return answer;
+ }
+
+ public static HttpVersion parserHttpVersion(String s) throws
ProtocolException {
+ int major;
+ int minor;
+ if (s == null) {
+ throw new IllegalArgumentException("String may not be null");
+ }
+ if (!s.startsWith("HTTP/")) {
+ throw new ProtocolException("Invalid HTTP version string: " + s);
+ }
+ int i1 = "HTTP/".length();
+ int i2 = s.indexOf(".", i1);
+ if (i2 == -1) {
+ throw new ProtocolException("Invalid HTTP version number: " + s);
+ }
+ try {
+ major = Integer.parseInt(s.substring(i1, i2));
+ } catch (NumberFormatException e) {
+ throw new ProtocolException("Invalid HTTP major version number: "
+ s);
+ }
+ i1 = i2 + 1;
+ i2 = s.length();
+ try {
+ minor = Integer.parseInt(s.substring(i1, i2));
+ } catch (NumberFormatException e) {
+ throw new ProtocolException("Invalid HTTP minor version number: "
+ s);
+ }
+ return new HttpVersion(major, minor);
+
+ }
}
Copied:
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
(from r1053350,
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpProducerHelperTest.java)
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java?p2=camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java&p1=camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpProducerHelperTest.java&r1=1053350&r2=1053671&rev=1053671&view=diff
==============================================================================
---
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpProducerHelperTest.java
(original)
+++
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
Wed Dec 29 16:40:56 2010
@@ -30,11 +30,11 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
-public class HttpProducerHelperTest {
+public class HttpHelperTest {
@Test
public void createURLShouldReturnTheHeaderURIIfNotBridgeEndpoint() throws
URISyntaxException {
- String url = HttpProducerHelper.createURL(
+ String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader("http://apache.org", null),
createHttpEndpoint(false, "http://camel.apache.org"));
@@ -43,7 +43,7 @@ public class HttpProducerHelperTest {
@Test
public void createURLShouldReturnTheEndpointURIIfBridgeEndpoint() throws
URISyntaxException {
- String url = HttpProducerHelper.createURL(
+ String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader("http://apache.org", null),
createHttpEndpoint(true, "http://camel.apache.org"));
@@ -52,7 +52,7 @@ public class HttpProducerHelperTest {
@Test
public void createURLShouldReturnTheEndpointURIIfNotBridgeEndpoint()
throws URISyntaxException {
- String url = HttpProducerHelper.createURL(
+ String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader(null, null),
createHttpEndpoint(false, "http://camel.apache.org"));
@@ -61,7 +61,7 @@ public class HttpProducerHelperTest {
@Test
public void
createURLShouldReturnTheEndpointURIWithHeaderHttpPathAndAddOneSlash() throws
URISyntaxException {
- String url = HttpProducerHelper.createURL(
+ String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader(null, "search"),
createHttpEndpoint(true, "http://www.google.com"));
@@ -70,7 +70,7 @@ public class HttpProducerHelperTest {
@Test
public void
createURLShouldReturnTheEndpointURIWithHeaderHttpPathAndRemoveOneSlash() throws
URISyntaxException {
- String url = HttpProducerHelper.createURL(
+ String url = HttpHelper.createURL(
createExchangeWithOptionalCamelHttpUriHeader(null, "/search"),
createHttpEndpoint(true, "http://www.google.com/"));
@@ -79,7 +79,7 @@ public class HttpProducerHelperTest {
@Test
public void createMethodAlwaysUseUserChoosenMethod() throws
URISyntaxException {
- HttpMethods method = HttpProducerHelper.createMethod(
+ HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel",
HttpMethods.POST),
createHttpEndpoint(true, "http://www.google.com/search"),
false);
@@ -89,7 +89,7 @@ public class HttpProducerHelperTest {
@Test
public void createMethodUseGETIfQueryIsProvidedInHeader() throws
URISyntaxException {
- HttpMethods method = HttpProducerHelper.createMethod(
+ HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", null),
createHttpEndpoint(true, "http://www.google.com/search"),
false);
@@ -99,7 +99,7 @@ public class HttpProducerHelperTest {
@Test
public void createMethodUseGETIfQueryIsProvidedInEndpointURI() throws
URISyntaxException {
- HttpMethods method = HttpProducerHelper.createMethod(
+ HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null,
null),
createHttpEndpoint(true,
"http://www.google.com/search?q=test"),
false);
@@ -109,7 +109,7 @@ public class HttpProducerHelperTest {
@Test
public void createMethodUseGETIfNoneQueryOrPayloadIsProvided() throws
URISyntaxException {
- HttpMethods method = HttpProducerHelper.createMethod(
+ HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null,
null),
createHttpEndpoint(true, "http://www.google.com/search"),
false);
@@ -119,7 +119,7 @@ public class HttpProducerHelperTest {
@Test
public void createMethodUsePOSTIfNoneQueryButPayloadIsProvided() throws
URISyntaxException {
- HttpMethods method = HttpProducerHelper.createMethod(
+ HttpMethods method = HttpHelper.createMethod(
createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null,
null),
createHttpEndpoint(true, "http://www.google.com/search"),
true);
Propchange:
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date