cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r503780 - in /incubator/cxf/trunk: rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/ systests/src/test/java/org/apache/cxf/systest/jms/
Date Mon, 05 Feb 2007 17:16:08 GMT
Author: eglynn
Date: Mon Feb  5 09:16:07 2007
New Revision: 503780

URL: http://svn.apache.org/viewvc?view=rev&rev=503780
Log:
Applying patch for CXF-393 on behalf of Gary Tully.

Modified:
    incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java
    incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
    incubator/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplTwoWayJMS.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java

Modified: incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java?view=diff&rev=503780&r1=503779&r2=503780
==============================================================================
--- incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java
(original)
+++ incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConstants.java
Mon Feb  5 09:16:07 2007
@@ -28,7 +28,8 @@
     public static final String BINARY_MESSAGE_TYPE = "binary";
 
     public static final String JMS_POOLEDSESSION = "jms.pooled.session";   
-    public static final String JMS_SERVER_HEADERS = "org.apache.cxf.jms.server.headers";
+    public static final String JMS_SERVER_REQUEST_HEADERS = "org.apache.cxf.jms.server.request.headers";
+    public static final String JMS_SERVER_RESPONSE_HEADERS = "org.apache.cxf.jms.server.response.headers";
     public static final String JMS_REQUEST_MESSAGE = "org.apache.cxf.jms.request.message";
     public static final String JMS_RESPONSE_MESSAGE = "org.apache.cxf.jms.reponse.message";
     public static final String JMS_CLIENT_REQUEST_HEADERS = "org.apache.cxf.jms.client.request.headers";

Modified: incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java?view=diff&rev=503780&r1=503779&r2=503780
==============================================================================
--- incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
Mon Feb  5 09:16:07 2007
@@ -189,9 +189,8 @@
             // get the message to be interceptor
             MessageImpl inMessage = new MessageImpl();
             inMessage.setContent(InputStream.class, new ByteArrayInputStream(bytes));
-            JMSMessageHeadersType headers = 
-                base.populateIncomingContext(message, inMessage, JMSConstants.JMS_SERVER_HEADERS);
-            inMessage.put(JMSConstants.JMS_SERVER_HEADERS, headers);
+            base.populateIncomingContext(message, inMessage, JMSConstants.JMS_SERVER_REQUEST_HEADERS);
+            inMessage.put(JMSConstants.JMS_SERVER_RESPONSE_HEADERS, new JMSMessageHeadersType());
             inMessage.put(JMSConstants.JMS_REQUEST_MESSAGE, message);
                         
             inMessage.setDestination(this);            
@@ -361,7 +360,7 @@
         private void commitOutputMessage() throws IOException {
             
             JMSMessageHeadersType headers =
-                (JMSMessageHeadersType) inMessage.get(JMSConstants.JMS_SERVER_HEADERS);
+                (JMSMessageHeadersType) inMessage.get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS);
             javax.jms.Message request = 
                 (javax.jms.Message) inMessage.get(JMSConstants.JMS_REQUEST_MESSAGE);    
         
             
@@ -433,7 +432,7 @@
 
         private void sendResponse() throws JMSException {
             JMSMessageHeadersType headers =
-                (JMSMessageHeadersType) inMessage.get(JMSConstants.JMS_SERVER_HEADERS);
+                (JMSMessageHeadersType) inMessage.get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
             javax.jms.Message request = 
                 (javax.jms.Message) inMessage.get(JMSConstants.JMS_REQUEST_MESSAGE);   
             

Modified: incubator/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java?view=diff&rev=503780&r1=503779&r2=503780
==============================================================================
--- incubator/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
(original)
+++ incubator/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
Mon Feb  5 09:16:07 2007
@@ -36,6 +36,7 @@
 import org.apache.cxf.transport.ConduitInitiator;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transports.jms.context.JMSMessageHeadersType;
+import org.apache.cxf.transports.jms.context.JMSPropertyType;
 import org.easymock.classextension.EasyMock;
 
 public class JMSDestinationTest extends AbstractJMSTester {
@@ -173,13 +174,29 @@
         assertEquals("The reponse date should be equals", reponse, "HelloWorld");
     }
     
+    private void verifyRequestResponseHeaders(Message inMessage, Message outMessage) {
+        JMSMessageHeadersType outHeader =
+            (JMSMessageHeadersType)outMessage.get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
+        
+        JMSMessageHeadersType inHeader =
+            (JMSMessageHeadersType)inMessage.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);

+               
+        verifyJmsHeaderEquality(outHeader, inHeader);
+        
+    }
+    
     private void verifyHeaders(Message inMessage, Message outMessage) {
         JMSMessageHeadersType outHeader =
             (JMSMessageHeadersType)outMessage.get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
         
         JMSMessageHeadersType inHeader =
-            (JMSMessageHeadersType)inMessage.get(JMSConstants.JMS_SERVER_HEADERS); 
+            (JMSMessageHeadersType)inMessage.get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);

                
+        verifyJmsHeaderEquality(outHeader, inHeader);
+        
+    }
+
+    private void verifyJmsHeaderEquality(JMSMessageHeadersType outHeader, JMSMessageHeadersType
inHeader) {
         assertEquals("The inMessage and outMessage JMS Header's CorrelationID should be equals",

                      outHeader.getJMSCorrelationID(), inHeader.getJMSCorrelationID());
         assertEquals("The inMessage and outMessage JMS Header's JMSPriority should be equals",

@@ -237,4 +254,71 @@
     }
     
 
+    public void testPropertyExclusion() throws Exception {
+        
+        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 
+        JMSConduit conduit = setupJMSConduit(true, false);
+        final Message outMessage = new MessageImpl();
+        setupMessageHeader(outMessage);
+        
+        JMSPropertyType excludeProp = new JMSPropertyType();
+        excludeProp.setName(customPropertyName);
+        excludeProp.setValue(customPropertyName);
+        
+        JMSMessageHeadersType headers = (JMSMessageHeadersType)
+            outMessage.get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
+        headers.getProperty().add(excludeProp);
+
+        
+        final JMSDestination destination = setupJMSDestination(true);
+        
+        //set up MessageObserver for handlering the conduit message
+        MessageObserver observer = new MessageObserver() {
+            public void onMessage(Message m) {                    
+                Exchange exchange = new ExchangeImpl();
+                exchange.setInMessage(m);
+                m.setExchange(exchange);
+                verifyReceivedMessage(m);
+                verifyHeaders(m, outMessage);
+                //setup the message for 
+                Conduit backConduit;
+                try {
+                    backConduit = destination.getBackChannel(m, null, null);            
    
+                    //wait for the message to be got from the conduit
+                    Message replyMessage = new MessageImpl();
+                    sendoutMessage(backConduit, replyMessage, true);
+                } catch (Exception e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        };
+        destination.setMessageObserver(observer);  
+        //set is oneway false for get response from destination
+        sendoutMessage(conduit, outMessage, false);        
+        //wait for the message to be got from the destination, 
+        // create the thread to handler the Destination incomming message
+               
+        waitForReceiveInMessage();
+        verifyReceivedMessage(inMessage);
+        
+        
+        verifyRequestResponseHeaders(inMessage, outMessage);
+        
+        JMSMessageHeadersType inHeader =
+            (JMSMessageHeadersType)inMessage.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
+        assertTrue("property has been excluded", inHeader.getProperty().isEmpty());
+
+        // wait for a while for the jms session recycling
+        Thread.sleep(1000);
+        destination.shutdown();
+    }
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplTwoWayJMS.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplTwoWayJMS.java?view=diff&rev=503780&r1=503779&r2=503780
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplTwoWayJMS.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplTwoWayJMS.java
Mon Feb  5 09:16:07 2007
@@ -31,6 +31,7 @@
 import org.apache.cxf.hello_world_jms.types.TestRpcLitFaultResponse;
 import org.apache.cxf.transport.jms.JMSConstants;
 import org.apache.cxf.transports.jms.context.JMSMessageHeadersType;
+import org.apache.cxf.transports.jms.context.JMSPropertyType;
 
 
 
@@ -44,9 +45,22 @@
     public String greetMe(String me) {
         MessageContext mc = wsContext.getMessageContext();
         JMSMessageHeadersType headers =
-            (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_HEADERS);
+            (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
         System.out.println("get the message headers JMSCorrelationID" + headers.getJMSCorrelationID());
         System.out.println("Reached here :" + me);
+        
+        // set reply header custom property
+        JMSPropertyType testProperty = new JMSPropertyType();
+        testProperty.setName("Test_Prop");
+        testProperty.setValue("some return value "  + me);
+        
+        System.out.println("found property in request headers at index: " 
+                           + headers.getProperty().indexOf(testProperty));
+        
+        JMSMessageHeadersType responseHeaders =
+            (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS);
+        responseHeaders.getProperty().add(testProperty);
+        
         return "Hello " + me;
     }
 

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?view=diff&rev=503780&r1=503779&r2=503780
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Mon Feb  5 09:16:07 2007
@@ -201,6 +201,8 @@
     }
     
     public void testContextPropogation() throws Exception {
+        final String testReturnPropertyName = "Test_Prop";
+        final String testIgnoredPropertyName = "Test_Prop_No_Return";
         serviceName =  new QName("http://cxf.apache.org/hello_world_jms",
                                  "HelloWorldService");
         portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
@@ -223,9 +225,12 @@
                 requestHeader.setJMSCorrelationID("JMS_SAMPLE_CORRELATION_ID");
                 requestHeader.setJMSExpiration(3600000L);
                 JMSPropertyType propType = new JMSPropertyType();
-                propType.setName("Test.Prop");
+                propType.setName(testReturnPropertyName);
                 propType.setValue("mustReturn");
                 requestHeader.getProperty().add(propType);
+                propType = new JMSPropertyType();
+                propType.setName(testIgnoredPropertyName);
+                propType.setValue("mustNotReturn");
                 requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
             } 
  
@@ -244,8 +249,10 @@
                 
                 assertTrue("CORRELATION ID should match :", 
                            "JMS_SAMPLE_CORRELATION_ID".equals(responseHdr.getJMSCorrelationID()));
-                assertTrue("response Headers must conain the app specific property set by
request context.", 
+                assertTrue("response Headers must conain the app property set in request
context.", 
                            responseHdr.getProperty() != null);
+                assertEquals("response Headers must match the app property set in request
context.",
+                             testReturnPropertyName, responseHdr.getProperty().iterator().next().getName());
             }
         } catch (UndeclaredThrowableException ex) {
             throw (Exception)ex.getCause();



Mime
View raw message