cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1501681 - in /cxf/branches/2.6.x-fixes: ./ systests/transports/src/test/java/org/apache/cxf/systest/http/ClientServerSessionTest.java systests/transports/src/test/java/org/apache/cxf/systest/http/GreeterSessionImpl.java
Date Wed, 10 Jul 2013 09:07:09 GMT
Author: ffang
Date: Wed Jul 10 09:07:09 2013
New Revision: 1501681

URL: http://svn.apache.org/r1501681
Log:
Merged revisions 1501674 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

................
  r1501674 | ffang | 2013-07-10 16:45:44 +0800 (三, 10  7 2013) | 9 lines
  
  Merged revisions 1501640 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1501640 | ffang | 2013-07-10 11:42:06 +0800 (三, 10  7 2013) | 1 line
    
    [CXF-5114]a testcase to demonstrate how to use session with Oneway invocation
  ........
................

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/ClientServerSessionTest.java
    cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/GreeterSessionImpl.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1501674
  Merged /cxf/trunk:r1501640

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

Modified: cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/ClientServerSessionTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/ClientServerSessionTest.java?rev=1501681&r1=1501680&r2=1501681&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/ClientServerSessionTest.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/ClientServerSessionTest.java
Wed Jul 10 09:07:09 2013
@@ -33,6 +33,7 @@ import org.apache.cxf.greeter_control.Gr
 import org.apache.cxf.greeter_control.GreeterService;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -84,7 +85,8 @@ public class ClientServerSessionTest ext
             assertEquals("Hello Bonjour", greeting);
             assertTrue(cookie.contains("a=a"));
             assertTrue(cookie.contains("b=b"));
-
+            
+            
             greeting = greeter.greetMe("Hello");
             cookie = "";
             if (greeting.indexOf(';') != -1) {
@@ -213,6 +215,31 @@ public class ClientServerSessionTest ext
         assertEquals("Bonjour World", greeter.sayHi());
     }
     
+    @Test    
+    public void testOnewayInvocationWithSession() throws Exception {
+
+        GreeterService service = new GreeterService();
+        assertNotNull(service);
+
+        try {
+            Greeter greeter = service.getGreeterPort();
+            
+            BindingProvider bp = (BindingProvider)greeter;
+            updateAddressPort(bp, PORT);
+            bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
+                                             
+            greeter.greetMeOneWay("Bonjour");
+            
+            String greeting = greeter.greetMe("Hello");
+            
+            assertNotNull("no response received from service", greeting);
+            assertEquals("Hello Bonjour", greeting);
+            
+        } catch (UndeclaredThrowableException ex) {
+            throw (Exception)ex.getCause();
+        }
+    }
+    
     private void doSessionsTest(String url) {
         GreeterService service = new GreeterService();
         assertNotNull(service);

Modified: cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/GreeterSessionImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/GreeterSessionImpl.java?rev=1501681&r1=1501680&r2=1501681&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/GreeterSessionImpl.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/GreeterSessionImpl.java
Wed Jul 10 09:07:09 2013
@@ -67,6 +67,7 @@ public class GreeterSessionImpl implemen
             }
         }
         
+        
         HttpSession session = req.getSession();
         // Get a session property "counter" from context
         if (session == null) {
@@ -106,9 +107,24 @@ public class GreeterSessionImpl implemen
     }
 
 
-    public void greetMeOneWay(String requestType) {
-        // TODO Auto-generated method stub
+    public void greetMeOneWay(String me) {
+        LOG.info("Executing operation greetMeOneWay");        
+        LOG.info("Message received: " + me);
+        MessageContext mc = context.getMessageContext();
+        HttpServletRequest req = (HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST);
         
+        HttpSession session = req.getSession();
+        if (session == null) {
+            throw new WebServiceException("No session in WebServiceContext");
+        }
+        String name = (String)session.getAttribute("name");
+        if (name == null) {
+            name = me;
+            LOG.info("Starting the Session");
+        } 
+        
+        session.setAttribute("name", me);
+                        
     }
 
 



Mime
View raw message