You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/04/07 12:36:52 UTC
svn commit: r1310725 - in /camel/trunk/components:
camel-test-spring/src/test/java/org/apache/camel/test/patterns/
camel-test-spring/src/test/resources/org/apache/camel/test/patterns/
camel-test/src/main/java/org/apache/camel/test/junit4/ camel-test/sr...
Author: davsclaus
Date: Sat Apr 7 10:36:52 2012
New Revision: 1310725
URL: http://svn.apache.org/viewvc?rev=1310725&view=rev
Log:
CAMEL-5149: The default injector should perform bean post processing to setup @Produce and the likes on the bean
Added:
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MySender.java
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml
- copied, changed from r1310679, camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml
camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MySender.java
camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
Modified:
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Added: 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=1310725&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java Sat Apr 7 10:36:52 2012
@@ -0,0 +1,32 @@
+/**
+ * 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.apache.camel.Produce;
+
+/**
+ *
+ */
+public class MyProduceBean {
+
+ @Produce(uri = "mock:result")
+ MySender sender;
+
+ public void doSomething(String body) {
+ sender.send(body);
+ }
+}
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MySender.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MySender.java?rev=1310725&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MySender.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/MySender.java Sat Apr 7 10:36:52 2012
@@ -0,0 +1,25 @@
+/**
+ * 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;
+
+/**
+ *
+ */
+public interface MySender {
+
+ void send(String body);
+}
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java?rev=1310725&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java Sat Apr 7 10:36:52 2012
@@ -0,0 +1,42 @@
+/**
+ * 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.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ *
+ */
+public class ProduceBeanTest extends CamelSpringTestSupport {
+
+ @Test
+ public void testProduceBean() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/test/patterns/ProduceBeanTest.xml");
+ }
+}
Copied: camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml (from r1310679, camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml?p2=camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml&p1=camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml&r1=1310679&r2=1310725&rev=1310725&view=diff
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml (original)
+++ camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml Sat Apr 7 10:36:52 2012
@@ -16,22 +16,17 @@
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="
+ 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" trace="true" autoStartup="true" >
+<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
<route>
- <from uri="direct:start" />
- <to uri="mock:a" />
- <transform>
- <simple>Hello ${body}</simple>
- </transform>
- <to uri="mock:b" />
+ <from uri="direct:start"/>
+ <bean beanType="org.apache.camel.test.patterns.MyProduceBean"/>
</route>
</camelContext>
Modified: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java?rev=1310725&r1=1310724&r2=1310725&view=diff
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java (original)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java Sat Apr 7 10:36:52 2012
@@ -367,7 +367,7 @@ public abstract class CamelTestSupport e
// use the default bean post processor from camel-core
DefaultCamelBeanPostProcessor processor = new DefaultCamelBeanPostProcessor(context);
- processor.postProcessBeforeInitialization(this, "this");
+ processor.postProcessBeforeInitialization(this, getClass().getName());
}
protected void stopCamelContext() throws Exception {
Added: camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java?rev=1310725&view=auto
==============================================================================
--- camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java (added)
+++ camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java Sat Apr 7 10:36:52 2012
@@ -0,0 +1,32 @@
+/**
+ * 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.apache.camel.Produce;
+
+/**
+ *
+ */
+public class MyProduceBean {
+
+ @Produce(uri = "mock:result")
+ MySender sender;
+
+ public void doSomething(String body) {
+ sender.send(body);
+ }
+}
Added: camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MySender.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MySender.java?rev=1310725&view=auto
==============================================================================
--- camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MySender.java (added)
+++ camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/MySender.java Sat Apr 7 10:36:52 2012
@@ -0,0 +1,25 @@
+/**
+ * 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;
+
+/**
+ *
+ */
+public interface MySender {
+
+ void send(String body);
+}
Added: camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java?rev=1310725&view=auto
==============================================================================
--- camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java (added)
+++ camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java Sat Apr 7 10:36:52 2012
@@ -0,0 +1,47 @@
+/**
+ * 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.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class ProduceBeanTest extends CamelTestSupport {
+
+ @Test
+ public void testProduceBean() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .bean(MyProduceBean.class, "doSomething");
+ }
+ };
+ }
+}