Este contenido no está disponible en el idioma seleccionado.
Chapter 55. Mock
Test routes and mediation rules using mocks.
55.1. What’s inside Copiar enlaceEnlace copiado en el portapapeles!
-
Mock component, URI syntax:
mock:name
Please refer to the above link for usage and configuration details.
55.2. Maven coordinates Copiar enlaceEnlace copiado en el portapapeles!
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mock</artifactId> </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mock</artifactId>
</dependency>
55.3. Usage Copiar enlaceEnlace copiado en el portapapeles!
To use camel-mock capabilities in tests it is required to get access to MockEndpoint instances.
CDI injection could be used for accessing instances (see Quarkus documentation). You can inject camelContext into test using @Inject
annotation. Camel context can be then used for obtaining mock endpoints. See the following example:
Route used for the example test:
55.4. Camel Quarkus limitations Copiar enlaceEnlace copiado en el portapapeles!
Injection of CDI beans (described in Usage) does not work in native mode.
In the native mode the test and the application under test are running in two different processes and it is not possible to share a mock bean between them (see Quarkus documentation).