camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r801084 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/ test/java/org/apache/camel/component/bean/issues/
Date Wed, 05 Aug 2009 08:29:02 GMT
Author: davsclaus
Date: Wed Aug  5 08:29:01 2009
New Revision: 801084

URL: http://svn.apache.org/viewvc?rev=801084&view=rev
Log:
A little code cleanup. Added unit test to CAMEL-1878.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseClass.java
  (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanRouteToDerivedClassTest.java
  (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/DerivedClass.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java?rev=801084&r1=801083&r2=801084&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java Wed Aug
 5 08:29:01 2009
@@ -107,29 +107,13 @@
      * @return the exchange
      */
     public Exchange send(Endpoint endpoint, ExchangePattern pattern, Processor processor)
{
-        return send(endpoint, pattern, processor, null);
-    }
-
-    /**
-     * Sends an exchange to an endpoint using a supplied
-     * {@link Processor} to populate the exchange
-     *
-     * @param endpoint the endpoint to send the exchange to
-     * @param pattern the message {@link ExchangePattern} such as
-     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
-     * @param processor the transformer used to populate the new exchange
-     * @param onCompletion  callback invoked when exchange has been completed
-     * @return the exchange
-     */
-    public Exchange send(Endpoint endpoint, ExchangePattern pattern, Processor processor,
Synchronization onCompletion) {
         try {
-            return sendExchange(endpoint, pattern, processor, null, onCompletion);
+            return sendExchange(endpoint, pattern, processor, null);
         } catch (Exception e) {
             throw wrapRuntimeCamelException(e);
         }
     }
 
-
     /**
      * Sends an exchange to an endpoint using a supplied callback
      *
@@ -168,11 +152,6 @@
 
     protected Exchange sendExchange(final Endpoint endpoint, ExchangePattern pattern,
                                     final Processor processor, Exchange exchange) throws
Exception {
-        return sendExchange(endpoint, pattern, processor, exchange, null);
-    }
-
-    protected Exchange sendExchange(final Endpoint endpoint, ExchangePattern pattern,
-                                    final Processor processor, Exchange exchange, final Synchronization
onCompletion) throws Exception {
         return doInProducer(endpoint, exchange, pattern, new ProducerCallback<Exchange>()
{
             public Exchange doInProducer(Producer producer, Exchange exchange, ExchangePattern
pattern) throws Exception {
                 if (exchange == null) {
@@ -184,10 +163,6 @@
                     processor.process(exchange);
                 }
 
-                if (onCompletion != null) {
-                    exchange.addOnCompletion(onCompletion);
-                }
-
                 // now lets dispatch
                 if (LOG.isDebugEnabled()) {
                     LOG.debug(">>>> " + endpoint + " " + exchange);

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseClass.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseClass.java?rev=801084&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseClass.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseClass.java
Wed Aug  5 08:29:01 2009
@@ -0,0 +1,29 @@
+/**
+ * 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.component.bean.issues;
+
+/**
+ * @version $Revision$
+ */
+public class BaseClass {
+
+    public void onMessage(String message) {
+        // noop
+    }
+    
+}
+

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseClass.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanRouteToDerivedClassTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanRouteToDerivedClassTest.java?rev=801084&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanRouteToDerivedClassTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanRouteToDerivedClassTest.java
Wed Aug  5 08:29:01 2009
@@ -0,0 +1,53 @@
+/**
+ * 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.component.bean.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+
+/**
+ * @version $Revision$
+ */
+public class BeanRouteToDerivedClassTest extends ContextTestSupport {
+
+    private DerivedClass derived = new DerivedClass();
+
+    public void testDerivedClassCalled() throws Exception {
+        template.sendBody("direct:start", "Hello World");
+
+        assertEquals("Derived class should have been invoked", "Hello World", derived.getBody());
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("derived", derived);
+        return jndi;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("bean:derived?method=process");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanRouteToDerivedClassTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanRouteToDerivedClassTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/DerivedClass.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/DerivedClass.java?rev=801084&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/DerivedClass.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/DerivedClass.java
Wed Aug  5 08:29:01 2009
@@ -0,0 +1,33 @@
+/**
+ * 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.component.bean.issues;
+
+/**
+ * @version $Revision$
+ */
+public class DerivedClass extends BaseClass {
+
+    private String body;
+
+    public void process(String body) {
+        this.body = body;
+    }
+
+    public String getBody() {
+        return body;
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/DerivedClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/issues/DerivedClass.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message