You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ni...@apache.org on 2006/11/19 09:05:49 UTC

svn commit: r476761 - in /incubator/cxf/trunk: rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplTwoWayJMS.java

Author: ningjiang
Date: Sun Nov 19 00:05:48 2006
New Revision: 476761

URL: http://svn.apache.org/viewvc?view=rev&rev=476761
Log:
Updated the context test for JMS Header setter and getter 

Modified:
    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

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=476761&r1=476760&r2=476761
==============================================================================
--- 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 Sun Nov 19 00:05:48 2006
@@ -32,6 +32,7 @@
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.ConduitInitiator;
 import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.transports.jms.context.JMSMessageHeadersType;
 import org.easymock.classextension.EasyMock;
 
 public class JMSDestinationTest extends AbstractJMSTester {
@@ -124,6 +125,7 @@
                          "HWStaticReplyQBinMsgPort");
         JMSConduit conduit = setupJMSConduit(true, false);
         Message outMessage = new MessageImpl();
+        setupMessageHeader(outMessage);
         JMSDestination destination = null;
         try {
             destination = setupJMSDestination(true);        
@@ -137,11 +139,21 @@
         waitForReceiveDestMessage();
         // just verify the Destination inMessage
         assertTrue("The destiantion should have got the message ", destMessage != null);
-        verifyDestinationReceivedMessage(destMessage);
+        verifyReceivedMessage(destMessage);
+        verifyHeaders(destMessage, outMessage);
         destination.shutdown();
     }
     
-    private void verifyDestinationReceivedMessage(Message inMessage) {
+    private void setupMessageHeader(Message outMessage) {
+        JMSMessageHeadersType header = new JMSMessageHeadersType();
+        header.setJMSCorrelationID("Destination test");        
+        header.setJMSDeliveryMode(3);
+        header.setJMSPriority(1);
+        header.setTimeToLive(1000);
+        outMessage.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, header);
+    }
+
+    private void verifyReceivedMessage(Message inMessage) {
         ByteArrayInputStream bis = 
             (ByteArrayInputStream) inMessage.getContent(InputStream.class);
         byte bytes[] = new byte[bis.available()];
@@ -153,28 +165,21 @@
         }
         String reponse = new String(bytes);
         assertEquals("The reponse date should be equals", reponse, "HelloWorld");
-        
-        //REVISIT we should check the message header in message context leavel
-        /*  
-         JMSMessageHeadersType outHeader =
+    }
+    
+    private void verifyHeaders(Message inMessage, Message outMessage) {
+        JMSMessageHeadersType outHeader =
             (JMSMessageHeadersType)outMessage.get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
         
-         JMSMessageHeadersType inHeader =
+        JMSMessageHeadersType inHeader =
             (JMSMessageHeadersType)inMessage.get(JMSConstants.JMS_SERVER_HEADERS); 
-        
-        System.out.println("outHeader" + outHeader);
-        System.out.println("inHeader" + 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 JMSExpiration should be equals", 
-                     outHeader.getJMSExpiration(), inHeader.getJMSExpiration());
-        assertEquals("The inMessage and outMessage JMS Header's JMSMessageID should be equals", 
-                     outHeader.getJMSMessageID(), inHeader.getJMSMessageID());
-        assertEquals("The inMessage and outMessage JMS Header's JMSTimeStamp should be equals", 
-                     outHeader.getJMSTimeStamp(), inHeader.getJMSTimeStamp());
+        assertEquals("The inMessage and outMessage JMS Header's JMSPriority should be equals", 
+                     outHeader.getJMSPriority(), inHeader.getJMSPriority());
         assertEquals("The inMessage and outMessage JMS Header's JMSType should be equals", 
-                     outHeader.getJMSType(), inHeader.getJMSType());*/
+                     outHeader.getJMSType(), inHeader.getJMSType());
         
     }
     
@@ -187,14 +192,15 @@
                          "HelloWorldPort");
         //set up the conduit send to be true 
         JMSConduit conduit = setupJMSConduit(true, false);
-        Message outMessage = new MessageImpl();
-        
+        final Message outMessage = new MessageImpl();
+        setupMessageHeader(outMessage);
         final JMSDestination destination = setupJMSDestination(true);
         
         //set up MessageObserver for handlering the conduit message
         MessageObserver observer = new MessageObserver() {
             public void onMessage(Message m) {                    
-                verifyDestinationReceivedMessage(m);
+                verifyReceivedMessage(m);
+                verifyHeaders(m, outMessage);
                 //setup the message for 
                 Conduit backConduit;
                 try {
@@ -215,7 +221,7 @@
         // create the thread to handler the Destination incomming message
                
         waitForReceiveInMessage();
-        verifyDestinationReceivedMessage(inMessage);
+        verifyReceivedMessage(inMessage);
         // 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=476761&r1=476760&r2=476761
==============================================================================
--- 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 Sun Nov 19 00:05:48 2006
@@ -18,7 +18,10 @@
  */
 package org.apache.cxf.systest.jms;
 
+import javax.annotation.Resource;
 import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
 
 import org.apache.cxf.hello_world_jms.BadRecordLitFault;
 import org.apache.cxf.hello_world_jms.HelloWorldPortType;
@@ -26,6 +29,8 @@
 import org.apache.cxf.hello_world_jms.types.ErrorCode;
 import org.apache.cxf.hello_world_jms.types.NoSuchCodeLit;
 import org.apache.cxf.hello_world_jms.types.TestRpcLitFaultResponse;
+import org.apache.cxf.transport.jms.JMSConstants;
+import org.apache.cxf.transports.jms.context.JMSMessageHeadersType;
 
 
 
@@ -34,13 +39,18 @@
             endpointInterface = "org.apache.cxf.hello_world_jms.HelloWorldPortType",
             targetNamespace = "http://cxf.apache.org/hello_world_jms")
 public class GreeterImplTwoWayJMS implements HelloWorldPortType {
-
+    @Resource
+    protected WebServiceContext wsContext;
     public String greetMe(String me) {
+        MessageContext mc = wsContext.getMessageContext();
+        JMSMessageHeadersType headers =
+            (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_HEADERS);
+        System.out.println("get the message headers JMSCorrelationID" + headers.getJMSCorrelationID());
         System.out.println("Reached here :" + me);
         return "Hello " + me;
     }
 
-    public String sayHi() {
+    public String sayHi() {        
         return "Bonjour";
     }