[jboss-svn-commits] JBL Code SVN: r18600 - 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
Tue Feb 26 14:25:27 EST 2008


Author: beve
Date: 2008-02-26 14:25:27 -0500 (Tue, 26 Feb 2008)
New Revision: 18600

Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContentsUnitTest.java
Log:
Work for JBESB-1559 "DefaultESBPropertiesSetter should not set the ESBMessageID"


Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java	2008-02-26 17:33:54 UTC (rev 18599)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java	2008-02-26 19:25:27 UTC (rev 18600)
@@ -3,17 +3,17 @@
  * 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
@@ -48,8 +48,8 @@
  * </lu>
  * Note: JMSCorrelationID is set as a fragment on the URI and can be retrieved like this:
  * correlationURI.getFragment();
- * 
- * @author <a href="mailto:daniel.bevenius at redpill.se">Daniel Bevenius</a>				
+ *
+ * @author <a href="mailto:daniel.bevenius at redpill.se">Daniel Bevenius</a>
  * @since 4.2
  *
  */
@@ -59,45 +59,22 @@
 
 	public void setPropertiesFromJMSMessage( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
 	{
-		setMessageID( fromJMSMessage, toESBMessage );
 		setCorrelationID( fromJMSMessage, toESBMessage );
 		setReplyTo( fromJMSMessage, toESBMessage );
 		setExpiration( fromJMSMessage, toESBMessage );
 		setProperties( fromJMSMessage, toESBMessage );
 	}
-	
-	private void setMessageID( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
-	{
-		if ( fromJMSMessage.getJMSMessageID()!=null) 
-		{
-			try
-			{
-				String messageID = fromJMSMessage.getJMSMessageID();
-				if ( messageID.contains( "<" ) )
-					messageID = messageID.replace( "<", "&lt;" );
-				if ( messageID.contains( ">" ) )
-					messageID = messageID.replace( ">", "&gt;" );
-				toESBMessage.getHeader().getCall().setMessageID( new URI( messageID ));
-			} 
-			catch (URISyntaxException e) 
-			{
-				String errorMessage = "Could not set ESB MessageID to JMSMessageID [" + fromJMSMessage.getJMSMessageID() + "]";
-				log.error( errorMessage, e );
-				throw new JMSException( errorMessage );
-			}
-		}
-	}
-	
+
 	private void setCorrelationID( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
 	{
-		if ( fromJMSMessage.getJMSCorrelationID()!=null) 
+		if ( fromJMSMessage.getJMSCorrelationID()!=null)
 		{
 			try
 			{
 				final URI correlationURI = new URI( JMSEpr.JMS_PROTOCOL, "correlationID" , fromJMSMessage.getJMSCorrelationID()  );
 				toESBMessage.getHeader().getCall().setRelatesTo( correlationURI );
-			} 
-			catch (URISyntaxException e) 
+			}
+			catch (URISyntaxException e)
 			{
 				final String errorMessage = "Could not ESB setRelatesTo to JMSCorrelationID [ " + fromJMSMessage.getJMSCorrelationID() + "]";
 				log.error( errorMessage, e );
@@ -105,10 +82,10 @@
 			}
 		}
 	}
-	
+
 	private void setReplyTo( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
 	{
-		if ( fromJMSMessage.getJMSReplyTo()!=null) 
+		if ( fromJMSMessage.getJMSReplyTo()!=null)
 		{
 			final Destination replyToDestination = fromJMSMessage.getJMSReplyTo();
 			final String connectionFactory = ModulePropertyManager.getPropertyManager("javax.jms.ConnectionFactory").getProperty(ConnectionFactory.class.getName(), "ConnectionFactory");
@@ -129,7 +106,7 @@
 			toESBMessage.getHeader().getCall().setReplyTo( new JMSEpr( destType , destName, connectionFactory ) );
 		}
 	}
-	
+
 	private void setExpiration( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
 	{
 		if( fromJMSMessage.getJMSExpiration() != 0 )
@@ -141,7 +118,7 @@
 			toESBMessage.getProperties().setProperty( JMSPropertiesSetter.JMS_EXPIRATION, ttl );
 		}
 	}
-	
+
 	private void setProperties( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
 	{
 		@SuppressWarnings("unchecked")

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java	2008-02-26 17:33:54 UTC (rev 18599)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java	2008-02-26 19:25:27 UTC (rev 18600)
@@ -3,17 +3,17 @@
  * 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
@@ -44,48 +44,30 @@
 /**
  * Unit test for DefaultESBPropertiesSetter
  * </p>
- * 
- * @author <a href="mailto:daniel.bevenius at redpill.se">Daniel Bevenius</a>				
+ *
+ * @author <a href="mailto:daniel.bevenius at redpill.se">Daniel Bevenius</a>
  * @since 4.2
  */
 public class DefaultESBPropertiesSetterUnitTest
 {
 	@SuppressWarnings ("unused")
 	private Logger log = Logger .getLogger( DefaultESBPropertiesSetterUnitTest.class );
-	
+
 	private final static String jmsMessageID = "123456780";
 	private final static String jmsCorrelationID = "YYXX-123456780-GG";
 	private ESBPropertiesSetter strategy;
 	private javax.jms.Message fromJMSTextMessage;
 	private Message toESBMessage;
-	
-	@Test (expected = JMSException.class )
-	public void setPropertiesFromJMSMessage_MessageID_negative() throws JMSException
-	{
-		log.debug( "The following Exception is expected: ");
-		fromJMSTextMessage.setJMSMessageID( "  -- // == " );
-		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
-	}
-	
+
 	@Test
-	public void setPropertiesFromJMSMessage_MessageID() throws JMSException
-	{
-		fromJMSTextMessage.setJMSMessageID( jmsMessageID );
-		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
-		
-		URI messageID = toESBMessage.getHeader().getCall().getMessageID();
-		assertEquals( jmsMessageID,  messageID.toString() );
-	}
-	
-	@Test
 	public void setPropertiesFromJMSMessage_CorrelationID() throws JMSException
 	{
 		fromJMSTextMessage.setJMSCorrelationID( jmsCorrelationID );
 		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
-		
+
 		assertEquals( jmsCorrelationID, toESBMessage.getHeader().getCall().getRelatesTo().getFragment() );
 	}
-	
+
 	@Test
 	public void setPropertiesFromJMSMessage_ReplyTo() throws JMSException
 	{
@@ -93,53 +75,41 @@
 		final MockQueue queue = new MockQueue( destinationName );
 		fromJMSTextMessage.setJMSReplyTo( queue );
 		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
-		
+
 		final EPR replyToEPR = toESBMessage.getHeader().getCall().getReplyTo();
-		
+
 		assertEquals( "jms://localhost/testDest", replyToEPR.getAddr().getAddress() );
-		
+
 		final String connectionFactory = replyToEPR.getAddr().getExtensionValue( JMSEpr.CONNECTION_FACTORY_TAG );
 		assertEquals ( "ConnectionFactory", connectionFactory );
 	}
-	
+
 	@Test
 	public void setPropertiesFromJMSMessage_Expiration() throws JMSException, InterruptedException
 	{
 		final long ttl = 5000l;
 		final long expirationTime = System.currentTimeMillis() + ttl;
 		fromJMSTextMessage.setJMSExpiration( expirationTime );
-		
+
 		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
-		
+
 		Long actualExpiration = (Long)toESBMessage.getProperties().getProperty( JMSPropertiesSetter.JMS_EXPIRATION );
 		assertTrue( actualExpiration != 0 );
 		assertTrue( actualExpiration > 0 );
 	}
-	
+
 	@Test
 	public void setPropertiesFromJMSMessage_withProperties() throws JMSException
 	{
 		final String propertyKey = "myProperty";
 		final String propertyValue = "myPropertyValue";
 		fromJMSTextMessage.setStringProperty( propertyKey, propertyValue );
-		
+
 		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
-		
+
 		assertEquals( propertyValue, toESBMessage.getProperties().getProperty( propertyKey )) ;
 	}
-	
-	@Test
-	public void setPropertiesFromJMSMessage_MessageID_xml_tag() throws JMSException
-	{
-		final String expectedMessageID = "ID:<kalle>";
-		final String expectedEncodedMessageID = "ID:&lt;kalle&gt;";
-		fromJMSTextMessage.setJMSMessageID( expectedMessageID );
-		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
-		
-		URI messageID = toESBMessage.getHeader().getCall().getMessageID();
-		assertEquals( expectedEncodedMessageID,  messageID.toString() );
-	}
-	
+
 	@Before
 	public void setup()
 	{
@@ -147,13 +117,13 @@
 		toESBMessage = MessageFactory.getInstance().getMessage();
 		strategy = new DefaultESBPropertiesSetter();
 	}
-	
+
 	/*
 	 * Just here to help Ant to find annotated test.
 	 */
 	public static junit.framework.Test suite()
 	{
 		return new JUnit4TestAdapter( DefaultESBPropertiesSetterUnitTest.class );
-	}	
+	}
 
 }

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	2008-02-26 17:33:54 UTC (rev 18599)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContentsUnitTest.java	2008-02-26 19:25:27 UTC (rev 18600)
@@ -3,17 +3,17 @@
  * 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
@@ -53,46 +53,46 @@
 
 /**
  * Unit test for PackageJmsMessageContents
- * 
- * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
  *
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>
+ *
  */
 public class PackageJmsMessageContentsUnitTest
 {
 	@SuppressWarnings ( "unused" )
 	private Logger log = Logger.getLogger( PackageJmsMessageContentsUnitTest.class );
-	
+
 	private final static String messageContent = "Test Message Content";
 	private final static String jmsMessageID = "123456780";
 	private final static String jmsCorrelationID = "YYXX-123456780-GG";
-	
+
 	private PackageJmsMessageContents packer;
 	private ObjectMessageImpl objectMsg;
-	
+
 	@Before
 	public void setup()
 	{
         ConfigTree emptyConfig = new ConfigTree("empty");
         MessagePayloadProxy proxy = PackageJmsMessageContents.createPayloadProxy(emptyConfig);
-        
+
         packer = new PackageJmsMessageContents(proxy);
 		objectMsg = new ObjectMessageImpl();
 	}
-	
+
 	@Test
 	public void process_ObjectMessage() throws JMSException, IOException, URISyntaxException, MessageDeliverException {
 		objectMsg.setObject( messageContent );
 		Message message = packer.process( objectMsg );
-		
+
 		assertThatByteArrayHasBeenSet( message );
-		
+
 		Object object = message.getBody().get();
 		assertTrue ( object instanceof String );
 		assertEquals (  String.class.getName(), object.getClass().getName() );
-		
+
 		assertEquals ( messageContent, message.getBody().get());
 	}
-	
+
 	@Test
 	public void process_ObjectMessage_HashMap() throws JMSException, IOException, URISyntaxException, MessageDeliverException {
 		final String key = "testkey";
@@ -101,93 +101,81 @@
 		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, MessageDeliverException {
 		TextMessageImpl textMessage = new TextMessageImpl();
 		textMessage.setText( messageContent );
 		Message message = packer.process( textMessage );
-		
+
 		assertThatByteArrayHasBeenSet( message );
-		
+
 		Object object = message.getBody().get();
 		assertTrue ( object instanceof String );
 		final String actualContent = (String) object;
 		assertEquals ( messageContent, actualContent );
 	}
-	
+
 	@Test
 	public void process_BytesMessage() throws JMSException, IOException, URISyntaxException, MessageDeliverException {
 		MockBytesMessage byteMessage = new MockBytesMessage();
-		
+
 		Message message = packer.process( byteMessage );
-		
+
 		assertThatByteArrayHasBeenSet( message );
-		
+
 	}
-	
+
 	@Test
-	public void process_with_JMSMessageID() throws JMSException, IOException, URISyntaxException, MessageDeliverException {
-		objectMsg.setObject( messageContent );
-		objectMsg.setJMSMessageID( jmsMessageID );
-		
-		Message message = packer.process( objectMsg );
-		
-		final String actualContent = (String)message.getBody().get();
-		assertEquals ( messageContent, actualContent );
-		assertEquals ( new URI( jmsMessageID ), message.getHeader().getCall().getMessageID()  );
-	}
-	
-	@Test
 	public void process_with_JMSCorrelationID() throws JMSException, IOException, URISyntaxException, MessageDeliverException {
 		objectMsg.setObject( messageContent );
 		objectMsg.setJMSCorrelationID( jmsCorrelationID );
-		
+
 		Message message = packer.process( objectMsg );
-		
+
 		assertEquals ( jmsCorrelationID, message.getHeader().getCall().getRelatesTo().getFragment()  );
 	}
-	
+
 	@Test
 	public void process_with_Properties() throws JMSException, IOException, URISyntaxException, MessageDeliverException {
 		final String propertyKey = "myProperty";
 		final String propertyValue = "myPropertyValue";
 		objectMsg.setObject( messageContent );
 		objectMsg.setObjectProperty( propertyKey, propertyValue );
-		
+
 		Message message = packer.process( objectMsg );
-		
+
 		assertEquals ( propertyValue, message.getProperties().getProperty( propertyKey ) );
 	}
-	
+
 	@Test
 	public void process_with_JMSReplyTo() throws JMSException, IOException, URISyntaxException, MessageDeliverException {
 		objectMsg.setObject( messageContent );
 		MockQueue jmsReplyToQueue = new MockQueue( "mockReplyToQueueName");
 		objectMsg.setJMSReplyTo( jmsReplyToQueue );
-		
+
 		Message message = packer.process( objectMsg );
-		
+
 		EPR replyTo = message.getHeader().getCall().getReplyTo();
 		assertTrue(  replyTo instanceof JMSEpr );
 		JMSEpr jmsEpr = (JMSEpr) replyTo;
 		assertEquals ( jmsReplyToQueue.getQueueName() , jmsEpr.getDestinationName() );
 	}
-	
+
 	/**
 	 * This asserts that the JMS Message's bodies content
 	 * is always set on the ESB Message object as a byte array.
-	 * 
+	 *
 	 * This is a backward compability issue and more on the reason for
 	 * this can be found in this ESB User Forum thread:
 	 * http://www.jboss.com/index.html?module=bb&op=viewtopic&t=113726&postdays=0&postorder=asc&start=10
@@ -197,7 +185,7 @@
 	{
 		assertNotNull ("byte array must always be set regardless of the type of JMS Message", esbMessage.getBody().get() );
 	}
-	
+
 	/**
 	 * Just here to get Ant to find annotated test.
 	 */




More information about the jboss-svn-commits mailing list