intellij-ideaapache-cameljettyunirest

is it possible to debug camel rest dsl component with jetty and unirest


I have a CarService Class:

    public class CarService {
    
        public Car getCar(){
            Car car = new Car();
            car.setBrand("hello");
            car.setId("1");
            return car;
        }
    }

which I expose through a jetty endpoint using camel restdsl defined in a RouteBuilder that is injected through CDI.

     restConfiguration().component("jetty")
                    .host("localhost")
                    .port("8889")
                    .bindingMode(RestBindingMode.json);

 rest("/cars").get().route().bean(CarService.class, "getCar");

This is my Unit Test

     @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 is from org.apache.camel.cdi

and I am using uniRest to send the HTTP request (http://unirest.io/java.html)

when running the unit test, it pass, but if I put a breakpoint in the getCar() method, the breakpoint is not hit.

rmq: I also tried with producerTemplate like 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);

but it didn't work either...

Could someone give me some insights how I could do this? Is this possible... It would be great to test endpoints...

UPDATE

I am testing with IntelliJ, and if I hit F7 on the following line:

     HttpResponse<JsonNode> carResponse =
                    Unirest.get("http://localhost:8889/cars").asJson();

that is I step into (strangely just one or two F7 hits is enough) I get in my CarService... so perhaps it's more an IntelliJ thing than camel or jetty or....


Solution

  • As I stated in my question UPDATE, when stepping into a unirest class and then resume, I can hit the breakpoint. so it's more an IDE related problem.