BAEL-5234 - Apache Camel Routes Testing in Spring Boot (#11925)
* BAEL-4706 - Spring Boot with Spring Batch * BAEL-3948 - Fix test(s) in spring-batch which leaves repository.sqlite changed * BAEL-4736 - Convert JSONArray to List of Object using camel-jackson * BAEL-4756 - Mockito MockSettings * BAEL-4756 - Mockito MockSettings - fix spelling * BAEL-2674 - Upgrade the Okhttp article * BAEL-4204 - Adding Interceptors in OkHTTP * BAEL-4836 - Mocking Static Methods with Mockito * BAEL-4205 - A Guide to Events in OkHTTP * BAEL-5408 - Update Camel version in spring-boot-camel module * BAEL-5234 - Apache Camel Routes Testing in Spring Boot * BAEL-5234 - Apache Camel Routes Testing in Spring Boot Co-authored-by: Jonathan Cook <jcook@sciops.esa.int>
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.camel.boot.testing;
|
||||
|
||||
import org.apache.camel.EndpointInject;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import org.apache.camel.component.mock.MockEndpoint;
|
||||
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
||||
import org.apache.camel.test.spring.junit5.MockEndpoints;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
@CamelSpringBootTest
|
||||
@MockEndpoints("file:output")
|
||||
class GreetingsFileRouterUnitTest {
|
||||
|
||||
@Autowired
|
||||
private ProducerTemplate template;
|
||||
|
||||
@EndpointInject("mock:file:output")
|
||||
private MockEndpoint mock;
|
||||
|
||||
@Test
|
||||
void whenSendBody_thenGreetingReceivedSuccessfully() throws InterruptedException {
|
||||
mock.expectedBodiesReceived("Hello Baeldung Readers!");
|
||||
|
||||
template.sendBody("direct:start", null);
|
||||
|
||||
mock.assertIsSatisfied();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user