Author: cschneider
Date: Wed Jun 15 08:52:19 2011
New Revision: 1135963
URL: http://svn.apache.org/viewvc?rev=1135963&view=rev
Log:
Making ports for test dynamic and resolve some warnings
Modified:
camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiUriTemplatesEndpointTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletPostContentTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGet2Test.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetResponseCodeTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletQueryTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRecipientListTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRequestAndResponseAPITest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletThrowExceptionOnFailureTest.java
Modified:
camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
(original)
+++
camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
Wed Jun 15 08:52:19 2011
@@ -202,7 +202,7 @@ public class DefaultRestletBinding imple
Object body = out.getBody();
if (body instanceof GenericFile) {
// grab body from generic file holder
- GenericFile gf = (GenericFile) body;
+ GenericFile<?> gf = (GenericFile<?>) body;
body = gf.getBody();
}
Modified:
camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
(original)
+++
camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
Wed Jun 15 08:52:19 2011
@@ -50,7 +50,7 @@ public class RestletComponent extends He
private final Component component = new Component();
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "rawtypes"})
protected Endpoint createEndpoint(String uri, String remaining, Map
parameters) throws Exception {
RestletEndpoint result = new RestletEndpoint(this, remaining);
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletExceptionResponseTest.java
Wed Jun 15 08:52:19 2011
@@ -36,7 +36,7 @@ public class RestletExceptionResponseTes
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("restlet:http://localhost:9080/users/{username}?restletMethod=POST").process(new
Processor() {
+ from("restlet:http://localhost:" + portNum +
"/users/{username}?restletMethod=POST").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setException(new
IllegalArgumentException("Damn something went wrong"));
}
@@ -47,7 +47,7 @@ public class RestletExceptionResponseTes
@Test
public void testExceptionResponse() throws Exception {
- HttpResponse response = doExecute(new
HttpPost("http://localhost:9080/users/homer"));
+ HttpResponse response = doExecute(new HttpPost("http://localhost:" +
portNum + "/users/homer"));
String body = EntityUtils.toString(response.getEntity());
assertHttpResponse(response, 500, "text/plain");
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
Wed Jun 15 08:52:19 2011
@@ -33,14 +33,14 @@ public class RestletMultiMethodsEndpoint
@Test
public void testPostMethod() throws Exception {
- HttpResponse response = doExecute(new
HttpPost("http://localhost:9080/users/homer"));
+ HttpResponse response = doExecute(new HttpPost("http://localhost:" +
portNum + "/users/homer"));
assertHttpResponse(response, 200, "text/plain", "POST");
}
@Test
public void testGetMethod() throws Exception {
- HttpResponse response = doExecute(new
HttpGet("http://localhost:9080/users/homer"));
+ HttpResponse response = doExecute(new HttpGet("http://localhost:" +
portNum + "/users/homer"));
assertHttpResponse(response, 200, "text/plain", "GET");
}
@@ -50,7 +50,7 @@ public class RestletMultiMethodsEndpoint
@Override
public void configure() throws Exception {
// START SNIPPET: routeDefinition
-
from("restlet:http://localhost:9080/users/{username}?restletMethods=post,get")
+ from("restlet:http://localhost:" + portNum +
"/users/{username}?restletMethods=post,get")
.process(new Processor() {
public void process(Exchange exchange) throws
Exception {
// echo the method
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiUriTemplatesEndpointTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiUriTemplatesEndpointTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiUriTemplatesEndpointTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiUriTemplatesEndpointTest.java
Wed Jun 15 08:52:19 2011
@@ -48,14 +48,14 @@ public class RestletMultiUriTemplatesEnd
@Test
public void testPostUserUriPattern() throws Exception {
- HttpResponse response = doExecute(new
HttpPost("http://localhost:9080/users/homer"));
+ HttpResponse response = doExecute(new HttpPost("http://localhost:" +
portNum + "/users/homer"));
assertHttpResponse(response, 200, "text/plain", "POST homer");
}
@Test
public void testGetAtomUriPattern() throws Exception {
- HttpResponse response = doExecute(new
HttpGet("http://localhost:9080/atom/collection/foo/component/bar"));
+ HttpResponse response = doExecute(new HttpGet("http://localhost:" +
portNum + "/atom/collection/foo/component/bar"));
assertHttpResponse(response, 200, "text/plain", "GET foo bar");
}
@@ -66,15 +66,15 @@ public class RestletMultiUriTemplatesEnd
@Override
public void configure() throws Exception {
// START SNIPPET: routeDefinition
-
from("restlet:http://localhost:9080?restletMethods=post,get&restletUriPatterns=#uriTemplates")
+ from("restlet:http://localhost:" + portNum +
"?restletMethods=post,get&restletUriPatterns=#uriTemplates")
.process(new Processor() {
public void process(Exchange exchange) throws
Exception {
// echo the method
String uri =
exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
String out =
exchange.getIn().getHeader(Exchange.HTTP_METHOD, String.class);
- if
("http://localhost:9080/users/homer".equals(uri)) {
+ if (("http://localhost:" + portNum +
"/users/homer").equals(uri)) {
exchange.getOut().setBody(out + " " +
exchange.getIn().getHeader("username", String.class));
- } else if
("http://localhost:9080/atom/collection/foo/component/bar".equals(uri)) {
+ } else if (("http://localhost:" + portNum +
"/atom/collection/foo/component/bar").equals(uri)) {
exchange.getOut().setBody(out + " " +
exchange.getIn().getHeader("id", String.class)
+ " " +
exchange.getIn().getHeader("cid", String.class));
}
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletPostContentTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletPostContentTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletPostContentTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletPostContentTest.java
Wed Jun 15 08:52:19 2011
@@ -40,7 +40,7 @@ public class RestletPostContentTest exte
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("restlet:http://localhost:9080/users/{username}?restletMethod=POST")
+ from("restlet:http://localhost:" + portNum +
"/users/{username}?restletMethod=POST")
.process(new SetUserProcessor());
}
};
@@ -54,7 +54,7 @@ public class RestletPostContentTest exte
@Test
public void testPostBody() throws Exception {
- HttpUriRequest method = new
HttpPost("http://localhost:9080/users/homer");
+ HttpUriRequest method = new HttpPost("http://localhost:" + portNum +
"/users/homer");
((HttpEntityEnclosingRequestBase)method).setEntity(new
StringEntity(MSG_BODY));
HttpResponse response = doExecute(method);
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
Wed Jun 15 08:52:19 2011
@@ -29,7 +29,6 @@ import java.util.concurrent.Future;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
@@ -37,7 +36,7 @@ import org.junit.Test;
*
* @version
*/
-public class RestletProducerConcurrentTest extends CamelTestSupport {
+public class RestletProducerConcurrentTest extends RestletTestSupport {
@Test
public void testNoConcurrentProducers() throws Exception {
@@ -53,16 +52,16 @@ public class RestletProducerConcurrentTe
getMockEndpoint("mock:result").expectedMessageCount(files);
ExecutorService executor = Executors.newFixedThreadPool(poolSize);
- Map<Integer, Future> responses = new ConcurrentHashMap<Integer,
Future>();
+ Map<Integer, Future<?>> responses = new ConcurrentHashMap<Integer,
Future<?>>();
for (int i = 0; i < files; i++) {
final int index = i;
- Future out = executor.submit(new Callable<Object>() {
+ Future<?> out = executor.submit(new Callable<Object>() {
public Object call() throws Exception {
Map<String, Object> headers = new HashMap<String,
Object>();
headers.put("username", "davsclaus");
headers.put("id", index);
return template
-
.requestBodyAndHeaders("restlet:http://localhost:9080/users/davsclaus/" + index
+ "?restletMethod=GET",
+ .requestBodyAndHeaders("restlet:http://localhost:" +
portNum + "/users/davsclaus/" + index + "?restletMethod=GET",
null, headers, String.class);
}
});
@@ -74,7 +73,7 @@ public class RestletProducerConcurrentTe
// get all responses
Set<Object> unique = new HashSet<Object>();
- for (Future future : responses.values()) {
+ for (Future<?> future : responses.values()) {
unique.add(future.get());
}
@@ -88,7 +87,7 @@ public class RestletProducerConcurrentTe
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("restlet:http://localhost:9080/users/{username}/{id}?restletMethod=GET")
+ from("restlet:http://localhost:" + portNum +
"/users/{username}/{id}?restletMethod=GET")
.to("log:inbox").process(new Processor() {
public void process(Exchange exchange) throws
Exception {
String index = exchange.getIn().getHeader("id",
String.class);
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGet2Test.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGet2Test.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGet2Test.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGet2Test.java
Wed Jun 15 08:52:19 2011
@@ -22,13 +22,12 @@ import java.util.Map;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
* @version
*/
-public class RestletProducerGet2Test extends CamelTestSupport {
+public class RestletProducerGet2Test extends RestletTestSupport {
@Test
public void testRestletProducerGet2() throws Exception {
@@ -45,9 +44,9 @@ public class RestletProducerGet2Test ext
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("direct:start").to("restlet:http://localhost:9080/users/{id}/like/{beverage.beer}");
+ from("direct:start").to("restlet:http://localhost:" + portNum
+ "/users/{id}/like/{beverage.beer}");
- from("restlet:http://localhost:9080/users/{id}/like/{beer}")
+ from("restlet:http://localhost:" + portNum +
"/users/{id}/like/{beer}")
.process(new Processor() {
public void process(Exchange exchange) throws
Exception {
String id = exchange.getIn().getHeader("id",
String.class);
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetResponseCodeTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetResponseCodeTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetResponseCodeTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetResponseCodeTest.java
Wed Jun 15 08:52:19 2011
@@ -19,13 +19,12 @@ package org.apache.camel.component.restl
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
* @version
*/
-public class RestletProducerGetResponseCodeTest extends CamelTestSupport {
+public class RestletProducerGetResponseCodeTest extends RestletTestSupport {
@Test
public void testRestletProducerGet() throws Exception {
@@ -39,7 +38,7 @@ public class RestletProducerGetResponseC
@Override
public void configure() throws Exception {
from("direct:start")
- .to("restlet:http://localhost:9080/users/123/basic")
+ .to("restlet:http://localhost:" + portNum +
"/users/123/basic")
.process(new Processor() {
public void process(Exchange exchange) throws
Exception {
assertEquals(200,
exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE));
@@ -47,7 +46,7 @@ public class RestletProducerGetResponseC
}
});
- from("restlet:http://localhost:9080/users/{id}/basic")
+ from("restlet:http://localhost:" + portNum +
"/users/{id}/basic")
.process(new Processor() {
public void process(Exchange exchange) throws
Exception {
String id = exchange.getIn().getHeader("id",
String.class);
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerGetTest.java
Wed Jun 15 08:52:19 2011
@@ -19,13 +19,12 @@ package org.apache.camel.component.restl
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
* @version
*/
-public class RestletProducerGetTest extends CamelTestSupport {
+public class RestletProducerGetTest extends RestletTestSupport {
@Test
public void testRestletProducerGet() throws Exception {
@@ -38,9 +37,9 @@ public class RestletProducerGetTest exte
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("direct:start").to("restlet:http://localhost:9080/users/123/basic").to("log:reply");
+ from("direct:start").to("restlet:http://localhost:" + portNum
+ "/users/123/basic").to("log:reply");
- from("restlet:http://localhost:9080/users/{id}/basic")
+ from("restlet:http://localhost:" + portNum +
"/users/{id}/basic")
.process(new Processor() {
public void process(Exchange exchange) throws
Exception {
String id = exchange.getIn().getHeader("id",
String.class);
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletQueryTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletQueryTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletQueryTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletQueryTest.java
Wed Jun 15 08:52:19 2011
@@ -35,10 +35,10 @@ public class RestletQueryTest extends Re
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("restlet:http://localhost:9080/users/{username}")
+ from("restlet:http://localhost:" + portNum +
"/users/{username}")
.process(new SetUserProcessor());
-
from("direct:start").to("restlet:http://localhost:9080/users/{username}");
+ from("direct:start").to("restlet:http://localhost:" + portNum
+ "/users/{username}");
}
};
@@ -54,7 +54,7 @@ public class RestletQueryTest extends Re
@Test
public void testPostBody() throws Exception {
- HttpResponse response = doExecute(new
HttpGet("http://localhost:9080/users/homer?" + QUERY_STRING));
+ HttpResponse response = doExecute(new HttpGet("http://localhost:" +
portNum + "/users/homer?" + QUERY_STRING));
assertHttpResponse(response, 200, "text/plain");
}
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRecipientListTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRecipientListTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRecipientListTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRecipientListTest.java
Wed Jun 15 08:52:19 2011
@@ -17,21 +17,20 @@
package org.apache.camel.component.restlet;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
* @version
*/
-public class RestletRecipientListTest extends CamelTestSupport {
+public class RestletRecipientListTest extends RestletTestSupport {
@Test
public void testRestlet() throws Exception {
getMockEndpoint("mock:oracle").expectedBodiesReceived("110");
getMockEndpoint("mock:apple").expectedBodiesReceived("150");
-
template.sendBody("restlet:http://0.0.0.0:9080/stock/ORCL?restletMethod=post",
"110");
-
template.sendBody("restlet:http://0.0.0.0:9080/stock/APPL?restletMethod=post",
"150");
+ template.sendBody("restlet:http://0.0.0.0:" + portNum +
"/stock/ORCL?restletMethod=post", "110");
+ template.sendBody("restlet:http://0.0.0.0:" + portNum +
"/stock/APPL?restletMethod=post", "150");
assertMockEndpointsSatisfied();
}
@@ -41,7 +40,7 @@ public class RestletRecipientListTest ex
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("restlet:http://0.0.0.0:9080/stock/{symbol}?restletMethods=post")
+ from("restlet:http://0.0.0.0:" + portNum +
"/stock/{symbol}?restletMethods=post")
.recipientList().simple("seda:${header.symbol}");
from("seda:ORCL").to("mock:oracle");
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRequestAndResponseAPITest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRequestAndResponseAPITest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRequestAndResponseAPITest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRequestAndResponseAPITest.java
Wed Jun 15 08:52:19 2011
@@ -22,7 +22,6 @@ import java.util.Map;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
import org.restlet.Request;
import org.restlet.Response;
@@ -35,7 +34,7 @@ import org.restlet.data.Status;
*
* @version
*/
-public class RestletRequestAndResponseAPITest extends CamelTestSupport {
+public class RestletRequestAndResponseAPITest extends RestletTestSupport {
@Test
public void testRestletProducer() throws Exception {
@@ -75,10 +74,10 @@ public class RestletRequestAndResponseAP
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("direct:start").to("restlet:http://localhost:9080/users/{id}/like/{beverage.beer}");
+ from("direct:start").to("restlet:http://localhost:" + portNum
+ "/users/{id}/like/{beverage.beer}");
// START SNIPPET: e1
- from("restlet:http://localhost:9080/users/{id}/like/{beer}")
+ from("restlet:http://localhost:" + portNum +
"/users/{id}/like/{beer}")
.process(new Processor() {
public void process(Exchange exchange) throws
Exception {
// the Restlet request should be available if
neeeded
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletResponseTest.java
Wed Jun 15 08:52:19 2011
@@ -39,7 +39,7 @@ public class RestletResponseTest extends
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("restlet:http://localhost:9080/users/{username}?restletMethod=POST").process(new
Processor() {
+ from("restlet:http://localhost:" + portNum +
"/users/{username}?restletMethod=POST").process(new Processor() {
public void process(Exchange exchange) throws Exception {
String userName =
exchange.getIn().getHeader("username", String.class);
assertNotNull("userName should not be null", userName);
@@ -54,7 +54,7 @@ public class RestletResponseTest extends
@Test
public void testCustomResponse() throws Exception {
- HttpResponse response = doExecute(new
HttpPost("http://localhost:9080/users/homer"));
+ HttpResponse response = doExecute(new HttpPost("http://localhost:" +
portNum + "/users/homer"));
assertHttpResponse(response, 417, "application/JSON");
}
@@ -63,7 +63,7 @@ public class RestletResponseTest extends
public void testRestletProducer() throws Exception {
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("username", "homer");
- String response =
(String)template.requestBodyAndHeaders("restlet:http://localhost:9080/users/{username}?restletMethod=POST",
"<request>message</request>", headers);
+ String response =
(String)template.requestBodyAndHeaders("restlet:http://localhost:" + portNum +
"/users/{username}?restletMethod=POST", "<request>message</request>", headers);
assertEquals("The response is wrong ", response, "{homer}");
}
}
\ No newline at end of file
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
Wed Jun 15 08:52:19 2011
@@ -22,7 +22,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
import org.restlet.Client;
import org.restlet.Request;
@@ -32,7 +31,7 @@ import org.restlet.data.Method;
import org.restlet.data.Protocol;
import org.restlet.data.Status;
-public class RestletRouteBuilderTest extends CamelTestSupport {
+public class RestletRouteBuilderTest extends RestletTestSupport {
private static final String ID = "89531";
private static final String JSON = "{\"document type\": \"JSON\"}";
@@ -44,10 +43,10 @@ public class RestletRouteBuilderTest ext
// Restlet producer to use POST method. The RestletMethod=post
will be stripped
// before request is sent.
from("direct:start").setHeader("id", constant(ID))
-
.to("restlet:http://localhost:9080/orders?restletMethod=post&foo=bar");
+ .to("restlet:http://localhost:" + portNum +
"/orders?restletMethod=post&foo=bar");
// Restlet consumer to handler POST method
-
from("restlet:http://localhost:9080/orders?restletMethod=post").process(new
Processor() {
+ from("restlet:http://localhost:" + portNum +
"/orders?restletMethod=post").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody(
"received [" +
exchange.getIn().getBody(String.class)
@@ -57,7 +56,7 @@ public class RestletRouteBuilderTest ext
});
// Restlet consumer to handler POST method
-
from("restlet:http://localhost:9080/ordersJSON?restletMethod=post").process(new
Processor() {
+ from("restlet:http://localhost:" + portNum +
"/ordersJSON?restletMethod=post").process(new Processor() {
public void process(Exchange exchange) throws Exception {
String body = exchange.getIn().getBody(String.class);
if (body.indexOf("{") == -1) {
@@ -68,7 +67,7 @@ public class RestletRouteBuilderTest ext
});
// Restlet consumer default to handle GET method
-
from("restlet:http://localhost:9080/orders/{id}/{x}").process(new Processor() {
+ from("restlet:http://localhost:" + portNum +
"/orders/{id}/{x}").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody(
"received GET request with id="
@@ -87,7 +86,7 @@ public class RestletRouteBuilderTest ext
assertEquals("received [<order foo='1'/>] as an order id = " + ID,
response);
response = (String)template.sendBodyAndHeader(
-
"restlet:http://localhost:9080/orders?restletMethod=post&foo=bar",
+ "restlet:http://localhost:" + portNum +
"/orders?restletMethod=post&foo=bar",
ExchangePattern.InOut,
"<order foo='1'/>", "id", "89531");
assertEquals("received [<order foo='1'/>] as an order id = " + ID,
response);
@@ -96,7 +95,7 @@ public class RestletRouteBuilderTest ext
@Test
public void testProducerJSON() throws IOException {
String response = (String)template.sendBodyAndHeader(
-
"restlet:http://localhost:9080/ordersJSON?restletMethod=post&foo=bar",
+ "restlet:http://localhost:" + portNum +
"/ordersJSON?restletMethod=post&foo=bar",
ExchangePattern.InOut,
JSON,
Exchange.CONTENT_TYPE,
@@ -110,7 +109,7 @@ public class RestletRouteBuilderTest ext
public void testProducerJSONFailure() throws IOException {
String response = (String)template.sendBodyAndHeader(
-
"restlet:http://localhost:9080/ordersJSON?restletMethod=post&foo=bar",
+ "restlet:http://localhost:" + portNum +
"/ordersJSON?restletMethod=post&foo=bar",
ExchangePattern.InOut,
"{'JSON'}",
Exchange.CONTENT_TYPE,
@@ -123,7 +122,7 @@ public class RestletRouteBuilderTest ext
public void testConsumer() throws IOException {
Client client = new Client(Protocol.HTTP);
Response response = client.handle(new Request(Method.GET,
- "http://localhost:9080/orders/99991/6"));
+ "http://localhost:" + portNum + "/orders/99991/6"));
assertEquals("received GET request with id=99991 and x=6",
response.getEntity().getText());
}
@@ -132,7 +131,7 @@ public class RestletRouteBuilderTest ext
public void testUnhandledConsumer() throws IOException {
Client client = new Client(Protocol.HTTP);
Response response = client.handle(new Request(Method.POST,
- "http://localhost:9080/orders/99991/6"));
+ "http://localhost:" + portNum + "/orders/99991/6"));
// expect error status as no Restlet consumer to handle POST method
assertEquals(Status.CLIENT_ERROR_NOT_FOUND, response.getStatus());
assertNotNull(response.getEntity().getText());
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
Wed Jun 15 08:52:19 2011
@@ -18,6 +18,7 @@ package org.apache.camel.component.restl
import java.io.IOException;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
@@ -26,13 +27,20 @@ import org.apache.http.client.methods.Ht
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
+import org.junit.BeforeClass;
/**
*
* @version
*/
public abstract class RestletTestSupport extends CamelTestSupport {
-
+ public static int portNum;
+
+ @BeforeClass
+ public static void initializePortNum() {
+ portNum = AvailablePortFinder.getNextAvailable();
+ }
+
public HttpResponse doExecute(HttpUriRequest method) throws Exception {
HttpClient client = new DefaultHttpClient();
try {
Modified:
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletThrowExceptionOnFailureTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletThrowExceptionOnFailureTest.java?rev=1135963&r1=1135962&r2=1135963&view=diff
==============================================================================
---
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletThrowExceptionOnFailureTest.java
(original)
+++
camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletThrowExceptionOnFailureTest.java
Wed Jun 15 08:52:19 2011
@@ -43,9 +43,9 @@ public class RestletThrowExceptionOnFail
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from("direct:start").to("restlet:http://localhost:9080/user/{id}/like/{beverage.beer}");
+ from("direct:start").to("restlet:http://localhost:" + portNum
+ "/user/{id}/like/{beverage.beer}");
-
from("restlet:http://localhost:9080/users/{id}/like/{beer}").process(new
Processor() {
+ from("restlet:http://localhost:" + portNum +
"/users/{id}/like/{beer}").process(new Processor() {
public void process(Exchange exchange) throws Exception {
String id = exchange.getIn().getHeader("id",
String.class);
String beer = exchange.getIn().getHeader("beer",
String.class);