[jboss-svn-commits] JBL Code SVN: r14442 - in labs/jbossesb/trunk/product/rosetta: src/org/jboss/soa/esb/notification/jms and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 22 05:03:28 EDT 2007
Author: beve
Date: 2007-08-22 05:03:28 -0400 (Wed, 22 Aug 2007)
New Revision: 14442
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContentsUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java
Log:
Work for http://jira.jboss.com/jira/browse/JBESB-724
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java 2007-08-22 07:53:02 UTC (rev 14441)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java 2007-08-22 09:03:28 UTC (rev 14442)
@@ -86,11 +86,6 @@
*/
private static Logger logger = Logger.getLogger(JMSRouter.class);
/**
- * Indicates whether processing of the action pipeline
- * should continue or not.
- */
- public static final String ATTR_CONTINUE_ACTION_PIPELINE_PROCESSING = "continue-processing";
- /**
* Routing properties.
*/
private List<KeyValuePair> properties;
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java 2007-08-22 07:53:02 UTC (rev 14441)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java 2007-08-22 09:03:28 UTC (rev 14442)
@@ -69,7 +69,6 @@
private void setJMSMessageID( final org.jboss.soa.esb.message.Message fromESBMessage , final Message toJMSMessage ) throws JMSException
{
final URI messageID = fromESBMessage.getHeader().getCall().getMessageID();
- log.debug( "MessageID is: " + messageID );
if ( messageID != null )
{
log.debug( "Setting outgoing JMSCorreletionID to : " + messageID );
@@ -88,6 +87,25 @@
}
}
+ /**
+ * Set ESB Message object properties on the outgoing JMS Message object instance.
+ * <p>
+ * Property names must obey the rules for a message selector identifier, See section 3.8.1.1,
+ * “Message Selector Syntax” on the JMS Spec.
+ * </p>
+ * Values must also by set with the correct type so that selector expressions work as
+ * expected.
+ * For example:
+ * myMessage.setStringProperty("NumberOfOrders", "2");
+ * The following expression in a message selector would evaluate to false,
+ * because a string cannot be used in an arithmetic expression:
+ * "NumberOfOrders > 1"
+ *
+ * @param fromESBMessage ESB Message object instance from which properties will be retrevied
+ * @param toJMSMessage JMS Message object instance upon which the properties will be set
+ *
+ * @throws JMSException
+ */
private void setProperties( final org.jboss.soa.esb.message.Message fromESBMessage, final Message toJMSMessage ) throws JMSException
{
Properties properties = fromESBMessage.getProperties();
@@ -96,11 +114,24 @@
if ( !Strings.isValidJavaIdentifier( key ))
continue;
- Object property = properties.getProperty( key );
- if ( property != null && ( property instanceof String ) )
- {
- toJMSMessage.setStringProperty( key, (String) property );
- }
+ Object value = properties.getProperty( key );
+ log.debug( "Setting outgoing JMSProperty, key : " + key + ", value : " + value );
+ if ( value instanceof String )
+ toJMSMessage.setStringProperty( key, (String) value );
+ else if ( value instanceof Boolean )
+ toJMSMessage.setBooleanProperty( key, (Boolean)value );
+ else if ( value instanceof Short )
+ toJMSMessage.setShortProperty( key, (Short)value );
+ else if ( value instanceof Integer )
+ toJMSMessage.setIntProperty( key, (Integer)value );
+ else if ( value instanceof Long )
+ toJMSMessage.setLongProperty( key, (Long)value );
+ else if ( value instanceof Float )
+ toJMSMessage.setFloatProperty( key, (Float)value );
+ else if ( value instanceof Double )
+ toJMSMessage.setDoubleProperty( key, (Double)value );
+ else if ( value instanceof Byte )
+ toJMSMessage.setByteProperty( key, (Byte)value );
}
}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContentsUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContentsUnitTest.java 2007-08-22 07:53:02 UTC (rev 14441)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContentsUnitTest.java 2007-08-22 09:03:28 UTC (rev 14442)
@@ -29,6 +29,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Enumeration;
+import java.util.HashMap;
import javax.jms.BytesMessage;
import javax.jms.Destination;
@@ -87,6 +88,26 @@
}
@Test
+ public void process_ObjectMessage_HashMap() throws JMSException, IOException, URISyntaxException
+ {
+ final String key = "testkey";
+ final String value = "testvalue";
+ HashMap<String,String> hashMap = new HashMap<String,String>();
+ hashMap.put( key, value );
+ objectMsg.setObject( hashMap );
+ Message message = packer.process( objectMsg );
+
+ assertThatByteArrayHasBeenSet( message );
+
+ Object object = message.getBody().get();
+ assertTrue ( object instanceof HashMap );
+
+ assertEquals ( HashMap.class.getName(), object.getClass().getName() );
+ HashMap actualMap = (HashMap) object;
+ assertEquals ( hashMap, actualMap );
+ }
+
+ @Test
public void process_TextMessage() throws JMSException, IOException, URISyntaxException
{
TextMessageImpl textMessage = new TextMessageImpl();
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java 2007-08-22 07:53:02 UTC (rev 14441)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java 2007-08-22 09:03:28 UTC (rev 14442)
@@ -52,6 +52,7 @@
private final String bodyContent = "hello";
private final String messageID = "1234-junittest";
+ private final String propertyKey = "testKey";
private TextMessageImpl toJMSMessage;
private DefaultJMSPropertiesSetter strategy;
private Message fromESBMessage;
@@ -98,9 +99,8 @@
}
@Test
- public void setJMSProperties_with_set_properties() throws JMSException, URISyntaxException
+ public void setJMSProperties_with_set_String_property() throws JMSException, URISyntaxException
{
- final String propertyKey = "name";
final String propertyValue = "myPropertyValue";
fromESBMessage.getProperties().setProperty( propertyKey, propertyValue );
@@ -108,6 +108,76 @@
assertEquals ( propertyValue, toJMSMessage.getStringProperty( propertyKey ) );
}
+ @Test
+ public void setJMSProperties_with_set_boolean_property() throws JMSException, URISyntaxException
+ {
+ final boolean propertyValue = true;
+ fromESBMessage.getProperties().setProperty( propertyKey, propertyValue );
+
+ strategy.setJMSProperties( fromESBMessage, toJMSMessage );
+ assertEquals ( propertyValue, toJMSMessage.getBooleanProperty( propertyKey ) );
+ }
+
+ @Test
+ public void setJMSProperties_with_set_short_property() throws JMSException, URISyntaxException
+ {
+ final short propertyValue = 2;
+ fromESBMessage.getProperties().setProperty( propertyKey, propertyValue );
+
+ strategy.setJMSProperties( fromESBMessage, toJMSMessage );
+ assertEquals ( propertyValue, toJMSMessage.getShortProperty( propertyKey ) );
+ }
+
+ @Test
+ public void setJMSProperties_with_set_int_property() throws JMSException, URISyntaxException
+ {
+ final int propertyValue = 2;
+ fromESBMessage.getProperties().setProperty( propertyKey, propertyValue );
+
+ strategy.setJMSProperties( fromESBMessage, toJMSMessage );
+ assertEquals ( propertyValue, toJMSMessage.getIntProperty( propertyKey ) );
+ }
+
+ @Test
+ public void setJMSProperties_with_set_long_property() throws JMSException, URISyntaxException
+ {
+ final long propertyValue = 102l;
+ fromESBMessage.getProperties().setProperty( propertyKey, propertyValue );
+
+ strategy.setJMSProperties( fromESBMessage, toJMSMessage );
+ assertEquals ( propertyValue, toJMSMessage.getLongProperty( propertyKey ) );
+ }
+
+ @Test
+ public void setJMSProperties_with_set_float_property() throws JMSException, URISyntaxException
+ {
+ final float propertyValue = 1024;
+ fromESBMessage.getProperties().setProperty( propertyKey, propertyValue );
+
+ strategy.setJMSProperties( fromESBMessage, toJMSMessage );
+ assertEquals ( propertyValue, toJMSMessage.getFloatProperty( propertyKey ) );
+ }
+
+ @Test
+ public void setJMSProperties_with_set_double_property() throws JMSException, URISyntaxException
+ {
+ final double propertyValue = 1024d;
+ fromESBMessage.getProperties().setProperty( propertyKey, propertyValue );
+
+ strategy.setJMSProperties( fromESBMessage, toJMSMessage );
+ assertEquals ( propertyValue, toJMSMessage.getDoubleProperty( propertyKey ) );
+ }
+
+ @Test
+ public void setJMSProperties_with_set_byte_property() throws JMSException, URISyntaxException
+ {
+ final byte propertyValue = 22;
+ fromESBMessage.getProperties().setProperty( propertyKey, propertyValue );
+
+ strategy.setJMSProperties( fromESBMessage, toJMSMessage );
+ assertEquals ( propertyValue, toJMSMessage.getByteProperty( propertyKey ) );
+ }
+
@Before
public void before() throws JMSException
{
More information about the jboss-svn-commits
mailing list