camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r724426 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/component/mock/ camel-core/src/main/java/org/apache/camel/impl/ components/camel-spring/src/main/java/org/apache/camel/spring/ components/camel-spring/src/test/ja...
Date Mon, 08 Dec 2008 17:51:51 GMT
Author: jstrachan
Date: Mon Dec  8 09:51:50 2008
New Revision: 724426

URL: http://svn.apache.org/viewvc?rev=724426&view=rev
Log:
added test case and fix for CAMEL-1157

Added:
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/EndpointUriSetFromSpringTest.java
  (with props)
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/EndpointUriSetFromSpringTest-context.xml
  (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?rev=724426&r1=724425&r2=724426&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
Mon Dec  8 09:51:50 2008
@@ -85,6 +85,9 @@
         init();
     }
 
+    public MockEndpoint() {
+        this(null);
+    }
 
     /**
      * A helper method to resolve the mock endpoint of the given URI on the given context

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java?rev=724426&r1=724425&r2=724426&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
Mon Dec  8 09:51:50 2008
@@ -194,6 +194,16 @@
         return null;
     }
 
+    /**
+     * Sets the endpointUri if it has not been specified yet via some kind of dependency
injection mechanism.
+     * This allows dependency injection frameworks such as Spring or Guice to set the default
endpoint URI in cases
+     * where it has not been explicitly configured using the name/context in which an Endpoint
is created.
+     */
+    public void setEndpointUriIfNotSpecified(String value) {
+        if (endpointUri == null) {
+            setEndpointUri(value);
+        }
+    }
     protected void setEndpointUri(String endpointUri) {
         this.endpointUri = endpointUri;
     }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java?rev=724426&r1=724425&r2=724426&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
Mon Dec  8 09:51:50 2008
@@ -30,6 +30,7 @@
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Produce;
 import org.apache.camel.impl.CamelPostProcessorHelper;
+import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spring.util.ReflectionUtils;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
@@ -86,6 +87,10 @@
     }
 
     public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
{
+        if (bean instanceof DefaultEndpoint) {
+            DefaultEndpoint defaultEndpoint = (DefaultEndpoint) bean;
+            defaultEndpoint.setEndpointUriIfNotSpecified(beanName);
+        }
         return bean;
     }
 

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/EndpointUriSetFromSpringTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/EndpointUriSetFromSpringTest.java?rev=724426&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/EndpointUriSetFromSpringTest.java
(added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/EndpointUriSetFromSpringTest.java
Mon Dec  8 09:51:50 2008
@@ -0,0 +1,44 @@
+/**
+ *
+ * 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.config;
+
+import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+import org.springframework.test.context.ContextConfiguration;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.annotation.Resource;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@ContextConfiguration
+public class EndpointUriSetFromSpringTest extends AbstractJUnit38SpringContextTests {
+    private static final transient Log LOG = LogFactory.getLog(EndpointUriSetFromSpringTest.class);
+
+    @Resource(name = "foo:bar")
+    MockEndpoint endpoint;
+
+    public void testEndpointCreatedWithCorrectUri() throws Exception {
+        assertNotNull("foo", endpoint);
+        assertEquals("foo.getEndpointUri()", "foo:bar", endpoint.getEndpointUri());
+        LOG.info("Found endpoint " + endpoint + " with URI: " + endpoint.getEndpointUri());
+    }
+
+}

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/EndpointUriSetFromSpringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/EndpointUriSetFromSpringTest-context.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/EndpointUriSetFromSpringTest-context.xml?rev=724426&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/EndpointUriSetFromSpringTest-context.xml
(added)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/EndpointUriSetFromSpringTest-context.xml
Mon Dec  8 09:51:50 2008
@@ -0,0 +1,29 @@
+<?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://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+  </camelContext>
+
+  <bean name="foo:bar" class="org.apache.camel.component.mock.MockEndpoint"/>
+</beans>

Propchange: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/EndpointUriSetFromSpringTest-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message