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/07/10 16:59:15 UTC
svn commit: r554968 - in /activemq/camel/trunk/components/camel-spring/src:
main/java/org/apache/camel/spring/model/
main/resources/org/apache/camel/spring/model/
test/java/org/apache/camel/spring/model/
test/resources/org/apache/camel/spring/model/
Author: jstrachan
Date: Tue Jul 10 07:59:13 2007
New Revision: 554968
URL: http://svn.apache.org/viewvc?view=rev&rev=554968
Log:
got a simple expression language XML working along with a filter
Added:
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ExpressionType.java (with props)
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java (with props)
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java (with props)
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java (with props)
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTestTest.java (with props)
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlTestSupport.java (with props)
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processor.xml
- copied, changed from r554600, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildCustomProcessor.xml
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processorWithFilter.xml
- copied, changed from r554600, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildCustomProcessorWithFilter.xml
Modified:
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/CamelContextType.java
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FromType.java
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java
activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlParseTest.java
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/CamelContextType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/CamelContextType.java?view=diff&rev=554968&r1=554967&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/CamelContextType.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/CamelContextType.java Tue Jul 10 07:59:13 2007
@@ -61,4 +61,12 @@
public void setRoutes(List<RouteType> routes) {
this.routes = routes;
}
+
+ // Fluent API
+ //-------------------------------------------------------------------------
+ public RouteType route() {
+ RouteType route = new RouteType();
+ getRoutes().add(route);
+ return route;
+ }
}
Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ExpressionType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ExpressionType.java?view=auto&rev=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ExpressionType.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ExpressionType.java Tue Jul 10 07:59:13 2007
@@ -0,0 +1,29 @@
+/**
+ *
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlElements;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class ExpressionType {
+}
Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ExpressionType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java?view=auto&rev=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java Tue Jul 10 07:59:13 2007
@@ -0,0 +1,49 @@
+/**
+ *
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlAccessOrder;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorOrder;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@XmlRootElement(name = "filter")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class FilterType extends OutputType implements ProcessorType {
+ @XmlElements({@XmlElement(name = "expression", type = LanguageExpression.class)})
+ private LanguageExpressionSupport expression;
+
+ @Override
+ public String toString() {
+ return "Filter[if: " + getExpression() + " process: " + getProcessor() + "]";
+ }
+
+ public LanguageExpressionSupport getExpression() {
+ return expression;
+ }
+
+ public void setExpression(LanguageExpressionSupport expression) {
+ this.expression = expression;
+ }
+}
Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FromType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FromType.java?view=diff&rev=554968&r1=554967&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FromType.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FromType.java Tue Jul 10 07:59:13 2007
@@ -36,8 +36,8 @@
*
* @version $Revision: $
*/
-@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "from")
+@XmlAccessorType(XmlAccessType.FIELD)
public class FromType {
@XmlAttribute
private String uri;
Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java?view=auto&rev=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java Tue Jul 10 07:59:13 2007
@@ -0,0 +1,64 @@
+/**
+ *
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+
+/**
+ * Represents a parameterised language expression
+ *
+ * @version $Revision: 1.1 $
+ */
+@XmlRootElement(name = "expression")
+public class LanguageExpression implements LanguageExpressionSupport{
+ private String language;
+ private String expression;
+
+ public LanguageExpression() {
+ }
+
+ public LanguageExpression(String language, String expression) {
+ setLanguage(language);
+ setExpression(expression);
+ }
+
+ @Override
+ public String toString() {
+ return getLanguage() + "Expression[" + getExpression() + "]";
+ }
+
+ @XmlAttribute
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ @XmlValue
+ public String getExpression() {
+ return expression;
+ }
+
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+}
Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java?view=auto&rev=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java Tue Jul 10 07:59:13 2007
@@ -0,0 +1,35 @@
+/**
+ *
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlValue;
+
+/**
+ * A useful base class for an expression
+ *
+ * @version $Revision: 1.1 $
+ */
+public interface LanguageExpressionSupport {
+
+ public abstract String getExpression();
+
+ public abstract String getLanguage();
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java?view=diff&rev=554968&r1=554967&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java Tue Jul 10 07:59:13 2007
@@ -32,6 +32,7 @@
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class OutputType {
@XmlElements({
+ @XmlElement(name = "filter", type = FilterType.class),
@XmlElement(name = "process", type = ProcessorRef.class),
@XmlElement(name = "to", type = ToType.class)})
protected List<ProcessorType> processor = new ArrayList<ProcessorType>();
@@ -42,5 +43,23 @@
public void setProcessor(List<ProcessorType> processor) {
this.processor = processor;
+ }
+
+ public FilterType filter(LanguageExpressionSupport expression) {
+ FilterType filter = new FilterType();
+ filter.setExpression(expression);
+ getProcessor().add(filter);
+ return filter;
+ }
+
+ public FilterType filter(String language, String expression) {
+ return filter(new LanguageExpression(language, expression));
+ }
+
+ public OutputType to(String uri) {
+ ToType to = new ToType();
+ to.setUri(uri);
+ getProcessor().add(to);
+ return this;
}
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java?view=diff&rev=554968&r1=554967&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java Tue Jul 10 07:59:13 2007
@@ -31,6 +31,11 @@
@XmlAttribute(required = true)
private String ref;
+ @Override
+ public String toString() {
+ return "Processor[ref: " + ref + "]";
+ }
+
public String getRef() {
return ref;
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java?view=diff&rev=554968&r1=554967&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java Tue Jul 10 07:59:13 2007
@@ -30,6 +30,8 @@
import java.util.ArrayList;
import java.util.List;
+import sun.net.smtp.SmtpClient;
+
/**
* Represents an XML <route/> element
*
@@ -88,5 +90,14 @@
throw new IllegalArgumentException("No Endpoint found for uri: " + uri);
}
return answer;
+ }
+
+ // Fluent API
+ //-----------------------------------------------------------------------
+ public RouteType from(String uri) {
+ FromType from = new FromType();
+ from.setUri(uri);
+ getFrom().add(from);
+ return this;
}
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index?view=diff&rev=554968&r1=554967&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index Tue Jul 10 07:59:13 2007
@@ -1,5 +1,7 @@
CamelContextType
+FilterType
FromType
+LanguageExpression
ProcessorRef
RouteType
ToType
Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTestTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTestTest.java?view=auto&rev=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTestTest.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTestTest.java Tue Jul 10 07:59:13 2007
@@ -0,0 +1,48 @@
+/**
+ *
+ * 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.model;
+
+import junit.framework.TestCase;
+
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.JAXBContext;
+import java.io.StringWriter;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class GenerateXmlTestTest extends XmlTestSupport {
+
+ public void testCreateXml() throws Exception {
+ CamelContextType context = new CamelContextType();
+ RouteType route = context.route();
+ route.from("seda:a");
+ route.filter("juel", "in.header.foo == 'bar'").to("seda:b");
+
+ dump(context);
+ }
+
+ protected void dump(CamelContextType context) throws Exception {
+ Marshaller marshaller = jaxbContext.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ StringWriter buffer = new StringWriter();
+ marshaller.marshal(context, buffer);
+ log.info("Created: " + buffer);
+ }
+}
Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTestTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlParseTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlParseTest.java?view=diff&rev=554968&r1=554967&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlParseTest.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlParseTest.java Tue Jul 10 07:59:13 2007
@@ -29,28 +29,16 @@
/**
* @version $Revision: 1.1 $
*/
-public class XmlParseTest extends TestSupport {
- protected JAXBContext context;
-
- public void testParseXml() throws Exception {
- Object value = parseUri("example1.xml");
- CamelContextType context = assertIsInstanceOf(CamelContextType.class, value);
-
- log.info("Found: " + context);
+public class XmlParseTest extends XmlTestSupport {
+ public void testParseExample1Xml() throws Exception {
+ assertParseAsJaxb("example1.xml");
}
- protected Object parseUri(String uri) throws JAXBException {
- Unmarshaller unmarshaller = context.createUnmarshaller();
- URL resource = getClass().getResource(uri);
- assertNotNull("Cannot find resource on the classpath: " + uri, resource);
- Object value = unmarshaller.unmarshal(resource);
- return value;
+ public void testParseProcessorXml() throws Exception {
+ assertParseAsJaxb("processor.xml");
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- context = JAXBContext.newInstance("org.apache.camel.spring.model");
+ public void testParseProcessorWithFilterXml() throws Exception {
+ assertParseAsJaxb("processorWithFilter.xml");
}
}
Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlTestSupport.java?view=auto&rev=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlTestSupport.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlTestSupport.java Tue Jul 10 07:59:13 2007
@@ -0,0 +1,56 @@
+/**
+ *
+ * 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.model;
+
+import org.apache.camel.TestSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.JAXBContext;
+import java.net.URL;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class XmlTestSupport extends TestSupport {
+ protected final transient Log log = LogFactory.getLog(getClass());
+ protected JAXBContext jaxbContext;
+
+ protected CamelContextType assertParseAsJaxb(String uri) throws JAXBException {
+ Object value = parseUri(uri);
+ CamelContextType context = assertIsInstanceOf(CamelContextType.class, value);
+ log.info("Found: " + context);
+ return context;
+ }
+
+ protected Object parseUri(String uri) throws JAXBException {
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ URL resource = getClass().getResource(uri);
+ assertNotNull("Cannot find resource on the classpath: " + uri, resource);
+ Object value = unmarshaller.unmarshal(resource);
+ return value;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ jaxbContext = JAXBContext.newInstance("org.apache.camel.spring.model");
+ }
+}
Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/XmlTestSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processor.xml (from r554600, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildCustomProcessor.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processor.xml?view=diff&rev=554968&p1=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildCustomProcessor.xml&r1=554600&p2=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processor.xml&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildCustomProcessor.xml (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processor.xml Tue Jul 10 07:59:13 2007
@@ -15,26 +15,9 @@
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
- ">
-
- <!--
- from("seda:a").process(myProcessor);
- -->
- <!-- START SNIPPET: example -->
- <bean id="myProcessor" class="org.apache.camel.builder.MyProcessor"/>
-
- <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
- <route>
- <from uri="seda:a"/>
- <process ref="myProcessor"/>
- </route>
- </camelContext>
- <!-- END SNIPPET: example -->
-
-
-</beans>
+<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <process ref="myProcessor"/>
+ </route>
+</camelContext>
Copied: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processorWithFilter.xml (from r554600, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildCustomProcessorWithFilter.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processorWithFilter.xml?view=diff&rev=554968&p1=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildCustomProcessorWithFilter.xml&r1=554600&p2=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processorWithFilter.xml&r2=554968
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildCustomProcessorWithFilter.xml (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/model/processorWithFilter.xml Tue Jul 10 07:59:13 2007
@@ -15,32 +15,12 @@
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
- ">
-
- <!--
- from("seda:a").filter(header("foo").isEqualTo("bar")).process(myProcessor);
- -->
- <!-- START SNIPPET: example -->
- <bean id="myProcessor" class="org.apache.camel.builder.MyProcessor"/>
-
- <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
- <route>
- <from uri="seda:a"/>
- <filter>
- <predicate>
- <header name="foo"/>
- <isEqualTo value="bar"/>
- </predicate>
- </filter>
+<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <filter>
+ <expression language="juel">in.header.foo == 'bar'</expression>
<process ref="myProcessor"/>
- </route>
- </camelContext>
- <!-- END SNIPPET: example -->
-
-
-</beans>
+ </filter>
+ </route>
+</camelContext>