[jboss-svn-commits] JBL Code SVN: r20906 - in labs/jbossesb/trunk: product/samples/quickstarts/fun_cbr and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 4 10:57:52 EDT 2008
Author: beve
Date: 2008-07-04 10:57:52 -0400 (Fri, 04 Jul 2008)
New Revision: 20906
Added:
labs/jbossesb/trunk/product/services/jbrules/src/test/resources/5KBNS_message.xml
labs/jbossesb/trunk/product/services/jbrules/src/test/resources/RulesWithDslNS.drl
Modified:
labs/jbossesb/trunk/product/docs/ServicesGuide.odt
labs/jbossesb/trunk/product/docs/ServicesGuide.pdf
labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/FunCBRRules-XPath.drl
labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/SampleOrder.xml
labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/readme.txt
labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java
labs/jbossesb/trunk/product/services/jbrules/src/main/resources/XPathLanguage.dsl
labs/jbossesb/trunk/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/routing/cbr/DslHelperUnitTest.java
labs/jbossesb/trunk/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/rules/DroolsRuleServiceUnitTest.java
labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/FunCBRTest.java
Log:
Work for JBESB-1426 "CBR XPathDSL should allow namespace aware documents"
Modified: labs/jbossesb/trunk/product/docs/ServicesGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/docs/ServicesGuide.pdf
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/FunCBRRules-XPath.drl
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/FunCBRRules-XPath.drl 2008-07-04 14:40:55 UTC (rev 20905)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/FunCBRRules-XPath.drl 2008-07-04 14:57:52 UTC (rev 20906)
@@ -11,7 +11,7 @@
rule "Blue Routing Rule using XPATH"
when
- xpathEquals "/Order/@statusCode", "0"
+ xpathEquals expr "/order:Order/@statusCode", "0" use namespaces "order=http://org.jboss.soa.esb/Order"
then
Log : "Blue Team";
Destination : "blue";
@@ -19,7 +19,7 @@
rule "Red Routing Rule using XPATH"
when
- xpathEquals "/Order/@statusCode", "1"
+ xpathEquals expr "/order:Order/@statusCode", "1" use namespaces "order=http://org.jboss.soa.esb/Order"
then
Log : "Red Team";
Destination : "red";
@@ -27,8 +27,8 @@
rule "Green Routing Rule using XPATH"
when
- xpathEquals "/Order/@statusCode", "2"
+ xpathEquals expr "/order:Order/@statusCode", "2" use namespaces "order=http://org.jboss.soa.esb/Order"
then
Log : "Green Team";
Destination : "green";
-end
\ No newline at end of file
+end
Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/SampleOrder.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/SampleOrder.xml 2008-07-04 14:40:55 UTC (rev 20905)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/SampleOrder.xml 2008-07-04 14:57:52 UTC (rev 20906)
@@ -1,4 +1,4 @@
-<Order orderId="1" orderDate="Wed Nov 15 13:45:28 EST 2006" statusCode="0"
+<Order xmlns="http://org.jboss.soa.esb/Order" orderId="1" orderDate="Wed Nov 15 13:45:28 EST 2006" statusCode="0"
netAmount="59.97" totalAmount="64.92" tax="4.95">
<Customer userName="user1" firstName="Harry" lastName="Fletcher" state="SD"/>
<OrderLines>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/readme.txt 2008-07-04 14:40:55 UTC (rev 20905)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/readme.txt 2008-07-04 14:57:52 UTC (rev 20906)
@@ -5,6 +5,8 @@
determine which team receives the order for actually processing. In the case
of the green team, the order is first transformed to a different format prior
to routing.
+ This quickstart also show how namepaces can be used with xpath expressions.
+
Running this quickstart:
========================
Modified: labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java 2008-07-04 14:40:55 UTC (rev 20905)
+++ labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java 2008-07-04 14:57:52 UTC (rev 20906)
@@ -24,8 +24,10 @@
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
+import java.util.Map.Entry;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
@@ -33,11 +35,13 @@
import javax.xml.xpath.XPathFactory;
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.MessagePayloadProxy;
import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.util.XPathNamespaceContext;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
@@ -76,77 +80,227 @@
/**
* Uses XPath to evalutate if the XPath expression is true or false.
+ * This is the equivalent of calling selectAsBoolean( message, xpathExp, null).
*
* @param message -
* the ESB Message which body content will be used
* @param xpathExp -
* XPath expression
- * @return true
- * if the XPath expression evalutes to true
+ * @return Boolean
+ * true if the XPath expression evalutes to true
* @throws XPathExpressionException
* represents an error in an XPath expression
*/
public static Boolean selectAsBoolean(final Message message, final String xpathExp ) throws XPathExpressionException
+ {
+ return selectAsBoolean( message, xpathExp, null );
+ }
+
+ /**
+ * Uses XPath to evalutate if the XPath expression is true or false.
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @return Boolean
+ * true if the XPath expression evalutes to true
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static Boolean selectAsBoolean(final Message message, final String xpathExp, final Map<String,String> namespaces ) throws XPathExpressionException
{
XPathCacheObject<Boolean> cachedObject = xpathBooleanResults.get( xpathExp );
if ( cacheHit( cachedObject, message ) )
return cachedObject.getResult();
- XPath xpath = xpf.newXPath();
- InputSource inputSource = getInputSource(message);
- Boolean value = (Boolean) xpath.evaluate( xpathExp, inputSource, XPathConstants.BOOLEAN);
+ XPath xpath = getXPath( namespaces );
+ Boolean value = (Boolean) xpath.evaluate( xpathExp, getInputSource(message), XPathConstants.BOOLEAN);
xpathBooleanResults.put( xpathExp, new XPathCacheObject<Boolean>( message.hashCode(), value ) );
return value;
}
+ /**
+ * Uses XPath to select the Number matched by the XPath expression.
+ * <p/>
+ * This is the equivalent of calling selectAsNumber( message, xpathExp, null).
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @return Number -
+ * the Number if XPath found a match, or null if no match was found.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
public static Number selectAsNumber(final Message message, final String xpathExp ) throws XPathExpressionException
+ {
+ return selectAsNumber( message, xpathExp, null );
+ }
+
+ /**
+ * Uses XPath to select the Number matched by the XPath expression.
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @return Number -
+ * the Number if XPath found a match, or null if no match was found.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static Number selectAsNumber(final Message message, final String xpathExp, final Map<String,String> namespaces ) throws XPathExpressionException
{
- XPathCacheObject<Number> cachedObject = xpathNumberResults.get( xpathExp );
+ final XPathCacheObject<Number> cachedObject = xpathNumberResults.get( xpathExp );
if ( cacheHit( cachedObject, message ) )
return cachedObject.getResult();
- XPath xpath = xpf.newXPath();
- InputSource inputSource = getInputSource(message);
- Number number = (Number) xpath.evaluate( xpathExp, inputSource, XPathConstants.NUMBER);
+ final XPath xpath = getXPath( namespaces );
+ final Number number = (Number) xpath.evaluate( xpathExp, getInputSource(message), XPathConstants.NUMBER);
xpathNumberResults.put( xpathExp, new XPathCacheObject<Number>( message.hashCode(), number ) );
return number;
}
+ /**
+ * Uses XPath to select the String matched by the XPath expression.
+ * <p/>
+ * This is the equivalen of calling selectAsString( message, xpathExp, null).
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @return String -
+ * the String if XPath found a match, or null if no match was found.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
public static String selectAsString(final Message message, final String xpathExp ) throws XPathExpressionException
{
- XPathCacheObject<String> cachedObject = xpathStringResults.get( xpathExp );
+ return selectAsString( message, xpathExp, null );
+ }
+
+ /**
+ * Uses XPath to select the String matched by the XPath expression.
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @return String -
+ * the String if XPath found a match, or null if no match was found.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static String selectAsString(final Message message, final String xpathExp, final Map<String,String> namespaces ) throws XPathExpressionException
+ {
+ final XPathCacheObject<String> cachedObject = xpathStringResults.get( xpathExp );
if ( cacheHit( cachedObject, message ) )
return cachedObject.getResult();
- XPath xpath = xpf.newXPath();
- InputSource inputSource = getInputSource(message);
- String string = (String) xpath.evaluate( xpathExp, inputSource, XPathConstants.STRING);
+ final XPath xpath = getXPath( namespaces );
+ final String string = (String) xpath.evaluate( xpathExp, getInputSource(message), XPathConstants.STRING);
xpathStringResults.put( xpathExp, new XPathCacheObject<String>( message.hashCode(), string ) );
return string;
}
+
+ /**
+ * Uses XPath to select the Node matched by the XPath expression.
+ * <p/>
+ * This is the equivalent of calling selectAsNode( message, xpathExp null).
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @return Node -
+ * the Node if XPath found a match, or null if no match was found.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
public static Node selectAsNode(final Message message, final String xpathExp ) throws XPathExpressionException
+ {
+ return selectAsNode( message, xpathExp, null );
+ }
+
+ /**
+ * Uses XPath to select the Node matched by the XPath expression.
+ * <p/>
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @return Node -
+ * the Node if XPath found a match, or null if no match was found.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static Node selectAsNode(final Message message, final String xpathExp, final Map<String,String> namespaces ) throws XPathExpressionException
{
- XPathCacheObject<Node> cachedObject = xpathNodeResults.get( xpathExp );
+ final XPathCacheObject<Node> cachedObject = xpathNodeResults.get( xpathExp );
if ( cacheHit( cachedObject, message ) )
return cachedObject.getResult();
- XPath xpath = xpf.newXPath();
- InputSource inputSource = getInputSource(message);
- Node node = (Node) xpath.evaluate( xpathExp, inputSource, XPathConstants.NODE);
+ final XPath xpath = getXPath( namespaces );
+ final Node node = (Node) xpath.evaluate( xpathExp, getInputSource(message), XPathConstants.NODE);
xpathNodeResults.put( xpathExp, new XPathCacheObject<Node>( message.hashCode(), node ) );
return node;
}
+ /**
+ * Uses XPath to select the NodeList matched by the XPath expression.
+ * <p/>
+ * This is the equivalent of calling selectAsNodeList( message, xpathExp null).
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @return NodeList -
+ * the NodeList if XPath found a match, or null if no match was found.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
public static NodeList selectAsNodeList( final Message message, final String xpathExp ) throws XPathExpressionException
+ {
+ return selectAsNodeList( message, xpathExp, null );
+ }
+
+ /**
+ * Uses XPath to select the NodeList matched by the XPath expression.
+ * <p/>
+ *
+ * @param message -
+ * the ESB Message which body content will be used
+ * @param xpathExp -
+ * XPath expression
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @return NodeList -
+ * the NodeList if XPath found a match, or null if no match was found.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static NodeList selectAsNodeList( final Message message, final String xpathExp, Map<String,String> namespaces ) throws XPathExpressionException
{
- XPathCacheObject<NodeList> cachedObject = xpathNodeListResults.get( xpathExp );
+ final XPathCacheObject<NodeList> cachedObject = xpathNodeListResults.get( xpathExp );
if ( cacheHit( cachedObject, message ) )
return cachedObject.getResult();
- XPath xpath = xpf.newXPath();
- InputSource inputSource = getInputSource(message);
- NodeList nodeList = (NodeList) xpath.evaluate(xpathExp, inputSource, XPathConstants.NODESET);
+ final XPath xpath = getXPath( namespaces );
+ final NodeList nodeList = (NodeList) xpath.evaluate(xpathExp, getInputSource(message), XPathConstants.NODESET);
log.info("XPath [" + xpathExp + "], nr of matches : " + nodeList.getLength());
xpathNodeListResults.put( xpathExp, new XPathCacheObject<NodeList>( message.hashCode(), nodeList ) );
return nodeList;
@@ -156,8 +310,9 @@
* Uses XPath to look for the occurence of a certain node, specified in the XPath expression.
* This can be used to find out if the Message object contains the node specified by the XPath
* expression.
+ * <p/>
+ * This is the equivalent of calling xmlContentMatches( message, xpathExp, null).
*
- *
* @param message -
* the ESB Message which body content will be used.
* @param xpathExp -
@@ -169,14 +324,37 @@
*/
public static boolean xmlContentMatches(final Message message, final String xpathExp) throws XPathExpressionException
{
- return selectAsNode( message, xpathExp ) != null ;
+ return xmlContentMatches( message, xpathExp, null );
}
/**
+ * Uses XPath to look for the occurence of a certain node, specified in the XPath expression.
+ * This can be used to find out if the Message object contains the node specified by the XPath
+ * expression.
+ *
+ * @param message -
+ * the ESB Message which body content will be used.
+ * @param xpathExp -
+ * XPath expression to find a node.
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @return true
+ * if the node is found and false in all other cases.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static boolean xmlContentMatches(final Message message, final String xpathExp, final Map<String,String> namespaces ) throws XPathExpressionException
+ {
+ return selectAsNode( message, xpathExp, namespaces ) != null ;
+ }
+
+ /**
* Uses XPath to look for any occurence of a certain tag, specific in the xpath expression.
* This can be used to find out if the Message object contains the node specified by the XPath
* Note, that this method cannot be used with a boolean expression, use {@link #selectAsBoolean(Message, String)}
* for that.
+ * <p/>
+ * This is the equivalent of calling xmlContentExists( message, xpathExp, null).
*
* @param message -
* the ESB Message which body content will be used.
@@ -189,7 +367,29 @@
*/
public static boolean xmlContentExists(final Message message, final String xpathExp) throws XPathExpressionException
{
- NodeList nodeList = selectAsNodeList( message, xpathExp );
+ return xmlContentExists( message, xpathExp, null );
+ }
+
+ /**
+ * Uses XPath to look for any occurence of a certain tag, specific in the xpath expression.
+ * This can be used to find out if the Message object contains the node specified by the XPath
+ * Note, that this method cannot be used with a boolean expression, use {@link #selectAsBoolean(Message, String)}
+ * for that.
+ *
+ * @param message -
+ * the ESB Message which body content will be used.
+ * @param xpathExp -
+ * XPath expression to find a node.
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @return true
+ * if one or more nodes are found and false in all other cases.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static boolean xmlContentExists(final Message message, final String xpathExp, final Map<String,String> namespaces ) throws XPathExpressionException
+ {
+ final NodeList nodeList = selectAsNodeList( message, xpathExp, namespaces );
return nodeList == null ? false : nodeList.getLength() > 0 ;
}
@@ -203,6 +403,8 @@
* String xpathExp = "/Order/OrderLines/OrderLine/Product/@productId = 364";
* }</pre>
* <br>
+ * <p/>
+ * This is the equivalent of calling xmlContentEquals( message, xpathExp, null).
*
* @param message -
* the ESB Message which body content will be used.
@@ -215,12 +417,41 @@
*/
public static boolean xmlContentEquals(final Message message, final String xpathExp, final String value ) throws XPathExpressionException
{
- String xpathResult = selectAsString( message, xpathExp );
+ return xmlContentEquals( message, xpathExp, value, null );
+ }
+
+ /**
+ * Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+ * </p>
+ * Note that {@link #selectAsBoolean(Message, String)} can be used instead of this method
+ * and the XPath equality operator can be used in the XPath expression:
+ * <br>
+ * <pre>{@code
+ * String xpathExp = "/Order/OrderLines/OrderLine/Product/@productId = 364";
+ * }</pre>
+ * <br>
+ *
+ * @param message -
+ * the ESB Message which body content will be used.
+ * @param xpathExp -
+ * XPath expression to find a node.
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @return true -
+ * if the node is found and false in all other cases.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static boolean xmlContentEquals(final Message message, final String xpathExp, final String value, final Map<String,String> namespaces ) throws XPathExpressionException
+ {
+ final String xpathResult = selectAsString( message, xpathExp, namespaces );
return xpathResult == null ? false : xpathResult.equals( value );
}
/**
* Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+ * <p/>
+ * This is the equivalent of calling xmlContentGreaterThan( message, xpathExp, value, null).
*
* @param message -
* the ESB Message which body content will be used.
@@ -233,16 +464,37 @@
*/
public static boolean xmlContentGreaterThan( final Message message, final String xpathExp, final String value) throws XPathExpressionException
{
- final String xpathResult = (String) selectAsString( message, xpathExp );
+ return xmlContentGreaterThan( message, xpathExp, value, null );
+ }
+
+ /**
+ * Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+ *
+ * @param message -
+ * the ESB Message which body content will be used.
+ * @param xpathExp -
+ * XPath expression to find a node.
+ * @param namespaces -
+ * Map of namespaces to be used in the xpath expression. Key=prefix,value = uri
+ * @return true
+ * if the node is found and false in all other cases.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static boolean xmlContentGreaterThan( final Message message, final String xpathExp, final String value, final Map<String,String> namespaces) throws XPathExpressionException
+ {
+ final String xpathResult = (String) selectAsString( message, xpathExp, namespaces );
if ( xpathResult != null && !"".equals( xpathResult ) )
return parseDouble( xpathResult ) > parseDouble( value );
else
return false;
}
-
- /**
+
+ /**
* Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+ * <p/>
+ * This is the equivalent of calling xmlContentLessThan( message, xpathExp, value, null).
*
* @param message -
* the ESB Message which body content will be used.
@@ -253,16 +505,53 @@
* @throws XPathExpressionException
* represents an error in an XPath expression
*/
- public static boolean xmlContentLessThan( final Message message, final String xpathExp, final String value ) throws XPathExpressionException
+ public static boolean xmlContentLessThan( final Message message, final String xpathExp, final String value) throws XPathExpressionException
+ {
+ return xmlContentLessThan( message, xpathExp, value, null );
+ }
+
+ /**
+ * Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+ *
+ * @param message -
+ * the ESB Message which body content will be used.
+ * @param xpathExp -
+ * XPath expression to find a node.
+ * @return true
+ * if the node is found and false in all other cases.
+ * @throws XPathExpressionException
+ * represents an error in an XPath expression
+ */
+ public static boolean xmlContentLessThan( final Message message, final String xpathExp, final String value, final Map<String,String> namespaces) throws XPathExpressionException
+ {
+ final String xpathResult = (String) selectAsString( message, xpathExp, namespaces );
+
+ if ( xpathResult != null && !"".equals( xpathResult ) )
+ return parseDouble( xpathResult ) < parseDouble( value );
+ else
+ return false;
+ }
+
+ /**
+ * Will take the passed in string of namespaces in the form "prefix=uri,prefix=uri".
+ *
+ * @param namespaces string of namespaces in the form "prefix=uri,prefix=uri"
+ * @return Map<String,String> where the key will be the namespace prefix and the value the uri
+ */
+ public static Map<String, String> parseNamespaces( final String namespaces )
{
- final String xpathResult = (String) selectAsString( message, xpathExp );
-
- if ( xpathResult != null && !"".equals( xpathResult ) )
- return parseDouble( xpathResult ) < parseDouble( value );
- else
- return false;
+ AssertArgument.isNotNullAndNotEmpty( namespaces, "namespaces" );
+
+ final String[] namespacesElements = namespaces.split( "," );
+ final Map<String,String> namespacesMap = new HashMap<String,String>();
+ for ( String ns : namespacesElements )
+ {
+ final String[] pairs = ns.split( "=" );
+ namespacesMap.put( pairs[0].trim(), pairs[1].trim() );
+ }
+ return namespacesMap;
}
-
+
/*
* Checks if the cachedObject was non-null, and if so, checks the message hashCode against
* the cachedObjects messageHashCode.
@@ -283,7 +572,20 @@
throw new XPathExpressionException("Could not parse value [" + string + "] to double" );
}
}
+
+ private static void setNamespaces( final XPath xpath, final Map<String,String> namespaces )
+ {
+ if ( namespaces == null )
+ return;
+ final XPathNamespaceContext namespaceContext = new XPathNamespaceContext();
+ for ( Entry<String, String> entry : namespaces.entrySet() )
+ namespaceContext.setMapping( entry.getKey(), entry.getValue() );
+
+ xpath.setNamespaceContext( namespaceContext );
+ }
+
+
private static InputSource getInputSource(Message message) throws XPathExpressionException
{
Object payload;
@@ -311,6 +613,13 @@
}
}
+ private static XPath getXPath( final Map<String,String> namespaces )
+ {
+ final XPath xpath = xpf.newXPath();
+ setNamespaces( xpath, namespaces );
+ return xpath;
+ }
+
/**
* XPathCacheObject holds results from XPath evaluations and message object instance hashcodes.
* </p>
@@ -358,5 +667,6 @@
return result;
}
}
+
}
Modified: labs/jbossesb/trunk/product/services/jbrules/src/main/resources/XPathLanguage.dsl
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/main/resources/XPathLanguage.dsl 2008-07-04 14:40:55 UTC (rev 20905)
+++ labs/jbossesb/trunk/product/services/jbrules/src/main/resources/XPathLanguage.dsl 2008-07-04 14:57:52 UTC (rev 20906)
@@ -5,3 +5,9 @@
[when]xpathLessThan "{xpath}", "{value}"=msg : org.jboss.soa.esb.message.Message( type == org.jboss.soa.esb.message.format.MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentLessThan(msg, "{xpath}", "{value}") )
[then]Log : "{message}"=System.out.println("{message}");
[then]Destination : "{message}"=destinations.add("{message}");
+
+# Namespace(NS) aware methods
+[when]xpathMatch expr "{xpath}" use namespaces "{namespaces}"=msg : org.jboss.soa.esb.message.Message( type == org.jboss.soa.esb.message.format.MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentMatches(msg, "{xpath}",org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.parseNamespaces("{namespaces}")) )
+[when]xpathEquals expr "{xpath}", "{value}" use namespaces "{namespaces}"=msg : org.jboss.soa.esb.message.Message( type == org.jboss.soa.esb.message.format.MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentEquals(msg, "{xpath}", "{value}",org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.parseNamespaces("{namespaces}")))
+[when]xpathGreaterThan expr "{xpath}", "{value}" use namespaces "{namespaces}"=msg : org.jboss.soa.esb.message.Message( type == org.jboss.soa.esb.message.format.MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentGreaterThan(msg, "{xpath}", "{value}",org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.parseNamespaces("{namespaces}") ) )
+[when]xpathLessThan expr "{xpath}", "{value}" use namespaces "{namespaces}"=msg : org.jboss.soa.esb.message.Message( type == org.jboss.soa.esb.message.format.MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentLessThan(msg, "{xpath}", "{value}", org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.parseNamespaces("{namespaces}") ))
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/routing/cbr/DslHelperUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/routing/cbr/DslHelperUnitTest.java 2008-07-04 14:40:55 UTC (rev 20905)
+++ labs/jbossesb/trunk/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/routing/cbr/DslHelperUnitTest.java 2008-07-04 14:57:52 UTC (rev 20906)
@@ -23,14 +23,18 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.xml.xpath.XPathExpressionException;
+import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
@@ -47,7 +51,14 @@
*/
public class DslHelperUnitTest
{
+ private Logger log = Logger.getLogger( DslHelperUnitTest.class );
+
+ // message with xml content in body
private static Message msg;
+
+ // message with namespace context in body
+ private static Message nsmsg;
+ private static HashMap<String, String> namespaces;
@Test
public void xmlContentExists() throws XPathExpressionException, UnsupportedEncodingException
@@ -58,6 +69,17 @@
}
@Test
+ public void xmlContentExistsWithNamespaces() throws XPathExpressionException, UnsupportedEncodingException
+ {
+ assertTrue( DslHelper.xmlContentExists( nsmsg, "/ord:Order/ord:OrderLines/ord:OrderLine/p:Product", namespaces ) );
+ assertTrue( DslHelper.xmlContentExists( nsmsg, "//p:Product", namespaces ) );
+
+ HashMap<String, String> oneNamspace = new HashMap<String,String>();
+ oneNamspace.put( "ord", "http://org.jboss.soa.esb/order" );
+ assertTrue( DslHelper.xmlContentExists( nsmsg, "/ord:Order", oneNamspace ) );
+ }
+
+ @Test
public void xmlContentMatches() throws XPathExpressionException, UnsupportedEncodingException
{
assertTrue( DslHelper.xmlContentMatches( msg, "//*[@productId = 299]" ) );
@@ -66,6 +88,12 @@
}
@Test
+ public void xmlContentMatchesWithNamespaces() throws XPathExpressionException, UnsupportedEncodingException
+ {
+ assertTrue( DslHelper.xmlContentMatches( nsmsg, "/ord:Order/ord:OrderLines/ord:OrderLine/p:Product", namespaces ) );
+ }
+
+ @Test
public void selectAsBoolean() throws UnsupportedEncodingException, XPathExpressionException
{
assertTrue( DslHelper.selectAsBoolean( msg, "/Order/OrderLines/OrderLine/Product/@productId = 364" ) );
@@ -75,30 +103,60 @@
}
@Test
+ public void selectAsBooleanWithNamespaces() throws UnsupportedEncodingException, XPathExpressionException
+ {
+ assertTrue( DslHelper.selectAsBoolean( nsmsg, "/ord:Order/ord:OrderLines/ord:OrderLine/p:Product/@productId = 364", namespaces ) );
+ }
+
+ @Test
public void selectAsNumber() throws UnsupportedEncodingException, XPathExpressionException
{
assertEquals ( 364, DslHelper.selectAsNumber( msg, "//Product/@productId" ).intValue() );
}
@Test
+ public void selectAsNumberWithNamespaces() throws UnsupportedEncodingException, XPathExpressionException
+ {
+ assertEquals ( 364, DslHelper.selectAsNumber( msg, "//Product/@productId", namespaces ).intValue() );
+ }
+
+ @Test
public void selectAsString() throws UnsupportedEncodingException, XPathExpressionException
{
assertEquals ( "364", DslHelper.selectAsString( msg, "//Product/@productId" ) );
}
@Test
+ public void selectAsStringWithNamespaces() throws UnsupportedEncodingException, XPathExpressionException
+ {
+ assertEquals ( "364", DslHelper.selectAsString( nsmsg, "//p:Product/@productId", namespaces ) );
+ }
+
+ @Test
public void selectAsNode() throws UnsupportedEncodingException, XPathExpressionException
{
assertEquals ( "productId", DslHelper.selectAsNode( msg, "/Order/OrderLines/OrderLine/Product/@productId").getNodeName() );
}
@Test
+ public void selectAsNodeWithNamespaces() throws UnsupportedEncodingException, XPathExpressionException
+ {
+ assertEquals ( "productId", DslHelper.selectAsNode( nsmsg, "/ord:Order/ord:OrderLines/ord:OrderLine/p:Product/@productId", namespaces ).getNodeName() );
+ }
+
+ @Test
public void selectAsNodeList() throws UnsupportedEncodingException, XPathExpressionException
{
assertEquals ( 42, DslHelper.selectAsNodeList( msg, "//Product/@productId" ).getLength() );
}
@Test
+ public void selectAsNodeListWithNamespaces() throws UnsupportedEncodingException, XPathExpressionException
+ {
+ assertEquals ( 2, DslHelper.selectAsNodeList( nsmsg, "//p:Product/@productId", namespaces ).getLength() );
+ }
+
+ @Test
public void xmlContentEquals() throws UnsupportedEncodingException, XPathExpressionException
{
assertTrue( DslHelper.xmlContentEquals( msg, "/Order/OrderLines/OrderLine/Product/@productId", "364" ) );
@@ -106,6 +164,12 @@
}
@Test
+ public void xmlContentEqualsWithNamespaces() throws UnsupportedEncodingException, XPathExpressionException
+ {
+ assertTrue( DslHelper.xmlContentEquals( nsmsg, "/ord:Order/ord:OrderLines/ord:OrderLine/p:Product/@productId", "364", namespaces ) );
+ }
+
+ @Test
public void xmlContentGreaterThan() throws UnsupportedEncodingException, XPathExpressionException
{
assertTrue( DslHelper.xmlContentGreaterThan( msg, "/Order/OrderLines/OrderLine/Product/@productId", "363" ) );
@@ -113,6 +177,12 @@
assertFalse( DslHelper.xmlContentGreaterThan( msg, "/Order/OrderLines/OrderLine/Product/@productId", "364" ) );
}
+ @Test
+ public void xmlContentGreaterThanWithNamespaces() throws UnsupportedEncodingException, XPathExpressionException
+ {
+ assertTrue( DslHelper.xmlContentGreaterThan( nsmsg, "/ord:Order/ord:OrderLines/ord:OrderLine/p:Product/@productId", "363", namespaces ) );
+ }
+
@Test ( expected = XPathExpressionException.class )
public void shouldThrowIfArgumentIsNotAParsableDouble() throws UnsupportedEncodingException, XPathExpressionException
{
@@ -129,6 +199,12 @@
}
@Test
+ public void xmlContentLessThanWithNamespaces() throws UnsupportedEncodingException, XPathExpressionException
+ {
+ assertTrue( DslHelper.xmlContentLessThan( nsmsg, "/ord:Order/ord:OrderLines/ord:OrderLine/p:Product/@productId", "366", namespaces));
+ }
+
+ @Test
public void xmlContentEqualsPerformanceTest() throws UnsupportedEncodingException, XPathExpressionException
{
int nrOfCalls = 4000;
@@ -139,11 +215,26 @@
DslHelper.xmlContentEquals( msg, "/Order/OrderLines/OrderLine/Product/@productId", "364" );
}
long endTime = TimeUnit.NANOSECONDS.toMillis( System.nanoTime() - startTime );
- System.out.println( "Timed " + nrOfCalls + " runs : " + endTime + "ms" );
+ log.info( "Timed " + nrOfCalls + " runs : " + endTime + "ms" );
assertTrue( nrOfCalls + " of calls should have taken less then 150ms", endTime < 150 );
-
}
+ @Test
+ public void parseNamespaces()
+ {
+ Map<String,String> namespaces = DslHelper.parseNamespaces( "pro=http://org.jboss.soa.esb/product, ord=http://org.jboss.soa.esb/order" );
+ assertNotNull( namespaces );
+ assertEquals( 2, namespaces.size() );
+ assertTrue( namespaces.containsKey( "pro" ) );
+ assertTrue( namespaces.containsKey( "ord" ) );
+ }
+
+ @Test ( expected = IllegalArgumentException.class )
+ public void parseNamespacesNegative()
+ {
+ DslHelper.parseNamespaces( null );
+ }
+
@BeforeClass
public static void createMessage() throws UnsupportedEncodingException
{
@@ -153,4 +244,17 @@
msg.getBody().add( contents );
}
+ @BeforeClass
+ public static void createNamespaceMessage() throws UnsupportedEncodingException
+ {
+ nsmsg = MessageFactory.getInstance().getMessage();
+ InputStream resourceAsStream = ClassUtil.getResourceAsStream( "/" + "5KBNS_message.xml", DslHelperUnitTest.class );
+ String contents = StreamUtils.readStreamString( resourceAsStream, "UTF-8" );
+ nsmsg.getBody().add( contents );
+
+ namespaces = new HashMap<String,String>();
+ namespaces.put( "ord", "http://org.jboss.soa.esb/order" );
+ namespaces.put( "p", "http://org.jboss.soa.esb/product" );
+ }
+
}
Modified: labs/jbossesb/trunk/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/rules/DroolsRuleServiceUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/rules/DroolsRuleServiceUnitTest.java 2008-07-04 14:40:55 UTC (rev 20905)
+++ labs/jbossesb/trunk/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/rules/DroolsRuleServiceUnitTest.java 2008-07-04 14:57:52 UTC (rev 20906)
@@ -22,16 +22,13 @@
package org.jboss.internal.soa.esb.services.rules;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-import java.io.FileInputStream;
-import java.io.FileReader;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -39,6 +36,7 @@
import java.util.concurrent.TimeUnit;
import junit.framework.JUnit4TestAdapter;
+
import org.drools.RuleBase;
import org.drools.agent.RuleAgent;
import org.jboss.internal.soa.esb.services.routing.cbr.Order;
@@ -174,6 +172,21 @@
}
@Test
+ public void executeStatelessRulesDrlWithDslAndNamespaces() throws RuleServiceException, ConfigurationException, UnsupportedEncodingException
+ {
+ Message msg = MessageFactory.getInstance().getMessage();
+ InputStream resourceAsStream = ClassUtil.getResourceAsStream( "/" + "5KBNS_message.xml", getClass() );
+ String contents = StreamUtils.readStreamString( resourceAsStream, "UTF-8" );
+ msg.getBody().add( contents );
+ Map<String,Object> globals = getGlobalsWithDest();
+ boolean ruleReload = true;
+
+ message = ruleService.executeStatelessRules( "RulesWithDslNS.drl", "XPathLanguage.dsl", ruleReload, msg, globals, null );
+ ArrayList<String> destinations = getDistinations( globals );
+ assertEquals( 3 , destinations.size() );
+ }
+
+ @Test
public void executeStatefulRulesContinueSession() throws RuleServiceException, ObjectMappingException
{
Message message = createMessageWithOrder( order );
@@ -246,7 +259,6 @@
assertEquals ( rBase, ruleService.getCachedRuleBases().get( ruleAgentProperites ) );
}
-
// Test setup methods
@Before
@@ -269,8 +281,6 @@
return new JUnit4TestAdapter( DroolsRuleServiceUnitTest.class );
}
- // private methods
-
@SuppressWarnings("unchecked")
private ArrayList<String> getDistinations( final Map<String,Object> globals )
{
Added: labs/jbossesb/trunk/product/services/jbrules/src/test/resources/5KBNS_message.xml
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/test/resources/5KBNS_message.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/jbrules/src/test/resources/5KBNS_message.xml 2008-07-04 14:57:52 UTC (rev 20906)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Order xmlns="http://org.jboss.soa.esb/order"
+ orderId="1" orderDate="Wed Nov 15 13:45:28 EST 2006" statusCode="0" netAmount="59.97" totalAmount="64.92" tax="4.95">
+ <Customer xmlns="http://org.jboss.soa.esb/customer" userName="user1" firstName="Harry" lastName="Fletcher" state="SD"/>
+ <OrderLines>
+ <OrderLine position="1" quantity="1">
+ <prod:Product xmlns:prod="http://org.jboss.soa.esb/product" productId="364" title="The 40-Year-Old Virgin " price="29.98"/>
+ </OrderLine>
+ <OrderLine position="2" quantity="2">
+ <prod2:Product xmlns:prod2="http://org.jboss.soa.esb/product" productId="364" title="The 40-Year-Old Virgin " price="29.98"/>
+ </OrderLine>
+ </OrderLines>
+</Order>
Added: labs/jbossesb/trunk/product/services/jbrules/src/test/resources/RulesWithDslNS.drl
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/test/resources/RulesWithDslNS.drl (rev 0)
+++ labs/jbossesb/trunk/product/services/jbrules/src/test/resources/RulesWithDslNS.drl 2008-07-04 14:57:52 UTC (rev 20906)
@@ -0,0 +1,809 @@
+package com.jboss.soa.esb.routing.cbr
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageType;
+import javax.xml.xpath.XPathExpression;
+
+expander XPathLanguage.dsl
+
+global java.util.List destinations;
+
+rule "ProductId1"
+ salience 99
+ when
+ xpathMatch expr "/order:Order/order:OrderLines/order:OrderLine/prod:Product/@productId" use namespaces "order=http://org.jboss.soa.esb/order,prod=http://org.jboss.soa.esb/product"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId2"
+ salience 99
+ when
+ xpathEquals expr "/order:Order/order:OrderLines/order:OrderLine/prod:Product/@productId", "364" use namespaces "order=http://org.jboss.soa.esb/order,prod=http://org.jboss.soa.esb/product"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId3"
+ salience 99
+ when
+ xpathGreaterThan expr "/o:Order/o:OrderLines/o:OrderLine/p:Product/@productId", "200" use namespaces "o=http://org.jboss.soa.esb/order,p=http://org.jboss.soa.esb/product"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId4"
+ salience 99
+ when
+ xpathLessThan expr "/o:Order/o:OrderLines/o:OrderLine/p:Product/@productId", "200" use namespaces "o=http://org.jboss.soa.esb/order,p=http://org.jboss.soa.esb/product"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId5"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "5"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId6"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "6"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId7"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "7"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId8"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "8"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId9"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "9"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId10"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "10"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId11"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "11"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId12"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "12"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId13"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "13"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId14"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "14"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId15"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "15"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId16"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "16"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId17"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "17"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId18"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "18"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId19"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "19"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId20"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "20"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId21"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "21"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId22"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "22"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId23"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "23"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId24"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "24"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId25"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "25"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId26"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "26"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId27"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "27"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId28"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "28"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId29"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "29"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId30"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "30"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId31"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "31"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId32"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "32"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId33"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "33"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId34"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "34"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId35"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "35"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId36"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "36"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId37"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "37"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId38"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "38"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId39"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "39"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId40"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "40"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId41"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "41"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId42"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "42"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId43"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "43"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId44"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "44"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId45"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "45"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId46"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "46"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId47"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "47"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId48"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "48"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId49"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "49"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId50"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "50"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId51"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "51"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId52"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "52"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId53"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "53"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId54"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "54"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId55"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "55"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId56"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "56"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId57"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "57"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId58"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "58"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId59"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "59"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId60"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "60"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId61"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "61"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId62"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "62"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId63"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "63"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId64"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "64"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId65"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "65"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId66"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "66"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId67"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "67"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId68"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "68"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId69"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "69"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId70"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "70"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId71"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "71"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId72"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "72"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId73"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "73"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId74"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "74"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId75"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "75"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId76"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "76"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId77"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "77"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId78"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "78"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId79"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "79"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId80"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "80"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId81"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "81"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId82"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "82"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId83"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "83"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId84"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "84"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId85"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "85"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId86"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "86"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId87"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "87"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId88"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "88"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId89"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "89"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId90"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "90"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId91"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "91"
+ then
+ Destination : "regular1";
+end
+
+rule "ProductId92"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "92"
+ then
+ Destination : "regular2";
+end
+
+rule "ProductId93"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "93"
+ then
+ Destination : "regular3";
+end
+
+rule "ProductId94"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "94"
+ then
+ Destination : "regular4";
+end
+
+rule "ProductId95"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "95"
+ then
+ Destination : "regular5";
+end
+
+rule "ProductId96"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "96"
+ then
+ Destination : "regular6";
+end
+
+rule "ProductId97"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "97"
+ then
+ Destination : "regular7";
+end
+
+rule "ProductId98"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "98"
+ then
+ Destination : "regular8";
+end
+
+rule "ProductId99"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "99"
+ then
+ Destination : "regular9";
+end
+
+rule "ProductId299"
+ salience 100
+ when
+ xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "299"
+ then
+ Destination : "regular0";
+end
Modified: labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/FunCBRTest.java
===================================================================
--- labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/FunCBRTest.java 2008-07-04 14:40:55 UTC (rev 20905)
+++ labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/FunCBRTest.java 2008-07-04 14:57:52 UTC (rev 20906)
@@ -35,7 +35,7 @@
public class FunCBRTest
extends AbstractQuickstartTestCase {
- private static String theXML = "<Order orderId=\"1\" "
+ private static String theXML = "<Order xmlns=\"http://org.jboss.soa.esb/Order\" orderId=\"1\" "
+ "orderDate=\"Wed Nov 15 13:45:28 EST 2006\" "
+ "statusCode=\"0\" " + "netAmount=\"59.97\" "
+ "totalAmount=\"64.92\" " + "tax=\"4.95\" "
More information about the jboss-svn-commits
mailing list