Author: ningjiang
Date: Mon Oct 29 07:59:15 2012
New Revision: 1403185

URL: http://svn.apache.org/viewvc?rev=1403185&view=rev
Log:
Added an unit test which is based on user mailing list

Added:
    
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
    
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
Modified:
    
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java

Modified: 
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java?rev=1403185&r1=1403184&r2=1403185&view=diff
==============================================================================
--- 
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
 (original)
+++ 
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
 Mon Oct 29 07:59:15 2012
@@ -16,7 +16,9 @@
  */
 package org.apache.camel.test.patterns;
 
+import org.apache.camel.EndpointInject;
 import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
 
 /**
  *
@@ -25,8 +27,15 @@ public class MyProduceBean {
 
     @Produce(uri = "mock:result")
     MySender sender;
+    
+    @EndpointInject(uri = "direct:start")
+    ProducerTemplate template;
 
     public void doSomething(String body) {
         sender.send(body);
     }
+    
+    public ProducerTemplate getProducerTemplate() {
+        return template;
+    }
 }

Added: 
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java?rev=1403185&view=auto
==============================================================================
--- 
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
 (added)
+++ 
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
 Mon Oct 29 07:59:15 2012
@@ -0,0 +1,38 @@
+/**
+ * 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.patterns;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ProducerBeanInjectTest extends Assert {
+
+    @Test
+    public void checkProducerBeanInjection() {
+        AbstractApplicationContext applicationContext = 
createApplicationContext();
+        MyProduceBean bean = applicationContext.getBean("myProduceBean", 
MyProduceBean.class);
+        assertNotNull("The producerTemplate should not be null.", 
bean.getProducerTemplate());
+        assertEquals("Get a wrong response", "Camel rocks!", 
bean.getProducerTemplate().requestBody("Camel"));
+    }
+
+    protected AbstractApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/test/patterns/ProduceBeanInjectTest.xml");
+    }
+
+}

Added: 
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml?rev=1403185&view=auto
==============================================================================
--- 
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
 (added)
+++ 
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
 Mon Oct 29 07:59:15 2012
@@ -0,0 +1,39 @@
+<?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>${in.body} rocks!</simple>
+             </transform>
+               </route>
+    </camelContext>
+    
+    <!--bean id="camelPostProcessBean" 
class="org.apache.camel.spring.CamelBeanPostProcessor" /-->
+
+    <bean id="myProduceBean" 
class="org.apache.camel.test.patterns.MyProduceBean"/>
+    
+</beans>
\ No newline at end of file


Reply via email to