Author: jstrachan
Date: Thu Mar 20 04:23:17 2008
New Revision: 639249
URL: http://svn.apache.org/viewvc?rev=639249&view=rev
Log:
added test cases using the DSL or the XML for https://issues.apache.org/activemq/browse/CAMEL-241
Added:
activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterTest.java
- copied, changed from r638976, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/XPathFilterTest.java
activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java
(with props)
activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterNotMatchingTest.java
(with props)
activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterTest.java
(with props)
activemq/camel/trunk/components/camel-jxpath/src/test/resources/
activemq/camel/trunk/components/camel-jxpath/src/test/resources/log4j.properties (with
props)
activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/
activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/
activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/
activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/language/
activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/language/jxpath/
activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/language/jxpath/SpringJXPathFilterTest-context.xml
(with props)
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExpressionSupport.java
activemq/camel/trunk/components/camel-jxpath/pom.xml
activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPathExpression.java
activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathTest.java
activemq/camel/trunk/components/camel-spring/pom.xml
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExpressionSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExpressionSupport.java?rev=639249&r1=639248&r2=639249&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExpressionSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ExpressionSupport.java
Thu Mar 20 04:23:17 2008
@@ -35,7 +35,7 @@
public void assertMatches(String text, E exchange) {
if (!matches(exchange)) {
- throw new AssertionError(text + assertionFailureMessage(exchange) + " for exchange:
" + exchange);
+ throw new AssertionError(text + " " + assertionFailureMessage(exchange) + " for
exchange: " + exchange);
}
}
Modified: activemq/camel/trunk/components/camel-jxpath/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/pom.xml?rev=639249&r1=639248&r2=639249&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/pom.xml (original)
+++ activemq/camel/trunk/components/camel-jxpath/pom.xml Thu Mar 20 04:23:17 2008
@@ -44,6 +44,10 @@
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-jxpath</groupId>
<artifactId>commons-jxpath</artifactId>
<version>1.2</version>
@@ -54,6 +58,12 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Modified: activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPathExpression.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPathExpression.java?rev=639249&r1=639248&r2=639249&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPathExpression.java
(original)
+++ activemq/camel/trunk/components/camel-jxpath/src/main/java/org/apache/camel/language/jxpath/JXPathExpression.java
Thu Mar 20 04:23:17 2008
@@ -18,6 +18,7 @@
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
+import org.apache.camel.Message;
import org.apache.camel.impl.ExpressionSupport;
import org.apache.camel.language.ExpressionEvaluationException;
import org.apache.commons.jxpath.CompiledExpression;
@@ -48,7 +49,8 @@
public Object evaluate(Exchange exchange) {
try {
- Object result = getJXPathExpression().getValue(JXPathContext.newContext(exchange));
+ JXPathContext context = JXPathContext.newContext(exchange);
+ Object result = getJXPathExpression().getValue(context, type);
assertResultType(exchange, result);
return result;
} catch (JXPathException e) {
Copied: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterTest.java
(from r638976, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/XPathFilterTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterTest.java?p2=activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/XPathFilterTest.java&r1=638976&r2=639249&rev=639249&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/XPathFilterTest.java
(original)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterTest.java
Thu Mar 20 04:23:17 2008
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.processor;
+package org.apache.camel.language.jxpath;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
@@ -22,14 +22,12 @@
/**
* @version $Revision$
*/
-public class XPathFilterTest extends ContextTestSupport {
- protected String matchingBody = "<person name='James' city='London'/>";
- protected String notMatchingBody = "<person name='Hiram' city='Tampa'/>";
+public class JXPathFilterTest extends ContextTestSupport {
public void testSendMatchingMessage() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived(matchingBody);
+ getMockEndpoint("mock:result").expectedMessageCount(1);
- sendBody("direct:start", matchingBody);
+ sendBody("direct:start", new PersonBean("James", "London"));
assertMockEndpointsSatisifed();
}
@@ -37,7 +35,7 @@
public void testSendNotMatchingMessage() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(0);
- sendBody("direct:start", notMatchingBody);
+ sendBody("direct:start", new PersonBean("Hiram", "Tampa"));
assertMockEndpointsSatisifed();
}
@@ -47,10 +45,10 @@
public void configure() {
// START SNIPPET: example
from("direct:start").
- filter().xpath("/person[@name='James']").
+ filter().jxpath("in/body/name='James'").
to("mock:result");
// END SNIPPET: example
}
};
}
-}
+}
\ No newline at end of file
Modified: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathTest.java?rev=639249&r1=639248&r2=639249&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathTest.java
(original)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathTest.java
Thu Mar 20 04:23:17 2008
@@ -17,14 +17,18 @@
package org.apache.camel.language.jxpath;
import org.apache.camel.LanguageTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
import org.apache.camel.language.ExpressionEvaluationException;
/**
* Test for {@link JXPathExpression} and {@link JXPathLanguage}
*/
public class JXPathTest extends LanguageTestSupport {
-
- /**
+
+ protected PersonBean body = new PersonBean("James", "London");
+
+ /**
* Test JXPath expressions
*/
public void testJXPathExpressions() throws Exception {
@@ -48,10 +52,18 @@
public void testExceptions() throws Exception {
assertInvalidExpression(".@.");
assertInvalidExpression("ins/body");
- assertInvalidPredicate("in/body");
+ //assertInvalidPredicate("in/body");
}
+/*
+ @Override
+ protected void populateExchange(Exchange exchange) {
+ Message in = exchange.getIn();
+ in.setHeader("foo", "abc");
+ in.setHeader("bar", 123);
+ in.setBody(body);
+ }*/
- private void assertInvalidExpression(String expression) {
+ private void assertInvalidExpression(String expression) {
try {
assertExpression(expression, null);
fail("Expected an ExpressionEvaluationException");
Added: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java?rev=639249&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java
(added)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java
Thu Mar 20 04:23:17 2008
@@ -0,0 +1,50 @@
+/**
+ *
+ * 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.language.jxpath;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class PersonBean {
+ private String name;
+ private String location;
+
+ public PersonBean() {
+ }
+
+ public PersonBean(String name, String location) {
+ this.name = name;
+ this.location = location;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Propchange: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/PersonBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterNotMatchingTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterNotMatchingTest.java?rev=639249&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterNotMatchingTest.java
(added)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterNotMatchingTest.java
Thu Mar 20 04:23:17 2008
@@ -0,0 +1,31 @@
+/**
+ * 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.language.jxpath;
+
+/**
+ * @version $Revision: 630568 $
+ */
+public class SpringJXPathFilterNotMatchingTest extends SpringJXPathFilterTest {
+
+ public void testFilterWithJXPath() throws Exception {
+ endpoint.expectedMessageCount(0);
+
+ template.sendBody("direct:start", new PersonBean("Hiram", "Tampa"));
+
+ endpoint.assertIsSatisfied();
+ }
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterNotMatchingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterTest.java?rev=639249&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterTest.java
(added)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterTest.java
Thu Mar 20 04:23:17 2008
@@ -0,0 +1,43 @@
+/**
+ * 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.language.jxpath;
+
+import org.apache.camel.CamelTemplate;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+
+/**
+ * @version $Revision: 630568 $
+ */
+@ContextConfiguration
+public class SpringJXPathFilterTest extends AbstractJUnit38SpringContextTests {
+ @Autowired
+ protected CamelTemplate template;
+ @EndpointInject(uri = "mock:results")
+ protected MockEndpoint endpoint;
+
+ public void testFilterWithJXPath() throws Exception {
+ endpoint.expectedMessageCount(1);
+
+ template.sendBody("direct:start", new PersonBean("James", "London"));
+
+ endpoint.assertIsSatisfied();
+ }
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/SpringJXPathFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-jxpath/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/resources/log4j.properties?rev=639249&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/resources/log4j.properties Thu Mar
20 04:23:17 2008
@@ -0,0 +1,34 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+log4j.logger.org.apache.camel=WARN
+#log4j.logger.org.apache.camel.component.test=DEBUG
+
+
+log4j.logger.org.springframework=WARN
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
Propchange: activemq/camel/trunk/components/camel-jxpath/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/language/jxpath/SpringJXPathFilterTest-context.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/language/jxpath/SpringJXPathFilterTest-context.xml?rev=639249&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/language/jxpath/SpringJXPathFilterTest-context.xml
(added)
+++ activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/language/jxpath/SpringJXPathFilterTest-context.xml
Thu Mar 20 04:23:17 2008
@@ -0,0 +1,38 @@
+<?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
+ ">
+
+ <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+ <template id="myTemplate"/>
+
+ <route>
+ <from uri="direct:start"/>
+ <filter>
+ <jxpath>in/body/name='James'</jxpath>
+ <to uri="mock:results"/>
+ </filter>
+ </route>
+
+ </camelContext>
+
+</beans>
Propchange: activemq/camel/trunk/components/camel-jxpath/src/test/resources/org/apache/camel/language/jxpath/SpringJXPathFilterTest-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-spring/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/pom.xml?rev=639249&r1=639248&r2=639249&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/pom.xml (original)
+++ activemq/camel/trunk/components/camel-spring/pom.xml Thu Mar 20 04:23:17 2008
@@ -74,6 +74,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
|