[jboss-svn-commits] JBL Code SVN: r9044 - in labs/jbossesb/trunk/product/core: listeners/src/org/jboss/soa/esb/actions/converters and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Jan 27 13:45:41 EST 2007


Author: tfennelly
Date: 2007-01-27 13:45:41 -0500 (Sat, 27 Jan 2007)
New Revision: 9044

Added:
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java.back
Removed:
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java
Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ContentBasedRouter.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/StaticRouter.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SystemPrintln.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/SmooksTransformer.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/helpers/ConfigTree.java
Log:
Fixes for http://jira.jboss.com/jira/browse/JBESB-392

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ContentBasedRouter.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ContentBasedRouter.java	2007-01-27 16:55:09 UTC (rev 9043)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ContentBasedRouter.java	2007-01-27 18:45:41 UTC (rev 9044)
@@ -116,9 +116,9 @@
 		for (ConfigTree curr : destList) {
 			try
 			{
-                String key = curr.getAttribute(ListenerTagNames.DESTINATION_NAME_TAG, null);
+                String key = curr.getRequiredAttribute(ListenerTagNames.DESTINATION_NAME_TAG);
 				String category = curr.getAttribute(ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, "");
-				String name = curr.getAttribute(ListenerTagNames.SERVICE_NAME_TAG, null);
+				String name = curr.getRequiredAttribute(ListenerTagNames.SERVICE_NAME_TAG);
 				_destinations.put(key, new String[] { category, name });
 			}
 			catch (Exception e)

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/StaticRouter.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/StaticRouter.java	2007-01-27 16:55:09 UTC (rev 9043)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/StaticRouter.java	2007-01-27 18:45:41 UTC (rev 9044)
@@ -90,8 +90,8 @@
 			{
 				String category = curr.getAttribute(
 						ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, "");
-				String name = curr.getAttribute(
-						ListenerTagNames.SERVICE_NAME_TAG, null);
+				String name = curr.getRequiredAttribute(
+						ListenerTagNames.SERVICE_NAME_TAG);
 				_destinations.add(new String[]
 				{ category, name });
 			}

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SystemPrintln.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SystemPrintln.java	2007-01-27 16:55:09 UTC (rev 9043)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SystemPrintln.java	2007-01-27 18:45:41 UTC (rev 9044)
@@ -21,7 +21,6 @@
 
 import java.io.Serializable;
 
-import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.message.Message;
 
@@ -38,11 +37,7 @@
 	 * @param config Configuration.
 	 */
 	public SystemPrintln(ConfigTree config) {
-		try {
-			printlnMessage = config.getAttribute("message", "** 'message' attribute not set **");
-		} catch (ConfigurationException e) {
-			printlnMessage = "** 'message' attribute not set **";
-		}
+		printlnMessage = config.getAttribute("message", "** 'message' attribute not set **");
 	}
 	
 	/* (non-Javadoc)

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/SmooksTransformer.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/SmooksTransformer.java	2007-01-27 16:55:09 UTC (rev 9043)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/SmooksTransformer.java	2007-01-27 18:45:41 UTC (rev 9044)
@@ -513,11 +513,11 @@
 				Context context = Configuration.getNamingContext(CONFIGURATION_SECTION);
 				topic = (Topic) context.lookup(notificationTopic);
 			} catch (ConfigurationException e) {
-				logger.error("Topic lookup failed for the Transformation configuration Update Listener.  Topic name '" + notificationTopic + "'. Update listener disabled!", e);
+				logger.error("Topic lookup failed for the Transformation configuration Update Listener.  Topic name '" + notificationTopic + "'.  \n\t\tThis JMS Topic may not be deployed, or this ESB instance may not be looking at the correct JMS provider (check configuration '" + Context.PROVIDER_URL + "' in config module/section '" + CONFIGURATION_SECTION + "').  \n\t\tUpdate listener disabled!", e);
 				close();
 				return false;
 			} catch (NamingException e) {
-				logger.error("Topic lookup failed for the Transformation configuration Update Listener.  Topic name '" + notificationTopic + "'. Update listener disabled!", e);
+				logger.error("Topic lookup failed for the Transformation configuration Update Listener.  Topic name '" + notificationTopic + "'.  \n\t\tThis JMS Topic may not be deployed, or this ESB instance may not be looking at the correct JMS provider (check configuration '" + Context.PROVIDER_URL + "' in config module/section '" + CONFIGURATION_SECTION + "').  \n\t\tUpdate listener disabled!", e);
 				close();
 				return false;
 			}

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java	2007-01-27 16:55:09 UTC (rev 9043)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java	2007-01-27 18:45:41 UTC (rev 9044)
@@ -196,7 +196,7 @@
 		try
 		{
 
-			String name = tree.getAttribute(JMSEpr.DESTINATION_NAME_TAG, null);
+			String name = tree.getRequiredAttribute(JMSEpr.DESTINATION_NAME_TAG);
 
 			String type = getAttrAndWarn(tree, JMSEpr.DESTINATION_TYPE_TAG,
 					"queue");
@@ -233,7 +233,7 @@
 	{
 		try
 		{
-			URL url = new URL(tree.getAttribute(ListenerTagNames.URL_TAG, null));
+			URL url = new URL(tree.getRequiredAttribute(ListenerTagNames.URL_TAG));
 			String protocol = url.getProtocol();
 	
 			if ("file".equals(protocol))
@@ -337,7 +337,7 @@
 
 	public static JDBCEpr jdbcEprFromElement(ConfigTree tree) throws ConfigurationException
 	{
-		String url = tree.getAttribute(JDBCEpr.URL_TAG, null);
+		String url = tree.getRequiredAttribute(JDBCEpr.URL_TAG);
 		if (!url.toLowerCase().startsWith("jdbc"))
 			throw new ConfigurationException("URL in "
 					+ ListenerTagNames.URL_TAG + " must be a jdbc URL");
@@ -349,10 +349,10 @@
 			boolean bErrorDel = Boolean.valueOf(tree.getAttribute(
 					JDBCEpr.ERROR_DEL_TAG, "true"));
 			JDBCEpr epr = new JDBCEpr(url, bPostDel, bErrorDel);
-			epr.setDriver(tree.getAttribute(JDBCEpr.DRIVER_TAG, null));
+			epr.setDriver(tree.getRequiredAttribute(JDBCEpr.DRIVER_TAG));
 			epr.setUserName(getAttrAndWarn(tree, JDBCEpr.USERNAME_TAG, ""));
 			epr.setPassword(getAttrAndWarn(tree, JDBCEpr.PASSWORD_TAG, ""));
-			epr.setTableName(tree.getAttribute(JDBCEpr.TABLE_NAME_TAG, null));
+			epr.setTableName(tree.getRequiredAttribute(JDBCEpr.TABLE_NAME_TAG));
 			epr.setMessageIdColumn(getColName(tree, JDBCEpr.MESSAGE_ID_COLUMN_TAG));
 			epr.setStatusColumn(getColName(tree, JDBCEpr.STATUS_COLUMN_TAG));
 			epr.setDataColumn(getColName(tree, JDBCEpr.DATA_COLUMN_TAG));

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	2007-01-27 16:55:09 UTC (rev 9043)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	2007-01-27 18:45:41 UTC (rev 9044)
@@ -293,7 +293,7 @@
 	
 			_tableName = _config.getAttribute(ListenerTagNames.SQL_TABLE_NAME_TAG);
 			if (null == _tableName)
-				_tableName = _config.getAttribute(JDBCEpr.TABLE_NAME_TAG, null);
+				_tableName = _config.getRequiredAttribute(JDBCEpr.TABLE_NAME_TAG);
 			if (Util.isNullString(_tableName))
 				throw new ConfigurationException("Empty or invalid table name");
 	
@@ -304,8 +304,7 @@
 						"Empty or invalid list of select fields");
 			_keyFields = _config.getAttribute(ListenerTagNames.SQL_KEY_FIELDS_TAG);
 			if (null == _keyFields)
-				_keyFields = _config.getAttribute(JDBCEpr.MESSAGE_ID_COLUMN_TAG,
-						null);
+				_keyFields = _config.getRequiredAttribute(JDBCEpr.MESSAGE_ID_COLUMN_TAG);
 			if (Util.isNullString(_keyFields))
 				throw new ConfigurationException(
 						"Empty or invalid list of key fields");

Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java	2007-01-27 16:55:09 UTC (rev 9043)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java	2007-01-27 18:45:41 UTC (rev 9044)
@@ -1,121 +0,0 @@
-package org.jboss.soa.esb.actions.templates;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.JUnit4TestAdapter;
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.jboss.soa.esb.actions.AbstractSqlRowAction;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.common.tests.BaseTest;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.message.format.MessageType;
-
-/**
- * Testing the AbstractSqlRowActionTest
- *
- * @author Jason Lenhart
- */
-public class SqlRowActionUnitTest extends BaseTest
-{
-
-
-    private Logger logger = Logger.getLogger(this.getClass());
-
-    /**
-     * Process a Message through the process() of AbstractSqlRowAction
-     * Using an Inner Class Implementation of AbstractSqlRowAction
-     */
-    public void testProcessMessage()
-    {
-        // Body Must implement Map in order to have SqlRowAction process
-        Message msg1 = MessageFactory.getInstance().getMessage(MessageType.DEFAULT_TYPE);
-
-        msg1.getBody().add("org.jboss.soa.esb.actions.current.after", new HashMap());
-
-        try
-        {
-            // Instantiate my AbstractSqlRowAction Inner Class implementation and test the concrete method
-            AbstractSqlRowAction sqlRowAction = new AbstractSqlRowActionTestImpl("myaction", new ArrayList());
-            // Should get removed after processing
-            Message msg2 = sqlRowAction.process(msg1);
-            Object obj = msg2.getBody().get("org.jboss.soa.esb.actions.current.after");
-            //Assert that it is no longer within the Body
-            assertNull(obj);
-        }
-        catch (Exception _ex)
-        {
-            logger.log(Priority.ERROR, _ex.getMessage(), _ex);
-            assertTrue(false);
-        }
-    }
-
-
-    public void testProcessIncorrectMessage()
-    {
-        // Body Must implement Map in order to have SqlRowAction process
-        // for this test it will not and we will expect an
-        Message msg1 = MessageFactory.getInstance().getMessage(MessageType.DEFAULT_TYPE);
-
-        msg1.getBody().add("org.jboss.soa.esb.actions.current.after", new Object());
-
-        try
-        {
-            // Instantiate my AbstractSqlRowAction Inner Class implementation and test the concrete method
-            AbstractSqlRowAction sqlRowAction = new AbstractSqlRowActionTestImpl("myaction", new ArrayList());
-            sqlRowAction.process(msg1);
-            assertTrue(false);
-
-        }
-        catch (ActionProcessingException _apex)
-        {
-            assertTrue(true);
-        }
-        catch (Exception _ex)
-        {
-            logger.log(Priority.ERROR, _ex.getMessage(), _ex);
-            assertTrue(false);
-        }
-
-
-    }
-
-
-    public static junit.framework.Test suite()
-    {
-        return new JUnit4TestAdapter(SqlRowActionUnitTest.class);
-    }
-
-
-    private class AbstractSqlRowActionTestImpl extends AbstractSqlRowAction
-    {
-        protected AbstractSqlRowActionTestImpl(String actionName, List<KeyValuePair> properties)
-                throws Exception
-        {
-            super(actionName, properties);
-        }
-
-
-        protected Object process(Map resultSet) throws ActionProcessingException
-        {
-            return null;
-        }
-
-        public Serializable getOkNotification(Message message)
-        {
-            return null;
-        }
-
-        public Serializable getErrorNotification(Message message)
-        {
-            return null;
-        }
-    }
-
-}

Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java.back (from rev 9043, labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java.back	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/templates/SqlRowActionUnitTest.java.back	2007-01-27 18:45:41 UTC (rev 9044)
@@ -0,0 +1,121 @@
+package org.jboss.soa.esb.actions.templates;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.JUnit4TestAdapter;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.jboss.soa.esb.actions.AbstractSqlRowAction;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+/**
+ * Testing the AbstractSqlRowActionTest
+ *
+ * @author Jason Lenhart
+ */
+public class SqlRowActionUnitTest extends BaseTest
+{
+
+
+    private Logger logger = Logger.getLogger(this.getClass());
+
+    /**
+     * Process a Message through the process() of AbstractSqlRowAction
+     * Using an Inner Class Implementation of AbstractSqlRowAction
+     */
+    public void testProcessMessage()
+    {
+        // Body Must implement Map in order to have SqlRowAction process
+        Message msg1 = MessageFactory.getInstance().getMessage(MessageType.DEFAULT_TYPE);
+
+        msg1.getBody().add("org.jboss.soa.esb.actions.current.after", new HashMap());
+
+        try
+        {
+            // Instantiate my AbstractSqlRowAction Inner Class implementation and test the concrete method
+            AbstractSqlRowAction sqlRowAction = new AbstractSqlRowActionTestImpl("myaction", new ArrayList());
+            // Should get removed after processing
+            Message msg2 = sqlRowAction.process(msg1);
+            Object obj = msg2.getBody().get("org.jboss.soa.esb.actions.current.after");
+            //Assert that it is no longer within the Body
+            assertNull(obj);
+        }
+        catch (Exception _ex)
+        {
+            logger.log(Priority.ERROR, _ex.getMessage(), _ex);
+            assertTrue(false);
+        }
+    }
+
+
+    public void testProcessIncorrectMessage()
+    {
+        // Body Must implement Map in order to have SqlRowAction process
+        // for this test it will not and we will expect an
+        Message msg1 = MessageFactory.getInstance().getMessage(MessageType.DEFAULT_TYPE);
+
+        msg1.getBody().add("org.jboss.soa.esb.actions.current.after", new Object());
+
+        try
+        {
+            // Instantiate my AbstractSqlRowAction Inner Class implementation and test the concrete method
+            AbstractSqlRowAction sqlRowAction = new AbstractSqlRowActionTestImpl("myaction", new ArrayList());
+            sqlRowAction.process(msg1);
+            assertTrue(false);
+
+        }
+        catch (ActionProcessingException _apex)
+        {
+            assertTrue(true);
+        }
+        catch (Exception _ex)
+        {
+            logger.log(Priority.ERROR, _ex.getMessage(), _ex);
+            assertTrue(false);
+        }
+
+
+    }
+
+
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(SqlRowActionUnitTest.class);
+    }
+
+
+    private class AbstractSqlRowActionTestImpl extends AbstractSqlRowAction
+    {
+        protected AbstractSqlRowActionTestImpl(String actionName, List<KeyValuePair> properties)
+                throws Exception
+        {
+            super(actionName, properties);
+        }
+
+
+        protected Object process(Map resultSet) throws ActionProcessingException
+        {
+            return null;
+        }
+
+        public Serializable getOkNotification(Message message)
+        {
+            return null;
+        }
+
+        public Serializable getErrorNotification(Message message)
+        {
+            return null;
+        }
+    }
+
+}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/helpers/ConfigTree.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/helpers/ConfigTree.java	2007-01-27 16:55:09 UTC (rev 9043)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/helpers/ConfigTree.java	2007-01-27 18:45:41 UTC (rev 9044)
@@ -126,31 +126,47 @@
 		return (null==_attributes) ? 0 : _attributes.size();
 	} // _______________________________
 	/**
-	 * retrieve the value assigned to an attribute key
-	 * @param name String - the search key
-	 * @return String - the value assigned to the specified key
+	 * Retrieve the value assigned to an attribute key.
+	 * @param name String - the search key.
+	 * @return String - the value assigned to the specified key, or null if the
+	 * attribute is not defined.
 	 */
 	public String getAttribute(String name)
 	{
 		return (null==_attributes) ? null : _attributes.get(name);
 	} // _______________________________
 	/**
-	 * retrieve the value assigned to an attribute key
-	 * @param name String - the search key
-	 * @param defaultValue String - the default value to return if attribute is not set
-	 * @return String - the value assigned to the specified key
+	 * Retrieve the value assigned to an attribute key, returning the supplied default
+	 * if the attribute is not defined.
+	 * @param name String - the search key.
+	 * @param defaultValue String - the default value to return if attribute is not set.
+	 * @return String - the value assigned to the specified key, or the default if
+	 * the value is not defined.
 	 */
 	public String getAttribute(String name, String defaultValue)
-		throws ConfigurationException
 	{
 		String ret = (null==_attributes) ? null : _attributes.get(name);
-		if (null!=ret)
-			return ret;
-		if (null!=defaultValue)
-			return defaultValue;
-		throw new ConfigurationException("Invalid or missing <"+name+"> attribute ");
+		return (ret !=null?ret:defaultValue);
 	} // _______________________________
+	
 	/**
+	 * Get the value of a requred property, throwing a {@link ConfigurationException}
+	 * if the property is not defined. 
+	 * @param name String - the search key.
+	 * @return The value assigned to the specified property.
+	 * @throws ConfigurationException The propery is not defined.
+	 */
+	public String getRequiredAttribute(String name) throws ConfigurationException {
+		String ret = getAttribute(name);
+		
+		if(ret == null) {
+			throw new ConfigurationException("Required configuration property '" + name + "' not defined on configuration '" + _name + "'.");
+		}
+		
+		return ret;
+	}
+	
+	/**
 	 * obtain the list of all attribute names
 	 * @return Set<String>  - the set of keys that have been assigned a non null value
 	 */




More information about the jboss-svn-commits mailing list