You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ay...@apache.org on 2013/02/26 15:08:44 UTC

svn commit: r1450175 - /cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java

Author: ay
Date: Tue Feb 26 14:08:43 2013
New Revision: 1450175

URL: http://svn.apache.org/r1450175
Log:
fix the mock usage in HTTPConduitURLEasyMockTest

Modified:
    cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java

Modified: cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java?rev=1450175&r1=1450174&r2=1450175&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java (original)
+++ cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java Tue Feb 26 14:08:43 2013
@@ -279,11 +279,11 @@ public class HTTPConduitURLEasyMockTest 
         message.put(AuthorizationPolicy.class, authPolicy);        
     }
 
-    private void setUpOneway(Message message) {
+    private void setUpExchange(Message message, boolean oneway) {
         Exchange exchange = control.createMock(Exchange.class);
         message.setExchange(exchange);
         exchange.isOneWay();
-        EasyMock.expectLastCall().andReturn(true).anyTimes();
+        EasyMock.expectLastCall().andReturn(oneway).anyTimes();
         exchange.isSynchronous();
         EasyMock.expectLastCall().andReturn(true).anyTimes();
         exchange.isEmpty();
@@ -445,9 +445,7 @@ public class HTTPConduitURLEasyMockTest 
             EasyMock.expectLastCall();
         }
         
-        if ((style == ResponseStyle.NONE) || (style == ResponseStyle.ONEWAY_NONE)) {
-            setUpOneway(message);
-        }
+        setUpExchange(message, style == ResponseStyle.NONE || style == ResponseStyle.ONEWAY_NONE);
         
         connection.getRequestMethod();
         EasyMock.expectLastCall().andReturn(method).anyTimes();
@@ -459,7 +457,9 @@ public class HTTPConduitURLEasyMockTest 
         wrappedOS.flush();
         wrappedOS.close();
 
-        if (style != ResponseStyle.ONEWAY_NONE) {
+        if ((style == ResponseStyle.NONE && !emptyResponse) 
+            || style == ResponseStyle.BACK_CHANNEL
+            || style == ResponseStyle.BACK_CHANNEL_ERROR) {
             assertNotNull("expected in message", inMessage);
             Map<?, ?> headerMap = (Map<?, ?>) inMessage.get(Message.PROTOCOL_HEADERS);
             assertEquals("unexpected response headers", headerMap.size(), 0);
@@ -547,7 +547,7 @@ public class HTTPConduitURLEasyMockTest 
         switch (style) {
         case NONE:            
         case DECOUPLED:
-            is = EasyMock.createMock(InputStream.class);
+            is = control.createMock(InputStream.class);
             connection.getInputStream();
             EasyMock.expectLastCall().andReturn(is).anyTimes();
             connection.getContentLength();
@@ -562,7 +562,11 @@ public class HTTPConduitURLEasyMockTest 
                     EasyMock.expectLastCall().andReturn("close");
                 }
                 is.read();
-                EasyMock.expectLastCall().andReturn(emptyResponse ? -1 : (int)'<');
+                if (emptyResponse) {
+                    EasyMock.expectLastCall().andReturn(-1).anyTimes();    
+                } else {
+                    EasyMock.expectLastCall().andReturn((int)'<');
+                }
             } else {
                 EasyMock.expectLastCall().andReturn(123).anyTimes();
             }