You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/06/30 04:42:09 UTC
svn commit: r789536 - in /camel/branches/camel-1.x/camel-core/src:
main/java/org/apache/camel/builder/Builder.java
main/java/org/apache/camel/builder/BuilderSupport.java
test/java/org/apache/camel/builder/ValueBuilderTest.java
Author: ningjiang
Date: Tue Jun 30 02:42:09 2009
New Revision: 789536
URL: http://svn.apache.org/viewvc?rev=789536&view=rev
Log:
CAMEL-1772 applied patch with thanks to Erwin
Added:
camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/builder/ValueBuilderTest.java (with props)
Modified:
camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/Builder.java
camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/Builder.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/Builder.java?rev=789536&r1=789535&r2=789536&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/Builder.java (original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/Builder.java Tue Jun 30 02:42:09 2009
@@ -105,6 +105,14 @@
}
/**
+ * Returns a predicate and value builder for properties on an exchange
+ */
+ public static ValueBuilder property(String name) {
+ Expression expression = ExpressionBuilder.propertyExpression(name);
+ return new ValueBuilder(expression);
+ }
+
+ /**
* Returns an expression for the given system property
*/
public static <E extends Exchange> ValueBuilder<E> systemProperty(final String name) {
Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java?rev=789536&r1=789535&r2=789536&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java (original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java Tue Jun 30 02:42:09 2009
@@ -110,6 +110,12 @@
return Builder.faultBodyAs(type);
}
+ /**
+ * Returns a value builder for the given property
+ */
+ public ValueBuilder property(String name) {
+ return Builder.property(name);
+ }
/**
* Returns a value builder for the given system property
Added: camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/builder/ValueBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/builder/ValueBuilderTest.java?rev=789536&view=auto
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/builder/ValueBuilderTest.java (added)
+++ camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/builder/ValueBuilderTest.java Tue Jun 30 02:42:09 2009
@@ -0,0 +1,54 @@
+/**
+ * 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.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class ValueBuilderTest extends ContextTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ public void testProperty() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").transform(property("hello_world")).to("mock:result");
+ }
+ });
+ context.start();
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("Hello World");
+
+ template.send("direct:start", new Processor() {
+ public void process(Exchange exchange) {
+ exchange.setProperty("hello_world", "Hello World");
+ }
+ });
+
+ assertMockEndpointsSatisfied();
+ }
+}
Propchange: camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/builder/ValueBuilderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/builder/ValueBuilderTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date