You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/11/05 09:56:59 UTC
svn commit: r1405714 - in /camel/trunk/components/camel-test-spring/src/test:
java/org/apache/camel/test/junit4/ resources/org/apache/camel/test/junit4/
Author: ningjiang
Date: Mon Nov 5 08:56:59 2012
New Revision: 1405714
URL: http://svn.apache.org/viewvc?rev=1405714&view=rev
Log:
CAMEL-5758 added an unit test to verify the spring active profile function
Added:
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringActiveProfileTest.java
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/CamelSpringActiveProfileTest-context.xml
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/test.properties
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringActiveProfileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringActiveProfileTest.java?rev=1405714&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringActiveProfileTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringActiveProfileTest.java Mon Nov 5 08:56:59 2012
@@ -0,0 +1,46 @@
+/**
+ * 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.test.junit4;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+
+@ContextConfiguration
+@ActiveProfiles("test")
+@RunWith(CamelSpringJUnit4ClassRunner.class)
+public class CamelSpringActiveProfileTest {
+ @Autowired
+ protected CamelContext camelContext;
+ @Produce(uri = "direct:start", context = "camelContext")
+ protected ProducerTemplate start;
+
+ @Test
+ public void testLoadActiveProfile() throws InterruptedException {
+ MockEndpoint mock = camelContext.getEndpoint("mock:test", MockEndpoint.class);
+ mock.expectedBodiesReceived("Hello World");
+ start.sendBody("World");
+ mock.assertIsSatisfied();
+ }
+
+}
Added: camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/CamelSpringActiveProfileTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/CamelSpringActiveProfileTest-context.xml?rev=1405714&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/CamelSpringActiveProfileTest-context.xml (added)
+++ camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/CamelSpringActiveProfileTest-context.xml Mon Nov 5 08:56:59 2012
@@ -0,0 +1,41 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+ <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct:start" />
+ <transform>
+ <simple>Hello ${body}</simple>
+ </transform>
+ <to uri="properties:{{cool.end}}" />
+ </route>
+ </camelContext>
+
+ <!-- setup the profile for testing -->
+ <beans profile="test">
+ <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
+ <property name="location" value="classpath:org/apache/camel/test/junit4/test.properties"/>
+ </bean>
+ </beans>
+</beans>
\ No newline at end of file
Added: camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/test.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/test.properties?rev=1405714&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/test.properties (added)
+++ camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/test.properties Mon Nov 5 08:56:59 2012
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+cool.end=mock:test
\ No newline at end of file