camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rom...@apache.org
Subject svn commit: r614843 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
Date Thu, 24 Jan 2008 11:22:46 GMT
Author: romkal
Date: Thu Jan 24 03:22:39 2008
New Revision: 614843

URL: http://svn.apache.org/viewvc?rev=614843&view=rev
Log:
CAMEL-309 : added whenAnyExchangeReceived() for MockEndpoint to specify default behaviour
of the endpoint

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.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=614843&r1=614842&r2=614843&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
Thu Jan 24 03:22:39 2008
@@ -51,6 +51,7 @@
     private static final transient Log LOG = LogFactory.getLog(MockEndpoint.class);
     private int expectedCount;
     private int counter;
+    private Processor defaultProcessor;
     private Map<Integer, Processor> processors;
     private List<Exchange> receivedExchanges;
     private List<Throwable> failures;
@@ -146,6 +147,19 @@
     }
 
     /**
+     * Set the processor that will be invoked when the some message
+     * is received.
+     * 
+     * This processor could be overwritten by
+     * {@link #whenExchangeReceived(int, Processor)} method.
+     * 
+     * @param processor
+     */
+    public void whenAnyExchangeReceived(Processor processor) {
+        this.defaultProcessor = processor;
+    }    
+    
+    /**
      * Validates that all the available expectations on this endpoint are
      * satisfied; or throw an exception
      */
@@ -509,7 +523,9 @@
 
             receivedExchanges.add(exchange);
 
-            Processor processor = processors.get(getReceivedCounter());
+            Processor processor = processors.get(getReceivedCounter()) != null ?
+                    processors.get(getReceivedCounter()) : defaultProcessor;
+                    
             if (processor != null) {
                 processor.process(exchange);
             }



Mime
View raw message