JAVA-2420 Merge spring-apache-camel and spring-boot-camel modules (#13409)
* JAVA-2420 Merge spring-apache-camel and spring-boot-camel modules * JAVA-2420 Migrate spring-boot-camel to spring-apache camel * JAVA-2420 Update README.md file * JAVA-2420 Remove spring-boot-camel --------- Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
parent
09382f545e
commit
a04d35a6d8
|
@ -18,7 +18,6 @@
|
|||
<module>jgroups</module>
|
||||
<module>rabbitmq</module>
|
||||
<module>spring-amqp</module>
|
||||
<module>spring-apache-camel</module>
|
||||
<module>spring-jms</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
/src/test/destination-folder/*
|
||||
/src/test/destination-folder/*
|
||||
/output/
|
|
@ -4,17 +4,19 @@ This module contains articles about Spring with Apache Camel
|
|||
|
||||
### Relevant Articles
|
||||
|
||||
- [Apache Camel](http://camel.apache.org/)
|
||||
- [Enterprise Integration Patterns](http://www.enterpriseintegrationpatterns.com/patterns/messaging/toc.html)
|
||||
- [Introduction To Apache Camel](http://www.baeldung.com/apache-camel-intro)
|
||||
- [Integration Patterns With Apache Camel](http://www.baeldung.com/camel-integration-patterns)
|
||||
- [Using Apache Camel with Spring](http://www.baeldung.com/spring-apache-camel-tutorial)
|
||||
- [Unmarshalling a JSON Array Using camel-jackson](https://www.baeldung.com/java-camel-jackson-json-array)
|
||||
- [Apache Camel with Spring Boot](https://www.baeldung.com/apache-camel-spring-boot)
|
||||
- [Apache Camel Routes Testing in Spring Boot](https://www.baeldung.com/spring-boot-apache-camel-routes-testing)
|
||||
- [Apache Camel Conditional Routing](https://www.baeldung.com/spring-apache-camel-conditional-routing)
|
||||
- [Apache Camel Exception Handling](https://www.baeldung.com/java-apache-camel-exception-handling)
|
||||
|
||||
### Framework Versions:
|
||||
|
||||
- Spring 4.2.4
|
||||
- Apache Camel 2.16.1
|
||||
- Spring 5.3.25
|
||||
- Apache Camel 3.14.7
|
||||
|
||||
### Build and Run Application
|
||||
|
||||
|
|
|
@ -58,11 +58,67 @@
|
|||
<version>${env.camel.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-servlet-starter</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-jackson-starter</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-swagger-java-starter</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-spring-boot-starter</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-test-spring-junit5</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<env.camel.version>2.18.1</env.camel.version>
|
||||
<env.spring.version>4.3.4.RELEASE</env.spring.version>
|
||||
<env.camel.version>3.14.7</env.camel.version>
|
||||
<env.spring.version>5.3.25</env.spring.version>
|
||||
<camel.version>3.15.0</camel.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>spring-boot</id>
|
||||
<build>
|
||||
<defaultGoal>spring-boot:run</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<mainClass>com.baeldung.camel.boot.boot.testing.GreetingsFileSpringApplication</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.file;
|
||||
package com.baeldung.camel.apache.file;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.file;
|
||||
package com.baeldung.camel.apache.file;
|
||||
|
||||
import org.apache.camel.LoggingLevel;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.file;
|
||||
package com.baeldung.camel.apache.file;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.file;
|
||||
package com.baeldung.camel.apache.file;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.file;
|
||||
package com.baeldung.camel.apache.file;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.file;
|
||||
package com.baeldung.camel.apache.file;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.file;
|
||||
package com.baeldung.camel.apache.file;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.file.cfg;
|
||||
package com.baeldung.camel.apache.file.cfg;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -8,7 +8,7 @@ import org.apache.camel.spring.javaconfig.CamelConfiguration;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.baeldung.camel.file.ContentBasedFileRouter;
|
||||
import com.baeldung.camel.apache.file.ContentBasedFileRouter;
|
||||
|
||||
@Configuration
|
||||
public class ContentBasedFileRouterConfig extends CamelConfiguration {
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.jackson;
|
||||
package com.baeldung.camel.apache.jackson;
|
||||
|
||||
public class Fruit {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.jackson;
|
||||
package com.baeldung.camel.apache.jackson;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.main;
|
||||
package com.baeldung.camel.apache.main;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.processor;
|
||||
package com.baeldung.camel.apache.processor;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel;
|
||||
package com.baeldung.camel.boot;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@SpringBootApplication(exclude = { WebSocketServletAutoConfiguration.class, AopAutoConfiguration.class, OAuth2ResourceServerAutoConfiguration.class, EmbeddedWebServerFactoryCustomizerAutoConfiguration.class })
|
||||
@ComponentScan(basePackages = "com.baeldung.camel")
|
||||
@ComponentScan(basePackages = "com.baeldung.camel.boot")
|
||||
public class Application {
|
||||
|
||||
@Value("${server.port}")
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel;
|
||||
package com.baeldung.camel.boot;
|
||||
|
||||
/**
|
||||
* a Mock class to show how some other layer
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel;
|
||||
package com.baeldung.camel.boot;
|
||||
|
||||
public class MyBean {
|
||||
private Integer id;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.boot.testing;
|
||||
package com.baeldung.camel.boot.boot.testing;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.stereotype.Component;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.boot.testing;
|
||||
package com.baeldung.camel.boot.boot.testing;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.conditional;
|
||||
package com.baeldung.camel.boot.conditional;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.stereotype.Component;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.conditional;
|
||||
package com.baeldung.camel.boot.conditional;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.stereotype.Component;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.conditional;
|
||||
package com.baeldung.camel.boot.conditional;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.stereotype.Component;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.conditional;
|
||||
package com.baeldung.camel.boot.conditional;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.conditional;
|
||||
package com.baeldung.camel.boot.conditional;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.baeldung.camel.boot.exception;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.baeldung.camel.boot.exception;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.baeldung.camel.boot.exception;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.baeldung.camel.boot.exception;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.baeldung.camel.boot.exception;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.baeldung.camel.boot.exception;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
|
@ -4,7 +4,7 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="contentBasedFileRouter" class="com.baeldung.camel.file.ContentBasedFileRouter" />
|
||||
<bean id="contentBasedFileRouter" class="com.baeldung.camel.apache.file.ContentBasedFileRouter" />
|
||||
|
||||
<camelContext xmlns="http://camel.apache.org/schema/spring">
|
||||
<routeBuilder ref="contentBasedFileRouter" />
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="deadLetterChannelFileRouter" class="com.baeldung.camel.file.DeadLetterChannelFileRouter" />
|
||||
<bean id="deadLetterChannelFileRouter" class="com.baeldung.camel.apache.file.DeadLetterChannelFileRouter" />
|
||||
|
||||
<camelContext xmlns="http://camel.apache.org/schema/spring">
|
||||
<routeBuilder ref="deadLetterChannelFileRouter" />
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="messageTranslatorFileRouter" class="com.baeldung.camel.file.MessageTranslatorFileRouter" />
|
||||
<bean id="messageTranslatorFileRouter" class="com.baeldung.camel.apache.file.MessageTranslatorFileRouter" />
|
||||
|
||||
<camelContext xmlns="http://camel.apache.org/schema/spring">
|
||||
<routeBuilder ref="messageTranslatorFileRouter" />
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="multicastFileRouter" class="com.baeldung.camel.file.MulticastFileRouter" />
|
||||
<bean id="multicastFileRouter" class="com.baeldung.camel.apache.file.MulticastFileRouter" />
|
||||
|
||||
<camelContext xmlns="http://camel.apache.org/schema/spring">
|
||||
<routeBuilder ref="multicastFileRouter" />
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="splitterFileRouter" class="com.baeldung.camel.file.SplitterFileRouter" />
|
||||
<bean id="splitterFileRouter" class="com.baeldung.camel.apache.file.SplitterFileRouter" />
|
||||
|
||||
<camelContext xmlns="http://camel.apache.org/schema/spring">
|
||||
<routeBuilder ref="splitterFileRouter" />
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="fileRouter" class="com.baeldung.camel.file.FileRouter" />
|
||||
<bean id="fileProcessor" class="com.baeldung.camel.file.FileProcessor" />
|
||||
<bean id="fileRouter" class="com.baeldung.camel.apache.file.FileRouter" />
|
||||
<bean id="fileProcessor" class="com.baeldung.camel.apache.file.FileProcessor" />
|
||||
|
||||
<camelContext xmlns="http://camel.apache.org/schema/spring">
|
||||
<routeBuilder ref="fileRouter" />
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
|
||||
</camelContext>
|
||||
|
||||
<bean id="myFileProcessor" class="com.baeldung.camel.processor.FileProcessor" />
|
||||
<bean id="myFileProcessor" class="com.baeldung.camel.apache.processor.FileProcessor" />
|
||||
</beans>
|
|
@ -1,8 +1,8 @@
|
|||
package com.baeldung;
|
||||
package com.apache.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.camel.main.App;
|
||||
import com.baeldung.camel.apache.main.App;
|
||||
|
||||
public class SpringContextTest {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.jackson;
|
||||
package com.apache.baeldung.camel.jackson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -13,6 +13,8 @@ import org.apache.camel.component.mock.MockEndpoint;
|
|||
import org.apache.camel.test.junit4.CamelTestSupport;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.camel.apache.jackson.Fruit;
|
||||
|
||||
public class FruitArrayJacksonUnmarshalUnitTest extends CamelTestSupport {
|
||||
|
||||
@Test
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.camel.jackson;
|
||||
package com.apache.baeldung.camel.jackson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -13,6 +13,9 @@ import org.apache.camel.component.mock.MockEndpoint;
|
|||
import org.apache.camel.test.junit4.CamelTestSupport;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.camel.apache.jackson.Fruit;
|
||||
import com.baeldung.camel.apache.jackson.FruitList;
|
||||
|
||||
public class FruitListJacksonUnmarshalUnitTest extends CamelTestSupport {
|
||||
|
||||
@Test
|
|
@ -11,7 +11,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
|||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.baeldung.camel.file.cfg.ContentBasedFileRouterConfig;
|
||||
import com.baeldung.camel.apache.file.cfg.ContentBasedFileRouterConfig;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class ContentBasedFileRouterIntegrationTest {
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.baeldung.camel.file.FileProcessor;
|
||||
import com.baeldung.camel.apache.file.FileProcessor;
|
||||
|
||||
|
||||
public class FileProcessorIntegrationTest {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.apache.camel.main;
|
||||
|
||||
import com.baeldung.camel.main.App;
|
||||
import com.baeldung.camel.apache.main.App;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.camel.util.FileUtil;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.baeldung;
|
||||
package com.boot;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.camel.Application;
|
||||
import com.baeldung.camel.boot.Application;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Application.class)
|
|
@ -1,4 +1,6 @@
|
|||
package com.baeldung.camel.boot.testing;
|
||||
package com.boot.camel.boot.testing;
|
||||
|
||||
import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
|
||||
|
||||
import org.apache.camel.EndpointInject;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
|
@ -8,10 +10,14 @@ 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;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
@SpringBootTest
|
||||
import com.baeldung.camel.boot.Application;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@CamelSpringBootTest
|
||||
@MockEndpoints("file:output")
|
||||
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
|
||||
class GreetingsFileRouterUnitTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -21,6 +27,7 @@ class GreetingsFileRouterUnitTest {
|
|||
private MockEndpoint mock;
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
void whenSendBody_thenGreetingReceivedSuccessfully() throws InterruptedException {
|
||||
mock.expectedBodiesReceived("Hello Baeldung Readers!");
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
package com.baeldung.camel.conditional;
|
||||
package com.boot.camel.conditional;
|
||||
|
||||
import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
|
||||
|
||||
import org.apache.camel.EndpointInject;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
|
@ -7,9 +9,13 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
@SpringBootTest
|
||||
import com.baeldung.camel.boot.Application;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@CamelSpringBootTest
|
||||
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
|
||||
class ConditionalBeanRouterUnitTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -19,6 +25,7 @@ class ConditionalBeanRouterUnitTest {
|
|||
private MockEndpoint mock;
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
void whenSendBodyWithFruit_thenFavouriteHeaderReceivedSuccessfully() throws InterruptedException {
|
||||
mock.expectedHeaderReceived("favourite", "Apples");
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
package com.baeldung.camel.conditional;
|
||||
package com.boot.camel.conditional;
|
||||
|
||||
import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
|
||||
|
||||
import org.apache.camel.EndpointInject;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
|
@ -7,9 +9,13 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
@SpringBootTest
|
||||
import com.baeldung.camel.boot.Application;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@CamelSpringBootTest
|
||||
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
|
||||
class ConditionalBodyRouterUnitTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -19,6 +25,7 @@ class ConditionalBodyRouterUnitTest {
|
|||
private MockEndpoint mock;
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
void whenSendBodyWithBaeldung_thenGoodbyeMessageReceivedSuccessfully() throws InterruptedException {
|
||||
mock.expectedBodiesReceived("Goodbye, Baeldung!");
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
package com.baeldung.camel.conditional;
|
||||
package com.boot.camel.conditional;
|
||||
|
||||
import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
|
||||
|
||||
import org.apache.camel.EndpointInject;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
|
@ -7,9 +9,13 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
@SpringBootTest
|
||||
import com.baeldung.camel.boot.Application;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@CamelSpringBootTest
|
||||
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
|
||||
class ConditionalHeaderRouterUnitTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -19,6 +25,7 @@ class ConditionalHeaderRouterUnitTest {
|
|||
private MockEndpoint mock;
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
void whenSendBodyWithFruit_thenFavouriteHeaderReceivedSuccessfully() throws InterruptedException {
|
||||
mock.expectedHeaderReceived("favourite", "Banana");
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.boot.camel.exception;
|
||||
|
||||
import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
|
||||
|
||||
import org.apache.camel.EndpointInject;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
|
@ -7,9 +9,13 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
@SpringBootTest
|
||||
import com.baeldung.camel.boot.Application;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@CamelSpringBootTest
|
||||
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
|
||||
class ExceptionHandlingWithDoTryRouteUnitTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -19,6 +25,7 @@ class ExceptionHandlingWithDoTryRouteUnitTest {
|
|||
private MockEndpoint mock;
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
void whenSendHeaders_thenExceptionRaisedAndHandledSuccessfully() throws Exception {
|
||||
mock.expectedMessageCount(1);
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.boot.camel.exception;
|
||||
|
||||
import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
|
||||
|
||||
import org.apache.camel.EndpointInject;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
|
@ -7,9 +9,13 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
@SpringBootTest
|
||||
import com.baeldung.camel.boot.Application;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@CamelSpringBootTest
|
||||
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
|
||||
class ExceptionHandlingWithExceptionClauseRouteUnitTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -19,6 +25,7 @@ class ExceptionHandlingWithExceptionClauseRouteUnitTest {
|
|||
private MockEndpoint mock;
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
void whenSendHeaders_thenExceptionRaisedAndHandledSuccessfully() throws Exception {
|
||||
mock.expectedMessageCount(1);
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.boot.camel.exception;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
|
||||
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Exchange;
|
||||
|
@ -11,15 +12,20 @@ import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
@SpringBootTest
|
||||
import com.baeldung.camel.boot.Application;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@CamelSpringBootTest
|
||||
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
|
||||
class ExceptionThrowingRouteUnitTest {
|
||||
|
||||
@Autowired
|
||||
private ProducerTemplate template;
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
void whenSendBody_thenExceptionRaisedSuccessfully() {
|
||||
CamelContext context = template.getCamelContext();
|
||||
Exchange exchange = context.getEndpoint("direct:start-exception")
|
|
@ -1,9 +1,11 @@
|
|||
package com.baeldung.camel.exception;
|
||||
package com.boot.camel.exception;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.baeldung.camel.boot.exception.IllegalArgumentExceptionThrowingProcessor;
|
||||
|
||||
class IllegalArgumentExceptionThrowingProcessorUnitTest {
|
||||
|
||||
@Test
|
4
pom.xml
4
pom.xml
|
@ -939,7 +939,6 @@
|
|||
<module>quarkus-modules/quarkus-vs-springboot</module>
|
||||
<module>quarkus-modules/quarkus-jandex</module>
|
||||
<module>spring-boot-modules/spring-boot-cassandre</module>
|
||||
<module>spring-boot-modules/spring-boot-camel</module>
|
||||
<module>spring-boot-modules/spring-boot-3</module>
|
||||
<module>spring-boot-modules/spring-boot-3-native</module>
|
||||
<module>spring-boot-modules/spring-boot-3-observation</module>
|
||||
|
@ -1055,6 +1054,7 @@
|
|||
<module>tensorflow-java</module>
|
||||
<module>xstream</module>
|
||||
<module>webrtc</module>
|
||||
<module>messaging-modules/spring-apache-camel</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
@ -1148,7 +1148,6 @@
|
|||
<module>quarkus-modules/quarkus-vs-springboot</module>
|
||||
<module>quarkus-modules/quarkus-jandex</module>
|
||||
<module>spring-boot-modules/spring-boot-cassandre</module>
|
||||
<module>spring-boot-modules/spring-boot-camel</module>
|
||||
<module>spring-boot-modules/spring-boot-3</module>
|
||||
<module>spring-boot-modules/spring-boot-3-native</module>
|
||||
<module>spring-boot-modules/spring-boot-3-observation</module>
|
||||
|
@ -1267,6 +1266,7 @@
|
|||
<module>tensorflow-java</module>
|
||||
<module>xstream</module>
|
||||
<module>webrtc</module>
|
||||
<module>messaging-modules/spring-apache-camel</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
/output/
|
|
@ -1,30 +0,0 @@
|
|||
## Spring Boot Camel
|
||||
|
||||
This module contains articles about Spring Boot with Apache Camel
|
||||
|
||||
### Example for the Article on Camel API with SpringBoot
|
||||
|
||||
To start, run:
|
||||
|
||||
`mvn spring-boot:run`
|
||||
|
||||
Then, make a POST http request to:
|
||||
|
||||
`http://localhost:8080/camel/api/bean`
|
||||
|
||||
Include the HEADER: Content-Type: application/json,
|
||||
|
||||
and a BODY Payload like:
|
||||
|
||||
`{"id": 1,"name": "World"}`
|
||||
|
||||
We will get a return code of 201 and the response: `Hello, World` - if the transform() method from Application class is uncommented and the process() method is commented
|
||||
|
||||
or return code of 201 and the response: `{"id": 10,"name": "Hello, World"}` - if the transform() method from Application class is commented and the process() method is uncommented
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
- [Apache Camel with Spring Boot](https://www.baeldung.com/apache-camel-spring-boot)
|
||||
- [Apache Camel Routes Testing in Spring Boot](https://www.baeldung.com/spring-boot-apache-camel-routes-testing)
|
||||
- [Apache Camel Conditional Routing](https://www.baeldung.com/spring-apache-camel-conditional-routing)
|
||||
- [Apache Camel Exception Handling](https://www.baeldung.com/java-apache-camel-exception-handling)
|
|
@ -1,80 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>spring-boot-camel</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>spring-boot-camel</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring-boot-modules</groupId>
|
||||
<artifactId>spring-boot-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-servlet-starter</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-jackson-starter</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-swagger-java-starter</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-spring-boot-starter</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-test-spring-junit5</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>spring-boot:run</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<mainClass>com.baeldung.camel.boot.testing.GreetingsFileSpringApplication</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
<camel.version>3.15.0</camel.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- encoders are assigned the type
|
||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue