From fee1c32f78c7a181bd16841a3c4f6428afafbabf Mon Sep 17 00:00:00 2001 From: jansupol <15908245+jansupol@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:25:54 +0100 Subject: [PATCH] Missing Content-Type header should be application/octet-stream optionally (#4911) Signed-off-by: jansupol --- bundles/jaxrs-ri/pom.xml | 2 +- .../jersey/server/ServerProperties.java | 43 ++++++------------- .../AbstractMethodSelectingRouter.java | 2 +- ... => OctetStreamMethodSelectingRouter.java} | 15 ++++--- .../internal/routing/RuntimeModelBuilder.java | 19 ++++---- ...ava => WildcardMethodSelectingRouter.java} | 4 +- .../model/ConsumeProduceSimpleTest.java | 30 ++++++++----- docs/src/main/docbook/appendix-properties.xml | 22 ++++++---- docs/src/main/docbook/migration.xml | 16 ------- etc/jenkins/jenkins_build.sh | 2 +- .../exception/ExceptionMappingFilterTest.java | 4 +- .../examples/httppatch/HttpPatchTest.java | 10 ++--- .../jersey/examples/jaxb/JaxbTest.java | 34 +++++---------- .../jsonp/JsonProcessingResourceTest.java | 10 ++--- .../server/async/AsyncResourceTest.java | 4 +- .../examples/sysprops/SysPropsTest.java | 11 +---- .../jersey/kryo/PersonResourceBaseTest.java | 3 +- pom.xml | 2 +- .../tests/e2e/client/ClientPathTest.java | 11 ++--- .../tests/e2e/entity/EntityTypesTest.java | 8 ++-- .../jersey/tests/e2e/entity/JsonMoxyTest.java | 11 +++-- .../jersey/tests/e2e/entity/XmlMoxyTest.java | 8 ++-- .../e2e/entity/filtering/EmptyEntityTest.java | 7 +-- .../filtering/EntityFilteringOnClassTest.java | 22 +++------- .../EntityFilteringOnPropertiesTest.java | 22 +++------- .../filtering/EntityFilteringScopesTest.java | 4 +- .../filtering/json/JsonEmptyEntityTest.java | 8 +--- .../json/JsonEntityFilteringOnClassTest.java | 17 +++----- .../JsonEntityFilteringOnPropertiesTest.java | 16 +++---- .../json/JsonEntityFilteringScopesTest.java | 5 +-- ...tractDisableMetainfServicesLookupTest.java | 4 +- .../jersey/tests/e2e/ClientTest.java | 5 +-- .../jersey2255/Jersey2255ITCase.java | 13 ++---- .../scanning/PackageNamesScannerTest.java | 4 +- .../filter/dynamic/FilterTest.java | 4 +- .../performance/filter/global/FilterTest.java | 4 +- .../performance/filter/name/FilterTest.java | 4 +- .../interceptor/dynamic/InterceptorTest.java | 4 +- .../interceptor/global/InterceptorTest.java | 4 +- .../interceptor/name/InterceptorTest.java | 4 +- .../mbw/custom/PersonEntityTest.java | 3 +- .../performance/mbw/json/JsonEntityTest.java | 5 +-- .../performance/mbw/json/JsonEntityTest.java | 5 +-- .../mbw/kryo/PersonResourceTest.java | 3 +- .../performance/mbw/text/TextEntityTest.java | 4 +- .../performance/mbw/xml/XmlEntityTest.java | 5 +-- .../performance/mbw/xml/XmlEntityTest.java | 5 +-- 47 files changed, 164 insertions(+), 288 deletions(-) rename core-server/src/main/java/org/glassfish/jersey/server/internal/routing/{MethodSelectingRouter.java => OctetStreamMethodSelectingRouter.java} (82%) rename core-server/src/main/java/org/glassfish/jersey/server/internal/routing/{MethodSelectingRouter2x.java => WildcardMethodSelectingRouter.java} (93%) diff --git a/bundles/jaxrs-ri/pom.xml b/bundles/jaxrs-ri/pom.xml index 9d4d2d1fcd..f0b647937a 100644 --- a/bundles/jaxrs-ri/pom.xml +++ b/bundles/jaxrs-ri/pom.xml @@ -314,7 +314,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + 3.2.4 package diff --git a/core-server/src/main/java/org/glassfish/jersey/server/ServerProperties.java b/core-server/src/main/java/org/glassfish/jersey/server/ServerProperties.java index 9ce94ad960..25b5e9ec86 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/ServerProperties.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/ServerProperties.java @@ -763,35 +763,20 @@ public final class ServerProperties { /** *

- * When an HTTP request does not contain a media type, the media type should default to {@code application/octet-stream}. - * In the past, Jersey used to match any {@code @Consumes} when the HTTP {@code Content-Type} header was not set. - * This property is to preserve the behaviour. Such behaviour is potentially dangerous, though. - * The default behaviour is to set the request media type to {@code application/octet-stream} when none set. - * This is a Jakarta REST requirement. - *

- *

- * This change can be can be eminent especially for HTTP resource methods which do not expect an entity, such as HTTP GET: - *

-     * {@code
-     * @Consumes(MediaType.TEXT_PLAIN)
-     * @Produces(MediaType.TEXT_PLAIN)
-     * @Path("/")
-     * public class Resource {
-     *     @GET
-     *     public String get() {
-     *         return ...
-     *     }
-     * }
-     * }
-     * 
- * The client request needs to contain the {@code Content-Type} HTTP header, for instance: - * {@code - * webTarget.request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get() - * } - *

- *

- * Set this property to true, if the empty request media type is to match any {@code @Consumes}. The default is {@code false}. - * The name of the configuration property is {@value}. + * Jakarta RESTful WebServices provides {@code @Consumes} annotation to accept only HTTP requests with compatible + * {@code Content-Type} header. However, when the header is missing a wildcard media type is used to + * match the {@code @Consumes} annotation. + *

+ *

HTTP/1.1 RFCrecommends that missing + * {@code Content-Type} header MAY default to {@code application/octet-stream}. This property makes Jersey consider the + * missing HTTP {@code Content-Type} header to be {@code application/octet-stream} rather than a wildcard + * media type. However, for a resource method without an entity argument, such as for HTTP GET, a wildcard media type + * is still considered to accept the HTTP request for the missing HTTP {@code Content-Type} header. + *

+ *

+ * Set this property to false, if the empty request media type should not to match applied {@code @Consumes} annotation + * on a resource method with an entity argument. The default is {@code true}. The name of the configuration property is + * {@value}. *

* @since 3.1.0 */ diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/AbstractMethodSelectingRouter.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/AbstractMethodSelectingRouter.java index f75ffaf352..160bb17e3d 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/AbstractMethodSelectingRouter.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/AbstractMethodSelectingRouter.java @@ -59,7 +59,7 @@ abstract class AbstractMethodSelectingRouter extends ContentTypeDeterminer implements Router { - private static final Logger LOGGER = Logger.getLogger(MethodSelectingRouter.class.getName()); + private static final Logger LOGGER = Logger.getLogger(AbstractMethodSelectingRouter.class.getName()); private static final Comparator CONSUMES_PRODUCES_ACCEPTOR_COMPARATOR = new Comparator() { diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/MethodSelectingRouter.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/OctetStreamMethodSelectingRouter.java similarity index 82% rename from core-server/src/main/java/org/glassfish/jersey/server/internal/routing/MethodSelectingRouter.java rename to core-server/src/main/java/org/glassfish/jersey/server/internal/routing/OctetStreamMethodSelectingRouter.java index 70f9218621..47b30a8f5e 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/MethodSelectingRouter.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/OctetStreamMethodSelectingRouter.java @@ -21,6 +21,7 @@ import org.glassfish.jersey.internal.routing.CombinedMediaType; import org.glassfish.jersey.message.MessageBodyWorkers; import org.glassfish.jersey.server.ContainerRequest; +import org.glassfish.jersey.server.model.ResourceMethod; /** * A single router responsible for selecting a single method from all the methods @@ -29,11 +30,8 @@ * The method selection algorithm selects the handling method based on the HTTP request * method name, requested media type as well as defined resource method media type * capabilities. - * - * @author Jakub Podlesak - * @author Marek Potociar */ -final class MethodSelectingRouter extends AbstractMethodSelectingRouter implements Router { +final class OctetStreamMethodSelectingRouter extends AbstractMethodSelectingRouter implements Router { /** * Create a new {@code MethodSelectingRouter} for all the methods on the same path. @@ -44,7 +42,7 @@ final class MethodSelectingRouter extends AbstractMethodSelectingRouter implemen * @param workers message body workers. * @param methodRoutings [method model, method methodAcceptorPair] pairs. */ - MethodSelectingRouter(MessageBodyWorkers workers, List methodRoutings) { + OctetStreamMethodSelectingRouter(MessageBodyWorkers workers, List methodRoutings) { super(workers, methodRoutings); } @@ -72,8 +70,11 @@ private ConsumesProducesAcceptor( */ boolean isConsumable(ContainerRequest requestContext) { MediaType contentType = requestContext.getMediaType(); - contentType = contentType == null ? MediaType.APPLICATION_OCTET_STREAM_TYPE : contentType; - return consumes.getMediaType().isCompatible(contentType); + if (contentType == null && methodRouting.method.getType() != ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR + && methodRouting.method.getInvocable().requiresEntity()) { + contentType = MediaType.APPLICATION_OCTET_STREAM_TYPE; + } + return contentType == null || consumes.getMediaType().isCompatible(contentType); } } } diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/RuntimeModelBuilder.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/RuntimeModelBuilder.java index ee69bf787f..10ce9034cb 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/RuntimeModelBuilder.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/RuntimeModelBuilder.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Properties; import java.util.function.Function; import jakarta.ws.rs.core.Configuration; @@ -57,7 +56,7 @@ final class RuntimeModelBuilder { // SubResourceLocator Model Builder. private final Value locatorBuilder; - private final boolean is2xMethodSelectingRouter; + private final boolean isWildcardMethodSelectingRouter; /** * Create a new instance of the runtime model builder. @@ -86,8 +85,8 @@ public RuntimeModelBuilder( this.locatorBuilder = Values.lazy((Value) () -> new RuntimeLocatorModelBuilder(config, messageBodyWorkers, valueSuppliers, resourceContext, RuntimeModelBuilder.this, modelProcessors, createServiceFunction)); - this.is2xMethodSelectingRouter = ServerProperties.getValue(config.getProperties(), - ServerProperties.EMPTY_REQUEST_MEDIA_TYPE_MATCHES_ANY_CONSUMES, false); + this.isWildcardMethodSelectingRouter = ServerProperties.getValue(config.getProperties(), + ServerProperties.EMPTY_REQUEST_MEDIA_TYPE_MATCHES_ANY_CONSUMES, true); } private Router createMethodRouter(final ResourceMethod resourceMethod) { @@ -154,9 +153,9 @@ public Router buildModel(final RuntimeResourceModel resourceModel, final boolean // resource methods if (!resource.getResourceMethods().isEmpty()) { final List methodRoutings = createResourceMethodRouters(resource, subResourceMode); - final Router methodSelectingRouter = is2xMethodSelectingRouter - ? new MethodSelectingRouter2x(messageBodyWorkers, methodRoutings) - : new MethodSelectingRouter(messageBodyWorkers, methodRoutings); + final Router methodSelectingRouter = isWildcardMethodSelectingRouter + ? new WildcardMethodSelectingRouter(messageBodyWorkers, methodRoutings) + : new OctetStreamMethodSelectingRouter(messageBodyWorkers, methodRoutings); if (subResourceMode) { currentRouterBuilder = startNextRoute(currentRouterBuilder, PathPattern.END_OF_PATH_PATTERN) .to(resourcePushingRouter) @@ -185,9 +184,9 @@ public Router buildModel(final RuntimeResourceModel resourceModel, final boolean srRoutedBuilder = startNextRoute(srRoutedBuilder, childClosedPattern) .to(uriPushingRouter) .to(childResourcePushingRouter) - .to(is2xMethodSelectingRouter - ? new MethodSelectingRouter2x(messageBodyWorkers, childMethodRoutings) - : new MethodSelectingRouter(messageBodyWorkers, childMethodRoutings)); + .to(isWildcardMethodSelectingRouter + ? new WildcardMethodSelectingRouter(messageBodyWorkers, childMethodRoutings) + : new OctetStreamMethodSelectingRouter(messageBodyWorkers, childMethodRoutings)); } // sub resource locator diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/MethodSelectingRouter2x.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/WildcardMethodSelectingRouter.java similarity index 93% rename from core-server/src/main/java/org/glassfish/jersey/server/internal/routing/MethodSelectingRouter2x.java rename to core-server/src/main/java/org/glassfish/jersey/server/internal/routing/WildcardMethodSelectingRouter.java index 3fa64a0f1b..c9f2e49456 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/MethodSelectingRouter2x.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/WildcardMethodSelectingRouter.java @@ -33,7 +33,7 @@ * @author Jakub Podlesak * @author Marek Potociar */ -final class MethodSelectingRouter2x extends AbstractMethodSelectingRouter implements Router { +final class WildcardMethodSelectingRouter extends AbstractMethodSelectingRouter implements Router { /** * Create a new {@code MethodSelectingRouter} for all the methods on the same path. @@ -44,7 +44,7 @@ final class MethodSelectingRouter2x extends AbstractMethodSelectingRouter implem * @param workers message body workers. * @param methodRoutings [method model, method methodAcceptorPair] pairs. */ - MethodSelectingRouter2x(MessageBodyWorkers workers, List methodRoutings) { + WildcardMethodSelectingRouter(MessageBodyWorkers workers, List methodRoutings) { super(workers, methodRoutings); } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceSimpleTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceSimpleTest.java index 3aff3e87cc..bd4cf3c639 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceSimpleTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceSimpleTest.java @@ -47,9 +47,9 @@ private ApplicationHandler createApplication(Class... classes) { return new ApplicationHandler(new ResourceConfig(classes)); } - private ApplicationHandler create2xApplication(Class... classes) { + private ApplicationHandler createAppOctetStreamApplication(Class... classes) { return new ApplicationHandler( - new ResourceConfig(classes).property(ServerProperties.EMPTY_REQUEST_MEDIA_TYPE_MATCHES_ANY_CONSUMES, true) + new ResourceConfig(classes).property(ServerProperties.EMPTY_REQUEST_MEDIA_TYPE_MATCHES_ANY_CONSUMES, false) ); } @@ -154,7 +154,7 @@ public void testProduceSimpleBean() throws Exception { assertEquals("XHTML", app.apply(RequestContextBuilder.from("/a/b", "GET").accept("text/xhtml").build()).get().getEntity()); - app = create2xApplication(ProduceSimpleBean.class); + app = createAppOctetStreamApplication(ProduceSimpleBean.class); assertEquals("HTML", app.apply(RequestContextBuilder.from("/a/b", "GET").accept("text/html").build()).get().getEntity()); assertEquals("XHTML", @@ -172,28 +172,38 @@ public void testConsumeProduceSimpleBean() throws Exception { app.apply(RequestContextBuilder.from("/a/b", "POST").entity("").type("text/xhtml").accept("text/xhtml").build()) .get().getEntity()); - assertEquals(415, - app.apply(RequestContextBuilder.from("/a/b", "GET").accept("text/html").build()) - .get().getStatus() + assertEquals("HTML", + app.apply(RequestContextBuilder.from("/a/b", "GET").accept("text/html").build()).get().getEntity() ); assertEquals("HTML", app.apply(RequestContextBuilder.from("/a/b", "GET").type("text/html").accept("text/html").build()) .get().getEntity() ); - assertEquals(415, - app.apply(RequestContextBuilder.from("/a/b", "GET").accept("text/xhtml").build()) - .get().getStatus() + assertEquals("XHTML", + app.apply(RequestContextBuilder.from("/a/b", "GET").accept("text/xhtml").build()).get().getEntity() ); assertEquals("XHTML", app.apply(RequestContextBuilder.from("/a/b", "GET").type("text/xhtml").accept("text/xhtml").build()) .get().getEntity() ); - app = create2xApplication(ConsumeProduceSimpleBean.class); + app = createAppOctetStreamApplication(ConsumeProduceSimpleBean.class); assertEquals("HTML", app.apply(RequestContextBuilder.from("/a/b", "GET").accept("text/html").build()).get().getEntity()); assertEquals("XHTML", app.apply(RequestContextBuilder.from("/a/b", "GET").accept("text/xhtml").build()).get().getEntity()); + + assertEquals(415, + app.apply(RequestContextBuilder.from("/a/b", "POST").entity("").accept("text/html").build()).get().getStatus()); + assertEquals(415, + app.apply(RequestContextBuilder.from("/a/b", "POST").entity("").accept("text/xhtml").build()).get().getStatus()); + + assertEquals("HTML", + app.apply(RequestContextBuilder.from("/a/b", "POST").entity("").type("text/html").accept("text/html").build()) + .get().getEntity()); + assertEquals("XHTML", + app.apply(RequestContextBuilder.from("/a/b", "POST").entity("").type("text/xhtml").accept("text/xhtml").build()) + .get().getEntity()); } @Path("/") diff --git a/docs/src/main/docbook/appendix-properties.xml b/docs/src/main/docbook/appendix-properties.xml index 501ff27d74..22cf2760a4 100644 --- a/docs/src/main/docbook/appendix-properties.xml +++ b/docs/src/main/docbook/appendix-properties.xml @@ -277,16 +277,22 @@ jersey.config.server.empty.request.media.matches.any.consumes - When an HTTP request does not contain a media type, the media type should default to - application/octet-stream. In the past, Jersey used to match any - @Consumes when the HTTP Content-Type header was not set. - This property is to preserve the behaviour. Such behaviour is potentially dangerous, though. - The default behaviour is to set the request media type to - application/octet-stream when none set. This is a Jakarta REST requirement. + Jakarta RESTful WebServices provides @Consumes annotation to accept only HTTP + requests with compatible HTTP Content-Type header. However, when the header + is missing a wildcard media type is used to match the @Consumes annotation. - Set this property to true, if the empty request media type is to match any - @Consumes. The default value is false. + HTTP/1.1 RFC recommends that missing HTTP Content-Type header MAY default to + application/octet-stream. This property makes Jersey consider the missing HTTP + Content-Type header to be application/octet-stream rather + than a wildcard media type. However, for a resource method without an entity argument, such as + for HTTP GET, a wildcard media type is still considered to accept the HTTP request for + the missing HTTP Content-Type header. + + + Set this property to false, if the empty request media type should not to match + applied @Consumes annotation on a resource method with an entity argument. The + default is true. diff --git a/docs/src/main/docbook/migration.xml b/docs/src/main/docbook/migration.xml index 0517ae48e5..9389341065 100644 --- a/docs/src/main/docbook/migration.xml +++ b/docs/src/main/docbook/migration.xml @@ -96,22 +96,6 @@ supports JDK 8. - - - Since Jersey 3.1.0 when incoming the HTTP request does not contain content type, the - application/octet-stream is considered, as required by the Jakarta REST - Specification and HTTP/1.1 RFC 2616. As a consequence, a resource method with non-wildcard - @Consumes annotation is not matched with the request without the - Content-Type HTTP header. This is typically the case of HTTP requests without an entity, - such as HTTP GET requests, where the Content-Type header is not set. - - - When using the @Consumes annotation, the Content-Type HTTP header must be set. - The previous behaviour when the missing Content-Type HTTP header matched any resource method - with @Consumes annotation, the - &jersey.server.ServerProperties.EMPTY_REQUEST_MEDIA_TYPE_MATCHES_ANY_CONSUMES; property can be set. - - &jersey.server.ServerProperties.UNWRAP_COMPLETION_STAGE_IN_WRITER_ENABLE; is by default diff --git a/etc/jenkins/jenkins_build.sh b/etc/jenkins/jenkins_build.sh index 5b3cad4957..9983a05bf8 100644 --- a/etc/jenkins/jenkins_build.sh +++ b/etc/jenkins/jenkins_build.sh @@ -2,4 +2,4 @@ export DEBUG=true -mvn -V -U -B -e -Psnapshots clean install glassfish-copyright:check -Dcopyright.quiet=false \ No newline at end of file +mvn -V -U -B -e -Pstaging clean install glassfish-copyright:check -Dcopyright.quiet=false \ No newline at end of file diff --git a/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingFilterTest.java b/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingFilterTest.java index e8c242fae5..0b641f125f 100644 --- a/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingFilterTest.java +++ b/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingFilterTest.java @@ -12,8 +12,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.client.WebTarget; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.UriBuilder; @@ -68,7 +66,7 @@ public void testWebApplicationExceptionInRequestFilter() { @Test public void testWebApplicationExceptionInResponseFilter() { WebTarget t = client().target(UriBuilder.fromUri(getBaseUri()).path(App.ROOT_PATH).path("response_exception").build()); - Response r = t.request("text/plain").header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(); + Response r = t.request("text/plain").get(); assertEquals(200, r.getStatus()); final String entity = r.readEntity(String.class); System.out.println("entity = " + entity); diff --git a/examples/http-patch/src/test/java/org/glassfish/jersey/examples/httppatch/HttpPatchTest.java b/examples/http-patch/src/test/java/org/glassfish/jersey/examples/httppatch/HttpPatchTest.java index a3395ce5ee..fa8d4d8768 100644 --- a/examples/http-patch/src/test/java/org/glassfish/jersey/examples/httppatch/HttpPatchTest.java +++ b/examples/http-patch/src/test/java/org/glassfish/jersey/examples/httppatch/HttpPatchTest.java @@ -12,7 +12,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.client.WebTarget; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.json.Json; @@ -63,8 +62,7 @@ public void testPatch() { // initial precondition check final State expected = new State(); - assertEquals(expected, target.request(MediaType.APPLICATION_JSON) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(State.class)); + assertEquals(expected, target.request(MediaType.APPLICATION_JSON).get(State.class)); // apply first patch expected.setMessage("patchedMessage"); @@ -96,8 +94,7 @@ public void testPatch() { assertEquals(expected, target.request() .method("PATCH", Entity.entity(patch_1, MediaType.APPLICATION_JSON_PATCH_JSON), State.class)); - assertEquals(expected, target.request(MediaType.APPLICATION_JSON) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(State.class)); + assertEquals(expected, target.request(MediaType.APPLICATION_JSON).get(State.class)); // apply second patch expected.getList().add("three"); @@ -112,7 +109,6 @@ public void testPatch() { assertEquals(expected, target.request() .method("PATCH", Entity.entity(patch_2, MediaType.APPLICATION_JSON_PATCH_JSON), State.class)); - assertEquals(expected, target.request("application/json") - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(State.class)); + assertEquals(expected, target.request("application/json").get(State.class)); } } diff --git a/examples/jaxb/src/test/java/org/glassfish/jersey/examples/jaxb/JaxbTest.java b/examples/jaxb/src/test/java/org/glassfish/jersey/examples/jaxb/JaxbTest.java index 6c22e21612..17109c6f92 100644 --- a/examples/jaxb/src/test/java/org/glassfish/jersey/examples/jaxb/JaxbTest.java +++ b/examples/jaxb/src/test/java/org/glassfish/jersey/examples/jaxb/JaxbTest.java @@ -16,7 +16,6 @@ import jakarta.ws.rs.core.GenericType; import static jakarta.ws.rs.client.Entity.xml; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.xml.bind.JAXBElement; import javax.xml.namespace.QName; @@ -57,8 +56,7 @@ public void testApplicationWadl() { @Test public void testRootElement() { - JaxbXmlRootElement e1 = target().path("jaxb/XmlRootElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(JaxbXmlRootElement.class); + JaxbXmlRootElement e1 = target().path("jaxb/XmlRootElement").request().get(JaxbXmlRootElement.class); JaxbXmlRootElement e2 = target().path("jaxb/XmlRootElement").request("application/xml") .post(xml(e1), JaxbXmlRootElement.class); @@ -68,11 +66,9 @@ public void testRootElement() { @Test public void testRootElementWithHeader() { - String e1 = target().path("jaxb/XmlRootElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(String.class); + String e1 = target().path("jaxb/XmlRootElement").request().get(String.class); - String e2 = target().path("jaxb/XmlRootElementWithHeader").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(String.class); + String e2 = target().path("jaxb/XmlRootElementWithHeader").request().get(String.class); assertTrue(e2.contains("") && e2.contains(e1.substring(e1.indexOf("?>") + 2).trim())); } @@ -80,8 +76,7 @@ public void testRootElementWithHeader() { public void testJAXBElement() { GenericType> genericType = new GenericType>() {}; - JAXBElement e1 = target().path("jaxb/JAXBElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(genericType); + JAXBElement e1 = target().path("jaxb/JAXBElement").request().get(genericType); JAXBElement e2 = target().path("jaxb/JAXBElement").request(MediaType.APPLICATION_XML) .post(xml(e1), genericType); @@ -91,8 +86,7 @@ public void testJAXBElement() { @Test public void testXmlType() { - JaxbXmlType t1 = target().path("jaxb/JAXBElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(JaxbXmlType.class); + JaxbXmlType t1 = target().path("jaxb/JAXBElement").request().get(JaxbXmlType.class); JAXBElement e = new JAXBElement( new QName("jaxbXmlRootElement"), @@ -110,8 +104,7 @@ public void testRootElementCollection() { GenericType> genericType = new GenericType>() {}; - Collection ce1 = target().path("jaxb/collection/XmlRootElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(genericType); + Collection ce1 = target().path("jaxb/collection/XmlRootElement").request().get(genericType); Collection ce2 = target().path("jaxb/collection/XmlRootElement").request(MediaType.APPLICATION_XML) .post(xml(new GenericEntity>(ce1) {}), genericType); @@ -126,22 +119,19 @@ public void testXmlTypeCollection() { new GenericType>() { }; - Collection ce1 = target().path("jaxb/collection/XmlRootElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(genericRootElement); + Collection ce1 = target().path("jaxb/collection/XmlRootElement").request().get(genericRootElement); Collection ct1 = target().path("jaxb/collection/XmlType").request(MediaType.APPLICATION_XML) .post(xml(new GenericEntity>(ce1) {}), genericXmlType); - Collection ct2 = target().path("jaxb/collection/XmlRootElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(genericXmlType); + Collection ct2 = target().path("jaxb/collection/XmlRootElement").request().get(genericXmlType); assertEquals(ct1, ct2); } @Test public void testRootElementArray() { - JaxbXmlRootElement[] ae1 = target().path("jaxb/array/XmlRootElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(JaxbXmlRootElement[].class); + JaxbXmlRootElement[] ae1 = target().path("jaxb/array/XmlRootElement").request().get(JaxbXmlRootElement[].class); JaxbXmlRootElement[] ae2 = target().path("jaxb/array/XmlRootElement").request(MediaType.APPLICATION_XML) .post(xml(ae1), JaxbXmlRootElement[].class); @@ -153,14 +143,12 @@ public void testRootElementArray() { @Test public void testXmlTypeArray() { - JaxbXmlRootElement[] ae1 = target().path("jaxb/array/XmlRootElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(JaxbXmlRootElement[].class); + JaxbXmlRootElement[] ae1 = target().path("jaxb/array/XmlRootElement").request().get(JaxbXmlRootElement[].class); JaxbXmlType[] at1 = target().path("jaxb/array/XmlType").request(MediaType.APPLICATION_XML) .post(xml(ae1), JaxbXmlType[].class); - JaxbXmlType[] at2 = target().path("jaxb/array/XmlRootElement").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(JaxbXmlType[].class); + JaxbXmlType[] at2 = target().path("jaxb/array/XmlRootElement").request().get(JaxbXmlType[].class); assertEquals(at1.length, at2.length); for (int i = 0; i < at1.length; i++) { diff --git a/examples/json-processing-webapp/src/test/java/org/glassfish/jersey/examples/jsonp/JsonProcessingResourceTest.java b/examples/json-processing-webapp/src/test/java/org/glassfish/jersey/examples/jsonp/JsonProcessingResourceTest.java index 885ca4486b..ef21a7bf50 100644 --- a/examples/json-processing-webapp/src/test/java/org/glassfish/jersey/examples/jsonp/JsonProcessingResourceTest.java +++ b/examples/json-processing-webapp/src/test/java/org/glassfish/jersey/examples/jsonp/JsonProcessingResourceTest.java @@ -20,7 +20,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.client.WebTarget; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.UriBuilder; @@ -87,18 +86,15 @@ public void testStoreGetRemoveDocument() throws Exception { // Get. final String id = ids.get(0).toString(); final WebTarget documentTarget = target("document").path(id); - final JsonObject storedDocument = documentTarget.request(MediaType.APPLICATION_JSON) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(JsonObject.class); + final JsonObject storedDocument = documentTarget.request(MediaType.APPLICATION_JSON).get(JsonObject.class); assertEquals(document, storedDocument); // Remove. - final JsonObject removedDocument = documentTarget.request(MediaType.APPLICATION_JSON) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).delete(JsonObject.class); + final JsonObject removedDocument = documentTarget.request(MediaType.APPLICATION_JSON).delete(JsonObject.class); assertEquals(document, removedDocument); // Get. - final Response errorResponse = documentTarget.request(MediaType.APPLICATION_JSON) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(); + final Response errorResponse = documentTarget.request(MediaType.APPLICATION_JSON).get(); assertEquals(204, errorResponse.getStatus()); } diff --git a/examples/server-async/src/test/java/org/glassfish/jersey/examples/server/async/AsyncResourceTest.java b/examples/server-async/src/test/java/org/glassfish/jersey/examples/server/async/AsyncResourceTest.java index 1abe7bba2f..319cdd9db9 100644 --- a/examples/server-async/src/test/java/org/glassfish/jersey/examples/server/async/AsyncResourceTest.java +++ b/examples/server-async/src/test/java/org/glassfish/jersey/examples/server/async/AsyncResourceTest.java @@ -28,8 +28,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.client.WebTarget; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder; import org.glassfish.jersey.process.JerseyProcessingUncaughtExceptionHandler; import org.glassfish.jersey.server.ResourceConfig; @@ -148,7 +146,7 @@ private void get() { attemptCounter++; try { final String response = resourceTarget.queryParam("id", requestId).request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + .get(String.class); getResponses.put(requestId, response); break; } catch (Throwable t) { diff --git a/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java b/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java index 7c724d2f5e..aa72d530fe 100644 --- a/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java +++ b/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java @@ -10,14 +10,8 @@ package org.glassfish.jersey.examples.sysprops; -import java.util.Collections; import java.util.Set; -import jakarta.ws.rs.core.Form; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.MultivaluedHashMap; -import jakarta.ws.rs.core.MultivaluedMap; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.proxy.WebResourceFactory; import org.glassfish.jersey.server.ResourceConfig; @@ -46,11 +40,8 @@ protected void configureClient(ClientConfig config) { @Test public void testGetPropertyNames() { - MultivaluedMap headers = new MultivaluedHashMap<>(); - headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); + PropertyNamesResource propertyNamesResource = WebResourceFactory.newResource(PropertyNamesResource.class, target()); - PropertyNamesResource propertyNamesResource = WebResourceFactory - .newResource(PropertyNamesResource.class, target(), false, headers, Collections.emptyList(), new Form()); Set propertyNames = propertyNamesResource.getPropertyNames(); assertEquals(System.getProperties().stringPropertyNames(), propertyNames); } diff --git a/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceBaseTest.java b/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceBaseTest.java index 529d00f91a..860aeb2365 100644 --- a/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceBaseTest.java +++ b/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceBaseTest.java @@ -16,7 +16,6 @@ package org.glassfish.jersey.kryo; -import jakarta.ws.rs.core.HttpHeaders; import org.glassfish.jersey.test.JerseyTest; import org.junit.Test; @@ -29,7 +28,7 @@ public abstract class PersonResourceBaseTest extends JerseyTest { @Test public void testGet() { - final Person getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, "application/x-kryo").get(Person.class); + final Person getResponse = target().request().get(Person.class); assertEquals("Wolfgang", getResponse.name); assertEquals(21, getResponse.age); assertEquals("Salzburg", getResponse.address); diff --git a/pom.xml b/pom.xml index 5cdf83132f..d74e17d32f 100644 --- a/pom.xml +++ b/pom.xml @@ -2146,7 +2146,7 @@ 3.0.1 3.0.2 3.0 - 3.1-SNAPSHOT + 3.1.0 11.0.0 11.0.0 6.1.14 diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPathTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPathTest.java index 6ea796c52a..c2b9c9b567 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPathTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPathTest.java @@ -23,7 +23,6 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.client.Client; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; @@ -55,7 +54,6 @@ public void pathParamInTargetTest() { Response response = client().target("http://localhost:" + getPort() + "/test/{beginBy}") .resolveTemplate("beginBy", "abc") .request(MediaType.TEXT_PLAIN_TYPE) - .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE) .get(); assertEquals(200, response.getStatus()); assertEquals("test-get,abc", response.readEntity(String.class)); @@ -68,7 +66,6 @@ public void pathParamInTargetTest() { public void pathConcatenationTest1() { Response response = client().target("http://localhost:" + getPort()).path("path") .request(MediaType.TEXT_PLAIN_TYPE) - .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE) .get(); assertEquals(200, response.getStatus()); assertEquals("test-path", response.readEntity(String.class)); @@ -80,7 +77,7 @@ public void pathConcatenationTest1() { @Test public void pathConcatenationTest2() { Response response = client().target("http://localhost:" + getPort()).path("/path").request(MediaType.TEXT_PLAIN_TYPE) - .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE).get(); + .get(); assertEquals(200, response.getStatus()); assertEquals("test-path", response.readEntity(String.class)); } @@ -91,7 +88,7 @@ public void pathConcatenationTest2() { @Test public void pathConcatenationTest3() { Response response = client().target("http://localhost:" + getPort()).path("/path/").path("/another/") - .request(MediaType.TEXT_PLAIN_TYPE).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE).get(); + .request(MediaType.TEXT_PLAIN_TYPE).get(); assertEquals(200, response.getStatus()); assertEquals("test-another-path", response.readEntity(String.class)); } @@ -102,7 +99,7 @@ public void pathConcatenationTest3() { @Test public void pathConcatenationTest4() { Response response = client().target("http://localhost:" + getPort()).path("/path").path("another/") - .request(MediaType.TEXT_PLAIN_TYPE).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE).get(); + .request(MediaType.TEXT_PLAIN_TYPE).get(); assertEquals(200, response.getStatus()); assertEquals("test-another-path", response.readEntity(String.class)); } @@ -113,7 +110,7 @@ public void pathConcatenationTest4() { @Test public void pathConcatenationTest6() { Response response = client().target("http://localhost:" + getPort() + "/").path("/path/another") - .request(MediaType.TEXT_PLAIN_TYPE).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE).get(); + .request(MediaType.TEXT_PLAIN_TYPE).get(); assertEquals(200, response.getStatus()); assertEquals("test-another-path", response.readEntity(String.class)); } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EntityTypesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EntityTypesTest.java index 4915aa3244..875bbc2f0f 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EntityTypesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EntityTypesTest.java @@ -886,7 +886,7 @@ public JaxbBean[] postType(final JaxbBeanType[] l) { public void testJAXBArrayRepresentation() { final WebTarget target = target("JAXBArrayResource"); - final JaxbBean[] a = target.request().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(JaxbBean[].class); + final JaxbBean[] a = target.request().get(JaxbBean[].class); JaxbBean[] b = target.request().post(Entity.entity(a, "application/xml"), JaxbBean[].class); assertEquals(a.length, b.length); for (int i = 0; i < a.length; i++) { @@ -910,7 +910,7 @@ public static class JAXBListResourceMediaType extends JAXBListResource { public void testJAXBListRepresentationMediaType() { final WebTarget target = target("JAXBListResourceMediaType"); - Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, "application/foo+xml").get( + Collection a = target.request().get( new GenericType>() { }); Collection b = target.request() @@ -1049,7 +1049,7 @@ public static class JAXBListResourceJSON extends JAXBListResource { public void testJAXBListRepresentationJSON() throws Exception { final WebTarget target = target("JAXBListResourceJSON"); - Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get( + Collection a = target.request().get( new GenericType>() { }); Collection b = target.request().post(Entity.entity(new GenericEntity>(a) { @@ -1121,7 +1121,7 @@ public static class JAXBListResourceJSONMediaType extends JAXBListResource { public void testJAXBListRepresentationJSONMediaType() throws Exception { final WebTarget target = target("JAXBListResourceJSONMediaType"); - final Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, "application/foo+json").get( + final Collection a = target.request().get( new GenericType>() { }); Collection b = target.request().post(Entity.entity(new GenericEntity>(a) { diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JsonMoxyTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JsonMoxyTest.java index 75c998afda..491afddd99 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JsonMoxyTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JsonMoxyTest.java @@ -38,7 +38,6 @@ import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.GenericEntity; import jakarta.ws.rs.core.GenericType; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.ext.ContextResolver; @@ -340,7 +339,7 @@ public static class JAXBListResourceJSON extends JAXBListResource { public void testJAXBListRepresentationJSONCollection() throws Exception { final WebTarget target = target("JAXBListResourceJSON"); - final Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get( + final Collection a = target.request().get( new GenericType>() { }); Collection b = target.request().post(Entity.entity(new GenericEntity>(a) { @@ -359,7 +358,7 @@ public void testJAXBListRepresentationJSONCollection() throws Exception { public void testJAXBListRepresentationJSONLinkedList() throws Exception { final WebTarget target = target("JAXBListResourceJSON"); - Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get( + Collection a = target.request().get( new GenericType>() { }); final Collection b; @@ -375,7 +374,7 @@ public void testJAXBListRepresentationJSONLinkedList() throws Exception { public void testJAXBListRepresentationJSONSet() throws Exception { final WebTarget target = target("JAXBListResourceJSON"); - Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get( + Collection a = target.request().get( new GenericType>() { }); final Collection b; @@ -401,7 +400,7 @@ public int compare(final JaxbBean t, final JaxbBean t1) { public void testJAXBListRepresentationJSONStack() throws Exception { final WebTarget target = target("JAXBListResourceJSON"); - final Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get( + final Collection a = target.request().get( new GenericType>() { }); final Collection b; @@ -439,7 +438,7 @@ public static class JAXBListResourceJSONMediaType extends JAXBListResource { public void testJAXBListRepresentationJSONMediaType() throws Exception { final WebTarget target = target("JAXBListResourceJSONMediaType"); - final Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, "application/foo+json").get( + final Collection a = target.request().get( new GenericType>() { }); Collection b = target.request().post(Entity.entity(new GenericEntity>(a) { diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlMoxyTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlMoxyTest.java index f5cac7bca5..de5b32e707 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlMoxyTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlMoxyTest.java @@ -38,7 +38,6 @@ import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.GenericEntity; import jakarta.ws.rs.core.GenericType; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.ext.ContextResolver; @@ -397,7 +396,7 @@ public JaxbBean[] postType(final JaxbBeanType[] l) { public void testJAXBArrayRepresentation() { final WebTarget target = target("JAXBArrayResource"); - final JaxbBean[] a = target.request().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(JaxbBean[].class); + final JaxbBean[] a = target.request().get(JaxbBean[].class); JaxbBean[] b = target.request().post(Entity.entity(a, "application/xml"), JaxbBean[].class); assertEquals(a.length, b.length); for (int i = 0; i < a.length; i++) { @@ -421,7 +420,7 @@ public static class JAXBListResourceMediaType extends JAXBListResource { public void testJAXBListRepresentationMediaType() { final WebTarget target = target("JAXBListResourceMediaType"); - Collection a = target.request().header(HttpHeaders.CONTENT_TYPE, "application/foo+xml").get( + Collection a = target.request().get( new GenericType>() { }); Collection b = target.request() @@ -537,8 +536,7 @@ public ComplexJaxbBean get() { @Test public void testAdditionalClasses() throws Exception { - final ComplexJaxbBean nonJaxbBean = target("AdditionalClassesResource").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(ComplexJaxbBean.class); + final ComplexJaxbBean nonJaxbBean = target("AdditionalClassesResource").request().get(ComplexJaxbBean.class); final Object simpleBean = nonJaxbBean.getSimpleBean(); assertThat(simpleBean, notNullValue()); diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EmptyEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EmptyEntityTest.java index ae298f24c2..225d2df7ef 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EmptyEntityTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EmptyEntityTest.java @@ -22,7 +22,6 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; import org.glassfish.jersey.message.filtering.EntityFilteringFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.TestProperties; @@ -71,16 +70,14 @@ protected Application configure() { @Test public void testNonEmptyEntity() throws Exception { - final String fields = target("nonEmptyEntity").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("nonEmptyEntity").request().get(String.class); assertSameFields(fields, "value"); } @Test public void testEmptyEntity() throws Exception { - final String fields = target("emptyEntity").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("emptyEntity").request().get(String.class); assertSameFields(fields, ""); } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java index fa1e839e44..09f16e4f5d 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java @@ -24,7 +24,6 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.message.filtering.EntityFilteringFeature; @@ -116,8 +115,7 @@ public ManyFilteringsOnClassEntity getManyFilteringsEntityManyViews() { @Test public void testOneEntityFilteringOnClass() throws Exception { - final String fields = target("OneFilteringEntity").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("OneFilteringEntity").request().get(String.class); assertSameFields(fields, "field,accessor,property,subEntities.field2,subEntities.property2,subEntities.property1," + "subEntities.field1,defaultEntities.field,defaultEntities.property"); @@ -125,16 +123,14 @@ public void testOneEntityFilteringOnClass() throws Exception { @Test public void testOneEntityFilteringOnClassDefaultViewResponse() throws Exception { - final String fields = target("OneFilteringEntityDefaultViewResponse").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("OneFilteringEntityDefaultViewResponse").request().get(String.class); assertSameFields(fields, ""); } @Test public void testOneEntityFilteringOnClassDefaultView() throws Exception { - final String fields = target("OneFilteringEntityDefaultView").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("OneFilteringEntityDefaultView").request().get(String.class); assertSameFields(fields, ""); } @@ -147,8 +143,7 @@ public void testMultipleViewsOnClass() throws Exception { @Test public void testManyFilteringsEntityPrimaryView() throws Exception { - final String fields = target("ManyFilteringsEntityPrimaryView").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("ManyFilteringsEntityPrimaryView").request().get(String.class); assertSameFields(fields, "field,accessor,property,manyEntities.property1,manyEntities.field1,oneEntities.field2," + "oneEntities.property2,oneEntities.property1,oneEntities.field1,defaultEntities.field,defaultEntities" @@ -157,8 +152,7 @@ public void testManyFilteringsEntityPrimaryView() throws Exception { @Test public void testManyFilteringsEntitySecondaryView() throws Exception { - final String fields = target("ManyFilteringsEntitySecondaryView").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("ManyFilteringsEntitySecondaryView").request().get(String.class); assertSameFields(fields, "field,accessor,property,manyEntities.field2,manyEntities.property2,manyEntities.field1," + "oneEntities.property2,oneEntities.field1,defaultEntities.field,defaultEntities.property"); @@ -166,16 +160,14 @@ public void testManyFilteringsEntitySecondaryView() throws Exception { @Test public void testManyFilteringsEntityDefaultView() throws Exception { - final String fields = target("ManyFilteringsEntityDefaultView").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("ManyFilteringsEntityDefaultView").request().get(String.class); assertSameFields(fields, ""); } @Test public void testManyFilteringsEntityManyViews() throws Exception { - final String fields = target("ManyFilteringsEntityManyViews").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("ManyFilteringsEntityManyViews").request().get(String.class); assertSameFields(fields, "field,accessor,property,manyEntities.field2,manyEntities.property2,manyEntities.property1," + "manyEntities.field1,oneEntities.field2,oneEntities.property2,oneEntities.property1,oneEntities.field1," diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnPropertiesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnPropertiesTest.java index d532803247..b0abf9c8d4 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnPropertiesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnPropertiesTest.java @@ -24,7 +24,6 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.message.filtering.EntityFilteringFeature; @@ -117,8 +116,7 @@ public ManyFilteringsOnPropertiesEntity getManyFilteringsEntityManyViews() { @Test public void testOneEntityFilteringOnProperties() throws Exception { - final String fields = target("OneFilteringEntity").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("OneFilteringEntity").request().get(String.class); assertSameFields(fields, "field,accessor,property,subEntities.field2,subEntities.property2,subEntities.property1," + "subEntities.field1,defaultEntities.field,defaultEntities.property"); @@ -126,24 +124,21 @@ public void testOneEntityFilteringOnProperties() throws Exception { @Test public void testOneEntityFilteringOnPropertiesDefaultViewResponse() throws Exception { - final String fields = target("OneFilteringEntityDefaultViewResponse").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("OneFilteringEntityDefaultViewResponse").request().get(String.class); assertSameFields(fields, "field"); } @Test public void testOneEntityFilteringOnPropertiesDefaultView() throws Exception { - final String fields = target("OneFilteringEntityDefaultView").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("OneFilteringEntityDefaultView").request().get(String.class); assertSameFields(fields, "field"); } @Test public void testManyFilteringsEntityPrimaryView() throws Exception { - final String fields = target("ManyFilteringsEntityPrimaryView").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("ManyFilteringsEntityPrimaryView").request().get(String.class); assertSameFields(fields, "field,accessor,property,oneEntities.field2,oneEntities.property2,oneEntities.property1," + "oneEntities.field1,defaultEntities.field,defaultEntities.property"); @@ -151,8 +146,7 @@ public void testManyFilteringsEntityPrimaryView() throws Exception { @Test public void testManyFilteringsEntitySecondaryView() throws Exception { - final String fields = target("ManyFilteringsEntitySecondaryView").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("ManyFilteringsEntitySecondaryView").request().get(String.class); assertSameFields(fields, "field,accessor,property,manyEntities.field2,manyEntities.property2,manyEntities.field1," + "oneEntities.property2,oneEntities.field1"); @@ -160,16 +154,14 @@ public void testManyFilteringsEntitySecondaryView() throws Exception { @Test public void testManyFilteringsEntityDefaultView() throws Exception { - final String fields = target("ManyFilteringsEntityDefaultView").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("ManyFilteringsEntityDefaultView").request().get(String.class); assertSameFields(fields, "field,accessor"); } @Test public void testManyFilteringsEntityManyViews() throws Exception { - final String fields = target("ManyFilteringsEntityManyViews").request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target("ManyFilteringsEntityManyViews").request().get(String.class); assertSameFields(fields, "field,accessor,property,manyEntities.field2,manyEntities.property2,manyEntities.property1," + "manyEntities.field1,oneEntities.field2,oneEntities.property2,oneEntities.property1,oneEntities.field1," diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringScopesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringScopesTest.java index 870450bc49..8478a266db 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringScopesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringScopesTest.java @@ -22,7 +22,6 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; import org.glassfish.jersey.message.filtering.EntityFilteringFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.TestProperties; @@ -65,8 +64,7 @@ public ComplexEntity get() { */ @Test public void testEntityFilteringScopes() throws Exception { - final String fields = target().request() - .header(HttpHeaders.CONTENT_TYPE, "entity/filtering").get(String.class); + final String fields = target().request().get(String.class); assertSameFields(fields, "accessor,property,field.field,field.accessor,field.property.accessor,field.property.property"); } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEmptyEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEmptyEntityTest.java index b4f014073f..98aaa73b94 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEmptyEntityTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEmptyEntityTest.java @@ -23,8 +23,6 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Feature; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.ext.ContextResolver; import org.glassfish.jersey.jackson.JacksonFeature; @@ -97,8 +95,7 @@ public ObjectMapper getContext(final Class type) { @Test public void testNonEmptyEntity() throws Exception { - final NonEmptyEntity entity = target("nonEmptyEntity").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(NonEmptyEntity.class); + final NonEmptyEntity entity = target("nonEmptyEntity").request().get(NonEmptyEntity.class); assertThat(entity.getValue(), is("foo")); assertThat(entity.getEmptyEntity(), nullValue()); @@ -106,7 +103,6 @@ public void testNonEmptyEntity() throws Exception { @Test public void testEmptyEntity() throws Exception { - assertThat(target("emptyEntity").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(String.class), is("{}")); + assertThat(target("emptyEntity").request().get(String.class), is("{}")); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnClassTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnClassTest.java index 4c5312f23e..5c18c6c5c1 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnClassTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnClassTest.java @@ -25,8 +25,6 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Feature; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.jackson.JacksonFeature; @@ -135,8 +133,7 @@ public ManyFilteringsOnClassEntity getManyFilteringsEntityManyViews() { @Test public void testOneEntityFilteringOnClass() throws Exception { - final OneFilteringOnClassEntity entity = target("OneFilteringEntity").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(OneFilteringOnClassEntity.class); + final OneFilteringOnClassEntity entity = target("OneFilteringEntity").request().get(OneFilteringOnClassEntity.class); // OneFilteringOnClassEntity assertThat(entity.field, is(10)); @@ -169,7 +166,7 @@ public void testOneEntityFilteringOnClass() throws Exception { @Test public void testOneEntityFilteringOnClassDefaultViewResponse() throws Exception { final OneFilteringOnClassEntity entity = target("OneFilteringEntityDefaultViewResponse").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(OneFilteringOnClassEntity.class); + .get(OneFilteringOnClassEntity.class); // OneFilteringOnClassEntity assertThat(entity.field, is(0)); @@ -190,7 +187,7 @@ public void testOneEntityFilteringOnClassDefaultViewResponse() throws Exception @Test public void testOneEntityFilteringOnClassDefaultView() throws Exception { final OneFilteringOnClassEntity entity = target("OneFilteringEntityDefaultView").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(OneFilteringOnClassEntity.class); + .get(OneFilteringOnClassEntity.class); // OneFilteringOnClassEntity assertThat(entity.field, is(0)); @@ -217,7 +214,7 @@ public void testMultipleViewsOnClass() throws Exception { @Test public void testManyFilteringsEntityPrimaryView() throws Exception { final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityPrimaryView").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ManyFilteringsOnClassEntity.class); + .get(ManyFilteringsOnClassEntity.class); // ManyFilteringsOnClassEntity assertThat(entity.field, is(50)); @@ -259,7 +256,7 @@ public void testManyFilteringsEntityPrimaryView() throws Exception { @Test public void testManyFilteringsEntitySecondaryView() throws Exception { final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntitySecondaryView").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ManyFilteringsOnClassEntity.class); + .get(ManyFilteringsOnClassEntity.class); // ManyFilteringsOnClassEntity assertThat(entity.field, is(50)); @@ -301,7 +298,7 @@ public void testManyFilteringsEntitySecondaryView() throws Exception { @Test public void testManyFilteringsEntityDefaultView() throws Exception { final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityDefaultView").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ManyFilteringsOnClassEntity.class); + .get(ManyFilteringsOnClassEntity.class); // ManyFilteringsOnClassEntity assertThat(entity.field, is(0)); @@ -325,7 +322,7 @@ public void testManyFilteringsEntityDefaultView() throws Exception { @Test public void testManyFilteringsEntityManyViews() throws Exception { final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityManyViews").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ManyFilteringsOnClassEntity.class); + .get(ManyFilteringsOnClassEntity.class); // ManyFilteringsOnClassEntity assertThat(entity.field, is(50)); diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnPropertiesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnPropertiesTest.java index b4bf5537c1..979483f544 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnPropertiesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnPropertiesTest.java @@ -25,8 +25,6 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Feature; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.jackson.JacksonFeature; @@ -136,7 +134,7 @@ public ManyFilteringsOnPropertiesEntity getManyFilteringsEntityManyViews() { @Test public void testOneEntityFilteringOnProperties() throws Exception { final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntity").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(OneFilteringOnPropertiesEntity.class); + .get(OneFilteringOnPropertiesEntity.class); // OneFilteringOnPropertiesEntity assertThat(entity.field, is(80)); @@ -169,7 +167,7 @@ public void testOneEntityFilteringOnProperties() throws Exception { @Test public void testOneEntityFilteringOnPropertiesDefaultViewResponse() throws Exception { final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntityDefaultViewResponse").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(OneFilteringOnPropertiesEntity.class); + .get(OneFilteringOnPropertiesEntity.class); // OneFilteringOnPropertiesEntity assertThat(entity.field, is(80)); @@ -190,7 +188,7 @@ public void testOneEntityFilteringOnPropertiesDefaultViewResponse() throws Excep @Test public void testOneEntityFilteringOnPropertiesDefaultView() throws Exception { final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntityDefaultView").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(OneFilteringOnPropertiesEntity.class); + .get(OneFilteringOnPropertiesEntity.class); // OneFilteringOnPropertiesEntity assertThat(entity.field, is(80)); @@ -217,7 +215,7 @@ public void testMultipleViewsOnProperties() throws Exception { @Test public void testManyFilteringsEntityPrimaryView() throws Exception { final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityPrimaryView").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ManyFilteringsOnPropertiesEntity.class); + .get(ManyFilteringsOnPropertiesEntity.class); // ManyFilteringsOnPropertiesEntity assertThat(entity.field, is(90)); @@ -253,7 +251,7 @@ public void testManyFilteringsEntityPrimaryView() throws Exception { @Test public void testManyFilteringsEntitySecondaryView() throws Exception { final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntitySecondaryView").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ManyFilteringsOnPropertiesEntity.class); + .get(ManyFilteringsOnPropertiesEntity.class); // ManyFilteringsOnPropertiesEntity assertThat(entity.field, is(90)); @@ -291,7 +289,7 @@ public void testManyFilteringsEntitySecondaryView() throws Exception { @Test public void testManyFilteringsEntityDefaultView() throws Exception { final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityDefaultView").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ManyFilteringsOnPropertiesEntity.class); + .get(ManyFilteringsOnPropertiesEntity.class); // ManyFilteringsOnPropertiesEntity assertThat(entity.field, is(90)); @@ -315,7 +313,7 @@ public void testManyFilteringsEntityDefaultView() throws Exception { @Test public void testManyFilteringsEntityManyViews() throws Exception { final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityManyViews").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ManyFilteringsOnPropertiesEntity.class); + .get(ManyFilteringsOnPropertiesEntity.class); // ManyFilteringsOnPropertiesEntity assertThat(entity.field, is(90)); diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringScopesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringScopesTest.java index 459c223fe3..88e70f17ad 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringScopesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringScopesTest.java @@ -24,8 +24,6 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Feature; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.message.filtering.EntityFilteringFeature; import org.glassfish.jersey.moxy.json.MoxyJsonFeature; @@ -80,8 +78,7 @@ public ComplexEntity get() { */ @Test public void testEntityFilteringScopes() throws Exception { - final ComplexEntity entity = target().request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(ComplexEntity.class); + final ComplexEntity entity = target().request().get(ComplexEntity.class); // ComplexEntity assertThat(entity.accessorTransient, is("propertyproperty")); diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AbstractDisableMetainfServicesLookupTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AbstractDisableMetainfServicesLookupTest.java index aea8397729..687fc049b4 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AbstractDisableMetainfServicesLookupTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AbstractDisableMetainfServicesLookupTest.java @@ -33,7 +33,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.Configuration; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.core.Response; @@ -63,8 +62,7 @@ public abstract class AbstractDisableMetainfServicesLookupTest extends JerseyTes protected void testGet(int expectedGetResponseCode, int expectedPostResponseCode) throws Exception { final String name = "Jersey"; { - Response response = target("/").path(name).request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(); + Response response = target("/").path(name).request().get(); Assert.assertEquals(expectedGetResponseCode, response.getStatus()); if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ClientTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ClientTest.java index 87b9f9b3b8..ccb44fd363 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ClientTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ClientTest.java @@ -90,11 +90,10 @@ protected ResourceConfig configure() { @Test public void testAccesingHelloworldResource() { final WebTarget resource = target().path("helloworld"); - final Response r = resource.request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(); + final Response r = resource.request().get(); assertEquals(200, r.getStatus()); - final String responseMessage = resource.request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + final String responseMessage = resource.request().get(String.class); assertEquals(HelloWorldResource.MESSAGE, responseMessage); } diff --git a/tests/integration/jersey-2255/src/test/java/org/glassfish/jersey/tests/integration/jersey2255/Jersey2255ITCase.java b/tests/integration/jersey-2255/src/test/java/org/glassfish/jersey/tests/integration/jersey2255/Jersey2255ITCase.java index 533edb90d6..7763394638 100644 --- a/tests/integration/jersey-2255/src/test/java/org/glassfish/jersey/tests/integration/jersey2255/Jersey2255ITCase.java +++ b/tests/integration/jersey-2255/src/test/java/org/glassfish/jersey/tests/integration/jersey2255/Jersey2255ITCase.java @@ -17,8 +17,6 @@ package org.glassfish.jersey.tests.integration.jersey2255; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -59,8 +57,7 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc */ @Test public void testClassAGet() { - final Response response = target("A").request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(); + final Response response = target("A").request().get(); final A entity = response.readEntity(A.class); assertThat(response.getStatus(), equalTo(200)); @@ -69,8 +66,7 @@ public void testClassAGet() { @Test public void testDetailedClassAGet() { - final Response response = target("A").queryParam("detailed", true).request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(); + final Response response = target("A").queryParam("detailed", true).request().get(); final A entity = response.readEntity(A.class); assertThat(response.getStatus(), equalTo(200)); @@ -82,8 +78,7 @@ public void testDetailedClassAGet() { */ @Test public void testDetailedClassBGet() { - final Response response = target("B").queryParam("detailed", true).request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(); + final Response response = target("B").queryParam("detailed", true).request().get(); final B entity = response.readEntity(B.class); assertThat(response.getStatus(), equalTo(200)); @@ -93,7 +88,7 @@ public void testDetailedClassBGet() { @Test public void testClassBGet() { - final Response response = target("B").request().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(); + final Response response = target("B").request().get(); final B entity = response.readEntity(B.class); assertThat(response.getStatus(), equalTo(200)); diff --git a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java index 3a883b73c4..b90d72d5de 100644 --- a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java +++ b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -145,7 +145,7 @@ public void testInputStreamClosedAfterClose() throws Exception { new Verifications() {{ stream.close(); - times = 3; + minTimes = 3; }}; } diff --git a/tests/performance/test-cases/filter-dynamic/src/test/java/org/glassfish/jersey/tests/performance/filter/dynamic/FilterTest.java b/tests/performance/test-cases/filter-dynamic/src/test/java/org/glassfish/jersey/tests/performance/filter/dynamic/FilterTest.java index 498db977d7..7a1fa59443 100644 --- a/tests/performance/test-cases/filter-dynamic/src/test/java/org/glassfish/jersey/tests/performance/filter/dynamic/FilterTest.java +++ b/tests/performance/test-cases/filter-dynamic/src/test/java/org/glassfish/jersey/tests/performance/filter/dynamic/FilterTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -41,7 +39,7 @@ protected Application configure() { @Test public void testGet() { - final String getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + final String getResponse = target().request().get(String.class); assertEquals("textDYN_MATCH_OUT", getResponse); } diff --git a/tests/performance/test-cases/filter-global/src/test/java/org/glassfish/jersey/tests/performance/filter/global/FilterTest.java b/tests/performance/test-cases/filter-global/src/test/java/org/glassfish/jersey/tests/performance/filter/global/FilterTest.java index 89f859a708..ea43dc2c20 100644 --- a/tests/performance/test-cases/filter-global/src/test/java/org/glassfish/jersey/tests/performance/filter/global/FilterTest.java +++ b/tests/performance/test-cases/filter-global/src/test/java/org/glassfish/jersey/tests/performance/filter/global/FilterTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -41,7 +39,7 @@ protected Application configure() { @Test public void testGet() { - final String getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + final String getResponse = target().request().get(String.class); assertEquals("textPRE_MATCH_OUT", getResponse); } diff --git a/tests/performance/test-cases/filter-name/src/test/java/org/glassfish/jersey/tests/performance/filter/name/FilterTest.java b/tests/performance/test-cases/filter-name/src/test/java/org/glassfish/jersey/tests/performance/filter/name/FilterTest.java index 9e35b94911..669253fc72 100644 --- a/tests/performance/test-cases/filter-name/src/test/java/org/glassfish/jersey/tests/performance/filter/name/FilterTest.java +++ b/tests/performance/test-cases/filter-name/src/test/java/org/glassfish/jersey/tests/performance/filter/name/FilterTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -41,7 +39,7 @@ protected Application configure() { @Test public void testGet() { - final String getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + final String getResponse = target().request().get(String.class); assertEquals("textNAM_MATCH_OUT", getResponse); } diff --git a/tests/performance/test-cases/interceptor-dynamic/src/test/java/org/glassfish/jersey/tests/performance/interceptor/dynamic/InterceptorTest.java b/tests/performance/test-cases/interceptor-dynamic/src/test/java/org/glassfish/jersey/tests/performance/interceptor/dynamic/InterceptorTest.java index a6b5b2b224..d9bcbf9812 100644 --- a/tests/performance/test-cases/interceptor-dynamic/src/test/java/org/glassfish/jersey/tests/performance/interceptor/dynamic/InterceptorTest.java +++ b/tests/performance/test-cases/interceptor-dynamic/src/test/java/org/glassfish/jersey/tests/performance/interceptor/dynamic/InterceptorTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -41,7 +39,7 @@ protected Application configure() { @Test public void testGet() { - final String getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + final String getResponse = target().request().get(String.class); assertEquals("WRITE text", getResponse); } diff --git a/tests/performance/test-cases/interceptor-global/src/test/java/org/glassfish/jersey/tests/performance/interceptor/global/InterceptorTest.java b/tests/performance/test-cases/interceptor-global/src/test/java/org/glassfish/jersey/tests/performance/interceptor/global/InterceptorTest.java index 311aca4533..439c3f7516 100644 --- a/tests/performance/test-cases/interceptor-global/src/test/java/org/glassfish/jersey/tests/performance/interceptor/global/InterceptorTest.java +++ b/tests/performance/test-cases/interceptor-global/src/test/java/org/glassfish/jersey/tests/performance/interceptor/global/InterceptorTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -41,7 +39,7 @@ protected Application configure() { @Test public void testGet() { - final String getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + final String getResponse = target().request().get(String.class); assertEquals("WRITE text", getResponse); } diff --git a/tests/performance/test-cases/interceptor-name/src/test/java/org/glassfish/jersey/tests/performance/interceptor/name/InterceptorTest.java b/tests/performance/test-cases/interceptor-name/src/test/java/org/glassfish/jersey/tests/performance/interceptor/name/InterceptorTest.java index ce0963114c..8de5beab61 100644 --- a/tests/performance/test-cases/interceptor-name/src/test/java/org/glassfish/jersey/tests/performance/interceptor/name/InterceptorTest.java +++ b/tests/performance/test-cases/interceptor-name/src/test/java/org/glassfish/jersey/tests/performance/interceptor/name/InterceptorTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -41,7 +39,7 @@ protected Application configure() { @Test public void testGet() { - final String getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + final String getResponse = target().request().get(String.class); assertEquals("WRITE text", getResponse); } diff --git a/tests/performance/test-cases/mbw-custom-provider/src/test/java/org/glassfish/jersey/tests/performance/mbw/custom/PersonEntityTest.java b/tests/performance/test-cases/mbw-custom-provider/src/test/java/org/glassfish/jersey/tests/performance/mbw/custom/PersonEntityTest.java index a1b5066222..f6da87095a 100644 --- a/tests/performance/test-cases/mbw-custom-provider/src/test/java/org/glassfish/jersey/tests/performance/mbw/custom/PersonEntityTest.java +++ b/tests/performance/test-cases/mbw-custom-provider/src/test/java/org/glassfish/jersey/tests/performance/mbw/custom/PersonEntityTest.java @@ -18,7 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.client.ClientConfig; @@ -46,7 +45,7 @@ protected void configureClient(ClientConfig config) { @Test public void testGet() { - final Person getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, "application/person").get(Person.class); + final Person getResponse = target().request().get(Person.class); assertEquals("Mozart", getResponse.name); assertEquals(21, getResponse.age); assertEquals("Salzburg", getResponse.address); diff --git a/tests/performance/test-cases/mbw-json-jackson/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java b/tests/performance/test-cases/mbw-json-jackson/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java index 17173add5e..6ba0c4520c 100644 --- a/tests/performance/test-cases/mbw-json-jackson/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java +++ b/tests/performance/test-cases/mbw-json-jackson/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.jackson.JacksonFeature; @@ -48,8 +46,7 @@ protected void configureClient(ClientConfig config) { @Test public void testGet() { - final Person getResponse = target().request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(Person.class); + final Person getResponse = target().request().get(Person.class); assertEquals("Wolfgang", getResponse.name); assertEquals(21, getResponse.age); assertEquals("Salzburg", getResponse.address); diff --git a/tests/performance/test-cases/mbw-json-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java b/tests/performance/test-cases/mbw-json-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java index 17e755df8a..038f8e10ff 100644 --- a/tests/performance/test-cases/mbw-json-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java +++ b/tests/performance/test-cases/mbw-json-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.client.ClientConfig; @@ -48,8 +46,7 @@ protected void configureClient(ClientConfig config) { @Test public void testGet() { - final Person getResponse = target().request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).get(Person.class); + final Person getResponse = target().request().get(Person.class); assertEquals("Wolfgang", getResponse.name); assertEquals(21, getResponse.age); assertEquals("Salzburg", getResponse.address); diff --git a/tests/performance/test-cases/mbw-kryo/src/test/java/org/glassfish/jersey/tests/performance/mbw/kryo/PersonResourceTest.java b/tests/performance/test-cases/mbw-kryo/src/test/java/org/glassfish/jersey/tests/performance/mbw/kryo/PersonResourceTest.java index adbe06f200..97d22be440 100644 --- a/tests/performance/test-cases/mbw-kryo/src/test/java/org/glassfish/jersey/tests/performance/mbw/kryo/PersonResourceTest.java +++ b/tests/performance/test-cases/mbw-kryo/src/test/java/org/glassfish/jersey/tests/performance/mbw/kryo/PersonResourceTest.java @@ -18,7 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.client.ClientConfig; @@ -47,7 +46,7 @@ protected void configureClient(final ClientConfig config) { @Test public void testGet() { - final Person getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, "application/x-kryo").get(Person.class); + final Person getResponse = target().request().get(Person.class); assertEquals("Wolfgang", getResponse.name); assertEquals(21, getResponse.age); assertEquals("Salzburg", getResponse.address); diff --git a/tests/performance/test-cases/mbw-text-plain/src/test/java/org/glassfish/jersey/tests/performance/mbw/text/TextEntityTest.java b/tests/performance/test-cases/mbw-text-plain/src/test/java/org/glassfish/jersey/tests/performance/mbw/text/TextEntityTest.java index a0e4615c72..06bbb91bd5 100644 --- a/tests/performance/test-cases/mbw-text-plain/src/test/java/org/glassfish/jersey/tests/performance/mbw/text/TextEntityTest.java +++ b/tests/performance/test-cases/mbw-text-plain/src/test/java/org/glassfish/jersey/tests/performance/mbw/text/TextEntityTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -41,7 +39,7 @@ protected Application configure() { @Test public void testGet() { - final String getResponse = target().request().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get(String.class); + final String getResponse = target().request().get(String.class); assertEquals("text", getResponse); } diff --git a/tests/performance/test-cases/mbw-xml-jaxb/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java b/tests/performance/test-cases/mbw-xml-jaxb/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java index ca4bb748d4..625417b53a 100644 --- a/tests/performance/test-cases/mbw-xml-jaxb/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java +++ b/tests/performance/test-cases/mbw-xml-jaxb/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; @@ -41,8 +39,7 @@ protected Application configure() { @Test public void testGet() { - final Person getResponse = target().request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(Person.class); + final Person getResponse = target().request().get(Person.class); assertEquals("Wolfgang", getResponse.name); assertEquals(21, getResponse.age); assertEquals("Salzburg", getResponse.address); diff --git a/tests/performance/test-cases/mbw-xml-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java b/tests/performance/test-cases/mbw-xml-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java index 18b0e3c033..355cbb34f6 100644 --- a/tests/performance/test-cases/mbw-xml-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java +++ b/tests/performance/test-cases/mbw-xml-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java @@ -18,8 +18,6 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.client.ClientConfig; @@ -48,8 +46,7 @@ protected void configureClient(ClientConfig config) { @Test public void testGet() { - final Person getResponse = target().request() - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).get(Person.class); + final Person getResponse = target().request().get(Person.class); assertEquals("Wolfgang", getResponse.name); assertEquals(21, getResponse.age); assertEquals("Salzburg", getResponse.address);