[jboss-svn-commits] JBL Code SVN: r20525 - in labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss: internal/soa/esb/services/routing/cbr and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jun 16 07:42:10 EDT 2008


Author: beve
Date: 2008-06-16 07:42:10 -0400 (Mon, 16 Jun 2008)
New Revision: 20525

Added:
   labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/actions/CBRConfigTreeBuilder.java
Removed:
   labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/jbrules/
   labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/CBRConfigTreeBuilder.java
   labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/ContentBasedRoutingUnitTest.java
Modified:
   labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java
   labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/actions/BusinessRulesProcessorUnitTest.java
Log:
refactoring.


Modified: labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java	2008-06-16 11:10:33 UTC (rev 20524)
+++ labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java	2008-06-16 11:42:10 UTC (rev 20525)
@@ -22,8 +22,10 @@
 package org.jboss.internal.soa.esb.services.routing.cbr;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.net.URI;
 import java.util.List;
 
 import junit.framework.JUnit4TestAdapter;
@@ -33,47 +35,139 @@
 import org.jboss.soa.esb.message.format.MessageFactory;
 import org.jboss.soa.esb.message.format.MessageType;
 import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouterFactory;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
  * 
  * @author kurt.stam at redhat.com
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
  *
  */
 public class JBossRulesRouterUnitTest
 {
+    //	instance under test
+	private JBossRulesRouter jbrRouter;
+	
 	@Test
-	public void routeSerializedMessage()
+	public void routeSerializedMessage() throws MessageRouterException
 	{
-        //new messages
-		Message message = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
-		//set some properties inside the Message
-		message.getProperties().setProperty("prop1", "val1");
-		message.getProperties().setProperty("prop2", "val2");
-		//set the body inside the Message
-		message.getBody().add(("TEST BODY").getBytes());
-		//set some object attachments inside the Message
-		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
-		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
+		Message message = createMessage( MessageType.JAVA_SERIALIZED );
+			
+		List<String> destinationServices = jbrRouter.route("JBossESBRules.drl",false,message,null);
+		assertNotNull(destinationServices);
+		assertTrue(destinationServices.size()>0);
+		assertEquals(destinationServices.iterator().next(),"serialized-destination");
+	}
+	
+	@Test
+	public void routeSerializedMessageDecisionTableStateless() throws MessageRouterException
+	{
+		Message message = createMessage( MessageType.JAVA_SERIALIZED );
+			
+		List<String> destinationServices = jbrRouter.route( "RuleBaseHelper.xls", false, message, null);
+			
+		assertNotNull( destinationServices );
+		assertTrue( "One destination should have been added by Drools", destinationServices.size() == 1 );
+		assertEquals( "serialized-destination", destinationServices.get(0).toString() );
+	}
+	
+	@Test
+	public void routeSerializedMessageDecisionTableStateful() throws MessageRouterException
+	{
+		Message message = createMessage( MessageType.JAVA_SERIALIZED );
+			
+		ConfigTree config = new ConfigTree("statefulConfig");
+		config.setAttribute( "stateful", "true" );
+		jbrRouter.setConfigTree( config );
+			
+		List<String> destinationServices = jbrRouter.route( "RuleBaseHelper.xls", false, message, null);
 		
-		JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
-		jbossRulesRouter.setConfigTree( new ConfigTree("dummy") );
-        try {
-    		List<String> destinationServices = jbossRulesRouter.route("JBossESBRules.drl", false, message, null);
-    		assertEquals(destinationServices.iterator().next(),"serialized-destination");
-            System.out.println(message.getBody().get());
-        } catch (MessageRouterException mre) {
-            System.out.println("Exception was thrown.");
-            mre.printStackTrace();
-            assertTrue(false);
-        }
+		assertNotNull( destinationServices );
+		assertTrue( "One destination should have been added by Drools", destinationServices.size() == 1 );
+		assertEquals( "serialized-destination", destinationServices.get(0).toString() );
 	}
 	
 	@Test
-	public void routeXMLMessage()
+	public void routeXMLMessage() throws MessageRouterException
 	{
-		//add new messages
-		Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+		Message message = createMessage( MessageType.JBOSS_XML);
+		List<String> destinationServices = jbrRouter.route("JBossESBRules.drl",false,message,null);
+		assertEquals(destinationServices.iterator().next(),"xml-destination");
+	}
+	
+	@Test
+	public void routeXMLMessageUsingXPathMatch() throws MessageRouterException
+	{
+		Message message = createMessage( MessageType.JBOSS_XML);
+		message.getBody().add(("<jbossesb>TEST BODY</jbossesb>").getBytes());
+			
+		List<String> destinationServices = jbrRouter.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",false,message,null);
+		assertEquals(destinationServices.iterator().next(),"XML_XPath_Destination");
+	}
+	
+	@Test
+	public void routeXMLMessageUsingXPathEquals() throws MessageRouterException
+	{
+		Message message = createMessage( MessageType.JBOSS_XML );
+		message.getBody().add(("<Dave>rocks</Dave>").getBytes());
+		
+		List<String> destinationServices = jbrRouter.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",false,message,null);
+		assertEquals(destinationServices.iterator().next(),"XML_XPath_Dave_Destination");
+	}
+	
+	@Test
+	public void routeXMLMessageUsingXPathGreaterThen() throws MessageRouterException
+	{
+		Message message = createMessage( MessageType.JBOSS_XML );
+		message.getBody().add(("<price>1.55</price>").getBytes());
+			
+		List<String> destinationServices = jbrRouter.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",false,message,null);
+		assertEquals(destinationServices.iterator().next(),"XML_XPath_GreaterThan_Destination");
+	}
+	
+	@Test
+	public void routeXMLMessageUsingXPathLessThen()
+	{
+		try {
+			//add new messages
+			Message message = MessageFactory.getInstance().getMessage( MessageType.JBOSS_XML );
+			//set the body inside the Message
+			message.getBody().add(("<price>0.55</price>").getBytes());
+			
+			List<String> destinationServices = jbrRouter.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",false,message,null);
+			assertEquals(destinationServices.iterator().next(),"XML_XPath_LessThan_Destination");
+		} catch (MessageRouterException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	@Before
+	public void setup() throws MessageRouterException
+	{
+		jbrRouter = (JBossRulesRouter) ContentBasedRouterFactory.getRouter(org.jboss.soa.esb.actions.ContentBasedRouter.DEFAULT_CBR_CLASS);
+		jbrRouter.setConfigTree( new ConfigTree("dummy" ));
+	}
+	
+	@BeforeClass
+	public static void runBeforeAllTests() throws Exception 
+	{
+		try {
+			TestEnvironmentUtil.setESBPropertiesFileToUse();
+		} catch (Exception e) {
+			e.printStackTrace();
+			System.out.println("We should stop testing, since we don't any config properties");
+			assertTrue(false);
+		}
+	}
+	
+	private Message createMessage( final URI type )
+	{
+		//new messages
+		Message message = MessageFactory.getInstance().getMessage( type );
 		//set some properties inside the Message
 		message.getProperties().setProperty("prop1", "val1");
 		message.getProperties().setProperty("prop2", "val2");
@@ -82,17 +176,7 @@
 		//set some object attachments inside the Message
 		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
 		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
-	
-		JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
-		jbossRulesRouter.setConfigTree( new ConfigTree("dummy") );
-        try {
-    		List<String> destinationServices = jbossRulesRouter.route("JBossESBRules.drl", false, message, null);
-    		assertEquals(destinationServices.iterator().next(),"xml-destination");
-        } catch (MessageRouterException mre) {
-            System.out.println("Exception was thrown.");
-            mre.printStackTrace();
-            assertTrue(false);
-        }
+		return message;
 	}
 	
 	public static junit.framework.Test suite() {

Modified: labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/actions/BusinessRulesProcessorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/actions/BusinessRulesProcessorUnitTest.java	2008-06-16 11:10:33 UTC (rev 20524)
+++ labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/actions/BusinessRulesProcessorUnitTest.java	2008-06-16 11:42:10 UTC (rev 20525)
@@ -39,7 +39,6 @@
 import org.jboss.soa.esb.message.mapping.ObjectMappingException;
 import org.jboss.soa.esb.services.registry.RegistryException;
 import org.jboss.soa.esb.services.routing.MessageRouterException;
-import org.jboss.soa.esb.services.routing.cbr.CBRConfigTreeBuilder;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;

Copied: labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/actions/CBRConfigTreeBuilder.java (from rev 20513, labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/CBRConfigTreeBuilder.java)
===================================================================
--- labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/actions/CBRConfigTreeBuilder.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/actions/CBRConfigTreeBuilder.java	2008-06-16 11:42:10 UTC (rev 20525)
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+import java.util.List;
+
+import org.jboss.soa.esb.actions.ContentBasedWiretap;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+
+/**
+ * Builder for CBR ConfigTree instances.
+ * </p>
+ * 
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public class CBRConfigTreeBuilder
+{
+	//	mandatory
+	private String ruleFile;
+	private String reload;
+ 		
+	//	optional 
+	private List<String> messagePathList;
+		
+	public CBRConfigTreeBuilder( final String ruleFile, final String reload )
+	{
+		this.ruleFile = ruleFile;
+		this.reload = reload;
+	}
+		
+	public CBRConfigTreeBuilder messagePaths( List<String> messagePathList )
+	{
+		this.messagePathList = messagePathList;
+		return this;
+	}
+		
+	public ConfigTree build()
+	{
+        ConfigTree configTree = new ConfigTree("cbr-config");
+        configTree.setAttribute( ListenerTagNames.RULE_SET_TAG, ruleFile );
+        configTree.setAttribute( ListenerTagNames.RULE_RELOAD_TAG, reload );
+            
+        if ( messagePathList != null )
+        {
+        	for (String messagePath : messagePathList)
+			{
+        		ConfigTree objectPath = new ConfigTree( ContentBasedWiretap.OBJECT_PATH_TAG, configTree );
+        		objectPath.setAttribute( ContentBasedWiretap.OBJECT_PATH, messagePath );
+			}
+        }
+            
+        return configTree;
+	}
+}

Deleted: labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/CBRConfigTreeBuilder.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/CBRConfigTreeBuilder.java	2008-06-16 11:10:33 UTC (rev 20524)
+++ labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/CBRConfigTreeBuilder.java	2008-06-16 11:42:10 UTC (rev 20525)
@@ -1,75 +0,0 @@
-/*
- * 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.services.routing.cbr;
-
-import java.util.List;
-
-import org.jboss.soa.esb.actions.ContentBasedWiretap;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-
-/**
- * Builder for CBR ConfigTree instances.
- * </p>
- * 
- * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
- *
- */
-public class CBRConfigTreeBuilder
-{
-	//	mandatory
-	private String ruleFile;
-	private String reload;
- 		
-	//	optional 
-	private List<String> messagePathList;
-		
-	public CBRConfigTreeBuilder( final String ruleFile, final String reload )
-	{
-		this.ruleFile = ruleFile;
-		this.reload = reload;
-	}
-		
-	public CBRConfigTreeBuilder messagePaths( List<String> messagePathList )
-	{
-		this.messagePathList = messagePathList;
-		return this;
-	}
-		
-	public ConfigTree build()
-	{
-        ConfigTree configTree = new ConfigTree("cbr-config");
-        configTree.setAttribute( ListenerTagNames.RULE_SET_TAG, ruleFile );
-        configTree.setAttribute( ListenerTagNames.RULE_RELOAD_TAG, reload );
-            
-        if ( messagePathList != null )
-        {
-        	for (String messagePath : messagePathList)
-			{
-        		ConfigTree objectPath = new ConfigTree( ContentBasedWiretap.OBJECT_PATH_TAG, configTree );
-        		objectPath.setAttribute( ContentBasedWiretap.OBJECT_PATH, messagePath );
-			}
-        }
-            
-        return configTree;
-	}
-}

Deleted: labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/ContentBasedRoutingUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/ContentBasedRoutingUnitTest.java	2008-06-16 11:10:33 UTC (rev 20524)
+++ labs/jbossesb/workspace/dbevenius/ruleservice/product/services/jbrules/src/test/java/org/jboss/soa/esb/services/routing/cbr/ContentBasedRoutingUnitTest.java	2008-06-16 11:42:10 UTC (rev 20525)
@@ -1,221 +0,0 @@
-/*
- * 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.services.routing.cbr;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.message.format.MessageType;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-/**
- * 
- * @author kurt.stam at redhat.com
- *
- */
-public class ContentBasedRoutingUnitTest
-{
-	//	instance under test
-	private ContentBasedRouter cbr;
-	
-	@Test
-	public void routeSerializedMessage() throws MessageRouterException
-	{
-        //new messages
-		Message message = createSerializedMessage();
-			
-		List<String> destinationServices = cbr.route("JBossESBRules.drl",false,message,null);
-		assertNotNull(destinationServices);
-		assertTrue(destinationServices.size()>0);
-		assertEquals(destinationServices.iterator().next(),"serialized-destination");
-	}
-	
-	@Test
-	public void routeSerializedMessageDecisionTableStateless() throws MessageRouterException
-	{
-		Message message = createSerializedMessage();
-			
-		List<String> destinationServices = cbr.route( "RuleBaseHelper.xls", false, message, null);
-			
-		assertNotNull( destinationServices );
-		assertTrue( "One destination should have been added by Drools", destinationServices.size() == 1 );
-		assertEquals( "serialized-destination", destinationServices.get(0).toString() );
-	}
-	
-	@Test
-	public void routeSerializedMessageDecisionTableStateful() throws MessageRouterException
-	{
-		Message message = createSerializedMessage();
-			
-		ConfigTree config = new ConfigTree("statelessConfig");
-		config.setAttribute( "stateful", "true" );
-		cbr.setConfigTree( config );
-			
-		List<String> destinationServices = cbr.route( "RuleBaseHelper.xls", false, message, null);
-		
-		assertNotNull( destinationServices );
-		assertTrue( "One destination should have been added by Drools", destinationServices.size() == 1 );
-		assertEquals( "serialized-destination", destinationServices.get(0).toString() );
-	}
-	
-	@Test
-	public void routeXMLMessage()
-	{
-		try {
-			//add new messages
-			Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
-			//set some properties inside the Message
-			message.getProperties().setProperty("prop1", "val1");
-			message.getProperties().setProperty("prop2", "val2");
-			//set the body inside the Message
-			message.getBody().add(("TEST BODY").getBytes());
-			//set some object attachments inside the Message
-			message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
-			message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
-			
-			List<String> destinationServices = cbr.route("JBossESBRules.drl",false,message,null);
-			assertEquals(destinationServices.iterator().next(),"xml-destination");
-		} catch (MessageRouterException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	@Test
-	public void routeXMLMessageUsingXPathMatch()
-	{
-		try {
-			//add new messages
-			Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
-			//set some properties inside the Message
-			message.getProperties().setProperty("prop1", "val1");
-			message.getProperties().setProperty("prop2", "val2");
-			//set the body inside the Message
-			message.getBody().add(("<jbossesb>TEST BODY</jbossesb>").getBytes());
-			//set some object attachments inside the Message
-			message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
-			message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
-			
-			List<String> destinationServices = cbr.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",false,message,null);
-			assertEquals(destinationServices.iterator().next(),"XML_XPath_Destination");
-		} catch (MessageRouterException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	@Test
-	public void routeXMLMessageUsingXPathEquals()
-	{
-		try {
-			//add new messages
-			Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
-			//set the body inside the Message
-			message.getBody().add(("<Dave>rocks</Dave>").getBytes());
-		
-			List<String> destinationServices = cbr.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",false,message,null);
-			assertEquals(destinationServices.iterator().next(),"XML_XPath_Dave_Destination");
-		} catch (MessageRouterException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	@Test
-	public void routeXMLMessageUsingXPathGreaterThen()
-	{
-		try {
-			//add new messages
-			Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
-			//set the body inside the Message
-			message.getBody().add(("<price>1.55</price>").getBytes());
-			
-			List<String> destinationServices = cbr.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",false,message,null);
-			assertEquals(destinationServices.iterator().next(),"XML_XPath_GreaterThan_Destination");
-		} catch (MessageRouterException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	@Test
-	public void routeXMLMessageUsingXPathLessThen()
-	{
-		try {
-			//add new messages
-			Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
-			//set the body inside the Message
-			message.getBody().add(("<price>0.55</price>").getBytes());
-			
-			List<String> destinationServices = cbr.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",false,message,null);
-			assertEquals(destinationServices.iterator().next(),"XML_XPath_LessThan_Destination");
-		} catch (MessageRouterException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	@Before
-	public void setup() throws MessageRouterException
-	{
-		cbr = ContentBasedRouterFactory.getRouter(org.jboss.soa.esb.actions.ContentBasedRouter.DEFAULT_CBR_CLASS);
-		cbr.setConfigTree( new ConfigTree("dummy" ));
-	}
-	
-	@BeforeClass
-	public static void runBeforeAllTests() throws Exception 
-	{
-		try {
-			TestEnvironmentUtil.setESBPropertiesFileToUse();
-		} catch (Exception e) {
-			e.printStackTrace();
-			System.out.println("We should stop testing, since we don't any config properties");
-			assertTrue(false);
-		}
-	}
-	
-	public static junit.framework.Test suite() {
-		return new JUnit4TestAdapter(ContentBasedRoutingUnitTest.class);
-	}
-	
-	private Message createSerializedMessage()
-	{
-		//new messages
-		Message message = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
-		//set some properties inside the Message
-		message.getProperties().setProperty("prop1", "val1");
-		message.getProperties().setProperty("prop2", "val2");
-		//set the body inside the Message
-		message.getBody().add(("TEST BODY").getBytes());
-		//set some object attachments inside the Message
-		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
-		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
-		return message;
-	}
-	
-}




More information about the jboss-svn-commits mailing list