TCK Migration : Move a set of jaxrs/ee/rs/ tests from jakartaee-tck (#1031) * Initial commit to migrate jaxrs/ee/rs/container,beanparam,constrainedto,delete tests - change package names to match new folder structure * rename JAXRS Client java files to *IT before other changes * fix test setup in ee.rs..container,beanparam,constrainedto,cookieparam,delete - fix the test setup, - comment failing test ee.rs.container.requestcontext.security.getSecurityContextTest - add missing files, jar dependency, imports - use junit assertTrue
diff --git a/jaxrs-tck/pom.xml b/jaxrs-tck/pom.xml index 5119ba6..3a6400c 100644 --- a/jaxrs-tck/pom.xml +++ b/jaxrs-tck/pom.xml
@@ -159,5 +159,13 @@ <version>3.0.0</version> </dependency> + <dependency> + <groupId>jakarta.servlet</groupId> + <artifactId>jakarta.servlet-api</artifactId> + <version>5.0.0</version> + <scope>provided</scope> + </dependency> + + </dependencies> </project> \ No newline at end of file
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/common/impl/SecurityContextImpl.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/common/impl/SecurityContextImpl.java new file mode 100644 index 0000000..6b216cd --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/common/impl/SecurityContextImpl.java
@@ -0,0 +1,88 @@ +/* + * Copyright (c) 2013, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.common.impl; + +import java.security.Principal; + +import jakarta.ws.rs.core.SecurityContext; + +/** + * This is simple implementation of a SecurityContext interface There are two + * constructors, the default representing dummy SecurityContext with no + * principal, scheme and role, and a constructor with principal scheme and + * information about whether the connection is secure and whether user is in + * role + */ +public class SecurityContextImpl implements SecurityContext { + + /** + * Representation of principal, role, scheme, and secure connection + */ + public SecurityContextImpl(String principal, boolean isUserInRole, + boolean isSecure, String scheme) { + super(); + this.principal = principal; + this.isUserInRole = isUserInRole; + this.isSecure = isSecure; + this.scheme = scheme; + } + + private String principal = null; + + private boolean isUserInRole = false; + + private boolean isSecure = false; + + private String scheme = null; + + /** + * Dummy security context + */ + public SecurityContextImpl() { + } + + @Override + public Principal getUserPrincipal() { + if (principal == null) + return null; + else { + Principal p = new Principal() { + @Override + public String getName() { + return principal; + } + }; + return p; + } + } + + @Override + public boolean isUserInRole(String role) { + return isUserInRole; + } + + @Override + public boolean isSecure() { + return isSecure; + } + + @Override + public String getAuthenticationScheme() { + return scheme; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/Constants.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/Constants.java new file mode 100644 index 0000000..bad2b25 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/Constants.java
@@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +/** + * The constants to be used on server resources for + * any @PathParam, @MatrixParam, ... and any other @Param + * + * @since 2.0.1 + */ +public interface Constants { + public static final String INNER = "Inner"; + + public static final String DEFAULT_VALUE = "DefaultParamValue"; + + public static final String PARAM_ENTITY_WITH_CONSTRUCTOR = "ParamEntityWithConstructor"; + + public static final String PARAM_ENTITY_WITH_FROMSTRING = "ParamEntityWithFromString"; + + public static final String PARAM_ENTITY_WITH_VALUEOF = "ParamEntityWithValueOf"; + + public static final String SET_PARAM_ENTITY_WITH_FROMSTRING = "SetParamEntityWithFromString"; + + public static final String SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING = "SortedSetParamEntityWithFromString"; + + public static final String LIST_PARAM_ENTITY_WITH_FROMSTRING = "ListParamEntityWithFromString"; + + public static final String ENTITY_THROWING_WEBAPPLICATIONEXCEPTION = "ParamEntityThrowingWebApplicationException"; + + public static final String ENTITY_THROWING_EXCEPTION_BY_NAME = "ParamEntityThrowingExceptionGivenByName"; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/JaxrsParamClient.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/JaxrsParamClient.java new file mode 100644 index 0000000..f415e1f --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/JaxrsParamClient.java
@@ -0,0 +1,334 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +import jakarta.ws.rs.tck.common.JAXRSCommonClient; + +import jakarta.ws.rs.core.Response.Status; + +/** + * @since 2.0 + */ +public abstract class JaxrsParamClient extends JAXRSCommonClient { + + private static final long serialVersionUID = 200L; + + /** + * Currently, not for every param annotation @DefaultValue works. Where it + * works not, set useDefaultValue to false when inherit + */ + protected boolean useDefaultValue = true; + + /** + * When URI is to be encoded, equals ('=') is encoded as '%3d' This variable + * is to set which equals, the original or encoded is to be searched in + * response + */ + protected boolean searchEqualsEncoded = false; + + /** + * Behind a test, there would be the following logic. a) There is a field + * test. This is to test instance attributes, i.e. fields. b) There is a param + * test. This is to test argument attributes, i.e. method arguments. Thus, the + * argument shall be named only by an Entity name (i.e. the name of the entity + * in jaxrs.ee.rs package), the CollectionName prefix to test arguments, or + * the Field prefix to check variant a, or Field and CollectionName to check + * variant a with collections. + * + * @throws Fault + * : When test fail + */ + protected void fieldOrParamEntityName(Class<?> entityClazz, + String nonDefaultValue, String... prefix) throws Fault { + StringBuilder request = new StringBuilder(); + // add prefix + for (String p : prefix) + request.append(p); + + request.append(entityClazz.getSimpleName()); + + if (useDefaultValue) + paramEntityDefault(request.toString()); + + request.append("=").append(nonDefaultValue); + paramEntity(request.toString()); + } + + /* + * @assertion_ids: JAXRS:SPEC:5.2; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named Param is handled properly + */ + public void paramEntityWithConstructorTest() throws Fault { + fieldOrParamEntityName(ParamEntityWithConstructor.class, "JAXRS_SPEC_5.2", + ""); + } + + /* + * @assertion_ids: JAXRS:SPEC:5.3; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named Param is handled properly + */ + public void paramEntityWithValueOfTest() throws Fault { + fieldOrParamEntityName(ParamEntityWithValueOf.class, "JAXRS_SPEC_5.3", ""); + } + + /* + * @assertion_ids: JAXRS:SPEC:5.3; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named Param is handled properly + */ + public void paramEntityWithFromStringTest() throws Fault { + fieldOrParamEntityName(ParamEntityWithFromString.class, "JAXRS_SPEC_5.3", + ""); + } + + /* + * @assertion_ids: JAXRS:SPEC:5.4; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named Param is handled properly + */ + /** + * @param collection + * : Collection to use from {List,Set,SortedSet} + * @throws Fault + */ + protected void paramCollectionEntityWithFromStringTest( + CollectionName collection) throws Fault { + fieldOrParamEntityName(ParamEntityWithFromString.class, "JAXRS_SPEC_5.4", + collection.value); + } + + /* + * @assertion_ids: JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named Param is handled properly + */ + public void fieldEntityWithConstructorTest() throws Fault { + fieldOrParamEntityName(ParamEntityWithConstructor.class, "JAXRS_SPEC_5.2", + ParamTest.FIELD); + } + + /* + * @assertion_ids: JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named Param is handled properly + */ + public void fieldEntityWithValueOfTest() throws Fault { + fieldOrParamEntityName(ParamEntityWithValueOf.class, "JAXRS_SPEC_5.3", + ParamTest.FIELD); + } + + /* + * @assertion_ids: JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named Param is handled properly + */ + public void fieldEntityWithFromStringTest() throws Fault { + fieldOrParamEntityName(ParamEntityWithFromString.class, "JAXRS_SPEC_5.3", + ParamTest.FIELD); + } + + /* + * @assertion_ids: JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named Param is handled properly + */ + /** + * @param collection + * : Collection to use from {List,Set,SortedSet} + * @throws Fault + */ + protected void fieldCollectionEntityWithFromStringTest( + CollectionName collection) throws Fault { + fieldOrParamEntityName(ParamEntityWithFromString.class, "JAXRS_SPEC_5.4", + ParamTest.FIELD, collection.value); + } + + protected void fieldOrParamEncodedTest(String prefix) throws Fault { + StringBuilder request = new StringBuilder(); + request.append(prefix); + request.append(ParamEntityWithValueOf.class.getSimpleName()); + setProperty(Property.REQUEST, buildRequest(request.toString() + "=%21")); + setProperty(Property.SEARCH_STRING, request.toString() + "=!"); + invoke(); + + request = new StringBuilder(); + request.append(prefix); + request.append(ParamEntityWithFromString.class.getSimpleName()); + request.append("=%21"); + paramEntity(request.toString()); + } + + /* + * @assertion_ids: JAXRS:SPEC:12.2; + * + * @test_Strategy: Verify that named Param @Encoded is handled + */ + public void paramEntityWithEncodedTest() throws Fault { + fieldOrParamEncodedTest(""); + } + + /* + * @assertion_ids: JAXRS:SPEC:7; + * + * @test_Strategy: Verify that named Param @Encoded is handled + */ + public void fieldEntityWithEncodedTest() throws Fault { + fieldOrParamEncodedTest(ParamTest.FIELD); + } + + /* + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + protected void fieldOrParamThrowingWebApplicationExceptionTest(String prefix) + throws Fault { + StringBuilder request = new StringBuilder(); + request.append(prefix); + request.append( + ParamEntityThrowingWebApplicationException.class.getSimpleName()); + request.append("=").append(Status.CREATED.name()); + // to override + paramEntityThrowingAfterRequestSet(request.toString()); + setProperty(Property.SEARCH_STRING, + WebApplicationExceptionMapper.class.getSimpleName()); + setProperty(Property.SEARCH_STRING, Status.CREATED.name()); + buildRequestAndInvoke(request.toString()); + } + + /* + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see Section 3.2. + */ + protected void paramThrowingWebApplicationExceptionTest() throws Fault { + fieldOrParamThrowingWebApplicationExceptionTest(""); + } + + /* + * @assertion_ids: JAXRS:SPEC:8; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + protected void fieldThrowingWebApplicationExceptionTest() throws Fault { + fieldOrParamThrowingWebApplicationExceptionTest(ParamTest.FIELD); + } + + protected void paramEntityThrowingAfterRequestSet(String request) + throws Fault { + } + + protected void fieldOrParamThrowingIllegalArgumentExceptionTest(String prefix) + throws Fault { + StringBuilder request = new StringBuilder(); + request.append(prefix); + request + .append(ParamEntityThrowingExceptionGivenByName.class.getSimpleName()); + request.append("=").append(IllegalArgumentException.class.getName()); + // to override + paramEntityThrowingAfterRequestSet(request.toString()); + setProperty(Property.SEARCH_STRING, + WebApplicationExceptionMapper.class.getSimpleName()); + setProperty(Property.UNEXPECTED_RESPONSE_MATCH, + ParamEntityThrowingExceptionGivenByName.ERROR_MSG); + setProperty(Property.SEARCH_STRING, + IllegalArgumentException.class.getName()); + buildRequestAndInvoke(request.toString()); + } + + /* + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + */ + public void paramThrowingIllegalArgumentExceptionTest() throws Fault { + fieldOrParamThrowingIllegalArgumentExceptionTest(""); + } + + /* + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.1; JAXRS:SPEC:9.2; + * JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @MatrixParam, + * + * @QueryParam or @PathParam then an implementation MUST generate a + * WebApplicationException that wraps the thrown exception with a not found + * response (404 status) and no entity; + * + * if the field or property is annotated with @HeaderParam or @CookieParam + * then an implementation MUST generate a WebApplicationException that wraps + * the thrown exception with a client error response (400 status) and no + * entity. + */ + public void fieldThrowingIllegalArgumentExceptionTest() throws Fault { + fieldOrParamThrowingIllegalArgumentExceptionTest(ParamTest.FIELD); + } + + protected void buildRequestAndInvoke(String request) throws Fault { + setProperty(Property.REQUEST, buildRequest(request)); + invoke(); + } + + protected void paramEntityDefault(String request) throws Fault { + setProperty(Property.SEARCH_STRING, getDefaultValueOfParam(request)); + setProperty(Property.REQUEST, buildRequest("")); + invoke(); + } + + protected void paramEntity(String request) throws Fault { + if (searchEqualsEncoded) + setProperty(Property.SEARCH_STRING_IGNORE_CASE, + request.replace("=", "%3d")); + else + setProperty(Property.SEARCH_STRING, request); + buildRequestAndInvoke(request); + } + + protected abstract String buildRequest(String param); + + protected abstract String getDefaultValueOfParam(String param); + + public enum CollectionName { + LIST("List"), SET("Set"), SORTED_SET("SortedSet"); + + private String value; + + public String value() { + return value; + } + + private CollectionName(String value) { + this.value = value; + } + }; + + protected static String segmentFromParam(String param) { + return param.contains("=") ? param.replaceAll("=.*", "") : param; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityThrowingExceptionGivenByName.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityThrowingExceptionGivenByName.java new file mode 100644 index 0000000..148f598 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityThrowingExceptionGivenByName.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +import java.lang.reflect.Constructor; + +import jakarta.ws.rs.WebApplicationException; + +public class ParamEntityThrowingExceptionGivenByName + extends ParamEntityThrowingWebApplicationException { + + public static final String ERROR_MSG = "ParamEntityThrowingExceptionGivenByName created unexpected error"; + + public static ParamEntityThrowingExceptionGivenByName fromString(String arg) { + Object o; + try { + Class<?> clazz = Class.forName(parseArg(arg)); + Constructor<?> constructor = clazz.getConstructor(); + o = constructor.newInstance(); + } catch (Exception e) { + throw new WebApplicationException(new RuntimeException(ERROR_MSG)); + } + throw (RuntimeException) o; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityThrowingWebApplicationException.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityThrowingWebApplicationException.java new file mode 100644 index 0000000..7ca79f9 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityThrowingWebApplicationException.java
@@ -0,0 +1,35 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Response.Status; + +public class ParamEntityThrowingWebApplicationException + extends ParamEntityWithFromString { + + public static ParamEntityThrowingWebApplicationException fromString( + String arg) { + throw new WebApplicationException(Status.valueOf(parseArg(arg))); + } + + protected static String parseArg(String arg) { + arg = arg.replace("%3d", "=").replace("%3D", "="); + arg = arg.contains("=") ? arg.replaceAll(".*=", "") : arg; + return arg; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithConstructor.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithConstructor.java new file mode 100644 index 0000000..73dad9e --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithConstructor.java
@@ -0,0 +1,23 @@ +/* + * Copyright (c) 2011, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +public class ParamEntityWithConstructor extends ParamEntityPrototype { + public ParamEntityWithConstructor(String arg) { + value = arg; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithFromString.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithFromString.java new file mode 100644 index 0000000..08da471 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithFromString.java
@@ -0,0 +1,46 @@ +/* + * Copyright (c) 2011, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +/** + * This is class ParamEntity With "fromString()" method Implements Comparable + * and overrides equals and hashCode for cases when it is in a sorted set + */ +public class ParamEntityWithFromString extends ParamEntityPrototype + implements java.lang.Comparable<ParamEntityWithFromString> { + + public static ParamEntityWithFromString fromString(String arg) { + ParamEntityWithFromString newEntity = new ParamEntityWithFromString(); + newEntity.value = arg; + return newEntity; + } + + @Override + public int compareTo(ParamEntityWithFromString o) { + return this.value.compareTo(o.value); + } + + @Override + public boolean equals(Object obj) { + return this.value.equals(obj); + } + + @Override + public int hashCode() { + return this.value.hashCode(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithValueOf.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithValueOf.java new file mode 100644 index 0000000..409541f --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamEntityWithValueOf.java
@@ -0,0 +1,29 @@ +/* + * Copyright (c) 2011, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +/** + * This is ParamEntity With valueOf method + */ +public class ParamEntityWithValueOf extends ParamEntityPrototype { + + public static ParamEntityWithValueOf valueOf(String arg) { + ParamEntityWithValueOf newEntity = new ParamEntityWithValueOf(); + newEntity.value = arg; + return newEntity; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamTest.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamTest.java new file mode 100644 index 0000000..fb2a713 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/ParamTest.java
@@ -0,0 +1,89 @@ +/* + * Copyright (c) 2012, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +public class ParamTest { + protected boolean noparam = true; + + protected StringBuilder sb; + + public static final String FIELD = "Field"; + + // public static final String BEAN = "Bean"; + public static final String PARAM = "Param"; + + protected void appendNonNullSetNoParam(String name, Number value) { + if (value.doubleValue() != 0d) { + noparam = false; + sb.append(name).append("=").append(value); + } + } + + protected void appendTrueSetNoParam(String name, boolean value) { + if (value) { + noparam = false; + sb.append(name).append("=").append(value); + } + } + + protected void append(Class<? extends ParamEntityPrototype> clazz, + ParamEntityPrototype entity, String... prefix) { + // add prefix + for (String p : prefix) + sb.append(p); + sb.append(clazz.getSimpleName()).append("="); + sb.append(entity != null ? entity.getValue() : "null"); + } + + protected void append(Class<? extends ParamEntityPrototype> clazz, + Collection<? extends ParamEntityPrototype> collection, String... prefix) { + // add prefix + for (String p : prefix) + sb.append(p); + sb.append(clazz.getSimpleName()).append("="); + if (collection != null && collection.iterator().hasNext()) + sb.append(collection.iterator().next().getValue()); + else + sb.append("null"); + } + + protected void setReturnValues( + ParamEntityWithConstructor paramEntityWithConstructor, + ParamEntityWithFromString paramEntityWithFromString, + ParamEntityWithValueOf paramEntityWithValueOf, + Set<ParamEntityWithFromString> setParamEntityWithFromString, + SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString, + List<ParamEntityWithFromString> listParamEntityWithFromString, + String prefix) { + append(ParamEntityWithConstructor.class, paramEntityWithConstructor, + prefix); + append(ParamEntityWithFromString.class, paramEntityWithFromString, prefix); + append(ParamEntityWithValueOf.class, paramEntityWithValueOf, prefix); + + append(ParamEntityWithFromString.class, setParamEntityWithFromString, + prefix, JaxrsParamClient.CollectionName.SET.value()); + append(ParamEntityWithFromString.class, sortedSetParamEntityWithFromString, + prefix, JaxrsParamClient.CollectionName.SORTED_SET.value()); + append(ParamEntityWithFromString.class, listParamEntityWithFromString, + prefix, JaxrsParamClient.CollectionName.LIST.value()); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/RuntimeExceptionMapper.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/RuntimeExceptionMapper.java new file mode 100644 index 0000000..06b10e2 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/RuntimeExceptionMapper.java
@@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +import java.util.IllegalFormatException; +import java.util.MissingFormatArgumentException; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; + +@Provider +public class RuntimeExceptionMapper + implements ExceptionMapper<RuntimeException> { + + @Override + public Response toResponse(RuntimeException exception) { + Status status = Status.GONE; + if (exception instanceof MissingFormatArgumentException) + status = Status.MOVED_PERMANENTLY; // 301 + else if (exception instanceof IllegalFormatException) + status = Status.SEE_OTHER; // 303 + else if (exception instanceof IllegalArgumentException) + status = Status.NOT_MODIFIED;// 304 + if (status == Status.GONE) + exception.printStackTrace(); + return Response.status(status).entity(exception.getMessage()).build(); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/WebApplicationExceptionMapper.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/WebApplicationExceptionMapper.java new file mode 100644 index 0000000..e019646 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/WebApplicationExceptionMapper.java
@@ -0,0 +1,47 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs; + +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; + +@Provider +public class WebApplicationExceptionMapper + implements ExceptionMapper<WebApplicationException> { + + @Override + public Response toResponse(WebApplicationException exception) { + Response response = exception.getResponse(); + Status status = Status.fromStatusCode(response.getStatus()); + StringBuilder sb = new StringBuilder(); + // Note mapper applied + sb.append(getClass().getSimpleName()); + // note what status there might have been + if (status != null) + sb.append("|status=").append(status.name()); + // Note what source exceptions there might have been + for (Throwable t = exception.getCause(); t != null; t = t.getCause()) { + sb.append("|msg=").append(t.getMessage()); + sb.append("|ex=").append(t.getClass().getName()); + } + return Response.ok(sb.toString()).build(); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/BeanParamCommonClient.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/BeanParamCommonClient.java new file mode 100644 index 0000000..dc79e3f --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/BeanParamCommonClient.java
@@ -0,0 +1,169 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam; + +import jakarta.ws.rs.tck.common.util.JaxrsUtil; +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.JaxrsParamClient; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; +import jakarta.ws.rs.tck.ee.rs.ParamTest; + +import jakarta.ws.rs.core.MediaType; +import static org.junit.jupiter.api.Assertions.assertTrue; +/* + * @since 2.0.1 + */ +public abstract class BeanParamCommonClient extends JaxrsParamClient { + private static final long serialVersionUID = 201L; + + protected String fieldBeanParam; + + protected int exceptionInEntity = 0; + + private void setFieldOrBean(String prefix) { + fieldBeanParam = prefix.contains(ParamTest.FIELD) ? ParamTest.FIELD + : ParamTest.PARAM; + } + + protected void fieldOrParamEntityName(Class<?> entityClazz, + String nonDefaultValue, String... prefix) throws Fault { + setFieldOrBean(prefix[0]); + if (prefix[0].contains(ParamTest.FIELD)) + prefix[0] = ""; + super.fieldOrParamEntityName(entityClazz, nonDefaultValue, prefix); + } + + protected void fieldOrParamThrowingWebApplicationExceptionTest(String prefix) + throws Fault { + setFieldOrBean(prefix); + exceptionInEntity++; + super.fieldOrParamThrowingWebApplicationExceptionTest(""); + } + + @Override + protected void fieldOrParamThrowingIllegalArgumentExceptionTest(String prefix) + throws Fault { + setFieldOrBean(prefix); + exceptionInEntity++; + super.fieldOrParamThrowingIllegalArgumentExceptionTest(""); + } + + @Override + protected void fieldOrParamEncodedTest(String prefix) throws Fault { + setFieldOrBean(prefix); + StringBuilder request = new StringBuilder(); + request.append(ParamEntityWithValueOf.class.getSimpleName()); + setProperty(Property.REQUEST, buildRequest(request.toString() + "=%21")); + setProperty(Property.SEARCH_STRING, fieldBeanParam, request.toString(), + "=!"); + setProperty(Property.SEARCH_STRING, Constants.INNER, fieldBeanParam, + request.toString(), "=!"); + invoke(); + + request = new StringBuilder(); + request.append(ParamEntityWithFromString.class.getSimpleName()); + request.append("=%21"); + paramEntity(request.toString()); + } + + protected void paramEntity(String request) throws Fault { + if (searchEqualsEncoded) { + setProperty(Property.SEARCH_STRING_IGNORE_CASE, fieldBeanParam, + request.replace("=", "%3d")); + setProperty(Property.SEARCH_STRING_IGNORE_CASE, Constants.INNER, + fieldBeanParam, request.replace("=", "%3d")); + } else { + setProperty(Property.SEARCH_STRING, fieldBeanParam, request); + setProperty(Property.SEARCH_STRING, Constants.INNER, fieldBeanParam, + request); + } + buildRequestAndInvoke(request); + } + + @Override + protected String getDefaultValueOfParam(String param) { + StringBuilder sb = new StringBuilder(); + sb.append(fieldBeanParam).append(param).append("="); + sb.append(Constants.DEFAULT_VALUE); + sb.append("|").append(Constants.INNER).append(fieldBeanParam); + sb.append(param).append("="); + sb.append(Constants.DEFAULT_VALUE); + return sb.toString(); + } + + @Override + protected void invoke() throws Fault { + setProperty(Property.REQUEST_HEADERS, + buildContentType(MediaType.APPLICATION_FORM_URLENCODED_TYPE)); + setProperty(Property.REQUEST_HEADERS, buildAccept(MediaType.WILDCARD_TYPE)); + super.invoke(); + } + + @Override + protected void buildRequestAndInvoke(String request) throws Fault { + String req = exceptionInEntity == 0 ? buildRequest(request) + : buildRequestForException(request, exceptionInEntity); + setProperty(Property.REQUEST, req); + invoke(); + } + + /** + * @param entity + * specifies whether the exception is to be tested in first entity, + * i.e. in the master BeanParamEntity or the second entity + * Inner*BeanParamEntity + */ + protected String buildRequestForException(String param, int entity) + throws Fault { + return buildRequest(param); + } + + // Cookie Param + + protected void createAndCheckCookie(String param, String uri) throws Fault { + // create cookie + String requestForCookie = param + ";" + Constants.INNER + param; + setProperty(Property.CONTENT, requestForCookie); + setProperty(Property.REQUEST, buildRequest(Request.POST, uri)); + setProperty(Property.SAVE_STATE, "true"); + invoke(); + checkCookie(param); + // check cookie + setProperty(Property.USE_SAVED_STATE, "true"); + } + + protected void checkCookie(String cookie) throws Fault { + boolean found = false; + String lowCookie = stripQuotesSpacesAndLowerCase(cookie); + String[] headers = getResponseHeaders(); + for (String h : headers) { + String header = stripQuotesSpacesAndLowerCase(h); + if (header.startsWith("set-cookie")) + if (header.contains(lowCookie)) + found = true; + } + assertTrue(found, "Could not find cookie" + cookie+ "in response headers:" + + JaxrsUtil.iterableToString(";", headers)); + logMsg("Found cookie", cookie, "as expected"); + } + + protected static String stripQuotesSpacesAndLowerCase(String cookie) { + return cookie.toLowerCase().replace("\"", "").replace("'", "").replace(" ", + ""); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/bean/BeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/bean/BeanParamEntity.java new file mode 100644 index 0000000..b02a038 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/bean/BeanParamEntity.java
@@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.bean; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.FormParam; +import jakarta.ws.rs.HeaderParam; +import jakarta.ws.rs.MatrixParam; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.QueryParam; + +public class BeanParamEntity { + @CookieParam("bpeCookie") + public String bpeCookie; + + @FormParam("bpeForm") + public String bpeForm; + + @HeaderParam("bpeHeader") + public String bpeHeader; + + @MatrixParam("bpeMatrix") + public String bpeMatrix; + + @PathParam("bpePath") + public String bpePath; + + @QueryParam("bpeQuery") + public String bpeQuery; + + // -------------------- + @BeanParam + public InnerBeanParamEntity bpeInner; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/bean/InnerBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/bean/InnerBeanParamEntity.java new file mode 100644 index 0000000..f7d547d --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/bean/InnerBeanParamEntity.java
@@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.bean; + +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.FormParam; +import jakarta.ws.rs.HeaderParam; +import jakarta.ws.rs.MatrixParam; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.QueryParam; + +public class InnerBeanParamEntity { + @CookieParam("innerCookie") + public String innerCookie; + + @FormParam("innerForm") + public String innerForm; + + @HeaderParam("innerHeader") + public String innerHeader; + + @MatrixParam("innerMatrix") + public String innerMatrix; + + @PathParam("innerPath") + public String innerPath; + + @QueryParam("innerQuery") + public String innerQuery; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/bean/CookieBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/bean/CookieBeanParamEntity.java new file mode 100644 index 0000000..1b5a162 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/bean/CookieBeanParamEntity.java
@@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.cookie.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.DefaultValue; + +public class CookieBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + // @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @CookieParam(Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @CookieParam(Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; + + @BeanParam + public InnerCookieBeanParamEntity inner; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/bean/InnerCookieBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/bean/InnerCookieBeanParamEntity.java new file mode 100644 index 0000000..770c5dc --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/bean/InnerCookieBeanParamEntity.java
@@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.cookie.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.DefaultValue; + +public class InnerCookieBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + // @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.INNER + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.INNER + + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @CookieParam(Constants.INNER + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @CookieParam(Constants.INNER + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @CookieParam(Constants.INNER + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/AppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/AppConfig.java new file mode 100644 index 0000000..5d88d3e --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/AppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.cookie.plain; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +public class AppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/JAXRSClientIT.java new file mode 100644 index 0000000..4aaeba7 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/JAXRSClientIT.java
@@ -0,0 +1,334 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.cookie.plain; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import jakarta.ws.rs.tck.ee.rs.beanparam.BeanParamCommonClient; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * @since 2.0.1 + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends BeanParamCommonClient { + private static final long serialVersionUID = 201L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_beanparam_cookie_plain_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_beanparam_cookie_plain_web.war"); + archive.addClasses(AppConfig.class, Resource.class, + jakarta.ws.rs.tck.ee.rs.beanparam.cookie.bean.CookieBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.beanparam.cookie.bean.InnerCookieBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.Constants.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* Run test */ + + /* + * @testName: cookieParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamEntityWithConstructorTest() throws Fault { + super.paramEntityWithConstructorTest(); + } + + /* + * @testName: cookieParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamEntityWithValueOfTest() throws Fault { + super.paramEntityWithValueOfTest(); + } + + /* + * @testName: cookieParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamEntityWithFromStringTest() throws Fault { + super.paramEntityWithFromStringTest(); + } + + /* + * @testName: cookieParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: cookieParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamSortedSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: cookieParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamListEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: cookieFieldParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamEntityWithConstructorTest() throws Fault { + super.fieldEntityWithConstructorTest(); + } + + /* + * @testName: cookieFieldParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamEntityWithValueOfTest() throws Fault { + super.fieldEntityWithValueOfTest(); + } + + /* + * @testName: cookieFieldParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamEntityWithFromStringTest() throws Fault { + super.fieldEntityWithFromStringTest(); + } + + /* + * @testName: cookieFieldParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: cookieFieldParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamSortedSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: cookieFieldParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamListEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: cookieParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see Section 3.2. + */ + @Test + public void cookieParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: cookieFieldThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:8; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + @Test + public void cookieFieldThrowingWebApplicationExceptionTest() throws Fault { + super.fieldThrowingWebApplicationExceptionTest(); + super.fieldThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: cookieParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + */ + @Test + public void cookieParamThrowingIllegalArgumentExceptionTest() throws Fault { + super.paramThrowingIllegalArgumentExceptionTest(); + super.paramThrowingIllegalArgumentExceptionTest(); + } + + /* + * @testName: cookieFieldThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.2; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @FormParam or @CookieParam then + * an implementation MUST generate a WebApplicationException that wraps the + * thrown exception with a client error response (400 status) and no entity. + */ + @Test + public void cookieFieldThrowingIllegalArgumentExceptionTest() throws Fault { + super.fieldThrowingIllegalArgumentExceptionTest(); + super.fieldThrowingIllegalArgumentExceptionTest(); + } + + @Override + protected String buildRequest(String param) { + return buildRequest(Request.POST, fieldBeanParam); + } + + @Override + protected void invoke() throws Fault { + setProperty(Property.CONTENT, "Anything"); + super.invoke(); + } + + @Override + protected void paramEntity(String request) throws Fault { + createAndCheckCookie(request, "Set"); + super.paramEntity(request); + } + + @Override + protected void paramEntityThrowingAfterRequestSet(String request) + throws Fault { + createAndCheckCookie(request, "Set"); + // this is for illegal argument exception tests only + if (request.contains(IllegalArgumentException.class.getSimpleName())) + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.paramEntityThrowingAfterRequestSet(request); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/Resource.java new file mode 100644 index 0000000..757cc97 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/Resource.java
@@ -0,0 +1,93 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.cookie.plain; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamTest; +import jakarta.ws.rs.tck.ee.rs.beanparam.cookie.bean.CookieBeanParamEntity; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.NewCookie; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.ResponseBuilder; + +@Path(value = "resource") +public class Resource extends ParamTest { + + @BeanParam + CookieBeanParamEntity field; + + @POST + @Path("Field") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String field() { + sb = new StringBuilder(); + setReturnValues(field.paramEntityWithConstructor, + field.paramEntityWithFromString, field.paramEntityWithValueOf, + field.setParamEntityWithFromString, + field.sortedSetParamEntityWithFromString, + field.listParamEntityWithFromString, FIELD); + setReturnValues(field.inner.paramEntityWithConstructor, + field.inner.paramEntityWithFromString, + field.inner.paramEntityWithValueOf, + field.inner.setParamEntityWithFromString, + field.inner.sortedSetParamEntityWithFromString, + field.inner.listParamEntityWithFromString, Constants.INNER + FIELD); + return sb.toString(); + } + + @POST + @Path("Param") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandling(@BeanParam CookieBeanParamEntity bean) { + sb = new StringBuilder(); + setReturnValues(bean.paramEntityWithConstructor, + bean.paramEntityWithFromString, bean.paramEntityWithValueOf, + bean.setParamEntityWithFromString, + bean.sortedSetParamEntityWithFromString, + bean.listParamEntityWithFromString, PARAM); + setReturnValues(bean.inner.paramEntityWithConstructor, + bean.inner.paramEntityWithFromString, bean.inner.paramEntityWithValueOf, + bean.inner.setParamEntityWithFromString, + bean.inner.sortedSetParamEntityWithFromString, + bean.inner.listParamEntityWithFromString, Constants.INNER + PARAM); + return sb.toString(); + } + + @POST + @Path("Set") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public Response set(String content) { + ResponseBuilder rb = Response.ok(); + if (content != null) { + String[] cookies1 = content.split(";"); + for (String cookie : cookies1) { + String[] nameVal = cookie.split("="); // name=0, value=1 + rb.cookie(new NewCookie(nameVal[0], nameVal[1])); + } + } + return rb.build(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/bean/FormBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/bean/FormBeanParamEntity.java new file mode 100644 index 0000000..6a3d98c --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/bean/FormBeanParamEntity.java
@@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.form.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Encoded; +import jakarta.ws.rs.FormParam; + +public class FormBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @FormParam(Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @FormParam(Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; + + @BeanParam + public InnerFormBeanParamEntity inner; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/bean/InnerFormBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/bean/InnerFormBeanParamEntity.java new file mode 100644 index 0000000..e110f4a --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/bean/InnerFormBeanParamEntity.java
@@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.form.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Encoded; +import jakarta.ws.rs.FormParam; + +public class InnerFormBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.INNER + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.INNER + + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @FormParam(Constants.INNER + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @FormParam(Constants.INNER + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @FormParam(Constants.INNER + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/AppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/AppConfig.java new file mode 100644 index 0000000..766f851 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/AppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.form.plain; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +public class AppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/JAXRSClientIT.java new file mode 100644 index 0000000..381a528 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/JAXRSClientIT.java
@@ -0,0 +1,357 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.form.plain; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.beanparam.BeanParamCommonClient; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * @since 2.0.1 + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends BeanParamCommonClient { + private static final long serialVersionUID = 201L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_beanparam_form_plain_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_beanparam_form_plain_web.war"); + archive.addClasses(AppConfig.class, Resource.class, + jakarta.ws.rs.tck.ee.rs.beanparam.form.bean.FormBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.beanparam.form.bean.InnerFormBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.Constants.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* Run test */ + + /* + * @testName: formParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formParamEntityWithConstructorTest() throws Fault { + super.paramEntityWithConstructorTest(); + } + + /* + * @testName: formParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formParamEntityWithValueOfTest() throws Fault { + super.paramEntityWithValueOfTest(); + } + + /* + * @testName: formParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formParamEntityWithFromStringTest() throws Fault { + super.paramEntityWithFromStringTest(); + } + + /* + * @testName: formParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formParamSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: formParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formParamSortedSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: formParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formParamListEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: formFieldParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formFieldParamEntityWithConstructorTest() throws Fault { + super.fieldEntityWithConstructorTest(); + } + + /* + * @testName: formFieldParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formFieldParamEntityWithValueOfTest() throws Fault { + super.fieldEntityWithValueOfTest(); + } + + /* + * @testName: formFieldParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formFieldParamEntityWithFromStringTest() throws Fault { + super.fieldEntityWithFromStringTest(); + } + + /* + * @testName: formFieldParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formFieldParamSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: formFieldParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formFieldParamSortedSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: formFieldParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named FormParam is handled properly + */ + @Test + public void formFieldParamListEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: formParamEntityWithEncodedTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:7; JAXRS:SPEC:12.2; + * + * @test_Strategy: Verify that named FormParam @Encoded is handled + */ + @Test + public void formParamEntityWithEncodedTest() throws Fault { + super.paramEntityWithEncodedTest(); + } + + /* + * @testName: formFieldParamEntityWithEncodedTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:7; + * + * @test_Strategy: Verify that named FormParam @Encoded is handled + */ + @Test + public void formFieldParamEntityWithEncodedTest() throws Fault { + super.fieldEntityWithEncodedTest(); + } + + /* + * @testName: formParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see Section 3.2. + */ + @Test + public void formParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: formFieldThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:8; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + @Test + public void formFieldThrowingWebApplicationExceptionTest() throws Fault { + super.fieldThrowingWebApplicationExceptionTest(); + super.fieldThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: formParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + */ + @Test + public void formParamThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + } + + /* + * @testName: formFieldThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.2; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @FormParam or @CookieParam then + * an implementation MUST generate a WebApplicationException that wraps the + * thrown exception with a client error response (400 status) and no entity. + */ + @Test + public void formFieldThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + } + + @Override + protected String buildRequest(String param) { + if (!"".equals(param)) { + setProperty(Property.CONTENT, "ANYTHING&", param, "&", Constants.INNER, + param); + } else { + setProperty(Property.CONTENT, "ANYTHING"); + } + return buildRequest(Request.POST, fieldBeanParam); + } + + @Override + protected// + String buildRequestForException(String param, int entity) throws Fault { + if (entity == 1) + setProperty(Property.CONTENT, "ANYTHING&", param); + else + setProperty(Property.CONTENT, "ANYTHING&", Constants.INNER, param); + return buildRequest(Request.POST, fieldBeanParam); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/Resource.java new file mode 100644 index 0000000..a630b36 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/Resource.java
@@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.form.plain; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamTest; +import jakarta.ws.rs.tck.ee.rs.beanparam.form.bean.FormBeanParamEntity; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path(value = "resource") +public class Resource extends ParamTest { + + @BeanParam + FormBeanParamEntity field; + + @POST + @Path("Field") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String field() { + sb = new StringBuilder(); + setReturnValues(field.paramEntityWithConstructor, + field.paramEntityWithFromString, field.paramEntityWithValueOf, + field.setParamEntityWithFromString, + field.sortedSetParamEntityWithFromString, + field.listParamEntityWithFromString, FIELD); + setReturnValues(field.inner.paramEntityWithConstructor, + field.inner.paramEntityWithFromString, + field.inner.paramEntityWithValueOf, + field.inner.setParamEntityWithFromString, + field.inner.sortedSetParamEntityWithFromString, + field.inner.listParamEntityWithFromString, Constants.INNER + FIELD); + return sb.toString(); + } + + @POST + @Path("Param") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandling(@BeanParam FormBeanParamEntity bean) { + sb = new StringBuilder(); + setReturnValues(bean.paramEntityWithConstructor, + bean.paramEntityWithFromString, bean.paramEntityWithValueOf, + bean.setParamEntityWithFromString, + bean.sortedSetParamEntityWithFromString, + bean.listParamEntityWithFromString, PARAM); + setReturnValues(bean.inner.paramEntityWithConstructor, + bean.inner.paramEntityWithFromString, bean.inner.paramEntityWithValueOf, + bean.inner.setParamEntityWithFromString, + bean.inner.sortedSetParamEntityWithFromString, + bean.inner.listParamEntityWithFromString, Constants.INNER + PARAM); + return sb.toString(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/bean/HeaderBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/bean/HeaderBeanParamEntity.java new file mode 100644 index 0000000..1324aa8 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/bean/HeaderBeanParamEntity.java
@@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.header.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.HeaderParam; + +public class HeaderBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + // @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @HeaderParam(Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @HeaderParam(Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; + + @BeanParam + public InnerHeaderBeanParamEntity inner; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/bean/InnerHeaderBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/bean/InnerHeaderBeanParamEntity.java new file mode 100644 index 0000000..184d5d8 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/bean/InnerHeaderBeanParamEntity.java
@@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.header.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.HeaderParam; + +public class InnerHeaderBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + // @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.INNER + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.INNER + + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @HeaderParam(Constants.INNER + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @HeaderParam(Constants.INNER + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @HeaderParam(Constants.INNER + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/AppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/AppConfig.java new file mode 100644 index 0000000..93e38f2 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/AppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.header.plain; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +public class AppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/JAXRSClientIT.java new file mode 100644 index 0000000..3a55159 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/JAXRSClientIT.java
@@ -0,0 +1,335 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.header.plain; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.beanparam.BeanParamCommonClient; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * @since 2.0.1 + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends BeanParamCommonClient { + private static final long serialVersionUID = 201L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_beanparam_header_plain_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_beanparam_header_plain_web.war"); + archive.addClasses(AppConfig.class, Resource.class, + jakarta.ws.rs.tck.ee.rs.beanparam.header.bean.HeaderBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.beanparam.header.bean.InnerHeaderBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.Constants.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* Run test */ + + /* + * @testName: headerParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerParamEntityWithConstructorTest() throws Fault { + super.paramEntityWithConstructorTest(); + } + + /* + * @testName: headerParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerParamEntityWithValueOfTest() throws Fault { + super.paramEntityWithValueOfTest(); + } + + /* + * @testName: headerParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerParamEntityWithFromStringTest() throws Fault { + super.paramEntityWithFromStringTest(); + } + + /* + * @testName: headerParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerParamSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: headerParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerParamSortedSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: headerParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerParamListEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: headerFieldParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerFieldParamEntityWithConstructorTest() throws Fault { + super.fieldEntityWithConstructorTest(); + } + + /* + * @testName: headerFieldParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerFieldParamEntityWithValueOfTest() throws Fault { + super.fieldEntityWithValueOfTest(); + } + + /* + * @testName: headerFieldParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerFieldParamEntityWithFromStringTest() throws Fault { + super.fieldEntityWithFromStringTest(); + } + + /* + * @testName: headerFieldParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerFieldParamSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: headerFieldParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerFieldParamSortedSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: headerFieldParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.5; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named HeaderParam is handled properly + */ + @Test + public void headerFieldParamListEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: headerParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see Section 3.2. + */ + @Test + public void headerParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: headerFieldThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:8; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + @Test + public void headerFieldThrowingWebApplicationExceptionTest() throws Fault { + super.fieldThrowingWebApplicationExceptionTest(); + super.fieldThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: headerParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + */ + @Test + public void headerParamThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + } + + /* + * @testName: headerFieldThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.2; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @HeaderParam or @CookieParam + * then an implementation MUST generate a WebApplicationException that wraps + * the thrown exception with a client error response (400 status) and no + * entity. + */ + @Test + public void headerFieldThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + } + + @Override + protected String buildRequest(String param) { + if (!"".equals(param)) { + String par = param.replace("=", ":"); + setProperty(Property.REQUEST_HEADERS, par); + setProperty(Property.REQUEST_HEADERS, Constants.INNER, par); + } + return buildRequest(Request.GET, fieldBeanParam); + } + + @Override + protected// + String buildRequestForException(String param, int entity) throws Fault { + String par = param.replace("=", ":"); + if (entity == 1) { + setProperty(Property.REQUEST_HEADERS, par); + } else { + setProperty(Property.REQUEST_HEADERS, Constants.INNER, par); + } + return buildRequest(Request.GET, fieldBeanParam); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/Resource.java new file mode 100644 index 0000000..466502c --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/Resource.java
@@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.header.plain; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamTest; +import jakarta.ws.rs.tck.ee.rs.beanparam.header.bean.HeaderBeanParamEntity; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path(value = "resource") +public class Resource extends ParamTest { + + @BeanParam + HeaderBeanParamEntity field; + + @GET + @Path("Field") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String field() { + sb = new StringBuilder(); + setReturnValues(field.paramEntityWithConstructor, + field.paramEntityWithFromString, field.paramEntityWithValueOf, + field.setParamEntityWithFromString, + field.sortedSetParamEntityWithFromString, + field.listParamEntityWithFromString, FIELD); + setReturnValues(field.inner.paramEntityWithConstructor, + field.inner.paramEntityWithFromString, + field.inner.paramEntityWithValueOf, + field.inner.setParamEntityWithFromString, + field.inner.sortedSetParamEntityWithFromString, + field.inner.listParamEntityWithFromString, Constants.INNER + FIELD); + return sb.toString(); + } + + @GET + @Path("Param") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandling(@BeanParam HeaderBeanParamEntity bean) { + sb = new StringBuilder(); + setReturnValues(bean.paramEntityWithConstructor, + bean.paramEntityWithFromString, bean.paramEntityWithValueOf, + bean.setParamEntityWithFromString, + bean.sortedSetParamEntityWithFromString, + bean.listParamEntityWithFromString, PARAM); + setReturnValues(bean.inner.paramEntityWithConstructor, + bean.inner.paramEntityWithFromString, bean.inner.paramEntityWithValueOf, + bean.inner.setParamEntityWithFromString, + bean.inner.sortedSetParamEntityWithFromString, + bean.inner.listParamEntityWithFromString, Constants.INNER + PARAM); + return sb.toString(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/bean/InnerMatrixBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/bean/InnerMatrixBeanParamEntity.java new file mode 100644 index 0000000..ec462d8 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/bean/InnerMatrixBeanParamEntity.java
@@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.matrix.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Encoded; +import jakarta.ws.rs.MatrixParam; + +public class InnerMatrixBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.INNER + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.INNER + + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.INNER + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @MatrixParam(Constants.INNER + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @MatrixParam(Constants.INNER + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/bean/MatrixBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/bean/MatrixBeanParamEntity.java new file mode 100644 index 0000000..539a7e3 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/bean/MatrixBeanParamEntity.java
@@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.matrix.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Encoded; +import jakarta.ws.rs.MatrixParam; + +public class MatrixBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @MatrixParam(Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @MatrixParam(Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @MatrixParam(Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; + + @BeanParam + public InnerMatrixBeanParamEntity inner; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/AppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/AppConfig.java new file mode 100644 index 0000000..7b074f5 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/AppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.matrix.plain; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +public class AppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/JAXRSClientIT.java new file mode 100644 index 0000000..9ea2e81 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/JAXRSClientIT.java
@@ -0,0 +1,355 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.matrix.plain; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.beanparam.BeanParamCommonClient; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * @since 2.0.1 + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends BeanParamCommonClient { + + private static final long serialVersionUID = 201L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_beanparam_matrix_plain_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_beanparam_matrix_plain_web.war"); + archive.addClasses(AppConfig.class, Resource.class, + jakarta.ws.rs.tck.ee.rs.beanparam.matrix.bean.MatrixBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.beanparam.matrix.bean.InnerMatrixBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.Constants.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* Run test */ + + /* + * @testName: matrixParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixParamEntityWithConstructorTest() throws Fault { + paramEntityWithConstructorTest(); + } + + /* + * @testName: matrixParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixParamEntityWithValueOfTest() throws Fault { + paramEntityWithValueOfTest(); + } + + /* + * @testName: matrixParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixParamEntityWithFromStringTest() throws Fault { + paramEntityWithFromStringTest(); + } + + /* + * @testName: matrixParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixParamSetEntityWithFromStringTest() throws Fault { + paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: matrixParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixParamSortedSetEntityWithFromStringTest() throws Fault { + paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: matrixParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixParamListEntityWithFromStringTest() throws Fault { + paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: matrixFieldParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixFieldParamEntityWithConstructorTest() throws Fault { + fieldEntityWithConstructorTest(); + } + + /* + * @testName: matrixFieldParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixFieldParamEntityWithValueOfTest() throws Fault { + fieldEntityWithValueOfTest(); + } + + /* + * @testName: matrixFieldParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixFieldParamEntityWithFromStringTest() throws Fault { + fieldEntityWithFromStringTest(); + } + + /* + * @testName: matrixFieldParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixFieldParamSetEntityWithFromStringTest() throws Fault { + fieldCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: matrixFieldParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixFieldParamSortedSetEntityWithFromStringTest() throws Fault { + fieldCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: matrixFieldParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named MatrixParam is handled properly + */ + @Test + public void matrixFieldParamListEntityWithFromStringTest() throws Fault { + fieldCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: matrixParamEntityWithEncodedTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:7; JAXRS:SPEC:12.2; + * + * @test_Strategy: Verify that named MatrixParam @Encoded is handled + */ + @Test + public void matrixParamEntityWithEncodedTest() throws Fault { + super.paramEntityWithEncodedTest(); + } + + /* + * @testName: matrixFieldParamEntityWithEncodedTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:7; + * + * @test_Strategy: Verify that named MatrixParam @Encoded is handled + */ + @Test + public void matrixFieldParamEntityWithEncodedTest() throws Fault { + super.fieldEntityWithEncodedTest(); + } + + /* + * @testName: matrixParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see Section 3.2. + */ + @Test + public void matrixParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: matrixFieldThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:8; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + @Test + public void matrixFieldThrowingWebApplicationExceptionTest() throws Fault { + super.fieldThrowingWebApplicationExceptionTest(); + super.fieldThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: matrixParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + */ + @Test + public void matrixParamThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + } + + /* + * @testName: matrixFieldThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.1; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @MatrixParam, + * + * @QueryParam or @PathParam then an implementation MUST generate a + * WebApplicationException that wraps the thrown exception with a not found + * response (404 status) and no entity; + */ + @Test + public void matrixFieldThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + } + + @Override + protected String buildRequest(String param) { + return buildRequest(Request.GET, fieldBeanParam, ";", param, ";", + Constants.INNER, param); + } + + @Override + protected// + String buildRequestForException(String param, int entity) throws Fault { + if (entity == 1) + return buildRequest(Request.GET, fieldBeanParam, ";", param); + else + return buildRequest(Request.GET, fieldBeanParam, ";", Constants.INNER, + param); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/Resource.java new file mode 100644 index 0000000..04f9e7e --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/Resource.java
@@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.matrix.plain; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamTest; +import jakarta.ws.rs.tck.ee.rs.beanparam.matrix.bean.MatrixBeanParamEntity; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path(value = "resource") +public class Resource extends ParamTest { + + @BeanParam + MatrixBeanParamEntity field; + + @GET + @Path("Field") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String field() { + sb = new StringBuilder(); + setReturnValues(field.paramEntityWithConstructor, + field.paramEntityWithFromString, field.paramEntityWithValueOf, + field.setParamEntityWithFromString, + field.sortedSetParamEntityWithFromString, + field.listParamEntityWithFromString, FIELD); + setReturnValues(field.inner.paramEntityWithConstructor, + field.inner.paramEntityWithFromString, + field.inner.paramEntityWithValueOf, + field.inner.setParamEntityWithFromString, + field.inner.sortedSetParamEntityWithFromString, + field.inner.listParamEntityWithFromString, Constants.INNER + FIELD); + return sb.toString(); + } + + @GET + @Path("Param") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandling(@BeanParam MatrixBeanParamEntity bean) { + sb = new StringBuilder(); + setReturnValues(bean.paramEntityWithConstructor, + bean.paramEntityWithFromString, bean.paramEntityWithValueOf, + bean.setParamEntityWithFromString, + bean.sortedSetParamEntityWithFromString, + bean.listParamEntityWithFromString, PARAM); + setReturnValues(bean.inner.paramEntityWithConstructor, + bean.inner.paramEntityWithFromString, bean.inner.paramEntityWithValueOf, + bean.inner.setParamEntityWithFromString, + bean.inner.sortedSetParamEntityWithFromString, + bean.inner.listParamEntityWithFromString, Constants.INNER + PARAM); + return sb.toString(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/bean/InnerPathBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/bean/InnerPathBeanParamEntity.java new file mode 100644 index 0000000..aff1032 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/bean/InnerPathBeanParamEntity.java
@@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.path.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Encoded; +import jakarta.ws.rs.PathParam; + +public class InnerPathBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.INNER + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.INNER + + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.INNER + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @PathParam(Constants.INNER + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @PathParam(Constants.INNER + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/bean/PathBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/bean/PathBeanParamEntity.java new file mode 100644 index 0000000..9a4b576 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/bean/PathBeanParamEntity.java
@@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.path.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Encoded; +import jakarta.ws.rs.PathParam; + +public class PathBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @PathParam(Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @PathParam(Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @PathParam(Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; + + @BeanParam + public InnerPathBeanParamEntity inner; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/AppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/AppConfig.java new file mode 100644 index 0000000..0afbc51 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/AppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.path.plain; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +public class AppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/JAXRSClientIT.java new file mode 100644 index 0000000..67d126d --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/JAXRSClientIT.java
@@ -0,0 +1,360 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.path.plain; + +import jakarta.ws.rs.tck.ee.rs.beanparam.BeanParamCommonClient; +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * @since 2.0.1 + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends BeanParamCommonClient { + + private static final long serialVersionUID = 201L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_beanparam_path_plain_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_beanparam_path_plain_web.war"); + archive.addClasses(AppConfig.class, Resource.class, + jakarta.ws.rs.tck.ee.rs.beanparam.path.bean.PathBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.beanparam.path.bean.InnerPathBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.Constants.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* Run test */ + + /* + * @testName: pathParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.2; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathParamEntityWithConstructorTest() throws Fault { + super.paramEntityWithConstructorTest(); + } + + /* + * @testName: pathParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.3; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathParamEntityWithValueOfTest() throws Fault { + super.paramEntityWithValueOfTest(); + } + + /* + * @testName: pathParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.3; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathParamEntityWithFromStringTest() throws Fault { + super.paramEntityWithFromStringTest(); + } + + /* + * @testName: pathParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathParamSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: pathParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathParamSortedSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: pathParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathParamListEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: pathFieldParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.2; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathFieldParamEntityWithConstructorTest() throws Fault { + super.fieldEntityWithConstructorTest(); + } + + /* + * @testName: pathFieldParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.3; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathFieldParamEntityWithValueOfTest() throws Fault { + super.fieldEntityWithValueOfTest(); + } + + /* + * @testName: pathFieldParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.3; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathFieldParamEntityWithFromStringTest() throws Fault { + super.fieldEntityWithFromStringTest(); + } + + /* + * @testName: pathFieldParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathFieldParamSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: pathFieldParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathFieldParamSortedSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: pathFieldParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named PathParam is handled properly + */ + @Test + public void pathFieldParamListEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: pathParamEntityWithEncodedTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:7; JAXRS:SPEC:12; + * JAXRS:SPEC:12.2; + * + * @test_Strategy: Verify that named PathParam @Encoded is handled + */ + @Test + public void pathParamEntityWithEncodedTest() throws Fault { + super.paramEntityWithEncodedTest(); + } + + /* + * @testName: pathFieldParamEntityWithEncodedTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:7; + * + * @test_Strategy: Verify that named PathParam @Encoded is handled + */ + @Test + public void pathFieldParamEntityWithEncodedTest() throws Fault { + super.fieldEntityWithEncodedTest(); + } + + /* + * @testName: pathParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see Section 3.2. + */ + @Test + public void pathParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: pathFieldThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:8; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + @Test + public void pathFieldThrowingWebApplicationExceptionTest() throws Fault { + super.fieldThrowingWebApplicationExceptionTest(); + super.fieldThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: pathParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + */ + @Test + public void pathParamThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + } + + /* + * @testName: pathFieldThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.1; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @MatrixParam, + * + * @QueryParam or @PathParam then an implementation MUST generate a + * WebApplicationException that wraps the thrown exception with a not found + * response (404 status) and no entity; + */ + @Test + public void pathFieldThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + } + + @Override + protected String buildRequest(String param) { + if (!"".equals(param)) + return buildRequest(Request.GET, fieldBeanParam, "/", + param.replaceAll("=", "/"), param.replaceAll(".*=", "/"), param); + else + return buildRequest(Request.GET, fieldBeanParam); + } + + @Override + protected// + String buildRequestForException(String param, int entity) throws Fault { + if (entity == 1) + return buildRequest(Request.GET, fieldBeanParam, "/1/", + param.replaceAll("=", "/"), "/ANYTHING"); + else + return buildRequest(Request.GET, fieldBeanParam, "/2/", + param.replaceAll("=.*", ""), "/ANYTHING/", + param.replaceAll(".*=", "")); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/Resource.java new file mode 100644 index 0000000..b36049b --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/Resource.java
@@ -0,0 +1,284 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.path.plain; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamTest; +import jakarta.ws.rs.tck.ee.rs.beanparam.path.bean.PathBeanParamEntity; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path(value = "resource") +public class Resource extends ParamTest { + + @BeanParam + PathBeanParamEntity field; + + @GET + @Path("Field") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String field() { + sb = new StringBuilder(); + setReturnValues(field.paramEntityWithConstructor, + field.paramEntityWithFromString, field.paramEntityWithValueOf, + field.setParamEntityWithFromString, + field.sortedSetParamEntityWithFromString, + field.listParamEntityWithFromString, FIELD); + setReturnValues(field.inner.paramEntityWithConstructor, + field.inner.paramEntityWithFromString, + field.inner.paramEntityWithValueOf, + field.inner.setParamEntityWithFromString, + field.inner.sortedSetParamEntityWithFromString, + field.inner.listParamEntityWithFromString, Constants.INNER + FIELD); + return sb.toString(); + } + + @GET + @Path("Field/" + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "/{" + + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "}/{" + Constants.INNER + + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldConstructor() { + return field(); + } + + @GET + @Path("Field/" + Constants.PARAM_ENTITY_WITH_FROMSTRING + "/{" + + Constants.PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.PARAM_ENTITY_WITH_FROMSTRING + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldFromString() { + return field(); + } + + @GET + @Path("Field/" + Constants.PARAM_ENTITY_WITH_VALUEOF + "/{" + + Constants.PARAM_ENTITY_WITH_VALUEOF + "}/{" + Constants.INNER + + Constants.PARAM_ENTITY_WITH_VALUEOF + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldValueOf() { + return field(); + } + + @GET + @Path("Field/" + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING + "/{" + + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldList() { + return field(); + } + + @GET + @Path("Field/" + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING + "/{" + + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldSet() { + return field(); + } + + @GET + @Path("Field/" + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING + "/{" + + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING + "}/{" + + Constants.INNER + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING + + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldSortedSet() { + return field(); + } + + @GET + @Path("Param") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandling(@BeanParam PathBeanParamEntity bean) { + sb = new StringBuilder(); + setReturnValues(bean.paramEntityWithConstructor, + bean.paramEntityWithFromString, bean.paramEntityWithValueOf, + bean.setParamEntityWithFromString, + bean.sortedSetParamEntityWithFromString, + bean.listParamEntityWithFromString, PARAM); + setReturnValues(bean.inner.paramEntityWithConstructor, + bean.inner.paramEntityWithFromString, bean.inner.paramEntityWithValueOf, + bean.inner.setParamEntityWithFromString, + bean.inner.sortedSetParamEntityWithFromString, + bean.inner.listParamEntityWithFromString, Constants.INNER + PARAM); + return sb.toString(); + } + + @GET + @Path("Param/" + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "/{" + + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "}/{" + Constants.INNER + + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingConstructor( + @BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/" + Constants.PARAM_ENTITY_WITH_FROMSTRING + "/{" + + Constants.PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.PARAM_ENTITY_WITH_FROMSTRING + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingFromString( + @BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/" + Constants.PARAM_ENTITY_WITH_VALUEOF + "/{" + + Constants.PARAM_ENTITY_WITH_VALUEOF + "}/{" + Constants.INNER + + Constants.PARAM_ENTITY_WITH_VALUEOF + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingValueOf( + @BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/" + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING + "/{" + + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingList(@BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/" + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING + "/{" + + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingSet(@BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/" + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING + "/{" + + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING + "}/{" + + Constants.INNER + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING + + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingSortedSet( + @BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/1/" + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME + "/{" + + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME + "}/{" + Constants.INNER + + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingThrowingByNameFirst( + @BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/2/" + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME + "/{" + + Constants.PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingThrowingByNameSecond( + @BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/1/" + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION + "/{" + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION + "}/{" + + Constants.INNER + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingThrowingWAEFirst( + @BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Param/2/" + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION + "/{" + + Constants.PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandlingThrowingWAESecond( + @BeanParam PathBeanParamEntity bean) { + return stringParamHandling(bean); + } + + @GET + @Path("Field/1/" + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME + "/{" + + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME + "}/{" + Constants.INNER + + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldThrowingByNameFirst() { + return field(); + } + + @GET + @Path("Field/2/" + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME + "/{" + + Constants.PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldThrowingByNameSecond() { + return field(); + } + + @GET + @Path("Field/1/" + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION + "/{" + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION + "}/{" + + Constants.INNER + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldThrowingWAEFirst() { + return field(); + } + + @GET + @Path("Field/2/" + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION + "/{" + + Constants.PARAM_ENTITY_WITH_FROMSTRING + "}/{" + Constants.INNER + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION + "}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String fieldThrowingWAESecond() { + return field(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/AppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/AppConfig.java new file mode 100644 index 0000000..985a6a5 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/AppConfig.java
@@ -0,0 +1,31 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.plain; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.core.Application; + +public class AppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/JAXRSClientIT.java new file mode 100644 index 0000000..6cf6f70 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/JAXRSClientIT.java
@@ -0,0 +1,395 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.plain; +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.tck.common.client.JaxrsCommonClient; + +import jakarta.ws.rs.core.MediaType; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + */ +/** + * Plain String to String parameter conversion into @BeanParam annotated bean + * + * @since 2.0.1 + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JaxrsCommonClient { + + private static final long serialVersionUID = 201; + + private static final String CONTENT = "Anything"; + + private static final String FIRST = "FIRST"; + + private static final String SECOND = "SECOND"; + + private static final String THIRD = "Third"; + + private static final String FOURTH = "Fourth"; + + private static final String FIFTH = "Fifth"; + + private static final String SIXTH = "Sixth"; + + private static final String SEVENTH = "Seventh"; + + private static final String EIGHTH = "Eighth"; + + private static final String NINETH = "Nineth"; + + private static final String TENTH = "Tenth"; + + private static final String ELEVENTH = "Eleventh"; + + private static final String TWELVENTH = "Twelveth"; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_beanparam_plain_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/beanparam/plain/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_beanparam_plain_web.war"); + archive.addClasses(AppConfig.class, Resource.class, + jakarta.ws.rs.tck.ee.rs.beanparam.bean.BeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.beanparam.bean.InnerBeanParamEntity.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* + * @testName: queryParamInParamTest + * + * @assertion_ids: JAXRS:SPEC:3.2; + * + * @test_Strategy: Make sure @QueryParam works in @BeanParam annotated bean + */ + @Test + public void queryParamInParamTest() throws Fault { + String[] reqArgs = getRequestArguments("Query"); + String request = buildRequestQuery(Request.POST, "queryparam", reqArgs[0], + reqArgs[1]); + invoke(request); + } + + /* + * @testName: queryParamOnFieldTest + * + * @assertion_ids: JAXRS:SPEC:3.2; + * + * @test_Strategy: Make sure @QueryParam works in @BeanParam annotated bean + */ + @Test + public void queryParamOnFieldTest() throws Fault { + String[] reqArgs = getRequestArguments("Query"); + String request = buildRequestQuery(Request.POST, "queryfield", reqArgs[0], + reqArgs[1]); + invoke(request); + } + + /* + * @testName: formParamInParamTest + * + * @assertion_ids: JAXRS:SPEC:12; + * + * @test_Strategy: Make sure @FormParam works in @BeanParam annotated bean + */ + @Test + public void formParamInParamTest() throws Fault { + String[] reqArgs = getRequestArguments("Form"); + String request = buildRequest(Request.POST, "formparam"); + invoke(request, andize(CONTENT, reqArgs[0], reqArgs[1])); + } + + /* + * @testName: formParamOnFieldTest + * + * @assertion_ids: JAXRS:SPEC:12; + * + * @test_Strategy: Make sure @FormParam works in @BeanParam annotated bean + */ + @Test + public void formParamOnFieldTest() throws Fault { + String[] reqArgs = getRequestArguments("Form"); + String request = buildRequest(Request.POST, "formfield"); + invoke(request, andize(CONTENT, reqArgs[0], reqArgs[1])); + } + + /* + * @testName: headerParamInParamTest + * + * @assertion_ids: JAXRS:SPEC:3.5; + * + * @test_Strategy: Make sure @HeaderParam works in @BeanParam annotated bean + */ + @Test + public void headerParamInParamTest() throws Fault { + String[] reqArgs = getRequestArguments("Header"); + String request = buildRequest(Request.POST, "headerparam"); + setProperty(Property.REQUEST_HEADERS, reqArgs[0].replace('=', ':')); + setProperty(Property.REQUEST_HEADERS, reqArgs[1].replace('=', ':')); + invoke(request); + } + + /* + * @testName: headerParamOnFieldTest + * + * @assertion_ids: JAXRS:SPEC:3.5; + * + * @test_Strategy: Make sure @HeaderParam works in @BeanParam annotated bean + */ + @Test + public void headerParamOnFieldTest() throws Fault { + String[] reqArgs = getRequestArguments("Header"); + String request = buildRequest(Request.POST, "headerfield"); + setProperty(Property.REQUEST_HEADERS, reqArgs[0].replace('=', ':')); + setProperty(Property.REQUEST_HEADERS, reqArgs[1].replace('=', ':')); + invoke(request); + } + + /* + * @testName: pathParamInParamTest + * + * @assertion_ids: JAXRS:SPEC:3.3; + * + * @test_Strategy: Make sure @PathParam works in @BeanParam annotated bean + */ + @Test + public void pathParamInParamTest() throws Fault { + String request = buildRequest(Request.POST, "pathparam/", FIRST, "/", + SECOND); + invoke(request); + } + + /* + * @testName: pathParamOnFieldTest + * + * @assertion_ids: JAXRS:SPEC:3.3; + * + * @test_Strategy: Make sure @PathParam works in @BeanParam annotated bean + */ + @Test + public void pathParamOnFieldTest() throws Fault { + String request = buildRequest(Request.POST, "pathfield/", FIRST, "/", + SECOND); + invoke(request); + } + + /* + * @testName: matrixParamInParamTest + * + * @assertion_ids: JAXRS:SPEC:3.1; + * + * @test_Strategy: Make sure @MatrixParam works in @BeanParam annotated bean + */ + @Test + public void matrixParamInParamTest() throws Fault { + String[] reqArgs = getRequestArguments("Matrix"); + String request = buildRequest(Request.POST, "matrixparam;", reqArgs[0], ";", + reqArgs[1]); + invoke(request); + } + + /* + * @testName: matrixParamOnFieldTest + * + * @assertion_ids: JAXRS:SPEC:3.1; + * + * @test_Strategy: Make sure @MatrixParam works in @BeanParam annotated bean + */ + @Test + public void matrixParamOnFieldTest() throws Fault { + String[] reqArgs = getRequestArguments("Matrix"); + String request = buildRequest(Request.POST, "matrixfield;", reqArgs[0], ";", + reqArgs[1]); + invoke(request); + } + + /* + * @testName: cookieParamInParamTest + * + * @assertion_ids: JAXRS:SPEC:3.4; + * + * @test_Strategy: Make sure @CookieParam works in @BeanParam annotated bean + */ + @Test + public void cookieParamInParamTest() throws Fault { + String request = buildRequest(Request.POST, "cookieparam"); + buildCookie(); + invoke(request); + } + + /* + * @testName: cookieParamOnFieldTest + * + * @assertion_ids: JAXRS:SPEC:3.4; + * + * @test_Strategy: Make sure @CookieParam works in @BeanParam annotated bean + */ + @Test + public void cookieParamOnFieldTest() throws Fault { + String request = buildRequest(Request.POST, "cookiefield"); + buildCookie(); + invoke(request); + } + + /* + * @testName: allParamsInParamTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:3.2; JAXRS:SPEC:3.3; + * JAXRS:SPEC:3.4; JAXRS:SPEC:3.5; JAXRS:SPEC:12; + * + * @test_Strategy: Make sure all params works in @BeanParam annotated bean + */ + @Test + public void allParamsInParamTest() throws Fault { + allParamsTest("allparam"); + } + + /* + * @testName: allParamsOnFieldTest + * + * @assertion_ids: JAXRS:SPEC:3.1; JAXRS:SPEC:3.2; JAXRS:SPEC:3.3; + * JAXRS:SPEC:3.4; JAXRS:SPEC:3.5; JAXRS:SPEC:12; + * + * @test_Strategy: Make sure all params works in @BeanParam annotated bean + */ + @Test + public void allParamsOnFieldTest() throws Fault { + allParamsTest("allfield"); + } + + private void allParamsTest(String path) throws Fault { + String[] formArgs = getRequestArguments("Form", THIRD, FOURTH); + String[] headerArgs = getRequestArguments("Header", FIFTH, SIXTH); + String[] matrixArgs = getRequestArguments("Matrix", SEVENTH, EIGHTH); + String[] queryArgs = getRequestArguments("Query", ELEVENTH, TWELVENTH); + String request = buildRequest(Request.POST, path, "/", NINETH, "/", TENTH, + ";", matrixArgs[0], ";", matrixArgs[1], "?", + andize(queryArgs[0], queryArgs[1])); + + buildCookie(); + setProperty(Property.REQUEST_HEADERS, headerArgs[0].replace('=', ':')); + setProperty(Property.REQUEST_HEADERS, headerArgs[1].replace('=', ':')); + + setProperty(Property.SEARCH_STRING, THIRD); + setProperty(Property.SEARCH_STRING, FOURTH); + setProperty(Property.SEARCH_STRING, FIFTH); + setProperty(Property.SEARCH_STRING, SIXTH); + setProperty(Property.SEARCH_STRING, SEVENTH); + setProperty(Property.SEARCH_STRING, EIGHTH); + setProperty(Property.SEARCH_STRING, NINETH); + setProperty(Property.SEARCH_STRING, TENTH); + setProperty(Property.SEARCH_STRING, ELEVENTH); + setProperty(Property.SEARCH_STRING, TWELVENTH); + invoke(request, andize(CONTENT, formArgs[0], formArgs[1])); + } + + // /////////////////////////////////////////////////////////////////////// + private static String[] getRequestArguments(String type) { + return getRequestArguments(type, FIRST, SECOND); + } + + private static String[] getRequestArguments(String type, String first, + String second) { + String[] args = new String[2]; + args[0] = new StringBuilder().append("bpe").append(type).append("=") + .append(first).toString(); + args[1] = new StringBuilder().append("inner").append(type).append("=") + .append(second).toString(); + return args; + } + + private void invoke(String request, String content) throws Fault { + setProperty(Property.REQUEST, request); + setProperty(Property.REQUEST_HEADERS, + buildContentType(MediaType.APPLICATION_FORM_URLENCODED_TYPE)); + setProperty(Property.CONTENT, content); + setProperty(Property.SEARCH_STRING, content); + setProperty(Property.SEARCH_STRING, FIRST); + setProperty(Property.SEARCH_STRING, SECOND); + invoke(); + } + + private void invoke(String request) throws Fault { + invoke(request, CONTENT); + } + + private String buildRequestQuery(Request type, String path, String... query) { + StringBuilder sb = new StringBuilder(); + sb.append(buildRequest(type, path)); + sb.append("?").append(andize(query)); + return sb.toString(); + } + + private static String andize(String... args) { + StringBuilder sb = new StringBuilder(); + if (args != null) + for (int i = 0; i != args.length; i++) { + if (i != 0) + sb.append("&"); + sb.append(args[i]); + } + return sb.toString(); + } + + private void buildCookie() { + String[] reqArgs = getRequestArguments("Cookie"); + StringBuilder sb = new StringBuilder().append("Cookie:").append(reqArgs[0]) + .append(";Version=1;").append(reqArgs[1]).append(";Version=1"); + + setProperty(Property.REQUEST_HEADERS, sb.toString()); + } +};
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/Resource.java new file mode 100644 index 0000000..fd1d003 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/plain/Resource.java
@@ -0,0 +1,153 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.plain; + +import jakarta.ws.rs.tck.ee.rs.beanparam.bean.BeanParamEntity; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +@Path("resource") +public class Resource { + + @BeanParam + BeanParamEntity fieldBeanParam; + + @POST + @Path("queryparam") + public String queryParam(String content, @BeanParam BeanParamEntity bean) { + return appnd(content, bean.bpeQuery, bean.bpeInner.innerQuery); + } + + @POST + @Path("queryfield") + public String queryField(String content) { + return appnd(content, fieldBeanParam.bpeQuery, + fieldBeanParam.bpeInner.innerQuery); + } + + @POST + @Path("formparam") + public String formParam(String content, @BeanParam BeanParamEntity bean) { + return appnd(content, bean.bpeForm, bean.bpeInner.innerForm); + } + + @POST + @Path("formfield") + public String formField(String content) { + return appnd(content, fieldBeanParam.bpeForm, + fieldBeanParam.bpeInner.innerForm); + } + + @POST + @Path("headerparam") + public String headerParam(String content, @BeanParam BeanParamEntity bean) { + return appnd(content, bean.bpeHeader, bean.bpeInner.innerHeader); + } + + @POST + @Path("headerfield") + public String headerField(String content) { + return appnd(content, fieldBeanParam.bpeHeader, + fieldBeanParam.bpeInner.innerHeader); + } + + @POST + @Path("pathparam/{bpePath}/{innerPath}") + public String pathParam(String content, @BeanParam BeanParamEntity bean) { + return appnd(content, bean.bpePath, bean.bpeInner.innerPath); + } + + @POST + @Path("pathfield/{bpePath}/{innerPath}") + public String pathField(String content) { + return appnd(content, fieldBeanParam.bpePath, + fieldBeanParam.bpeInner.innerPath); + } + + @POST + @Path("matrixparam") + public String matrixParam(String content, @BeanParam BeanParamEntity bean) { + return appnd(content, bean.bpeMatrix, bean.bpeInner.innerMatrix); + } + + @POST + @Path("matrixfield") + public String matrixField(String content) { + return appnd(content, fieldBeanParam.bpeMatrix, + fieldBeanParam.bpeInner.innerMatrix); + } + + @POST + @Path("cookieparam") + public String cookieParam(String content, @BeanParam BeanParamEntity bean) { + return appnd(content, bean.bpeCookie, bean.bpeInner.innerCookie); + } + + @POST + @Path("cookiefield") + public String cookieField(String content) { + return appnd(content, fieldBeanParam.bpeCookie, + fieldBeanParam.bpeInner.innerCookie); + } + + @POST + @Path("allfield/{bpePath}/{innerPath}") + public String everyField(String content) { + return appnd(fieldBeanParam.bpeForm // + , fieldBeanParam.bpeInner.innerForm // + , fieldBeanParam.bpeHeader // + , fieldBeanParam.bpeInner.innerHeader // + , fieldBeanParam.bpeMatrix // + , fieldBeanParam.bpeInner.innerMatrix // + , fieldBeanParam.bpePath // + , fieldBeanParam.bpeInner.innerPath // + , fieldBeanParam.bpeQuery // + , fieldBeanParam.bpeInner.innerQuery // + , content // + , fieldBeanParam.bpeCookie // + , fieldBeanParam.bpeInner.innerCookie); + } + + @POST + @Path("allparam/{bpePath}/{innerPath}") + public String everyParam(String content, @BeanParam BeanParamEntity bean) { + return appnd(bean.bpeForm // + , bean.bpeInner.innerForm // + , bean.bpeHeader // + , bean.bpeInner.innerHeader // + , bean.bpeMatrix // + , bean.bpeInner.innerMatrix // + , bean.bpePath // + , bean.bpeInner.innerPath // + , bean.bpeQuery // + , bean.bpeInner.innerQuery // + , content // + , bean.bpeCookie // + , bean.bpeInner.innerCookie); + } + + private static String appnd(String... strings) { + StringBuilder sb = new StringBuilder(); + if (strings != null) + for (String s : strings) + sb.append(s); + return sb.toString(); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/bean/InnerQueryBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/bean/InnerQueryBeanParamEntity.java new file mode 100644 index 0000000..b45fa4a --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/bean/InnerQueryBeanParamEntity.java
@@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.query.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Encoded; +import jakarta.ws.rs.QueryParam; + +public class InnerQueryBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.INNER + Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.INNER + Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.INNER + + Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.INNER + Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @QueryParam(Constants.INNER + + Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @QueryParam(Constants.INNER + Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/bean/QueryBeanParamEntity.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/bean/QueryBeanParamEntity.java new file mode 100644 index 0000000..010b62a --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/bean/QueryBeanParamEntity.java
@@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.query.bean; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Encoded; +import jakarta.ws.rs.QueryParam; + +public class QueryBeanParamEntity { + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.PARAM_ENTITY_WITH_CONSTRUCTOR) + public ParamEntityWithConstructor paramEntityWithConstructor; + + @Encoded + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.PARAM_ENTITY_WITH_FROMSTRING) + public ParamEntityWithFromString paramEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.PARAM_ENTITY_WITH_VALUEOF) + public ParamEntityWithValueOf paramEntityWithValueOf; + + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.SET_PARAM_ENTITY_WITH_FROMSTRING) + public Set<ParamEntityWithFromString> setParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.SORTED_SET_PARAM_ENTITY_WITH_FROMSTRING) + public SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString; + + @DefaultValue(Constants.DEFAULT_VALUE) + @QueryParam(Constants.LIST_PARAM_ENTITY_WITH_FROMSTRING) + public List<ParamEntityWithFromString> listParamEntityWithFromString; + + @QueryParam(Constants.ENTITY_THROWING_WEBAPPLICATIONEXCEPTION) + public ParamEntityThrowingWebApplicationException entityThrowingWebApplicationException; + + @QueryParam(Constants.ENTITY_THROWING_EXCEPTION_BY_NAME) + public ParamEntityThrowingExceptionGivenByName entityThrowingExceptionGivenByName; + + @BeanParam + public InnerQueryBeanParamEntity inner; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/AppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/AppConfig.java new file mode 100644 index 0000000..d496b9e --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/AppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.query.plain; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +public class AppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/JAXRSClientIT.java new file mode 100644 index 0000000..4a95efd --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/JAXRSClientIT.java
@@ -0,0 +1,358 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.query.plain; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.beanparam.BeanParamCommonClient; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * @since 2.0.1 + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends BeanParamCommonClient { + + private static final long serialVersionUID = 201L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_beanparam_query_plain_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_beanparam_query_plain_web.war"); + archive.addClasses(AppConfig.class, Resource.class, + jakarta.ws.rs.tck.ee.rs.beanparam.query.bean.QueryBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.beanparam.query.bean.InnerQueryBeanParamEntity.class, + jakarta.ws.rs.tck.ee.rs.Constants.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + + /* Run test */ + + /* + * @testName: queryParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.2; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryParamEntityWithConstructorTest() throws Fault { + super.paramEntityWithConstructorTest(); + } + + /* + * @testName: queryParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.3; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryParamEntityWithValueOfTest() throws Fault { + super.paramEntityWithValueOfTest(); + } + + /* + * @testName: queryParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.3; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryParamEntityWithFromStringTest() throws Fault { + super.paramEntityWithFromStringTest(); + } + + /* + * @testName: queryParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryParamSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: queryParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryParamSortedSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: queryParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:12; + * JAXRS:SPEC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryParamListEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: queryFieldParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.2; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryFieldParamEntityWithConstructorTest() throws Fault { + super.fieldEntityWithConstructorTest(); + } + + /* + * @testName: queryFieldParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.3; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryFieldParamEntityWithValueOfTest() throws Fault { + super.fieldEntityWithValueOfTest(); + } + + /* + * @testName: queryFieldParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.3; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryFieldParamEntityWithFromStringTest() throws Fault { + super.fieldEntityWithFromStringTest(); + } + + /* + * @testName: queryFieldParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryFieldParamSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: queryFieldParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryFieldParamSortedSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: queryFieldParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:5.4; JAXRS:SPEC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void queryFieldParamListEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: queryParamEntityWithEncodedTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:7; JAXRS:SPEC:12; + * JAXRS:SPEC:12.2; + * + * @test_Strategy: Verify that named QueryParam @Encoded is handled + */ + @Test + public void queryParamEntityWithEncodedTest() throws Fault { + super.paramEntityWithEncodedTest(); + } + + /* + * @testName: queryFieldParamEntityWithEncodedTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:7; + * + * @test_Strategy: Verify that named QueryParam @Encoded is handled + */ + @Test + public void queryFieldParamEntityWithEncodedTest() throws Fault { + super.fieldEntityWithEncodedTest(); + } + + /* + * @testName: queryParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see Section 3.2. + */ + @Test + public void queryParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: queryFieldThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.2; JAXRS:SPEC:8; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + @Test + public void queryFieldThrowingWebApplicationExceptionTest() throws Fault { + super.fieldThrowingWebApplicationExceptionTest(); + super.fieldThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: queryParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + */ + @Test + public void queryParamThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.paramThrowingIllegalArgumentExceptionTest(); + } + + /* + * @testName: queryFieldThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.1; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @MatrixParam, + * + * @QueryParam or @PathParam then an implementation MUST generate a + * WebApplicationException that wraps the thrown exception with a not found + * response (404 status) and no entity; + */ + @Test + public void queryFieldThrowingIllegalArgumentExceptionTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + setProperty(Property.UNORDERED_SEARCH_STRING, Status.NOT_FOUND.name()); + super.fieldThrowingIllegalArgumentExceptionTest(); + } + + @Override + protected String buildRequest(String param) { + return buildRequest(Request.GET, fieldBeanParam, "?", param, "&", + Constants.INNER, param); + } + + @Override + protected// + String buildRequestForException(String param, int entity) throws Fault { + if (entity == 1) + return buildRequest(Request.GET, fieldBeanParam, "?", param); + else + return buildRequest(Request.GET, fieldBeanParam, "?", Constants.INNER, + param); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/Resource.java new file mode 100644 index 0000000..70aa412 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/Resource.java
@@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.beanparam.query.plain; + +import jakarta.ws.rs.tck.ee.rs.Constants; +import jakarta.ws.rs.tck.ee.rs.ParamTest; +import jakarta.ws.rs.tck.ee.rs.beanparam.query.bean.QueryBeanParamEntity; + +import jakarta.ws.rs.BeanParam; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path(value = "resource") +public class Resource extends ParamTest { + + @BeanParam + QueryBeanParamEntity field; + + @GET + @Path("Field") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String field() { + sb = new StringBuilder(); + setReturnValues(field.paramEntityWithConstructor, + field.paramEntityWithFromString, field.paramEntityWithValueOf, + field.setParamEntityWithFromString, + field.sortedSetParamEntityWithFromString, + field.listParamEntityWithFromString, FIELD); + setReturnValues(field.inner.paramEntityWithConstructor, + field.inner.paramEntityWithFromString, + field.inner.paramEntityWithValueOf, + field.inner.setParamEntityWithFromString, + field.inner.sortedSetParamEntityWithFromString, + field.inner.listParamEntityWithFromString, Constants.INNER + FIELD); + return sb.toString(); + } + + @GET + @Path("Param") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public String stringParamHandling(@BeanParam QueryBeanParamEntity bean) { + sb = new StringBuilder(); + setReturnValues(bean.paramEntityWithConstructor, + bean.paramEntityWithFromString, bean.paramEntityWithValueOf, + bean.setParamEntityWithFromString, + bean.sortedSetParamEntityWithFromString, + bean.listParamEntityWithFromString, PARAM); + setReturnValues(bean.inner.paramEntityWithConstructor, + bean.inner.paramEntityWithFromString, bean.inner.paramEntityWithValueOf, + bean.inner.setParamEntityWithFromString, + bean.inner.sortedSetParamEntityWithFromString, + bean.inner.listParamEntityWithFromString, Constants.INNER + PARAM); + return sb.toString(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ClientSideReader.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ClientSideReader.java new file mode 100644 index 0000000..df93c50 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ClientSideReader.java
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.constrainedto; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import jakarta.ws.rs.ConstrainedTo; +import jakarta.ws.rs.RuntimeType; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyReader; +import jakarta.ws.rs.ext.Provider; + +@Provider +@ConstrainedTo(value = RuntimeType.CLIENT) +public class ClientSideReader implements MessageBodyReader<String> { + + public static final String FAKE_MESSAGE = "The fake reader on client side"; + + public static final MediaType MEDIA_TYPE = new MediaType("reader", + "clientside"); + + @Override + public boolean isReadable(Class<?> type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + return mediaType.equals(MEDIA_TYPE); + } + + @Override + public String readFrom(Class<String> type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap<String, String> httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + return FAKE_MESSAGE; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ClientSideWriter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ClientSideWriter.java new file mode 100644 index 0000000..6046a2b --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ClientSideWriter.java
@@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.constrainedto; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import java.nio.charset.Charset; + +import jakarta.ws.rs.ConstrainedTo; +import jakarta.ws.rs.RuntimeType; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyWriter; +import jakarta.ws.rs.ext.Provider; + +@Provider +@ConstrainedTo(value = RuntimeType.CLIENT) +public class ClientSideWriter implements MessageBodyWriter<String> { + + public static final String FAKE_MESSAGE = "The fake writer on client side"; + + public static final MediaType MEDIA_TYPE = new MediaType("writer", + "clientside"); + + @Override + public boolean isWriteable(Class<?> type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + return mediaType.equals(MEDIA_TYPE); + } + + @Override + public long getSize(String t, Class<?> type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + return FAKE_MESSAGE.length(); + } + + @Override + public void writeTo(String t, Class<?> type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) + throws IOException, WebApplicationException { + entityStream.write(FAKE_MESSAGE.getBytes(Charset.defaultCharset())); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/JAXRSClientIT.java new file mode 100644 index 0000000..0be9edb --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/JAXRSClientIT.java
@@ -0,0 +1,245 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.constrainedto; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.common.client.JaxrsCommonClient; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + */ + +/** + * test_strategy_common: If such a annotation is present, the JAX-RS runtime + * will enforce the specified usage restriction. - Not optional + * + * It is a configuration error to constraint a JAX-RS provider implementation to + * a run-time context in which the provider cannot be applied. In such case a + * JAX-RS runtime SHOULD inform a user about the issue and ignore the provider + * implementation in further processing - Should not throw exception, just + * ignore + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JaxrsCommonClient { + + private static final long serialVersionUID = 3343257931794865470L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_constrainedto_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException { + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/constrainedto/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_constrainedto_web.war"); + archive.addClasses(TSAppConfig.class, Resource.class, + ClientSideReader.class, ClientSideWriter.class, + ServerSideReader.class, ServerSideWriter.class); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* Run test */ + /* + * @testName: serverSideReaderIsUsedOnServerTest + * + * @assertion_ids: JAXRS:JAVADOC:969; + * + * @test_Strategy: jakarta.ws.rs.ConstrainedTo.value is used + */ + @Test + public void serverSideReaderIsUsedOnServerTest() throws Fault { + setProperty(Property.CONTENT, "Anything"); + setProperty(Property.SEARCH_STRING, ServerSideReader.FAKE_MESSAGE); + setProperty(Property.REQUEST, buildRequest(Request.POST, "echo")); + setProperty(Property.REQUEST_HEADERS, + buildContentType(ServerSideReader.MEDIA_TYPE)); + invoke(); + } + + /* + * @testName: clientSideReaderIsNotUsedOnServerTest + * + * @assertion_ids: JAXRS:JAVADOC:969; + * + * @test_Strategy: jakarta.ws.rs.ConstrainedTo.value is used + */ + @Test + public void clientSideReaderIsNotUsedOnServerTest() throws Fault { + setProperty(Property.CONTENT, Resource.MESSAGE); + setProperty(Property.SEARCH_STRING, Resource.MESSAGE); + setProperty(Property.REQUEST, buildRequest(Request.POST, "echo")); + setProperty(Property.REQUEST_HEADERS, + buildContentType(ClientSideReader.MEDIA_TYPE)); + invoke(); + } + + /* + * @testName: serverSideWriterIsUsedOnServerTest + * + * @assertion_ids: JAXRS:JAVADOC:969; + * + * @test_Strategy: jakarta.ws.rs.ConstrainedTo.value is used + */ + @Test + public void serverSideWriterIsUsedOnServerTest() throws Fault { + setProperty(Property.CONTENT, Resource.MESSAGE); + setProperty(Property.SEARCH_STRING, ServerSideWriter.FAKE_MESSAGE); + setProperty(Property.REQUEST, buildRequest(Request.POST, "echo")); + setProperty(Property.REQUEST_HEADERS, + buildContentType(ServerSideWriter.MEDIA_TYPE)); + invoke(); + } + + /* + * @testName: clientSideWriterIsNotUsedOnServerTest + * + * @assertion_ids: JAXRS:JAVADOC:969; + * + * @test_Strategy: jakarta.ws.rs.ConstrainedTo.value is used + */ + @Test + public void clientSideWriterIsNotUsedOnServerTest() throws Fault { + setPrintEntity(true); + setProperty(Property.CONTENT, Resource.MESSAGE); + setProperty(Property.SEARCH_STRING, Resource.MESSAGE); + setProperty(Property.REQUEST, buildRequest(Request.POST, "echo")); + setProperty(Property.REQUEST_HEADERS, + buildContentType(ClientSideWriter.MEDIA_TYPE)); + invoke(); + } + + /* + * @testName: serverSideReaderIsNotUsedOnClientTest + * + * @assertion_ids: JAXRS:JAVADOC:969; + * + * @test_Strategy: jakarta.ws.rs.ConstrainedTo.value is used + */ + @Test + public void serverSideReaderIsNotUsedOnClientTest() throws Fault { + addProviders(); + setProperty(Property.CONTENT, ServerSideReader.MEDIA_TYPE.toString()); + setProperty(Property.SEARCH_STRING, Resource.MESSAGE); + setProperty(Property.REQUEST, buildRequest(Request.POST, "media")); + setProperty(Property.REQUEST_HEADERS, + buildContentType(MediaType.TEXT_PLAIN_TYPE)); + invoke(); + } + + /* + * @testName: clientSideReaderIsUsedOnClientTest + * + * @assertion_ids: JAXRS:JAVADOC:969; + * + * @test_Strategy: jakarta.ws.rs.ConstrainedTo.value is used + */ + @Test + public void clientSideReaderIsUsedOnClientTest() throws Fault { + addProviders(); + setProperty(Property.CONTENT, ClientSideReader.MEDIA_TYPE.toString()); + setProperty(Property.SEARCH_STRING, ClientSideReader.FAKE_MESSAGE); + setProperty(Property.REQUEST, buildRequest(Request.POST, "media")); + setProperty(Property.REQUEST_HEADERS, + buildContentType(MediaType.TEXT_PLAIN_TYPE)); + invoke(); + } + + /* + * @testName: serverSideWriterIsNotUsedOnClientTest + * + * @assertion_ids: JAXRS:JAVADOC:969; + * + * @test_Strategy: jakarta.ws.rs.ConstrainedTo.value is used + */ + @Test + public void serverSideWriterIsNotUsedOnClientTest() throws Fault { + addProviders(); + setProperty(Property.CONTENT, ServerSideWriter.MEDIA_TYPE.toString()); + setProperty(Property.SEARCH_STRING, Resource.MESSAGE); + setProperty(Property.REQUEST, buildRequest(Request.POST, "media")); + setProperty(Property.REQUEST_HEADERS, + buildContentType(MediaType.TEXT_PLAIN_TYPE)); + invoke(); + } + + /* + * @testName: clientSideWriterIsUsedOnClientTest + * + * @assertion_ids: JAXRS:JAVADOC:969; + * + * @test_Strategy: jakarta.ws.rs.ConstrainedTo.value is used this goes to + * special resource method with response 204 to check the ClientSideWriter + * worked on client rather then let it (wrongly) work on server and falsely + * pass + */ + @Test + public void clientSideWriterIsUsedOnClientTest() throws Fault { + addProviders(); + setProperty(Property.CONTENT, Resource.MESSAGE); + setProperty(Property.REQUEST, buildRequest(Request.POST, "clientwriter")); + setProperty(Property.REQUEST_HEADERS, + buildContentType(ClientSideWriter.MEDIA_TYPE)); + setProperty(Property.STATUS_CODE, getStatusCode(Status.NO_CONTENT)); + invoke(); + } + + // ///////////////////////////////////////////////////////////////////// + protected void addProviders() { + addProvider(ServerSideReader.class); + addProvider(ClientSideReader.class); + addProvider(ServerSideWriter.class); + addProvider(ClientSideWriter.class); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/Resource.java new file mode 100644 index 0000000..f8bc120 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/Resource.java
@@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.constrainedto; + +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +@Path("resource") +public class Resource { + public static final String MESSAGE = "ConstrainedTo message"; + + @POST + @Path("echo") + public String post(String entity) { + return entity; + } + + @POST + @Path("media") + public Response buildResponseWithMedia(String media) { + Response r = Response.ok().entity(MESSAGE).type(media).build(); + return r; + } + + @POST + @Path("clientwriter") + public Response return201IfWriterWorkedOnClient(String entity) { + Response r = null; + if (ClientSideWriter.FAKE_MESSAGE.equals(entity)) + r = Response.noContent().build(); + else + r = Response.ok().build(); + return r; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ServerSideReader.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ServerSideReader.java new file mode 100644 index 0000000..0bcdba4 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ServerSideReader.java
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.constrainedto; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import jakarta.ws.rs.ConstrainedTo; +import jakarta.ws.rs.RuntimeType; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyReader; +import jakarta.ws.rs.ext.Provider; + +@Provider +@ConstrainedTo(value = RuntimeType.SERVER) +public class ServerSideReader implements MessageBodyReader<String> { + + public static final String FAKE_MESSAGE = "The fake reader on server side"; + + public static final MediaType MEDIA_TYPE = new MediaType("reader", + "serverside"); + + @Override + public boolean isReadable(Class<?> type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + return mediaType.equals(MEDIA_TYPE); + } + + @Override + public String readFrom(Class<String> type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap<String, String> httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + return FAKE_MESSAGE; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ServerSideWriter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ServerSideWriter.java new file mode 100644 index 0000000..4a48c71 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/ServerSideWriter.java
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.constrainedto; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import jakarta.ws.rs.ConstrainedTo; +import jakarta.ws.rs.RuntimeType; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyReader; +import jakarta.ws.rs.ext.Provider; + +@Provider +@ConstrainedTo(value = RuntimeType.SERVER) +public class ServerSideWriter implements MessageBodyReader<String> { + + public static final String FAKE_MESSAGE = "The fake writer on server side"; + + public static final MediaType MEDIA_TYPE = new MediaType("writer", + "serverside"); + + @Override + public boolean isReadable(Class<?> type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + return mediaType.equals(MEDIA_TYPE); + } + + @Override + public String readFrom(Class<String> type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap<String, String> httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + return FAKE_MESSAGE; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/TSAppConfig.java new file mode 100644 index 0000000..5baf2a7 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/constrainedto/TSAppConfig.java
@@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.constrainedto; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.core.Application; + +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(ClientSideReader.class); // test this is not used + resources.add(ServerSideReader.class); // this one only should be used + resources.add(ClientSideWriter.class); // this is not used + resources.add(ServerSideWriter.class); // this one would be used + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/ContextOperation.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/ContextOperation.java new file mode 100644 index 0000000..d2501c8 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/ContextOperation.java
@@ -0,0 +1,21 @@ +/* + * Copyright (c) 2012, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext; + +public enum ContextOperation { + ABORTWITH, GETACCEPTABLELANGUAGES, GETACCEPTABLELANGUAGESISREADONLY, GETACCEPTABLEMEDIATYPES, GETACCEPTABLEMEDIATYPESISREADONLY, GETCOOKIES, GETCOOKIESISREADONLY, GETDATE, GETENTITYSTREAM, GETHEADERS, GETHEADERSISMUTABLE, GETHEADERSTRING2, GETLANGUAGE, GETLENGTH, GETMEDIATYPE, GETMETHOD, GETPROPERTY, GETPROPERTYNAMES, GETPROPERTYNAMESISREADONLY, GETREQUEST, GETSECURITYCONTEXT, GETURIINFO, HASENTITY, REMOVEPROPERTY, SETENTITYSTREAM, SETMETHOD, SETPROPERTY, SETPROPERTYNULL, SETPROPERTYCONTEXT, SETREQUESTURI1, SETREQUESTURI2, SETSECURITYCONTEXT; +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/JAXRSClientIT.java new file mode 100644 index 0000000..274ad50 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/JAXRSClientIT.java
@@ -0,0 +1,822 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext; + +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; +import java.io.InputStream; +import java.io.IOException; + +import jakarta.ws.rs.tck.common.client.JaxrsCommonClient; +import jakarta.ws.rs.tck.common.util.JaxrsUtil; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.MediaType; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JaxrsCommonClient { + + private static final long serialVersionUID = 111355567568365703L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_container_requestcontext_web/resource"); + setPrintEntity(true); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException { + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/container/requestcontext/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_container_requestcontext_web.war"); + archive.addClasses(TSAppConfig.class, Resource.class, + ContextOperation.class, RequestFilter.class, SecondRequestFilter.class, + TemplateFilter.class, jakarta.ws.rs.tck.common.impl.SecurityContextImpl.class); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* + * @testName: abortWithTest + * + * @assertion_ids: JAXRS:JAVADOC:649; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Invoke HTTP DELETE method for the current request + * asynchronously. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void abortWithTest() throws Fault { + invokeRequestAndCheckResponse(ContextOperation.ABORTWITH); + } + + /* + * @testName: getAcceptableLanguagesTest + * + * @assertion_ids: JAXRS:JAVADOC:650; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get a read-only list of acceptable languages sorted + * according to their q-value, with highest preference first. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getAcceptableLanguagesTest() throws Fault { + setProperty(Property.REQUEST_HEADERS, "Accpet-Language:en-us"); + invokeRequestAndCheckResponse(ContextOperation.GETACCEPTABLELANGUAGES); + } + + /* + * @testName: getAcceptableLanguagesIsSortedTest + * + * @assertion_ids: JAXRS:JAVADOC:650; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get a read-only list of acceptable languages sorted + * according to their q-value, with highest preference first. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getAcceptableLanguagesIsSortedTest() throws Fault { + logMsg( + "Check the #getAcceptableLanguages is sorted according to their q-value"); + setProperty(Property.REQUEST_HEADERS, + "Accept-Language: da, en-gb;q=0.6, en-us;q=0.7"); + setProperty(Property.SEARCH_STRING, "da"); + setProperty(Property.SEARCH_STRING, "en-us"); + setProperty(Property.SEARCH_STRING, "en-gb"); + invokeRequestAndCheckResponse(ContextOperation.GETACCEPTABLELANGUAGES); + } + + /* + * @testName: getAcceptableLanguagesIsReadOnlyTest + * + * @assertion_ids: JAXRS:JAVADOC:650; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get a read-only list of acceptable languages sorted + * according to their q-value, with highest preference first. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getAcceptableLanguagesIsReadOnlyTest() throws Fault { + setProperty(Property.REQUEST_HEADERS, + "Accept-Language: da, en-gb;q=0.6, en-us;q=0.7"); + setProperty(Property.UNEXPECTED_RESPONSE_MATCH, "ca-fr"); + invokeRequestAndCheckResponse( + ContextOperation.GETACCEPTABLELANGUAGESISREADONLY); + } + + /* + * @testName: getAcceptableMediaTypesTest + * + * @assertion_ids: JAXRS:JAVADOC:651; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get a read-only list of acceptable languages sorted + * according to their q-value. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getAcceptableMediaTypesTest() throws Fault { + setProperty(Property.REQUEST_HEADERS, + buildAccept(MediaType.APPLICATION_JSON_TYPE)); + setProperty(Property.SEARCH_STRING, MediaType.APPLICATION_JSON); + invokeRequestAndCheckResponse(ContextOperation.GETACCEPTABLEMEDIATYPES); + } + + /* + * @testName: getAcceptableMediaTypesIsSortedTest + * + * @assertion_ids: JAXRS:JAVADOC:651; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get a read-only list of acceptable languages sorted + * according to their q-value. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getAcceptableMediaTypesIsSortedTest() throws Fault { + logMsg( + "Check the #getAcceptableMediaTypes is sorted according to their q-value"); + setProperty(Property.REQUEST_HEADERS, + "Accept: text/*;q=0.3, text/html;q=0.7, text/html;level=1,text/html;level=2;q=0.4, */*;q=0.5"); + setProperty(Property.SEARCH_STRING, "text/html;level=1"); + setProperty(Property.SEARCH_STRING, "text/html;q=0.7"); + setProperty(Property.SEARCH_STRING, "*/*;q=0.5"); + setProperty(Property.SEARCH_STRING, "text/html;level=2;q=0.4"); + setProperty(Property.SEARCH_STRING, "text/*;q=0.3"); + invokeRequestAndCheckResponse(ContextOperation.GETACCEPTABLEMEDIATYPES); + } + + /* + * @testName: getAcceptableMediaTypesIsReadOnlyTest + * + * @assertion_ids: JAXRS:JAVADOC:651; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get a read-only list of acceptable languages sorted + * according to their q-value. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getAcceptableMediaTypesIsReadOnlyTest() throws Fault { + setProperty(Property.REQUEST_HEADERS, buildAccept(MediaType.TEXT_XML_TYPE)); + setProperty(Property.UNEXPECTED_RESPONSE_MATCH, MediaType.APPLICATION_JSON); + invokeRequestAndCheckResponse( + ContextOperation.GETACCEPTABLEMEDIATYPESISREADONLY); + } + + /* + * @testName: getCookiesTest + * + * @assertion_ids: JAXRS:JAVADOC:652; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get any cookies that accompanied the request. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getCookiesTest() throws Fault { + String[] cookies = { "cookie1", "coookkkie99", "cookiiieee999" }; + for (String cookie : cookies) { + String sCookie = new StringBuilder().append("Cookie: $Version=1; ") + .append(cookie).append("=").append(cookie).append(";").toString(); + setProperty(Property.REQUEST_HEADERS, sCookie); + setProperty(Property.SEARCH_STRING, cookie); + invokeRequestAndCheckResponse(ContextOperation.GETCOOKIES); + } + } + + /* + * @testName: getCookiesIsReadonlyTest + * + * @assertion_ids: JAXRS:JAVADOC:652; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get any cookies that accompanied the request. Returns : a + * read-only map of cookie name (String) to Cookie. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getCookiesIsReadonlyTest() throws Fault { + setPrintEntity(true); + invokeRequestAndCheckResponse(ContextOperation.GETCOOKIESISREADONLY); + } + + /* + * @testName: getDateTest + * + * @assertion_ids: JAXRS:JAVADOC:653; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: the message date, otherwise null if not present. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getDateTest() throws Fault { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + Date date = calendar.getTime(); + String gmt = JaxrsUtil.createDateFormat(TimeZone.getTimeZone("GMT")) + .format(date); + setProperty(Property.REQUEST_HEADERS, "Date:" + gmt); + setProperty(Property.SEARCH_STRING, String.valueOf(date.getTime())); + invokeRequestAndCheckResponse(ContextOperation.GETDATE); + } + + /* + * @testName: getDateIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:653; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: the message date, otherwise null if not present. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getDateIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, "NULL"); + invokeRequestAndCheckResponse(ContextOperation.GETDATE); + } + + /* + * @testName: getEntityStreamTest + * + * @assertion_ids: JAXRS:JAVADOC:654; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get the entity input stream. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getEntityStreamTest() throws Fault { + String entity = "EnTiTyStReAmTeSt"; + setProperty(Property.CONTENT, entity); + setProperty(Property.SEARCH_STRING, entity); + invokeRequestAndCheckResponse(Request.POST, + ContextOperation.GETENTITYSTREAM); + } + + /* + * @testName: getHeadersTest + * + * @assertion_ids: JAXRS:JAVADOC:655; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get mutable multivalued map of request headers. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getHeadersTest() throws Fault { + for (int i = 1; i != 5; i++) { + String header = "header" + i + ":" + "header" + i; + setProperty(Property.REQUEST_HEADERS, header); + setProperty(Property.UNORDERED_SEARCH_STRING, header); + } + invokeRequestAndCheckResponse(ContextOperation.GETHEADERS); + } + + /* + * @testName: getHeadersIsMutableTest + * + * @assertion_ids: JAXRS:JAVADOC:655; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get mutable multivalued map of request headers. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getHeadersIsMutableTest() throws Fault { + setPrintEntity(true); + invokeRequestAndCheckResponse(ContextOperation.GETHEADERSISMUTABLE); + } + + /* + * @testName: getHeaderStringTest + * + * @assertion_ids: JAXRS:JAVADOC:656; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get a message header as a single string value. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getHeaderStringTest() throws Fault { + setProperty(Property.SEARCH_STRING, + ContextOperation.GETHEADERSTRING2.name()); + invokeRequestAndCheckResponse(ContextOperation.GETHEADERSTRING2); + } + + /* + * @testName: getLanguageTest + * + * @assertion_ids: JAXRS:JAVADOC:657; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get the language of the entity or null if not specified + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getLanguageTest() throws Fault { + setProperty(Property.REQUEST_HEADERS, + HttpHeaders.CONTENT_LANGUAGE + ":en-gb"); + setProperty(Property.SEARCH_STRING, "en-gb"); + invokeRequestAndCheckResponse(ContextOperation.GETLANGUAGE); + } + + /* + * @testName: getLanguageIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:657; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get the language of the entity or null if not specified + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getLanguageIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, "NULL"); + invokeRequestAndCheckResponse(ContextOperation.GETLANGUAGE); + } + + /* + * @testName: getLengthTest + * + * @assertion_ids: JAXRS:JAVADOC:658; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get Content-Length as integer if present and valid number. + * In other cases returns -1. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getLengthTest() throws Fault { + setProperty(Property.CONTENT, "12345678901234567890"); + setProperty(Property.SEARCH_STRING, "20"); + invokeRequestAndCheckResponse(Request.POST, ContextOperation.GETLENGTH); + } + + /* + * @testName: getLengthWhenNoEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:658; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get Content-Length as integer if present and valid number. + * In other cases returns -1. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getLengthWhenNoEntityTest() throws Fault { + setProperty(Property.SEARCH_STRING, "-1"); + invokeRequestAndCheckResponse(ContextOperation.GETLENGTH); + } + + /* + * @testName: getMediaTypeTest + * + * @assertion_ids: JAXRS:JAVADOC:659; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: the media type or null if not specified (e.g. there's no + * request entity). + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getMediaTypeTest() throws Fault { + addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_SVG_XML); + setProperty(Property.SEARCH_STRING, MediaType.APPLICATION_SVG_XML); + invokeRequestAndCheckResponse(ContextOperation.GETMEDIATYPE); + } + + /* + * @testName: getMediaTypeIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:659; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: the media type or null if not specified (e.g. there's no + * request entity). + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getMediaTypeIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, "NULL"); + invokeRequestAndCheckResponse(ContextOperation.GETMEDIATYPE); + } + + /* + * @testName: getMethodTest + * + * @assertion_ids: JAXRS:JAVADOC:660; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get the request method. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getMethodTest() throws Fault { + String method = Request.OPTIONS.name(); + String header = RequestFilter.OPERATION + ":" + + ContextOperation.GETMETHOD.name(); + getTestCase().setRequestType(method); + getTestCase().setUrlRequest(getContextRoot()); + setProperty(Property.SEARCH_STRING_IGNORE_CASE, method); + setProperty(Property.REQUEST_HEADERS, header); + invoke(); + } + + /* + * @testName: getPropertyIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:661; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Returns the property with the given name registered in the + * current request/response exchange context, or null if there is no property + * by that name. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getPropertyIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, "NULL"); + invokeRequestAndCheckResponse(ContextOperation.GETPROPERTY); + } + + /* + * @testName: getPropertyNamesTest + * + * @assertion_ids: JAXRS:JAVADOC:986; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Returns immutable java.util.Collection collection + * containing the property names available within the context of the current + * request/response exchange context. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getPropertyNamesTest() throws Fault { + for (int i = 0; i != 5; i++) + setProperty(Property.UNORDERED_SEARCH_STRING, + TemplateFilter.PROPERTYNAME.toLowerCase() + i); + invokeRequestAndCheckResponse(ContextOperation.GETPROPERTYNAMES); + } + + /* + * @testName: getPropertyNamesIsReadOnlyTest + * + * @assertion_ids: JAXRS:JAVADOC:986; + * + * @test_Strategy: Returns immutable java.util.Collection collection + * containing the property names available within the context of the current + * request/response exchange context. + */ + @Test + public void getPropertyNamesIsReadOnlyTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, "0"); + invokeRequestAndCheckResponse(ContextOperation.GETPROPERTYNAMESISREADONLY); + } + + /* + * @testName: getRequestTest + * + * @assertion_ids: JAXRS:JAVADOC:663; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get the injectable request information. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getRequestTest() throws Fault { + String method = Request.OPTIONS.name(); + String header = RequestFilter.OPERATION + ":" + + ContextOperation.GETREQUEST.name(); + getTestCase().setRequestType(method); + getTestCase().setUrlRequest(getContextRoot()); + setProperty(Property.SEARCH_STRING_IGNORE_CASE, method); + setProperty(Property.REQUEST_HEADERS, header); + invoke(); + } + + /* + * @testName: getSecurityContextPrincipalIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:664; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get the injectable security context information for the + * current request. The SecurityContext.getUserPrincipal() must return null if + * the current request has not been authenticated. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getSecurityContextPrincipalIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, "NULL"); + invokeRequestAndCheckResponse(ContextOperation.GETSECURITYCONTEXT); + } + + /* + * @testName: getUriInfoTest + * + * @assertion_ids: JAXRS:JAVADOC:665; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Get request URI information. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void getUriInfoTest() throws Fault { + setProperty(Property.SEARCH_STRING, getAbsoluteUrl()); + invokeRequestAndCheckResponse(ContextOperation.GETURIINFO); + } + + /* + * @testName: hasEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:666; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Check if there is a non-empty entity input stream available + * in the request message. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void hasEntityTest() throws Fault { + setRequestContentEntity("entity"); + setProperty(Property.SEARCH_STRING, "true"); + invokeRequestAndCheckResponse(Request.POST, ContextOperation.HASENTITY); + } + + /* + * @testName: hasEntityWhenNoEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:666; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Check if there is a non-empty entity input stream available + * in the request message. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void hasEntityWhenNoEntityTest() throws Fault { + setProperty(Property.SEARCH_STRING, "false"); + invokeRequestAndCheckResponse(ContextOperation.HASENTITY); + } + + /* + * @testName: removePropertyTest + * + * @assertion_ids: JAXRS:JAVADOC:667; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Removes a property with the given name from the current + * request/response exchange context. After removal, subsequent calls to + * getProperty(java.lang.String) to retrieve the property value will return + * null. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void removePropertyTest() throws Fault { + // getProperty returns null after the property has been set and removed + setProperty(Property.SEARCH_STRING, "NULL"); + invokeRequestAndCheckResponse(ContextOperation.REMOVEPROPERTY); + } + + /* + * @testName: setEntityStreamTest + * + * @assertion_ids: JAXRS:JAVADOC:668; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Set a new entity input stream. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void setEntityStreamTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.SETENTITYSTREAMENTITY); + invokeRequestAndCheckResponse(ContextOperation.SETENTITYSTREAM); + } + + /* + * @testName: setMethodTest + * + * @assertion_ids: JAXRS:JAVADOC:669; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Set the request method. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void setMethodTest() throws Fault { + setProperty(Property.SEARCH_STRING, Request.OPTIONS.name()); + invokeRequestAndCheckResponse(ContextOperation.SETMETHOD); + } + + /* + * @testName: setPropertyTest + * + * @assertion_ids: JAXRS:JAVADOC:671; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Binds an object to a given property name in the current + * request/response exchange context. If the name specified is already used + * for a property, this method will replace the value of the property with the + * new value. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void setPropertyTest() throws Fault { + setProperty(Property.SEARCH_STRING, TemplateFilter.PROPERTYNAME); + invokeRequestAndCheckResponse(ContextOperation.SETPROPERTY); + } + + /* + * @testName: setPropertyNullTest + * + * @assertion_ids: JAXRS:JAVADOC:671; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: If a null value is passed, the effect is the same as + * calling the removeProperty(String) method. Will replace the value of the + * property with the new value. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. * + */ + @Test + public void setPropertyNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, "NULL"); + invokeRequestAndCheckResponse(ContextOperation.SETPROPERTYNULL); + } + + /* + * @testName: setPropertyIsReflectedInServletRequestTest + * + * @assertion_ids: JAXRS:JAVADOC:671; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: In a Servlet container, the properties are synchronized + * with the ServletRequest and expose all the attributes available in the + * ServletRequest. Any modifications of the properties are also reflected in + * the set of properties of the associated ServletRequest. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. * + */ + @Test + public void setPropertyIsReflectedInServletRequestTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.PROPERTYNAME); + invokeRequestAndCheckResponse(ContextOperation.SETPROPERTYCONTEXT); + } + + /* + * @testName: setRequestUriOneUriTest + * + * @assertion_ids: JAXRS:JAVADOC:672; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Set a new request URI using the current base URI of the + * application to resolve the application-specific request URI part. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void setRequestUriOneUriTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.URI); + invokeRequestAndCheckResponse(ContextOperation.SETREQUESTURI1); + } + + /* + * @testName: setRequestUriTwoUrisTest + * + * @assertion_ids: JAXRS:JAVADOC:674; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Set a new request URI using a new base URI to resolve the + * application-specific request URI part. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void setRequestUriTwoUrisTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.URI); + invokeRequestAndCheckResponse(ContextOperation.SETREQUESTURI2); + } + + /* + * @testName: setSecurityContextTest + * + * @assertion_ids: JAXRS:JAVADOC:676; JAXRS:JAVADOC:677; JAXRS:JAVADOC:678; + * + * @test_Strategy: Set a new injectable security context information for the + * current request. + * + * Filter method called before a request has been dispatched to a resource. + * Throws IOException. + */ + @Test + public void setSecurityContextTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.PRINCIPAL); + invokeRequestAndCheckResponse(ContextOperation.SETSECURITYCONTEXT); + } + + // //////////////////////////////////////////////////////////////////////////// + + protected void invokeRequestAndCheckResponse( + ContextOperation contextOperation) throws Fault { + invokeRequestAndCheckResponse(Request.GET, contextOperation); + } + + protected void invokeRequestAndCheckResponse(Request req, + ContextOperation contextOperation) throws Fault { + String operation = contextOperation.name(); + String request = buildRequest(req, operation.toLowerCase()); + String header = RequestFilter.OPERATION + ":" + operation; + setProperty(Property.REQUEST, request); + setProperty(Property.SEARCH_STRING, operation); + setProperty(Property.REQUEST_HEADERS, header); + invoke(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/RequestFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/RequestFilter.java new file mode 100644 index 0000000..d00bdee --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/RequestFilter.java
@@ -0,0 +1,312 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.Principal; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; + +import jakarta.ws.rs.tck.common.impl.SecurityContextImpl; + +import jakarta.annotation.Priority; +import jakarta.ws.rs.container.PreMatching; +import jakarta.ws.rs.core.Cookie; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Request; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.core.UriInfo; +import jakarta.ws.rs.ext.Provider; + +/** + * The methods are called here by reflection from the superclass + */ +@Provider +@Priority(100) +@PreMatching +public class RequestFilter extends TemplateFilter { + + public static final String PRINCIPAL = "PrincipalName"; + + public static final String SETENTITYSTREAMENTITY = "SetEntityStreamEntity"; + + public static final String URI = "http://xx.yy:888/base/resource/sub"; + + public void abortWith() { + abortWithEntity(null); + } + + public void getAcceptableLanguages() { + List<Locale> langs = requestContext.getAcceptableLanguages(); + abortWithEntity(collectionToString(langs)); + } + + public void getAcceptableLanguagesIsReadOnly() { + List<Locale> langs = requestContext.getAcceptableLanguages(); + if (assertTrue(!langs.contains(Locale.CANADA_FRENCH), Locale.CANADA_FRENCH, + "already included")) + return; + try { + langs.add(Locale.CANADA_FRENCH); + } catch (Exception e) { + // expected, but optional + } + langs = requestContext.getAcceptableLanguages(); + if (assertTrue(!langs.contains(Locale.CANADA_FRENCH), Locale.CANADA_FRENCH, + "included, the list is not read-only")) + return; + abortWithEntity(collectionToString(langs)); + } + + public void getAcceptableMediaTypes() { + List<MediaType> types = requestContext.getAcceptableMediaTypes(); + abortWithEntity(collectionToString(types)); + } + + public void getAcceptableMediaTypesIsReadOnly() { + List<MediaType> types = requestContext.getAcceptableMediaTypes(); + if (assertTrue(!types.contains(MediaType.APPLICATION_JSON_TYPE), + MediaType.APPLICATION_JSON, "already included")) + return; + try { + types.add(MediaType.APPLICATION_JSON_TYPE); + } catch (Exception e) { + // expected, but optional + } + types = requestContext.getAcceptableMediaTypes(); + if (assertTrue(!types.contains(MediaType.APPLICATION_JSON_TYPE), + MediaType.APPLICATION_JSON, "included, the list is not read-only")) + return; + abortWithEntity(collectionToString(types)); + } + + public void getCookies() { + Map<String, Cookie> cookies = requestContext.getCookies(); + Collection<Cookie> values = cookies.values(); + abortWithEntity(collectionToString(values)); + } + + public void getCookiesIsReadOnly() { + Map<String, Cookie> cookies = requestContext.getCookies(); + int length = cookies.size(); + try { + cookies.put("key", new Cookie("coo", "kie")); + } catch (Exception e) { + // expected, but optional + } + cookies = requestContext.getCookies(); + if (assertTrue(cookies.size() == length, "Cookie was added present")) + return; + abortWithEntity("#getCookies is read-only as expected"); + } + + public void getDate() { + Date date = requestContext.getDate(); + abortWithEntity(String.valueOf(date == null ? "NULL" : date.getTime())); + } + + public void getEntityStream() throws IOException { + InputStream stream = requestContext.getEntityStream(); + InputStreamReader isr = new InputStreamReader(stream); + BufferedReader br = new BufferedReader(isr); + String entity = br.readLine(); + br.close(); + abortWithEntity(entity); + } + + public void getHeaders() { + MultivaluedMap<String, String> headers = requestContext.getHeaders(); + StringBuilder sb = new StringBuilder(); + for (Entry<String, List<String>> set : headers.entrySet()) { + String first = headers.getFirst(set.getKey()); + sb.append(set.getKey()).append(":").append(first).append(";"); + } + abortWithEntity(sb.toString()); + } + + public void getHeadersIsMutable() { + String key = "KEY"; + MultivaluedMap<String, String> headers = requestContext.getHeaders(); + if (assertTrue(!headers.containsKey(key), "Key", key, "is already present")) + return; + headers.add(key, "VALUE"); + assertTrue(headers.containsKey(key), "Key", key, "not found"); + } + + public void getHeaderString2() { + String string = requestContext.getHeaderString(OPERATION); + abortWithEntity(string); + } + + public void getLanguage() { + Locale lang = requestContext.getLanguage(); + String entity = lang == null ? "NULL" + : collectionToString(Collections.singleton(lang)); + abortWithEntity(entity); + } + + public void getLength() { + int len = requestContext.getLength(); + abortWithEntity(String.valueOf(len)); + } + + public void getMediaType() { + MediaType media = requestContext.getMediaType(); + abortWithEntity(media == null ? "NULL" : media.toString()); + } + + public void getMethod() { + String method = requestContext.getMethod(); + abortWithEntity(method); + } + + public void getProperty() { + Object o = requestContext.getProperty(PROPERTYNAME); + abortWithEntity(o == null ? "NULL" : o.toString()); + } + + public void getPropertyNames() { + int length = requestContext.getPropertyNames().size(); + for (int i = 0; i != 5; i++) + requestContext.setProperty(PROPERTYNAME + i, PROPERTYNAME); + Collection<String> names = requestContext.getPropertyNames(); + assertTrue(names.size() == 5 + length, + "#getPropertyNames has unexpected number of elements", names.size(), + "before any addition it was", length); + } + + public void getPropertyNamesIsReadOnly() { + Collection<String> names = requestContext.getPropertyNames(); + int length = names.size(); + for (int i = 0; i != 5; i++) + try { + names.add(PROPERTYNAME + i); + } catch (Exception e) { + // Exception here is possible + } + names = requestContext.getPropertyNames(); + if (assertTrue(names.size() == length, + "#getPropertyNames has unexpected elements", names)) + return; + abortWithEntity("0"); + } + + public void getRequest() { + Request request = requestContext.getRequest(); + String method = request.getMethod(); + abortWithEntity(method); + } + + public void getSecurityContext() { + SecurityContext secCtx = requestContext.getSecurityContext(); + Principal principal = secCtx.getUserPrincipal(); + if (assertTrue(principal == null, "principal is not null")) + return; + abortWithEntity("NULL"); + } + + public void getUriInfo() { + UriInfo info = requestContext.getUriInfo(); + abortWithEntity(info.getAbsolutePath().toASCIIString()); + } + + public void hasEntity() { + boolean has = requestContext.hasEntity(); + abortWithEntity(String.valueOf(has).toLowerCase()); + } + + public void removeProperty() { + setProperty(); + requestContext.removeProperty(PROPERTYNAME); + getProperty(); + } + + public void setEntityStream() throws IOException { + ByteArrayInputStream stream = new ByteArrayInputStream( + SETENTITYSTREAMENTITY.getBytes()); + requestContext.setEntityStream(stream); + getEntityStream(); + } + + public void setMethod() { + requestContext.setMethod("OPTIONS"); + // really pass to the server to check the changes, do NOT abortWith + } + + public void setProperty() { + requestContext.setProperty(PROPERTYNAME, PROPERTYNAME + PROPERTYNAME); + assertTrue(requestContext.getProperty(PROPERTYNAME) != null, "property", + PROPERTYNAME, "not found"); + } + + public void setPropertyNull() { + setProperty(); + requestContext.setProperty(PROPERTYNAME, null); + getProperty(); + } + + public void setPropertyContext() { + requestContext.setProperty(PROPERTYNAME, PROPERTYNAME); + } + + public void setRequestUri1() throws IOException { + URI uri; + try { + UriInfo info = requestContext.getUriInfo(); + String path = new StringBuilder().append(info.getAbsolutePath()) + .append("uri").toString(); + uri = new URI(path); + } catch (URISyntaxException e) { + throw new IOException(e); + } + requestContext.setRequestUri(uri); + // pass to a resource to see whether the uri change has been reflected + } + + public void setRequestUri2() throws IOException { + URI base; + URI suffix; + try { + base = new URI("http://localhost:888/otherbase"); + suffix = new URI(URI); + } catch (URISyntaxException e) { + throw new IOException(e); + } + requestContext.setRequestUri(base, suffix); + getUriInfo(); + } + + public void setSecurityContext() throws IOException { + SecurityContext secCtx = new SecurityContextImpl(PRINCIPAL, false, false, + null); + requestContext.setSecurityContext(secCtx); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/Resource.java new file mode 100644 index 0000000..63f82fa --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/Resource.java
@@ -0,0 +1,79 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.OPTIONS; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.HttpHeaders; + +@Path("resource") +public class Resource { + + /** + * The method has been changed from POST to OPTIONS on a request filter Check + * that correct method has been called then + */ + @GET + @Path("setmethod") + public String setMethod1() { + return getReturnValue("GET"); + } + + @OPTIONS + @Path("setmethod") + public String setMethod2() { + return getReturnValue("OPTIONS"); + } + + /** + * SetUri change + */ + @GET + @Path("setrequesturi1uri") + public String setRequestUri() { + return getReturnValue(RequestFilter.URI); + } + + @GET + @Path("setpropertycontext") + public String setPropertyContext(@Context HttpServletRequest servletRequest) { + if (servletRequest == null) { + return "NULL"; + } + String entity = (String) servletRequest + .getAttribute(RequestFilter.PROPERTYNAME); + return getReturnValue(entity); + } + + @GET + @Path("setrequesturi1") + public String setRequestUriDidNotChangeUri() { + return "Filter did not change the uri to go to"; + } + + @Context + HttpHeaders headers; + + private String getReturnValue(String subValue) { + String header = headers.getHeaderString(RequestFilter.OPERATION); + return subValue + " " + header; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/SecondRequestFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/SecondRequestFilter.java new file mode 100644 index 0000000..c595ed2 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/SecondRequestFilter.java
@@ -0,0 +1,91 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext; + +import java.security.Principal; +import java.util.Collection; + +import jakarta.annotation.Priority; +import jakarta.ws.rs.container.PreMatching; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.ext.Provider; + +/** + * The methods are called here by reflection from the superclass This is a + * second filter, the lower priority filter, only a few requests will pass here, + * rest is handled in higher priority filter. + */ +@Provider +@Priority(500) +@PreMatching +public class SecondRequestFilter extends TemplateFilter { + + public void abortWith() { + throw new RuntimeException("The filter chain has not been broken"); + } + + public void getHeadersIsMutable() { + String key = "KEY"; + MultivaluedMap<String, String> headers = requestContext.getHeaders(); + if (assertTrue(headers.containsKey(key), "Key", key, "not found")) + return; + abortWithEntity("#getHeaders() is mutable as expected"); + } + + public void setProperty() { + Object o = requestContext.getProperty(PROPERTYNAME); + // If the name specified + // is already used for a property, this method will replace + // the value of the property with the new value. + if (assertTrue(o.equals(PROPERTYNAME + PROPERTYNAME), o, "is unexpected")) + return; + requestContext.setProperty(PROPERTYNAME, PROPERTYNAME); + o = requestContext.getProperty(PROPERTYNAME); + abortWithEntity(o == null ? "NULL" : o.toString()); + } + + public void setPropertyContext() { + // servletRequest injection not working here + } + + public void getPropertyNames() { + Collection<String> names = requestContext.getPropertyNames(); + if (assertTrue(names.size() >= 5, + "#getPropertyNames has unexpected number of elements", names.size(), + "{", collectionToString(names), "}")) + return; + abortWithEntity(collectionToString(names)); + } + + public void setSecurityContext() { + SecurityContext secCtx = requestContext.getSecurityContext(); + Principal principal = secCtx.getUserPrincipal(); + if (assertTrue(principal != null, "injected principal is null")) + return; + abortWithEntity(principal.getName()); + } + + public void setMethod() { + // void, just do not return Operation SETMETHOD not implemented + } + + public void setRequestUri1() { + // void, just do not return Operation SETREQUESTURI1 not implemented + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/TSAppConfig.java new file mode 100644 index 0000000..f355141 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/TSAppConfig.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.core.Application; + +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RequestFilter.class); + resources.add(SecondRequestFilter.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/TemplateFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/TemplateFilter.java new file mode 100644 index 0000000..b739463 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/TemplateFilter.java
@@ -0,0 +1,99 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.lang.reflect.Method; +import java.util.Collection; + +import jakarta.ws.rs.container.ContainerRequestContext; +import jakarta.ws.rs.container.ContainerRequestFilter; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +public abstract class TemplateFilter implements ContainerRequestFilter { + + public static final String OPERATION = "OPERATION"; + + public static final String PROPERTYNAME = "getSetProperty"; + + protected ContainerRequestContext requestContext; + + @Override + public void filter(ContainerRequestContext requestContext) + throws IOException { + this.requestContext = requestContext; + String operation = getHeaderString(); + Method[] methods = getClass().getMethods(); + for (Method method : methods) + if (operation.equalsIgnoreCase(method.getName())) { + try { + method.invoke(this); + return; + } catch (Exception e) { + e.printStackTrace(); + Response response = Response.status(Status.SERVICE_UNAVAILABLE) + .entity(e.getMessage()).build(); + requestContext.abortWith(response); + } + } + Response response = Response.status(Status.SERVICE_UNAVAILABLE) + .entity("Operation " + operation + " not implemented").build(); + requestContext.abortWith(response); + } + + // //////////////////////////////////////////////////////////////////// + protected static <T> String collectionToString(Collection<T> collection) { + StringBuilder sb = new StringBuilder(); + for (T item : collection) { + String replace = item.toString().toLowerCase().replace("_", "-") + .replace(" ", ""); + sb.append(replace).append(" "); + } + return sb.toString(); + } + + protected void abortWithEntity(String entity) { + StringBuilder sb = new StringBuilder(); + if (entity != null) + sb.append(entity).append(";"); + sb.append(getHeaderString()); + Response response = Response.ok(sb.toString()).build(); + requestContext.abortWith(response); + } + + protected boolean assertTrue(boolean conditionTrue, Object... msg) { + if (conditionTrue) + return false; + StringBuilder sb = new StringBuilder(); + if (msg != null) + for (Object str : msg) + sb.append(str).append(" "); + Response response = Response.status(Status.NOT_ACCEPTABLE) + .entity(sb.toString()).build(); + requestContext.abortWith(response); + return true; + } + + // might be replaced with ctx.getStringHeader() + protected String getHeaderString() { + MultivaluedMap<String, String> headers = requestContext.getHeaders(); + return headers.getFirst(OPERATION); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ContextOperation.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ContextOperation.java new file mode 100644 index 0000000..9ff1614 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ContextOperation.java
@@ -0,0 +1,21 @@ +/* + * Copyright (c) 2012, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +public enum ContextOperation { + ABORTWITH, SETMETHOD, SETREQUESTURI1, SETREQUESTURI2, SETENTITYSTREAM, SETSECURITYCONTEXT +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/JAXRSClientIT.java new file mode 100644 index 0000000..29b2285 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/JAXRSClientIT.java
@@ -0,0 +1,180 @@ +/* + * Copyright (c) 2012, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import jakarta.ws.rs.tck.common.client.JaxrsCommonClient; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JaxrsCommonClient { + + private static final long serialVersionUID = -8112756483664393579L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_container_requestcontext_illegalstate_web/resource"); + setPrintEntity(true); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_container_requestcontext_illegalstate_web.war"); + archive.addClasses(TSAppConfig.class, Resource.class, RequestFilter.class, ContextOperation.class, + RequestTemplateFilter.class, ResponseFilter.class, ResponseTemplateFilter.class, TemplateFilter.class, + jakarta.ws.rs.tck.common.provider.PrintingErrorHandler.class, + jakarta.ws.rs.tck.common.impl.SecurityContextImpl.class); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* + * @testName: setMethodTest + * + * @assertion_ids: JAXRS:JAVADOC:669; JAXRS:SPEC:85; + * + * @test_Strategy: Throws IllegalStateException - in case the method is not + * invoked from a pre-matching request filter. + */ + @Test + public void setMethodTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.ISEXCEPTION); + invokeRequestAndCheckResponse(ContextOperation.SETMETHOD); + } + + /* + * @testName: setRequestUriOneUriTest + * + * @assertion_ids: JAXRS:JAVADOC:672; JAXRS:SPEC:85; + * + * @test_Strategy: Trying to invoke the method in a filter bound to a resource + * method results in an IllegalStateException being thrown. + * + * ContainerRequestContext.abortWith + */ + @Test + public void setRequestUriOneUriTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.ISEXCEPTION); + invokeRequestAndCheckResponse(ContextOperation.SETREQUESTURI1); + } + + /* + * @testName: setRequestUriTwoUrisTest + * + * @assertion_ids: JAXRS:JAVADOC:674; JAXRS:SPEC:85; + * + * @test_Strategy: Trying to invoke the method in a filter bound to a resource + * method results in an IllegalStateException being thrown. + * + * ContainerRequestContext.abortWith + */ + @Test + public void setRequestUriTwoUrisTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.ISEXCEPTION); + invokeRequestAndCheckResponse(ContextOperation.SETREQUESTURI2); + } + + /* + * @testName: abortWithTest + * + * @assertion_ids: JAXRS:JAVADOC:649; + * + * @test_Strategy: throws IllegalStateException in case the method is invoked + * from a response filter. + */ + @Test + public void abortWithTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.ISEXCEPTION); + invokeRequestAndCheckResponse(ContextOperation.ABORTWITH); + } + + /* + * @testName: setEntityStreamTest + * + * @assertion_ids: JAXRS:JAVADOC:668; + * + * @test_Strategy: throws IllegalStateException in case the method is invoked + * from a response filter. + */ + @Test + public void setEntityStreamTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.ISEXCEPTION); + invokeRequestAndCheckResponse(ContextOperation.SETENTITYSTREAM); + } + + /* + * @testName: setSecurityContextTest + * + * @assertion_ids: JAXRS:JAVADOC:676; + * + * @test_Strategy: throws IllegalStateException in case the method is invoked + * from a response filter. + */ + @Test + public void setSecurityContextTest() throws Fault { + setProperty(Property.SEARCH_STRING, RequestFilter.ISEXCEPTION); + invokeRequestAndCheckResponse(ContextOperation.SETSECURITYCONTEXT); + } + + // //////////////////////////////////////////////////////////////////////////// + + protected void invokeRequestAndCheckResponse(ContextOperation operation) + throws Fault { + String op = operation.name(); + String request = buildRequest(Request.GET, op.toLowerCase()); + String header = RequestFilter.OPERATION + ":" + op; + setProperty(Property.REQUEST, request); + setProperty(Property.REQUEST_HEADERS, header); + invoke(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/RequestFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/RequestFilter.java new file mode 100644 index 0000000..cab1180 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/RequestFilter.java
@@ -0,0 +1,72 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.net.URI; +import java.net.URISyntaxException; + +import jakarta.ws.rs.ext.Provider; + +/** + * The methods are called here by reflection from the superclass + */ +@Provider +public class RequestFilter extends RequestTemplateFilter { + + public void setMethod() { + try { + requestContext.setMethod("OPTIONS"); + setEntity(NOEXCEPTION); + } catch (IllegalStateException e) { + setEntity(ISEXCEPTION); + } + } + + public void setRequestUri1() throws IOException { + URI uri; + try { + uri = new URI(URI); + } catch (URISyntaxException e) { + throw new IOException(e); + } + try { + requestContext.setRequestUri(uri); + setEntity(NOEXCEPTION); + } catch (IllegalStateException e) { + setEntity(ISEXCEPTION); + } + } + + public void setRequestUri2() throws IOException { + URI base; + URI suffix; + try { + base = new URI("http://localhost:888/otherbase"); + suffix = new URI(URI); + } catch (URISyntaxException e) { + throw new IOException(e); + } + try { + requestContext.setRequestUri(base, suffix); + setEntity(NOEXCEPTION); + } catch (IllegalStateException e) { + setEntity(ISEXCEPTION); + } + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/RequestTemplateFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/RequestTemplateFilter.java new file mode 100644 index 0000000..728edf8 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/RequestTemplateFilter.java
@@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.lang.reflect.Method; + +import jakarta.ws.rs.container.ContainerRequestContext; +import jakarta.ws.rs.container.ContainerRequestFilter; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +public abstract class RequestTemplateFilter extends TemplateFilter + implements ContainerRequestFilter { + @Override + public void filter(ContainerRequestContext requestContext) + throws IOException { + this.requestContext = requestContext; + String operation = requestContext.getHeaderString(OPERATION); + Method[] methods = getClass().getMethods(); + for (Method method : methods) + if (operation.equalsIgnoreCase(method.getName())) { + try { + method.invoke(this); + if (entity != null) { + Response response = Response.ok(entity).build(); + requestContext.abortWith(response); + } + return; + } catch (Exception e) { + e.printStackTrace(); + Response response = Response.status(Status.SERVICE_UNAVAILABLE) + .entity(e.getMessage()).build(); + requestContext.abortWith(response); + } + } + // If method not found, it is response context operation + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/Resource.java new file mode 100644 index 0000000..59b9d60 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/Resource.java
@@ -0,0 +1,86 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +import java.util.List; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.PathSegment; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.UriInfo; + +@Path("resource") +public class Resource { + + @GET + @Path("setmethod") + public Response setMethod() { + return createResponseWithHeader(); + } + + @GET + @Path("setrequesturi1") + public Response setRequestUri1() { + return createResponseWithHeader(); + } + + @GET + @Path("setrequesturi2") + public Response setRequestUri2() { + return createResponseWithHeader(); + } + + @GET + @Path("abortwith") + public Response abortWith() { + return createResponseWithHeader(); + } + + @GET + @Path("setentitystream") + public Response setEntityStream() { + return createResponseWithHeader(); + } + + @GET + @Path("setsecuritycontext") + public Response setSecurityContext() { + return createResponseWithHeader(); + } + + // ////////////////////////////////////////////////////////////////// + + @Context + UriInfo info; + + private Response createResponseWithHeader() { + // get value of @Path(value) + List<PathSegment> segments = info.getPathSegments(); + PathSegment last = segments.get(segments.size() - 1); + // convert the value to ContextOperation + ContextOperation op = ContextOperation + .valueOf(last.getPath().toUpperCase()); + Response.ResponseBuilder builder = Response.ok(); + // set a header with ContextOperation so that the filter knows what to + // do + builder = builder.header(TemplateFilter.OPERATION, op.name()); + return builder.build(); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ResponseFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ResponseFilter.java new file mode 100644 index 0000000..db2bb49 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ResponseFilter.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +import java.io.ByteArrayInputStream; + +import jakarta.ws.rs.tck.common.impl.SecurityContextImpl; + +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.ext.Provider; + +@Provider +public class ResponseFilter extends ResponseTemplateFilter { + public void abortWith() { + try { + requestContext.abortWith(Response.ok().build()); + setEntity(NOEXCEPTION); + } catch (IllegalStateException e) { + setEntity(ISEXCEPTION); + } + } + + public void setEntityStream() { + try { + ByteArrayInputStream bais = new ByteArrayInputStream( + NOEXCEPTION.getBytes()); + requestContext.setEntityStream(bais); + setEntity(NOEXCEPTION); + } catch (IllegalStateException e) { + setEntity(ISEXCEPTION); + } + } + + public void setSecurityContext() { + SecurityContext ctx = new SecurityContextImpl(); + try { + requestContext.setSecurityContext(ctx); + setEntity(NOEXCEPTION); + } catch (IllegalStateException e) { + setEntity(ISEXCEPTION); + } + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ResponseTemplateFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ResponseTemplateFilter.java new file mode 100644 index 0000000..14df043 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/ResponseTemplateFilter.java
@@ -0,0 +1,62 @@ +/* + * Copyright (c) 2013, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; + +import jakarta.ws.rs.container.ContainerRequestContext; +import jakarta.ws.rs.container.ContainerResponseContext; +import jakarta.ws.rs.container.ContainerResponseFilter; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response.Status; + +public class ResponseTemplateFilter extends TemplateFilter + implements ContainerResponseFilter { + + protected ContainerResponseContext responseContext; + + @Override + public void filter(ContainerRequestContext requestContext, + ContainerResponseContext responseContext) throws IOException { + this.responseContext = responseContext; + this.requestContext = requestContext; + String operation = requestContext.getHeaderString(OPERATION); + Method[] methods = getClass().getMethods(); + for (Method method : methods) + if (operation.equalsIgnoreCase(method.getName())) { + try { + method.invoke(this); + return; + } catch (Exception e) { + e.printStackTrace(); + setEntity(e.getMessage()); + responseContext.setStatus(Status.SERVICE_UNAVAILABLE.getStatusCode()); + } + } + // When method not found, it is request context operation + } + + @Override + protected void setEntity(String entity) { + responseContext.setEntity(entity, (Annotation[]) null, + MediaType.WILDCARD_TYPE); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/TSAppConfig.java new file mode 100644 index 0000000..fdf942b --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/TSAppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.common.provider.PrintingErrorHandler; + +import jakarta.ws.rs.core.Application; + +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RequestFilter.class); + resources.add(ResponseFilter.class); + resources.add(PrintingErrorHandler.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/TemplateFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/TemplateFilter.java new file mode 100644 index 0000000..b6f0a6a --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/TemplateFilter.java
@@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate; + +import java.util.Collection; + +import jakarta.ws.rs.container.ContainerRequestContext; + +public class TemplateFilter { + + public static final String NOEXCEPTION = "No exception has been thrown"; + + public static final String ISEXCEPTION = "IllegalSteateException has been thrown"; + + public static final String URI = "http://xx.yy:888/base/resource/sub"; + + public static final String OPERATION = "OPERATION"; + + protected String entity = null; + + protected ContainerRequestContext requestContext; + + protected static <T> String collectionToString(Collection<T> collection) { + StringBuilder sb = new StringBuilder(); + for (T item : collection) { + String replace = item.toString().toLowerCase().replace("_", "-") + .replace(" ", ""); + sb.append(replace).append(" "); + } + return sb.toString(); + } + + protected void setEntity(String entity) { + this.entity = entity; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/JAXRSClientIT.java new file mode 100644 index 0000000..43e927f --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/JAXRSClientIT.java
@@ -0,0 +1,132 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.security; + +import java.io.InputStream; +import java.io.IOException; +import java.util.Properties; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.tck.common.client.JaxrsCommonClient; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * user; + * password; + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JaxrsCommonClient { + + private static final long serialVersionUID = -3020219607348263568L; + + protected String user; + + protected String password; + + public JAXRSClientIT() { + usersetup(); + setContextRoot("/jaxrs_ee_rs_container_requestcontext_security_web/resource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException { + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_container_requestcontext_security_web.war"); + archive.addClasses(TSAppConfig.class, Resource.class, RequestFilter.class); + archive.addAsResource("jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/jaxrs_ee_rs_container_requestcontext_security_web.war.sun-web.xml"); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + public void usersetup() { + user = System.getProperty("user"); + password = System.getProperty("password"); + assertTrue(!isNullOrEmpty(user), "user not set"); + assertTrue(!isNullOrEmpty(password), + "password not set"); + super.setup(); + } + + /* + * @testName: getSecurityContextTest + * + * @assertion_ids: JAXRS:JAVADOC:664; + * + * @test_Strategy: Get the injectable security context information for the + * current request, the user is authenticated. + */ + //@Test + public void getSecurityContextTest() throws Fault { + setProperty(Property.BASIC_AUTH_USER, user); + setProperty(Property.BASIC_AUTH_PASSWD, password); + setProperty(Property.SEARCH_STRING, user); + String request = buildRequest(Request.POST, ""); + setProperty(Property.REQUEST, request); + invoke(); + } + + /* + * @testName: noSecurityTest + * + * @assertion_ids: JAXRS:JAVADOC:664; + * + * @test_Strategy: Make sure the authorization is needed + */ + @Test + public void noSecurityTest() throws Fault { + String request = buildRequest(Request.POST, ""); + setProperty(Property.REQUEST, request); + setProperty(Property.STATUS_CODE, getStatusCode(Status.UNAUTHORIZED)); + invoke(); + } + + // //////////////////////////////////////////////////////////////////////////// + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/RequestFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/RequestFilter.java new file mode 100644 index 0000000..6b6c0f8 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/RequestFilter.java
@@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.security; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.container.ContainerRequestContext; +import jakarta.ws.rs.container.ContainerRequestFilter; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.ext.Provider; + +/** + * The methods are called here by reflection from the superclass + */ +@Provider +public class RequestFilter implements ContainerRequestFilter { + + @Override + public void filter(ContainerRequestContext requestContext) + throws IOException { + SecurityContext security = requestContext.getSecurityContext(); + String msg = "security.getUserPrincipal() is null"; + if (security.getUserPrincipal() != null) + msg = security.getUserPrincipal().getName(); + Response response = Response.ok(msg).build(); + requestContext.abortWith(response); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/Resource.java new file mode 100644 index 0000000..2dddd59 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/Resource.java
@@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.security; + +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +@Path("resource") +public class Resource { + @POST + public String echo(String echo) { + return echo; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/TSAppConfig.java new file mode 100644 index 0000000..c002118 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/TSAppConfig.java
@@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.requestcontext.security; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.core.Application; + +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(RequestFilter.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/JAXRSClientIT.java new file mode 100644 index 0000000..4d983bb --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/JAXRSClientIT.java
@@ -0,0 +1,108 @@ +/* + * Copyright (c) 2013, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.resourceinfo; + +import java.io.IOException; +import java.io.InputStream; +import jakarta.ws.rs.tck.common.client.JaxrsCommonClient; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JaxrsCommonClient { + + private static final long serialVersionUID = -2900337741491627385L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_container_resourceinfo_web/resource"); + setPrintEntity(true); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException { + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/container/resourceinfo/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_container_resourceinfo_web.war"); + archive.addClasses(TSAppConfig.class, Resource.class); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* + * @testName: getResourceClassTest + * + * @assertion_ids: JAXRS:JAVADOC:721; + * + * @test_Strategy: Get the resource class that is the target of a request + */ + @Test + public void getResourceClassTest() throws Fault { + setProperty(Property.REQUEST, buildRequest(Request.GET, "clazz")); + setProperty(Property.SEARCH_STRING, Resource.class.getName()); + invoke(); + logMsg("Found expected resource class name"); + } + + /* + * @testName: getResourceMethodTest + * + * @assertion_ids: JAXRS:JAVADOC:722; + * + * @test_Strategy: Get the resource method that is the target of a request + */ + @Test + public void getResourceMethodTest() throws Fault { + setProperty(Property.REQUEST, buildRequest(Request.GET, "method")); + setProperty(Property.SEARCH_STRING, "getResourceMethod"); + invoke(); + logMsg("Found expected resource method name"); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/Resource.java new file mode 100644 index 0000000..a7dbfc1 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/Resource.java
@@ -0,0 +1,44 @@ +/* + * Copyright (c) 2013, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.resourceinfo; + +import java.lang.reflect.Method; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.container.ResourceInfo; +import jakarta.ws.rs.core.Context; + +@Path("resource") +public class Resource { + @Context + ResourceInfo info; + + @GET + @Path("clazz") + public String getResourceClass() { + Class<?> clazz = info.getResourceClass(); + return clazz.getName(); + } + + @GET + @Path("method") + public String getResourceMethod() { + Method method = info.getResourceMethod(); + return method.getName(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/TSAppConfig.java new file mode 100644 index 0000000..b878572 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/TSAppConfig.java
@@ -0,0 +1,31 @@ +/* + * Copyright (c) 2013, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.resourceinfo; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.core.Application; + +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/ContextOperation.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/ContextOperation.java new file mode 100644 index 0000000..ac1f194 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/ContextOperation.java
@@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.responsecontext; + +public enum ContextOperation { + GETALLOWEDMETHODS, GETCOOKIES, GETCOOKIESISREADONLY, GETDATE, GETENTITY, GETENTITYANNOTATIONS, GETENTITYANNOTATIONSONENTITY, GETENTITYCLASS, GETENTITYSTREAM, GETENTITYTAG, GETENTITYTYPE, GETHEADERS, GETHEADERSISMUTABLE, GETHEADERSTRINGOPERATION, GETHEADERSTRINGHEADER, GETLANGUAGE, GETLASTMODIFIED, GETLENGTH, GETLINK, GETLINKBUILDER, GETLINKS, GETLOCATION, GETMEDIATYPE, GETSTATUS, GETSTATUSINFO, GETSTRINGHEADERS, HASENTITY, HASLINK, SETENTITY, SETENTITYSTREAM, SETSTATUS, SETSTATUSINFO, + + // just helping methods, pass + SETSTRINGBEANRUNTIME, SETORIGINALRUNTIME +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/JAXRSClientIT.java new file mode 100644 index 0000000..06445c2 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/JAXRSClientIT.java
@@ -0,0 +1,1164 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.responsecontext; + +import java.io.ByteArrayInputStream; +import java.util.Locale; +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.tck.common.client.JaxrsCommonClient; +import jakarta.ws.rs.tck.common.client.TextCaser; + +import jakarta.annotation.Priority; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.Provider; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + * + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JaxrsCommonClient { + + private static final long serialVersionUID = 7090474648496503290L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_container_responsecontext_web/resource"); + setPrintEntity(true); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/container/responsecontext/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_container_responsecontext_web.war"); + archive.addClasses(TSAppConfig.class, Resource.class, + ContextOperation.class, ResponseFilter.class, SecondResponseFilter.class, TemplateFilter.class, + jakarta.ws.rs.tck.common.provider.PrintingErrorHandler.class, + jakarta.ws.rs.tck.common.provider.StringBean.class, + jakarta.ws.rs.tck.common.provider.StringBeanEntityProvider.class, + jakarta.ws.rs.tck.common.provider.StringBeanHeaderDelegate.class, + jakarta.ws.rs.tck.common.provider.StringBeanRuntimeDelegate.class, + jakarta.ws.rs.tck.common.provider.StringBeanWithAnnotation.class, + jakarta.ws.rs.tck.common.provider.PrintingErrorHandler.class, + jakarta.ws.rs.tck.common.util.JaxrsUtil.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* + * @testName: getAllowedMethodsTest + * + * @assertion_ids: JAXRS:JAVADOC:679; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the allowed HTTP methods, all methods will returned as + * upper case strings. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getAllowedMethodsTest() throws Fault { + setProperty(Property.UNORDERED_SEARCH_STRING, "options"); + setProperty(Property.UNORDERED_SEARCH_STRING, "trace"); + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.GETALLOWEDMETHODS); + } + + /* + * @testName: getCookiesTest + * + * @assertion_ids: JAXRS:JAVADOC:680; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a read-only map of cookie name (String) to a new + * cookie. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getCookiesTest() throws Fault { + setProperty(Property.SEARCH_STRING_IGNORE_CASE, ResponseFilter.COOKIENAME); + invokeRequestAndCheckResponse(Request.GET, ContextOperation.GETCOOKIES); + } + + /* + * @testName: getCookiesIsReadOnlyTest + * + * @assertion_ids: JAXRS:JAVADOC:680; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a read-only map of cookie name (String) to a new + * cookie. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getCookiesIsReadOnlyTest() throws Fault { + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.GETCOOKIESISREADONLY); + } + + /* + * @testName: getDateTest + * + * @assertion_ids: JAXRS:JAVADOC:681; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the message date, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getDateTest() throws Fault { + long date = System.currentTimeMillis(); + date = (date / 1000) * 1000; + String value = String.valueOf(date); + setProperty(Property.CONTENT, value); + setProperty(Property.SEARCH_STRING, value); + invokeRequestAndCheckResponse(ContextOperation.GETDATE); + } + + /* + * @testName: getDateIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:681; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the message date, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getDateIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, "0"); + invokeRequestAndCheckResponse(ContextOperation.GETDATE); + } + + /* + * @testName: getEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:682; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the message entity Java instance. Returns null if the + * message does not contain an entity. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityTest() throws Fault { + String entity = getClass().getName() + "entity"; + setProperty(Property.CONTENT, entity); + setProperty(Property.SEARCH_STRING, entity + entity); + invokeRequestAndCheckResponse(ContextOperation.GETENTITY); + } + + /* + * @testName: getEntityIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:682; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the message entity Java instance. Returns null if the + * message does not contain an entity. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETENTITY); + } + + /* + * @testName: getEntityAnnotationsTest + * + * @assertion_ids: JAXRS:JAVADOC:683; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the annotations attached to the entity. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityAnnotationsTest() throws Fault { + setTextCaser(TextCaser.LOWER); + setProperty(Property.UNORDERED_SEARCH_STRING, Provider.class.getName()); + setProperty(Property.UNORDERED_SEARCH_STRING, Priority.class.getName()); + setProperty(Property.UNORDERED_SEARCH_STRING, Path.class.getName()); + setProperty(Property.UNORDERED_SEARCH_STRING, POST.class.getName()); + setProperty(Property.CONTENT, "true"); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYANNOTATIONS); + } + + /* + * @testName: getEntityAnnotationsWhenNoAnnotationsTest + * + * @assertion_ids: JAXRS:JAVADOC:683; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the annotations attached to the entity. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityAnnotationsWhenNoAnnotationsTest() throws Fault { + setTextCaser(TextCaser.UPPER); + setProperty(Property.UNORDERED_SEARCH_STRING, Path.class.getName()); + setProperty(Property.UNORDERED_SEARCH_STRING, POST.class.getName()); + setProperty(Property.CONTENT, "false"); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYANNOTATIONS); + } + + /* + * @testName: getEntityAnnotationsWhenAnnotationsOnEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:683; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the annotations attached to the entity. The entity + * instance annotations array does not include annotations declared on the + * entity implementation class or its ancestors. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityAnnotationsWhenAnnotationsOnEntityTest() throws Fault { + String entity = "getEntityAnnotationsWhenAnnotationsOnEntityTest"; + setTextCaser(TextCaser.UPPER); + setProperty(Property.CONTENT, entity); + setProperty(Property.UNORDERED_SEARCH_STRING, entity); + setProperty(Property.UNORDERED_SEARCH_STRING, "2"); + invokeRequestAndCheckResponse( + ContextOperation.GETENTITYANNOTATIONSONENTITY); + } + + /* + * @testName: getEntityClassStringTest + * + * @assertion_ids: JAXRS:JAVADOC:684; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the raw entity type information. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityClassStringTest() throws Fault { + setProperty(Property.CONTENT, "string"); + setProperty(Property.SEARCH_STRING, String.class.getName()); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYCLASS); + } + + /* + * @testName: getEntityClassByteArrayTest + * + * @assertion_ids: JAXRS:JAVADOC:684; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the raw entity type information. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityClassByteArrayTest() throws Fault { + setProperty(Property.CONTENT, "bytearray"); + setProperty(Property.SEARCH_STRING, "[B"); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYCLASS); + } + + /* + * @testName: getEntityClassInputStreamTest + * + * @assertion_ids: JAXRS:JAVADOC:684; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the raw entity type information. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityClassInputStreamTest() throws Fault { + setProperty(Property.CONTENT, "inputstream"); + setProperty(Property.SEARCH_STRING, ByteArrayInputStream.class.getName()); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYCLASS); + } + + /* + * @testName: getEntityStreamTest + * + * @assertion_ids: JAXRS:JAVADOC:685; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the entity output stream. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityStreamTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.ENTITY); + setProperty(Property.UNEXPECTED_RESPONSE_MATCH, ResponseFilter.NULL); + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.GETENTITYSTREAM); + } + + /* + * @testName: getEntityTagTest + * + * @assertion_ids: JAXRS:JAVADOC:686; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the entity tag, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityTagTest() throws Fault { + setProperty(Property.CONTENT, ResponseFilter.ENTITY); + setProperty(Property.SEARCH_STRING, ResponseFilter.ENTITY); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYTAG); + } + + /* + * @testName: getEntityTagIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:686; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the entity tag, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityTagIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYTAG); + } + + /* + * @testName: getEntityTypeStringTest + * + * @assertion_ids: JAXRS:JAVADOC:687; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the raw entity type information. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityTypeStringTest() throws Fault { + setProperty(Property.CONTENT, "string"); + setProperty(Property.SEARCH_STRING, String.class.getName()); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYTYPE); + } + + /* + * @testName: getEntityTypeByteArrayTest + * + * @assertion_ids: JAXRS:JAVADOC:687; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the raw entity type information. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityTypeByteArrayTest() throws Fault { + setProperty(Property.CONTENT, "bytearray"); + setProperty(Property.SEARCH_STRING, "[B"); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYTYPE); + } + + /* + * @testName: getEntityTypeInputStreamTest + * + * @assertion_ids: JAXRS:JAVADOC:687; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the raw entity type information. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getEntityTypeInputStreamTest() throws Fault { + setProperty(Property.CONTENT, "inputstream"); + setProperty(Property.SEARCH_STRING, ByteArrayInputStream.class.getName()); + invokeRequestAndCheckResponse(ContextOperation.GETENTITYTYPE); + } + + /* + * @testName: getHeadersTest + * + * @assertion_ids: JAXRS:JAVADOC:688; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the mutable response headers multivalued map. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getHeadersTest() throws Fault { + String header = "header"; + for (int i = 0; i != 5; i++) + setProperty(Property.UNORDERED_SEARCH_STRING, header + i); + setProperty(Property.CONTENT, header); + invokeRequestAndCheckResponse(ContextOperation.GETHEADERS); + } + + /* + * @testName: getHeadersIsMutableTest + * + * @assertion_ids: JAXRS:JAVADOC:688; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the mutable response headers multivalued map. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getHeadersIsMutableTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.HEADER); + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.GETHEADERSISMUTABLE); + } + + /* + * @testName: getHeaderStringTest + * + * @assertion_ids: JAXRS:JAVADOC:689; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a message header as a single string value. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getHeaderStringTest() throws Fault { + setProperty(Property.SEARCH_STRING, + ContextOperation.GETHEADERSTRINGOPERATION.name()); + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.GETHEADERSTRINGOPERATION); + } + + /* + * @testName: getHeaderStringHeaderIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:689; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a message header as a single string value. If the + * message header is not present then null is returned. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getHeaderStringHeaderIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + setProperty(Property.CONTENT, "null"); + invokeRequestAndCheckResponse(ContextOperation.GETHEADERSTRINGHEADER); + } + + /* + * @testName: getHeaderStringHeaderUsesToStringMethodTest + * + * @assertion_ids: JAXRS:JAVADOC:689; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a message header as a single string value. Each single + * header value is converted to String using its toString method if a header + * delegate is not available. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getHeaderStringHeaderUsesToStringMethodTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.ENTITY); + setProperty(Property.CONTENT, "toString"); + invokeRequestAndCheckResponse(ContextOperation.GETHEADERSTRINGHEADER); + } + + /* + * @testName: getHeaderStringHeaderUsesHeaderDelegateTest + * + * @assertion_ids: JAXRS:JAVADOC:689; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a message header as a single string value. Each single + * header value is converted to String using a RuntimeDelegate.HeaderDelegate + * if one is available via + * RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the header value + * class + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getHeaderStringHeaderUsesHeaderDelegateTest() throws Fault { + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.SETSTRINGBEANRUNTIME); + + setProperty(Property.SEARCH_STRING, ResponseFilter.ENTITY); + setProperty(Property.CONTENT, "headerDelegate"); + invokeRequestAndCheckResponse(ContextOperation.GETHEADERSTRINGHEADER); + + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.SETORIGINALRUNTIME); + } + + /* + * @testName: getHeaderStringHeaderIsCommaSepearatedTest + * + * @assertion_ids: JAXRS:JAVADOC:689; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a message header as a single string value. If the + * message header is present more than once then the values of joined together + * and separated by a ',' character. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getHeaderStringHeaderIsCommaSepearatedTest() throws Fault { + String entity = ResponseFilter.ENTITY + "," + ResponseFilter.ENTITY; + setProperty(Property.SEARCH_STRING, entity); + setProperty(Property.CONTENT, "commaSeparated"); + invokeRequestAndCheckResponse(ContextOperation.GETHEADERSTRINGHEADER); + } + + /* + * @testName: getLanguageTest + * + * @assertion_ids: JAXRS:JAVADOC:690; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the language of the entity or null if not specified + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLanguageTest() throws Fault { + setProperty(Property.CONTENT, "fr-ca"); + setProperty(Property.SEARCH_STRING, Locale.CANADA_FRENCH.toString()); + invokeRequestAndCheckResponse(ContextOperation.GETLANGUAGE); + } + + /* + * @testName: getLanguageIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:690; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the language of the entity or null if not specified + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLanguageIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETLANGUAGE); + } + + /* + * @testName: getLastModifiedTest + * + * @assertion_ids: JAXRS:JAVADOC:691; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the last modified date, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLastModifiedTest() throws Fault { + long milis = System.currentTimeMillis(); + milis = (milis / 1000) * 1000; + String lastModified = String.valueOf(milis); + setProperty(Property.CONTENT, lastModified); + setProperty(Property.SEARCH_STRING, lastModified); + invokeRequestAndCheckResponse(ContextOperation.GETLASTMODIFIED); + } + + /* + * @testName: getLastModifiedIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:691; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the last modified date, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLastModifiedIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETLASTMODIFIED); + } + + /* + * @testName: getLengthTest + * + * @assertion_ids: JAXRS:JAVADOC:692; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Content-Length as integer if present and valid number. In + * other cases returns -1. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLengthTest() throws Fault { + String entity = ResponseFilter.ENTITY; + setProperty(Property.CONTENT, entity); + String search = ResponseFilter.replaceStart(entity, entity.length()); + setProperty(Property.SEARCH_STRING, search); + invokeRequestAndCheckResponse(ContextOperation.GETLENGTH); + } + + /* + * @testName: getLengthWhenNoEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:692; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Content-Length as integer if present and valid number. In + * other cases returns -1. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLengthWhenNoEntityTest() throws Fault { + setProperty(Property.SEARCH_STRING, "-1"); + invokeRequestAndCheckResponse(ContextOperation.GETLENGTH); + } + + /* + * @testName: getLinkTest + * + * @assertion_ids: JAXRS:JAVADOC:693; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the link for the relation, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLinkTest() throws Fault { + String url = getAbsoluteUrl(); + setProperty(Property.CONTENT, url); + setProperty(Property.SEARCH_STRING, url); + invokeRequestAndCheckResponse(ContextOperation.GETLINK); + } + + /* + * @testName: getLinkWhenNoLinkTest + * + * @assertion_ids: JAXRS:JAVADOC:693; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the link for the relation, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLinkWhenNoLinkTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETLINK); + } + + /* + * @testName: getLinkBuilderTest + * + * @assertion_ids: JAXRS:JAVADOC:694; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the link for the relation, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLinkBuilderTest() throws Fault { + String url = getAbsoluteUrl(); + setProperty(Property.CONTENT, url); + setProperty(Property.SEARCH_STRING, url); + invokeRequestAndCheckResponse(ContextOperation.GETLINKBUILDER); + } + + /* + * @testName: getLinkBuilderWhenNoLinkTest + * + * @assertion_ids: JAXRS:JAVADOC:694; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the link for the relation, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLinkBuilderWhenNoLinkTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETLINKBUILDER); + } + + /* + * @testName: getLinksTest + * + * @assertion_ids: JAXRS:JAVADOC:695; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: links, may return empty Set if no links are present. Never + * returns null. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLinksTest() throws Fault { + String uri1 = getAbsoluteUrl(); + String uri2 = "html://localhost:8080/nohttp"; + setProperty(Property.CONTENT, uri1 + ";" + uri2); + setProperty(Property.UNORDERED_SEARCH_STRING, uri1); + setProperty(Property.UNORDERED_SEARCH_STRING, uri2); + invokeRequestAndCheckResponse(ContextOperation.GETLINKS); + } + + /* + * @testName: getLinksWhenNoLinkTest + * + * @assertion_ids: JAXRS:JAVADOC:695; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: links, may return empty Set if no links are present. Never + * returns null. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLinksWhenNoLinkTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETLINKS); + } + + /* + * @testName: getLocationTest + * + * @assertion_ids: JAXRS:JAVADOC:696; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the location URI, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLocationTest() throws Fault { + String uri = getAbsoluteUrl(); + setProperty(Property.CONTENT, uri); + setProperty(Property.SEARCH_STRING, uri); + invokeRequestAndCheckResponse(ContextOperation.GETLOCATION); + } + + /* + * @testName: getLocationWhenNoLocationTest + * + * @assertion_ids: JAXRS:JAVADOC:696; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the location URI, otherwise null if not present. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getLocationWhenNoLocationTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETLOCATION); + } + + /* + * @testName: getMediaTypeTest + * + * @assertion_ids: JAXRS:JAVADOC:697; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the media type or null if not specified. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getMediaTypeTest() throws Fault { + String uri = MediaType.APPLICATION_SVG_XML; + setProperty(Property.CONTENT, uri); + setProperty(Property.SEARCH_STRING, uri); + invokeRequestAndCheckResponse(ContextOperation.GETMEDIATYPE); + } + + /* + * @testName: getMediaTypeWhenNoMediaTypeTest + * + * @assertion_ids: JAXRS:JAVADOC:697; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the media type or null if not specified. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getMediaTypeWhenNoMediaTypeTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + invokeRequestAndCheckResponse(ContextOperation.GETMEDIATYPE); + } + + /* + * @testName: getStatusTest + * + * @assertion_ids: JAXRS:JAVADOC:698; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get the status code associated with the response. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getStatusTest() throws Fault { + for (Response.Status status : Response.Status.values()) { + String content = String.valueOf(status.getStatusCode()); + setProperty(Property.CONTENT, content); + setProperty(Property.SEARCH_STRING, content); + invokeRequestAndCheckResponse(ContextOperation.GETSTATUS); + } + } + + /* + * @testName: getStatusInfoTest + * + * @assertion_ids: JAXRS:JAVADOC:699; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: the response status information or null if the status was + * not set. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getStatusInfoTest() throws Fault { + for (Response.Status status : Response.Status.values()) { + String content = String.valueOf(status.getStatusCode()); + setProperty(Property.CONTENT, content); + setProperty(Property.SEARCH_STRING, content); + invokeRequestAndCheckResponse(ContextOperation.GETSTATUSINFO); + } + } + + /* + * @testName: getStringHeadersTest + * + * @assertion_ids: JAXRS:JAVADOC:700; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a string view of header values associated with the + * message. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getStringHeadersTest() throws Fault { + String entity = "EnTITY"; + setProperty(Property.SEARCH_STRING, entity); + setProperty(Property.CONTENT, entity); + invokeRequestAndCheckResponse(ContextOperation.GETSTRINGHEADERS); + } + + /* + * @testName: getStringHeadersHeaderIsNullTest + * + * @assertion_ids: JAXRS:JAVADOC:700; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a string view of header values associated with the + * message. If the message header is not present then null is returned. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getStringHeadersHeaderIsNullTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.NULL); + setProperty(Property.CONTENT, "null"); + invokeRequestAndCheckResponse(ContextOperation.GETSTRINGHEADERS); + } + + /* + * @testName: getStringHeadersUsesToStringMethodTest + * + * @assertion_ids: JAXRS:JAVADOC:700; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a string view of header values associated with the + * message. Each single header value is converted to String using its toString + * method if a header delegate is not available. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getStringHeadersUsesToStringMethodTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.ENTITY); + setProperty(Property.CONTENT, "toString"); + invokeRequestAndCheckResponse(ContextOperation.GETSTRINGHEADERS); + } + + /* + * @testName: getStringHeadersUsesHeaderDelegateTest + * + * @assertion_ids: JAXRS:JAVADOC:700; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a string view of header values associated with the + * message. Each single header value is converted to String using a + * RuntimeDelegate.HeaderDelegate if one is available via + * RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the header value + * class + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getStringHeadersUsesHeaderDelegateTest() throws Fault { + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.SETSTRINGBEANRUNTIME); + + setProperty(Property.SEARCH_STRING, ResponseFilter.ENTITY); + setProperty(Property.CONTENT, "headerDelegate"); + invokeRequestAndCheckResponse(ContextOperation.GETSTRINGHEADERS); + + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.SETORIGINALRUNTIME); + } + + /* + * @testName: getStringsHeaderMoreItemsTest + * + * @assertion_ids: JAXRS:JAVADOC:700; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Get a string view of header values associated with the + * message. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void getStringsHeaderMoreItemsTest() throws Fault { + // its twice there + setProperty(Property.SEARCH_STRING_IGNORE_CASE, ResponseFilter.ENTITY); + setProperty(Property.SEARCH_STRING_IGNORE_CASE, ResponseFilter.ENTITY); + setProperty(Property.CONTENT, "commaSeparated"); + invokeRequestAndCheckResponse(ContextOperation.GETSTRINGHEADERS); + } + + /* + * @testName: hasEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:701; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: The method returns true if the entity is present, returns + * false otherwise. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void hasEntityTest() throws Fault { + setProperty(Property.CONTENT, ResponseFilter.ENTITY); + setProperty(Property.SEARCH_STRING, "true"); + invokeRequestAndCheckResponse(ContextOperation.HASENTITY); + } + + /* + * @testName: hasEntityWhenNoEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:701; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: The method returns true if the entity is present, returns + * false otherwise. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void hasEntityWhenNoEntityTest() throws Fault { + setProperty(Property.SEARCH_STRING, "false"); + invokeRequestAndCheckResponse(ContextOperation.HASENTITY); + } + + /* + * @testName: hasLinkTest + * + * @assertion_ids: JAXRS:JAVADOC:702; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Check if link for relation exists. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void hasLinkTest() throws Fault { + String url = getAbsoluteUrl(); + setProperty(Property.CONTENT, url); + setProperty(Property.SEARCH_STRING, "true"); + invokeRequestAndCheckResponse(ContextOperation.HASLINK); + } + + /* + * @testName: hasLinkWhenNoLinkTest + * + * @assertion_ids: JAXRS:JAVADOC:702; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Check if link for relation exists. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void hasLinkWhenNoLinkTest() throws Fault { + setProperty(Property.SEARCH_STRING, "false"); + invokeRequestAndCheckResponse(ContextOperation.HASLINK); + } + + /* + * @testName: setEntityTest + * + * @assertion_ids: JAXRS:JAVADOC:703; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Set a new response message entity. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void setEntityTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.ENTITY); + invokeRequestAndCheckResponse(Request.GET, ContextOperation.SETENTITY); + } + + /* + * @testName: setEntityStreamTest + * + * @assertion_ids: JAXRS:JAVADOC:704; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Set a new entity output stream. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void setEntityStreamTest() throws Fault { + setProperty(Property.SEARCH_STRING, ResponseFilter.ENTITY); + setProperty(Property.SEARCH_STRING, "OK"); + invokeRequestAndCheckResponse(Request.GET, + ContextOperation.SETENTITYSTREAM); + } + + /* + * @testName: setStatusTest + * + * @assertion_ids: JAXRS:JAVADOC:705; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Set a new response status code + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void setStatusTest() throws Fault { + for (Response.Status status : Response.Status.values()) { + String content = String.valueOf(status.getStatusCode()); + setProperty(Property.CONTENT, content); + setProperty(Property.STATUS_CODE, content); + invokeRequestAndCheckResponse(ContextOperation.SETSTATUS); + } + } + + /* + * @testName: setStatusInfoTest + * + * @assertion_ids: JAXRS:JAVADOC:706; JAXRS:JAVADOC:707; JAXRS:JAVADOC:708; + * + * @test_Strategy: Set the complete status information associated with the + * response. + * + * Filter method called after a response has been provided for a request. + * Throws IOException. + */ + @Test + public void setStatusInfoTest() throws Fault { + for (Response.Status status : Response.Status.values()) { + String content = String.valueOf(status.getStatusCode()); + setProperty(Property.CONTENT, content); + setProperty(Property.STATUS_CODE, content); + invokeRequestAndCheckResponse(ContextOperation.SETSTATUSINFO); + } + } + + // //////////////////////////////////////////////////////////////////////////// + + protected void invokeRequestAndCheckResponse(ContextOperation operation) + throws Fault { + String request; + request = buildRequest(Request.POST, operation.name().toLowerCase()); + setProperty(Property.REQUEST, request); + invoke(); + } + + protected void invokeRequestAndCheckResponse(Request method, + ContextOperation operation) throws Fault { + String request; + request = buildRequest(method, operation.name().toLowerCase()); + setProperty(Property.REQUEST, request); + invoke(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/Resource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/Resource.java new file mode 100644 index 0000000..847e204 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/Resource.java
@@ -0,0 +1,423 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.responsecontext; + +import java.io.ByteArrayInputStream; +import java.lang.annotation.Annotation; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Date; +import java.util.List; + +import jakarta.ws.rs.tck.common.provider.StringBean; +import jakarta.ws.rs.tck.common.provider.StringBeanRuntimeDelegate; +import jakarta.ws.rs.tck.common.provider.StringBeanWithAnnotation; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.EntityTag; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.Link; +import jakarta.ws.rs.core.NewCookie; +import jakarta.ws.rs.core.PathSegment; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.ResponseBuilder; +import jakarta.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.UriInfo; +import jakarta.ws.rs.ext.RuntimeDelegate; + +@Path("resource") +public class Resource { + + @Context + UriInfo info; + + @Path("getallowedmethods") + @GET + public Response getAllowedMethods() { + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.allow("OPTIONS", "TRACE").build(); + return response; + } + + @Path("getcookies") + @GET + public Response getCookies() { + NewCookie cookie = new NewCookie(ResponseFilter.COOKIENAME, + ResponseFilter.COOKIENAME); + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.cookie(cookie).build(); + return response; + } + + @Path("getcookiesisreadonly") + @GET + public Response getCookiesIsReadOnly() { + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.build(); + return response; + } + + @POST + @Path("getdate") + public Response getDate(String text) { + ResponseBuilder builder = createResponseWithHeader(); + if (text != null && text.length() != 0) { + long milis = Long.valueOf(text); + Date date = new Date(milis); + builder = builder.header("Date", date); + } + Response response = builder.build(); + return response; + } + + @POST + @Path("getentity") + public Response getEntity(String entity) { + ResponseBuilder builder = createResponseWithHeader(); + if (entity != null && entity.length() != 0) + builder = builder.entity(entity.getBytes()); + Response response = builder.build(); + return response; + } + + @POST + @Path("getentityannotations") + public Response getEntityAnnotations(String setEntity) { + Annotation[] annotations = ResponseFilter.class.getAnnotations(); + ResponseBuilder builder = createResponseWithHeader(); + if (Boolean.parseBoolean(setEntity)) + builder = builder.entity("entity", annotations); + Response response = builder.build(); + return response; + } + + @POST + @Path("getentityannotationsonentity") + public Response getEntityAnnotationsOnEntity(String entity) { + ResponseBuilder builder = createResponseWithHeader(); + builder = builder.entity(new StringBeanWithAnnotation(entity)); + Response response = builder.build(); + return response; + } + + @POST + @Path("getentityclass") + public Response getEntityClass(String clazz) { + String content = "ENTity"; + ResponseBuilder builder = createResponseWithHeader(); + Object entity = null; + if ("string".equals(clazz)) + entity = content; + else if ("bytearray".equals(clazz)) + entity = content.getBytes(); + else if ("inputstream".equals(clazz)) + entity = new ByteArrayInputStream(content.getBytes()); + builder = builder.entity(entity); + Response response = builder.build(); + return response; + } + + @GET + @Path("getentitystream") + public Response getEntityStream() { + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.build(); + return response; + } + + @POST + @Path("getentitytag") + public Response getEntityTag(String tagName) { + ResponseBuilder builder = createResponseWithHeader(); + if (tagName != null && tagName.length() != 0) { + EntityTag tag = new EntityTag(tagName); + builder = builder.tag(tag); + } + Response response = builder.build(); + return response; + } + + @POST + @Path("getentitytype") + public Response getEntityType(String type) { + ResponseBuilder builder = createResponseWithHeader(); + Object entity = null; + String content = "ENTity"; + if ("string".equals(type)) + entity = content; + else if ("bytearray".equals(type)) + entity = content.getBytes(); + else if ("inputstream".equals(type)) + entity = new ByteArrayInputStream(content.getBytes()); + builder = builder.entity(entity); + Response response = builder.build(); + return response; + } + + @GET + @Path("setentitystream") + public Response setEntityStream() { + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.build(); + return response; + } + + @POST + @Path("getheaders") + public Response getHeaders(String header) { + ResponseBuilder builder = createResponseWithHeader(); + for (int i = 0; i != 5; i++) + builder = builder.header(header + i, header); + Response response = builder.build(); + return response; + } + + @GET + @Path("getheadersismutable") + public Response getHeadersIsMutable() { + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.build(); + return response; + } + + @GET + @Path("getheaderstringoperation") + public Response getHeaderStringByOperation() { + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.build(); + return response; + } + + @POST + @Path("getheaderstringheader") + public Response getHeaderStringByHeader(String content) { + ResponseBuilder builder = createResponseWithHeader(); + if (content.equals("toString")) + builder = builder.header(ResponseFilter.HEADER, + new StringBuilder().append(ResponseFilter.ENTITY)); + if (content.equals("commaSeparated")) { + builder = builder.header(ResponseFilter.HEADER, + new StringBuilder().append(ResponseFilter.ENTITY)); + builder = builder.header(ResponseFilter.HEADER, ResponseFilter.ENTITY); + } + if (content.equals("headerDelegate")) { + StringBean bean = new StringBean(ResponseFilter.ENTITY); + builder = builder.header(ResponseFilter.HEADER, bean); + } + if (content.equalsIgnoreCase("entity")) + builder = builder.header(ResponseFilter.HEADER, content); + Response response = builder.build(); + return response; + } + + @POST + @Path("getlanguage") + public Response getLanguage(String language) { + ResponseBuilder builder = createResponseWithHeader(); + if (language != null && language.length() != 0) + builder = builder.language(language); + Response response = builder.build(); + return response; + } + + @POST + @Path("getlastmodified") + public Response getLastModified(String last) { + ResponseBuilder builder = createResponseWithHeader(); + if (last != null && last.length() != 0) { + long lastMilist = Long.parseLong(last); + Date date = new Date(lastMilist); + builder = builder.lastModified(date); + } + Response response = builder.build(); + return response; + } + + @POST + @Path("getlength") + public Response getLength(String entity) { + ResponseBuilder builder = createResponseWithHeader(); + if (entity != null && entity.length() != 0) + builder = builder.entity(entity).header(HttpHeaders.CONTENT_LENGTH, + entity.length()); + Response response = builder.build(); + return response; + } + + @POST + @Path("getlink") + public Response getLink(String uri) { + ResponseBuilder builder = createResponseWithHeader(); + if (uri != null && uri.length() != 0) { + Link link = Link.fromUri(uri).rel(ResponseFilter.RELATION).build(); + builder = builder.links(link); + } + Response response = builder.build(); + return response; + } + + @POST + @Path("getlinkbuilder") + public Response getLinkBuilder(String uri) { + return getLink(uri); + } + + @POST + @Path("getlinks") + public Response getLinks(String uris) { + ResponseBuilder builder = createResponseWithHeader(); + if (uris != null && uris.length() != 0) { + String[] tokens = uris.split(";"); + Link[] links = new Link[tokens.length]; + for (int i = 0; i != tokens.length; i++) + links[i] = Link.fromUri(tokens[i]).build(); + builder = builder.links(links); + } + Response response = builder.build(); + return response; + } + + @POST + @Path("getlocation") + public Response getLocation(String uri) throws URISyntaxException { + ResponseBuilder builder = createResponseWithHeader(); + if (uri != null && uri.length() != 0) + builder = builder.location(new URI(uri)); + Response response = builder.build(); + return response; + } + + @POST + @Path("getmediatype") + public Response getMediaType(String media) throws URISyntaxException { + ResponseBuilder builder = createResponseWithHeader(); + if (media != null && media.length() != 0) + builder = builder.type(media); + Response response = builder.build(); + return response; + } + + @POST + @Path("getstatus") + public Response getStatus(String entity) { + int status = Integer.parseInt(entity); + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.status(status).build(); + return response; + } + + @POST + @Path("getstatusinfo") + public Response getStatusinfo(String entity) { + return getStatus(entity); + } + + @POST + @Path("getstringheaders") + public Response getStringHeaders(String content) { + return getHeaderStringByHeader(content); + } + + @POST + @Path("hasentity") + public Response hasEntity(String entity) { + ResponseBuilder builder = createResponseWithHeader(); + if (entity != null && entity.length() != 0) + builder = builder.entity(entity); + Response response = builder.build(); + return response; + } + + @POST + @Path("haslink") + public Response hasLink(String uri) { + return getLink(uri); + } + + @GET + @Path("setentity") + public Response setEntity() { + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.build(); + return response; + } + + @POST + @Path("setstatus") + public Response setStatus(String status) { + ResponseBuilder builder = createResponseWithHeader(); + Response response = builder.entity(status).build(); + return response; + } + + @POST + @Path("setstatusinfo") + public Response setStatusInfo(String status) { + return setStatus(status); + } + + // For the methods that checks for the header delegate this is the way + // to add header delegate by switching runtimedelegate + // As long as the runtime delegate is one only for whole classloader + @Path("setstringbeanruntime") + @GET + public Response setStringBeanRuntime() { + RuntimeDelegate original = RuntimeDelegate.getInstance(); + if (!(original instanceof StringBeanRuntimeDelegate)) { + StringBeanRuntimeDelegate sbrd = new StringBeanRuntimeDelegate(original); + RuntimeDelegate.setInstance(sbrd); + } + return createResponseWithHeader().build(); + } + + // We need to switch back to the original runtime delegate since + // we cannot be sure what happen when the war with our runtimedelegate gets + // undeployed + @Path("setoriginalruntime") + @GET + public Response setOriginalRuntime() { + ResponseBuilder builder = createResponseWithHeader(); + RuntimeDelegate stringBeanDelegate = RuntimeDelegate.getInstance(); + if (stringBeanDelegate instanceof StringBeanRuntimeDelegate) { + RuntimeDelegate original = ((StringBeanRuntimeDelegate) stringBeanDelegate) + .getOriginal(); + RuntimeDelegate.setInstance(original); + } else + builder = builder.status(Status.NO_CONTENT); + return builder.build(); + } + + // ////////////////////////////////////////////////////////////////// + + private ResponseBuilder createResponseWithHeader() { + // get value of @Path(value) + List<PathSegment> segments = info.getPathSegments(); + PathSegment last = segments.get(segments.size() - 1); + // convert the value to ContextOperation + ContextOperation op = ContextOperation + .valueOf(last.getPath().toUpperCase()); + Response.ResponseBuilder builder = Response.ok(); + // set a header with ContextOperation so that the filter knows what to + // do + builder = builder.header(ResponseFilter.OPERATION, op.name()); + return builder; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/ResponseFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/ResponseFilter.java new file mode 100644 index 0000000..206722a --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/ResponseFilter.java
@@ -0,0 +1,379 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.responsecontext; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import java.net.URI; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import jakarta.ws.rs.tck.common.provider.StringBeanWithAnnotation; +import jakarta.ws.rs.tck.common.util.JaxrsUtil; + +import jakarta.annotation.Priority; +import jakarta.ws.rs.core.EntityTag; +import jakarta.ws.rs.core.Link; +import jakarta.ws.rs.core.Link.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.NewCookie; +import jakarta.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status.Family; +import jakarta.ws.rs.core.Response.StatusType; +import jakarta.ws.rs.ext.Provider; + +@Provider +@Priority(500) +// reverse order +public class ResponseFilter extends TemplateFilter { + public static final String COOKIENAME = "CookieName"; + + public static final String ENTITY = "ResponseFilterEntity"; + + public static final String NULL = "NULL"; + + public static final String RELATION = "relation"; + + public void getAllowedMethods() { + Set<String> set = responseContext.getAllowedMethods(); + setEntity(collectionToString(set)); + for (String s : set) + if (!s.toUpperCase().equals(s)) { + setEntity(s + " is not uppercase"); + break; + } + } + + public void getCookies() { + Map<String, NewCookie> cookies = responseContext.getCookies(); + setEntity(collectionToString(cookies.keySet())); + } + + public void getCookiesIsReadOnly() { + NewCookie cookie = new NewCookie(COOKIENAME, COOKIENAME); + Map<String, NewCookie> cookies = responseContext.getCookies(); + if (assertTrue(!cookies.containsKey(COOKIENAME), COOKIENAME, + "is already present")) + return; + try { + cookies.put(COOKIENAME, cookie); + } catch (Exception e) { + // Not mandatory, but possible as cookies is read-only + } + cookies = responseContext.getCookies(); + if (assertTrue(!cookies.containsKey(COOKIENAME), + "#getCookies is Not readOnly")) + return; + setEntity("getCookies is read-only as expected"); + } + + public void getDate() { + Date date = responseContext.getDate(); + long milis = date == null ? 0 : date.getTime(); + setEntity(String.valueOf(milis)); + } + + public void getEntity() { + byte[] entity = (byte[]) responseContext.getEntity(); + if (entity != null) + setEntity(new String(entity) + new String(entity)); + else + setEntity(NULL); + } + + public void getEntityAnnotations() { + Annotation[] annotations = responseContext.getEntityAnnotations(); + if (annotations != null && annotations.length != 0) { + String[] names = new String[annotations.length]; + for (int i = 0; i != annotations.length; i++) + names[i] = annotations[i].annotationType().getName(); + setEntity(collectionToString(Arrays.asList(names))); + } else + setEntity(NULL); + } + + public void getEntityAnnotationsOnEntity() { + Annotation[] annotations = responseContext.getEntityAnnotations(); + String entity = responseContext.hasEntity() + ? ((StringBeanWithAnnotation) responseContext.getEntity()).get() + : NULL; + String annotationCount = annotations == null ? NULL + : String.valueOf(annotations.length); + setEntity(entity + " " + annotationCount); + } + + public void getEntityClass() { + Class<?> clazz = responseContext.getEntityClass(); + setEntity(clazz.getName()); + } + + public void getEntityStream() throws IOException { + OutputStream stream = responseContext.getEntityStream(); + if (stream == null) + setEntity(NULL); + else + setEntity(ENTITY); + } + + public void getEntityTag() { + EntityTag tag = responseContext.getEntityTag(); + setEntity(tag == null ? NULL : tag.getValue()); + } + + public void getEntityType() { + Type type = responseContext.getEntityType(); + String name = NULL; + if (type instanceof Class) + name = ((Class<?>) type).getName(); + else if (type != null) + name = type.getClass().getName(); + setEntity(name); + } + + public void getHeaders() { + MultivaluedMap<String, Object> headers = responseContext.getHeaders(); + setEntity(collectionToString(headers.keySet())); + } + + public void getHeadersIsMutable() { + MultivaluedMap<String, Object> headers = responseContext.getHeaders(); + if (assertTrue(!headers.containsKey(HEADER), HEADER, + "header is alredy in header map")) + return; + headers.add(HEADER, HEADER); + headers = responseContext.getHeaders(); + if (assertTrue(headers.containsKey(HEADER), HEADER, + "header is not in header map")) + return; + // second filter run + } + + public void getHeaderStringOperation() { + String header = responseContext.getHeaderString(OPERATION); + setEntity(header); + } + + public void getHeaderStringHeader() { + String header = responseContext.getHeaderString(HEADER); + setEntity(header == null ? NULL : header); + } + + public void getLanguage() { + Locale locale = responseContext.getLanguage(); + setEntity(locale == null ? NULL : locale.toString()); + } + + public void getLastModified() { + Date date = responseContext.getLastModified(); + setEntity(date == null ? NULL : String.valueOf(date.getTime())); + } + + public void getLength() { + int contentLen = responseContext.getLength(); + String entity = (String) responseContext.getEntity(); + setEntity(replaceStart(entity, contentLen)); + } + + public static String replaceStart(String where, int by) { + StringBuilder sb = new StringBuilder().append(by); + if (where != null) + sb.append(where.substring(String.valueOf(by).length())); + return sb.toString(); + } + + public void getLink() { + Link link = responseContext.getLink(RELATION); + setLinkForGetLink(link); + } + + public void getLinkBuilder() { + Builder builder = responseContext.getLinkBuilder(RELATION); + if (builder != null) { + Link link = builder.build(); + setLinkForGetLink(link); + } else + setEntity(NULL); + } + + private void setLinkForGetLink(Link link) { + String entity = NULL; + if (link != null && link.getUri() != null) + entity = link.getUri().toASCIIString(); + setEntity(entity); + } + + public void getLinks() { + Set<Link> set = responseContext.getLinks(); + if (assertTrue(set != null, "#getLinks shall never be null")) + return; + if (set.size() == 0) { + setEntity(NULL); + return; + } + Set<String> strings = new HashSet<String>(); + for (Link link : set) + strings.add(link.toString()); + setEntity(JaxrsUtil.iterableToString(";", strings)); + } + + public void getLocation() { + URI uri = responseContext.getLocation(); + setEntity(uri == null ? NULL : uri.toASCIIString()); + } + + public void getMediaType() { + MediaType type = responseContext.getMediaType(); + setEntity(type == null ? NULL : type.toString()); + } + + public void getStatus() { + int status = responseContext.getStatus(); + responseContext.setStatus(Status.OK.getStatusCode()); + setEntity(String.valueOf(status)); + } + + public void getStatusNotSet() { + getStatus(); + } + + public void getStatusInfo() { + StatusType type = responseContext.getStatusInfo(); + if (type == null) { + setEntity(NULL); + responseContext.setStatus(Status.OK.getStatusCode()); + return; + } + int status = type.getStatusCode(); + responseContext.setStatus(Status.OK.getStatusCode()); + setEntity(String.valueOf(status)); + } + + public void getStatusInfoNotSet() { + getStatusInfo(); + } + + public void getStringHeaders() { + MultivaluedMap<String, String> map = responseContext.getStringHeaders(); + List<String> list = map.get(HEADER); + setEntity(list == null ? NULL + : list.size() == 1 ? list.iterator().next() : collectionToString(list)); + } + + public void hasEntity() { + boolean has = responseContext.hasEntity(); + setEntity(String.valueOf(has)); + } + + public void hasLink() { + boolean has = responseContext.hasLink(RELATION); + setEntity(String.valueOf(has)); + } + + public void setEntity() { + Annotation[] annotations = getClass().getAnnotations(); + MediaType type = MediaType.APPLICATION_SVG_XML_TYPE; + responseContext.setEntity(ENTITY, annotations, type); + } + + public void setEntityStream() { + final OutputStream stream = responseContext.getEntityStream(); + OutputStream byteStream = new OutputStream() { + @Override + public void write(byte[] b) throws IOException { + stream.write(ENTITY.getBytes()); + stream.write(b); + } + + @Override + public void write(int b) throws IOException { + write(intToByteArray(b)); + } + + @Override + public synchronized void write(byte[] b, int off, int len) + throws IOException { + write(b); + } + + public final byte[] intToByteArray(int value) { + return new byte[] { (byte) (value & 0xff) }; + } + }; + responseContext.setEntityStream(byteStream); + StringBuilder sb = new StringBuilder(ENTITY.length() + 4); + for (int i = 0; i < ENTITY.length() + 3; i += 2) + sb.append("OK"); + setEntity(sb.toString()); + } + + public void setStatus() { + String entity = (String) responseContext.getEntity(); + int status = Integer.parseInt(entity); + responseContext.setStatus(status); + resetStatusEntity(status); + } + + public void setStatusInfo() { + String entity = (String) responseContext.getEntity(); + final int status = Integer.parseInt(entity); + StatusType type = new StatusType() { + + @Override + public int getStatusCode() { + return status; + } + + @Override + public String getReasonPhrase() { + return null; + } + + @Override + public Family getFamily() { + return Family.familyOf(status); + } + }; + responseContext.setStatusInfo(type); + resetStatusEntity(status); + } + + private void resetStatusEntity(int status) { + switch (status) { + case 204: + case 205: + responseContext.setEntity(null); + break; + } + } + + public void setStringBeanRuntime() { + // pass + } + + public void setOriginalRuntime() { + // pass + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/SecondResponseFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/SecondResponseFilter.java new file mode 100644 index 0000000..b5a3999 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/SecondResponseFilter.java
@@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.responsecontext; + +import java.lang.annotation.Annotation; + +import jakarta.annotation.Priority; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.Provider; + +@Provider +@Priority(100) +// reverse order, should be second +public class SecondResponseFilter extends TemplateFilter { + @Override + protected void operationMethodNotFound(String operation) { + // the check is to apply on ResponseFilter only + // here, it is usually not found. + } + + public void getHeadersIsMutable() { + MultivaluedMap<String, Object> headers = responseContext.getHeaders(); + if (assertTrue(headers.containsKey(HEADER), HEADER, + "header is not in header map")) + return; + setEntity(HEADER + " found as expected"); + } + + public void setEntity() { + MediaType type = responseContext.getMediaType(); + if (assertTrue(MediaType.APPLICATION_SVG_XML_TYPE.equals(type), + "Unexpected mediatype", type)) + return; + + Annotation[] annotations = responseContext.getEntityAnnotations(); + for (Annotation annotation : annotations) { + Class<?> clazz = annotation.annotationType(); + if (assertTrue(clazz == Provider.class || clazz == Priority.class, + "Annotation", clazz, "was unexpected")) + return; + } + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/TSAppConfig.java new file mode 100644 index 0000000..934b1f2 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/TSAppConfig.java
@@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.responsecontext; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.common.provider.PrintingErrorHandler; +import jakarta.ws.rs.tck.common.provider.StringBeanEntityProvider; + +import jakarta.ws.rs.core.Application; + +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(Resource.class); + resources.add(ResponseFilter.class); + resources.add(SecondResponseFilter.class); + resources.add(PrintingErrorHandler.class); + resources.add(StringBeanEntityProvider.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/TemplateFilter.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/TemplateFilter.java new file mode 100644 index 0000000..f099812 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/container/responsecontext/TemplateFilter.java
@@ -0,0 +1,103 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.container.responsecontext; + +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import java.lang.reflect.Method; +import java.util.Collection; + +import jakarta.ws.rs.container.ContainerRequestContext; +import jakarta.ws.rs.container.ContainerResponseContext; +import jakarta.ws.rs.container.ContainerResponseFilter; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response.Status; + +public abstract class TemplateFilter implements ContainerResponseFilter { + + public static final String OPERATION = "OPERATION"; + + public static final String PROPERTYNAME = "getSetProperty"; + + public static final String HEADER = "HEADER"; + + protected ContainerRequestContext requestContext; + + protected ContainerResponseContext responseContext; + + @Override + public void filter(ContainerRequestContext requestContext, + ContainerResponseContext responseContext) throws IOException { + this.requestContext = requestContext; + this.responseContext = responseContext; + String operation = getHeaderString(); + Method[] methods = getClass().getMethods(); + for (Method method : methods) + if (operation.equalsIgnoreCase(method.getName())) { + try { + method.invoke(this); + return; + } catch (Exception e) { + e.printStackTrace(); + responseContext.setStatus(Status.SERVICE_UNAVAILABLE.getStatusCode()); + setEntity(e.getMessage()); + return; + } + } + operationMethodNotFound(operation); + } + + protected void operationMethodNotFound(String operation) { + responseContext.setStatus(Status.SERVICE_UNAVAILABLE.getStatusCode()); + setEntity("Operation " + operation + " not implemented"); + } + + // //////////////////////////////////////////////////////////////////// + protected static <T> String collectionToString(Collection<T> collection) { + StringBuilder sb = new StringBuilder(); + for (T item : collection) { + String replace = item.toString().toLowerCase().replace("_", "-") + .replace(" ", ""); + sb.append(replace).append(" "); + } + return sb.toString(); + } + + protected boolean assertTrue(boolean conditionTrue, Object... msg) { + if (conditionTrue) + return false; + StringBuilder sb = new StringBuilder(); + if (msg != null) + for (Object str : msg) + sb.append(str).append(" "); + setEntity(sb.toString()); + responseContext.setStatus(Status.NOT_ACCEPTABLE.getStatusCode()); + return true; + } + + // might be replaced with ctx.getStringHeader() + protected String getHeaderString() { + MultivaluedMap<String, Object> headers = responseContext.getHeaders(); + return (String) headers.getFirst(OPERATION); + } + + protected void setEntity(String entity) { + responseContext.setEntity(entity, null, MediaType.TEXT_PLAIN_TYPE); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/CookieParamTest.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/CookieParamTest.java new file mode 100644 index 0000000..2c70f3d --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/CookieParamTest.java
@@ -0,0 +1,137 @@ +/* + * Copyright (c) 2008, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; +import jakarta.ws.rs.tck.ee.rs.ParamTest; + +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.Cookie; +import jakarta.ws.rs.core.NewCookie; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.ResponseBuilder; + +@Path(value = "/CookieParamTest") +public class CookieParamTest extends ParamTest { + + @DefaultValue("CookieParamTest") + @CookieParam("FieldParamEntityWithConstructor") + ParamEntityWithConstructor fieldParamEntityWithConstructor; + + @DefaultValue("CookieParamTest") + @CookieParam("FieldParamEntityWithFromString") + ParamEntityWithFromString fieldParamEntityWithFromString; + + @DefaultValue("CookieParamTest") + @CookieParam("FieldParamEntityWithValueOf") + ParamEntityWithValueOf fieldParamEntityWithValueOf; + + @DefaultValue("CookieParamTest") + @CookieParam("FieldSetParamEntityWithFromString") + Set<ParamEntityWithFromString> fieldSetParamEntityWithFromString; + + @DefaultValue("CookieParamTest") + @CookieParam("FieldSortedSetParamEntityWithFromString") + SortedSet<ParamEntityWithFromString> fieldSortedSetParamEntityWithFromString; + + @DefaultValue("CookieParamTest") + @CookieParam("FieldListParamEntityWithFromString") + List<ParamEntityWithFromString> fieldListParamEntityWithFromString; + + @CookieParam("FieldParamEntityThrowingWebApplicationException") + public ParamEntityThrowingWebApplicationException fieldParamEntityThrowingWebApplicationException; + + @CookieParam("FieldParamEntityThrowingExceptionGivenByName") + public ParamEntityThrowingExceptionGivenByName fieldParamEntityThrowingExceptionGivenByName; + + @GET + public Response cookieParamHandling(@QueryParam("todo") String todo, + @CookieParam("name1") @DefaultValue("abc") String value, + @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithConstructor") ParamEntityWithConstructor paramEntityWithConstructor, + @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithFromString") ParamEntityWithFromString paramEntityWithFromString, + @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithValueOf") ParamEntityWithValueOf paramEntityWithValueOf, + @DefaultValue("CookieParamTest") @CookieParam("SetParamEntityWithFromString") Set<ParamEntityWithFromString> setParamEntityWithFromString, + @DefaultValue("CookieParamTest") @CookieParam("SortedSetParamEntityWithFromString") SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString, + @DefaultValue("CookieParamTest") @CookieParam("ListParamEntityWithFromString") List<ParamEntityWithFromString> listParamEntityWithFromString, + @CookieParam("ParamEntityThrowingWebApplicationException") ParamEntityThrowingWebApplicationException paramEntityThrowingWebApplicationException, + @CookieParam("ParamEntityThrowingExceptionGivenByName") ParamEntityThrowingExceptionGivenByName paramEntityThrowingExceptionGivenByName) { + + sb = new StringBuilder(); + Response.ResponseBuilder respb = Response.status(200); + + if (todo == null) { + sb.append("todo=null"); + } else if (todo.equalsIgnoreCase("setCookie")) { + String cookie_name = "name1"; + String cookie_value = "value1"; + Cookie ck = new Cookie(cookie_name, cookie_value); + NewCookie nck = new NewCookie(ck); + respb = respb.cookie(nck); + sb.append("setCookie=done"); + } else if (todo.equalsIgnoreCase("verifycookie")) { + sb.append("name1" + "=" + value); + sb.append("verifyCookie=done"); + } else if (todo.equals("")) { + setReturnValues(paramEntityWithConstructor, paramEntityWithFromString, + paramEntityWithValueOf, setParamEntityWithFromString, + sortedSetParamEntityWithFromString, listParamEntityWithFromString, + ""); + setReturnValues(fieldParamEntityWithConstructor, + fieldParamEntityWithFromString, fieldParamEntityWithValueOf, + fieldSetParamEntityWithFromString, + fieldSortedSetParamEntityWithFromString, + fieldListParamEntityWithFromString, FIELD); + } else if (todo.contains("ParamEntity")) { + setNewCookie(respb, todo); + setReturnValues(paramEntityWithConstructor, paramEntityWithFromString, + paramEntityWithValueOf, setParamEntityWithFromString, + sortedSetParamEntityWithFromString, listParamEntityWithFromString, + ""); + setReturnValues(fieldParamEntityWithConstructor, + fieldParamEntityWithFromString, fieldParamEntityWithValueOf, + fieldSetParamEntityWithFromString, + fieldSortedSetParamEntityWithFromString, + fieldListParamEntityWithFromString, FIELD); + } else { + sb.append("other stuff"); + } + + return respb.entity(sb.toString()).build(); + } + + private static void setNewCookie(ResponseBuilder rb, String queryParam) { + if (!queryParam.contains("=")) + return; + String[] split = queryParam.split("="); + Cookie cookie = new Cookie(split[0], split[1]); + NewCookie newCookie = new NewCookie(cookie); + rb.cookie(newCookie); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/JAXRSClientIT.java new file mode 100644 index 0000000..ca83969 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/JAXRSClientIT.java
@@ -0,0 +1,406 @@ +/* + * Copyright (c) 2007, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ +package jakarta.ws.rs.tck.ee.rs.cookieparam; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.common.util.JaxrsUtil; +import jakarta.ws.rs.tck.ee.rs.JaxrsParamClient; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JaxrsParamClient { + private static final long serialVersionUID = 1L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_cookieparam_web/CookieParamTest"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false, name = "cookieparam") + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/cookieparam/web.xml.template"); + String webXml = editWebXmlString(inStream); + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_cookieparam_web.war"); + archive.addClasses(TSAppConfig.class, CookieParamTest.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + + /* Run test */ + /* + * @testName: cookieParamTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:JAVADOC:145; JAXRS:JAVADOC:2; + * + * @test_Strategy: Client invokes GET on root resource at /CookieParamTest; + * Resource will respond with a cookie; Client verify the cookie is received; + * Client send request again with the cookie; Verify that the cookie is + * received using CookieParam in the resource; Verify on the client side from + * response. + */ + @Test + public void cookieParamTest() throws Fault { + StringBuffer sb = new StringBuffer(); + boolean pass = true; + + setProperty(Property.REQUEST, buildRequest("setcookie")); + setProperty(Property.SEARCH_STRING, "setCookie=done"); + setProperty(Property.EXPECTED_HEADERS, "Set-Cookie:name1=value1"); + setProperty(Property.SAVE_STATE, "true"); + try { + invoke(); + } catch (Exception ex) { + pass = false; + sb.append("Test failed with: " + ex.getMessage()); + } + + setProperty(Property.REQUEST, buildRequest("verifycookie")); + setProperty(Property.SEARCH_STRING, "name1=value1|verifyCookie=done"); + setProperty(Property.USE_SAVED_STATE, "true"); + try { + invoke(); + } catch (Exception ex) { + pass = false; + sb.append("Test failed with: " + ex.getMessage()); + } + + assertTrue(pass, "At least one assertion failed:"+ sb); + } + + /* + * @testName: cookieParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.2; JAXRS:JAVADOC:12; + * JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamEntityWithConstructorTest() throws Fault { + super.paramEntityWithConstructorTest(); + } + + /* + * @testName: cookieParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:JAVADOC:12; + * JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamEntityWithValueOfTest() throws Fault { + super.paramEntityWithValueOfTest(); + } + + /* + * @testName: cookieParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:JAVADOC:12; + * JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamEntityWithFromStringTest() throws Fault { + super.paramEntityWithFromStringTest(); + } + + /* + * @testName: cookieParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:JAVADOC:12; + * JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: cookieParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:JAVADOC:12; + * JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamListEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: cookieParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:JAVADOC:12; + * JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieParamSortedSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: cookieFieldParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.2; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamEntityWithConstructorTest() throws Fault { + super.fieldEntityWithConstructorTest(); + } + + /* + * @testName: cookieFieldParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamEntityWithValueOfTest() throws Fault { + super.fieldEntityWithValueOfTest(); + } + + /* + * @testName: cookieFieldParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamEntityWithFromStringTest() throws Fault { + super.fieldEntityWithFromStringTest(); + } + + /* + * @testName: cookieFieldParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: cookieFieldParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldParamListEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: cookieFieldSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named CookieParam is handled properly + */ + @Test + public void cookieFieldSortedSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: cookieParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + * + */ + @Test + public void cookieParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: cookieFieldThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:8; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + */ + @Test + public void cookieFieldThrowingWebApplicationExceptionTest() throws Fault { + super.fieldThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: cookieParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.2; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @HeaderParam or @CookieParam + * then an implementation MUST generate a WebApplicationException that wraps + * the thrown exception with a client error response (400 status) and no + * entity. + */ + @Test + public void cookieParamThrowingIllegalArgumentExceptionTest() throws Fault { + super.paramThrowingIllegalArgumentExceptionTest(); + } + + /* + * @testName: cookieFieldParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + */ + @Test + public void cookieFieldParamThrowingIllegalArgumentExceptionTest() + throws Fault { + super.fieldThrowingIllegalArgumentExceptionTest(); + } + + @Override + protected void paramEntityThrowingAfterRequestSet(String request) + throws Fault { + createAndCheckCookie(request); + // this is for illegal argument exception tests only + if (request.contains(IllegalArgumentException.class.getSimpleName())) + setProperty(Property.UNORDERED_SEARCH_STRING, Status.BAD_REQUEST.name()); + super.paramEntityThrowingAfterRequestSet(request); + } + + private void createAndCheckCookie(String request) throws Fault { + // create cookie + setProperty(Property.REQUEST, buildRequest(request)); + setProperty(Property.SAVE_STATE, "true"); + invoke(); + checkCookie(request); + // check cookie + setProperty(Property.USE_SAVED_STATE, "true"); + } + + @Override + protected void paramEntity(String request) throws Fault { + createAndCheckCookie(request); + super.paramEntity(request); + } + + @Override + protected String buildRequest(String param) { + StringBuilder sb = new StringBuilder(); + sb.append(Request.GET).append(" ").append(_contextRoot); + sb.append("?todo=").append(param.replace("=", "%3d")).append(HTTP11); + return sb.toString(); + } + + @Override + protected String getDefaultValueOfParam(String param) { + StringBuilder sb = new StringBuilder(); + sb.append(param).append("="); + sb.append(CookieParamTest.class.getSimpleName()); + return sb.toString(); + } + + private void checkCookie(String cookie) throws Fault { + boolean found = false; + String lowCookie = stripQuotesSpacesAndLowerCase(cookie); + String[] headers = getResponseHeaders(); + for (String h : headers) { + String header = stripQuotesSpacesAndLowerCase(h); + if (header.startsWith("set-cookie")) + if (header.contains(lowCookie)) + found = true; + } + assertTrue(found, "Could not find cookie"+ cookie+ "in response headers:"+ + JaxrsUtil.iterableToString(";", headers)); + logMsg("Found cookie", cookie, "as expected"); + } + + private static String stripQuotesSpacesAndLowerCase(String cookie) { + return cookie.toLowerCase().replace("\"", "").replace("'", "").replace(" ", + ""); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/TSAppConfig.java new file mode 100644 index 0000000..462352a --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/TSAppConfig.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2007, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +/** + * + * @author diannejiao + */ +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(CookieParamTest.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/JAXRSLocatorClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/JAXRSLocatorClientIT.java new file mode 100644 index 0000000..2572bcb --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/JAXRSLocatorClientIT.java
@@ -0,0 +1,272 @@ +/* + * Copyright (c) 2012, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam.locator; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSLocatorClientIT + extends jakarta.ws.rs.tck.ee.rs.cookieparam.JAXRSClientIT { + + private static final long serialVersionUID = 1L; + + public JAXRSLocatorClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_cookieparam_locator_web/resource/locator"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false, name = "cookieparamlocator") + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSLocatorClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/cookieparam/locator/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_cookieparam_locator_web.war"); + archive.addClasses(TSAppConfig.class, LocatorResource.class, MiddleResource.class, + jakarta.ws.rs.tck.ee.rs.cookieparam.CookieParamTest.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* + * @testName: cookieParamSubTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:20; JAXRS:SPEC:20.3; + * JAXRS:JAVADOC:145; JAXRS:JAVADOC:2; + * + * @test_Strategy: Client invokes GET on root resource at /CookieParamTest; + * Resource will respond with a cookie; Client verify the cookie is received; + * Client send request again with the cookie; Verify that the cookie is + * received using CookieParam in the resource; Verify on the client side from + * response. + */ + @Test + public void cookieParamSubTest() throws Fault { + super.cookieParamTest(); + } + + /* + * @testName: cookieParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.2; JAXRS:SPEC:20; + * JAXRS:SPEC:20.3; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamEntityWithConstructorTest() throws Fault { + super.paramEntityWithConstructorTest(); + } + + /* + * @testName: cookieParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:SPEC:20; + * JAXRS:SPEC:20.3; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamEntityWithValueOfTest() throws Fault { + super.paramEntityWithValueOfTest(); + } + + /* + * @testName: cookieParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:SPEC:20; + * JAXRS:SPEC:20.3; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamEntityWithFromStringTest() throws Fault { + super.paramEntityWithFromStringTest(); + } + + /* + * @testName: cookieParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.3; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: cookieParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.3; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamListEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: cookieParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.3; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamSortedSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: cookieParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:12.3; JAXRS:SPEC:20; + * JAXRS:SPEC:20.3; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + * + */ + @Test + public void cookieParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: cookieParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.2; JAXRS:SPEC:20; + * JAXRS:SPEC:20.3; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @HeaderParam or @CookieParam + * then an implementation MUST generate a WebApplicationException that wraps + * the thrown exception with a client error response (400 status) and no + * entity. + * + */ + @Test + public void cookieParamThrowingIllegalArgumentExceptionTest() throws Fault { + super.paramThrowingIllegalArgumentExceptionTest(); + } + + @Override + public void cookieFieldParamEntityWithFromStringTest() throws Fault{ + //do nothing + } + + @Override + public void cookieParamTest() throws Fault { + //do nothing + } + + @Override + public void cookieFieldParamEntityWithConstructorTest() throws Fault { + //do nothing + } + + @Override + public void cookieFieldParamListEntityWithFromStringTest() throws Fault { + //do nothing + } + + @Override + public void cookieFieldParamThrowingIllegalArgumentExceptionTest() throws Fault { + //do nothing + } + + @Override + public void cookieFieldThrowingWebApplicationExceptionTest() throws Fault { + //do nothing + } + + + @Override + public void cookieFieldSortedSetEntityWithFromStringTest() throws Fault { + //do nothing + } + + @Override + public void cookieFieldParamSetEntityWithFromStringTest() throws Fault { + //do nothing + } + + @Override + public void cookieFieldParamEntityWithValueOfTest() throws Fault { + //do nothing + } + + @Override + protected String buildRequest(String param) { + return super.buildRequest(param).replace(Request.GET.name(), + Request.POST.name()); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/LocatorResource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/LocatorResource.java new file mode 100644 index 0000000..d4fb0da --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/LocatorResource.java
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam.locator; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; + +import jakarta.ws.rs.CookieParam; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.QueryParam; + +@Path("resource") +public class LocatorResource extends MiddleResource { + + @Path("locator") + public MiddleResource locatorHasArguments(@QueryParam("todo") String todo, + @CookieParam("name1") @DefaultValue("abc") String value, + @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithConstructor") ParamEntityWithConstructor paramEntityWithConstructor, + @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithFromString") ParamEntityWithFromString paramEntityWithFromString, + @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithValueOf") ParamEntityWithValueOf paramEntityWithValueOf, + @DefaultValue("CookieParamTest") @CookieParam("SetParamEntityWithFromString") Set<ParamEntityWithFromString> setParamEntityWithFromString, + @DefaultValue("CookieParamTest") @CookieParam("SortedSetParamEntityWithFromString") SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString, + @DefaultValue("CookieParamTest") @CookieParam("ListParamEntityWithFromString") List<ParamEntityWithFromString> listParamEntityWithFromString, + @CookieParam("ParamEntityThrowingWebApplicationException") ParamEntityThrowingWebApplicationException paramEntityThrowingWebApplicationException, + @CookieParam("ParamEntityThrowingExceptionGivenByName") ParamEntityThrowingExceptionGivenByName paramEntityThrowingExceptionGivenByName) { + return new MiddleResource(todo, value, paramEntityWithConstructor, + paramEntityWithFromString, paramEntityWithValueOf, + setParamEntityWithFromString, sortedSetParamEntityWithFromString, + listParamEntityWithFromString, + paramEntityThrowingWebApplicationException, + paramEntityThrowingExceptionGivenByName); + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/MiddleResource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/MiddleResource.java new file mode 100644 index 0000000..153e5f5 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/MiddleResource.java
@@ -0,0 +1,63 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam.locator; + +import java.util.List; +import java.util.Set; +import java.util.SortedSet; + +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName; +import jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString; +import jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf; +import jakarta.ws.rs.tck.ee.rs.cookieparam.CookieParamTest; + +import jakarta.ws.rs.POST; +import jakarta.ws.rs.core.Response; + +public class MiddleResource extends CookieParamTest { + + private final Response returnValue; + + public MiddleResource() { + returnValue = null; + } + + protected MiddleResource(String todo, String value, + ParamEntityWithConstructor paramEntityWithConstructor, + ParamEntityWithFromString paramEntityWithFromString, + ParamEntityWithValueOf paramEntityWithValueOf, + Set<ParamEntityWithFromString> setParamEntityWithFromString, + SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString, + List<ParamEntityWithFromString> listParamEntityWithFromString, + ParamEntityThrowingWebApplicationException paramEntityThrowingWebApplicationException, + ParamEntityThrowingExceptionGivenByName paramEntityThrowingExceptionGivenByName) { + returnValue = cookieParamHandling(todo, value, paramEntityWithConstructor, + paramEntityWithFromString, paramEntityWithValueOf, + setParamEntityWithFromString, sortedSetParamEntityWithFromString, + listParamEntityWithFromString, + paramEntityThrowingWebApplicationException, + paramEntityThrowingExceptionGivenByName); + } + + @POST + public Response returnValue() { + return returnValue; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/TSAppConfig.java new file mode 100644 index 0000000..c630d57 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/TSAppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam.locator; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(LocatorResource.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/CookieSubResource.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/CookieSubResource.java new file mode 100644 index 0000000..e04d150 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/CookieSubResource.java
@@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam.sub; + +import jakarta.ws.rs.tck.ee.rs.cookieparam.CookieParamTest; + +import jakarta.ws.rs.Path; + +@Path("Resource") +public class CookieSubResource extends CookieParamTest { + + @Path("subresource") + public CookieSubResource subResourceHandling() { + return this; + } + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/JAXRSSubClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/JAXRSSubClientIT.java new file mode 100644 index 0000000..79c9baf --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/JAXRSSubClientIT.java
@@ -0,0 +1,368 @@ +/* + * Copyright (c) 2012, 2018 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam.sub; + +import java.io.InputStream; +import java.io.IOException; + +import jakarta.ws.rs.tck.lib.util.TestUtil; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +/* + * @class.setup_props: webServerHost; + * webServerPort; + * ts_home; + */ +@ExtendWith(ArquillianExtension.class) +public class JAXRSSubClientIT + extends jakarta.ws.rs.tck.ee.rs.cookieparam.JAXRSClientIT { + + private static final long serialVersionUID = 1L; + + public JAXRSSubClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_cookieparam_sub_web/Resource/subresource"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false, name = "cookieparamsub") + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSSubClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/cookieparam/sub/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_cookieparam_sub_web.war"); + archive.addClasses(TSAppConfig.class, CookieSubResource.class, + jakarta.ws.rs.tck.ee.rs.cookieparam.CookieParamTest.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityPrototype.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithConstructor.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithValueOf.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityWithFromString.class, + jakarta.ws.rs.tck.ee.rs.ParamTest.class, + jakarta.ws.rs.tck.ee.rs.JaxrsParamClient.CollectionName.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingWebApplicationException.class, + jakarta.ws.rs.tck.ee.rs.ParamEntityThrowingExceptionGivenByName.class, + jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper.class, + jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper.class + ); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* + * @testName: cookieParamSubTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:20; JAXRS:SPEC:20.2; + * JAXRS:JAVADOC:145; JAXRS:JAVADOC:2; + * + * @test_Strategy: Client invokes GET on root resource at /CookieParamTest; + * Resource will respond with a cookie; Client verify the cookie is received; + * Client send request again with the cookie; Verify that the cookie is + * received using CookieParam in the resource; Verify on the client side from + * response. + */ + @Test + public void cookieParamSubTest() throws Fault { + super.cookieParamTest(); + } + + /* + * @testName: cookieParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.2; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamEntityWithConstructorTest() throws Fault { + super.paramEntityWithConstructorTest(); + } + + /* + * @testName: cookieParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamEntityWithValueOfTest() throws Fault { + super.paramEntityWithValueOfTest(); + } + + /* + * @testName: cookieParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamEntityWithFromStringTest() throws Fault { + super.paramEntityWithFromStringTest(); + } + + /* + * @testName: cookieParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: cookieParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamListEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: cookieParamSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:JAVADOC:12; JAXRS:JAVADOC:12.1; + * + * @test_Strategy: Verify that named QueryParam is handled properly + */ + @Test + public void cookieParamSortedSetEntityWithFromStringTest() throws Fault { + super.paramCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: cookieFieldParamEntityWithConstructorTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.2; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:SPEC:4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + * + * An implementation is only required to set the annotated field and bean + * property values of instances created by the implementation runtime. (Check + * the resource with resource locator is injected field properties) + */ + @Test + public void cookieFieldParamEntityWithConstructorTest() throws Fault { + super.fieldEntityWithConstructorTest(); + } + + /* + * @testName: cookieFieldParamEntityWithValueOfTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:SPEC:4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + * + * An implementation is only required to set the annotated field and bean + * property values of instances created by the implementation runtime. (Check + * the resource with resource locator is injected field properties) + */ + @Test + public void cookieFieldParamEntityWithValueOfTest() throws Fault { + super.fieldEntityWithValueOfTest(); + } + + /* + * @testName: cookieFieldParamEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.3; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:SPEC:4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + * + * An implementation is only required to set the annotated field and bean + * property values of instances created by the implementation runtime. (Check + * the resource with resource locator is injected field properties) + */ + @Test + public void cookieFieldParamEntityWithFromStringTest() throws Fault { + super.fieldEntityWithFromStringTest(); + } + + /* + * @testName: cookieFieldParamSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:SPEC:4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + * + * An implementation is only required to set the annotated field and bean + * property values of instances created by the implementation runtime. (Check + * the resource with resource locator is injected field properties) + */ + @Test + public void cookieFieldParamSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SET); + } + + /* + * @testName: cookieFieldParamListEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:SPEC:4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + * + * An implementation is only required to set the annotated field and bean + * property values of instances created by the implementation runtime. (Check + * the resource with resource locator is injected field properties) + */ + @Test + public void cookieFieldParamListEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.LIST); + } + + /* + * @testName: cookieFieldSortedSetEntityWithFromStringTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:5.4; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:SPEC:4; JAXRS:JAVADOC:6; + * + * @test_Strategy: Verify that named QueryParam is handled properly + * + * An implementation is only required to set the annotated field and bean + * property values of instances created by the implementation runtime. (Check + * the resource with resource locator is injected field properties) + */ + @Test + public void cookieFieldSortedSetEntityWithFromStringTest() throws Fault { + super.fieldCollectionEntityWithFromStringTest(CollectionName.SORTED_SET); + } + + /* + * @testName: cookieParamThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:12.3; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + * + */ + @Test + public void cookieParamThrowingWebApplicationExceptionTest() throws Fault { + super.paramThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: cookieFieldThrowingWebApplicationExceptionTest + * + * @assertion_ids: JAXRS:SPEC:3.4; JAXRS:SPEC:8; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:SPEC:4; + * + * @test_Strategy: A WebApplicationException thrown during construction of + * field or property values using 2 or 3 above is processed directly as + * described in section 3.3.4. + * + * An implementation is only required to set the annotated field and bean + * property values of instances created by the implementation runtime. (Check + * the resource with resource locator is injected field properties) + */ + @Test + public void cookieFieldThrowingWebApplicationExceptionTest() throws Fault { + super.fieldThrowingWebApplicationExceptionTest(); + } + + /* + * @testName: cookieParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:9; JAXRS:SPEC:9.2; JAXRS:SPEC:20; + * JAXRS:SPEC:20.2; JAXRS:SPEC:10; + * + * @test_Strategy: Other exceptions thrown during construction of field or + * property values using 2 or 3 above are treated as client errors: + * + * if the field or property is annotated with @HeaderParam or @CookieParam + * then an implementation MUST generate a WebApplicationException that wraps + * the thrown exception with a client error response (400 status) and no + * entity. + * + */ + @Test + public void cookieParamThrowingIllegalArgumentExceptionTest() throws Fault { + super.paramThrowingIllegalArgumentExceptionTest(); + } + + /* + * @testName: cookieFieldParamThrowingIllegalArgumentExceptionTest + * + * @assertion_ids: JAXRS:SPEC:12.3; JAXRS:SPEC:20; JAXRS:SPEC:20.2; + * JAXRS:SPEC:4; + * + * @test_Strategy: Exceptions thrown during construction of parameter values + * are treated the same as exceptions thrown during construction of field or + * bean property values, see section 3.2. + * + * An implementation is only required to set the annotated field and bean + * property values of instances created by the implementation runtime. (Check + * the resource with resource locator is injected field properties) + */ + @Test + public void cookieFieldParamThrowingIllegalArgumentExceptionTest() + throws Fault { + super.fieldThrowingIllegalArgumentExceptionTest(); + } + + @Override + public void cookieParamTest() + throws Fault { + //do nothing + } + + +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/TSAppConfig.java new file mode 100644 index 0000000..f3efbf3 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/TSAppConfig.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.cookieparam.sub; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.tck.ee.rs.RuntimeExceptionMapper; +import jakarta.ws.rs.tck.ee.rs.WebApplicationExceptionMapper; + +import jakarta.ws.rs.core.Application; + +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(CookieSubResource.class); + resources.add(RuntimeExceptionMapper.class); + resources.add(WebApplicationExceptionMapper.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/HttpMethodDeleteTest.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/HttpMethodDeleteTest.java new file mode 100644 index 0000000..75bd6eb --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/HttpMethodDeleteTest.java
@@ -0,0 +1,49 @@ +/* + * Copyright (c) 2007, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.delete; + +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; + +@Path(value = "/DeleteTest") + +public class HttpMethodDeleteTest { + + static String html_content = "<html>" + + "<head><title>CTS-Delete text/html</title></head>" + + "<body>CTS-Delete text/html</body></html>"; + + @DELETE + @Produces(value = "text/plain") + public String getPlain() { + return "CTS-Delete text/plain"; + } + + @DELETE + @Produces(value = "text/html") + public String getHtml() { + return html_content; + } + + @DELETE + @Path(value = "/sub") + @Produces(value = "text/html") + public String getSub() { + return html_content; + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/JAXRSClientIT.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/JAXRSClientIT.java new file mode 100644 index 0000000..0f6cdbe --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/JAXRSClientIT.java
@@ -0,0 +1,146 @@ +/* + * Copyright (c) 2007, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ +package jakarta.ws.rs.tck.ee.rs.delete; + +import java.io.InputStream; +import java.io.IOException; +import jakarta.ws.rs.tck.lib.util.TestUtil; +import jakarta.ws.rs.tck.common.JAXRSCommonClient; + +import jakarta.ws.rs.core.Response.Status; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; + +@ExtendWith(ArquillianExtension.class) +public class JAXRSClientIT extends JAXRSCommonClient { + + private static final long serialVersionUID = 204493956987397506L; + + public JAXRSClientIT() { + setup(); + setContextRoot("/jaxrs_ee_rs_delete_web"); + } + + @BeforeEach + void logStartTest(TestInfo testInfo) { + TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName()); + } + + @AfterEach + void logFinishTest(TestInfo testInfo) { + TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName()); + } + + @Deployment(testable = false) + public static WebArchive createDeployment() throws IOException{ + + InputStream inStream = JAXRSClientIT.class.getClassLoader().getResourceAsStream("jakarta/ws/rs/tck/ee/rs/delete/web.xml.template"); + String webXml = editWebXmlString(inStream); + + WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs_ee_rs_delete_web.war"); + archive.addClasses(TSAppConfig.class, HttpMethodDeleteTest.class); + archive.setWebXML(new StringAsset(webXml)); + return archive; + + } + + /* Run test */ + /* + * @testName: deleteTest1 + * + * @assertion_ids: JAXRS:JAVADOC:6; JAXRS:JAVADOC:10; + * + * @test_Strategy: Client invokes Delete on root resource at /DeleteTest; + * Verify that right Method is invoked. + */ + @Test + public void deleteTest1() throws Fault { + setProperty(REQUEST_HEADERS, "Accept:text/plain"); + setProperty(REQUEST, "DELETE " + getContextRoot() + "/DeleteTest HTTP/1.1"); + setProperty(SEARCH_STRING, "CTS-Delete text/plain"); + invoke(); + } + + /* + * @testName: deleteTest2 + * + * @assertion_ids: JAXRS:JAVADOC:6; JAXRS:JAVADOC:10; + * + * @test_Strategy: Client invokes Delete on root resource at /DeleteTest; + * Verify that right Method is invoked. + */ + @Test + public void deleteTest2() throws Fault { + setProperty(REQUEST_HEADERS, "Accept:text/html"); + setProperty(REQUEST, + "DELETE " + getContextRoot() + "/DeleteTest HTTP/1.1"); + setProperty(SEARCH_STRING, "CTS-Delete text/html"); + invoke(); + } + + /* + * @testName: deleteSubTest + * + * @assertion_ids: JAXRS:SPEC:20.1; JAXRS:JAVADOC:6; JAXRS:JAVADOC:10; + * JAXRS:JAVADOC:8; + * + * @test_Strategy: Client invokes Delete on a sub resource at /DeleteTest/sub; + * Verify that right Method is invoked. + */ + @Test + public void deleteSubTest() throws Fault { + setProperty(REQUEST_HEADERS, "Accept:text/html"); + setProperty(REQUEST, + "DELETE " + getContextRoot() + "/DeleteTest/sub HTTP/1.1"); + setProperty(SEARCH_STRING, "CTS-Delete text/html"); + invoke(); + } + + /* + * @testName: deleteSubTest1 + * + * @assertion_ids: JAXRS:SPEC:20.1; JAXRS:SPEC:21; JAXRS:SPEC:25.6; + * JAXRS:JAVADOC:6; JAXRS:JAVADOC:10; JAXRS:JAVADOC:8; + * + * @test_Strategy: Client invokes Delete on a sub resource at /DeleteTest/sub; + * Verify that no Method is invoked. + */ + @Test + public void deleteSubTest1() throws Fault { + setProperty(REQUEST_HEADERS, "Accept:text/plain"); + setProperty(REQUEST, + "DELETE " + getContextRoot() + "/DeleteTest/sub HTTP/1.1"); + setProperty(STATUS_CODE, getStatusCode(Status.NOT_ACCEPTABLE)); + invoke(); + } +}
diff --git a/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/TSAppConfig.java b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/TSAppConfig.java new file mode 100644 index 0000000..9f46786 --- /dev/null +++ b/jaxrs-tck/src/main/java/jakarta/ws/rs/tck/ee/rs/delete/TSAppConfig.java
@@ -0,0 +1,35 @@ +/* + * Copyright (c) 2007, 2020 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 + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.ws.rs.tck.ee.rs.delete; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.core.Application; + +/** + * + * @author diannejiao + */ +public class TSAppConfig extends Application { + + public java.util.Set<java.lang.Class<?>> getClasses() { + Set<Class<?>> resources = new HashSet<Class<?>>(); + resources.add(HttpMethodDeleteTest.class); + return resources; + } +}
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/web.xml.template new file mode 100644 index 0000000..c68c63f --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/cookie/plain/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2014, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_EE_BeanParam_Cookie_Plain</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.beanparam.cookie.plain.AppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_EE_BeanParam_Cookie_Plain</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/web.xml.template new file mode 100644 index 0000000..f4fcd0a --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/form/plain/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2014, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_EE_BeanParam_Form_Plain</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.beanparam.form.plain.AppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_EE_BeanParam_Form_Plain</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/web.xml.template new file mode 100644 index 0000000..ec821fb --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/header/plain/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2014, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_EE_BeanParam_Header_Plain</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.beanparam.header.plain.AppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_EE_BeanParam_Header_Plain</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/web.xml.template new file mode 100644 index 0000000..5c79f49 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/matrix/plain/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2014, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_EE_BeanParam_Matrix_Plain</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.beanparam.matrix.plain.AppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_EE_BeanParam_Matrix_Plain</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/web.xml.template new file mode 100644 index 0000000..e08fa1f --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/path/plain/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2014, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_EE_BeanParam_Path_Plain</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.beanparam.path.plain.AppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_EE_BeanParam_Path_Plain</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/plain/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/plain/web.xml.template new file mode 100644 index 0000000..08e96bb --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/plain/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2014, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_EE_BeanParam_Plain</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.beanparam.plain.AppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_EE_BeanParam_Plain</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/web.xml.template new file mode 100644 index 0000000..3d37d99 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/beanparam/query/plain/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2014, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_EE_BeanParam_Query_Plain</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.beanparam.query.plain.AppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_EE_BeanParam_Query_Plain</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/constrainedto/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/constrainedto/web.xml.template new file mode 100644 index 0000000..902e408 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/constrainedto/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2014, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTSJAXRS_EE_RS_CONSTRAINEDTO</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.constrainedto.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTSJAXRS_EE_RS_CONSTRAINEDTO</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/web.xml.template new file mode 100644 index 0000000..f263443 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/illegalstate/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2012, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_Container_RequestContext_illegalstate</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.container.requestcontext.illegalstate.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_Container_RequestContext_illegalstate</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/jaxrs_ee_rs_container_requestcontext_security_web.war.sun-web.xml b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/jaxrs_ee_rs_container_requestcontext_security_web.war.sun-web.xml new file mode 100644 index 0000000..43b0e26 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/jaxrs_ee_rs_container_requestcontext_security_web.war.sun-web.xml
@@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2012, 2018 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 8.0 Servlet 2.4//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_5-0.dtd"> +<sun-web-app> + <context-root>jaxrs_ee_rs_container_requestcontext_security_web</context-root> + <security-role-mapping> + <role-name>DIRECTOR</role-name> + <principal-name>j2ee</principal-name> + </security-role-mapping> +</sun-web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/web.xml.template new file mode 100644 index 0000000..09ab05c --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/security/web.xml.template
@@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2012, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_Container_RequestContext_Security</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.container.requestcontext.security.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + <security-role-ref> + <role-name>staff</role-name> + <role-link>DIRECTOR</role-link> + </security-role-ref> + </servlet> + <security-constraint> + <display-name>Resource</display-name> + <web-resource-collection> + <web-resource-name>Resource</web-resource-name> + <description></description> + <url-pattern>/resource/*</url-pattern> + <http-method>GET</http-method> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <description>j2ee</description> + <role-name>DIRECTOR</role-name> + </auth-constraint> + <user-data-constraint> + <transport-guarantee>NONE</transport-guarantee> + </user-data-constraint> + </security-constraint> + <servlet-mapping> + <servlet-name>CTS_JAXRS_Container_RequestContext_Security</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> + <login-config> + <auth-method>BASIC</auth-method> + </login-config> + <security-role> + <description>director</description> + <role-name>DIRECTOR</role-name> + </security-role> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/web.xml.template new file mode 100644 index 0000000..e84844b --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/requestcontext/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2012, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_Container_RequestContext</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.container.requestcontext.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_Container_RequestContext</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/web.xml.template new file mode 100644 index 0000000..6e82c34 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/resourceinfo/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2013, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_Container_ResourceInfo</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.container.resourceinfo.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_Container_ResourceInfo</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/responsecontext/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/responsecontext/web.xml.template new file mode 100644 index 0000000..b518723 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/container/responsecontext/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2012, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTS_JAXRS_Container_ResponseContext</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.container.responsecontext.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTS_JAXRS_Container_ResponseContext</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/web.xml.template new file mode 100644 index 0000000..b4b85a9 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/locator/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2012, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTSJAX-RSCookieParam_LOCATOR</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.cookieparam.locator.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTSJAX-RSCookieParam_LOCATOR</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/web.xml.template new file mode 100644 index 0000000..bd240d6 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/sub/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2008, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTSJAX-RSCookieParamSub</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.cookieparam.sub.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTSJAX-RSCookieParamSub</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/web.xml.template new file mode 100644 index 0000000..75b3de2 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/cookieparam/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2008, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTSJAX-RSCookieParam</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.cookieparam.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTSJAX-RSCookieParam</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>
diff --git a/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/delete/web.xml.template b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/delete/web.xml.template new file mode 100644 index 0000000..1480f90 --- /dev/null +++ b/jaxrs-tck/src/main/resources/jakarta/ws/rs/tck/ee/rs/delete/web.xml.template
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2007, 2020 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 + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"> + <servlet> + <servlet-name>CTSJAX-RSDelete</servlet-name> + <servlet-class>servlet_adaptor</servlet-class> + <init-param> + <param-name>jakarta.ws.rs.Application</param-name> + <param-value>jakarta.ws.rs.tck.ee.rs.delete.TSAppConfig</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CTSJAX-RSDelete</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>30</session-timeout> + </session-config> +</web-app>