[[test-other]]
= Test Component
//THIS FILE IS COPIED: EDIT THE SOURCE FILE:
:page-source: components/camel-test/src/main/docs/test.adoc
:docTitle: Test
:artifactId: camel-test
:description: Camel unit testing
:since: 2.9
:supportLevel: Stable
include::{cq-version}@camel-quarkus:ROOT:partial$reference/others/test.adoc[opts=optional]

*Since Camel {since}*

The `camel-test` module is used for unit testing Camel.

The class `org.apache.camel.test.junit4.CamelTestSupport` provides a base JUnit class which you would extend
and implement your Camel unit test.

== Simple unit test example

As shown below is a basic junit test which uses `camel-test`. The `createRouteBuilder` method is used
for build the routes to be tested. Then the methods with `@Test` annotations are JUnit test methods which
will be executed. The base class `CamelTestSupport` has a number of helper methods to configure testing,
see more at the javadoc of this class.

[source,java]
----
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

public class SimpleMockTest extends CamelTestSupport {

    @Test
    public void testMock() throws Exception {
        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");

        template.sendBody("direct:start", "Hello World");

        assertMockEndpointsSatisfied();
    }

    @Override
    protected RoutesBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:start")
                        .to("mock:result");
            }
        };
    }

}
----
