Author: davsclaus
Date: Sat Apr 12 04:35:45 2008
New Revision: 647433
URL: http://svn.apache.org/viewvc?rev=647433&view=rev
Log:
CAMEL-195 applied patch with huge thanks to Jonathan
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetHeaderProcessor.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/convertBody.xml
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeader.xml
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderToConstant.xml
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderWithChildProcessor.xml
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringConvertBodyTest.java
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderTest.java
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithChildProcessorTest.java
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest.java
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTest-context.xml
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTestWithChildProcessor-context.xml
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest-context.xml
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/convertBody.xml
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/model/ProcessorType.java
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetHeaderUsingDslExpressionsTest.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?rev=647433&r1=647432&r2=647433&view=diff
==============================================================================
---
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
Sat Apr 12 04:35:45 2008
@@ -202,7 +202,7 @@
}
/**
- * Returns an expression for the contant value
+ * Returns an expression for the constant value
*
* @param value the value the expression will return
* @return an expression object which will return the constant value
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java
(added)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,91 @@
+/**
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.camel.Processor;
+import org.apache.camel.impl.RouteContext;
+import org.apache.camel.processor.ConvertBodyProcessor;
+import org.apache.camel.util.ObjectHelper;
+
[EMAIL PROTECTED](name = "convertBodyTo")
[EMAIL PROTECTED](XmlAccessType.FIELD)
+public class ConvertBodyType extends ProcessorType<ProcessorType> {
+ @XmlAttribute
+ private String type;
+ @XmlTransient
+ private Class typeClass;
+
+ public ConvertBodyType() {
+ }
+
+ public ConvertBodyType(String type) {
+ setType(type);
+ }
+
+ public ConvertBodyType(Class typeClass) {
+ setTypeClass(typeClass);
+ }
+
+ @Override
+ public String toString() {
+ return "convertBodyTo[ " + getType() + "]";
+ }
+
+ @Override
+ public Processor createProcessor(RouteContext routeContext) throws
Exception {
+ return new ConvertBodyProcessor(getTypeClass());
+ }
+
+ @Override
+ public List<ProcessorType<?>> getOutputs() {
+ return Collections.EMPTY_LIST;
+ }
+
+ protected Class createTypeClass() {
+ return ObjectHelper.loadClass(getType(), getClass().getClassLoader());
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setTypeClass(Class typeClass) {
+ this.typeClass = typeClass;
+ }
+
+ public Class getTypeClass() {
+ if (typeClass == null) {
+ setTypeClass(createTypeClass());
+ }
+ return typeClass;
+ }
+}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=647433&r1=647432&r2=647433&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
Sat Apr 12 04:35:45 2008
@@ -50,6 +50,7 @@
import org.apache.camel.processor.MulticastProcessor;
import org.apache.camel.processor.Pipeline;
import org.apache.camel.processor.RecipientList;
+import org.apache.camel.processor.SetHeaderProcessor;
import org.apache.camel.processor.aggregate.AggregationCollection;
import org.apache.camel.processor.aggregate.AggregationStrategy;
import org.apache.camel.processor.idempotent.IdempotentConsumer;
@@ -1108,7 +1109,8 @@
*/
public ExpressionClause<ProcessorType<Type>> setHeader(String name) {
ExpressionClause<ProcessorType<Type>> clause = new
ExpressionClause<ProcessorType<Type>>((Type) this);
- process(ProcessorBuilder.setHeader(name, clause));
+ SetHeaderType answer = new SetHeaderType(name, clause);
+ addOutput(answer);
return clause;
}
@@ -1116,14 +1118,18 @@
* Adds a processor which sets the header on the IN message
*/
public Type setHeader(String name, Expression expression) {
- return process(ProcessorBuilder.setHeader(name, expression));
+ SetHeaderType answer = new SetHeaderType(name, expression);
+ addOutput(answer);
+ return (Type) this;
}
/**
* Adds a processor which sets the header on the IN message to the given
value
*/
public Type setHeader(String name, String value) {
- return (Type) setHeader(name).constant(value);
+ SetHeaderType answer = new SetHeaderType(name, value);
+ addOutput(answer);
+ return (Type) this;
}
/**
@@ -1205,7 +1211,8 @@
* Converts the IN message body to the specified type
*/
public Type convertBodyTo(Class type) {
- return process(new ConvertBodyProcessor(type));
+ addOutput(new ConvertBodyType(type));
+ return (Type) this;
}
/**
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java
(added)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,93 @@
+/**
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.impl.RouteContext;
+import org.apache.camel.model.language.ExpressionType;
+import org.apache.camel.processor.Delayer;
+import org.apache.camel.processor.SetHeaderProcessor;
+
[EMAIL PROTECTED](name = "setHeader")
[EMAIL PROTECTED](XmlAccessType.FIELD)
+public class SetHeaderType extends ExpressionNode {
+ @XmlAttribute
+ private String headerName;
+ @XmlAttribute(required = false)
+ private String value;
+
+ public SetHeaderType() {
+ }
+
+ public SetHeaderType(String headerName, ExpressionType expression) {
+ super(expression);
+ setHeaderName(headerName);
+ }
+
+ public SetHeaderType(String headerName, Expression expression) {
+ super(expression);
+ setHeaderName(headerName);
+ }
+
+ public SetHeaderType(String headerName, String value) {
+ super(ExpressionBuilder.constantExpression(value));
+ setHeaderName(headerName);
+ }
+
+ @Override
+ public String toString() {
+ return "SetHeader[ " + getHeaderName() + ", " + getExpression() + "]";
+ }
+
+ @Override
+ public Processor createProcessor(RouteContext routeContext) throws
Exception {
+ Expression expr;
+
+ if (getValue() == null) {
+ expr = getExpression().createExpression(routeContext);
+ } else {
+ expr = ExpressionBuilder.constantExpression(getValue());
+ }
+
+ Processor childProcessor = routeContext.createProcessor(this);
+
+ return new SetHeaderProcessor(getHeaderName(), expr, childProcessor);
+ }
+
+ public void setHeaderName(String headerName) {
+ this.headerName = headerName;
+ }
+
+ public String getHeaderName() {
+ return headerName;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetHeaderProcessor.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetHeaderProcessor.java?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetHeaderProcessor.java
(added)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetHeaderProcessor.java
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,60 @@
+/**
+ *
+ * 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.Expression;
+import org.apache.camel.Processor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A processor which sets the header on the IN message
+ */
+public class SetHeaderProcessor extends DelegateProcessor implements Processor
{
+ private static final transient Log LOG =
LogFactory.getLog(SetHeaderProcessor.class);
+ private String name;
+ private Expression expression;
+
+ public SetHeaderProcessor(String name, Expression expression) {
+ this.name = name;
+ this.expression = expression;
+ }
+
+ public SetHeaderProcessor(String name, Expression expression,
+ Processor childProcessor) {
+ super(childProcessor);
+ this.name = name;
+ this.expression = expression;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Object value = expression.evaluate(exchange);
+ if (value == null) {
+ LOG.warn("Expression: " + expression
+ + " on exchange: " + exchange + " evaluated to null.");
+ }
+ exchange.getIn().setHeader(name, value);
+ super.process(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return "setHeader(" + name + ", " + expression + ")";
+ }
+}
Modified:
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index?rev=647433&r1=647432&r2=647433&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
(original)
+++
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
Sat Apr 12 04:35:45 2008
@@ -19,6 +19,7 @@
CatchType
ChoiceType
CompletedPredicate
+ConvertBodyType
DelayerType
ExceptionType
FilterType
@@ -42,6 +43,7 @@
RoutesType
RoutingSlipType
ServiceActivationType
+SetHeaderType
SplitterType
ThrottlerType
ThreadType
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java?rev=647433&r1=647432&r2=647433&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
Sat Apr 12 04:35:45 2008
@@ -81,6 +81,42 @@
assertChildTo(route, "seda:b", "seda:c", "seda:d");
}
+ public void testParseSetHeaderXml() throws Exception {
+ RouteType route = assertOneRoute("setHeader.xml");
+ assertFrom(route, "seda:a");
+ SetHeaderType node = assertSetHeader(route);
+ assertEquals("oldBodyValue", node.getHeaderName());
+ assertExpression(node.getExpression(), "simple", "body");
+ assertChildTo(route, "mock:b", 1);
+ }
+
+ public void testParseSetHeaderWithChildProcessorXml() throws Exception {
+ RouteType route = assertOneRoute("setHeaderWithChildProcessor.xml");
+ assertFrom(route, "seda:a");
+ SetHeaderType node = assertSetHeader(route);
+ assertEquals("oldBodyValue", node.getHeaderName());
+ assertExpression(node.getExpression(), "simple", "body");
+ assertChildTo(node, "mock:b");
+ }
+
+ public void testParseSetHeaderToConstantXml() throws Exception {
+ RouteType route = assertOneRoute("setHeaderToConstant.xml");
+ assertFrom(route, "seda:a");
+ SetHeaderType node = assertSetHeader(route);
+ assertEquals("theHeader", node.getHeaderName());
+ assertEquals("a value", node.getValue());
+ assertEquals("", node.getExpression().getExpression());
+ assertChildTo(route, "mock:b", 1);
+ }
+
+ public void testParseConvertBodyXml() throws Exception {
+ RouteType route = assertOneRoute("convertBody.xml");
+ assertFrom(route, "seda:a");
+ ConvertBodyType node = assertConvertBody(route);
+ assertEquals("java.lang.Integer", node.getType());
+ assertEquals(Integer.class, node.getTypeClass());
+ }
+
public void testParseRoutingSlipXml() throws Exception {
RouteType route = assertOneRoute("routingSlip.xml");
assertFrom(route, "seda:a");
@@ -209,6 +245,11 @@
}
}
+ protected void assertChildTo(ProcessorType route, String uri, int toIdx) {
+ List<ProcessorType<?>> list = route.getOutputs();
+ assertTo("to and idx=" + toIdx, list.get(toIdx), uri);
+ }
+
protected void assertProcessor(ProcessorType<?> route, String
processorRef) {
ProcessorType<?> processor = assertOneElement(route.getOutputs());
ProcessorRef to = assertIsInstanceOf(ProcessorRef.class, processor);
@@ -225,11 +266,21 @@
return assertIsInstanceOf(RecipientListType.class, processor);
}
+ protected ConvertBodyType assertConvertBody(ProcessorType<?> route) {
+ ProcessorType<?> processor = assertOneElement(route.getOutputs());
+ return assertIsInstanceOf(ConvertBodyType.class, processor);
+ }
+
protected RoutingSlipType assertRoutingSlip(ProcessorType<?> route) {
ProcessorType<?> processor = assertOneElement(route.getOutputs());
return assertIsInstanceOf(RoutingSlipType.class, processor);
}
+ protected SetHeaderType assertSetHeader(ProcessorType<?> route) {
+ ProcessorType<?> processor = route.getOutputs().get(0);
+ return assertIsInstanceOf(SetHeaderType.class, processor);
+ }
+
protected ChoiceType assertChoice(ProcessorType<?> route) {
ProcessorType<?> processor = assertOneElement(route.getOutputs());
return assertIsInstanceOf(ChoiceType.class, processor);
Added:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java
(added)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,44 @@
+/**
+ * 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.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+public class ConvertBodyTest extends ContextTestSupport {
+ public void testConvertToInteger() throws Exception {
+
+ MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result",
+ MockEndpoint.class);
+ resultEndpoint.expectedBodiesReceived(11);
+
+ template.sendBody("direct:start", "11");
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+
from("direct:start").convertBodyTo(Integer.class).to("mock:result");
+ }
+ };
+ }
+
+}
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetHeaderUsingDslExpressionsTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetHeaderUsingDslExpressionsTest.java?rev=647433&r1=647432&r2=647433&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetHeaderUsingDslExpressionsTest.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetHeaderUsingDslExpressionsTest.java
Sat Apr 12 04:35:45 2008
@@ -86,7 +86,7 @@
assertMockEndpointsSatisifed();
}
- public void testUseBodyExpresion() throws Exception {
+ public void testUseBodyExpression() throws Exception {
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("direct:start").
@@ -100,7 +100,7 @@
assertMockEndpointsSatisifed();
}
- public void testUseBodyAsTypeExpresion() throws Exception {
+ public void testUseBodyAsTypeExpression() throws Exception {
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("direct:start").
@@ -121,4 +121,4 @@
expected = getMockEndpoint("mock:result");
expected.message(0).header("foo").isEqualTo("ABC");
}
-}
\ No newline at end of file
+}
Added:
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/convertBody.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/convertBody.xml?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/convertBody.xml
(added)
+++
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/convertBody.xml
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<routes id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <convertBodyTo type="java.lang.Integer"/>
+ </route>
+</routes>
Added:
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeader.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeader.xml?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeader.xml
(added)
+++
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeader.xml
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<routes id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <setHeader headerName="oldBodyValue">
+ <simple>body</simple>
+ </setHeader>
+ <to uri="mock:b"/>
+ </route>
+</routes>
Added:
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderToConstant.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderToConstant.xml?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderToConstant.xml
(added)
+++
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderToConstant.xml
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<routes id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <setHeader headerName="theHeader" value="a value">
+ <expression/>
+ </setHeader>
+ <to uri="mock:b"/>
+ </route>
+</routes>
Added:
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderWithChildProcessor.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderWithChildProcessor.xml?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderWithChildProcessor.xml
(added)
+++
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setHeaderWithChildProcessor.xml
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<routes id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <setHeader headerName="oldBodyValue">
+ <simple>body</simple>
+ <to uri="mock:b"/>
+ </setHeader>
+ </route>
+</routes>
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringConvertBodyTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringConvertBodyTest.java?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringConvertBodyTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringConvertBodyTest.java
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,28 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.ConvertBodyTest;
+import static
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringConvertBodyTest extends ConvertBodyTest {
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this,
+ "org/apache/camel/spring/processor/convertBody.xml");
+ }
+}
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderTest.java?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderTest.java
Sat Apr 12 04:35:45 2008
@@ -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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import static
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringSetHeaderTest extends ContextTestSupport {
+
+ public void testSetHeaderWithExpression() throws Exception {
+ MockEndpoint resultEndpoint = getMockEndpoint("mock:b");
+ resultEndpoint.expectedBodiesReceived("Hello");
+ resultEndpoint.expectedHeaderReceived("oldBodyValue", "Hello");
+
+ sendBody("seda:a", "Hello");
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this,
"org/apache/camel/spring/processor/SpringSetHeaderTest-context.xml");
+ }
+}
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithChildProcessorTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithChildProcessorTest.java?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithChildProcessorTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithChildProcessorTest.java
Sat Apr 12 04:35:45 2008
@@ -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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import static
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringSetHeaderWithChildProcessorTest extends ContextTestSupport {
+
+ public void testSetHeaderWithExpression() throws Exception {
+ MockEndpoint resultEndpoint = getMockEndpoint("mock:b");
+ resultEndpoint.expectedBodiesReceived("Hello");
+ resultEndpoint.expectedHeaderReceived("oldBodyValue", "Hello");
+
+ sendBody("seda:a", "Hello");
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this,
"org/apache/camel/spring/processor/SpringSetHeaderTestWithChildProcessor-context.xml");
+ }
+}
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest.java?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest.java
Sat Apr 12 04:35:45 2008
@@ -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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import static
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringSetHeaderWithConstantTest extends ContextTestSupport {
+
+ public void testSetHeaderWithExpression() throws Exception {
+ MockEndpoint resultEndpoint = getMockEndpoint("mock:b");
+ resultEndpoint.expectedBodiesReceived("Hello");
+ resultEndpoint.expectedHeaderReceived("theHeader", "the value");
+
+ sendBody("seda:a", "Hello");
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this,
"org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest-context.xml");
+ }
+}
Added:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTest-context.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTest-context.xml?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTest-context.xml
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTest-context.xml
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- START SNIPPET: example -->
+ <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <setHeader headerName="oldBodyValue">
+ <simple>body</simple>
+ </setHeader>
+ <to uri="mock:b"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+</beans>
Added:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTestWithChildProcessor-context.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTestWithChildProcessor-context.xml?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTestWithChildProcessor-context.xml
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderTestWithChildProcessor-context.xml
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- START SNIPPET: example -->
+ <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <setHeader headerName="oldBodyValue">
+ <simple>body</simple>
+ <to uri="mock:b"/>
+ </setHeader>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+</beans>
Added:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest-context.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest-context.xml?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest-context.xml
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetHeaderWithConstantTest-context.xml
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- START SNIPPET: example -->
+ <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <setHeader headerName="theHeader" value="the value">
+ <expression/>
+ </setHeader>
+ <to uri="mock:b"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+</beans>
Added:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/convertBody.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/convertBody.xml?rev=647433&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/convertBody.xml
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/convertBody.xml
Sat Apr 12 04:35:45 2008
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- START SNIPPET: example -->
+ <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="direct:start"/>
+ <convertBodyTo type="java.lang.Integer"/>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+</beans>