我有一个汽车服务类:
public class CarService {
public Car getCar(){
Car car = new Car();
car.setBrand("hello");
car.setId("1");
return car;
}
}
wich i使用骆驼restds使用乘坐CDI注入的路由构造器中定义的骆驼retdsl。
。 restConfiguration().component("jetty")
.host("localhost")
.port("8889")
.bindingMode(RestBindingMode.json);
rest("/cars").get().route().bean(CarService.class, "getCar");
这是我的单位测试
@Test
public void restTest() throws Exception {
Main booter = new Main();
booter.start();
HttpResponse<JsonNode> carResponse =
Unirest.get("http://localhost:8889/cars").asJson();
String s = carResponse.getBody().toString();
assertEquals("{"id":"1","brand":"hello"}", s);
booter.stop();
}
main来自 org.apache.camel.cdi
我正在使用Unirest发送http请求(http://unirest.io/java.html)
运行单元测试时,它会通过,但是如果我在getCar()方法中放一个断点,则不会打破断点。
rmq:我还尝试了这样的生产板,例如So
List<CamelContext> contexts = ngbaMain.getCamelContexts();
FluentProducerTemplate fpt = DefaultFluentProducerTemplate.on(contexts.get(0));
Object result = fpt.to("jetty:http://localhost:8889/cars?httpMethodRestrict=GET")
.request(String.class);
,但它也没有起作用...
有人可以给我一些见解,我该怎么做?这可能...测试端点很棒...
update
我正在使用 Intellij 进行测试,如果我在以下行中击中F7:
HttpResponse<JsonNode> carResponse =
Unirest.get("http://localhost:8889/cars").asJson();
那是我进入(奇怪的是一个或两个F7的命中就足够了)我进入了我的汽车服务...所以也许这比骆驼或码头或..
正如我在问题更新中所说的那样,进入unirest类,然后恢复时,我可以点击断点。因此,这更多是一个与IDE相关的问题。