package com.mycompany.fuse7hello;


import org.apache.camel.Header;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.language.Simple;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestParamType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Routes extends RouteBuilder {

    @Value("${my.greeting}")
    private String greeting;

    @Override
    public void configure() throws Exception {

        restConfiguration("servlet")
            .bindingMode(RestBindingMode.json)
            .apiContextPath("/swagger") //swagger endpoint path; Final URL: Camel path + apiContextPath: /api/swagger
            .apiContextRouteId("swagger")

            .contextPath("/api")
            .apiProperty("api.title", "Example REST api")
            .apiProperty("api.version", "1.0")
            .apiProperty("host","")
        ;

        from("timer:myTimer?period=2000&repeatCount=3")
            .log("Hello World!");

        rest()
            .get("hello")
                .route()
                .setBody().body(()->new HelloResponse(greeting+" World!"))
                .removeHeaders("*")
                .endRest()
            //"name" is an Exchange header
            .get("hello/{name}")
                //swagger
                .description("Hello with name")
                .param().name("name").type(RestParamType.path).description("Name of the user").required(true).dataType("string").endParam()
                .responseMessage().code(200).responseModel(HelloResponse.class).endResponseMessage() //OK

                .route()
                .setBody(method(this,"setHelloWithName"))
                .removeHeaders("*")
                .endRest()
        ;

    }

    //Get exchange header and add to response
    public HelloResponse setHelloWithName(@Simple("${properties:my.greeting} ${header.name}!") String message){
        return new HelloResponse(message);
    }
}

@@ -29,16 +29,171 @@
 ello;%0A%0A%0A
+import java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.TimeUnit;%0Aimport java.util.stream.Stream;%0A%0A
 import o
@@ -1962,225 +1962,2073 @@
 t()%0A
-        ;%0A%0A    %7D%0A%0A    //Get exchange header and add to response%0A    public HelloResponse setHelloWithName(@Simple(%22$%7Bproperties:my.greeting%7D $%7Bheader.name%7D!%22) String message)%7B%0A        return new HelloResponse(message)
+%0A            //Some additional APIs to test memory heavy or cpu intensive workloads%0A            .get(%22memory/%7Bmb%7D%22)%0A                .route()%0A                .setBody().method(this,%22createObject%22)%0A                .endRest()%0A            .get(%22cpu/%7Biteration%7D%22)%0A                .route()%0A                .setBody().method(this,%22cpuLoad%22)%0A                .endRest()%0A            .get(%22threads/%7Bthreads%7D/cpu/%7Biteration%7D%22)%0A                .route()%0A                .setBody().method(this,%22multiThreadCpuLoad%22)%0A                .endRest()%0A        ;%0A%0A    %7D%0A%0A    //Get exchange header and add to response%0A    public HelloResponse setHelloWithName(@Simple(%22$%7Bproperties:my.greeting%7D $%7Bheader.name%7D!%22) String message)%7B%0A        return new HelloResponse(message);%0A    %7D%0A%0A    //Create a big object on heap%0A    public Integer createObject(@Header(%22mb%22) Integer mb)%7B%0A        byte%5B%5D one = new byte%5Bmb*1024*1024%5D;%0A        return mb;%0A    %7D%0A%0A    //Do some cpu intensive calculation%0A    public Long cpuLoad(@Header(%22iteration%22) Long iteration)%7B%0A        double response =0.5;%0A        long start = System.currentTimeMillis();%0A        for (long i=0; i%3Citeration;i++)%7B%0A            response = i%252==0 ? Math.pow(response,2.0) : Math.sqrt(response);%0A            if (i%25(iteration/10) == 0) log.info(%22Iteration: %7B%7D%22,i);%0A        %7D%0A        long time = System.currentTimeMillis()-start;%0A        log.info(%22Time %7B%7D: %7B%7D%22,iteration,time);%0A        return time;%0A    %7D%0A%0A    //Run cpu intensive tasks on multiple threads%0A    public Long multiThreadCpuLoad(@Header(%22threads%22) int threads, @Header(%22iteration%22) Long iteration) throws InterruptedException%7B%0A        ExecutorService executor = Executors.newFixedThreadPool(threads);%0A        long start = System.currentTimeMillis();%0A        for (int i=0; i%3Cthreads; i++) %7B%0A            executor.submit(()-%3Ethis.cpuLoad(iteration));%0A        %7D%0A        executor.shutdown();%0A        executor.awaitTermination(20, TimeUnit.MINUTES);%0A%0A        long time = System.currentTimeMillis()-start;%0A        log.info(%22Total time %7B%7D/%7B%7D: %7B%7D%22,threads,iteration,time);%0A        return time
 ;%0A  

Add memory/cpu test apis