Created
July 20, 2013 15:09
-
-
Save stibi/6045400 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.camel.Exchange; | |
import org.apache.camel.Processor; | |
import org.apache.camel.builder.RouteBuilder; | |
import org.apache.camel.test.AvailablePortFinder; | |
import org.apache.camel.test.junit4.CamelTestSupport; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.impl.client.DefaultHttpClient; | |
import org.junit.Test; | |
import java.io.IOException; | |
public class JaxrsTesting extends CamelTestSupport { | |
private static final String PORT_PATH = AvailablePortFinder.getNextAvailable() + "/CxfRsTesting"; | |
private static final String CXF_RS_ENDPOINT_URI = "cxfrs:http://localhost:" + PORT_PATH + | |
"/rest?resourceClasses=com.my.project.JaxrsTestingServiceResource" + | |
"&bindingStyle=SimpleConsumer"; | |
private HttpClient httpClient; | |
@Override | |
public void setUp() throws Exception { | |
super.setUp(); | |
httpClient = new DefaultHttpClient(); | |
} | |
@Override | |
public void tearDown() throws Exception { | |
super.tearDown(); | |
httpClient.getConnectionManager().shutdown(); | |
} | |
@Override | |
protected RouteBuilder createRouteBuilder() { | |
return new RouteBuilder() { | |
@Override | |
public void configure() throws Exception { | |
from(CXF_RS_ENDPOINT_URI) | |
.recipientList(simple("direct:${header.operationName}")); | |
from("direct:getFoo").process(new Processor() { | |
@Override | |
public void process(Exchange exchange) throws Exception { | |
exchange.getOut().setBody("Hello there!"); | |
} | |
}); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment