activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r520900 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/resources/META-INF/services/org/...
Date Wed, 21 Mar 2007 14:37:14 GMT
Author: jstrachan
Date: Wed Mar 21 07:37:11 2007
New Revision: 520900

URL: http://svn.apache.org/viewvc?view=rev&rev=520900
Log:
added test cases showing the use of the errorHandler() DSL to configure error handlers for an entire set of routes or on a specific route. Also added a useful base class for test cases

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandler.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingLevel.java   (with props)
    activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/pojo
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java   (with props)
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java   (with props)
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java   (contents, props changed)
      - copied, changed from r520860, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java
    activemq/camel/trunk/camel-core/src/test/resources/log4j.properties   (with props)
    activemq/camel/trunk/camel-jms/src/test/resources/
    activemq/camel/trunk/camel-jms/src/test/resources/log4j.properties   (with props)
Removed:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java
    activemq/camel/trunk/camel-core/src/test/resources/META-INF/
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/InterceptorBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RecipientListBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java
    activemq/camel/trunk/camel-xbean/src/test/java/org/apache/camel/xbean/XBeanRouteBuilderTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java Wed Mar 21 07:37:11 2007
@@ -16,9 +16,11 @@
  */
 package org.apache.camel.builder;
 
-import org.apache.camel.Expression;
 import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
+import org.apache.camel.Expression;
+import org.apache.camel.processor.LoggingLevel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Base class for implementation inheritance
@@ -26,12 +28,17 @@
  * @version $Revision: $
  */
 public abstract class BuilderSupport<E extends Exchange> {
-
     private ErrorHandlerBuilder<E> errorHandlerBuilder;
-                                                    
+
     protected BuilderSupport() {
     }
 
+    protected BuilderSupport(BuilderSupport<E> parent) {
+        if (parent.errorHandlerBuilder != null) {
+            this.errorHandlerBuilder = parent.errorHandlerBuilder.copy();
+        }
+    }
+
     // Builder methods
     //-------------------------------------------------------------------------
 
@@ -75,16 +82,50 @@
         return new ValueBuilder<E>(expression);
     }
 
+    /**
+     * Creates a disabled error handler for removing the default error handler
+     */
+    public NoErrorHandlerBuilder<E> noErrorHandler() {
+        return new NoErrorHandlerBuilder<E>();
+    }
 
-    // Properties
-    //-------------------------------------------------------------------------
+    /**
+     * Creates an error handler which just logs errors
+     */
+    public LoggingErrorHandlerBuilder<E> loggingErrorHandler() {
+        return new LoggingErrorHandlerBuilder<E>();
+    }
 
-    protected BuilderSupport(BuilderSupport<E> parent) {
-        if (parent.errorHandlerBuilder != null) {
-            this.errorHandlerBuilder = parent.errorHandlerBuilder.copy();
-        }
+    /**
+     * Creates an error handler which just logs errors
+     */
+    public LoggingErrorHandlerBuilder<E> loggingErrorHandler(String log) {
+        return loggingErrorHandler(LogFactory.getLog(log));
     }
 
+    /**
+     * Creates an error handler which just logs errors
+     */
+    public LoggingErrorHandlerBuilder<E> loggingErrorHandler(Log log) {
+        return new LoggingErrorHandlerBuilder<E>(log);
+    }
+
+    /**
+     * Creates an error handler which just logs errors
+     */
+    public LoggingErrorHandlerBuilder<E> loggingErrorHandler(Log log, LoggingLevel level) {
+        return new LoggingErrorHandlerBuilder<E>(log, level);
+    }
+
+    /*
+    public DeadLetterChannelBuilder<E> deadLetterChannel() {
+        return new DeadLetterChannelBuilder<E>();
+    }
+    */
+
+    // Properties
+    //-------------------------------------------------------------------------
+
     public ErrorHandlerBuilder<E> getErrorHandlerBuilder() {
         if (errorHandlerBuilder == null) {
             errorHandlerBuilder = new DeadLetterChannelBuilder<E>();
@@ -98,5 +139,4 @@
     public void setErrorHandlerBuilder(ErrorHandlerBuilder<E> errorHandlerBuilder) {
         this.errorHandlerBuilder = errorHandlerBuilder;
     }
-
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java Wed Mar 21 07:37:11 2007
@@ -16,18 +16,19 @@
  */
 package org.apache.camel.builder;
 
-import org.apache.camel.processor.CompositeProcessor;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.camel.Processor;
+import org.apache.camel.processor.CompositeProcessor;
 import org.apache.camel.processor.InterceptorProcessor;
 import org.apache.camel.processor.MulticastProcessor;
 import org.apache.camel.processor.Pipeline;
-import org.apache.camel.Predicate;
-import org.apache.camel.Processor;
+import org.apache.camel.processor.RecipientList;
 
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Collection;
+import java.util.List;
 
 /**
  * @version $Revision$
@@ -39,11 +40,13 @@
     private List<ProcessorFactory<E>> processFactories = new ArrayList<ProcessorFactory<E>>();
 
     public FromBuilder(RouteBuilder<E> builder, Endpoint<E> from) {
+        super(builder);
         this.builder = builder;
         this.from = from;
     }
 
     public FromBuilder(FromBuilder<E> parent) {
+        super(parent);
         this.builder = parent.getBuilder();
         this.from = parent.getFrom();
     }
@@ -71,7 +74,6 @@
         return endpoints;
     }
 
-
     /**
      * Sends the exchange to the given endpoint URI
      */
@@ -88,7 +90,6 @@
         return answer;
     }
 
-
     /**
      * Sends the exchange to a list of endpoints using the {@link MulticastProcessor} pattern
      */
@@ -103,7 +104,6 @@
         return to(endpoints(endpoints));
     }
 
-
     /**
      * Sends the exchange to a list of endpoint using the {@link MulticastProcessor} pattern
      */
@@ -144,8 +144,6 @@
         return answer;
     }
 
-
-
     /**
      * Creates a predicate which is applied and only if it is true then
      * the exchange is forwarded to the destination
@@ -158,7 +156,6 @@
         return answer;
     }
 
-
     /**
      * Creates a choice of one or more predicates with an otherwise clause
      *
@@ -172,8 +169,8 @@
 
     /**
      * Creates a dynamic <a href="http://activemq.apache.org/camel/recipient-list.html">Recipient List</a> pattern.
-     * 
-     * @param valueBuilder
+     *
+     * @param valueBuilder is the builder of the expression used in the {@link RecipientList} to decide the destinations
      */
     public RecipientListBuilder<E> recipientList(ValueBuilder<E> valueBuilder) {
         RecipientListBuilder<E> answer = new RecipientListBuilder<E>(this, valueBuilder);
@@ -189,11 +186,22 @@
      * @return the builder
      */
     public SplitterBuilder<E> splitter(ValueBuilder<E> valueBuilder) {
-              SplitterBuilder<E> answer = new SplitterBuilder<E>(this, valueBuilder);
+        SplitterBuilder<E> answer = new SplitterBuilder<E>(this, valueBuilder);
         addProcessBuilder(answer);
         return answer;
     }
 
+    /**
+     * Installs the given error handler builder
+     *
+     * @param errorHandlerBuilder the error handler to be used by default for all child routes
+     * @return the current builder with the error handler configured
+     */
+    public FromBuilder<E> errorHandler(ErrorHandlerBuilder errorHandlerBuilder) {
+        setErrorHandlerBuilder(errorHandlerBuilder);
+        return this;
+    }
+
     // Properties
     //-------------------------------------------------------------------------
     public RouteBuilder<E> getBuilder() {
@@ -246,16 +254,16 @@
         return processors;
     }
 
-	public InterceptorBuilder<E> intercept() {
-		InterceptorBuilder<E> answer = new InterceptorBuilder<E>(this);
+    public InterceptorBuilder<E> intercept() {
+        InterceptorBuilder<E> answer = new InterceptorBuilder<E>(this);
         addProcessBuilder(answer);
         return answer;
-	}
-	
-	public InterceptorBuilder<E> intercept(InterceptorProcessor<E> interceptor) {
-		InterceptorBuilder<E> answer = new InterceptorBuilder<E>(this);
-		answer.add(interceptor);
+    }
+
+    public InterceptorBuilder<E> intercept(InterceptorProcessor<E> interceptor) {
+        InterceptorBuilder<E> answer = new InterceptorBuilder<E>(this);
+        answer.add(interceptor);
         addProcessBuilder(answer);
         return answer;
-	}
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/InterceptorBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/InterceptorBuilder.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/InterceptorBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/InterceptorBuilder.java Wed Mar 21 07:37:11 2007
@@ -34,7 +34,7 @@
 	private FromBuilder<E> target;
 
 	public InterceptorBuilder(FromBuilder<E> parent) {
-		this.parent = parent;
+        this.parent = parent;
 	}
 
 	public InterceptorBuilder<E> add(InterceptorProcessor<E> intercept) {

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java Wed Mar 21 07:37:11 2007
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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.builder;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.processor.Logger;
+import org.apache.camel.processor.LoggingLevel;
+import org.apache.camel.processor.LoggingErrorHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Uses the {@link Logger} as an error handler
+ * 
+ * @version $Revision$
+ */
+public class LoggingErrorHandlerBuilder<E extends Exchange> extends BuilderSupport<E> implements ErrorHandlerBuilder<E> {
+    private Log log = LogFactory.getLog(Logger.class);
+    private LoggingLevel level = LoggingLevel.INFO;
+
+    public LoggingErrorHandlerBuilder() {
+    }
+
+    public LoggingErrorHandlerBuilder(Log log) {
+        this.log = log;
+    }
+
+    public LoggingErrorHandlerBuilder(Log log, LoggingLevel level) {
+        this.log = log;
+        this.level = level;
+    }
+
+    public ErrorHandlerBuilder<E> copy() {
+        LoggingErrorHandlerBuilder<E> answer = new LoggingErrorHandlerBuilder<E>();
+        answer.setLog(getLog());
+        answer.setLevel(getLevel());
+        return answer;
+    }
+
+    public Processor<E> createErrorHandler(Processor<E> processor) {
+        return new LoggingErrorHandler<E>(processor, log, level);
+    }
+
+    public LoggingLevel getLevel() {
+        return level;
+    }
+
+    public void setLevel(LoggingLevel level) {
+        this.level = level;
+    }
+
+    public Log getLog() {
+        return log;
+    }
+
+    public void setLog(Log log) {
+        this.log = log;
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java Wed Mar 21 07:37:11 2007
@@ -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.builder;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+/**
+ * A builder to disable the use of an error handler so that any exceptions are thrown.
+ * This not recommended in general, the
+ * <a href="http://activemq.apache.org/camel/dead-letter-channel.html">Dead Letter Channel</a> should be used
+ * if you are unsure; however it can be useful sometimes to disable an error handler inside a complex route
+ * so that exceptions bubble up to the parent {@link Processor}
+ *
+ * @version $Revision$
+ */
+public class NoErrorHandlerBuilder<E extends Exchange> extends BuilderSupport<E> implements ErrorHandlerBuilder<E> {
+    public ErrorHandlerBuilder<E> copy() {
+        return this;
+    }
+
+    public Processor<E> createErrorHandler(Processor<E> processor) {
+        return processor;
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RecipientListBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RecipientListBuilder.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RecipientListBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RecipientListBuilder.java Wed Mar 21 07:37:11 2007
@@ -30,8 +30,8 @@
 public class RecipientListBuilder<E extends Exchange> extends BuilderSupport<E> implements ProcessorFactory<E> {
     private final ValueBuilder<E> valueBuilder;
 
-    public RecipientListBuilder(FromBuilder<E> fromBuilder, ValueBuilder<E> valueBuilder) {
-        super();
+    public RecipientListBuilder(FromBuilder<E> parent, ValueBuilder<E> valueBuilder) {
+        super(parent);
         this.valueBuilder = valueBuilder;
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java Wed Mar 21 07:37:11 2007
@@ -35,7 +35,7 @@
  * @version $Revision$
  */
 public abstract class RouteBuilder<E extends Exchange> extends BuilderSupport<E> {
-    private CamelContext<E> container;
+    private CamelContext<E> context;
     private List<FromBuilder<E>> fromBuilders = new ArrayList<FromBuilder<E>>();
     private AtomicBoolean initalized = new AtomicBoolean(false);
     private Map<Endpoint<E>, Processor<E>> routeMap = new HashMap<Endpoint<E>, Processor<E>>();
@@ -43,8 +43,8 @@
     protected RouteBuilder() {
     }
 
-    protected RouteBuilder(CamelContext<E> container) {
-        this.container = container;
+    protected RouteBuilder(CamelContext<E> context) {
+        this.context = context;
     }
 
     /**
@@ -56,7 +56,7 @@
      * Resolves the given URI to an endpoint
      */
     public Endpoint<E> endpoint(String uri) {
-         CamelContext<E> c = getContainer();
+         CamelContext<E> c = getContext();
          EndpointResolver<E> er = c.getEndpointResolver();
          return er.resolveEndpoint(c, uri);
     }
@@ -71,19 +71,28 @@
         return answer;
     }
 
+    /**
+     * Installs the given error handler builder
+     * @param errorHandlerBuilder the error handler to be used by default for all child routes
+     * @return the current builder with the error handler configured
+     */
+    public RouteBuilder<E> errorHandler(ErrorHandlerBuilder errorHandlerBuilder) {
+        setErrorHandlerBuilder(errorHandlerBuilder);
+        return this;
+    }
 
     // Properties
     //-----------------------------------------------------------------------
 
-    public CamelContext<E> getContainer() {
-        if (container == null) {
-            container = createContainer();
+    public CamelContext<E> getContext() {
+        if (context == null) {
+            context = createContainer();
         }
-        return container;
+        return context;
     }
 
-    public void setContainer(CamelContext<E> container) {
-        this.container = container;
+    public void setContext(CamelContext<E> context) {
+        this.context = context;
     }
 
     /**

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Wed Mar 21 07:37:11 2007
@@ -147,7 +147,7 @@
 
     public void setRoutes(RouteBuilder<E> builder) {
         // lets now add the routes from the builder
-        builder.setContainer(this);
+        builder.setContext(this);
         setRoutes(builder.getRouteMap());
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java Wed Mar 21 07:37:11 2007
@@ -29,7 +29,7 @@
  *
  * @version $Revision$
  */
-public class DeadLetterChannel<E extends Exchange> implements Processor<E> {
+public class DeadLetterChannel<E extends Exchange> implements ErrorHandler<E> {
     public static final String REDELIVERY_COUNT_HEADER = "org.apache.camel.redeliveryCount";
 
     private static final transient Log log = LogFactory.getLog(DeadLetterChannel.class);

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandler.java?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandler.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandler.java Wed Mar 21 07:37:11 2007
@@ -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.processor;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+/**
+ * An interface used to represent an error handler
+ *
+ * @version $Revision$
+ */
+public interface ErrorHandler<E extends Exchange> extends Processor<E> {
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java Wed Mar 21 07:37:11 2007
@@ -30,18 +30,24 @@
  */
 public class Logger<E extends Exchange> implements Processor<E> {
     private Log log;
-    private Level level = Level.INFO;
-
-    public static enum Level {
-        DEBUG, ERROR, FATAL, INFO, TRACE, WARN;
-    };
+    private LoggingLevel level;
 
     public Logger() {
         this(LogFactory.getLog(Logger.class));
     }
 
     public Logger(Log log) {
+        this(log, LoggingLevel.INFO);
+    }
+
+    public Logger(Log log, LoggingLevel level) {
         this.log = log;
+        this.level = level;
+    }
+
+    @Override
+    public String toString() {
+        return "Logger[" + log + "]";
     }
 
     public void onExchange(E exchange) {

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java Wed Mar 21 07:37:11 2007
@@ -0,0 +1,127 @@
+/**
+ *
+ * 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.processor;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * An {@link ErrorHandler} which uses commons-logging to dump the error
+ *
+ * @version $Revision$
+ */
+public class LoggingErrorHandler<E extends Exchange> implements ErrorHandler<E> {
+    private Processor<E> output;
+    private Log log;
+    private LoggingLevel level;
+
+    public LoggingErrorHandler(Processor<E> output) {
+        this(output, LogFactory.getLog(LoggingErrorHandler.class), LoggingLevel.INFO);
+    }
+
+    public LoggingErrorHandler(Processor<E> output, Log log, LoggingLevel level) {
+        this.output = output;
+        this.log = log;
+        this.level = level;
+    }
+
+    @Override
+    public String toString() {
+        return "LoggingErrorHandler[" + output + "]";
+    }
+
+    public void onExchange(E exchange) {
+        try {
+            output.onExchange(exchange);
+        }
+        catch (RuntimeException e) {
+            logError(exchange, e);
+        }
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+
+    /**
+     * Returns the output processor
+     */
+    public Processor<E> getOutput() {
+        return output;
+    }
+
+    public LoggingLevel getLevel() {
+        return level;
+    }
+
+    public void setLevel(LoggingLevel level) {
+        this.level = level;
+    }
+
+    public Log getLog() {
+        return log;
+    }
+
+    public void setLog(Log log) {
+        this.log = log;
+    }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+    protected void logError(E exchange, RuntimeException e) {
+        switch (level) {
+            case DEBUG:
+                if (log.isDebugEnabled()) {
+                    log.debug(logMessage(exchange, e), e);
+                }
+                break;
+            case ERROR:
+                if (log.isErrorEnabled()) {
+                    log.error(logMessage(exchange, e), e);
+                }
+                break;
+            case FATAL:
+                if (log.isFatalEnabled()) {
+                    log.fatal(logMessage(exchange, e), e);
+                }
+                break;
+            case INFO:
+                if (log.isInfoEnabled()) {
+                    log.debug(logMessage(exchange, e), e);
+                }
+                break;
+            case TRACE:
+                if (log.isTraceEnabled()) {
+                    log.trace(logMessage(exchange, e), e);
+                }
+                break;
+            case WARN:
+                if (log.isWarnEnabled()) {
+                    log.warn(logMessage(exchange, e), e);
+                }
+                break;
+            default:
+                log.error("Unknown level: " + level + " when trying to log exchange: " + logMessage(exchange, e), e);
+        }
+    }
+
+    protected Object logMessage(E exchange, RuntimeException e) {
+        return e + " while processing exchange: " + exchange;
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingLevel.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingLevel.java?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingLevel.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingLevel.java Wed Mar 21 07:37:11 2007
@@ -0,0 +1,27 @@
+/**
+ *
+ * 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.processor;
+
+/**
+ * Used to configure the logging levels
+ *
+ * @version $Revision$
+*/
+public enum LoggingLevel {
+    DEBUG, ERROR, FATAL, INFO, TRACE, WARN;
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingLevel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingLevel.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingLevel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/pojo
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/pojo?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/pojo (added)
+++ activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/pojo Wed Mar 21 07:37:11 2007
@@ -0,0 +1 @@
+class=org.apache.camel.pojo.PojoEndpointResolver

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java (added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java Wed Mar 21 07:37:11 2007
@@ -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;
+
+import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A bunch of useful testing methods
+ * 
+ * @version $Revision$
+ */
+public abstract class TestSupport extends TestCase {
+
+    protected transient Log log = LogFactory.getLog(getClass());
+
+    protected <T> T assertIsInstanceOf(Class<T> expectedType, Object value) {
+        assertNotNull("Expected an instance of type: " + expectedType.getName() + " but was null", value);
+        assertTrue("object should be a " + expectedType.getName() + " but was: " + value + " with type: " + value.getClass().getName(),
+                expectedType.isInstance(value));
+        return expectedType.cast(value);
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java (added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java Wed Mar 21 07:37:11 2007
@@ -0,0 +1,100 @@
+/**
+ *
+ * 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.builder;
+
+import junit.framework.TestCase;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.TestSupport;
+import org.apache.camel.processor.LoggingErrorHandler;
+import org.apache.camel.processor.SendProcessor;
+import org.apache.camel.processor.DeadLetterChannel;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @version $Revision$
+ */
+public class ErrorHandlerTest extends TestSupport {
+    public void testOverloadingTheDefaultErrorHandler() throws Exception {
+
+        // START SNIPPET: e1
+        RouteBuilder<Exchange> builder1 = new RouteBuilder<Exchange>() {
+            public void configure() {
+                errorHandler(loggingErrorHandler("FOO.BAR"));
+
+                from("queue:a").to("queue:b");
+            }
+        };
+        // END SNIPPET: e1
+        RouteBuilder<Exchange> builder = builder1;
+
+        Map<Endpoint<Exchange>, Processor<Exchange>> routeMap = builder.getRouteMap();
+        Set<Map.Entry<Endpoint<Exchange>, Processor<Exchange>>> routes = routeMap.entrySet();
+        assertEquals("Number routes created", 1, routes.size());
+        for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route : routes) {
+            Endpoint<Exchange> key = route.getKey();
+            assertEquals("From endpoint", "queue:a", key.getEndpointUri());
+            Processor processor = route.getValue();
+
+            LoggingErrorHandler loggingProcessor = assertIsInstanceOf(LoggingErrorHandler.class, processor);
+        }
+    }
+
+    public void testOverloadingTheHandlerOnASingleRoute() throws Exception {
+
+        // START SNIPPET: e2
+        RouteBuilder<Exchange> builder1 = new RouteBuilder<Exchange>() {
+            public void configure() {
+                from("queue:a").errorHandler(loggingErrorHandler("FOO.BAR")).to("queue:b");
+
+                // this route will use the default error handler, DeadLetterChannel
+                from("queue:b").to("queue:c");
+            }
+        };
+        // END SNIPPET: e2
+        RouteBuilder<Exchange> builder = builder1;
+
+        Map<Endpoint<Exchange>, Processor<Exchange>> routeMap = builder.getRouteMap();
+        log.info(routeMap);
+
+        Set<Map.Entry<Endpoint<Exchange>, Processor<Exchange>>> routes = routeMap.entrySet();
+        assertEquals("Number routes created", 2, routes.size());
+        for (Map.Entry<Endpoint<Exchange>, Processor<Exchange>> route : routes) {
+            Endpoint<Exchange> key = route.getKey();
+            String endpointUri = key.getEndpointUri();
+            Processor processor = route.getValue();
+
+            if (endpointUri.equals("queue:a")) {
+                LoggingErrorHandler loggingProcessor = assertIsInstanceOf(LoggingErrorHandler.class, processor);
+
+                Processor outputProcessor = loggingProcessor.getOutput();
+                SendProcessor sendProcessor = assertIsInstanceOf(SendProcessor.class, outputProcessor);
+            }
+            else {
+                assertEquals("From endpoint", "queue:b", endpointUri);
+
+                DeadLetterChannel deadLetterChannel = assertIsInstanceOf(DeadLetterChannel.class, processor);
+                Processor outputProcessor = deadLetterChannel.getOutput();
+                SendProcessor sendProcessor = assertIsInstanceOf(SendProcessor.class, outputProcessor);
+            }
+        }
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java (from r520860, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java?view=diff&rev=520900&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java&r1=520860&p2=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/RouteBuilderTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java Wed Mar 21 07:37:11 2007
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel;
+package org.apache.camel.builder;
 
 import junit.framework.TestCase;
 import org.apache.camel.builder.RouteBuilder;
@@ -26,6 +26,10 @@
 import org.apache.camel.processor.Splitter;
 import org.apache.camel.processor.DeadLetterChannel;
 import org.apache.camel.processor.MulticastProcessor;
+import org.apache.camel.TestSupport;
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.Endpoint;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -35,7 +39,7 @@
 /**
  * @version $Revision$
  */
-public class RouteBuilderTest extends TestCase {
+public class RouteBuilderTest extends TestSupport {
     protected Processor<Exchange> myProcessor = new Processor<Exchange>() {
         public void onExchange(Exchange exchange) {
             System.out.println("Called with exchange: " + exchange);
@@ -71,8 +75,7 @@
             assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = getProcessorWithoutErrorHandler(route);
 
-            assertTrue("Processor should be a SendProcessor but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof SendProcessor);
-            SendProcessor sendProcessor = (SendProcessor) processor;
+            SendProcessor sendProcessor = assertIsInstanceOf(SendProcessor.class, processor);
             assertEquals("Endpoint URI", "queue:b", sendProcessor.getDestination().getEndpointUri());
         }
     }
@@ -101,10 +104,8 @@
             assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = getProcessorWithoutErrorHandler(route);
 
-            assertTrue("Processor should be a FilterProcessor but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof FilterProcessor);
-            FilterProcessor filterProcessor = (FilterProcessor) processor;
-
-            SendProcessor sendProcessor = (SendProcessor) unwrapErrorHandler(filterProcessor.getProcessor());
+            FilterProcessor filterProcessor = assertIsInstanceOf(FilterProcessor.class, processor);
+    SendProcessor sendProcessor = assertIsInstanceOf(SendProcessor.class, unwrapErrorHandler(filterProcessor.getProcessor()));
             assertEquals("Endpoint URI", "queue:b", sendProcessor.getDestination().getEndpointUri());
         }
     }
@@ -137,9 +138,7 @@
             assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = getProcessorWithoutErrorHandler(route);
 
-            assertTrue("Processor should be a ChoiceProcessor but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof ChoiceProcessor);
-            ChoiceProcessor<Exchange> choiceProcessor = (ChoiceProcessor<Exchange>) processor;
-
+            ChoiceProcessor<Exchange> choiceProcessor = assertIsInstanceOf(ChoiceProcessor.class, processor);
             List<FilterProcessor<Exchange>> filters = choiceProcessor.getFilters();
             assertEquals("Should be two when clauses", 2, filters.size());
 
@@ -211,8 +210,7 @@
             assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = getProcessorWithoutErrorHandler(route);
 
-            assertTrue("Processor should be a FilterProcessor but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof FilterProcessor);
-            FilterProcessor filterProcessor = (FilterProcessor) processor;
+            FilterProcessor filterProcessor = assertIsInstanceOf(FilterProcessor.class, processor);
             assertEquals("Should be called with my processor", myProcessor, unwrapErrorHandler(filterProcessor.getProcessor()));
         }
     }
@@ -242,9 +240,7 @@
             assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = getProcessorWithoutErrorHandler(route);
 
-            assertTrue("Processor should be a MulticastProcessor but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof MulticastProcessor);
-            MulticastProcessor<Exchange> multicastProcessor = (MulticastProcessor<Exchange>) processor;
-
+            MulticastProcessor<Exchange> multicastProcessor = assertIsInstanceOf(MulticastProcessor.class, processor);
             List<Endpoint<Exchange>> endpoints = new ArrayList<Endpoint<Exchange>>(multicastProcessor.getEndpoints());
             assertEquals("Should have 2 endpoints", 2, endpoints.size());
 
@@ -293,12 +289,10 @@
             assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = getProcessorWithoutErrorHandler(route);
 
-            assertTrue("Processor should be a interceptor1 but was: " + processor + " with type: " + processor.getClass().getName(), processor==interceptor1);
-            InterceptorProcessor<Exchange> p1 = (InterceptorProcessor<Exchange>) processor;
-
+            InterceptorProcessor<Exchange> p1 = assertIsInstanceOf(InterceptorProcessor.class, processor);
             processor = p1.getNext();
-            assertTrue("Processor should be a interceptor2 but was: " + processor + " with type: " + processor.getClass().getName(), processor==interceptor2);
-            InterceptorProcessor<Exchange> p2 = (InterceptorProcessor<Exchange>) processor;
+
+            InterceptorProcessor<Exchange> p2 = assertIsInstanceOf(InterceptorProcessor.class, processor);
 
             assertSendTo(p2.getNext(), "queue:d");
         }
@@ -326,10 +320,9 @@
 
             System.out.println("processor: " + processor);
             /* TODO
-            assertTrue("Processor should be a FilterProcessor but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof FilterProcessor);
-            FilterProcessor filterProcessor = (FilterProcessor) processor;
+            FilterProcessor filterProcessor = assertIsInstanceOf(FilterProcessor.class, processor);
 
-            SendProcessor sendProcessor = (SendProcessor) filterProcessor.getProcessor();
+            SendProcessor sendProcessor = assertIsInstanceOf(SendProcessor.class, filterProcessor.getProcessor());
             assertEquals("Endpoint URI", "queue:b", sendProcessor.getDestination().getEndpointUri());
             */
         }
@@ -371,8 +364,7 @@
             assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = getProcessorWithoutErrorHandler(route);
 
-            assertTrue("Processor should be a RecipientList but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof RecipientList);
-            RecipientList<Exchange> p1 = (RecipientList<Exchange>) processor;
+            RecipientList<Exchange> p1 = assertIsInstanceOf(RecipientList.class, processor);
         }
     }
     protected RouteBuilder<Exchange> buildSplitter() {
@@ -400,17 +392,14 @@
             assertEquals("From endpoint", "queue:a", key.getEndpointUri());
             Processor processor = getProcessorWithoutErrorHandler(route);
 
-            assertTrue("Processor should be a Splitter but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof Splitter);
-            Splitter<Exchange> p1 = (Splitter<Exchange>) processor;
+            Splitter<Exchange> p1 = assertIsInstanceOf(Splitter.class, processor);
         }
     }
 
     protected void assertSendTo(Processor processor, String uri) {
         processor = unwrapErrorHandler(processor);
-        
-        assertTrue("Processor should be a SendProcessor but was: " + processor + " with type: " + processor.getClass().getName(), processor instanceof SendProcessor);
 
-        SendProcessor sendProcessor = (SendProcessor) processor;
+        SendProcessor sendProcessor = assertIsInstanceOf(SendProcessor.class, processor);
         assertEquals("Endpoint URI", uri, sendProcessor.getDestination().getEndpointUri());
     }
 

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/resources/log4j.properties?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-core/src/test/resources/log4j.properties Wed Mar 21 07:37:11 2007
@@ -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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.activemq=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

Propchange: activemq/camel/trunk/camel-core/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-core/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-jms/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/test/resources/log4j.properties?view=auto&rev=520900
==============================================================================
--- activemq/camel/trunk/camel-jms/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-jms/src/test/resources/log4j.properties Wed Mar 21 07:37:11 2007
@@ -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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.activemq=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

Propchange: activemq/camel/trunk/camel-jms/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-jms/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-jms/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: activemq/camel/trunk/camel-xbean/src/test/java/org/apache/camel/xbean/XBeanRouteBuilderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xbean/src/test/java/org/apache/camel/xbean/XBeanRouteBuilderTest.java?view=diff&rev=520900&r1=520899&r2=520900
==============================================================================
--- activemq/camel/trunk/camel-xbean/src/test/java/org/apache/camel/xbean/XBeanRouteBuilderTest.java (original)
+++ activemq/camel/trunk/camel-xbean/src/test/java/org/apache/camel/xbean/XBeanRouteBuilderTest.java Wed Mar 21 07:37:11 2007
@@ -17,7 +17,7 @@
 package org.apache.camel.xbean;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.RouteBuilderTest;
+import org.apache.camel.builder.RouteBuilderTest;
 import org.apache.camel.builder.RouteBuilder;
 
 /**



Mime
View raw message