cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1471322 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java
Date Wed, 24 Apr 2013 09:31:20 GMT
Author: sergeyb
Date: Wed Apr 24 09:31:20 2013
New Revision: 1471322

URL: http://svn.apache.org/r1471322
Log:
Merged revisions 1471321 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1471321 | sergeyb | 2013-04-24 10:28:09 +0100 (Wed, 24 Apr 2013) | 1 line
  
  [CXF-4983] Updating ResponseImpl.getStatusInfo to deal with status codes which have no matching
Status enums
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1471321

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

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java?rev=1471322&r1=1471321&r2=1471322&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
Wed Apr 24 09:31:20 2013
@@ -105,19 +105,19 @@ public final class ResponseImpl extends 
     }
 
     public StatusType getStatusInfo() {
-        final Response.Status responseStatus = Response.Status.fromStatusCode(status);
         return new Response.StatusType() {
 
             public Family getFamily() {
-                return responseStatus.getFamily();
+                return Response.Status.Family.familyOf(ResponseImpl.this.status);
             }
 
             public String getReasonPhrase() {
-                return responseStatus.getReasonPhrase();
+                Response.Status statusEnum = Response.Status.fromStatusCode(ResponseImpl.this.status);

+                return statusEnum != null ? statusEnum.getReasonPhrase() : "";
             }
 
             public int getStatusCode() {
-                return responseStatus.getStatusCode();
+                return ResponseImpl.this.status;
             } 
             
         };

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java?rev=1471322&r1=1471321&r2=1471322&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java
Wed Apr 24 09:31:20 2013
@@ -28,6 +28,8 @@ import javax.ws.rs.core.Link;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.NewCookie;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.Response.StatusType;
 
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 
@@ -58,6 +60,33 @@ public class ResponseImplTest extends As
     }
     
     @Test
+    public void testStatuInfoForOKStatus() {
+        StatusType si = new ResponseImpl(200, "").getStatusInfo();
+        assertNotNull(si);
+        assertEquals(200, si.getStatusCode());
+        assertEquals(Status.Family.SUCCESSFUL, si.getFamily());
+        assertEquals("OK", si.getReasonPhrase());
+    }
+    
+    @Test
+    public void testStatuInfoForClientErrorStatus() {
+        StatusType si = new ResponseImpl(400, "").getStatusInfo();
+        assertNotNull(si);
+        assertEquals(400, si.getStatusCode());
+        assertEquals(Status.Family.CLIENT_ERROR, si.getFamily());
+        assertEquals("Bad Request", si.getReasonPhrase());
+    }
+    
+    @Test
+    public void testStatuInfoForClientErrorStatus2() {
+        StatusType si = new ResponseImpl(499, "").getStatusInfo();
+        assertNotNull(si);
+        assertEquals(499, si.getStatusCode());
+        assertEquals(Status.Family.CLIENT_ERROR, si.getFamily());
+        assertEquals("", si.getReasonPhrase());
+    }
+    
+    @Test
     public void testHasEntityAfterClose() {
         Response r = new ResponseImpl(200, new ByteArrayInputStream("data".getBytes()));

         assertTrue(r.hasEntity());



Mime
View raw message