[jboss-svn-commits] JBL Code SVN: r24453 - in labs/jbossesb/trunk/product/rosetta: tests/src/org/jboss/soa/esb/listeners/gateway and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Dec 21 01:29:48 EST 2008


Author: mark.little at jboss.com
Date: 2008-12-21 01:29:48 -0500 (Sun, 21 Dec 2008)
New Revision: 24453

Added:
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListenerOptionalUnitTest.java
Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2216

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	2008-12-20 23:52:13 UTC (rev 24452)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	2008-12-21 06:29:48 UTC (rev 24453)
@@ -348,6 +348,7 @@
                     + ListenerTagNames.SQL_TIMESTAMP_TAG);
             _timestamp = null ;
         }
+        
         _where = ListenerUtil.getValue(_config,
                 ListenerTagNames.SQL_WHERE_CONDITION_TAG, "");
         if (_where.trim().length() < 1)

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListenerOptionalUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListenerOptionalUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListenerOptionalUnitTest.java	2008-12-21 06:29:48 UTC (rev 24453)
@@ -0,0 +1,187 @@
+/*
+ * 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.listeners.gateway;
+
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.helpers.persist.JdbcCleanConn;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+
+public class SqlTableGatewayListenerOptionalUnitTest extends BaseTest
+{
+	private Logger log = Logger
+			.getLogger( SqlTableGatewayListenerOptionalUnitTest.class );
+	
+	public SqlTableGatewayListenerOptionalUnitTest ()
+	{
+	}
+	
+	public void setUp()
+	{
+		try
+		{
+			MockRegistry.install();
+			Statement stmt = getDbConnection().createStatement();
+
+			try
+			{
+				stmt.executeUpdate("DROP TABLE esb_messages");
+			}
+			catch (Exception e)
+			{
+				// Ignore
+			}
+
+			stmt.executeUpdate("CREATE TABLE esb_messages (message_id varchar NOT NULL, message varchar, status varchar, CONSTRAINT pkey_esb_messages PRIMARY KEY (message_id))");
+		}
+		catch (SQLException ex)
+		{
+			log.error(ex);
+
+			fail();
+		}
+	}
+	public void tearDown()
+	{
+		MockRegistry.uninstall();
+	}
+	
+	public void testGateway () throws Exception
+	{
+		ConfigTree tree = new ConfigTree("test");
+
+		tree.setAttribute(JDBCEpr.URL_TAG, "jdbc:postgresql://myhost:5432/testDB");
+		tree.setAttribute(JDBCEpr.POST_DEL_TAG, "true");
+		tree.setAttribute(JDBCEpr.ERROR_DEL_TAG, "true");
+		tree.setAttribute(JDBCEpr.DRIVER_TAG, "org.postgresql.Driver");
+		tree.setAttribute(JDBCEpr.MESSAGE_ID_COLUMN_TAG, "message_id");
+		tree.setAttribute(JDBCEpr.PASSWORD_TAG, "secret");
+		tree.setAttribute(JDBCEpr.STATUS_COLUMN_TAG, "status");
+		tree.setAttribute(JDBCEpr.TABLE_NAME_TAG, "testtable");
+		tree.setAttribute(JDBCEpr.USERNAME_TAG, "joe");
+		tree.setAttribute(ListenerTagNames.POLL_LATENCY_SECS_TAG, "abcde");
+		tree.setAttribute("target-service-category", "Example");
+		tree.setAttribute("target-service-name", "Test");
+		tree.setAttribute("gatewayClass", "org.jboss.soa.esb.listeners.gateway.JdbcTableGatewayListener");
+		
+		SqlTableGatewayListener gateway = new SqlTableGatewayListener(tree);
+		
+		try
+		{
+			gateway.resolveComposerClass();
+		}
+		catch (ConfigurationException ex)
+		{
+			fail();
+		}
+		
+		boolean exception = false;
+				
+		tree = new ConfigTree("test");
+
+		tree.setAttribute(JDBCEpr.URL_TAG, getDbUrl());
+		tree.setAttribute(JDBCEpr.POST_DEL_TAG, "true");
+		tree.setAttribute(JDBCEpr.ERROR_DEL_TAG, "true");
+		tree.setAttribute(JDBCEpr.DRIVER_TAG, getDbDriver());
+		tree.setAttribute(JDBCEpr.MESSAGE_ID_COLUMN_TAG, "message_id");
+		tree.setAttribute(JDBCEpr.PASSWORD_TAG, getDbPassword());
+		tree.setAttribute(JDBCEpr.STATUS_COLUMN_TAG, "status");
+		tree.setAttribute(JDBCEpr.TABLE_NAME_TAG, "esb_messages");
+		tree.setAttribute(JDBCEpr.USERNAME_TAG, getDbUser());
+		tree.setAttribute(ListenerTagNames.POLL_LATENCY_SECS_TAG, "1000");
+		tree.setAttribute("target-service-category", "Example");
+		tree.setAttribute("target-service-name", "Test");
+		tree.setAttribute("gatewayClass", "org.jboss.soa.esb.listeners.gateway.JdbcTableGatewayListener");
+		tree.setAttribute(ListenerTagNames.SQL_SELECT_FIELDS_TAG, "esb_messages");
+		
+		exception = false;
+		
+		try
+		{
+			gateway = new SqlTableGatewayListener(tree);
+		}
+		catch (ConfigurationException ex)
+		{
+			exception = true;
+		}
+		
+		if (!exception)
+			fail();
+		
+		tree.setAttribute(ListenerTagNames.SQL_SELECT_FIELDS_TAG, "*");
+		
+		gateway = new SqlTableGatewayListener(tree);
+		
+		try
+		{
+			JdbcCleanConn conn = gateway.getDbConn();
+			gateway.prepareStatements();
+		}
+		catch (RuntimeException ex)
+		{
+			log.error(ex);
+			
+			fail();
+		}
+		
+		gateway.resolveComposerClass();
+		
+		exception = false;
+		
+		try
+		{
+			gateway.doInitialise();
+		}
+		catch (ManagedLifecycleException ex)
+		{
+			exception = true;
+		}
+		
+		if (!exception)
+			fail();
+	
+		gateway.pollForCandidates();
+		
+		gateway.doThreadedDestroy();
+		
+		gateway.changeStatusToDone();
+		
+		try
+		{
+			gateway.deleteCurrentRow();
+		}
+		catch (IllegalStateException ex)
+		{
+			fail();
+		}
+	}
+	
+}




More information about the jboss-svn-commits mailing list