camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r788297 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/component/bean/ camel-core/src/main/java/org/apache/camel/impl/ components/camel-spring/src/main/java/org/apache/camel/spring/ c...
Date Thu, 25 Jun 2009 09:01:10 GMT
Author: davsclaus
Date: Thu Jun 25 09:01:10 2009
New Revision: 788297

URL: http://svn.apache.org/viewvc?rev=788297&view=rev
Log:
CAMEL-1758: Added context attribute to Camel annotations to apply it for only that particual
camel context id/name. Needed for users having multiple camel contexts.

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel1Consumer.java
  (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2Consumer.java
  (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2RecipientList.java
  (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
  (contents, props changed)
      - copied, changed from r788262, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoConsumerTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/Consume.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/EndpointInject.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/Produce.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/RecipientList.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoConsumer.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Consume.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Consume.java?rev=788297&r1=788296&r2=788297&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Consume.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Consume.java Thu Jun 25 09:01:10
2009
@@ -38,6 +38,6 @@
 @Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
 public @interface Consume {
     String uri() default "";
-
     String ref() default "";
+    String context() default "";
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/EndpointInject.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/EndpointInject.java?rev=788297&r1=788296&r2=788297&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/EndpointInject.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/EndpointInject.java Thu Jun 25 09:01:10
2009
@@ -40,4 +40,5 @@
 public @interface EndpointInject {
     String uri() default "";
     String name() default "";
+    String context() default "";
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Produce.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Produce.java?rev=788297&r1=788296&r2=788297&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Produce.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Produce.java Thu Jun 25 09:01:10
2009
@@ -40,6 +40,6 @@
 @Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
 public @interface Produce {
     String uri() default "";
-
     String ref() default "";
+    String context() default "";
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/RecipientList.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/RecipientList.java?rev=788297&r1=788296&r2=788297&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/RecipientList.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/RecipientList.java Thu Jun 25 09:01:10
2009
@@ -43,4 +43,5 @@
 @Documented
 @Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
 public @interface RecipientList {
+    String context() default "";
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java?rev=788297&r1=788296&r2=788297&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java Thu
Jun 25 09:01:10 2009
@@ -317,7 +317,7 @@
         }
 
         // now lets add the method to the repository
-        return new MethodInfo(clazz, method, parameters, bodyParameters, hasCustomAnnotation,
hasHandlerAnnotation);
+        return new MethodInfo(camelContext, clazz, method, parameters, bodyParameters, hasCustomAnnotation,
hasHandlerAnnotation);
     }
 
     /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java?rev=788297&r1=788296&r2=788297&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java Thu
Jun 25 09:01:10 2009
@@ -25,6 +25,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Expression;
@@ -45,6 +46,7 @@
 public class MethodInfo {
     private static final transient Log LOG = LogFactory.getLog(MethodInfo.class);
 
+    private CamelContext camelContext;
     private Class type;
     private Method method;
     private final List<ParameterInfo> parameters;
@@ -55,8 +57,9 @@
     private ExchangePattern pattern = ExchangePattern.InOut;
     private RecipientList recipientList;
 
-    public MethodInfo(Class type, Method method, List<ParameterInfo> parameters, List<ParameterInfo>
bodyParameters,
+    public MethodInfo(CamelContext camelContext, Class type, Method method, List<ParameterInfo>
parameters, List<ParameterInfo> bodyParameters,
                       boolean hasCustomAnnotation, boolean hasHandlerAnnotation) {
+        this.camelContext = camelContext;
         this.type = type;
         this.method = method;
         this.parameters = parameters;
@@ -64,15 +67,32 @@
         this.hasCustomAnnotation = hasCustomAnnotation;
         this.hasHandlerAnnotation = hasHandlerAnnotation;
         this.parametersExpression = createParametersExpression();
+
         Pattern oneway = findOneWayAnnotation(method);
         if (oneway != null) {
             pattern = oneway.value();
         }
-        if (method.getAnnotation(org.apache.camel.RecipientList.class) != null) {
+
+        if (method.getAnnotation(org.apache.camel.RecipientList.class) != null
+                && matchContext(method.getAnnotation(org.apache.camel.RecipientList.class).context()))
{
             recipientList = new RecipientList();
         }
     }
 
+    /**
+     * Does the given context match this camel context
+     */
+    private boolean matchContext(String context) {
+        if (ObjectHelper.isNotEmpty(context)) {
+            if (!camelContext.getName().equals(context)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+
+
     public String toString() {
         return method.toString();
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java?rev=788297&r1=788296&r2=788297&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java
Thu Jun 25 09:01:10 2009
@@ -65,9 +65,21 @@
         this.camelContext = camelContext;
     }
 
+    /**
+     * Does the given context match this camel context
+     */
+    public boolean matchContext(String context) {
+        if (ObjectHelper.isNotEmpty(context)) {
+            if (!camelContext.getName().equals(context)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     public void consumerInjection(Method method, Object bean) {
         Consume consume = method.getAnnotation(Consume.class);
-        if (consume != null) {
+        if (consume != null && matchContext(consume.context())) {
             LOG.info("Creating a consumer for: " + consume);
             subscribeMethod(method, bean, consume.uri(), consume.ref());
         }

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=788297&r1=788296&r2=788297&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
Thu Jun 25 09:01:10 2009
@@ -87,8 +87,10 @@
         if (camelContext == null && applicationContext.containsBean(camelId)) {
             setCamelContext((CamelContext) applicationContext.getBean(camelId));
         }
+
         injectFields(bean);
         injectMethods(bean);
+
         if (bean instanceof CamelContextAware) {
             CamelContextAware contextAware = (CamelContextAware)bean;
             if (camelContext == null) {
@@ -97,6 +99,7 @@
                 contextAware.setCamelContext(camelContext);
             }
         }
+
         return bean;
     }
 
@@ -114,6 +117,7 @@
             DefaultEndpoint defaultEndpoint = (DefaultEndpoint) bean;
             defaultEndpoint.setEndpointUriIfNotSpecified(beanName);
         }
+
         return bean;
     }
 
@@ -176,12 +180,13 @@
     protected void injectFields(final Object bean) {
         ReflectionUtils.doWithFields(bean.getClass(), new ReflectionUtils.FieldCallback()
{
             public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException
{
-                EndpointInject annotation = field.getAnnotation(EndpointInject.class);
-                if (annotation != null) {
-                    injectField(field, annotation.uri(), annotation.name(), bean);
+                EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
+                if (endpointInject != null && postProcessor.matchContext(endpointInject.context()))
{
+                    injectField(field, endpointInject.uri(), endpointInject.name(), bean);
                 }
+
                 Produce produce = field.getAnnotation(Produce.class);
-                if (produce != null) {
+                if (produce != null && postProcessor.matchContext(produce.context()))
{
                     injectField(field, produce.uri(), produce.ref(), bean);
                 }
             }
@@ -203,12 +208,13 @@
     }
 
     protected void setterInjection(Method method, Object bean) {
-        EndpointInject annoation = method.getAnnotation(EndpointInject.class);
-        if (annoation != null) {
-            setterInjection(method, bean, annoation.uri(), annoation.name());
+        EndpointInject endpointInject = method.getAnnotation(EndpointInject.class);
+        if (endpointInject != null && postProcessor.matchContext(endpointInject.context()))
{
+            setterInjection(method, bean, endpointInject.uri(), endpointInject.name());
         }
+
         Produce produce = method.getAnnotation(Produce.class);
-        if (produce != null) {
+        if (produce != null && postProcessor.matchContext(produce.context())) {
             setterInjection(method, bean, produce.uri(), produce.ref());
         }
     }
@@ -230,4 +236,5 @@
         ObjectHelper.notNull(postProcessor, "postProcessor");
         return postProcessor;
     }
+
 }

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel1Consumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel1Consumer.java?rev=788297&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel1Consumer.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel1Consumer.java
Thu Jun 25 09:01:10 2009
@@ -0,0 +1,52 @@
+/**
+ * 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.example;
+
+import org.apache.camel.Consume;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision$
+ */
+public class MyCamel1Consumer {
+
+    private static final Log LOG = LogFactory.getLog(MyCamel1Consumer.class);
+
+    @EndpointInject(uri = "mock:result", context = "camel-1")
+    private ProducerTemplate destination;
+
+    @Consume(uri = "direct:start", context = "camel-1")
+    public void doSomething(String body) {
+        ObjectHelper.notNull(destination, "destination");
+
+        LOG.info("Received body: " + body);
+        destination.sendBody(body);
+    }
+
+    public ProducerTemplate getDestination() {
+        return destination;
+    }
+
+    public void setDestination(ProducerTemplate destination) {
+        this.destination = destination;
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel1Consumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel1Consumer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2Consumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2Consumer.java?rev=788297&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2Consumer.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2Consumer.java
Thu Jun 25 09:01:10 2009
@@ -0,0 +1,52 @@
+/**
+ * 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.example;
+
+import org.apache.camel.Consume;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision$
+ */
+public class MyCamel2Consumer {
+
+    private static final Log LOG = LogFactory.getLog(MyCamel2Consumer.class);
+
+    @EndpointInject(uri = "mock:result", context = "camel-2")
+    private ProducerTemplate destination;
+
+    @Consume(uri = "direct:start", context = "camel-2")
+    public void doSomething(String body) {
+        ObjectHelper.notNull(destination, "destination");
+
+        LOG.info("Received body: " + body);
+        destination.sendBody(body);
+    }
+
+    public ProducerTemplate getDestination() {
+        return destination;
+    }
+
+    public void setDestination(ProducerTemplate destination) {
+        this.destination = destination;
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2Consumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2Consumer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2RecipientList.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2RecipientList.java?rev=788297&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2RecipientList.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2RecipientList.java
Thu Jun 25 09:01:10 2009
@@ -0,0 +1,39 @@
+/**
+ * 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.example;
+
+import org.apache.camel.Consume;
+import org.apache.camel.RecipientList;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision$
+ */
+public class MyCamel2RecipientList {
+
+    private static final Log LOG = LogFactory.getLog(MyCamel2RecipientList.class);
+
+    @Consume(uri = "direct:foo", context = "camel-2")
+    @RecipientList(context = "camel-2")
+    public String[] doSomething(String body) {
+        LOG.info("Received body: " + body);
+
+        return new String[]{"mock:foo", "mock:result"};
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2RecipientList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyCamel2RecipientList.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
(from r788262, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoConsumerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoConsumerTest.java&r1=788262&r2=788297&rev=788297&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoConsumerTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
Thu Jun 25 09:01:10 2009
@@ -16,38 +16,85 @@
  */
 package org.apache.camel.spring.example;
 
+import org.apache.camel.CamelContext;
+import org.apache.camel.TestSupport;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.spring.SpringTestSupport;
-import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * @version $Revision$
  */
-public class PojoConsumerTest extends SpringTestSupport {
-    protected MockEndpoint resultEndpoint;
+public class PojoDualCamelContextConsumerTest extends TestSupport {
+    private CamelContext camel1;
+    private CamelContext camel2;
+    private ApplicationContext ac;
 
-    public void testMessagesSentToConsumerArrive() throws Exception {
+    public void testCamel1() throws Exception {
         String body = "<hello>world!</hello>";
-        resultEndpoint.expectedBodiesReceived(body);
 
-        template.sendBody("direct:start", body);
+        MockEndpoint result = camel1.getEndpoint("mock:result", MockEndpoint.class);
+        result.expectedBodiesReceived(body);
 
-        resultEndpoint.assertIsSatisfied();
+        camel1.createProducerTemplate().sendBody("direct:start", body);
+
+        result.assertIsSatisfied();
+    }
+
+    public void testCamel2() throws Exception {
+        String body = "<bye>world!</bye>";
+
+        MockEndpoint result = camel2.getEndpoint("mock:result", MockEndpoint.class);
+        result.expectedBodiesReceived(body);
+
+        camel2.createProducerTemplate().sendBody("direct:start", body);
+
+        result.assertIsSatisfied();
+    }
+
+    public void testCamel1RecipientList() throws Exception {
+        String body = "<hello>world!</hello>";
+
+        // direct:foo has no consumer in camel-1 so we should not expect any messages to
be routed to result/foo
+        MockEndpoint result = camel1.getEndpoint("mock:result", MockEndpoint.class);
+        result.expectedMessageCount(0);
+
+        camel1.createProducerTemplate().sendBody("direct:foo", body);
+
+        Thread.sleep(200);
+        
+        result.assertIsSatisfied();
+    }
+
+    public void testCamel2RecipientList() throws Exception {
+        String body = "<bye>world!</bye>";
+
+        MockEndpoint result = camel2.getEndpoint("mock:result", MockEndpoint.class);
+        result.expectedBodiesReceived(body);
+
+        MockEndpoint foo = camel2.getEndpoint("mock:foo", MockEndpoint.class);
+        foo.expectedBodiesReceived(body);
+
+        camel2.createProducerTemplate().sendBody("direct:foo", body);
+
+        result.assertIsSatisfied();
+        foo.assertIsSatisfied();
     }
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
 
-        resultEndpoint = getMockEndpoint("mock:result");
+        ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml");
+        camel1 = (CamelContext) ac.getBean("camel-1");
+        camel2 = (CamelContext) ac.getBean("camel-2");
     }
 
-    protected AbstractXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/spring/example/pojoConsumer.xml");
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        camel1.stop();
+        camel2.stop();
     }
 
-    protected int getExpectedRouteCount() {
-        return 0;
-    }
-}
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoConsumer.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoConsumer.xml?rev=788297&r1=788296&r2=788297&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoConsumer.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoConsumer.xml
Thu Jun 25 09:01:10 2009
@@ -24,7 +24,6 @@
 
   <!-- START SNIPPET: example -->
   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-    <beanPostProcessor/>
   </camelContext>
   <!-- END SNIPPET: example -->
 

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml?rev=788297&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml
(added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml
Thu Jun 25 09:01:10 2009
@@ -0,0 +1,36 @@
+<?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"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+
+    <camelContext id="camel-1" xmlns="http://camel.apache.org/schema/spring">
+    </camelContext>
+
+    <camelContext id="camel-2" xmlns="http://camel.apache.org/schema/spring">
+    </camelContext>
+
+    <bean id="myCamel1Consumer" class="org.apache.camel.spring.example.MyCamel1Consumer"/>
+    <bean id="myCamel2Consumer" class="org.apache.camel.spring.example.MyCamel2Consumer"/>
+    <bean id="myCamel2RecipeintList" class="org.apache.camel.spring.example.MyCamel2RecipientList"/>
+
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/example/pojoDualCamelContextConsumer.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message