[jboss-svn-commits] JBL Code SVN: r33759 - in labs/jbossesb/trunk/product: docs and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 7 11:36:12 EDT 2010
Author: tfennelly
Date: 2010-07-07 11:36:09 -0400 (Wed, 07 Jul 2010)
New Revision: 33759
Added:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/NamespaceContext.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/SxcXPathRouter.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/SxcXPathRouterUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/config.xml
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/rules.properties
Modified:
labs/jbossesb/trunk/product/.classpath
labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
labs/jbossesb/trunk/product/ivy.xml
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/RegexRouter.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/XPathRouter.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java
Log:
https://jira.jboss.org/browse/JBESB-2862
Add support for XPath based routing using SXC
Modified: labs/jbossesb/trunk/product/.classpath
===================================================================
--- labs/jbossesb/trunk/product/.classpath 2010-07-07 15:13:28 UTC (rev 33758)
+++ labs/jbossesb/trunk/product/.classpath 2010-07-07 15:36:09 UTC (rev 33759)
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/.svn/" kind="src" path="rosetta/src"/>
- <classpathentry kind="src" path="samples/quickstarts/spring_aop/src"/>
- <classpathentry kind="src" path="samples/quickstarts/spring_jpetstore/src"/>
<classpathentry excluding="**/.svn/" kind="src" path="rosetta/tests/resources"/>
<classpathentry excluding="**/.svn/" kind="src" path="rosetta/tests/src"/>
<classpathentry excluding="**/.svn/" kind="src" path="services/jbossesb/src/main/java"/>
@@ -191,5 +189,11 @@
<classpathentry kind="lib" path="services/spring/lib/ext/snowdrop/snowdrop-deployers-1.1.0.GA.jar"/>
<classpathentry kind="lib" path="services/spring/lib/ext/snowdrop/snowdrop-vfs-1.1.0.GA.jar"/>
<classpathentry kind="lib" path="services/spring/lib/ext/snowdrop/snowdrop-weaving-1.1.0.GA.jar"/>
+ <classpathentry kind="lib" path="build/lib/stax-api-1.0-2.jar"/>
+ <classpathentry kind="lib" path="build/lib/sxc-core-0.7.3.jar"/>
+ <classpathentry kind="lib" path="build/lib/sxc-runtime-0.7.3.jar"/>
+ <classpathentry kind="lib" path="build/lib/sxc-xpath-0.7.3.jar"/>
+ <classpathentry kind="lib" path="build/lib/wstx-asl-3.2.0.jar"/>
+ <classpathentry kind="lib" path="build/lib/jaxen-1.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/ivy.xml
===================================================================
--- labs/jbossesb/trunk/product/ivy.xml 2010-07-07 15:13:28 UTC (rev 33758)
+++ labs/jbossesb/trunk/product/ivy.xml 2010-07-07 15:36:09 UTC (rev 33759)
@@ -178,5 +178,9 @@
<dependency org="org.jboss.jopr" name="jopr-embedded-jbas5" rev="1.3.2.GA">
<artifact name="jopr-embedded-jbas5" type="war"/>
</dependency>
+
+ <!-- SXC XPath -->
+ <dependency org="com.envoisolutions.sxc" name="sxc-xpath" rev="0.7.3"/>
+
</dependencies>
</ivy-module>
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2010-07-07 15:13:28 UTC (rev 33758)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2010-07-07 15:36:09 UTC (rev 33759)
@@ -29,6 +29,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.actions.cbr.SxcXPathRouter;
import org.jboss.soa.esb.actions.cbr.XPathRouter;
import org.jboss.soa.esb.actions.cbr.RegexRouter;
import org.jboss.soa.esb.helpers.ConfigTree;
@@ -226,6 +227,8 @@
_cbrClass = DEFAULT_CBR_CLASS;
} else if(cbrAlias.equalsIgnoreCase("XPath")) {
_cbrClass = XPathRouter.class.getName();
+ } else if(cbrAlias.equalsIgnoreCase("SXC")) {
+ _cbrClass = SxcXPathRouter.class.getName();
} else if(cbrAlias.equalsIgnoreCase("Regex") || cbrAlias.equalsIgnoreCase("Regexp")) {
_cbrClass = RegexRouter.class.getName();
} else {
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/NamespaceContext.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/NamespaceContext.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/NamespaceContext.java 2010-07-07 15:36:09 UTC (rev 33759)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions.cbr;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.util.XPathNamespaceContext;
+
+/**
+ * Utility namespace configuration class.
+ *
+ * @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
+ */
+class NamespaceContext extends XPathNamespaceContext {
+
+ public NamespaceContext(ConfigTree[] namespaces) throws ConfigurationException {
+ if(namespaces != null) {
+ for(ConfigTree namespace : namespaces) {
+ String prefix = namespace.getRequiredAttribute("prefix");
+ String uri = namespace.getRequiredAttribute("uri");
+
+ setMapping(prefix, uri);
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/NamespaceContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/RegexRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/RegexRouter.java 2010-07-07 15:13:28 UTC (rev 33758)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/RegexRouter.java 2010-07-07 15:36:09 UTC (rev 33759)
@@ -20,18 +20,9 @@
package org.jboss.soa.esb.actions.cbr;
import org.jboss.soa.esb.services.routing.MessageRouterException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.util.XPathNamespaceContext;
-import org.jboss.soa.esb.ConfigurationException;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.apache.taglibs.bsf.expression;
-import javax.xml.xpath.*;
import java.util.*;
import java.util.regex.Pattern;
-import java.io.*;
/**
* Regex Content Based Router implementation.
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/SxcXPathRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/SxcXPathRouter.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/SxcXPathRouter.java 2010-07-07 15:36:09 UTC (rev 33759)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.cbr;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.util.XPathNamespaceContext;
+
+import com.envoisolutions.sxc.xpath.XPathBuilder;
+import com.envoisolutions.sxc.xpath.XPathEvaluator;
+import com.envoisolutions.sxc.xpath.XPathEvent;
+import com.envoisolutions.sxc.xpath.XPathEventHandler;
+import com.envoisolutions.sxc.xpath.XPathException;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.*;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+/**
+ * <a href="http://sxc.codehaus.org/XPath">SXC XPath</a> Content Based Router implementation.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class SxcXPathRouter extends AbstractPropertyRulesRouter {
+
+ private XPathNamespaceContext namespaceContext;
+
+ public void setConfigTree(ConfigTree configTree) throws MessageRouterException {
+ try {
+ namespaceContext = new NamespaceContext(configTree.getChildren("namespace"));
+ } catch (ConfigurationException e) {
+ throw new MessageRouterException("Error loading namespace prefix mappings.", e);
+ }
+
+ super.setConfigTree(configTree);
+ }
+
+ public Map<String, RoutingRule> buildRoutingMap(Properties rules) throws MessageRouterException {
+ Map<String, RoutingRule> routingMap = new HashMap<String, RoutingRule>();
+
+ Set<Map.Entry<Object, Object>> ruleSet = rules.entrySet();
+ for(Map.Entry<Object, Object> rule : ruleSet) {
+ String destinationName = (String) rule.getKey();
+ String expression = (String) rule.getValue();
+
+ try {
+ routingMap.put(destinationName, new SxcXpathRoutingRule(expression, namespaceContext));
+ } catch(XPathException e) {
+ throw new MessageRouterException("Error compiling XPath expression '" + expression + "'.", e);
+ }
+ }
+
+ return routingMap;
+ }
+
+ public javax.xml.namespace.NamespaceContext getNamespaceContext() {
+ return namespaceContext;
+ }
+
+ private static class SxcXpathRoutingRule implements RoutingRule {
+
+ private XPathEvaluator evaluator;
+ private String expression;
+ private static ThreadLocal<Boolean> matchTL = new ThreadLocal<Boolean>();
+
+ private SxcXpathRoutingRule(String expression, XPathNamespaceContext namespaceContext) {
+ this.expression = expression;
+
+ XPathEventHandler matchIdHandler = new XPathEventHandler() {
+ public void onMatch(XPathEvent event) throws XMLStreamException {
+ matchTL.set(true);
+ }
+ };
+
+ XPathBuilder builder = new XPathBuilder();
+ builder.addAllPrefixes(namespaceContext.getPrefixToURI());
+ builder.listen(expression, matchIdHandler);
+
+ evaluator = builder.compile();
+ }
+
+ public boolean evaluate(Object objectToTest) throws MessageRouterException {
+
+ try {
+ // Need to use a ThreadLocal because the SXC XPathEvaluator class
+ // doesn't support a context of any kind... so using the executing
+ // thread as our context...
+ matchTL.set(false);
+ evaluator.evaluate(toSource(objectToTest));
+ return matchTL.get();
+ } catch (Exception e) {
+ throw new MessageRouterException("Exception while evaluating SXC expression '" + expression + "'");
+ }
+ }
+
+ private Source toSource(Object objectToTest) throws MessageRouterException {
+ if(objectToTest instanceof String) {
+ return new StreamSource(new StringReader((String) objectToTest));
+ } else if(objectToTest instanceof byte[]) {
+ return new StreamSource(new ByteArrayInputStream((byte[]) objectToTest));
+ } else if(objectToTest instanceof Reader) {
+ return new StreamSource((Reader) objectToTest);
+ } else if(objectToTest instanceof InputStream) {
+ return new StreamSource((InputStream) objectToTest);
+// } else if(objectToTest instanceof Node) {
+ // Disabled.... with dom (at least) SXC has validation turned on, so if the message does not define an XSD/DTD, you get errors
+ // Can't see how to turn off validation (probably a STAX thing)... API not exposed (that I can see anyway).
+
+// return new DOMSource((Node)objectToTest);
+ } else {
+ throw new MessageRouterException("Unsupported SXC CBR payload type '" + objectToTest.getClass().getName() + "'.");
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/SxcXPathRouter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/XPathRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/XPathRouter.java 2010-07-07 15:13:28 UTC (rev 33758)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/XPathRouter.java 2010-07-07 15:36:09 UTC (rev 33759)
@@ -113,18 +113,4 @@
return false;
}
}
-
- private static class NamespaceContext extends XPathNamespaceContext {
-
- public NamespaceContext(ConfigTree[] namespaces) throws ConfigurationException {
- if(namespaces != null) {
- for(ConfigTree namespace : namespaces) {
- String prefix = namespace.getRequiredAttribute("prefix");
- String uri = namespace.getRequiredAttribute("uri");
-
- setMapping(prefix, uri);
- }
- }
- }
- }
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java 2010-07-07 15:13:28 UTC (rev 33758)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java 2010-07-07 15:36:09 UTC (rev 33759)
@@ -83,6 +83,14 @@
}
/**
+ * Get the Prefix to URI Mappings.
+ * @return The Prefix to URI Mappings.
+ */
+ public HashMap<String, String> getPrefixToURI() {
+ return prefixToURI;
+ }
+
+ /**
* Initialise the prefix/namespace URI mapping.
* @param prefix The prefix.
* @param uri The namespace URI.
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/SxcXPathRouterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/SxcXPathRouterUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/SxcXPathRouterUnitTest.java 2010-07-07 15:36:09 UTC (rev 33759)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.cbr.sxc;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.testutils.ESBConfigUtil;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.actions.cbr.SxcXPathRouter;
+import org.jboss.soa.esb.actions.cbr.RoutingRule;
+import org.xml.sax.SAXException;
+
+import javax.xml.namespace.NamespaceContext;
+import java.io.IOException;
+import java.io.File;
+import java.util.Map;
+import java.util.List;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class SxcXPathRouterUnitTest extends TestCase {
+
+ public void test_rulefile_load_classpath() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ test("1");
+ }
+
+ public void test_rulefile_load_filesys() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ String cwd = new File(".").getAbsolutePath().replace("\\", "/");
+ if(!cwd.endsWith("product/.")) {
+ throw new IllegalStateException("Invalid working directory for test. Must be the 'product/rosetta/tests' dir. Current working directory is '" + cwd + "'.");
+ }
+
+ test("2");
+ }
+
+ public void test_inlineRules() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ test("3");
+ }
+
+ public void test_namespaces_undefined() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ try {
+ test("4");
+ fail("Expected MessageRouterException");
+ } catch (MessageRouterException e) {
+ assertEquals("Error compiling XPath expression '/a:order/b:header[@cat='blue']'.", e.getMessage());
+ }
+ }
+
+ public void test_namespaces_defined() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ NamespaceContext nsContext = test("5");
+
+ assertEquals("http://a", nsContext.getNamespaceURI("a"));
+ assertEquals("http://b", nsContext.getNamespaceURI("b"));
+ }
+
+ private NamespaceContext test(String configName) throws MessageRouterException, IOException, SAXException, ConfigurationException {
+ ESBConfigUtil esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("config.xml"));
+ ConfigTree configTree = esbConfig.getActionConfig("null-listener", configName);
+ SxcXPathRouter router = new SxcXPathRouter();
+
+ router.setConfigTree(configTree);
+
+ Map<String, RoutingRule> map = router.getRoutingMap();
+ assertEquals(3, map.size());
+ assertNotNull(map.get("scat-red"));
+ assertNotNull(map.get("scat-green"));
+ assertNotNull(map.get("scat-blue"));
+
+ return router.getNamespaceContext();
+ }
+
+ public static final String GREEN_MESSAGE = "<order xmlns='http://a' xmlns:bbbb='http://b'><bbbb:header cat='green'/></order>";
+
+ public void test_routing_String() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ Message message = MessageFactory.getInstance().getMessage();
+
+ message.getBody().add(GREEN_MESSAGE);
+ test_routing(message, null);
+ }
+
+ public void test_routing_bytes() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ Message message = MessageFactory.getInstance().getMessage();
+
+ message.getBody().add(GREEN_MESSAGE.getBytes());
+ test_routing(message, null);
+ }
+
+ // Disabled.... with dom (at least) SXC has validation turned on, so if the message does not define an XSD/DTD, you get errors
+ // Can't see how to turn off validation (probably a STAX thing)... API not exposed (that I can see anyway).
+// public void test_routing_dom() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+// Message message = MessageFactory.getInstance().getMessage();
+//
+// message.getBody().add(YADOMUtil.parseStream(new ByteArrayInputStream(GREEN_MESSAGE.getBytes()), true, true, true));
+// test_routing(message, null);
+// }
+
+ public void test_routing_ObjectList() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ Message message = MessageFactory.getInstance().getMessage();
+
+ message.getBody().add("x", "<x/>");
+ message.getBody().add("y", GREEN_MESSAGE);
+ test_routing(message, Arrays.asList("y"));
+ test_routing(message, Arrays.asList("body.y"));
+ }
+
+ public void test_routing(Message message, List objectLists) throws IOException, SAXException, ConfigurationException, MessageRouterException {
+ ESBConfigUtil esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("config.xml"));
+ ConfigTree configTree = esbConfig.getActionConfig("null-listener", "5");
+ SxcXPathRouter router = new SxcXPathRouter();
+
+ router.setConfigTree(configTree);
+
+ List<String> destinations = router.route(null, false, message, objectLists);
+ assertEquals("[scat-green]", destinations.toString());
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/SxcXPathRouterUnitTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/config.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/config.xml (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/config.xml 2010-07-07 15:36:09 UTC (rev 33759)
@@ -0,0 +1,54 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+
+ <providers>
+ <bus-provider name="null"><bus busid="null"/></bus-provider>
+ </providers>
+
+ <services>
+ <service category="scat" name="sname" description="boo">
+
+ <listeners>
+ <listener name="null-listener" busidref="null" />
+ </listeners>
+
+ <actions mep="OneWay">
+ <action name="1" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+ <property name="ruleSet" value="/org/jboss/soa/esb/actions/cbr/xpath/rules.properties"/>
+ </action>
+
+ <action name="2" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+ <property name="ruleSet" value="rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/rules.properties"/>
+ </action>
+
+ <action name="3" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+ <property name="destinations">
+ <route-to service-category="scat" service-name="blue" expression="/order/header[@cat='blue']" />
+ <route-to service-category="scat" service-name="red" expression="/order/header[@cat='red']" />
+ <route-to service-category="scat" service-name="green" expression="/order/header[@cat='green']" />
+ </property>
+ </action>
+
+ <!-- Undefined namespaces.. should get an error... -->
+ <action name="4" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+ <property name="destinations">
+ <route-to service-category="scat" service-name="blue" expression="/a:order/b:header[@cat='blue']" />
+ </property>
+ </action>
+
+ <action name="5" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+ <property name="destinations">
+ <route-to service-category="scat" service-name="blue" expression="/a:order/b:header[@cat='blue']" />
+ <route-to service-category="scat" service-name="red" expression="/a:order/b:header[@cat='red']" />
+ <route-to service-category="scat" service-name="green" expression="/a:order/b:header[@cat='green']" />
+ </property>
+ <property name="namespaces">
+ <namespace prefix="a" uri="http://a" />
+ <namespace prefix="b" uri="http://b" />
+ </property>
+ </action>
+
+ </actions>
+ </service>
+ </services>
+</jbossesb>
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/rules.properties
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/rules.properties (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/rules.properties 2010-07-07 15:36:09 UTC (rev 33759)
@@ -0,0 +1,3 @@
+scat-blue=/order/header[@cat='blue']
+scat-red=/order/header[@cat='red']
+scat-green=/order/header[@cat='green']
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/sxc/rules.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jboss-svn-commits
mailing list