11/*
22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33 *
4- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
4+ * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
55 *
66 * The contents of this file are subject to the terms of either the GNU
77 * General Public License Version 2 only ("GPL") or the Common Development
5151import java .net .URL ;
5252import java .util .logging .Logger ;
5353
54+ import javax .ws .rs .HeaderParam ;
5455import javax .ws .rs .POST ;
5556import javax .ws .rs .Path ;
5657import javax .ws .rs .Produces ;
6566import javax .ws .rs .container .DynamicFeature ;
6667import javax .ws .rs .container .ResourceInfo ;
6768import javax .ws .rs .core .Application ;
69+ import javax .ws .rs .core .Context ;
6870import javax .ws .rs .core .FeatureContext ;
6971import javax .ws .rs .core .HttpHeaders ;
7072import javax .ws .rs .core .MediaType ;
7577import javax .ws .rs .ext .ReaderInterceptorContext ;
7678
7779import org .glassfish .jersey .filter .LoggingFilter ;
80+ import org .glassfish .jersey .server .ContainerRequest ;
7881import org .glassfish .jersey .server .ResourceConfig ;
7982import org .glassfish .jersey .test .JerseyTest ;
8083import org .glassfish .jersey .test .TestProperties ;
@@ -94,7 +97,7 @@ public class ContentTypeTest extends JerseyTest {
9497 public static class ContentTypeResource {
9598
9699 @ POST
97- @ Produces (value = "text/plain" )
100+ @ Produces ("text/plain" )
98101 @ SuppressWarnings ("UnusedParameters" )
99102 public void postTest (final String str ) {
100103 // Ignore to generate response 204 - NoContent.
@@ -107,6 +110,13 @@ public void postTest(final String str) {
107110 public String changeContentTypeTest (String echo ) {
108111 return echo ;
109112 }
113+
114+ @ POST
115+ @ Path ("null-content" )
116+ public String process (@ HeaderParam (HttpHeaders .CONTENT_TYPE ) String mediaType , @ Context ContainerRequest request ) {
117+ return mediaType + "-" + request .hasEntity ();
118+ }
119+
110120 }
111121
112122 @ Retention (RetentionPolicy .RUNTIME )
@@ -252,4 +262,11 @@ public void testChangeContentTypeHeader() throws Exception {
252262 assertEquals (MediaType .TEXT_PLAIN_TYPE , response .getMediaType ());
253263 }
254264
265+ @ Test
266+ public void testEmptyPostRequestWithContentType () {
267+ String response = target ().path ("ContentType/null-content" ).request ("text/plain" )
268+ .post (Entity .entity (null , "foo/bar" ), String .class );
269+
270+ assertEquals ("foo/bar-false" , response );
271+ }
255272}
0 commit comments