Merge pull request #1122 from alwin-joseph/exclude-servlet-security

diff --git a/jaxrs-tck-docs/userguide/src/main/jbake/content/attributes.conf b/jaxrs-tck-docs/userguide/src/main/jbake/content/attributes.conf
index e7352a9..d462414 100644
--- a/jaxrs-tck-docs/userguide/src/main/jbake/content/attributes.conf
+++ b/jaxrs-tck-docs/userguide/src/main/jbake/content/attributes.conf
@@ -26,6 +26,7 @@
 :MavenVersion: 3.6.3+
 :JakartaEEVersion: 10
 :excludeListFileName: jaxrs-tck-docs/TCK-Exclude-List.txt
+:groupsExample: xml_binding
 :TCKPackageName: jakarta-restful-ws-tck-x.y.z.zip
 // Directory names used in examples in using.adoc.
 :sigTestDirectoryExample: ee.jakarta.tck.ws.rs.signaturetest.jaxrs
diff --git a/jaxrs-tck-docs/userguide/src/main/jbake/content/using-examples.inc b/jaxrs-tck-docs/userguide/src/main/jbake/content/using-examples.inc
index da42a04..f989877 100644
--- a/jaxrs-tck-docs/userguide/src/main/jbake/content/using-examples.inc
+++ b/jaxrs-tck-docs/userguide/src/main/jbake/content/using-examples.inc
@@ -17,10 +17,27 @@
 --
 [source,oac_no_warn]
 ----
-mvn verify -DexcludedGroups="xml_binding"
+mvn verify -DexcludedGroups=xml_binding
+----
+--
+Run only the optional jaxb tests using the following command:
+
+--
+[source,oac_no_warn]
+----
+mvn verify -Dgroups=xml_binding
 ----
 --
 
+Run the tests by excluding the security & servlet tests using the following 
+command:
+
+--
+[source,oac_no_warn]
+----
+mvn verify -DexcludedGroups=security,servlet
+----
+--
 
 [[GCMCU]]
 
diff --git a/jaxrs-tck-docs/userguide/src/main/jbake/content/using.adoc b/jaxrs-tck-docs/userguide/src/main/jbake/content/using.adoc
index 4b181b0..a7db87c 100644
--- a/jaxrs-tck-docs/userguide/src/main/jbake/content/using.adoc
+++ b/jaxrs-tck-docs/userguide/src/main/jbake/content/using.adoc
@@ -96,7 +96,6 @@
 * link:#GBFWK[Section 5.2.1, "To Run a Subset of Tests in Command-Line Mode"]
 
 
-
 [[GBFWK]][[to-run-a-subset-of-tests-in-command-line-mode]]
 
 5.2.1 To Run a Subset of Tests in Command-Line Mode
@@ -111,6 +110,46 @@
 
 The tests in the directory and its subdirectories are run.
 
+[NOTE]
+=======================================================================
+
+The Junit test tags(groups) available in the TCK are `xml_binding`, 
+`security` and `servlet`. These can be used to select or deselect the 
+tests for the execution.
+
+=======================================================================
+
+[[GBFQA]][[to-run-a-group-of-tests-in-command-line-mode]]
+
+5.2.2 To Run a Group of Tests in Command-Line Mode
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Start the test run by executing the following command: +
+
+[source,subs="attributes"]
+----
+mvn verify -Dgroups={groupsExample}
+----
+
+Only the tests in the group +{groupsExample}+ is run. 
+Multiple groups can be separated by comma.
+
+
+[[GBFEP]][[to-exclude-a-group-of-tests-in-command-line-mode]]
+
+5.2.3 To Exclude a Group of Tests in Command-Line Mode
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Start the test run by executing the following command: +
+
+[source,subs="attributes"]
+----
+mvn verify -DexcludedGroups={groupsExample}
+----
+
+The tests in the group +{groupsExample}+ is exclued from the run. 
+Multiple groups can be separated by comma.
+
 [[GCLRR]][[running-the-tck-against-the-ri]]
 
 5.3 Running the TCK Against another CI
diff --git a/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/rs/container/requestcontext/JAXRSClientIT.java b/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/rs/container/requestcontext/JAXRSClientIT.java
index a731c03..dc3d48a 100644
--- a/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/rs/container/requestcontext/JAXRSClientIT.java
+++ b/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/rs/container/requestcontext/JAXRSClientIT.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 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
@@ -42,6 +42,7 @@
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.api.TestInfo;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.AfterEach;
 
 /*
@@ -97,6 +98,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void abortWithTest() throws Fault {
     invokeRequestAndCheckResponse(ContextOperation.ABORTWITH);
   }
@@ -113,8 +115,9 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getAcceptableLanguagesTest() throws Fault {
-    setProperty(Property.REQUEST_HEADERS, "Accpet-Language:en-us");
+    setProperty(Property.REQUEST_HEADERS, "Accept-Language:en-us");
     invokeRequestAndCheckResponse(ContextOperation.GETACCEPTABLELANGUAGES);
   }
 
@@ -130,6 +133,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getAcceptableLanguagesIsSortedTest() throws Fault {
     logMsg(
         "Check the #getAcceptableLanguages is sorted according to their q-value");
@@ -153,6 +157,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getAcceptableLanguagesIsReadOnlyTest() throws Fault {
     setProperty(Property.REQUEST_HEADERS,
         "Accept-Language: da, en-gb;q=0.6, en-us;q=0.7");
@@ -173,6 +178,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getAcceptableMediaTypesTest() throws Fault {
     setProperty(Property.REQUEST_HEADERS,
         buildAccept(MediaType.APPLICATION_JSON_TYPE));
@@ -192,6 +198,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getAcceptableMediaTypesIsSortedTest() throws Fault {
     logMsg(
         "Check the #getAcceptableMediaTypes is sorted according to their q-value");
@@ -217,6 +224,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getAcceptableMediaTypesIsReadOnlyTest() throws Fault {
     setProperty(Property.REQUEST_HEADERS, buildAccept(MediaType.TEXT_XML_TYPE));
     setProperty(Property.UNEXPECTED_RESPONSE_MATCH, MediaType.APPLICATION_JSON);
@@ -235,6 +243,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getCookiesTest() throws Fault {
     String[] cookies = { "cookie1", "coookkkie99", "cookiiieee999" };
     for (String cookie : cookies) {
@@ -258,6 +267,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getCookiesIsReadonlyTest() throws Fault {
     setPrintEntity(true);
     invokeRequestAndCheckResponse(ContextOperation.GETCOOKIESISREADONLY);
@@ -274,6 +284,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getDateTest() throws Fault {
     Calendar calendar = Calendar.getInstance();
     calendar.set(Calendar.MILLISECOND, 0);
@@ -296,6 +307,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getDateIsNullTest() throws Fault {
     setProperty(Property.SEARCH_STRING, "NULL");
     invokeRequestAndCheckResponse(ContextOperation.GETDATE);
@@ -312,6 +324,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getEntityStreamTest() throws Fault {
     String entity = "EnTiTyStReAmTeSt";
     setProperty(Property.CONTENT, entity);
@@ -331,6 +344,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getHeadersTest() throws Fault {
     for (int i = 1; i != 5; i++) {
       String header = "header" + i + ":" + "header" + i;
@@ -351,6 +365,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getHeadersIsMutableTest() throws Fault {
     setPrintEntity(true);
     invokeRequestAndCheckResponse(ContextOperation.GETHEADERSISMUTABLE);
@@ -367,6 +382,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getHeaderStringTest() throws Fault {
     setProperty(Property.SEARCH_STRING,
         ContextOperation.GETHEADERSTRING2.name());
@@ -384,6 +400,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getLanguageTest() throws Fault {
     setProperty(Property.REQUEST_HEADERS,
         HttpHeaders.CONTENT_LANGUAGE + ":en-gb");
@@ -402,6 +419,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getLanguageIsNullTest() throws Fault {
     setProperty(Property.SEARCH_STRING, "NULL");
     invokeRequestAndCheckResponse(ContextOperation.GETLANGUAGE);
@@ -419,6 +437,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getLengthTest() throws Fault {
     setProperty(Property.CONTENT, "12345678901234567890");
     setProperty(Property.SEARCH_STRING, "20");
@@ -437,6 +456,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getLengthWhenNoEntityTest() throws Fault {
     setProperty(Property.SEARCH_STRING, "-1");
     invokeRequestAndCheckResponse(ContextOperation.GETLENGTH);
@@ -454,6 +474,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getMediaTypeTest() throws Fault {
     addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_SVG_XML);
     setProperty(Property.SEARCH_STRING, MediaType.APPLICATION_SVG_XML);
@@ -472,6 +493,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getMediaTypeIsNullTest() throws Fault {
     setProperty(Property.SEARCH_STRING, "NULL");
     invokeRequestAndCheckResponse(ContextOperation.GETMEDIATYPE);
@@ -488,6 +510,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getMethodTest() throws Fault {
     String method = Request.OPTIONS.name();
     String header = RequestFilter.OPERATION + ":"
@@ -512,6 +535,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getPropertyIsNullTest() throws Fault {
     setProperty(Property.SEARCH_STRING, "NULL");
     invokeRequestAndCheckResponse(ContextOperation.GETPROPERTY);
@@ -530,6 +554,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getPropertyNamesTest() throws Fault {
     for (int i = 0; i != 5; i++)
       setProperty(Property.UNORDERED_SEARCH_STRING,
@@ -547,6 +572,7 @@
    * request/response exchange context.
    */
   @Test
+  @Tag("servlet")
   public void getPropertyNamesIsReadOnlyTest() throws Fault {
     setProperty(Property.UNORDERED_SEARCH_STRING, "0");
     invokeRequestAndCheckResponse(ContextOperation.GETPROPERTYNAMESISREADONLY);
@@ -563,6 +589,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getRequestTest() throws Fault {
     String method = Request.OPTIONS.name();
     String header = RequestFilter.OPERATION + ":"
@@ -587,6 +614,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getSecurityContextPrincipalIsNullTest() throws Fault {
     setProperty(Property.SEARCH_STRING, "NULL");
     invokeRequestAndCheckResponse(ContextOperation.GETSECURITYCONTEXT);
@@ -603,6 +631,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void getUriInfoTest() throws Fault {
     setProperty(Property.SEARCH_STRING, getAbsoluteUrl());
     invokeRequestAndCheckResponse(ContextOperation.GETURIINFO);
@@ -620,6 +649,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void hasEntityTest() throws Fault {
     setRequestContentEntity("entity");
     setProperty(Property.SEARCH_STRING, "true");
@@ -638,6 +668,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void hasEntityWhenNoEntityTest() throws Fault {
     setProperty(Property.SEARCH_STRING, "false");
     invokeRequestAndCheckResponse(ContextOperation.HASENTITY);
@@ -657,6 +688,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void removePropertyTest() throws Fault {
     // getProperty returns null after the property has been set and removed
     setProperty(Property.SEARCH_STRING, "NULL");
@@ -674,6 +706,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void setEntityStreamTest() throws Fault {
     setProperty(Property.SEARCH_STRING, RequestFilter.SETENTITYSTREAMENTITY);
     invokeRequestAndCheckResponse(ContextOperation.SETENTITYSTREAM);
@@ -690,6 +723,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void setMethodTest() throws Fault {
     setProperty(Property.SEARCH_STRING, Request.OPTIONS.name());
     invokeRequestAndCheckResponse(ContextOperation.SETMETHOD);
@@ -709,6 +743,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void setPropertyTest() throws Fault {
     setProperty(Property.SEARCH_STRING, TemplateFilter.PROPERTYNAME);
     invokeRequestAndCheckResponse(ContextOperation.SETPROPERTY);
@@ -727,6 +762,7 @@
    * Throws IOException. *
    */
   @Test
+  @Tag("servlet")
   public void setPropertyNullTest() throws Fault {
     setProperty(Property.SEARCH_STRING, "NULL");
     invokeRequestAndCheckResponse(ContextOperation.SETPROPERTYNULL);
@@ -746,6 +782,7 @@
    * Throws IOException. *
    */
   @Test
+  @Tag("servlet")
   public void setPropertyIsReflectedInServletRequestTest() throws Fault {
     setProperty(Property.SEARCH_STRING, RequestFilter.PROPERTYNAME);
     invokeRequestAndCheckResponse(ContextOperation.SETPROPERTYCONTEXT);
@@ -763,6 +800,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void setRequestUriOneUriTest() throws Fault {
     setProperty(Property.SEARCH_STRING, RequestFilter.URI);
     invokeRequestAndCheckResponse(ContextOperation.SETREQUESTURI1);
@@ -780,6 +818,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void setRequestUriTwoUrisTest() throws Fault {
     setProperty(Property.SEARCH_STRING, RequestFilter.URI);
     invokeRequestAndCheckResponse(ContextOperation.SETREQUESTURI2);
@@ -797,6 +836,7 @@
    * Throws IOException.
    */
   @Test
+  @Tag("servlet")
   public void setSecurityContextTest() throws Fault {
     setProperty(Property.SEARCH_STRING, RequestFilter.PRINCIPAL);
     invokeRequestAndCheckResponse(ContextOperation.SETSECURITYCONTEXT);
diff --git a/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/rs/core/securitycontext/basic/JAXRSBasicClientIT.java b/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/rs/core/securitycontext/basic/JAXRSBasicClientIT.java
index 9a7277a..5efacca 100644
--- a/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/rs/core/securitycontext/basic/JAXRSBasicClientIT.java
+++ b/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/rs/core/securitycontext/basic/JAXRSBasicClientIT.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 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
@@ -38,6 +38,7 @@
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.api.TestInfo;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.AfterEach;
 
 /*
@@ -104,6 +105,7 @@
    * @test_Strategy: Send no authorization, make sure of 401 response
    */
   @Test
+  @Tag("security")
   @RunAsClient
   public void noAuthorizationTest() throws Fault {
     super.noAuthorizationTest();
@@ -118,6 +120,7 @@
    * @test_Strategy: Send basic authorization, check security context
    */
   @Test
+  @Tag("security")
   @RunAsClient
   public void basicAuthorizationAdminTest() throws Fault {
     setProperty(Property.STATUS_CODE, getStatusCode(Response.Status.OK));
@@ -139,6 +142,7 @@
    * @test_Strategy: Send basic authorization, check security context
    */
   @Test
+  @Tag("security")
   @RunAsClient
   public void basicAuthorizationIncorrectUserTest() throws Fault {
     setProperty(Property.STATUS_CODE,
@@ -156,6 +160,7 @@
    * @test_Strategy: Send basic authorization, check security context
    */
   @Test
+  @Tag("security")
   @RunAsClient
   public void basicAuthorizationIncorrectPasswordTest() throws Fault {
     setProperty(Property.STATUS_CODE,
@@ -175,6 +180,7 @@
    * context
    */
   @Test
+  @Tag("security")
   @RunAsClient
   public void basicAuthorizationStandardUserTest() throws Fault {
     setProperty(Property.STATUS_CODE, getStatusCode(Response.Status.OK));