wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r1471518 - in /wink/trunk/wink-server/src: main/java/org/apache/wink/server/internal/handlers/ test/java/org/apache/wink/server/internal/activation/ test/java/org/apache/wink/server/serviceability/
Date Wed, 24 Apr 2013 16:36:40 GMT
Author: lresende
Date: Wed Apr 24 16:36:39 2013
New Revision: 1471518

URL: http://svn.apache.org/r1471518
Log:
WINK-379 - Return HttpStatus.NOT_ACCEPTABLE (406) if no methods support one of the acceptable
response entity body media types

Added:
    wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter406Test.java
      - copied, changed from r1467159, wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter500Test.java
    wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter406Test.java
      - copied, changed from r1467159, wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter500Test.java
Removed:
    wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter500Test.java
    wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter500Test.java
Modified:
    wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java
    wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/activation/ActivationDataContentHandlerTest.java

Modified: wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java
URL: http://svn.apache.org/viewvc/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java?rev=1471518&r1=1471517&r2=1471518&view=diff
==============================================================================
--- wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java
(original)
+++ wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java
Wed Apr 24 16:36:39 2013
@@ -43,6 +43,7 @@ import javax.ws.rs.ext.Providers;
 import javax.ws.rs.ext.RuntimeDelegate;
 import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
 
+import org.apache.wink.common.http.HttpStatus;
 import org.apache.wink.common.internal.MultivaluedMapImpl;
 import org.apache.wink.common.internal.i18n.Messages;
 import org.apache.wink.common.internal.runtime.RuntimeContextTLS;
@@ -232,7 +233,11 @@ public class FlushResultHandler extends 
                 logger.error(Messages.getMessage("noWriterOrDataSourceProvider", entity.getClass()
//$NON-NLS-1$
                     .getName(), responseMediaType));
             }
-            throw new WebApplicationException(500);
+            // WINK-379 - From the spec :
+            // If no methods support one of the acceptable response entity body media types
+            // an implementation MUST generate a WebApplicationException with a not acceptable
+            // response (HTTP 406 status) and no entity
+            throw new WebApplicationException(HttpStatus.NOT_ACCEPTABLE.getCode());
         }
 
         if (logger.isTraceEnabled()) {

Modified: wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/activation/ActivationDataContentHandlerTest.java
URL: http://svn.apache.org/viewvc/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/activation/ActivationDataContentHandlerTest.java?rev=1471518&r1=1471517&r2=1471518&view=diff
==============================================================================
--- wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/activation/ActivationDataContentHandlerTest.java
(original)
+++ wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/activation/ActivationDataContentHandlerTest.java
Wed Apr 24 16:36:39 2013
@@ -182,13 +182,13 @@ public class ActivationDataContentHandle
         }
     }
 
-    public void test500ForMissingWriterAndHandler() throws Exception {
+    public void test406ForMissingWriterAndHandler() throws Exception {
         System.out.println(TestResource.class.getName());
         MockHttpServletRequest mockRequest =
             MockRequestConstructor.constructMockRequest("GET",
                                                         "/root/nowriterorhandler",
                                                         "not/valid");
         MockHttpServletResponse response = invoke(mockRequest);
-        assertEquals(500, response.getStatus());
+        assertEquals(406, response.getStatus());
     }
 }

Copied: wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter406Test.java
(from r1467159, wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter500Test.java)
URL: http://svn.apache.org/viewvc/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter406Test.java?p2=wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter406Test.java&p1=wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter500Test.java&r1=1467159&r2=1471518&rev=1471518&view=diff
==============================================================================
--- wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter500Test.java
(original)
+++ wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter406Test.java
Wed Apr 24 16:36:39 2013
@@ -36,7 +36,7 @@ import org.apache.wink.test.mock.MockReq
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 
-public class DebugNoMessageBodyWriter500Test extends MockServletInvocationTest {
+public class DebugNoMessageBodyWriter406Test extends MockServletInvocationTest {
 
     @Override
     protected Class<?>[] getClasses() {
@@ -105,14 +105,14 @@ public class DebugNoMessageBodyWriter500
                                                         "noWriterForJavaType",
                                                         MediaType.WILDCARD);
         MockHttpServletResponse response = invoke(request);
-        assertEquals(500, response.getStatus());
+        assertEquals(406, response.getStatus());
         assertEquals("", response.getContentAsString());
 
         assertEquals(Level.SEVERE, records.get(21).getLevel());
         assertTrue(records
             .get(21)
             .getMessage()
-            .indexOf("The system could not find a javax.ws.rs.ext.MessageBodyWriter or a
DataSourceProvider class for the org.apache.wink.server.serviceability.DebugNoMessageBodyWriter500Test$MyObject
type and") != -1 && records
+            .indexOf("The system could not find a javax.ws.rs.ext.MessageBodyWriter or a
DataSourceProvider class for the org.apache.wink.server.serviceability.DebugNoMessageBodyWriter406Test$MyObject
type and") != -1 && records
             .get(21)
             .getMessage()
             .indexOf("mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists
in the JAX-RS application for the type and media type specified.") != -1);

Copied: wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter406Test.java
(from r1467159, wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter500Test.java)
URL: http://svn.apache.org/viewvc/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter406Test.java?p2=wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter406Test.java&p1=wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter500Test.java&r1=1467159&r2=1471518&rev=1471518&view=diff
==============================================================================
--- wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter500Test.java
(original)
+++ wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter406Test.java
Wed Apr 24 16:36:39 2013
@@ -35,7 +35,7 @@ import org.apache.wink.test.mock.MockReq
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 
-public class InfoNoMessageBodyWriter500Test extends MockServletInvocationTest {
+public class InfoNoMessageBodyWriter406Test extends MockServletInvocationTest {
 
     @Override
     protected Class<?>[] getClasses() {
@@ -92,14 +92,14 @@ public class InfoNoMessageBodyWriter500T
                                                         "noWriterForJavaType",
                                                         MediaType.WILDCARD);
         MockHttpServletResponse response = invoke(request);
-        assertEquals(500, response.getStatus());
+        assertEquals(406, response.getStatus());
         assertEquals("", response.getContentAsString());
 
         assertEquals(Level.SEVERE, records.get(5).getLevel());
         assertTrue(records
             .get(5)
             .getMessage()
-            .indexOf("The system could not find a javax.ws.rs.ext.MessageBodyWriter or a
DataSourceProvider class for the org.apache.wink.server.serviceability.InfoNoMessageBodyWriter500Test$MyObject
type and") != -1 && records
+            .indexOf("The system could not find a javax.ws.rs.ext.MessageBodyWriter or a
DataSourceProvider class for the org.apache.wink.server.serviceability.InfoNoMessageBodyWriter406Test$MyObject
type and") != -1 && records
             .get(5)
             .getMessage()
             .indexOf("Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS
application for the type and media type specified.") != -1);
@@ -115,7 +115,7 @@ public class InfoNoMessageBodyWriter500T
                                                         "noWriterForMediaType",
                                                         MediaType.WILDCARD);
         MockHttpServletResponse response = invoke(request);
-        assertEquals(500, response.getStatus());
+        assertEquals(406, response.getStatus());
         assertEquals("", response.getContentAsString());
 
         assertEquals(Level.SEVERE, records.get(5).getLevel());



Mime
View raw message