You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/09/11 07:50:28 UTC

svn commit: r574469 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/camel/processo...

Author: jstrachan
Date: Mon Sep 10 22:50:27 2007
New Revision: 574469

URL: http://svn.apache.org/viewvc?rev=574469&view=rev
Log:
added support for InOnly and InOut for the file component; together with a simulator test showing how we can simulate a service using a recipientList and files

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimulatorTest.java
    activemq/camel/trunk/components/camel-juel/src/test/data/
    activemq/camel/trunk/components/camel-juel/src/test/data/bar.xml
      - copied, changed from r573786, activemq/camel/trunk/camel-core/src/main/data/bar.xml
    activemq/camel/trunk/components/camel-juel/src/test/data/foo.xml
      - copied, changed from r573786, activemq/camel/trunk/camel-core/src/main/data/foo.xml
    activemq/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/
    activemq/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/
    activemq/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java   (contents, props changed)
      - copied, changed from r573786, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProducer.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java?rev=574469&r1=574468&r2=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java Mon Sep 10 22:50:27 2007
@@ -125,19 +125,29 @@
     }
 
     /**
-     * Send the body to an endpoint
+     * Send the body to an endpoint with the given {@link ExchangePattern}
+     * returning any result output body
      * 
      * @param endpoint
      * @param body = the payload
+     * @param pattern the message {@link ExchangePattern} such as
+     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
      * @return the result
      */
-    public Object sendBody(Endpoint<E> endpoint, final Object body) {
-        E result = send(endpoint, new Processor() {
-            public void process(Exchange exchange) {
-                Message in = exchange.getIn();
-                in.setBody(body);
-            }
-        });
+    public Object sendBody(Endpoint<E> endpoint, ExchangePattern pattern, Object body) {
+        E result = send(endpoint, pattern, createSetBodyProcessor(body));
+        return extractResultBody(result);
+    }
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body = the payload
+     * @return the result
+     */
+    public Object sendBody(Endpoint<E> endpoint, Object body) {
+        E result = send(endpoint, createSetBodyProcessor(body));
         return extractResultBody(result);
     }
 
@@ -154,6 +164,20 @@
     }
 
     /**
+     * Send the body to an endpoint
+     *
+     * @param endpointUri
+     * @param pattern the message {@link ExchangePattern} such as
+     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
+     * @param body = the payload
+     * @return the result
+     */
+    public Object sendBody(String endpointUri, ExchangePattern pattern, Object body) {
+        Endpoint endpoint = resolveMandatoryEndpoint(endpointUri);
+        return sendBody(endpoint, pattern, body);
+    }
+
+    /**
      * Sends the body to an endpoint with a specified header and header value
      * 
      * @param endpointUri the endpoint URI to send to
@@ -178,17 +202,47 @@
      */
     public Object sendBodyAndHeader(Endpoint endpoint, final Object body, final String header,
                                     final Object headerValue) {
-        E result = send(endpoint, new Processor() {
-            public void process(Exchange exchange) {
-                Message in = exchange.getIn();
-                in.setHeader(header, headerValue);
-                in.setBody(body);
-            }
-        });
+        E result = send(endpoint, createBodyAndHeaderProcessor(body, header, headerValue));
         return extractResultBody(result);
     }
 
     /**
+     * Sends the body to an endpoint with a specified header and header value
+     *
+     * @param endpoint the Endpoint to send to
+     * @param pattern the message {@link ExchangePattern} such as
+     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
+     * @param body the payload send
+     * @param header the header name
+     * @param headerValue the header value
+     * @return the result
+     */
+    public Object sendBodyAndHeader(Endpoint endpoint, ExchangePattern pattern, final Object body, final String header,
+                                    final Object headerValue) {
+        E result = send(endpoint, pattern, createBodyAndHeaderProcessor(body, header, headerValue));
+        return extractResultBody(result);
+    }
+
+
+    /**
+     * Sends the body to an endpoint with a specified header and header value
+     *
+     * @param endpoint the Endpoint URI to send to
+     * @param pattern the message {@link ExchangePattern} such as
+     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
+     * @param body the payload send
+     * @param header the header name
+     * @param headerValue the header value
+     * @return the result
+     */
+    public Object sendBodyAndHeader(String endpoint, ExchangePattern pattern, final Object body, final String header,
+                                    final Object headerValue) {
+        E result = send(endpoint, pattern, createBodyAndHeaderProcessor(body, header, headerValue));
+        return extractResultBody(result);
+    }
+
+
+    /**
      * Sends the body to an endpoint with the specified headers and header
      * values
      * 
@@ -221,6 +275,79 @@
         return extractResultBody(result);
     }
 
+    // Methods using an InOut ExchangePattern
+    // -----------------------------------------------------------------------
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param processor the processor which will populate the exchange before sending
+     * @return the result
+     */
+    public E request(Endpoint<E> endpoint, Processor processor) {
+        return send(endpoint, ExchangePattern.InOut, processor);
+    }
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body     = the payload
+     * @return the result
+     */
+    public Object requestBody(Endpoint<E> endpoint, Object body) {
+        return sendBody(endpoint, ExchangePattern.InOut, body);
+    }
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body     = the payload
+     * @param header
+     * @param headerValue
+     * @return the result
+     */
+    public Object requestBodyAndHeader(Endpoint<E> endpoint, Object body, String header, Object headerValue) {
+        return sendBodyAndHeader(endpoint, ExchangePattern.InOut, body, header, headerValue);
+    }
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param processor the processor which will populate the exchange before sending
+     * @return the result
+     */
+    public E request(String endpoint, Processor processor) {
+        return send(endpoint, ExchangePattern.InOut, processor);
+    }
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body     = the payload
+     * @return the result
+     */
+    public Object requestBody(String endpoint, Object body) {
+        return sendBody(endpoint, ExchangePattern.InOut, body);
+    }
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body     = the payload
+     * @param header
+     * @param headerValue
+     * @return the result
+     */
+    public Object requestBodyAndHeader(String endpoint, Object body, String header, Object headerValue) {
+        return sendBodyAndHeader(endpoint, ExchangePattern.InOut, body, header, headerValue);
+    }
+
     // Methods using the default endpoint
     // -----------------------------------------------------------------------
 
@@ -298,6 +425,27 @@
     // Implementation methods
     // -----------------------------------------------------------------------
 
+
+    protected Processor createBodyAndHeaderProcessor(final Object body, final String header, final Object headerValue) {
+        return new Processor() {
+            public void process(Exchange exchange) {
+                Message in = exchange.getIn();
+                in.setHeader(header, headerValue);
+                in.setBody(body);
+            }
+        };
+    }
+
+
+
+    protected Processor createSetBodyProcessor(final Object body) {
+        return new Processor() {
+            public void process(Exchange exchange) {
+                Message in = exchange.getIn();
+                in.setBody(body);
+            }
+        };
+    }
     protected Endpoint resolveMandatoryEndpoint(String endpointUri) {
         Endpoint endpoint = null;
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java?rev=574469&r1=574468&r2=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java Mon Sep 10 22:50:27 2007
@@ -141,4 +141,161 @@
      * @return the result
      */
     Object sendBody(String endpointUri, Object body);
+
+    /**
+     * Send the body to an endpoint with the given {@link ExchangePattern}
+     * returning any result output body
+     *
+     * @param endpoint
+     * @param body = the payload
+     * @param pattern the message {@link ExchangePattern} such as
+     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
+     * @return the result
+     */
+    Object sendBody(Endpoint<E> endpoint, ExchangePattern pattern, Object body);
+
+    /**
+     * Send the body to an endpoint
+     *
+     * @param endpointUri
+     * @param pattern the message {@link ExchangePattern} such as
+     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
+     * @param body = the payload
+     * @return the result
+     */
+    Object sendBody(String endpointUri, ExchangePattern pattern, Object body);
+
+    /**
+     * Sends the body to an endpoint with a specified header and header value
+     *
+     * @param endpointUri the endpoint URI to send to
+     * @param body the payload send
+     * @param header the header name
+     * @param headerValue the header value
+     * @return the result
+     */
+    Object sendBodyAndHeader(String endpointUri, Object body, String header,
+                                    Object headerValue);
+
+    /**
+     * Sends the body to an endpoint with a specified header and header value
+     *
+     * @param endpoint the Endpoint to send to
+     * @param body the payload send
+     * @param header the header name
+     * @param headerValue the header value
+     * @return the result
+     */
+    Object sendBodyAndHeader(Endpoint endpoint, Object body, String header,
+                                    Object headerValue);
+
+    /**
+     * Sends the body to an endpoint with a specified header and header value
+     *
+     * @param endpoint the Endpoint to send to
+     * @param pattern the message {@link ExchangePattern} such as
+     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
+     * @param body the payload send
+     * @param header the header name
+     * @param headerValue the header value
+     * @return the result
+     */
+    Object sendBodyAndHeader(Endpoint endpoint, ExchangePattern pattern, Object body, String header,
+                                    Object headerValue);
+
+    /**
+     * Sends the body to an endpoint with a specified header and header value
+     *
+     * @param endpoint the Endpoint URI to send to
+     * @param pattern the message {@link ExchangePattern} such as
+     *   {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
+     * @param body the payload send
+     * @param header the header name
+     * @param headerValue the header value
+     * @return the result
+     */
+    Object sendBodyAndHeader(String endpoint, ExchangePattern pattern, Object body, String header,
+                                    Object headerValue);
+
+    /**
+     * Sends the body to an endpoint with the specified headers and header
+     * values
+     *
+     * @param endpointUri the endpoint URI to send to
+     * @param body the payload send
+     * @return the result
+     */
+    Object sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers);
+
+    /**
+     * Sends the body to an endpoint with the specified headers and header
+     * values
+     *
+     * @param endpoint the endpoint URI to send to
+     * @param body the payload send
+     * @return the result
+     */
+    Object sendBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers);
+
+
+    // Methods using an InOut ExchangePattern
+    // -----------------------------------------------------------------------
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param processor the processor which will populate the exchange before sending
+     * @return the result
+     */
+    E request(Endpoint<E> endpoint, Processor processor);
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body     = the payload
+     * @return the result
+     */
+    Object requestBody(Endpoint<E> endpoint, Object body);
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body     = the payload
+     * @param header
+     * @param headerValue
+     * @return the result
+     */
+    Object requestBodyAndHeader(Endpoint<E> endpoint, Object body, String header, Object headerValue);
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param processor the processor which will populate the exchange before sending
+     * @return the result
+     */
+    E request(String endpoint, Processor processor);
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body     = the payload
+     * @return the result
+     */
+    Object requestBody(String endpoint, Object body);
+
+    /**
+     * Send the body to an endpoint returning any result output body
+     *
+     * @param endpoint
+     * @param body     = the payload
+     * @param header
+     * @param headerValue
+     * @return the result
+     */
+    Object requestBodyAndHeader(String endpoint, Object body, String header, Object headerValue);
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java?rev=574469&r1=574468&r2=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java Mon Sep 10 22:50:27 2007
@@ -38,7 +38,6 @@
     private boolean recursive = true;
     private String regexPattern = "";
     private long lastPollTime;
-    private boolean preserveFileName = true;
 
     public FileConsumer(final FileEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
@@ -96,14 +95,7 @@
             final FileProcessStrategy processStrategy = endpoint.getFileStrategy();
             final FileExchange exchange = endpoint.createExchange(file);
 
-            if (isPreserveFileName()) {
-                String relativePath = file.getPath().substring(endpoint.getFile().getPath().length());
-                if (relativePath.startsWith(File.separator)) {
-                	relativePath = relativePath.substring(1);
-                }
-                exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, relativePath);
-            }
-            
+            endpoint.configureMessage(file, exchange.getIn());
             try {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("About to process file:  " + file + " using exchange: " + exchange);
@@ -205,11 +197,4 @@
         this.regexPattern = regexPattern;
     }
 
-	public boolean isPreserveFileName() {
-		return preserveFileName;
-	}
-
-	public void setPreserveFileName(boolean preserveFileName) {
-		this.preserveFileName = preserveFileName;
-	}
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=574469&r1=574468&r2=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java Mon Sep 10 22:50:27 2007
@@ -20,6 +20,7 @@
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
 import org.apache.camel.component.file.strategy.DefaultFileRenamer;
 import org.apache.camel.component.file.strategy.DeleteFileProcessStrategy;
 import org.apache.camel.component.file.strategy.FileProcessStrategy;
@@ -52,6 +53,7 @@
     private String[] excludedNamePrefixes = {"."};
     private String[] excludedNamePostfixes = { FileProcessStrategySupport.DEFAULT_LOCK_FILE_POSTFIX };
     private int bufferSize = 128 * 1024;
+    private boolean ignoreFileNameHeader;
 
     protected FileEndpoint(File file, String endpointUri, FileComponent component) {
         super(endpointUri, component);
@@ -101,6 +103,20 @@
         return new FileExchange(getContext(), pattern, file);
     }
 
+    /**
+     * Configures the given message with the file which sets the body to the file object
+     * and sets the {@link FileComponent#HEADER_FILE_NAME} header.
+     */
+    public void configureMessage(File file, Message message) {
+        message.setBody(file);
+        String path = file.getPath();
+        String relativePath = path.substring(path.length());
+        if (relativePath.startsWith(File.separator) || relativePath.startsWith("/")) {
+            relativePath = relativePath.substring(1);
+        }
+        message.setHeader(FileComponent.HEADER_FILE_NAME, relativePath);
+    }
+
     public File getFile() {
         if (autoCreate && !file.exists()) {
             file.mkdirs();
@@ -252,6 +268,19 @@
     public void setBufferSize(int bufferSize) {
         this.bufferSize = bufferSize;
     }
+
+    public boolean isIgnoreFileNameHeader() {
+        return ignoreFileNameHeader;
+    }
+
+    /**
+     * If this flag is enabled then producers will ignore the {@link FileComponent#HEADER_FILE_NAME}
+     * header and generate a new dynamic file
+     */
+    public void setIgnoreFileNameHeader(boolean ignoreFileNameHeader) {
+        this.ignoreFileNameHeader = ignoreFileNameHeader;
+    }
+
 
     /**
      * A strategy method to lazily create the file strategy

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProducer.java?rev=574469&r1=574468&r2=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProducer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProducer.java Mon Sep 10 22:50:27 2007
@@ -55,10 +55,19 @@
      * @see org.apache.camel.Processor#process(Exchange)
      */
     public void process(Exchange exchange) throws Exception {
-        process(endpoint.createExchange(exchange));
+        // TODO is it really worth using a FileExchange as the core type?
+        FileExchange fileExchange = endpoint.createExchange(exchange);
+        process(fileExchange);
+        ExchangeHelper.copyResults(exchange, fileExchange);
     }
 
     public void process(FileExchange exchange) throws Exception {
+        if (ExchangeHelper.isOutCapable(exchange)) {
+            // lets poll the file
+            Message out = exchange.getOut(true);
+            endpoint.configureMessage(endpoint.getFile(), out);
+            return;
+        }
         InputStream in = ExchangeHelper.getMandatoryInBody(exchange, InputStream.class);
         File file = createFileName(exchange.getIn());
         buildDirectory(file);
@@ -148,7 +157,10 @@
     protected File createFileName(Message message) {
         File answer;
         File endpointFile = endpoint.getFile();
-        String name = message.getHeader(FileComponent.HEADER_FILE_NAME, String.class);
+        String name = null;
+        if (!endpoint.isIgnoreFileNameHeader()) {
+            name = message.getHeader(FileComponent.HEADER_FILE_NAME, String.class);
+        }
         if (endpointFile.isDirectory()) {
             if (name != null) {
                 answer = new File(endpointFile, name);

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java?rev=574469&r1=574468&r2=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java Mon Sep 10 22:50:27 2007
@@ -17,17 +17,20 @@
 package org.apache.camel.processor;
 
 import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.AsyncCallback;
 import org.apache.camel.converter.ObjectConverter;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.util.ExchangeHelper;
-import org.apache.camel.util.ProducerCache;
-
 import static org.apache.camel.util.ObjectHelper.notNull;
+import org.apache.camel.util.ProducerCache;
 
 /**
  * Implements a dynamic <a
@@ -54,11 +57,16 @@
     public void process(Exchange exchange) throws Exception {
         Object receipientList = expression.evaluate(exchange);
         Iterator iter = ObjectConverter.iterator(receipientList);
+        List<Processor> processors = new ArrayList<Processor>();
         while (iter.hasNext()) {
             Object recipient = iter.next();
             Endpoint<Exchange> endpoint = resolveEndpoint(exchange, recipient);
-            producerCache.getProducer(endpoint).process(exchange);
+            Producer<Exchange> producer = producerCache.getProducer(endpoint);
+            processors.add(producer);
         }
+        // TODO we could support a multicast option?
+        Pipeline pipeline = new Pipeline(processors);
+        pipeline.process(exchange);
     }
 
     protected Endpoint<Exchange> resolveEndpoint(Exchange exchange, Object recipient) {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java?rev=574469&r1=574468&r2=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java Mon Sep 10 22:50:27 2007
@@ -27,33 +27,19 @@
  * @version $Revision: 1.1 $
  */
 public class RecipientListTest extends ContextTestSupport {
-    protected MockEndpoint x;
-    protected MockEndpoint y;
-    protected MockEndpoint z;
 
     public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception {
+        MockEndpoint x = getMockEndpoint("mock:x");
+        MockEndpoint y = getMockEndpoint("mock:y");
+        MockEndpoint z = getMockEndpoint("mock:z");
+
         x.expectedBodiesReceived("answer");
         y.expectedBodiesReceived("answer");
         z.expectedBodiesReceived("answer");
 
-        template.send("direct:a", new Processor() {
-            public void process(Exchange exchange) {
-                Message in = exchange.getIn();
-                in.setBody("answer");
-                in.setHeader("recipientListHeader", "mock:x,mock:y,mock:z");
-            }
-        });
-
-        MockEndpoint.assertIsSatisfied(x, y, z);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+        template.sendBodyAndHeader("direct:a", "answer", "recipientListHeader", "mock:x,mock:y,mock:z");
 
-        x = getMockEndpoint("mock:x");
-        y = getMockEndpoint("mock:y");
-        z = getMockEndpoint("mock:z");
+        assertMockEndpointsSatisifed();
     }
 
     protected RouteBuilder createRouteBuilder() {

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimulatorTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimulatorTest.java?rev=574469&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimulatorTest.java (added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimulatorTest.java Mon Sep 10 22:50:27 2007
@@ -0,0 +1,67 @@
+/**
+ * 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.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import static org.apache.camel.language.simple.SimpleLanguage.simple;
+import org.apache.camel.util.ExchangeHelper;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class SimulatorTest extends ContextTestSupport {
+
+    public void testReceivesFooResponse() throws Exception {
+        assertRespondsWith("foo", "<hello>foo</hello>");
+    }
+
+    public void testReceivesBarResponse() throws Exception {
+        assertRespondsWith("bar", "<hello>bar</hello>");
+    }
+
+    protected void assertRespondsWith(final String value, String containedText) throws InvalidPayloadException {
+        Exchange response = template.request("direct:a", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                Message in = exchange.getIn();
+                in.setBody("answer");
+                in.setHeader("cheese", value);
+            }
+        });
+
+        assertNotNull("Should receive a response!", response);
+
+        String text = ExchangeHelper.getMandatoryOutBody(response, String.class);
+        log.info("Received: " + text);
+        assertStringContains(text, containedText);
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // START SNIPPET: example
+                from("direct:a").
+                    recipientList(simple("file:src/main/data/${in.headers.cheese}.xml"));
+                // END SNIPPET: example
+            }
+        };
+    }
+}
\ No newline at end of file

Copied: activemq/camel/trunk/components/camel-juel/src/test/data/bar.xml (from r573786, activemq/camel/trunk/camel-core/src/main/data/bar.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-juel/src/test/data/bar.xml?p2=activemq/camel/trunk/components/camel-juel/src/test/data/bar.xml&p1=activemq/camel/trunk/camel-core/src/main/data/bar.xml&r1=573786&r2=574469&rev=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/data/bar.xml (original)
+++ activemq/camel/trunk/components/camel-juel/src/test/data/bar.xml Mon Sep 10 22:50:27 2007
@@ -15,4 +15,4 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<hello>bar</hello>
+<hello>barResponse</hello>

Copied: activemq/camel/trunk/components/camel-juel/src/test/data/foo.xml (from r573786, activemq/camel/trunk/camel-core/src/main/data/foo.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-juel/src/test/data/foo.xml?p2=activemq/camel/trunk/components/camel-juel/src/test/data/foo.xml&p1=activemq/camel/trunk/camel-core/src/main/data/foo.xml&r1=573786&r2=574469&rev=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/data/foo.xml (original)
+++ activemq/camel/trunk/components/camel-juel/src/test/data/foo.xml Mon Sep 10 22:50:27 2007
@@ -15,4 +15,4 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<hello>foo</hello>
+<hello>fooResponse</hello>

Copied: activemq/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java (from r573786, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java?p2=activemq/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java&r1=573786&r2=574469&rev=574469&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListTest.java (original)
+++ activemq/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java Mon Sep 10 22:50:27 2007
@@ -14,57 +14,54 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.processor;
+package org.apache.camel.processor.juel;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Processor;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
-import org.apache.camel.Processor;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
+import static org.apache.camel.language.juel.JuelExpression.el;
 
 /**
  * @version $Revision: 1.1 $
  */
-public class RecipientListTest extends ContextTestSupport {
-    protected MockEndpoint x;
-    protected MockEndpoint y;
-    protected MockEndpoint z;
-
-    public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception {
-        x.expectedBodiesReceived("answer");
-        y.expectedBodiesReceived("answer");
-        z.expectedBodiesReceived("answer");
+public class SimulatorTest extends ContextTestSupport {
 
-        template.send("direct:a", new Processor() {
-            public void process(Exchange exchange) {
+    public void testReceivesFooResponse() throws Exception {
+        assertRespondsWith("foo", "fooResponse");
+    }
+
+    public void testReceivesBarResponse() throws Exception {
+        assertRespondsWith("bar", "barResponse");
+    }
+
+    protected void assertRespondsWith(final String value, String containedText) throws InvalidPayloadException {
+        Exchange response = template.request("direct:a", new Processor() {
+            public void process(Exchange exchange) throws Exception {
                 Message in = exchange.getIn();
                 in.setBody("answer");
-                in.setHeader("recipientListHeader", "mock:x,mock:y,mock:z");
+                in.setHeader("cheese", value);
             }
         });
 
-        MockEndpoint.assertIsSatisfied(x, y, z);
-    }
+        assertNotNull("Should receive a response!", response);
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        x = getMockEndpoint("mock:x");
-        y = getMockEndpoint("mock:y");
-        z = getMockEndpoint("mock:z");
+        String text = ExchangeHelper.getMandatoryOutBody(response, String.class);
+        log.info("Received: " + text);
+        assertStringContains(text, containedText);
     }
 
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
                 // START SNIPPET: example
-                from("direct:a").recipientList(header("recipientListHeader").tokenize(","));
+                from("direct:a").
+                    recipientList(el("file:src/test/data/${in.headers.cheese}.xml"));
                 // END SNIPPET: example
             }
         };
-
     }
-
-}
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native