This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit dbb1e913a15d9a07014805b72b345e8db78dd662 Author: Claus Ibsen <[email protected]> AuthorDate: Mon Jan 10 11:50:53 2022 +0100 CAMEL-17460: Remove camel-spring-javaconfig which has been deprecated for a long time. --- .../camel/catalog/others/spring-javaconfig.json | 15 -- components/camel-spring-javaconfig/pom.xml | 73 -------- .../services/org/apache/camel/other.properties | 7 - .../src/generated/resources/spring-javaconfig.json | 15 -- .../src/main/docs/spring-javaconfig.adoc | 99 ---------- .../spring/javaconfig/CamelConfiguration.java | 208 --------------------- ...melSpringJavaconfigInitializationException.java | 25 --- .../org/apache/camel/spring/javaconfig/Main.java | 156 ---------------- .../camel/spring/javaconfig/RoutesCollector.java | 107 ----------- .../javaconfig/SingleRouteCamelConfiguration.java | 49 ----- .../spring/javaconfig/BeanJavaConfigTest.java | 78 -------- .../apache/camel/spring/javaconfig/MainTest.java | 67 ------- .../autowire/AutodetectNoRoutesConfigTest.java | 49 ----- .../autowire/AutodetectingConfigTest.java | 68 ------- .../autowire/AutowiringContextConfig.java | 38 ---- .../autowire/LoadingRawCamelConfigurationTest.java | 58 ------ .../spring/javaconfig/autowire/ModuleConfig.java | 40 ---- .../spring/javaconfig/config/ContextConfig.java | 36 ---- .../spring/javaconfig/patterns/FilterTest.java | 83 -------- ...CamelSpringDelegatingTestContextLoaderTest.java | 80 -------- .../camel/spring/javaconfig/test/Cheese.java | 21 --- .../test/JavaConfigWithNestedConfigClassTest.java | 58 ------ .../test/JavaConfigWithPostProcessorTest.java | 47 ----- .../camel/spring/javaconfig/test/MyConfig.java | 29 --- .../spring/javaconfig/test/MyPostProcessor.java | 44 ----- .../camel/spring/javaconfig/test/package-info.java | 20 -- .../src/test/resources/log4j2.properties | 28 --- components/pom.xml | 1 - parent/pom.xml | 5 - tooling/maven/camel-maven-plugin/pom.xml | 4 - 30 files changed, 1608 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/spring-javaconfig.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/spring-javaconfig.json deleted file mode 100644 index 1283c22..0000000 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/spring-javaconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "other": { - "kind": "other", - "name": "spring-javaconfig", - "title": "Spring Java Configuration", - "description": "Using Camel with Spring Java Configuration", - "deprecated": true, - "firstVersion": "2.0.0", - "label": "spring", - "supportLevel": "Stable", - "groupId": "org.apache.camel", - "artifactId": "camel-spring-javaconfig", - "version": "3.15.0-SNAPSHOT" - } -} diff --git a/components/camel-spring-javaconfig/pom.xml b/components/camel-spring-javaconfig/pom.xml deleted file mode 100644 index 5422ca4..0000000 --- a/components/camel-spring-javaconfig/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<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> - - <parent> - <groupId>org.apache.camel</groupId> - <artifactId>components</artifactId> - <version>3.15.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-spring-javaconfig</artifactId> - <packaging>jar</packaging> - - <name>Camel :: Spring JavaConfig (deprecated)</name> - <description>Using Camel with Spring Java Configuration</description> - - <properties> - <firstVersion>2.0.0</firstVersion> - <label>spring</label> - <title>Spring Java Configuration</title> - - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-support</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-xml</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-main</artifactId> - </dependency> - - <!-- test dependencies --> - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring-junit5</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/components/camel-spring-javaconfig/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-spring-javaconfig/src/generated/resources/META-INF/services/org/apache/camel/other.properties deleted file mode 100644 index c95e8eb..0000000 --- a/components/camel-spring-javaconfig/src/generated/resources/META-INF/services/org/apache/camel/other.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -name=spring-javaconfig -groupId=org.apache.camel -artifactId=camel-spring-javaconfig -version=3.15.0-SNAPSHOT -projectName=Camel :: Spring JavaConfig (deprecated) -projectDescription=Using Camel with Spring Java Configuration diff --git a/components/camel-spring-javaconfig/src/generated/resources/spring-javaconfig.json b/components/camel-spring-javaconfig/src/generated/resources/spring-javaconfig.json deleted file mode 100644 index 1283c22..0000000 --- a/components/camel-spring-javaconfig/src/generated/resources/spring-javaconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "other": { - "kind": "other", - "name": "spring-javaconfig", - "title": "Spring Java Configuration", - "description": "Using Camel with Spring Java Configuration", - "deprecated": true, - "firstVersion": "2.0.0", - "label": "spring", - "supportLevel": "Stable", - "groupId": "org.apache.camel", - "artifactId": "camel-spring-javaconfig", - "version": "3.15.0-SNAPSHOT" - } -} diff --git a/components/camel-spring-javaconfig/src/main/docs/spring-javaconfig.adoc b/components/camel-spring-javaconfig/src/main/docs/spring-javaconfig.adoc deleted file mode 100644 index 0a6a8e7..0000000 --- a/components/camel-spring-javaconfig/src/main/docs/spring-javaconfig.adoc +++ /dev/null @@ -1,99 +0,0 @@ -= Spring Java Configuration Component (deprecated) -:doctitle: Spring Java Configuration -:shortname: spring-javaconfig -:artifactid: camel-spring-javaconfig -:description: Using Camel with Spring Java Configuration -:since: 2.0 -:supportlevel: Stable-deprecated -:deprecated: *deprecated* -//Manually maintained attributes -:camel-spring-boot-name: spring-javaconfig - -*Since Camel {since}* - -Spring started life using XML Config to wire beans -together. However some folks don't like using XML and would rather use -Java code with the Spring JavaConfig project. - - -You can use either the XML or Java config approaches with Camel; its -your choice really on which you prefer. - -[[SpringJavaConfig-UsingSpringJavaConfig]] -== Using Spring Java Config - -To use Spring Java Config in your Camel project the easiest thing to do -is add the following to your pom.xml - -[source,xml] --------------------------------------------------- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-javaconfig</artifactId> - <version>${camel-version}</version> -</dependency> --------------------------------------------------- - -This will then add the dependencies on the Spring JavaConfig library -along with some helper classes for configuring Camel inside Spring. - -Note that this library is totally optional; you could just wire Camel -together yourself with Java Config. - -[[SpringJavaConfig-Configuration]] -== Configuration - -The most common case of using JavaConfig with Camel would be to create -configuration with defined list of routes to be used by router. - -[source,java] --------------------------------------------------------------------- -@Configuration -public class MyRouteConfiguration extends CamelConfiguration { - - @Autowire - private MyRouteBuilder myRouteBuilder; - - @Autowire - private MyAnotherRouteBuilder myAnotherRouteBuilder; - - @Override - public List<RouteBuilder> routes() { - return Arrays.asList(myRouteBuilder, myAnotherRouteBuilder); - } - -} --------------------------------------------------------------------- - -You can skip the *routes()* definition, and -fall back to the *RouteBuilder* instances located in the Spring context. - -[source,java] --------------------------------------------------------------- -@Configuration -@ComponentScan("com.example.routes") -public class MyRouteConfiguration extends CamelConfiguration { -} --------------------------------------------------------------- - -[[SpringJavaConfig-Testing]] -== Testing - -You can use the `CamelSpringJUnit4ClassRunner` with -`CamelSpringDelegatingTestContextLoader`. This is the recommended way to -test Java Config and Camel integration. - -If you wish to create a collection of *RouteBuilder* instances then -derive from the *CamelConfiguration* helper class and implement the -*routes()* method. Keep in mind that if -you don't override *routes()* method, then *CamelConfiguration* will use -all *RouteBuilder* instances available in the Spring context. - -The *@ContextConfiguration* annotation tells the -Spring Testing framework to load the -*ContextConfig* class as the configuration to use. This class derives -from *SingleRouteCamelConfiguration* which is a helper Spring Java -Config class which will configure the CamelContext for us and then -register the RouteBuilder we create. - -include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java b/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java deleted file mode 100644 index 2e61b0c..0000000 --- a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.ConsumerTemplate; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.spring.SpringCamelContext; -import org.apache.camel.spring.xml.CamelBeanPostProcessor; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.config.AutowireCapableBeanFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationEventPublisherAware; -import org.springframework.context.MessageSourceAware; -import org.springframework.context.ResourceLoaderAware; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static java.util.Collections.emptyList; - -/** - * A useful base class for writing <a href= - * "http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-annotation-config"> - * Spring annotation-based</a> configurations for working with Camel. - */ -@Deprecated -@Configuration -public abstract class CamelConfiguration implements BeanFactoryAware, ApplicationContextAware { - - private BeanFactory beanFactory; - private AutowireCapableBeanFactory autowireCapableBeanFactory; - private ApplicationContext applicationContext; - - @Override - public void setBeanFactory(BeanFactory beanFactory) { - this.beanFactory = beanFactory; - if (beanFactory instanceof AutowireCapableBeanFactory) { - autowireCapableBeanFactory = (AutowireCapableBeanFactory) beanFactory; - } - } - - protected BeanFactory getBeanFactory() { - return this.beanFactory; - } - - @Override - public void setApplicationContext(ApplicationContext ac) { - this.applicationContext = ac; - } - - protected ApplicationContext getApplicationContext() { - return this.applicationContext; - } - - public Object getBean(String beanName) { - return beanFactory.getBean(beanName); - } - - public <T> T getBean(Class<T> type) { - return beanFactory.getBean(type); - } - - public <T> T getBean(String beanName, Class<T> type) { - return beanFactory.getBean(beanName, type); - } - - /** - * Invoke callbacks on the object, as though it were configured in the factory. If appropriate, the object may be - * wrapped before being returned. For this reason, it is recommended to always respect the return value when using - * this method. - * - * @param object object to configure - * - * @return either the original object or a wrapped one after callbacks called on it. - */ - protected <T> T getConfigured(T object) { - if (this.autowireCapableBeanFactory == null) { - throw new UnsupportedOperationException( - "Cannot configure object - not running in an AutowireCapableBeanFactory"); - } - - @SuppressWarnings("unchecked") // See SPR-4955 - T configuredObject = (T) autowireCapableBeanFactory.initializeBean(object, null); - - // this block copied from ApplicationContextAwareProcessor. See SJC-149. - if (this.applicationContext != null) { - if (configuredObject instanceof ResourceLoaderAware) { - ((ResourceLoaderAware) configuredObject).setResourceLoader(this.applicationContext); - } - - if (configuredObject instanceof ApplicationEventPublisherAware) { - ((ApplicationEventPublisherAware) configuredObject).setApplicationEventPublisher(this.applicationContext); - } - - if (configuredObject instanceof MessageSourceAware) { - ((MessageSourceAware) configuredObject).setMessageSource(this.applicationContext); - } - - if (configuredObject instanceof ApplicationContextAware) { - ((ApplicationContextAware) configuredObject).setApplicationContext(this.applicationContext); - } - } - - return configuredObject; - } - - /** - * Get's the {@link ProducerTemplate} to be used. - */ - @Bean(initMethod = "", destroyMethod = "") - // Camel handles the lifecycle of this bean - public ProducerTemplate producerTemplate(CamelContext camelContext) { - return camelContext.createProducerTemplate(); - } - - /** - * Get's the {@link ConsumerTemplate} to be used. - */ - @Bean(initMethod = "", destroyMethod = "") - // Camel handles the lifecycle of this bean - public ConsumerTemplate consumerTemplate(CamelContext camelContext) { - return camelContext.createConsumerTemplate(); - } - - /** - * Camel post processor - required to support Camel annotations. - */ - @Bean - public CamelBeanPostProcessor camelBeanPostProcessor() throws Exception { - CamelBeanPostProcessor answer = new CamelBeanPostProcessor(); - answer.setApplicationContext(getApplicationContext()); - // do not set CamelContext as we will lazy evaluate that later - return answer; - } - - /** - * Get's the {@link CamelContext} to be used. - */ - @Bean - public CamelContext camelContext() throws Exception { - CamelContext camelContext = createCamelContext(); - setupCamelContext(camelContext); - camelContext.build(); - return camelContext; - } - - @Bean - RoutesCollector routesCollector(ApplicationContext applicationContext) { - return new RoutesCollector(applicationContext, this); - } - - /** - * Callback to setup {@link CamelContext} before its started - */ - protected void setupCamelContext(CamelContext camelContext) throws Exception { - // noop - } - - /** - * Factory method returning {@link CamelContext} used by this configuration. - * - * @return {@link CamelContext} used by this configuration. By default {@link SpringCamelContext} instance is - * created, to fully integrate Spring application context and Camel registry. - */ - protected CamelContext createCamelContext() { - return new SpringCamelContext(getApplicationContext()); - } - - /** - * Returns the list of routes to use in this configuration. By default autowires all - * {@link org.apache.camel.builder.RouteBuilder} instances available in the - * {@link org.springframework.context.ApplicationContext}. - */ - public List<RouteBuilder> routes() { - if (this.applicationContext != null) { - Map<String, RouteBuilder> routeBuildersMap = applicationContext.getBeansOfType(RouteBuilder.class); - List<RouteBuilder> routeBuilders = new ArrayList<>(routeBuildersMap.size()); - for (RouteBuilder routeBuilder : routeBuildersMap.values()) { - routeBuilders.add(routeBuilder); - } - return routeBuilders; - } else { - return emptyList(); - } - } - -} diff --git a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelSpringJavaconfigInitializationException.java b/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelSpringJavaconfigInitializationException.java deleted file mode 100644 index 1f4ca04..0000000 --- a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelSpringJavaconfigInitializationException.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig; - -@Deprecated -public class CamelSpringJavaconfigInitializationException extends RuntimeException { - - public CamelSpringJavaconfigInitializationException(Throwable cause) { - super(cause); - } -} diff --git a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/Main.java b/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/Main.java deleted file mode 100644 index 5252628..0000000 --- a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/Main.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import org.apache.camel.util.ObjectHelper; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.support.AbstractApplicationContext; - -/** - * The Main class which takes the spring java config parameter - */ -@Deprecated -public class Main extends org.apache.camel.spring.Main { - - private String basedPackages; - private String configClasses; - private Class[] configClass; - - public Main() { - - addOption(new ParameterOption( - "bp", "basedPackages", - "Sets the based packages of Spring java config ApplicationContext", "basedPackages") { - protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) { - setBasedPackages(parameter); - } - }); - - addOption(new ParameterOption( - "cc", "configClasses", - "Sets the config of Spring java config ApplicationContext", "configureClasses") { - protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) { - setConfigClasses(parameter); - } - }); - } - - public static void main(String... args) throws Exception { - Main main = new Main(); - instance = main; - main.run(args); - } - - /** - * Sets the base packages where Spring annotation scanning is performed. You can separate multiple packages using - * comma or semi colon. - */ - public void setBasedPackages(String config) { - basedPackages = config; - } - - public String getBasedPackages() { - return basedPackages; - } - - /** - * Sets the name of Spring <tt>@Configuration</tt> classes to use. You can separate multiple classes using comma or - * semi colon. - */ - public void setConfigClasses(String config) { - configClasses = config; - } - - public String getConfigClasses() { - return configClasses; - } - - /** - * @deprecated use {@link #setConfigClasses(String)} - */ - @Deprecated - public void setConfigClassesString(String config) { - setConfigClasses(config); - } - - /** - * @deprecated use {@link #getConfigClasses()} - */ - @Deprecated - public String getConfigClassesString() { - return getConfigClasses(); - } - - public Class[] getConfigClass() { - return configClass; - } - - /** - * Sets the Spring <tt>@Configuration</tt> classes to use. - */ - public void setConfigClass(Class... configClass) { - this.configClass = configClass; - } - - private Class<?>[] getConfigClasses(String configureClasses) { - List<Class<?>> answer = new ArrayList<>(); - String[] classes = configureClasses.split("(;|,)"); - for (String className : classes) { - className = className.trim(); - Class<?> configClass = ObjectHelper.loadClass(className); - if (configClass != null) { - answer.add(configClass); - } - } - return answer.toArray(new Class<?>[answer.size()]); - } - - @Override - protected AbstractApplicationContext createDefaultApplicationContext() { - ApplicationContext parentContext = getParentApplicationContext(); - AnnotationConfigApplicationContext acApplicationContext = new AnnotationConfigApplicationContext(); - if (parentContext != null) { - acApplicationContext.setParent(parentContext); - } - if (getConfigClasses() != null) { - Class<?>[] configClasses = getConfigClasses(getConfigClasses()); - for (Class<?> cls : configClasses) { - acApplicationContext.register(cls); - } - } - if (getConfigClass() != null) { - for (Class<?> cls : getConfigClass()) { - acApplicationContext.register(cls); - } - } - if (getBasedPackages() != null) { - String[] basePackages = getBasedPackages().split("(;|,)"); - for (String basePackage : basePackages) { - basePackage = basePackage.trim(); - acApplicationContext.scan(basePackage); - } - } - acApplicationContext.refresh(); - return acApplicationContext; - } - -} diff --git a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/RoutesCollector.java b/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/RoutesCollector.java deleted file mode 100644 index 720ab44..0000000 --- a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/RoutesCollector.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig; - -import java.lang.reflect.Modifier; - -import org.apache.camel.CamelContext; -import org.apache.camel.RoutesBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.core.Ordered; - -/** - * Collects routes and rests from the various sources (like Spring application context beans registry or opinionated - * classpath locations) and injects these into the Camel context. - */ -@Deprecated -public class RoutesCollector implements ApplicationListener<ContextRefreshedEvent>, Ordered { - - // Static collaborators - - private static final Logger LOG = LoggerFactory.getLogger(RoutesCollector.class); - - // Collaborators - - private final ApplicationContext applicationContext; - private final CamelConfiguration configuration; - - // Constructors - - public RoutesCollector(ApplicationContext applicationContext, CamelConfiguration configuration) { - this.applicationContext = applicationContext; - this.configuration = configuration; - } - - // Overridden - - @Override - public void onApplicationEvent(ContextRefreshedEvent event) { - ApplicationContext applicationContext = event.getApplicationContext(); - - // only listen to context refresh of "my" applicationContext - if (this.applicationContext.equals(applicationContext)) { - - CamelContext camelContext = event.getApplicationContext().getBean(CamelContext.class); - - // only add and start Camel if its stopped (initial state) - if (camelContext.getStatus().isStopped()) { - LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName()); - for (RoutesBuilder routesBuilder : configuration.routes()) { - // filter out abstract classes - boolean abs = Modifier.isAbstract(routesBuilder.getClass().getModifiers()); - if (!abs) { - try { - LOG.debug("Injecting following route into the CamelContext: {}", routesBuilder); - camelContext.addRoutes(routesBuilder); - } catch (Exception e) { - throw new CamelSpringJavaconfigInitializationException(e); - } - } - } - - try { - boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext")); - if (skip) { - LOG.info( - "Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true."); - } else { - // start camel - camelContext.start(); - } - - } catch (Exception e) { - throw new CamelSpringJavaconfigInitializationException(e); - } - - } - } else { - LOG.debug("Ignore ContextRefreshedEvent: {}", event); - } - } - - @Override - public int getOrder() { - // we want the RoutesCollector to receive ContextRefreshedEvent - // before SpringCamelContext (see SpringCamelContext::getOrder) - return LOWEST_PRECEDENCE - 1; - } - -} diff --git a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/SingleRouteCamelConfiguration.java b/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/SingleRouteCamelConfiguration.java deleted file mode 100644 index 7c47b12..0000000 --- a/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/SingleRouteCamelConfiguration.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig; - -import java.util.Collections; -import java.util.List; - -import org.apache.camel.builder.RouteBuilder; -import org.springframework.context.annotation.Bean; - -/** - * A useful base class for writing <a href= - * "http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-annotation-config"> - * Spring annotation-based</a> configurations to configure a {@link org.apache.camel.CamelContext} with a single - * {@link RouteBuilder} instance. - * <p/> - * You may want to use Spring's {@link org.springframework.stereotype.Component} annotation and mark your Camel - * {@link RouteBuilder} classes using this annotation and have it automatic discovered, if you are using Spring's - * annotation scanner. - */ -@Deprecated -public abstract class SingleRouteCamelConfiguration extends CamelConfiguration { - - @Override - @Bean - public List<RouteBuilder> routes() { - return Collections.singletonList(route()); - } - - /** - * Creates the single {@link RouteBuilder} to use in this configuration - */ - public abstract RouteBuilder route(); - -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java deleted file mode 100644 index abce949..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Handler; -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.spring.junit5.CamelSpringTest; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; - -@CamelSpringTest -@ContextConfiguration(classes = BeanJavaConfigTest.ContextConfig.class) -public class BeanJavaConfigTest { - - @EndpointInject("mock:end") - protected MockEndpoint endpoint; - - @EndpointInject("mock:error") - protected MockEndpoint errorEndpoint; - - @Produce("direct:start") - protected ProducerTemplate producer; - - @Test - @DirtiesContext - public void testRouteUsingBean() throws Exception { - endpoint.expectedMessageCount(1); - endpoint.message(0).body().isEqualTo("Hello World"); - producer.sendBody("World"); - endpoint.assertIsSatisfied(); - } - - public static class SomeBean { - @Handler - public String someMethod(String body) { - return "Hello " + body; - } - } - - @Configuration - public static class ContextConfig extends SingleRouteCamelConfiguration { - @Bean - @Override - public RouteBuilder route() { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start") - .errorHandler(deadLetterChannel("mock:end")) - .bean(new SomeBean()) - .to("mock:end"); - } - }; - } - } - -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java deleted file mode 100644 index d0b71aa..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.jupiter.api.Test; -import org.springframework.context.ApplicationContext; - -public class MainTest { - - @Test - public void testOptions() throws Exception { - CamelContext context - = createCamelContext(new String[] { "-cc", "org.apache.camel.spring.javaconfig.config.ContextConfig" }); - context.start(); - runTests(context); - context.stop(); - } - - @org.junit.jupiter.api.Test - public void testOptionBP() throws Exception { - CamelContext context = createCamelContext(new String[] { "-bp", "org.apache.camel.spring.javaconfig.config" }); - context.start(); - runTests(context); - context.stop(); - } - - private CamelContext createCamelContext(String[] options) throws Exception { - Main main = new Main(); - main.parseArguments(options); - ApplicationContext applicationContext = main.createDefaultApplicationContext(); - CamelContext context = applicationContext.getBean(CamelContext.class); - return context; - } - - private void runTests(CamelContext context) throws Exception { - MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); - ProducerTemplate template = context.createProducerTemplate(); - - String expectedBody = "<matched/>"; - resultEndpoint.expectedBodiesReceived(expectedBody); - template.sendBodyAndHeader("direct:start", expectedBody, "foo", "bar"); - resultEndpoint.assertIsSatisfied(); - - resultEndpoint.reset(); - resultEndpoint.expectedMessageCount(0); - template.sendBodyAndHeader("direct:start", "<notMatched/>", "foo", "notMatchedHeaderValue"); - resultEndpoint.assertIsSatisfied(); - } - -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java deleted file mode 100644 index 3ab364b..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.autowire; - -import org.apache.camel.CamelContext; -import org.apache.camel.spring.javaconfig.CamelConfiguration; -import org.apache.camel.test.spring.junit5.CamelSpringTest; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -@CamelSpringTest -@ContextConfiguration(classes = NoRoutesConfig.class) -public class AutodetectNoRoutesConfigTest { - - @Autowired - CamelContext camelContext; - - @Test - public void shouldAutodetectRouteBuilders() throws InterruptedException { - // When - int routesNumber = camelContext.getRoutes().size(); - - //Then - assertEquals(0, routesNumber); - } - -} - -@Configuration -class NoRoutesConfig extends CamelConfiguration { -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java deleted file mode 100644 index f1f17b8..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.autowire; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.spring.junit5.CamelSpringTest; -import org.junit.jupiter.api.Test; -import org.springframework.test.context.ContextConfiguration; - -@CamelSpringTest -@ContextConfiguration(classes = AutowiringContextConfig.class) -public class AutodetectingConfigTest { - - @EndpointInject("mock:autowire") - MockEndpoint autowireMockEndpoint; - - @EndpointInject("mock:module") - MockEndpoint moduleMockEndpoint; - - @Produce - ProducerTemplate producer; - - String message = "Hello!"; - - @Test - public void shouldAutodetectRouteBuilders() throws InterruptedException { - // Given - autowireMockEndpoint.expectedMessageCount(1); - autowireMockEndpoint.message(0).body().isEqualTo(message); - - // When - producer.sendBody("direct:autowire", message); - - // Then - autowireMockEndpoint.assertIsSatisfied(); - } - - @org.junit.jupiter.api.Test - public void shouldWireRouteBuildersFromModule() throws InterruptedException { - // Given - moduleMockEndpoint.expectedMessageCount(1); - moduleMockEndpoint.message(0).body().isEqualTo(message); - - // When - producer.sendBody("direct:module", message); - - // Then - moduleMockEndpoint.assertIsSatisfied(); - } - -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutowiringContextConfig.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutowiringContextConfig.java deleted file mode 100644 index 761ba43..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutowiringContextConfig.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.autowire; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.spring.javaconfig.CamelConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; - -@Configuration -@ComponentScan("org.apache.camel.spring.javaconfig.autowire") -public class AutowiringContextConfig extends CamelConfiguration { -} - -@Component -class MockedRoute extends RouteBuilder { - - @Override - public void configure() throws Exception { - from("direct:autowire").to("mock:autowire"); - } - -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java deleted file mode 100644 index dc34848..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.autowire; - -import org.apache.camel.EndpointInject; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.spring.javaconfig.CamelConfiguration; -import org.apache.camel.test.spring.junit5.CamelSpringTest; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@CamelSpringTest -@ContextConfiguration(classes = { CamelConfiguration.class, AdditionalRouteConfiguration.class }) -public class LoadingRawCamelConfigurationTest { - - @EndpointInject("mock:rawConfigTest") - MockEndpoint moduleMockEndpoint; - - @Test - public void shouldAutodetectRouteBuilders() throws InterruptedException { - assertNotNull(moduleMockEndpoint); - } - -} - -@Configuration -class AdditionalRouteConfiguration { - - @Bean - public RouteBuilder routeBuilder() { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:rawConfigTest").to("mock:rawConfigTest"); - } - }; - } - -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/ModuleConfig.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/ModuleConfig.java deleted file mode 100644 index 8b58505..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/ModuleConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.autowire; - -import org.apache.camel.builder.RouteBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ModuleConfig { - - @Bean - public MockedRouteLoadedByModule mockedRouteLoadedByModule() { - return new MockedRouteLoadedByModule(); - } - -} - -class MockedRouteLoadedByModule extends RouteBuilder { - - @Override - public void configure() throws Exception { - from("direct:module").to("mock:module"); - } - -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/config/ContextConfig.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/config/ContextConfig.java deleted file mode 100644 index 5417bdb..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/config/ContextConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.config; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ContextConfig extends SingleRouteCamelConfiguration { - - @Override - @Bean - public RouteBuilder route() { - return new RouteBuilder() { - public void configure() { - from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result"); - } - }; - } -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java deleted file mode 100644 index 5941689..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.patterns; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration; -import org.apache.camel.test.spring.junit5.CamelSpringTest; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; - -/** - * Tests filtering using Spring Test and Java Config - */ -// START SNIPPET: example -// tag::example[] -@CamelSpringTest -@ContextConfiguration(classes = FilterTest.ContextConfig.class) -public class FilterTest { - - @EndpointInject("mock:result") - protected MockEndpoint resultEndpoint; - - @Produce("direct:start") - protected ProducerTemplate template; - - @DirtiesContext - @org.junit.jupiter.api.Test - public void testSendMatchingMessage() throws Exception { - String expectedBody = "<matched/>"; - - resultEndpoint.expectedBodiesReceived(expectedBody); - - template.sendBodyAndHeader(expectedBody, "foo", "bar"); - - resultEndpoint.assertIsSatisfied(); - } - - @DirtiesContext - @Test - public void testSendNotMatchingMessage() throws Exception { - resultEndpoint.expectedMessageCount(0); - - template.sendBodyAndHeader("<notMatched/>", "foo", "notMatchedHeaderValue"); - - resultEndpoint.assertIsSatisfied(); - } - - @Configuration - public static class ContextConfig extends SingleRouteCamelConfiguration { - @Override - @Bean - public RouteBuilder route() { - return new RouteBuilder() { - public void configure() { - from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result"); - } - }; - } - } -} -// end::example[] -// END SNIPPET: example diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java deleted file mode 100644 index 9844097..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.test; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration; -import org.apache.camel.test.spring.junit5.CamelSpringTest; -import org.apache.camel.test.spring.junit5.MockEndpoints; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; - -/** - * Test for CamelSpringDelegatingTestContextLoader. - */ -//START SNIPPET: example -// tag::example[] -@CamelSpringTest -@ContextConfiguration(classes = CamelSpringDelegatingTestContextLoaderTest.TestConfig.class) -@MockEndpoints -public class CamelSpringDelegatingTestContextLoaderTest { - @EndpointInject("mock:direct:end") - protected MockEndpoint endEndpoint; - - @EndpointInject("mock:direct:error") - protected MockEndpoint errorEndpoint; - - @Produce("direct:test") - protected ProducerTemplate testProducer; - - @Configuration - public static class TestConfig extends SingleRouteCamelConfiguration { - @Bean - @Override - public RouteBuilder route() { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:test").errorHandler(deadLetterChannel("direct:error")).to("direct:end"); - - from("direct:error").log("Received message on direct:error endpoint."); - - from("direct:end").log("Received message on direct:end endpoint."); - } - }; - } - } - - @Test - public void testRoute() throws InterruptedException { - endEndpoint.expectedMessageCount(1); - errorEndpoint.expectedMessageCount(0); - - testProducer.sendBody("<name>test</name>"); - - endEndpoint.assertIsSatisfied(); - errorEndpoint.assertIsSatisfied(); - } -} -// end::example[] -//END SNIPPET: example diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/Cheese.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/Cheese.java deleted file mode 100644 index e3588c0..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/Cheese.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.test; - -public interface Cheese { - void doCheese(); -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java deleted file mode 100644 index 9a71cca..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.test; - -import org.apache.camel.test.spring.junit5.CamelSpringTest; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -import org.springframework.test.context.ContextConfiguration; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -@CamelSpringTest -@ContextConfiguration(classes = JavaConfigWithNestedConfigClassTest.ContextConfig.class) -@Component -public class JavaConfigWithNestedConfigClassTest implements Cheese { - - private static final Logger LOGGER = LoggerFactory.getLogger(JavaConfigWithPostProcessorTest.class); - - private boolean doCheeseCalled; - - @Test - public void testPostProcessorInjectsMe() throws Exception { - assertTrue(doCheeseCalled, "doCheese() should be called"); - } - - @Override - public void doCheese() { - LOGGER.info("doCheese called!"); - doCheeseCalled = true; - } - - @Configuration - public static class ContextConfig { - @Bean - public MyPostProcessor myPostProcessor() { - return new MyPostProcessor(); - } - } - -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java deleted file mode 100644 index 3c454c5..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.test; - -import org.apache.camel.test.spring.junit5.CamelSpringTest; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import org.springframework.test.context.ContextConfiguration; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -@CamelSpringTest -@ContextConfiguration(classes = MyConfig.class) -@Component -public class JavaConfigWithPostProcessorTest implements Cheese { - - private static final Logger LOGGER = LoggerFactory.getLogger(JavaConfigWithPostProcessorTest.class); - - private boolean doCheeseCalled; - - @Test - public void testPostProcessorInjectsMe() throws Exception { - assertTrue(doCheeseCalled, "doCheese() should be called"); - } - - @Override - public void doCheese() { - LOGGER.info("doCheese called!"); - doCheeseCalled = true; - } -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/MyConfig.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/MyConfig.java deleted file mode 100644 index a92162f..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/MyConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.test; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MyConfig { - - @Bean - public MyPostProcessor myPostProcessor() { - return new MyPostProcessor(); - } -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/MyPostProcessor.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/MyPostProcessor.java deleted file mode 100644 index a400cf0..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/MyPostProcessor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.javaconfig.test; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; - -/** - * A simple post processor - */ -public class MyPostProcessor implements BeanPostProcessor { - - @Override - public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { - if (bean instanceof Cheese) { - Cheese cheese = (Cheese) bean; - cheese.doCheese(); - } - return bean; - } - - @Override - public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { - if (bean instanceof Cheese) { - Cheese cheese = (Cheese) bean; - cheese.doCheese(); - } - return bean; - } -} diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/package-info.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/package-info.java deleted file mode 100644 index fe13c4e..0000000 --- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Tests the behaviour of Spring JavaConfig with Spring-Test - */ -package org.apache.camel.spring.javaconfig.test; diff --git a/components/camel-spring-javaconfig/src/test/resources/log4j2.properties b/components/camel-spring-javaconfig/src/test/resources/log4j2.properties deleted file mode 100644 index d66e767..0000000 --- a/components/camel-spring-javaconfig/src/test/resources/log4j2.properties +++ /dev/null @@ -1,28 +0,0 @@ -## --------------------------------------------------------------------------- -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## --------------------------------------------------------------------------- - -appender.file.type = File -appender.file.name = file -appender.file.fileName = target/camel-spring-javaconfig-test.log -appender.file.layout.type = PatternLayout -appender.file.layout.pattern = %d %-5p %c{1} - %m %n -appender.out.type = Console -appender.out.name = out -appender.out.layout.type = PatternLayout -appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n -rootLogger.level = INFO -rootLogger.appenderRef.file.ref = file diff --git a/components/pom.xml b/components/pom.xml index 020885b..2a45d7c 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -304,7 +304,6 @@ <module>camel-splunk-hec</module> <module>camel-spring-batch</module> <module>camel-spring-integration</module> - <module>camel-spring-javaconfig</module> <module>camel-spring-jdbc</module> <module>camel-spring-ldap</module> <module>camel-spring-rabbitmq</module> diff --git a/parent/pom.xml b/parent/pom.xml index 28bde7f..ea1a093 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -2402,11 +2402,6 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-javaconfig</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> <artifactId>camel-spring-jdbc</artifactId> <version>${project.version}</version> </dependency> diff --git a/tooling/maven/camel-maven-plugin/pom.xml b/tooling/maven/camel-maven-plugin/pom.xml index 8238da5..858c550 100644 --- a/tooling/maven/camel-maven-plugin/pom.xml +++ b/tooling/maven/camel-maven-plugin/pom.xml @@ -82,10 +82,6 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-spring-main</artifactId> </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-javaconfig</artifactId> - </dependency> <!-- camel-cdi-main has Main class for running CDI --> <dependency> <groupId>org.apache.camel</groupId>
