camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r919719 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ components/camel-spring/src/main/java/org/apache/camel/spring/ components/camel-spring/src/test/java/org/apache...
Date Sat, 06 Mar 2010 09:09:06 GMT
Author: davsclaus
Date: Sat Mar  6 09:09:05 2010
New Revision: 919719

URL: http://svn.apache.org/viewvc?rev=919719&view=rev
Log:
CAMEL-1437: Added custom executor service strategy test.

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategy.java
  (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest.java
      - copied, changed from r919409, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DefaultErrorHandlerConfigTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest-context.xml
      - copied, changed from r919409, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DefaultErrorHandlerConfigTest-context.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StreamResequencer.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java?rev=919719&r1=919718&r2=919719&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
Sat Mar  6 09:09:05 2010
@@ -270,7 +270,7 @@
             StreamResequencerConfig config) throws Exception {
         config.getComparator().setExpressions(resolveExpressionList(routeContext));
         Processor processor = routeContext.createProcessor(this);
-        StreamResequencer resequencer = new StreamResequencer(processor, config.getComparator());
+        StreamResequencer resequencer = new StreamResequencer(routeContext.getCamelContext(),
processor, config.getComparator());
         resequencer.setTimeout(config.getTimeout());
         resequencer.setCapacity(config.getCapacity());
         return resequencer;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StreamResequencer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StreamResequencer.java?rev=919719&r1=919718&r2=919719&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StreamResequencer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StreamResequencer.java
Sat Mar  6 09:09:05 2010
@@ -23,7 +23,7 @@
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.camel.CamelException;
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Navigate;
 import org.apache.camel.Processor;
@@ -33,8 +33,8 @@
 import org.apache.camel.processor.resequencer.SequenceElementComparator;
 import org.apache.camel.processor.resequencer.SequenceSender;
 import org.apache.camel.spi.ExceptionHandler;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
-import org.apache.camel.util.concurrent.ExecutorServiceHelper;
 
 /**
  * A resequencer that re-orders a (continuous) stream of {@link Exchange}s. The
@@ -61,7 +61,8 @@
 public class StreamResequencer extends ServiceSupport implements SequenceSender<Exchange>,
Processor, Navigate<Processor>, Traceable {
 
     private static final long DELIVERY_ATTEMPT_INTERVAL = 1000L;
-    
+
+    private final CamelContext camelContext;
     private final ExceptionHandler exceptionHandler;
     private final ResequencerEngine<Exchange> engine;
     private final Processor processor;
@@ -74,7 +75,9 @@
      * @param processor next processor that processes re-ordered exchanges.
      * @param comparator a sequence element comparator for exchanges.
      */
-    public StreamResequencer(Processor processor, SequenceElementComparator<Exchange>
comparator) {
+    public StreamResequencer(CamelContext camelContext, Processor processor, SequenceElementComparator<Exchange>
comparator) {
+        ObjectHelper.notNull(camelContext, "CamelContext");
+        this.camelContext = camelContext;
         this.exceptionHandler = new LoggingExceptionHandler(getClass());
         this.engine = new ResequencerEngine<Exchange>(comparator);
         this.engine.setSequenceSender(this);
@@ -189,7 +192,7 @@
         private Condition deliveryRequestCondition = deliveryRequestLock.newCondition();
         
         public Delivery() {
-            super(ExecutorServiceHelper.getThreadName("Resequencer Delivery"));
+            super(camelContext.getExecutorServiceStrategy().getThreadName("Resequencer Delivery"));
         }
         
         @Override

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=919719&r1=919718&r2=919719&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Sat Mar  6 09:09:05 2010
@@ -64,6 +64,7 @@
 import org.apache.camel.spi.ClassResolver;
 import org.apache.camel.spi.EventFactory;
 import org.apache.camel.spi.EventNotifier;
+import org.apache.camel.spi.ExecutorServiceStrategy;
 import org.apache.camel.spi.FactoryFinderResolver;
 import org.apache.camel.spi.InflightRepository;
 import org.apache.camel.spi.InterceptStrategy;
@@ -208,8 +209,13 @@
             LOG.info("Using custom FactoryFinderResolver: " + factoryFinderResolver);
             getContext().setFactoryFinderResolver(factoryFinderResolver);
         }
+        ExecutorServiceStrategy executorServiceStrategy = getBeanForType(ExecutorServiceStrategy.class);
+        if (executorServiceStrategy != null) {
+            LOG.info("Using custom ExecutorServiceStrategy: " + executorServiceStrategy);
+            getContext().setExecutorServiceStrategy(executorServiceStrategy);
+        }
 
-        // set the strategy if defined
+        // set the custom registry if defined
         Registry registry = getBeanForType(Registry.class);
         if (registry != null) {
             LOG.info("Using custom Registry: " + registry);

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategy.java?rev=919719&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategy.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategy.java
Sat Mar  6 09:09:05 2010
@@ -0,0 +1,30 @@
+/**
+ * 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.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultExecutorServiceStrategy;
+
+/**
+ * @version $Revision$
+ */
+public class CustomExecutorServiceStrategy extends DefaultExecutorServiceStrategy {
+
+    public CustomExecutorServiceStrategy(CamelContext camelContext) {
+        super(camelContext);
+    }
+}

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

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

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest.java
(from r919409, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DefaultErrorHandlerConfigTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DefaultErrorHandlerConfigTest.java&r1=919409&r2=919719&rev=919719&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DefaultErrorHandlerConfigTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest.java
Sat Mar  6 09:09:05 2010
@@ -16,9 +16,8 @@
  */
 package org.apache.camel.spring.config;
 
+import junit.framework.Assert;
 import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.mock.MockEndpoint;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
@@ -27,30 +26,13 @@
  * @version $Revision$
  */
 @ContextConfiguration
-public class DefaultErrorHandlerConfigTest extends AbstractJUnit38SpringContextTests {
-
-    @Autowired
-    protected ProducerTemplate template;
+public class CustomExecutorServiceStrategyTest extends AbstractJUnit38SpringContextTests
{
 
     @Autowired
     protected CamelContext context;
 
-    protected Object expectedBody = "<hello>world!</hello>";
-
-    public void testRouteInheritsConfiguredErrorHandler() throws Exception {
-        assertReceivedMessageWithErrorHandlerValue("foo", null);
-    }
-
-    public void testRouteConfiguredErrorHandler() throws Exception {
-        assertReceivedMessageWithErrorHandlerValue("bar", null);
-    }
-
-    protected void assertReceivedMessageWithErrorHandlerValue(String name, String value)
throws Exception {
-        template.sendBody("direct:" + name, expectedBody);
-
-        MockEndpoint endpoint = MockEndpoint.resolve(context, "mock:" + name);
-        endpoint.expectedMessageCount(1);
-        endpoint.assertIsSatisfied();
+    public void testCustomExecutorService() throws Exception {
+        Assert.assertTrue(context.getExecutorServiceStrategy() instanceof CustomExecutorServiceStrategy);
     }
 
 }
\ No newline at end of file

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest-context.xml
(from r919409, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DefaultErrorHandlerConfigTest-context.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest-context.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest-context.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DefaultErrorHandlerConfigTest-context.xml&r1=919409&r2=919719&rev=919719&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DefaultErrorHandlerConfigTest-context.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/CustomExecutorServiceStrategyTest-context.xml
Sat Mar  6 09:09:05 2010
@@ -22,21 +22,15 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <camelContext xmlns="http://camel.apache.org/schema/spring">
-        <template id="myTemplate"/>
+    <bean id="myCustomPoolStrategy" class="org.apache.camel.spring.config.CustomExecutorServiceStrategy">
+        <constructor-arg index="0" ref="camel"/>
+    </bean>
 
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <route>
             <from uri="direct:foo"/>
             <to uri="mock:foo"/>
         </route>
-        <route errorHandlerRef="dlc">
-            <from uri="direct:bar"/>
-            <to uri="mock:bar"/>
-        </route>
     </camelContext>
 
-    <bean id="dlc" class="org.apache.camel.builder.DeadLetterChannelBuilder">
-        <property name="deadLetterUri" value="mock:dead"/>
-    </bean>
-
 </beans>



Mime
View raw message