[jboss-svn-commits] JBL Code SVN: r7471 - in labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer: actions util

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Nov 8 11:04:33 EST 2006


Author: daniel.brum at jboss.com
Date: 2006-11-08 11:04:26 -0500 (Wed, 08 Nov 2006)
New Revision: 7471

Added:
   labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/TrailblazerAction.java
   labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/Launcher.java
Removed:
   labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/LoanBrokerAction.java
   labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/MockLauncher.java
   labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TestLauncher.java
Modified:
   labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/HsqldbUtil.java
Log:


Deleted: labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/LoanBrokerAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/LoanBrokerAction.java	2006-11-08 15:39:20 UTC (rev 7470)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/LoanBrokerAction.java	2006-11-08 16:04:26 UTC (rev 7471)
@@ -1,56 +0,0 @@
-package org.jboss.soa.esb.samples.trailblazer.actions;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.actions.templates.MockMessageAction;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.persistence.MessageStore;
-import org.jboss.soa.esb.services.persistence.MessageStoreFactory;
-import org.jboss.soa.esb.services.persistence.MessageStoreType;
-import org.jboss.soa.esb.util.Util;
-
-public class LoanBrokerAction {
-	
-	protected Message 		_message;
-	protected ConfigTree	_config;
-	
-	private static Logger _logger = Logger.getLogger(MockMessageAction.class);
-	
-    public LoanBrokerAction(ConfigTree config) { _config = config; } 
-    public Message noOperation(Message message) { return message; } 
-	
-	public Message processQuoteRequest(Message message) throws Exception{
-		
-		_message = message;
-        _logger.info(Util.getStamp()+" process was called with <<" + getMessagePayload() + ">>");
-        
-		
-		return message;
-	}
-	
-	public Message persistMessage(Message message) throws Exception {		
-		
-		MessageStore store = MessageStoreFactory.getInstance().getMessageStore(MessageStoreType.DATABASE);
-		store.addMessage(message);
-		
-		return message;
-	}
-	
-	public void persistOK(Message msg) throws Exception {
-		_logger.info("*** NOTIFICATON *** Persist OK on Message: " + new String(msg.getBody().getContents()));
-	}
-	
-	public void persistFail(Message msg, Throwable thrown) throws Exception {
-		_logger.error("*** NOTIFICATON *** Persist FAIL on Message with exception: " + thrown.toString());
-	}
-	
-	public Message failAlways(Message msg) throws Exception {
-		throw new Exception ("The hand Of God WAS A GOAL! \n");
-	}
-	
-	Object getMessagePayload() 
-	{ 
-		return new String(_message.getBody().getContents()); 
-	}
-
-}

Copied: labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/TrailblazerAction.java (from rev 7466, labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/LoanBrokerAction.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/LoanBrokerAction.java	2006-11-08 14:18:24 UTC (rev 7466)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/actions/TrailblazerAction.java	2006-11-08 16:04:26 UTC (rev 7471)
@@ -0,0 +1,56 @@
+package org.jboss.soa.esb.samples.trailblazer.actions;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.templates.MockMessageAction;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+import org.jboss.soa.esb.services.persistence.MessageStoreFactory;
+import org.jboss.soa.esb.services.persistence.MessageStoreType;
+import org.jboss.soa.esb.util.Util;
+
+public class TrailblazerAction {
+	
+	protected Message 		_message;
+	protected ConfigTree	_config;
+	
+	private static Logger _logger = Logger.getLogger(MockMessageAction.class);
+	
+    public TrailblazerAction(ConfigTree config) { _config = config; } 
+    public Message noOperation(Message message) { return message; } 
+	
+	public Message processQuoteRequest(Message message) throws Exception{
+		
+		_message = message;
+        _logger.info(Util.getStamp()+" process was called with <<" + getMessagePayload() + ">>");
+        
+		
+		return message;
+	}
+	
+	public Message persistMessage(Message message) throws Exception {		
+		
+		MessageStore store = MessageStoreFactory.getInstance().getMessageStore(MessageStoreType.DATABASE);
+		store.addMessage(message);
+		
+		return message;
+	}
+	
+	public void persistOK(Message msg) throws Exception {
+		_logger.info("*** NOTIFICATON *** Persist OK on Message: " + new String(msg.getBody().getContents()));
+	}
+	
+	public void persistFail(Message msg, Throwable thrown) throws Exception {
+		_logger.error("*** NOTIFICATON *** Persist FAIL on Message with exception: " + thrown.toString());
+	}
+	
+	public Message failAlways(Message msg) throws Exception {
+		throw new Exception ("The hand Of God WAS A GOAL! \n");
+	}
+	
+	Object getMessagePayload() 
+	{ 
+		return new String(_message.getBody().getContents()); 
+	}
+
+}

Modified: labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/HsqldbUtil.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/HsqldbUtil.java	2006-11-08 15:39:20 UTC (rev 7470)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/HsqldbUtil.java	2006-11-08 16:04:26 UTC (rev 7471)
@@ -3,6 +3,7 @@
 import java.sql.DriverManager;
 import java.sql.Statement;
 
+import org.apache.log4j.Logger;
 import org.hsqldb.Server;
 /**
  * Utility to start and stop a hsql Database.
@@ -13,6 +14,8 @@
 public class HsqldbUtil 
 {
 	final private static String THREAD_NAME = "hypersonic-unittest";
+	
+	private static Logger _logger = Logger.getLogger(HsqldbUtil.class);
 	/**
 	 * Starts the hsql database in it's own thread. 
 	 * Don't forget to shut it down when you're done.
@@ -35,7 +38,7 @@
 					args[2] = "-dbname.0";
 					args[3] = databaseName;
 					
-					System.out.println("creating db from this script: " + databaseFile);
+					_logger.info("creating db from this script: " + databaseFile);
 
 					// Start server
 					Server.main(args);

Copied: labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/Launcher.java (from rev 7466, labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TestLauncher.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TestLauncher.java	2006-11-08 14:18:24 UTC (rev 7466)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/Launcher.java	2006-11-08 16:04:26 UTC (rev 7471)
@@ -0,0 +1,115 @@
+package org.jboss.soa.esb.samples.trailblazer.util;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.Statement;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.persistence.format.db.DBConnectionManager;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.listeners.gateway.GatewayListenerController;
+import org.jboss.soa.esb.listeners.message.EsbListenerController;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+
+
+public class Launcher {	
+	
+	private EsbListenerController	_esbListController;
+	private GatewayListenerController _gatewayController;
+	
+	
+	private Logger _logger = Logger.getLogger(Launcher.class);
+	
+	public static void main (String args[]) throws Exception {
+				
+		Launcher launcher = new Launcher();
+		if(args.length > 2)
+			launcher.triggerListener(Long.valueOf(args[0]).longValue(), args[1], args[2]);
+		else
+			launcher.triggerListener(Long.valueOf(args[0]).longValue(), args[1], null);
+	
+	}
+	
+	private void triggerListener(long runTime, String messageAwareConfigFile, String gatewayConfigFile) throws Exception{
+		try 
+        {
+			runBeforeAllTests();
+			
+			
+    		if (null != messageAwareConfigFile) {
+    			_logger.info("starting message aware listener with config file - " + messageAwareConfigFile);
+    			_esbListController = new EsbListenerController(messageAwareConfigFile);
+    			new Thread(_esbListController).start();
+    			Thread.sleep(2000);
+    		}
+    		
+    		if (null != gatewayConfigFile) {
+    			_logger.info("starting gateway listener with config file - " + gatewayConfigFile);
+    			_gatewayController = new GatewayListenerController(gatewayConfigFile);
+    			new Thread(_gatewayController).start();
+    			Thread.sleep(4000);
+    		}
+
+    		Thread.sleep(runTime);
+    		if (null != messageAwareConfigFile)
+    			_esbListController.requestEnd();
+    		
+    		if (null != gatewayConfigFile)
+    			_gatewayController.requestEnd();    		
+    		    	
+        }
+        catch (Exception e) { 
+        	_logger.error(e);
+        	throw(e);
+        }
+        finally { Launcher.runAfterAllTests(); }
+	
+
+	}
+		
+//	private static void sendOneMessage() throws Exception{		
+//		Message msg = MessageFactory.getInstance().getMessage();
+//		msg.getBody().setContents("Foooooooooooooo".getBytes());		
+//		try {
+//			_epr = EsbListenerController.getEprManager().loadEPR(SERVICE_NAME); //TODO: replace with a real registry lookup
+//		}catch(Exception e) {	
+//			System.out.println("nobody servicing service " + SERVICE_NAME);
+//			return;
+//		}
+//		Courier courier = CourierFactory.getCourier(_epr);
+//		courier.deliver(msg);
+//		
+//	}
+	
+protected static void runBeforeAllTests() throws Exception{
+	TestEnvironmentUtil.setESBPropertiesFileToUse();
+							
+	if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver")) {
+		HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir() + "build/hsqltestdb", "jbossesb");
+		//Get the registry-schema create scripts
+		String database = "hsqldb";
+		String sqlDir = TestEnvironmentUtil.getUserDir() + "install/message-store/sql/" + database + "/";
+		//Drop what is there now, if exists. We want to start fresh.				
+		String sqlCreateCmd    = TestEnvironmentUtil.readTextFile(new File(sqlDir + "create_database.sql"));
+		String sqlDropCmd      = TestEnvironmentUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
+		
+		DBConnectionManager mgr = DBConnectionManager.getInstance();
+		Connection con = mgr.getConnection();
+		Statement stmnt = con.createStatement();
+		System.out.println("Dropping the schema if exist");
+		stmnt.execute(sqlDropCmd);
+		System.out.println("Creating the message store schema");
+		stmnt.execute(sqlCreateCmd);
+	}
+		
+	}
+	
+	private static void runAfterAllTests() throws Exception{
+		
+		if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver")) {
+			HsqldbUtil.stopHsqldb(Configuration.getStoreUrl(),
+					Configuration.getStoreUser(),Configuration.getStorePwd() );
+		}
+	}
+
+}

Deleted: labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/MockLauncher.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/MockLauncher.java	2006-11-08 15:39:20 UTC (rev 7470)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/MockLauncher.java	2006-11-08 16:04:26 UTC (rev 7471)
@@ -1,95 +0,0 @@
-package org.jboss.soa.esb.samples.trailblazer.util;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.Statement;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.persistence.format.db.DBConnectionManager;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.common.Configuration;
-import org.jboss.soa.esb.couriers.Courier;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.listeners.message.EsbListenerController;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.messagestore.HsqldbUtil;
-import org.jboss.soa.esb.common.tests.TestUtil;
-
-
-public class MockLauncher {
-	
-	private static EsbListenerController _proc = null;
-	private static EPR _epr = null;
-	
-	private static final String SERVICE_NAME = "LoanRequestService";
-	
-	@SuppressWarnings("unused")
-	private static Logger _logger = Logger.getLogger(MockLauncher.class);
-	
-	public static void main (String args[]) throws Exception {
-		MockLauncher.runBeforeAllTests();
-		triggerListener("/home/dbrum/dev/jbossesb/product/samples/trailblazer2/esb/conf/loanbroker-esb.xml");
-		// give the listener time to register
-		Thread.sleep(2000);
-		sendOneMessage();
-		_proc.requestEnd();
-		//give the action class time to finish
-		Thread.sleep(2000);
-
-		EsbListenerController.State oS = _proc.getState();
-		System.out.println("Exit state = "+oS.toString());
-		MockLauncher.runAfterAllTests();
-	}
-	
-	private static void triggerListener(String paramFile) throws Exception {
-		_proc = new EsbListenerController(paramFile);
-		new Thread(_proc).start();
-	}
-		
-	private static void sendOneMessage() throws Exception{		
-		Message msg = MessageFactory.getInstance().getMessage();
-		msg.getBody().setContents("Foooooooooooooo".getBytes());		
-		try {
-			_epr = EsbListenerController.getEprManager().loadEPR(SERVICE_NAME); //TODO: replace with a real registry lookup
-		}catch(Exception e) {	
-			System.out.println("nobody servicing service " + SERVICE_NAME);
-			return;
-		}
-		Courier courier = CourierFactory.getCourier(_epr);
-		courier.deliver(msg);
-		
-	}
-	
-protected static void runBeforeAllTests() throws Exception{
-TestUtil.setESBPropertiesFileToUse();
-							
-	if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver")) {
-		HsqldbUtil.startHsqldb(TestUtil.getPrefix() + "build/hsqltestdb", "jbossesb");
-		//Get the registry-schema create scripts
-		String database = "hsqldb";
-		String sqlDir = TestUtil.getPrefix() + "install/message-store/sql/" + database + "/";
-		//Drop what is there now, if exists. We want to start fresh.				
-		String sqlCreateCmd    = TestUtil.readTextFile(new File(sqlDir + "create_database.sql"));
-		String sqlDropCmd      = TestUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
-		
-		DBConnectionManager mgr = DBConnectionManager.getInstance();
-		Connection con = mgr.getConnection();
-		Statement stmnt = con.createStatement();
-		System.out.println("Dropping the schema if exist");
-		stmnt.execute(sqlDropCmd);
-		System.out.println("Creating the message store schema");
-		stmnt.execute(sqlCreateCmd);
-	}
-		
-	}
-	
-	private static void runAfterAllTests() throws Exception{
-		
-		if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver")) {
-			HsqldbUtil.stopHsqldb(Configuration.getStoreUrl(),
-					Configuration.getStoreUser(),Configuration.getStorePwd() );
-		}
-	}
-
-}

Deleted: labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TestLauncher.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TestLauncher.java	2006-11-08 15:39:20 UTC (rev 7470)
+++ labs/jbossesb/trunk/product/samples/trailblazer2/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TestLauncher.java	2006-11-08 16:04:26 UTC (rev 7471)
@@ -1,95 +0,0 @@
-package org.jboss.soa.esb.samples.trailblazer.util;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.Statement;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.persistence.format.db.DBConnectionManager;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.common.Configuration;
-import org.jboss.soa.esb.couriers.Courier;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.listeners.message.EsbListenerController;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.messagestore.HsqldbUtil;
-import org.jboss.soa.esb.common.tests.TestUtil;
-
-
-public class TestLauncher {
-	
-	private static EsbListenerController _proc = null;
-	private static EPR _epr = null;
-	
-	private static final String SERVICE_NAME = "LoanRequestService";
-	
-	@SuppressWarnings("unused")
-	private static Logger _logger = Logger.getLogger(TestLauncher.class);
-	
-	public static void main (String args[]) throws Exception {
-		TestLauncher.runBeforeAllTests();
-		triggerListener("/home/dbrum/dev/jbossesb/product/samples/trailblazer2/esb/conf/loanbroker-esb.xml");
-		// give the listener time to register
-		Thread.sleep(2000);
-		sendOneMessage();
-		_proc.requestEnd();
-		//give the action class time to finish
-		Thread.sleep(2000);
-
-		EsbListenerController.State oS = _proc.getState();
-		System.out.println("Exit state = "+oS.toString());
-		TestLauncher.runAfterAllTests();
-	}
-	
-	private static void triggerListener(String paramFile) throws Exception {
-		_proc = new EsbListenerController(paramFile);
-		new Thread(_proc).start();
-	}
-		
-	private static void sendOneMessage() throws Exception{		
-		Message msg = MessageFactory.getInstance().getMessage();
-		msg.getBody().setContents("Foooooooooooooo".getBytes());		
-		try {
-			_epr = EsbListenerController.getEprManager().loadEPR(SERVICE_NAME); //TODO: replace with a real registry lookup
-		}catch(Exception e) {	
-			System.out.println("nobody servicing service " + SERVICE_NAME);
-			return;
-		}
-		Courier courier = CourierFactory.getCourier(_epr);
-		courier.deliver(msg);
-		
-	}
-	
-protected static void runBeforeAllTests() throws Exception{
-TestUtil.setESBPropertiesFileToUse();
-							
-	if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver")) {
-		HsqldbUtil.startHsqldb(TestUtil.getPrefix() + "build/hsqltestdb", "jbossesb");
-		//Get the registry-schema create scripts
-		String database = "hsqldb";
-		String sqlDir = TestUtil.getPrefix() + "install/message-store/sql/" + database + "/";
-		//Drop what is there now, if exists. We want to start fresh.				
-		String sqlCreateCmd    = TestUtil.readTextFile(new File(sqlDir + "create_database.sql"));
-		String sqlDropCmd      = TestUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
-		
-		DBConnectionManager mgr = DBConnectionManager.getInstance();
-		Connection con = mgr.getConnection();
-		Statement stmnt = con.createStatement();
-		System.out.println("Dropping the schema if exist");
-		stmnt.execute(sqlDropCmd);
-		System.out.println("Creating the message store schema");
-		stmnt.execute(sqlCreateCmd);
-	}
-		
-	}
-	
-	private static void runAfterAllTests() throws Exception{
-		
-		if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver")) {
-			HsqldbUtil.stopHsqldb(Configuration.getStoreUrl(),
-					Configuration.getStoreUser(),Configuration.getStorePwd() );
-		}
-	}
-
-}




More information about the jboss-svn-commits mailing list