This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3c37db8ae40f75f129c0207fd5be98944b57fe95 Author: Luca Burgazzoli <[email protected]> AuthorDate: Tue Mar 9 17:49:16 2021 +0100 dsl: refactor camel-xml-jaxb-dsl tests (spring) --- dsl/camel-xml-jaxb-dsl-test/pom.xml | 1 + dsl/camel-xml-jaxb-dsl-test/spring/pom.xml | 157 +++++++++++++++++++++ .../jaxb}/spring/CamelLoadRoutesFromXMLTest.java | 18 +-- .../src/test/resources/log4j2-test.properties | 31 ++++ .../camel/spring/camelLoadRoutesFromXMLTest.xml | 0 .../resources/org/apache/camel/spring/myRoutes.xml | 0 .../org/apache/camel/spring/myUpdatedRoutes.xml | 0 7 files changed, 198 insertions(+), 9 deletions(-) diff --git a/dsl/camel-xml-jaxb-dsl-test/pom.xml b/dsl/camel-xml-jaxb-dsl-test/pom.xml index 9d1bf63..a0296da 100644 --- a/dsl/camel-xml-jaxb-dsl-test/pom.xml +++ b/dsl/camel-xml-jaxb-dsl-test/pom.xml @@ -37,5 +37,6 @@ <module>definition</module> <module>management</module> <module>cdi</module> + <module>spring</module> </modules> </project> diff --git a/dsl/camel-xml-jaxb-dsl-test/spring/pom.xml b/dsl/camel-xml-jaxb-dsl-test/spring/pom.xml new file mode 100644 index 0000000..9847594 --- /dev/null +++ b/dsl/camel-xml-jaxb-dsl-test/spring/pom.xml @@ -0,0 +1,157 @@ +<?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/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>camel-xml-jaxb-dsl-test</artifactId> + <version>3.9.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-xml-jaxb-dsl-test-spring</artifactId> + <packaging>jar</packaging> + <name>Camel :: XML DSL Jaxb :: Test :: Spring</name> + <description>Camel XML DSL Tests with Jaxb and Spring</description> + + <properties> + <firstVersion>3.9.0</firstVersion> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-xml-jaxb-dsl</artifactId> + </dependency> + <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-core</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-main</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-management</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-direct</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-rest</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-mock</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core-languages</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-bean</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-log</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-telegram</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-seda</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <!-- skip testing on java 8 --> + <profiles> + <profile> + <id>jdk8</id> + <activation> + <jdk>[,8)</jdk> + </activation> + <properties> + <maven.test.skip.exec>true</maven.test.skip.exec> + </properties> + </profile> + </profiles> + +</project> \ No newline at end of file diff --git a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/CamelLoadRoutesFromXMLTest.java b/dsl/camel-xml-jaxb-dsl-test/spring/src/test/java/org/apache/camel/dsl/xml/jaxb/spring/CamelLoadRoutesFromXMLTest.java similarity index 86% rename from components/camel-spring-xml/src/test/java/org/apache/camel/spring/CamelLoadRoutesFromXMLTest.java rename to dsl/camel-xml-jaxb-dsl-test/spring/src/test/java/org/apache/camel/dsl/xml/jaxb/spring/CamelLoadRoutesFromXMLTest.java index 25f21a6..10f7b56 100644 --- a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/CamelLoadRoutesFromXMLTest.java +++ b/dsl/camel-xml-jaxb-dsl-test/spring/src/test/java/org/apache/camel/dsl/xml/jaxb/spring/CamelLoadRoutesFromXMLTest.java @@ -14,37 +14,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.spring; +package org.apache.camel.dsl.xml.jaxb.spring; import java.io.InputStream; +import org.apache.camel.ContextTestSupport; import org.apache.camel.ExtendedCamelContext; import org.apache.camel.ProducerTemplate; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.model.RoutesDefinition; +import org.apache.camel.spring.SpringCamelContext; import org.junit.jupiter.api.Test; import org.springframework.context.support.AbstractXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.core.io.ClassPathResource; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public class CamelLoadRoutesFromXMLTest extends SpringTestSupport { - - @Override - protected AbstractXmlApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("org/apache/camel/spring/camelLoadRoutesFromXMLTest.xml"); - } +public class CamelLoadRoutesFromXMLTest extends ContextTestSupport { @Test public void testLoadRoutes() throws Exception { + AbstractXmlApplicationContext applicationContext + = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelLoadRoutesFromXMLTest.xml"); SpringCamelContext camel = applicationContext.getBean(SpringCamelContext.class); assertEquals(0, camel.getRoutes().size()); assertTrue(camel.getStatus().isStarted()); // load routes from xml file - InputStream is = this.getClass().getResourceAsStream("myRoutes.xml"); + InputStream is = new ClassPathResource("org/apache/camel/spring/myRoutes.xml").getInputStream(); ExtendedCamelContext ecc = camel.adapt(ExtendedCamelContext.class); RoutesDefinition routes = (RoutesDefinition) ecc.getXMLRoutesDefinitionLoader().loadRoutesDefinition(ecc, is); camel.addRouteDefinitions(routes.getRoutes()); @@ -82,7 +82,7 @@ public class CamelLoadRoutesFromXMLTest extends SpringTestSupport { //camel.getRouteController().removeRoute("bar"); // load updated xml - is = this.getClass().getResourceAsStream("myUpdatedRoutes.xml"); + is = new ClassPathResource("org/apache/camel/spring/myUpdatedRoutes.xml").getInputStream(); routes = (RoutesDefinition) ecc.getXMLRoutesDefinitionLoader().loadRoutesDefinition(ecc, is); camel.addRouteDefinitions(routes.getRoutes()); diff --git a/dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/log4j2-test.properties b/dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000..0dd4797 --- /dev/null +++ b/dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/log4j2-test.properties @@ -0,0 +1,31 @@ +## --------------------------------------------------------------------------- +## 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-xml-jaxb-dsl-test-spring.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{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 +#rootLogger.appenderRef.out.ref = out diff --git a/components/camel-spring-xml/src/test/resources/org/apache/camel/spring/camelLoadRoutesFromXMLTest.xml b/dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/org/apache/camel/spring/camelLoadRoutesFromXMLTest.xml similarity index 100% rename from components/camel-spring-xml/src/test/resources/org/apache/camel/spring/camelLoadRoutesFromXMLTest.xml rename to dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/org/apache/camel/spring/camelLoadRoutesFromXMLTest.xml diff --git a/components/camel-spring-xml/src/test/resources/org/apache/camel/spring/myRoutes.xml b/dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/org/apache/camel/spring/myRoutes.xml similarity index 100% rename from components/camel-spring-xml/src/test/resources/org/apache/camel/spring/myRoutes.xml rename to dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/org/apache/camel/spring/myRoutes.xml diff --git a/components/camel-spring-xml/src/test/resources/org/apache/camel/spring/myUpdatedRoutes.xml b/dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/org/apache/camel/spring/myUpdatedRoutes.xml similarity index 100% rename from components/camel-spring-xml/src/test/resources/org/apache/camel/spring/myUpdatedRoutes.xml rename to dsl/camel-xml-jaxb-dsl-test/spring/src/test/resources/org/apache/camel/spring/myUpdatedRoutes.xml
