Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 6bd5179

Browse files
Michal GajdosGerrit Code Review
authored andcommitted
Merge "Added test for posting null entity with content-type."
2 parents ca78467 + 0800fdd commit 6bd5179

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentTypeTest.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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
@@ -51,6 +51,7 @@
5151
import java.net.URL;
5252
import java.util.logging.Logger;
5353

54+
import javax.ws.rs.HeaderParam;
5455
import javax.ws.rs.POST;
5556
import javax.ws.rs.Path;
5657
import javax.ws.rs.Produces;
@@ -65,6 +66,7 @@
6566
import javax.ws.rs.container.DynamicFeature;
6667
import javax.ws.rs.container.ResourceInfo;
6768
import javax.ws.rs.core.Application;
69+
import javax.ws.rs.core.Context;
6870
import javax.ws.rs.core.FeatureContext;
6971
import javax.ws.rs.core.HttpHeaders;
7072
import javax.ws.rs.core.MediaType;
@@ -75,6 +77,7 @@
7577
import javax.ws.rs.ext.ReaderInterceptorContext;
7678

7779
import org.glassfish.jersey.filter.LoggingFilter;
80+
import org.glassfish.jersey.server.ContainerRequest;
7881
import org.glassfish.jersey.server.ResourceConfig;
7982
import org.glassfish.jersey.test.JerseyTest;
8083
import 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

Comments
 (0)