cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r798666 - in /cxf/branches/2.1.x-fixes: ./ rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/
Date Tue, 28 Jul 2009 19:25:08 GMT
Author: dkulp
Date: Tue Jul 28 19:25:08 2009
New Revision: 798666

URL: http://svn.apache.org/viewvc?rev=798666&view=rev
Log:
Merged revisions 798655 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes

................
  r798655 | dkulp | 2009-07-28 15:03:38 -0400 (Tue, 28 Jul 2009) | 9 lines
  
  Merged revisions 798654 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r798654 | dkulp | 2009-07-28 15:01:30 -0400 (Tue, 28 Jul 2009) | 1 line
    
    [CXF-2366] Patch from Marat Bedretdinov applied
  ........
................

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java
    cxf/branches/2.1.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 28 19:25:08 2009
@@ -1,2 +1,2 @@
-/cxf/branches/2.2.x-fixes:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218,776429,776459,777189,777224,777243,777481,777505,777572,777580,780033,780184,780213,780421,780664,780800,780902,780911,781497,781841,782733,782735-782736,783099,783407,784064,784197,785293,785296,785298-785299,785301,785656,786158,786587,786589,786591-786592,786640,787272,787276,787282-787283,787285,787295,787307,787324,7873
 67,788824-788825,788827-788828,788830,789423,789429,789707,789709-789710,789712,789721,789905,789908,789910,789912,790295,790646-790647,790651,790654-790655,790659,791948,791950,791952,791955,792276,792288,792291,792992,792995,792998,794402,794404,794735,794797,794799,794803,795161-795162,796300-796301,796598,797449,797452-797453,797460,797463-797464,797521-797522,797584-797585,797645,797652,797701,797884,797886,798348-798350,798568,798574-798575,798577-798578,798586
-/cxf/trunk:782181,782728-782730,783097,783396,784059,784181,784895,785279-785282,785468,786142,786271,786395,786582-786583,786638,786647,787269,787277-787279,787290,787305,787323,787366,788060,788187,788703,788774,788820,789371,789420,789527-789529,789704-789705,789896,789898-789900,790294,790637-790644,791354,791538,791753,791947,792261-792263,792684,792975,792985,794297,794396,794728,794778-794780,794892,795160,796022-796023,796593,796780,797194,797231-797233,797442,797505,797517,797581-797582,797640,797651,797699,797882-797883,798344-798346,798533,798551,798561-798562,798570,798584
+/cxf/branches/2.2.x-fixes:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218,776429,776459,777189,777224,777243,777481,777505,777572,777580,780033,780184,780213,780421,780664,780800,780902,780911,781497,781841,782733,782735-782736,783099,783407,784064,784197,785293,785296,785298-785299,785301,785656,786158,786587,786589,786591-786592,786640,787272,787276,787282-787283,787285,787295,787307,787324,7873
 67,788824-788825,788827-788828,788830,789423,789429,789707,789709-789710,789712,789721,789905,789908,789910,789912,790295,790646-790647,790651,790654-790655,790659,791948,791950,791952,791955,792276,792288,792291,792992,792995,792998,794402,794404,794735,794797,794799,794803,795161-795162,796300-796301,796598,797449,797452-797453,797460,797463-797464,797521-797522,797584-797585,797645,797652,797701,797884,797886,798348-798350,798568,798574-798575,798577-798578,798586,798655
+/cxf/trunk:782181,782728-782730,783097,783396,784059,784181,784895,785279-785282,785468,786142,786271,786395,786582-786583,786638,786647,787269,787277-787279,787290,787305,787323,787366,788060,788187,788703,788774,788820,789371,789420,789527-789529,789704-789705,789896,789898-789900,790294,790637-790644,791354,791538,791753,791947,792261-792263,792684,792975,792985,794297,794396,794728,794778-794780,794892,795160,796022-796023,796593,796780,797194,797231-797233,797442,797505,797517,797581-797582,797640,797651,797699,797882-797883,798344-798346,798533,798551,798561-798562,798570,798584,798654

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=798666&r1=798665&r2=798666&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
Tue Jul 28 19:25:08 2009
@@ -164,13 +164,15 @@
                 String messageType = jmsConfig.getMessageType();
                 final javax.jms.Message jmsMessage;
                 Destination replyToDestination = replyTo;
-                if (exchange.isOneWay() && !jmsConfig.isEnforceSpec()) {
-                    final String contextReplyToName = 
-                        (headers != null) ? headers.getJMSReplyTo() : null;
-                    if (contextReplyToName != null) {
+                if (exchange.isOneWay() && !jmsConfig.isEnforceSpec() &&
isSetReplyTo(outMessage)) {
+                    String replyToName = (headers != null) ? headers.getJMSReplyTo() : null;

+                    if (replyToName == null && jmsConfig.getReplyDestination() !=
null) {
+                        replyToName = jmsConfig.getReplyDestination();
+                    }
+                    if (replyToName != null) {
                         replyToDestination = 
                             JMSFactory.resolveOrCreateDestination(jmsTemplate, 
-                                                                  contextReplyToName, 
+                                                                  replyToName, 
                                                                   jmsConfig.isPubSubDomain());
                     }
                 }
@@ -321,6 +323,11 @@
         this.jmsConfig = jmsConfig;
     }
 
+    protected static boolean isSetReplyTo(Message message) {         
+        Boolean ret = (Boolean)message.get(JMSConstants.JMS_SET_REPLY_TO);
+        return ret == null || (ret != null && ret.booleanValue());
+    }
+
     @Override
     protected void finalize() throws Throwable {
         if (listener != null) {

Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java?rev=798666&r1=798665&r2=798666&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java
Tue Jul 28 19:25:08 2009
@@ -55,6 +55,7 @@
     public static final String JMS_SERVER_CONFIG_ID = "jms-server";
     
     public static final String JMS_REBASED_REPLY_TO = "org.apache.cxf.jms.server.replyto";
+    public static final String JMS_SET_REPLY_TO = "org.apache.cxf.jms.client.set.replyto";
     
     
     private JMSConstants() {

Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java?rev=798666&r1=798665&r2=798666&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
Tue Jul 28 19:25:08 2009
@@ -24,6 +24,9 @@
 import java.io.InputStream;
 
 import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.Topic;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.cxf.BusFactory;
@@ -44,6 +47,10 @@
     private static final int MAX_RECEIVE_TIME = 5;
     private Message destMessage;
 
+    public JMSDestinationTest() {
+        
+    }
+    
     @BeforeClass
     public static void createAndStartBroker() throws Exception {
         startBroker(new JMSBrokerSetup("tcp://localhost:61500"));
@@ -173,14 +180,12 @@
         bus = bf.createBus("jms_test_config.xml");
         BusFactory.setDefaultBus(bus);
         destMessage = null;
-        inMessage = null;
         setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
                          "HelloWorldPubSubService", "HelloWorldPubSubPort");
         JMSConduit conduit = setupJMSConduit(true, false);
         Message outMessage = new MessageImpl();
         setupMessageHeader(outMessage);
         JMSDestination destination = setupJMSDestination(true);
-        destination.activate();
         sendoutMessage(conduit, outMessage, true);
         // wait for the message to be get from the destination
         waitForReceiveDestMessage();
@@ -194,15 +199,12 @@
 
     @Test
     public void testOneWayDestination() throws Exception {
-        destMessage = null;
-        inMessage = null;
         setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
                          "HWStaticReplyQBinMsgService", "HWStaticReplyQBinMsgPort");
         JMSConduit conduit = setupJMSConduit(true, false);
         Message outMessage = new MessageImpl();
         setupMessageHeader(outMessage);
         JMSDestination destination = setupJMSDestination(true);
-        destination.activate();
         sendoutMessage(conduit, outMessage, true);
         // wait for the message to be get from the destination
         waitForReceiveDestMessage();
@@ -214,22 +216,128 @@
         destination.shutdown();
     }
 
-    private void setupMessageHeader(Message outMessage, String correlationId) {
+    @Test
+    public void testOneWayReplyToSetUnset() throws Exception {
+        /* 1. Test that replyTo destination set in WSDL is NOT used 
+         * in spec compliant mode */
+        
+        destMessage = null;
+        setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
+                         "HWStaticReplyQBinMsgService", "HWStaticReplyQBinMsgPort");
+        JMSConduit conduit = setupJMSConduit(true, false);
+        Message outMessage = new MessageImpl();
+        setupMessageHeader(outMessage);
+        JMSDestination destination = setupJMSDestination(true);
+        sendoutMessage(conduit, outMessage, true);
+        // wait for the message to be get from the destination
+        waitForReceiveDestMessage();
+        // just verify the Destination inMessage
+        assertTrue("The destiantion should have got the message ", destMessage != null);
+        verifyReplyToNotSet(destMessage);
+        destMessage = null;
+        
+        /* 2. Test that replyTo destination set in WSDL IS used 
+         * in spec non-compliant mode */
+        
+        conduit.getJmsConfig().setEnforceSpec(false);
+        sendoutMessage(conduit, outMessage, true);
+        waitForReceiveDestMessage();
+        assertTrue("The destiantion should have got the message ", destMessage != null);
+        String exName = conduit.getJmsConfig().getReplyDestination();
+        exName = (exName.indexOf('/') != -1 && exName.indexOf('/') < exName.length())

+            ? exName.substring(exName.indexOf('/') + 1) : exName;
+        verifyReplyToSet(destMessage, Queue.class, exName);
+        destMessage = null;
+        
+        /* 3. Test that replyTo destination provided via invocation context 
+         * overrides the value set in WSDL and IS used in spec non-compliant mode */
+        
+        String contextReplyTo = conduit.getJmsConfig().getReplyDestination() + ".context";
+        exName += ".context";
+        setupMessageHeader(outMessage, "cidValue", contextReplyTo);
+        sendoutMessage(conduit, outMessage, true);
+        waitForReceiveDestMessage();
+        assertTrue("The destiantion should have got the message ", destMessage != null);
+        verifyReplyToSet(destMessage, Queue.class, exName);
+        destMessage = null;
+        
+        /* 4. Test that replyTo destination provided via invocation context 
+         * and the value set in WSDL are NOT used in spec non-compliant mode 
+         * when JMSConstants.JMS_SET_REPLY_TO == false */
+
+        setupMessageHeader(outMessage);
+        outMessage.put(JMSConstants.JMS_SET_REPLY_TO, Boolean.FALSE);
+        sendoutMessage(conduit, outMessage, true);
+        waitForReceiveDestMessage();
+        assertTrue("The destiantion should have got the message ", destMessage != null);
+        verifyReplyToNotSet(destMessage);
+        destMessage = null;
+        
+        /* 5. Test that replyTo destination set in WSDL IS used in spec non-compliant 
+         * mode when JMSConstants.JMS_SET_REPLY_TO == true */
+
+        setupMessageHeader(outMessage);
+        outMessage.put(JMSConstants.JMS_SET_REPLY_TO, Boolean.TRUE);
+        sendoutMessage(conduit, outMessage, true);
+        waitForReceiveDestMessage();
+        assertTrue("The destiantion should have got the message ", destMessage != null);
+        exName = conduit.getJmsConfig().getReplyDestination();
+        exName = (exName.indexOf('/') != -1 && exName.indexOf('/') < exName.length())

+            ? exName.substring(exName.indexOf('/') + 1) : exName;
+        verifyReplyToSet(destMessage, Queue.class, exName);
+        destMessage = null;
+        
+        conduit.close();
+        destination.shutdown();
+    }
+
+    
+    protected void verifyReplyToNotSet(Message cxfMsg) {
+        javax.jms.Message jmsMsg = 
+            javax.jms.Message.class.cast(cxfMsg.get(JMSConstants.JMS_REQUEST_MESSAGE));
+        assertNotNull("JMS Messsage must be null", jmsMsg);
+    }
+    
+    protected void verifyReplyToSet(Message cxfMsg, 
+                                    Class<? extends Destination> type, 
+                                    String name) throws Exception {
+        javax.jms.Message jmsMsg = 
+            javax.jms.Message.class.cast(cxfMsg.get(JMSConstants.JMS_REQUEST_MESSAGE));
+        assertNotNull("JMS Messsage must not be null", jmsMsg);
+        assertNotNull("JMS Messsage's replyTo must not be null", jmsMsg.getJMSReplyTo());
+        assertTrue("JMS Messsage's replyTo type must be of type " + type.getName(), 
+                   type.isAssignableFrom(jmsMsg.getJMSReplyTo().getClass()));
+        String receivedName = null; 
+        if (type == Queue.class) {
+            receivedName = ((Queue)jmsMsg.getJMSReplyTo()).getQueueName();
+        } else if (type == Topic.class) {
+            receivedName = ((Topic)jmsMsg.getJMSReplyTo()).getTopicName();
+        }
+        assertTrue("JMS Messsage's replyTo must be named " + name + " but was " + receivedName,
+                   name == receivedName || receivedName.equals(name));
+        
+    }
+    private void setupMessageHeader(Message outMessage, String correlationId, String replyTo)
{
         JMSMessageHeadersType header = new JMSMessageHeadersType();
         header.setJMSCorrelationID(correlationId);
         header.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
         header.setJMSPriority(1);
         header.setTimeToLive(1000);
+        header.setJMSReplyTo(replyTo != null ? replyTo : null);
         outMessage.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, header);
         outMessage.put(Message.ENCODING, "US-ASCII");
     }
-    
+
     private void setupMessageHeader(Message outMessage) {
-        setupMessageHeader(outMessage, "Destination test");
+        setupMessageHeader(outMessage, "Destination test", null);
+    }
+
+    private void setupMessageHeader(Message outMessage, String correlationId) {
+        setupMessageHeader(outMessage, correlationId, null);
     }
 
-    private void verifyReceivedMessage(Message inMessage) {
-        ByteArrayInputStream bis = (ByteArrayInputStream)inMessage.getContent(InputStream.class);
+    private void verifyReceivedMessage(Message message) {
+        ByteArrayInputStream bis = (ByteArrayInputStream)message.getContent(InputStream.class);
         byte bytes[] = new byte[bis.available()];
         try {
             bis.read(bytes);
@@ -241,26 +349,26 @@
         assertEquals("The response content should be equal", AbstractJMSTester.MESSAGE_CONTENT,
response);
     }
 
-    private void verifyRequestResponseHeaders(Message inMessage, Message outMessage) {
-        JMSMessageHeadersType outHeader = (JMSMessageHeadersType)outMessage
+    private void verifyRequestResponseHeaders(Message msgIn, Message msgOut) {
+        JMSMessageHeadersType outHeader = (JMSMessageHeadersType)msgOut
             .get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
-        String inEncoding = (String) inMessage.get(Message.ENCODING);
-        String outEncoding = (String) outMessage.get(Message.ENCODING);
+        String inEncoding = (String) msgIn.get(Message.ENCODING);
+        String outEncoding = (String) msgOut.get(Message.ENCODING);
         
         assertEquals("The message encoding should be equal", inEncoding, outEncoding);
 
-        JMSMessageHeadersType inHeader = (JMSMessageHeadersType)inMessage
+        JMSMessageHeadersType inHeader = (JMSMessageHeadersType)msgIn
             .get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
 
         verifyJmsHeaderEquality(outHeader, inHeader);
 
     }
 
-    private void verifyHeaders(Message inMessage, Message outMessage) {
-        JMSMessageHeadersType outHeader = (JMSMessageHeadersType)outMessage
+    private void verifyHeaders(Message msgIn, Message msgOut) {
+        JMSMessageHeadersType outHeader = (JMSMessageHeadersType)msgOut
             .get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
 
-        JMSMessageHeadersType inHeader = (JMSMessageHeadersType)inMessage
+        JMSMessageHeadersType inHeader = (JMSMessageHeadersType)msgIn
             .get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
 
         verifyJmsHeaderEquality(outHeader, inHeader);
@@ -286,14 +394,13 @@
     @Test
     public void testRoundTripDestination() throws Exception {
 
-        inMessage = null;
         setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
                          "HelloWorldService", "HelloWorldPort");
         // set up the conduit send to be true
         JMSConduit conduit = setupJMSConduit(true, false);
         final Message outMessage = new MessageImpl();
         setupMessageHeader(outMessage, null);
-        final JMSDestination destination = setupJMSDestination(true);
+        final JMSDestination destination = setupJMSDestination(false);
 
         // set up MessageObserver for handling the conduit message
         MessageObserver observer = new MessageObserver() {
@@ -342,7 +449,6 @@
 
         final String customPropertyName = "THIS_PROPERTY_WILL_NOT_BE_AUTO_COPIED";
 
-        inMessage = null;
         setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
                          "HelloWorldService", "HelloWorldPort");
         // set up the conduit send to be true
@@ -358,7 +464,7 @@
             .get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
         headers.getProperty().add(excludeProp);
 
-        final JMSDestination destination = setupJMSDestination(true);
+        final JMSDestination destination = setupJMSDestination(false);
 
         // set up MessageObserver for handling the conduit message
         MessageObserver observer = new MessageObserver() {
@@ -408,7 +514,6 @@
 
     @Test
     public void testIsMultiplexCapable() throws Exception {
-        inMessage = null;
         setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
                          "HelloWorldService", "HelloWorldPort");
         final JMSDestination destination = setupJMSDestination(true);
@@ -418,7 +523,6 @@
     
     @Test
     public void testSecurityContext() throws Exception {
-        inMessage = null;
         setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
                          "HelloWorldService", "HelloWorldPort");
         final JMSDestination destination = setupJMSDestination(true);



Mime
View raw message