[jboss-svn-commits] JBL Code SVN: r7708 - labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Nov 19 07:46:45 EST 2006


Author: estebanschifman
Date: 2006-11-19 07:46:39 -0500 (Sun, 19 Nov 2006)
New Revision: 7708

Added:
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/fileEsbListenerConfig.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/fileGatewayConfig.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/jmsEsbListenerConfig.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/jmsGatewayConfig.xml
Modified:
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListenerUnitTest.java
Log:
Put xml configurations in classpath for gateway listeners

Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java	2006-11-18 14:45:11 UTC (rev 7707)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java	2006-11-19 12:46:39 UTC (rev 7708)
@@ -52,11 +52,12 @@
 public class FileGatewayListenerUnitTest
 {
 
-	private static final String TMP_DIR	= System.getProperty("java.io.tmpdir","/tmp"); 
 
 	private static Logger _logger			= Logger.getLogger(FileGatewayListenerUnitTest.class);
-	static File _gatewayConfig		= new File(TMP_DIR,"fileGatewayConfig.xml");
-	static File _esbListenerConfig 	= new File(TMP_DIR,"fileEsbListenerConfig.xml");
+	static String _gatewayConfig		= "fileGatewayConfig.xml";
+	static String _esbListenerConfig 	= "fileEsbListenerConfig.xml";
+
+	private static final String TMP_DIR	= System.getProperty("java.io.tmpdir","/tmp"); 
 	static File _returnFile			= new File(TMP_DIR,"fileMessageBack.txt");
 	static File _droppedFile		= new File(TMP_DIR,"fileLegacy.dat");
 	static String POST_SUFFIX 		= ".sentToEsb";
@@ -78,8 +79,6 @@
 	public static void setUp() throws Exception
 	{
 		_logger.info("Writing temp files to "+TMP_DIR);
-    	writeGatewayConfig();
-    	writeEsbListenerConfig();
     	bytesToFile(_droppedFile, THE_TEXT.getBytes());
 
     	// delete these two just to make sure asserts take the new ones
@@ -94,11 +93,9 @@
 	public static void tearDown() throws Exception
 	{
 		
-    	_gatewayConfig.delete();
-    	_esbListenerConfig.delete();
     	_doneFile.delete();
     	_returnFile.delete();
-    	Thread.sleep(1000);
+    	Thread.sleep(2000);
     	if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
 			HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
 	}
@@ -108,10 +105,15 @@
     {
         try 
         {
-    		_esbListController = new EsbListenerController(_esbListenerConfig.toString());
+    		InputStream inStream = getClass().getResourceAsStream(_esbListenerConfig);
+    		ConfigTree tree = ConfigTree.fromInputStream(inStream);
+    		_esbListController = new EsbListenerController(tree);
     		new Thread(_esbListController).start();
-    		Thread.sleep(5000);
-    		_gatewayController = new GatewayListenerController(_gatewayConfig.toString());
+    		Thread.sleep(15000);
+
+    		inStream = getClass().getResourceAsStream(_gatewayConfig);
+    		tree = ConfigTree.fromInputStream(inStream);
+    		_gatewayController = new GatewayListenerController(tree);
     		new Thread(_gatewayController).start();
     		Thread.sleep(4000);
 
@@ -136,51 +138,6 @@
 
 	} // ___________________________________________________
 
-	private static void writeGatewayConfig() throws Exception
-	{
-		StringBuilder sb = new StringBuilder()
-		.append("<FileGateway parameterReloadSecs=\"180\">\n")
-		 .append("  <GatewayConfig\n")
-		 .append("     target-service-category=\"eprManager1\"\n")
-		 .append("     target-service-name=\"").append(SERVICE_NAME).append("\"\n")
-		 .append("     gatewayClass=\"org.jboss.soa.esb.listeners.gateway.FileGatewayListener\"\n")
-		 .append("     pollLatencySeconds=\"5\"\n")
-		 .append("     inputDir=\"").append(TMP_DIR).append("\"\n")
-		 .append("     inputSuffix=\".dat\"\n")
-		 .append("     postSuffix=\"").append(POST_SUFFIX).append("\"\n")
-		 .append("   >\n")
-		 .append("   </GatewayConfig>\n")
-		 .append("</FileGateway>\n")
-		 ;
-		bytesToFile(_gatewayConfig, sb.toString().getBytes());
-		_logger.info("GatewayConfiguration\n"+stringFromFile(_gatewayConfig));
-	}
-	
-	private static void writeEsbListenerConfig() throws Exception
-	{
-		StringBuilder sb = new StringBuilder()
-		.append("<DummyTester parameterReloadSecs=\"180\">\n")
-		.append("   <DummyActionConfig\n")
-		.append("   service-category=\"eprManager1\"\n")
-		.append("	service-name=\"").append(SERVICE_NAME).append("\"\n")
-		.append("	service-description=\"My Dummy Service Name\"\n")
-		.append("	epr-description=\"EPR descriptionnnnnnnnnnnnnnn\"\n")		
-		.append("  	listenerClass=\"org.jboss.soa.esb.listeners.message.JmsQueueListener\"\n")
-		.append("	connection-factory=\"ConnectionFactory\"\n")
-		.append("	destination-type=\"queue\"\n")
-		.append("	destination-name=\"queue/A\"\n")
-		.append("	jndi-type=\"jboss\"\n")
-		.append("	jndi-URL=\"").append(_appServer).append("\"\n")
-		.append("	message-selector=\"service='testFileGateway'\"\n")
-		.append("	>\n")
-		.append("	   <action class=\"").append(MockMessageAwareAction.class.getName()).append("\" process=\"writeToDisk\" />\n")
-		.append("   </DummyActionConfig>\n")
-		.append("</DummyTester>\n")
-		;
-		bytesToFile(_esbListenerConfig, sb.toString().getBytes());
-		_logger.info("EsbListenerConfiguration\n"+stringFromFile(_esbListenerConfig));
-	}
-	
 	private static void bytesToFile(File file, byte[] text) throws Exception
 	{
 		OutputStream out = new FileOutputStream(file);

Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListenerUnitTest.java	2006-11-18 14:45:11 UTC (rev 7707)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListenerUnitTest.java	2006-11-19 12:46:39 UTC (rev 7708)
@@ -65,8 +65,8 @@
 	private static final String TMP_DIR	= System.getProperty("java.io.tmpdir","/tmp"); 
 
 	private static Logger _logger			= Logger.getLogger(JmsGatewayListenerUnitTest.class);
-	static File _gatewayConfig		= new File(TMP_DIR,"jmsGatewayConfig.xml");
-	static File _esbListenerConfig 	= new File(TMP_DIR,"jmsEsbListenerConfig.xml");
+	static String _gatewayConfig		= "jmsGatewayConfig.xml";
+	static String _esbListenerConfig 	= "jmsEsbListenerConfig.xml";
 	static File _returnFile			= new File(TMP_DIR,"jmsMessageBack.txt");
 
 	
@@ -86,8 +86,6 @@
 	public static void setUp() throws Exception
 	{
 		_logger.info("Writing temp files to "+TMP_DIR);
-    	writeGatewayConfig();
-    	writeEsbListenerConfig();
 
     	// delete this one just to make sure asserts take the new ones
     	_returnFile.delete();
@@ -102,11 +100,9 @@
 	@AfterClass
 	public static void tearDown() throws Exception
 	{
-    	_gatewayConfig.delete();
-    	_esbListenerConfig.delete();
     	_returnFile.delete();
 
-    	Thread.sleep(1000);
+    	Thread.sleep(2000);
     	if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
 			HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
 	}
@@ -116,10 +112,15 @@
     {
         try 
         {
-    		_esbListController = new EsbListenerController(_esbListenerConfig.toString());
+    		InputStream inStream = getClass().getResourceAsStream(_esbListenerConfig);
+    		ConfigTree tree = ConfigTree.fromInputStream(inStream);
+    		_esbListController = new EsbListenerController(tree);
     		new Thread(_esbListController).start();
-    		Thread.sleep(5000);
-    		_gatewayController = new GatewayListenerController(_gatewayConfig.toString());
+    		Thread.sleep(15000);
+
+    		inStream = getClass().getResourceAsStream(_gatewayConfig);
+    		tree = ConfigTree.fromInputStream(inStream);
+    		_gatewayController = new GatewayListenerController(tree);
     		new Thread(_gatewayController).start();
     		Thread.sleep(4000);
 
@@ -143,53 +144,6 @@
 
 	} // ___________________________________________________
 
-	private static void writeGatewayConfig() throws Exception
-	{
-		StringBuilder sb = new StringBuilder()
-		.append("<JmsGateway parameterReloadSecs=\"180\">\n")
-		 .append("  <GatewayConfig\n")
-		 .append("     target-service-category=\"XXeprManager\"\n")
-		 .append("     target-service-name=\"").append(SERVICE_NAME).append("\"\n")
-		 .append("     gatewayClass=\"org.jboss.soa.esb.listeners.gateway.JmsGatewayListener\"\n")
-		 .append("     connection-factory=\"ConnectionFactory\"\n")
-		 .append("     destination-type=\"queue\"\n")
-		 .append("     destination-name=\"queue/A\"\n")
-		 .append("     jndi-type=\"jboss\"\n")
-		 .append("     jndi-URL=\"").append(_appServer).append("\"\n")
-		 .append("     message-selector=\"messSelector='testJmsGateway'\"\n")
-		 .append("   >\n")
-		 .append("   </GatewayConfig>\n")
-		 .append("</JmsGateway>\n")
-		 ;
-		bytesToFile(_gatewayConfig, sb.toString().getBytes());
-		_logger.info("GatewayConfiguration\n"+stringFromFile(_gatewayConfig));
-	}
-	
-	private static void writeEsbListenerConfig() throws Exception
-	{
-		StringBuilder sb = new StringBuilder()
-		.append("<DummyTester parameterReloadSecs=\"180\">\n")
-		.append("   <DummyActionConfig\n")
-		.append("   service-category=\"XXeprManager\"\n")
-		.append("	service-name=\"").append(SERVICE_NAME).append("\"\n")
-		.append("	service-description=\"My Dummy Service Name\"\n")
-		.append("	epr-description=\"EPR descriptionnnnnnnnnnnnnnn\"\n")		
-		.append("  	listenerClass=\"org.jboss.soa.esb.listeners.message.JmsQueueListener\"\n")
-		.append("	connection-factory=\"ConnectionFactory\"\n")
-		.append("	destination-type=\"queue\"\n")
-		.append("	destination-name=\"queue/A\"\n")
-		.append("	jndi-type=\"jboss\"\n")
-		.append("	jndi-URL=\"").append(_appServer).append("\"\n")
-		.append("	message-selector=\"service='testJmsGateway'\"\n")
-		.append("	>\n")
-		.append("	   <action class=\"").append(MockMessageAwareAction.class.getName()).append("\" process=\"writeToDisk\" />\n")
-		.append("   </DummyActionConfig>\n")
-		.append("</DummyTester>\n")
-		;
-		bytesToFile(_esbListenerConfig, sb.toString().getBytes());
-		_logger.info("EsbListenerConfiguration\n"+stringFromFile(_esbListenerConfig));
-	}
-	
 	private static void bytesToFile(File file, byte[] text) throws Exception
 	{
 		OutputStream out = new FileOutputStream(file);
@@ -215,7 +169,8 @@
 	
 	private static void sendJmsMessage(String text) throws Exception
 	{
-		ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(_gatewayConfig))
+		InputStream inStream = JmsGatewayListenerUnitTest.class.getResourceAsStream(_gatewayConfig);
+		ConfigTree tree = ConfigTree.fromInputStream(inStream)
 				.getAllChildren()[0];
         String sJndiType = tree.getAttribute(JMSEpr.JNDI_TYPE_TAG);
         String sJndiURL = _appServer;

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/fileEsbListenerConfig.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/fileEsbListenerConfig.xml	2006-11-18 14:45:11 UTC (rev 7707)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/fileEsbListenerConfig.xml	2006-11-19 12:46:39 UTC (rev 7708)
@@ -0,0 +1,20 @@
+<DummyTester parameterReloadSecs="180">
+   <DummyActionConfig
+   service-category="my category"
+	service-name="testFileGateway"
+	service-description="My Dummy Service Name"
+	epr-description="EPR descriptionnnnnnnnnnnnnnn"
+  	listenerClass="org.jboss.soa.esb.listeners.message.JmsQueueListener"
+	connection-factory="ConnectionFactory"
+	destination-type="queue"
+	destination-name="queue/A"
+	jndi-type="jboss"
+	jndi-URL="localhost"
+	message-selector="service='testFileGateway'"
+	>
+	   <action 
+	   	class="org.jboss.soa.esb.listeners.gateway.FileGatewayListenerUnitTest$MockMessageAwareAction" 
+	   	process="writeToDisk" 
+	   />
+   </DummyActionConfig>
+</DummyTester>

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/fileGatewayConfig.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/fileGatewayConfig.xml	2006-11-18 14:45:11 UTC (rev 7707)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/fileGatewayConfig.xml	2006-11-19 12:46:39 UTC (rev 7708)
@@ -0,0 +1,12 @@
+<FileGateway parameterReloadSecs="180">
+  <GatewayConfig
+     target-service-category="my category"
+     target-service-name="testFileGateway"
+     gatewayClass="org.jboss.soa.esb.listeners.gateway.FileGatewayListener"
+     pollLatencySeconds="5"
+     inputDir="/tmp"
+     inputSuffix=".dat"
+     postSuffix=".sentToEsb"
+   >
+   </GatewayConfig>
+</FileGateway>

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/jmsEsbListenerConfig.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/jmsEsbListenerConfig.xml	2006-11-18 14:45:11 UTC (rev 7707)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/jmsEsbListenerConfig.xml	2006-11-19 12:46:39 UTC (rev 7708)
@@ -0,0 +1,17 @@
+<DummyTester parameterReloadSecs="180">
+   <DummyActionConfig
+   service-category="my category"
+	service-name="testJmsGateway"
+	service-description="My Dummy Service Name"
+	epr-description="EPR descriptionnnnnnnnnnnnnnn"
+  	listenerClass="org.jboss.soa.esb.listeners.message.JmsQueueListener"
+	connection-factory="ConnectionFactory"
+	destination-type="queue"
+	destination-name="queue/A"
+	jndi-type="jboss"
+	jndi-URL="localhost"
+	message-selector="service='testJmsGateway'"
+	>
+	   <action class="org.jboss.soa.esb.listeners.gateway.JmsGatewayListenerUnitTest$MockMessageAwareAction" process="writeToDisk" />
+   </DummyActionConfig>
+</DummyTester>

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/jmsGatewayConfig.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/jmsGatewayConfig.xml	2006-11-18 14:45:11 UTC (rev 7707)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/gateway/jmsGatewayConfig.xml	2006-11-19 12:46:39 UTC (rev 7708)
@@ -0,0 +1,14 @@
+<JmsGateway parameterReloadSecs="180">
+  <GatewayConfig
+     target-service-category="my category"
+     target-service-name="testJmsGateway"
+     gatewayClass="org.jboss.soa.esb.listeners.gateway.JmsGatewayListener"
+     connection-factory="ConnectionFactory"
+     destination-type="queue"
+     destination-name="queue/A"
+     jndi-type="jboss"
+     jndi-URL="localhost"
+     message-selector="messSelector='testJmsGateway'"
+   >
+   </GatewayConfig>
+</JmsGateway>




More information about the jboss-svn-commits mailing list