activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r530776 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/builder/ExpressionBuilder.java main/java/org/apache/camel/component/mock/MockEndpoint.java test/java/org/apache/camel/processor/RecipientTest.java
Date Fri, 20 Apr 2007 12:49:50 GMT
Author: jstrachan
Date: Fri Apr 20 05:49:49 2007
New Revision: 530776

URL: http://svn.apache.org/viewvc?view=rev&rev=530776
Log:
added a test case for recipient list

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientTest.java
  (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
    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/builder/ExpressionBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java?view=diff&rev=530776&r1=530775&r2=530776
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
Fri Apr 20 05:49:49 2007
@@ -240,4 +240,22 @@
         Object value = expression.evaluate(exchange);
         return exchange.getContext().getTypeConverter().convertTo(String.class, value);
     }
+
+    /**
+     * Returns an expression for the given system property
+     */
+    public static <E extends Exchange> Expression<E> systemProperty(final String
name) {
+        return systemProperty(name, null);
+    }
+
+    /**
+     * Returns an expression for the given system property
+     */
+    public static <E extends Exchange> Expression<E> systemProperty(final String
name, final String defaultValue) {
+        return new Expression<E>() {
+            public Object evaluate(E exchange) {
+                return System.getProperty(name, defaultValue);
+            }
+        };
+    }
 }

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?view=diff&rev=530776&r1=530775&r2=530776
==============================================================================
--- 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
Fri Apr 20 05:49:49 2007
@@ -175,7 +175,7 @@
 
                     assertEquals("Body of message: " + counter, expectedBody, actualBody);
 
-                    log.debug("Received message: " + counter + " with body: " + actualBody);
+                    log.debug(getEndpointUri() + " >>>> message: " + counter
+ " with body: " + actualBody);
                 }
             }
         });
@@ -237,7 +237,7 @@
     //-------------------------------------------------------------------------
     protected synchronized void onExchange(Exchange exchange) {
         try {
-            log.debug("Received exchange: " + exchange);
+            log.debug(getEndpointUri() + " >>>> " + exchange);
 
             exchangesReceived.add(exchange);
 

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientTest.java?view=auto&rev=530776
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientTest.java
(added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientTest.java
Fri Apr 20 05:49:49 2007
@@ -0,0 +1,70 @@
+/**
+ *
+ * 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.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class RecipientTest extends ContextTestSupport {
+    protected MockEndpoint x, y, z;
+
+    public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception
{
+        x.expectedBodiesReceived("answer");
+        y.expectedBodiesReceived("answer");
+        z.expectedBodiesReceived("answer");
+
+        client.send("direct:a", new Processor<Exchange>() {
+            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();
+
+        x = (MockEndpoint) resolveMandatoryEndpoint("mock:x");
+        y = (MockEndpoint) resolveMandatoryEndpoint("mock:y");
+        z = (MockEndpoint) resolveMandatoryEndpoint("mock:z");
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder<Exchange>() {
+            public void configure() {
+                // START SNIPPET: example
+                from("direct:a").recipientList(header("recipientListHeader").tokenize(","));
+                // END SNIPPET: example
+            }
+        };
+
+    }
+
+}

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



Mime
View raw message