cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r471102 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
Date Sat, 04 Nov 2006 02:42:36 GMT
Author: ningjiang
Date: Fri Nov  3 18:42:36 2006
New Revision: 471102

URL: http://svn.apache.org/viewvc?view=rev&rev=471102
Log:
[JIRA CXF-207] 
Applied Conrad's patch for MessageContext.HTTP_RESPONSE_CODE

Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java?view=diff&rev=471102&r1=471101&r2=471102
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
Fri Nov  3 18:42:36 2006
@@ -144,7 +144,9 @@
     
     public static void updateWebServiceContext(Exchange exchange, MessageContext ctx) {
         //get the context response code and setback to out message
-        
+        if (ctx.containsKey(MessageContext.HTTP_RESPONSE_CODE)) {
+            exchange.getOutMessage().put(Message.RESPONSE_CODE, ctx.get(MessageContext.HTTP_RESPONSE_CODE));
+        }
     }
    
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java?view=diff&rev=471102&r1=471101&r2=471102
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ContextPropertiesMappingTest.java
Fri Nov  3 18:42:36 2006
@@ -30,11 +30,14 @@
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.easymock.EasyMock;
 
 public class ContextPropertiesMappingTest extends TestCase {
     private static final String ADDRESS = "test address";
     private static final String REQUEST_METHOD = "GET";
     private static final String HEADER = "header";
+    private static final Integer RESPONSE_CODE = 401; 
+    
     private Map<String, Object> message = new HashMap<String, Object>();
     private Map<String, Object> requestContext = new HashMap<String, Object>();
     private Map<String, Object> responseContext = new HashMap<String, Object>();
@@ -45,6 +48,7 @@
         message.put(Message.ENDPOINT_ADDRESS, ADDRESS);
         message.put(Message.HTTP_REQUEST_METHOD, REQUEST_METHOD);
         message.put(Message.PROTOCOL_HEADERS, HEADER);
+        
         requestContext.clear();
         requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS + "jaxws");
         requestContext.put(MessageContext.HTTP_REQUEST_HEADERS, HEADER + "jaxws");
@@ -101,5 +105,24 @@
         
     }
     
+    public void testUpdateWebServiceContext() {
+        Exchange xchng = new ExchangeImpl();
+        Message outMsg = new MessageImpl();
+        xchng.setOutMessage(outMsg);
+        
+        responseContext.put(MessageContext.HTTP_RESPONSE_CODE, RESPONSE_CODE);
+        
+        MessageContext ctx = EasyMock.createMock(MessageContext.class);
+        ctx.containsKey(MessageContext.HTTP_RESPONSE_CODE);
+        EasyMock.expectLastCall().andReturn(true);
+        ctx.get(MessageContext.HTTP_RESPONSE_CODE);
+        EasyMock.expectLastCall().andReturn(RESPONSE_CODE);
+        EasyMock.replay(ctx);
+        
+        ContextPropertiesMapping.updateWebServiceContext(xchng, ctx);
+        Integer respCode = (Integer)outMsg.get(Message.RESPONSE_CODE);
+        assertNotNull("no response code set on out message", respCode);
+        assertEquals("incorrect response code returned", RESPONSE_CODE, respCode);
+    }
 
 }



Mime
View raw message