Test case for Camel Springboot application takes a longer build time

518 views Asked by At

I have written camel test case for my spring boot application as below.

@RunWith(CamelSpringRunner.class)
@SpringBootTest
@ActiveProfiles("test")
@ContextConfiguration(classes = Application.class)
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
@UseAdviceWith

public class CamelTestClass {

    @Autowired
    private CamelContext camelContext;
    private String routeID = "routeId";
    Logger log = Logger.getLogger(String.valueOf(CamelSpringBootApplication.class));


    @Test
    @DirtiesContext
    public void test1() throws Exception {
        ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class);
        RouteReifier.adviceWith(mcc.getRouteDefinition(routeID), mcc, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
               doSOmething
            }
        });
        mcc.start();
        assertion
        mcc.stop();
    }


    @Test
    @DirtiesContext
    public void test2() throws Exception {
        ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class);
        RouteReifier.adviceWith(mcc.getRouteDefinition(routeID), mcc, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
              doSomething
            }
        });
        mcc.start();
        assertion
        mcc.stop();
    }


    @Test
    @DirtiesContext
    public void test3() throws Exception {
        ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class);
        RouteReifier.adviceWith(mcc.getRouteDefinition(routeID), mcc, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                doSomething
            }
        });
        mcc.start();
        assertion
        mcc.stop();
    }
}

So there are 3 test cases written, On each beginning of the test case I had to start the camel context and clear it at the end. With this setup, On a maven build test tests are taking a long time to get it completed. with around 30 test cases, the build is taking 25 mins for completion. Is there a scope for optimization of test cases in terms of running time here?

0

There are 0 answers