Author: davsclaus
Date: Mon May 30 07:24:24 2011
New Revision: 1129023

URL: http://svn.apache.org/viewvc?rev=1129023&view=rev
Log:
CAMEL-4025: Added unit test. Polished code.

Added:
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProduceBean.java
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.java
    
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.xml
      - copied, changed from r1129004, 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aopafter.xml
Modified:
    
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
    
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java

Modified: 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java?rev=1129023&r1=1129022&r2=1129023&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
 (original)
+++ 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
 Mon May 30 07:24:24 2011
@@ -55,7 +55,9 @@ import org.springframework.context.Appli
  * {@link org.apache.camel.Consume} annotation along with
  * <a href="http://camel.apache.org/pojo-producing.html";>POJO Producing</a> 
via the
  * {@link org.apache.camel.Produce} annotation along with other annotations 
such as
+ * {@link org.apache.camel.DynamicRouter} for creating <a 
href="http://camel.apache.org/dynamicrouter-annotation.html";>a Dynamic router 
via annotations</a>.
  * {@link org.apache.camel.RecipientList} for creating <a 
href="http://camel.apache.org/recipientlist-annotation.html";>a Recipient List 
router via annotations</a>.
+ * {@link org.apache.camel.RoutingSlip} for creating <a 
href="http://camel.apache.org/routingslip-annotation.html";>a Routing Slip 
router via annotations</a>.
  * <p>
  * If you use the &lt;camelContext&gt; element in your <a 
href="http://camel.apache.org/spring.html";>Spring XML</a>
  * then one of these bean post processors is implicitly installed and 
configured for you. So you should never have to

Modified: 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=1129023&r1=1129022&r2=1129023&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
 (original)
+++ 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
 Mon May 30 07:24:24 2011
@@ -103,7 +103,7 @@ public class CamelNamespaceHandler exten
         
         addBeanDefinitionParser("keyStoreParameters", 
KeyStoreParametersFactoryBean.class, true, true);
         addBeanDefinitionParser("secureRandomParameters", 
SecureRandomParametersFactoryBean.class, true, true);
-        registerBeanDefinitionParser("sslContextParameters", new 
SSLContextParametersFactoryBeanBeanDefinitionBarser());
+        registerBeanDefinitionParser("sslContextParameters", new 
SSLContextParametersFactoryBeanBeanDefinitionParser());
 
         addBeanDefinitionParser("proxy", CamelProxyFactoryBean.class, true, 
false);
         addBeanDefinitionParser("template", 
CamelProducerTemplateFactoryBean.class, true, false);
@@ -201,9 +201,9 @@ public class CamelNamespaceHandler exten
         return classes;
     }
     
-    protected class SSLContextParametersFactoryBeanBeanDefinitionBarser 
extends BeanDefinitionParser {
+    protected class SSLContextParametersFactoryBeanBeanDefinitionParser 
extends BeanDefinitionParser {
 
-        public SSLContextParametersFactoryBeanBeanDefinitionBarser() {
+        public SSLContextParametersFactoryBeanBeanDefinitionParser() {
             super(SSLContextParametersFactoryBean.class, true);
         }
 
@@ -236,7 +236,7 @@ public class CamelNamespaceHandler exten
                 builder.addPropertyValue("clientParameters", 
bean.getClientParameters());
                 builder.addPropertyValue("serverParameters", 
bean.getServerParameters());
             } else {
-                throw new BeanDefinitionStoreException("Parsed type is not of 
the expected type.  Expected "
+                throw new BeanDefinitionStoreException("Parsed type is not of 
the expected type. Expected "
                                                        + 
SSLContextParametersFactoryBean.class.getName() + " but found "
                                                        + 
value.getClass().getName());
             }
@@ -270,13 +270,9 @@ public class CamelNamespaceHandler exten
 
             // lets inject the namespaces into any namespace aware POJOs
             injectNamespaces(element, binder);
-
-            // TODO: We need to inject bean post processors
-            // but we need to camelContext id its referred from
         }
     }
 
-
     protected class CamelContextBeanDefinitionParser extends 
BeanDefinitionParser {
 
         public CamelContextBeanDefinitionParser(Class type) {

Added: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProduceBean.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProduceBean.java?rev=1129023&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProduceBean.java
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/MyProduceBean.java
 Mon May 30 07:24:24 2011
@@ -0,0 +1,34 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+
+/**
+ *
+ */
+public class MyProduceBean {
+
+    @Produce(uri = "seda:bar")
+    private ProducerTemplate bar;
+
+    public void doSomething(String s) {
+        bar.sendBody(s);
+    }
+
+}

Added: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.java?rev=1129023&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.java
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.java
 Mon May 30 07:24:24 2011
@@ -0,0 +1,40 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ *
+ */
+public class SpringRouteContextProduceBeanTest extends SpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.xml");
+    }
+
+    public void testRouteContextProduceBean() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+}

Copied: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.xml
 (from r1129004, 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aopafter.xml)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aopafter.xml&r1=1129004&r2=1129023&rev=1129023&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aopafter.xml
 (original)
+++ 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteContextProduceBeanTest.xml
 Mon May 30 07:24:24 2011
@@ -22,16 +22,21 @@
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <!-- START SNIPPET: e1 -->
-    <camelContext xmlns="http://camel.apache.org/schema/spring";>
-        <route>
-            <from uri="direct:start"/>
-            <aop afterUri="mock:after">
-                <transform><constant>Bye World</constant></transform>
-                <to uri="mock:result"/>
-            </aop>
-        </route>
-    </camelContext>
-    <!-- END SNIPPET: e1 -->
+  <bean id="myBean" class="org.apache.camel.spring.processor.MyProduceBean"/>
+
+  <routeContext id="myRoutes" xmlns="http://camel.apache.org/schema/spring";>
+    <route>
+      <from uri="direct:start"/>
+      <bean ref="myBean"/>
+    </route>
+    <route>
+      <from uri="seda:bar"/>
+      <to uri="mock:result"/>
+    </route>
+  </routeContext>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring";>
+    <routeContextRef ref="myRoutes"/>
+  </camelContext>
 
 </beans>


Reply via email to