[jboss-svn-commits] JBL Code SVN: r21023 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/soa/esb/listeners/gateway and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jul 14 08:52:00 EDT 2008


Author: beve
Date: 2008-07-14 08:52:00 -0400 (Mon, 14 Jul 2008)
New Revision: 21023

Added:
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyJMSIntegrationTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/SerializableMockQueue.java
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/listeners/gateway/DefaultESBPropertiesSetter.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/NotifyJMS.java
   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/JMSPropertiesSetter.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.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
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java
   labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbm-queue-service.xml
   labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbmq-queue-service.xml
   labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jboss-esb.xml
   labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java
Log:
Work for "JBESB-1622" "Need to add an ESB reply to header"


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	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -45,7 +45,6 @@
 import org.jboss.internal.soa.esb.rosetta.pooling.JmsSession;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.eprs.JMSEpr;
 import org.jboss.soa.esb.common.Configuration;
 import org.jboss.soa.esb.helpers.ConfigTree;
@@ -238,6 +237,7 @@
 
             setStringProperties(jmsMessage);
             setJMSProperties( esbMessage, jmsMessage );
+            setJMSReplyTo( jmsMessage, esbMessage );
             send( jmsMessage );
 
         } catch(Exception e) {
@@ -376,7 +376,6 @@
         MessageProducer jmsProducer;
         String destinationName;
         JmsConnectionPool pool;
-        Properties environment;
 
         private JMSSendQueueSetup(String destinationName) throws NamingException, JMSException, ConnectionException, NamingContextException  {
         	this( destinationName, null, null, null, null, null, null );
@@ -399,7 +398,7 @@
             if ( connectionFactoryName == null )
             	connectionFactoryName = "ConnectionFactory";
 
-            environment = new Properties();
+            Properties environment = new Properties();
             environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, jndiContextFactory);
             environment.setProperty(Context.PROVIDER_URL, jndiUrl);
             environment.setProperty(Context.URL_PKG_PREFIXES, jndiPkgPrefix);
@@ -467,31 +466,13 @@
         }
     }
 
-	protected void setJMSReplyTo( Message jmsMessage, org.jboss.soa.esb.message.Message esbMessage ) throws URISyntaxException, JMSException, NamingException, ConnectionException
+	protected void setJMSReplyTo( final Message jmsMessage, final org.jboss.soa.esb.message.Message esbMessage ) throws URISyntaxException, JMSException, NamingException, ConnectionException, NamingContextException
 	{
-		EPR replyToEpr = esbMessage.getHeader().getCall().getReplyTo();
-		if( !( replyToEpr instanceof JMSEpr) )
-			return;
-
-		JMSEpr jmsEpr = (JMSEpr) replyToEpr;
-		String destinationType = jmsEpr.getDestinationType();
-        Destination jmsDestination = null;
-
-		if ( destinationType.equals( JMSEpr.QUEUE_TYPE ))
+		Destination destination = (Destination) esbMessage.getProperties().getProperty( JMSPropertiesSetter.JMS_REPLY_TO );
+		if ( destination != null )
 		{
-            jmsDestination = queueSetup.jmsSession.createQueue( jmsEpr.getDestinationName() );
+			jmsMessage.setJMSReplyTo( (Destination) destination );
 		}
-		else
-		{
-			/* Topics are currently not supported.
-            JmsConnectionPool pool = JmsConnectionPoolContainer.getPool(queueSetup.environment, "ConnectionFactory", JMSEpr.TOPIC_TYPE);
-            jmsDestination = pool.getTopicSession().createTopic( jmsEpr.getDestinationName() );
-            */
-		}
-
-		if ( jmsDestination != null )
-			jmsMessage.setJMSReplyTo( jmsDestination );
-
 	}
 
 	/**

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-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetter.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -25,15 +25,12 @@
 import java.net.URISyntaxException;
 import java.util.Enumeration;
 
-import javax.jms.ConnectionFactory;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
-import javax.jms.Queue;
-import javax.jms.Topic;
+
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.common.ModulePropertyManager;
 import org.jboss.soa.esb.message.Properties;
 import org.jboss.soa.esb.notification.jms.JMSPropertiesSetter;
 
@@ -42,11 +39,11 @@
  * </p>
  * The following JMS Header fields are set on the ESB Message instance:
  * <lu>
- * <li> JMSMessageID 		-> Call.setMessagID
  * <li> JMSCorrelationID	-> Call.setRelatesTo	URI = jms:correlationID#YYXX-123456780-GG
- * <li> JMSReplyTo			-> Call.setReplyTo
+ * <li> JMSReplyTo			-> Properties( key = JMSPropertiesSetter.JMS_REPLY_TO )
  * <li> JMSExpiration		-> Properties( key = JMSPropertiesSetter.JMS_EXPIRATION )
- * <li> JMSRedeliverd		-> Properties( key = JMSPropertiesSetter.JMS_REDELIVERED
+ * <li> JMSRedeliverd		-> Properties( key = JMSPropertiesSetter.JMS_REDELIVERED )
+ * <li> JMSProperties		-> Properties( key = propertyName )
  * </lu>
  * Note: JMSCorrelationID is set as a fragment on the URI and can be retrieved like this:
  * correlationURI.getFragment();
@@ -64,6 +61,7 @@
 		setCorrelationID( fromJMSMessage, toESBMessage );
 		setReplyTo( fromJMSMessage, toESBMessage );
 		setExpiration( fromJMSMessage, toESBMessage );
+		setRedelivered( fromJMSMessage, toESBMessage );
 		setProperties( fromJMSMessage, toESBMessage );
 	}
 
@@ -78,34 +76,18 @@
 			}
 			catch (URISyntaxException e)
 			{
-				final String errorMessage = "Could not ESB setRelatesTo to JMSCorrelationID [ " + fromJMSMessage.getJMSCorrelationID() + "]";
-				log.error( errorMessage, e );
+				final String errorMessage = "Could not set ESB setRelatesTo to JMSCorrelationID [ " + fromJMSMessage.getJMSCorrelationID() + "]";
 				throw new JMSException( errorMessage );
 			}
 		}
 	}
 
-	private void setReplyTo( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
+	private void setReplyTo( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message esbMessage ) throws JMSException
 	{
-		if ( fromJMSMessage.getJMSReplyTo()!=null)
+		final Destination destination = fromJMSMessage.getJMSReplyTo();
+		if ( destination != null )
 		{
-			final Destination replyToDestination = fromJMSMessage.getJMSReplyTo();
-			final String connectionFactory = ModulePropertyManager.getPropertyManager("javax.jms.ConnectionFactory").getProperty(ConnectionFactory.class.getName(), "ConnectionFactory");
-			String destType = null;
-			String destName = null;
-			if ( replyToDestination instanceof Queue )
-			{
-				final Queue queue = ( Queue ) replyToDestination;
-				destName = queue.getQueueName();
-				destType = JMSEpr.QUEUE_TYPE;
-			}
-			else
-			{
-				final Topic topic = ( Topic ) replyToDestination;
-				destName = topic.getTopicName();
-				destType = JMSEpr.TOPIC_TYPE;
-			}
-			toESBMessage.getHeader().getCall().setReplyTo( new JMSEpr( destType , destName, connectionFactory ) );
+			esbMessage.getProperties().setProperty( JMSPropertiesSetter.JMS_REPLY_TO, destination );
 		}
 	}
 
@@ -120,6 +102,12 @@
 			toESBMessage.getProperties().setProperty( JMSPropertiesSetter.JMS_EXPIRATION, ttl );
 		}
 	}
+	
+	private void setRedelivered( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
+	{
+		final boolean redelivered = fromJMSMessage.getJMSRedelivered();
+		toESBMessage.getProperties().setProperty( JMSPropertiesSetter.JMS_REDELIVERED, Boolean.valueOf( redelivered ));
+	}
 
 	private void setProperties( final Message fromJMSMessage, final org.jboss.soa.esb.message.Message toESBMessage ) throws JMSException
 	{
@@ -136,8 +124,6 @@
 					esbProperties.setProperty(key, value);
 			}
 	     }
-		final boolean redelivered = fromJMSMessage.getJMSRedelivered();
-		esbProperties.setProperty( JMSPropertiesSetter.JMS_REDELIVERED, Boolean.valueOf( redelivered ));
 	}
 
 }

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/NotifyJMS.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/NotifyJMS.java	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/NotifyJMS.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -27,6 +27,7 @@
 import java.util.Properties;
 
 import javax.jms.DeliveryMode;
+import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageProducer;
@@ -39,14 +40,14 @@
 import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool;
 import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
 import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
 import org.jboss.soa.esb.addressing.eprs.JMSEpr;
 import org.jboss.soa.esb.common.Environment;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.MessagePayloadProxy;
 import org.jboss.soa.esb.message.body.content.BytesBody;
 import org.jboss.soa.esb.message.format.MessageType;
-import org.jboss.soa.esb.message.MessagePayloadProxy;
 import org.jboss.soa.esb.notification.jms.DefaultJMSPropertiesSetter;
 import org.jboss.soa.esb.notification.jms.JMSPropertiesSetter;
 
@@ -187,6 +188,8 @@
 	 */
 	protected long[] timeToLives;
 
+	private Properties environment;
+
 	/**
 	 * Constructor that will be called by child classes to perform
 	 * initialization tasks that are common to all derived classes
@@ -283,6 +286,7 @@
 		}
 		
 		setJMSProperties( esbMessage, jmsMessage );
+		setJMSReplyTo( jmsMessage, esbMessage );
 
 		for (Iterator<Object> II = m_oProps.keySet().iterator(); II.hasNext();)
 		{
@@ -323,6 +327,22 @@
 		jmsPropertiesStrategy.setJMSProperties( fromESBMessage, toJMSMessage );
 	}
 	
+	void setJMSReplyTo( final Message jmsMessage, final org.jboss.soa.esb.message.Message esbMessage ) throws NotificationException
+	{
+		Destination destination = (Destination) esbMessage.getProperties().getProperty( JMSPropertiesSetter.JMS_REPLY_TO );
+		if ( destination != null )
+		{
+			try
+			{
+    			jmsMessage.setJMSReplyTo( (Destination) destination );
+			}
+			catch (JMSException e)
+			{
+				throw new NotificationException( "Could not set the JMSReplyTo to destination [" + destination + "]", e );
+			} 
+		}
+	}
+	
 	/**
 	 * Template method for sending JMS messages to destinations.
 	 * </p>
@@ -378,7 +398,7 @@
 		{
 			for (int i = 0; i < nrQueuesOrTopics; i++)
 			{
-                Properties environment = new Properties();
+                environment = new Properties();
 				String sAtt = configTrees[i].getAttribute(ATT_DEST_NAME);
 				if (null == sAtt) throw new ConfigurationException("Missing attribute '" + ATT_DEST_NAME);
 				

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	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -23,8 +23,11 @@
 
 import java.net.URI;
 
+import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
+import javax.naming.Context;
+import javax.naming.NamingException;
 
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.message.Properties;
@@ -37,7 +40,6 @@
  * <lu>
  * <li> Call.setMessagID	-> JMSMessageID 		
  * <li> Call.setRelatesTo 	-> JMSCorrelationID
- * <li> Call.setReplyTo 	-> JMSReplyTo
  * <li> Properties( key = JSMPropertiesSetter.JMS_EXPIRATION ) -> JMSExpiration
  * </lu>
  * 
@@ -167,5 +169,5 @@
 				toJMSMessage.setByteProperty( key, (Byte)value );
 		}
 	}
-
+	
 }

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/jms/JMSPropertiesSetter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/jms/JMSPropertiesSetter.java	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/notification/jms/JMSPropertiesSetter.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -46,6 +46,12 @@
 	String JMS_REDELIVERED = "javax.jms.message.redelivered";
 	
 	/**
+	 * Key used when setting the JMSReplyTo as a 
+	 * property on an ESB Message instance.
+	 */
+	String JMS_REPLY_TO = "javax.jms.message.replyTo";
+	
+	/**
      * Sets JMS properties fields on the outgoing JMS Message.
      * </p>
      * 

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -35,7 +35,8 @@
 import javax.jms.JMSException;
 import javax.jms.Queue;
 import javax.jms.TextMessage;
-import javax.jms.Topic;
+import javax.naming.Context;
+import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import junit.framework.JUnit4TestAdapter;
@@ -46,13 +47,17 @@
 import org.jboss.soa.esb.actions.ActionProcessingException;
 import org.jboss.soa.esb.addressing.eprs.JMSEpr;
 import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.helpers.NamingContextException;
+import org.jboss.soa.esb.listeners.gateway.DefaultESBPropertiesSetter;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.testutils.SerializableMockQueue;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
+import org.mockejb.jms.MockQueue;
 import org.mockejb.jms.ObjectMessageImpl;
 import org.mockejb.jms.TextMessageImpl;
+import org.mockejb.jndi.MockContextFactory;
 
 /**
  * Integration test for {@link JMSRouter}
@@ -136,43 +141,40 @@
 	}
 
 	@Test
-	public void setJMSReplyToQueue() throws JMSException, URISyntaxException, ConfigurationException, NamingException, ConnectionException
+	public void setJMSReplyToQueue() throws JMSException, URISyntaxException, ConfigurationException, NamingException, ConnectionException, NamingContextException
 	{
-		final String queueName = "testQueue";
+		try
+		{
+    		MockContextFactory.setAsInitial();
+    		Context context = new InitialContext();
+    		MockContextFactory.setDelegateContext( context );
+		
+    		final String destName = "/queue/A";
+    		final MockQueue queue = new SerializableMockQueue( destName );
+		
+    		context.rebind( destName, queue );
 
-		TextMessageImpl jmsMessage = new TextMessageImpl();
+    		// inbound is to simulate a jms message arriving at a gateway endpoint.
+    		TextMessageImpl inBoundJmsMessage = new TextMessageImpl();
+    		inBoundJmsMessage.setJMSReplyTo( queue );
+    		new DefaultESBPropertiesSetter().setPropertiesFromJMSMessage( inBoundJmsMessage, msg );
+		
+    		JMSRouter router = new JMSRouter( createConfigTree() );
+    		
+    		// outbound is to simulate a new jms message that is about to leave the ESB.
+    		TextMessageImpl outBoundJmsMessage = new TextMessageImpl();
+    		router.setJMSReplyTo( outBoundJmsMessage,  msg );
 
-		JMSEpr jmsEpr = new JMSEpr( JMSEpr.QUEUE_TYPE, queueName , "ConnectionFactory" );
-		msg.getHeader().getCall().setReplyTo( jmsEpr );
-		JMSRouter router = new JMSRouter( createConfigTree() );
-		router.setJMSReplyTo( jmsMessage,  msg );
-
-		Destination replyTo = jmsMessage.getJMSReplyTo();
-		assertTrue( replyTo instanceof Queue );
-		Queue replyToQueue = (Queue) replyTo;
-		assertEquals( queueName , replyToQueue.getQueueName() );
+    		Destination replyTo = outBoundJmsMessage.getJMSReplyTo();
+    		assertTrue( replyTo instanceof Queue );
+		}
+		finally
+		{
+    		MockContextFactory.revertSetAsInitial();
+		}
 	}
-
+	
 	@Test
-	@Ignore
-	public void setJMSReplyToTopic() throws JMSException, URISyntaxException, ConfigurationException, NamingException, ConnectionException
-	{
-		final String queueName = "testTopic";
-
-		TextMessageImpl jmsMessage = new TextMessageImpl();
-
-		JMSEpr jmsEpr = new JMSEpr( JMSEpr.TOPIC_TYPE, queueName , "ConnectionFactory" );
-		msg.getHeader().getCall().setReplyTo( jmsEpr );
-		JMSRouter router = new JMSRouter( createConfigTree() );
-		router.setJMSReplyTo( jmsMessage,  msg );
-
-		Destination replyTo = jmsMessage.getJMSReplyTo();
-		assertTrue( replyTo instanceof Topic );
-		Topic replyToTopic = (Topic) replyTo;
-		assertEquals( queueName , replyToTopic.getTopicName() );
-	}
-
-	@Test
 	public void constructWithDefaultPersitentAttribute() throws ConfigurationException, NamingException, JMSException
 	{
 		ConfigTree config = createConfigTree();

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-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/DefaultESBPropertiesSetterUnitTest.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -22,20 +22,21 @@
 package org.jboss.soa.esb.listeners.gateway;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-import java.net.URI;
 
 import javax.jms.JMSException;
+import javax.jms.Queue;
 
 import junit.framework.JUnit4TestAdapter;
 
 import org.apache.log4j.Logger;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.format.MessageFactory;
 import org.jboss.soa.esb.notification.jms.JMSPropertiesSetter;
+import org.jboss.soa.esb.testutils.SerializableMockQueue;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockejb.jms.MockQueue;
@@ -53,7 +54,6 @@
 	@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;
@@ -69,19 +69,27 @@
 	}
 
 	@Test
-	public void setPropertiesFromJMSMessage_ReplyTo() throws JMSException
+	public void setPropertiesFromJMSMessageReplyTo() throws JMSException
 	{
-		final String destinationName = "testDest";
-		final MockQueue queue = new MockQueue( destinationName );
+		final String destinationName = "/queue/testDest";
+		final MockQueue queue = new SerializableMockQueue( destinationName );
 		fromJMSTextMessage.setJMSReplyTo( queue );
 		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
 
-		final EPR replyToEPR = toESBMessage.getHeader().getCall().getReplyTo();
+		final Object object = toESBMessage.getProperties().getProperty( JMSPropertiesSetter.JMS_REPLY_TO );
+		assertNotNull( object );
+		assertTrue( object instanceof Queue );
+	}
+	
+	@Test
+	public void setPropertiesFromJMSMessageReplyToNull() throws JMSException
+	{
+		final MockQueue queue = null;
+		fromJMSTextMessage.setJMSReplyTo( queue );
+		strategy.setPropertiesFromJMSMessage( fromJMSTextMessage , toESBMessage );
 
-		assertEquals( "jms://localhost/testDest", replyToEPR.getAddr().getAddress() );
-
-		final String connectionFactory = replyToEPR.getAddr().getExtensionValue( JMSEpr.CONNECTION_FACTORY_TAG );
-		assertEquals ( "ConnectionFactory", connectionFactory );
+		final String replyTo = (String) toESBMessage.getProperties().getProperty( JMSPropertiesSetter.JMS_REPLY_TO );
+		assertNull( replyTo );
 	}
 
 	@Test

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-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContentsUnitTest.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -34,6 +34,7 @@
 import javax.jms.BytesMessage;
 import javax.jms.Destination;
 import javax.jms.JMSException;
+import javax.jms.Queue;
 
 import junit.framework.JUnit4TestAdapter;
 
@@ -43,6 +44,8 @@
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.MessagePayloadProxy;
 import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.notification.jms.JMSPropertiesSetter;
+import org.jboss.soa.esb.testutils.SerializableMockQueue;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.listeners.message.MessageDeliverException;
 import org.junit.Before;
@@ -63,7 +66,6 @@
 	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;
@@ -161,15 +163,14 @@
 	@Test
 	public void process_with_JMSReplyTo() throws JMSException, IOException, URISyntaxException, MessageDeliverException {
 		objectMsg.setObject( messageContent );
-		MockQueue jmsReplyToQueue = new MockQueue( "mockReplyToQueueName");
+		MockQueue jmsReplyToQueue = new SerializableMockQueue( "/queue/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() );
+		Destination replyTo = (Destination) message.getProperties().getProperty( JMSPropertiesSetter.JMS_REPLY_TO );
+		assertNotNull ( replyTo );
+		assertTrue ( replyTo instanceof Queue );
 	}
 
 	/**

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyJMSIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyJMSIntegrationTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyJMSIntegrationTest.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.notification;
+
+import static org.junit.Assert.assertTrue;
+
+import java.net.URISyntaxException;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.internal.soa.esb.rosetta.pooling.ConnectionException;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.helpers.NamingContextException;
+import org.jboss.soa.esb.listeners.gateway.DefaultESBPropertiesSetter;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.testutils.SerializableMockQueue;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockejb.jms.MockQueue;
+import org.mockejb.jms.TextMessageImpl;
+import org.mockejb.jndi.MockContextFactory;
+
+/**
+ * Integration test for {@link NotifyJMS}
+ * <p/>
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
+ *
+ */
+public class NotifyJMSIntegrationTest
+{
+	private InitialContext context;
+	private String destName = "/queue/A";
+	private MockQueue queue;
+
+	@Test
+	public void setJMSReplyToQueue() throws JMSException, URISyntaxException, ConfigurationException, NamingException, ConnectionException, NamingContextException, NotificationException
+	{
+		TextMessageImpl inBoundJmsMessage = new TextMessageImpl();
+		inBoundJmsMessage.setJMSReplyTo( queue );
+
+		Message esbMessage = MessageFactory.getInstance().getMessage();
+		new DefaultESBPropertiesSetter().setPropertiesFromJMSMessage( inBoundJmsMessage, esbMessage );
+    		
+		NotifyJMS notifyJMS = new NotifyQueues( new ConfigTree("test" ) );
+		
+		TextMessageImpl outBoundJmsMessage = new TextMessageImpl();
+		notifyJMS.setJMSReplyTo( outBoundJmsMessage, esbMessage );
+		
+		Destination replyTo = outBoundJmsMessage.getJMSReplyTo();
+		assertTrue( replyTo instanceof Queue );
+	}
+	
+	@Before
+	public void before() throws NamingException
+	{
+		MockContextFactory.setAsInitial();
+		context = new InitialContext();
+		MockContextFactory.setDelegateContext( context );
+		queue = new SerializableMockQueue( destName );
+		context.rebind( destName, queue );
+	}
+	
+	@After
+	public void after()
+	{
+		MockContextFactory.revertSetAsInitial();
+	}
+	
+	/*
+	 * Just here to help Ant to find annotated test.
+	 */
+	public static junit.framework.Test suite()
+	{
+		return new JUnit4TestAdapter( NotifyJMSIntegrationTest.class );
+	}	
+	
+}

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	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -29,6 +29,9 @@
 import java.net.URISyntaxException;
 
 import javax.jms.JMSException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 
 import junit.framework.JUnit4TestAdapter;
 
@@ -36,9 +39,12 @@
 import org.jboss.soa.esb.addressing.eprs.JMSEpr;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.format.MessageFactory;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockejb.jms.MockQueue;
 import org.mockejb.jms.TextMessageImpl;
+import org.mockejb.jndi.MockContextFactory;
 
 /**
  * Unit test for DefaultJMSPropertiesSetter.
@@ -58,6 +64,8 @@
 	private DefaultJMSPropertiesSetter strategy;
 	private Message fromESBMessage;
 	
+	private Context context;
+	
 	@Test
 	public void setJMSProperties_negative() throws JMSException, URISyntaxException
 	{
@@ -98,6 +106,8 @@
 		assertEquals ( expire, toJMSMessage.getJMSExpiration() );
 	}
 	
+	
+	
 	@Test
 	public void setJMSProperties_with_set_properties_negative() throws JMSException, URISyntaxException
 	{
@@ -203,14 +213,24 @@
 	}
 	
 	@Before
-	public void before() throws JMSException
+	public void before() throws JMSException, NamingException
 	{
 		toJMSMessage = new TextMessageImpl();
 		toJMSMessage.setText( bodyContent );
 		fromESBMessage = MessageFactory.getInstance().getMessage();
 		strategy = new DefaultJMSPropertiesSetter();
+		
+		MockContextFactory.setAsInitial();
+		context = new InitialContext();
+		MockContextFactory.setDelegateContext( context );
 	}
 	
+	@After
+	public void after()
+	{
+		MockContextFactory.revertSetAsInitial();
+	}
+
 	/*
 	 * Just here to help Ant to find annotated test.
 	 */

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/SerializableMockQueue.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/SerializableMockQueue.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/SerializableMockQueue.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.testutils;
+
+import java.io.Serializable;
+
+import org.mockejb.jms.MockQueue;
+
+/**
+ * Simple class that extends MockQueue and implements serializable 
+ * <p/>
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public class SerializableMockQueue extends MockQueue implements Serializable
+{
+	private static final long serialVersionUID = 1L;
+
+	public SerializableMockQueue(String name)
+	{
+		super( name );
+	}
+}

Modified: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbm-queue-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbm-queue-service.xml	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbm-queue-service.xml	2008-07-14 12:52:00 UTC (rev 21023)
@@ -28,4 +28,11 @@
 
   </mbean>
 
+  <mbean code="org.jboss.jms.server.destination.QueueService"
+    name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_replyToQueue"
+    xmbean-dd="xmdesc/Queue-xmbean.xml">
+	<depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+	<depends>jboss.messaging:service=PostOffice</depends>
+  </mbean>
+
 </server>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbmq-queue-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbmq-queue-service.xml	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbmq-queue-service.xml	2008-07-14 12:52:00 UTC (rev 21023)
@@ -17,4 +17,11 @@
     <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
 	<depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
   </mbean>
+
+  <mbean code="org.jboss.mq.server.jmx.Queue"
+    name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_replyToQueue">
+    <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+	<depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+  </mbean>
+
 </server>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jboss-esb.xml	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jboss-esb.xml	2008-07-14 12:52:00 UTC (rev 21023)
@@ -41,7 +41,7 @@
             
                     <action name="printMessage" class="org.jboss.soa.esb.actions.SystemPrintln">
                       <property name="message" value="JMS Secured Quickstart message"/>
-                      <property name="printfull" value="true"/>
+                      <property name="printfull" value="false"/>
                     </action>
 					<action name="routeToReplyQueue" class="org.jboss.soa.esb.actions.routing.JMSRouter">
 						<property name="jndi-context-factory" value="org.jnp.interfaces.NamingContextFactory"/>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java	2008-07-14 10:14:06 UTC (rev 21022)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java	2008-07-14 12:52:00 UTC (rev 21023)
@@ -47,6 +47,7 @@
     private Session session;
     private Destination gatewayDestination;
     private Destination responseDestination;
+    private Destination replyToDestination;
     private String correlationId;
 
     public void setupConnection(String destination) throws JMSException, NamingException
@@ -59,6 +60,7 @@
 
     	gatewayDestination = (Destination) iniCtx.lookup("queue/quickstart_jms_router_Request_gw");
     	responseDestination = (Destination)iniCtx.lookup(destination);
+    	replyToDestination = (Destination) iniCtx.lookup("queue/quickstart_jms_router_replyToQueue");
     	session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
     	connection.start();
     	System.out.println("Connection Started");
@@ -76,6 +78,7 @@
         MessageProducer producer = session.createProducer(gatewayDestination);
         ObjectMessage objectMsg = session.createObjectMessage(msg);
         objectMsg.setJMSCorrelationID( correlationId );
+		objectMsg.setJMSReplyTo( replyToDestination );
 
         producer.send(objectMsg);
     	System.out.println("Sent message with CorrelationID : " + correlationId );
@@ -90,6 +93,7 @@
         System.out.println("Received from " + responseDestination + ":");
         System.out.println("\t[JMSMessageID : " +  jmsMsg.getJMSMessageID() + "]" );
 		System.out.println("\t[JMSCorrelelationID : " +  jmsMsg.getJMSCorrelationID() + "]" );
+		System.out.println("\t[JMSReplyto : " +  jmsMsg.getJMSReplyTo() + "]" );
 		if ( jmsMsg instanceof ObjectMessage )
 		{
     		System.out.println("\t[MessageType : ObjectMessage]");




More information about the jboss-svn-commits mailing list