From d16f29cb1f977ea5be702800788abf9c5e6f9a38 Mon Sep 17 00:00:00 2001 From: Brian Stansberry Date: Mon, 22 Dec 2025 20:03:09 -0600 Subject: [PATCH] [JBMETA-459] Add the version enums for Servlet 6.1, jboss-web_15_1.xsd schema and related parsing tests --- .../metadata/parser/jbossweb/Version.java | 1 + .../metadata/parser/servlet/Version.java | 3 +- .../main/resources/schema/jboss-web_15_1.xsd | 516 ++++++++++++++++++ .../metadata/web/JBossWeb151UnitTestCase.java | 33 ++ .../web/WebApp11EverythingUnitTestCase.java | 34 ++ .../web/WebApp11FragmentUnitTestCase.java | 23 + .../web/JBossWeb151_testClustering.xml | 12 + .../web/JBossWeb151_testReplicationConfig.xml | 15 + .../web/WebApp11Fragment_testEverything.xml | 2 +- 9 files changed, 637 insertions(+), 2 deletions(-) create mode 100644 web/src/main/resources/schema/jboss-web_15_1.xsd create mode 100644 web/src/test/java/org/jboss/test/metadata/web/JBossWeb151UnitTestCase.java create mode 100644 web/src/test/java/org/jboss/test/metadata/web/WebApp11EverythingUnitTestCase.java create mode 100644 web/src/test/java/org/jboss/test/metadata/web/WebApp11FragmentUnitTestCase.java create mode 100644 web/src/test/resources/org/jboss/test/metadata/web/JBossWeb151_testClustering.xml create mode 100644 web/src/test/resources/org/jboss/test/metadata/web/JBossWeb151_testReplicationConfig.xml diff --git a/web/src/main/java/org/jboss/metadata/parser/jbossweb/Version.java b/web/src/main/java/org/jboss/metadata/parser/jbossweb/Version.java index 2d2319549..248386be8 100644 --- a/web/src/main/java/org/jboss/metadata/parser/jbossweb/Version.java +++ b/web/src/main/java/org/jboss/metadata/parser/jbossweb/Version.java @@ -30,6 +30,7 @@ public enum Version implements org.jboss.metadata.parser.util.Version { JBOSS_WEB_14_0(org.jboss.metadata.parser.servlet.Version.SERVLET_4_0, 14, 0), JBOSS_WEB_14_1(org.jboss.metadata.parser.servlet.Version.SERVLET_4_0, 14, 1), JBOSS_WEB_15_0(org.jboss.metadata.parser.servlet.Version.SERVLET_6_0, 15, 0), + JBOSS_WEB_15_1(org.jboss.metadata.parser.servlet.Version.SERVLET_6_1, 15, 1), ; // The corresponding servlet version private final org.jboss.metadata.parser.servlet.Version servletVersion; diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/Version.java b/web/src/main/java/org/jboss/metadata/parser/servlet/Version.java index 51d0aeab6..a320fc83c 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/Version.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/Version.java @@ -21,8 +21,9 @@ public enum Version implements org.jboss.metadata.parser.util.Version { SERVLET_4_0(4, 0, "http://xmlns.jcp.org/xml/ns/javaee/web-app_%d_%d.xsd"), SERVLET_5_0(5, 0), SERVLET_6_0(6, 0), + SERVLET_6_1(6, 1), ; - public static final Version LATEST = Version.SERVLET_6_0; + public static final Version LATEST = Version.SERVLET_6_1; private static final Map VERSIONS = EnumSet.allOf(Version.class).stream().collect(Collectors.toMap(Version::toString, Function.identity())); private static final Map SYSTEM_IDS = EnumSet.allOf(Version.class).stream().collect(Collectors.toMap(Version::getSystemId, Function.identity())); diff --git a/web/src/main/resources/schema/jboss-web_15_1.xsd b/web/src/main/resources/schema/jboss-web_15_1.xsd new file mode 100644 index 000000000..cfbbba2ff --- /dev/null +++ b/web/src/main/resources/schema/jboss-web_15_1.xsd @@ -0,0 +1,516 @@ + + + + + + + + + ... + + + + Instance documents may indicate the published version of + the schema using the xsi:schemaLocation attribute for the + Jakarta EE namespace with the following location: + + https://www.jboss.org/schema/jbossas/jboss-web_15_1.xsd + + ]]> + + + + + + The following conventions apply to all Jakarta EE deployment descriptor + elements unless indicated otherwise. - In elements that specify a pathname to a file within + the same JAR file, relative filenames (i.e., those not starting with "/") are considered + relative to the root of the JAR file's namespace. Absolute filenames (i.e., those starting + with "/") also specify names in the root of the JAR file's namespace. In general, relative + names are preferred. The exception is .war files where absolute names are preferred for + consistency with the Servlet API. + + + + + + + + + + This is the root element of jboss-web deployment descriptor. + + + + + + + + + + + + + + The jboss-web element is the root element of jboss-web.xml file. It contains + all the information used by jboss but not described in the web.xml file. All of it is optional. + + + + + + + + + + + + + + + + + + + + + + + + + + + Determines the maximum number of sessions to retain in memory. If the application attempts to exceed + this limit, the resulting behavior is determined by the session manager. + + If the session manager supports passivation, then sessions accessed least recently will be + passivated to make room for new sessions. + If the session manager does not support passivation then any attempt to create more than + max-active-sessions will fail. + + If undefined, or if set to -1, then no limit is placed on the number of sessions retained in memory, + and sessions will never passivate. + + + + + + + + + + + + + + + + Defines a web container listener. The module element allows specifying from which + module in the application server the specified class will be loaded. The listener type + element defines which events the listener will receive from the web container. + + + + + + + + + + + + + + + LIFECYCLE + + ]]> + + + + + + + + + + + + + + + + + Defines a web container valve. The module element allows specifying from which + module in the application server the specified class will be loaded. A container + valve is used to intercept the request that will be processed by the servlet. It + is invoked as part of a chain, before the invocation of the webapp's filter chain. + + + + + + + + + + + + + + + Defines a web container HTTPHandler. The module element allows specifying from which + module in the application server the specified class will be loaded. A handler + is used to intercept the request that will be processed by the servlet. It + is invoked as part of a chain, before the invocation of the webapp's filter chain. + + The class specified can either be a HttpHandler that has a constructor that takes the + next HttpHandler, or can be a HandlerWrapper that produces the next handler. + + + + + + + + + + + + + + The overlay element specifies additional static files overlays for this + web application. The content of the element should be a folder in the + filesystem containing the static files that will overlay the webapp's + static files, similar to what happens with regular JAR overlays. + If a file is found in both the deployment and in the overlay folder, + the file in the deployment takes precedence. If more than one overlay + is provided, the order in which the overlay elements are declared + determines precedence for files that can be found in multiple overlay + folders. + + + + + + + + + + + The name of a security-domain that will be used to authenticate and authorize users. + + + + + + + + Whether the domain's cache should be flushed when the session invalidates. + + + + + + + + + + + The disable-cross-context element specifies if cross context + access should be enabled for this webapp, allowing it to use the + request dispatcher to access other webapps deployed in the + application server. + + + + + + + + + + + The use-jboss-authorization element specifies if the JBoss + authorization layer should be used. + + + + + + + + + + + The disable-audit element specifies if the security audit logging + should be disabled. + + + + + + + + + + + If this is set to false then authentication will not be performed unless it is required, + even if credentials are present. + + + + + + + + + + The distinct-name element specifies the EJB 3 distinct name for this + web application. + + + + + + + + + + + The symbolic-linked-allowed element specifies if symlinking is allowed in exploded deployments. + + + + + + + + + + + The jacc-star-role-allow element specifies whether the + jacc permission generating agent in the web layer needs to generate a + WebResourcePermission(url,null) permission such that the jacc provider can + make a decision as to bypass authorization or not. + + + + + + + + + + + The jacc-context-id element allows for the specification of the JACC contextID that should + be used to identify the web application when checking for permissions. If not set the deployment + unit name is used as JACC contextID. + + + + + + + + + + + The context-root element specifies the context root of a web + application. This is normally specified at the ear level using the standard + JEE application.xml descriptor, but it may be given here for standalone wars. + This should not override the application.xml level specification. + + + + + + + + + + + The servlet-container element specifies the which servlet container this application + should be using. + + + + + + + + + + + + The server-instance element specifies the which server instance configuration this application belongs to. + + + + + + + + + + + Default encoding to use for this application + + + + + + + + + + + www.jboss-store.org + + ]]> + + + + + + + + + + + The servlet element specifies servlet specific bindings. Currently this + is only the run-as principal identity. + + + + + + + + + The run-as-principal element specifies whether a specific run-as identity is + to be used. If there is a run-as role defined for a servlet, there can also + be a run-as-principal defined here. If you don't define a run-as principal + the callee will see ctx.getUserPrincipal() == 'anonymous' + + + + + + + + + + + + + + + The annotation element specifies annotation specific bindings. This allows + overriding the @ServletSecurity, @RunAs and @MultipartConfig, which apply + on a Servlet class rather than a Servlet name. They have the same structure + and element names as the corresponding annotation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Legacy enable-websockets option. Websockets are enabled by default, this option allows them to be + turned off. + + + + + + + diff --git a/web/src/test/java/org/jboss/test/metadata/web/JBossWeb151UnitTestCase.java b/web/src/test/java/org/jboss/test/metadata/web/JBossWeb151UnitTestCase.java new file mode 100644 index 000000000..895529abd --- /dev/null +++ b/web/src/test/java/org/jboss/test/metadata/web/JBossWeb151UnitTestCase.java @@ -0,0 +1,33 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.jboss.test.metadata.web; + + +import javax.xml.stream.XMLStreamException; + +import org.jboss.metadata.parser.jbossweb.JBossWebMetaDataParser; +import org.jboss.metadata.property.PropertyReplacers; +import org.jboss.metadata.web.jboss.JBossWebMetaData; +import org.jboss.test.metadata.javaee.AbstractJavaEEEverythingTest; +import org.junit.Assert; + +public class JBossWeb151UnitTestCase extends AbstractJavaEEEverythingTest { + + public void testReplicationConfig() throws Exception { + try { + JBossWebMetaDataParser.parse(getReader(), PropertyReplacers.noop()); + Assert.fail(" is no longer valid"); + } catch (XMLStreamException e) { + // Expected + } + } + + @SuppressWarnings("deprecation") + public void testClustering() throws Exception { + JBossWebMetaData metaData = JBossWebMetaDataParser.parse(getReader(), PropertyReplacers.noop()); + Assert.assertNull(metaData.getReplicationConfig()); + } +} diff --git a/web/src/test/java/org/jboss/test/metadata/web/WebApp11EverythingUnitTestCase.java b/web/src/test/java/org/jboss/test/metadata/web/WebApp11EverythingUnitTestCase.java new file mode 100644 index 000000000..09e707ebc --- /dev/null +++ b/web/src/test/java/org/jboss/test/metadata/web/WebApp11EverythingUnitTestCase.java @@ -0,0 +1,34 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.test.metadata.web; + +import java.util.List; + +import org.jboss.metadata.merge.javaee.spec.JavaEEVersion; +import org.jboss.metadata.web.spec.AttributeValueMetaData; +import org.jboss.metadata.web.spec.WebMetaData; + +/** + * Test all entries of Jakarta EE 11 web-app. + * + * @author Eduardo Martins + * + */ +public class WebApp11EverythingUnitTestCase extends WebApp6EverythingUnitTestCase { + + public void testEverything() throws Exception { + WebMetaData webApp = unmarshal(); + assertEverything(webApp, Mode.SPEC, JavaEEVersion.V11); + } + + protected void assertCookieAttributes(List attributes) { + assertNotNull("cookie attributes not set", attributes); + assertEquals(2, attributes.size()); + assertEquals("SameSite", attributes.get(0).getAttributeName()); + assertEquals("None", attributes.get(0).getAttributeValue()); + assertEquals("foo", attributes.get(1).getAttributeName()); + assertEquals("bar", attributes.get(1).getAttributeValue()); + } +} diff --git a/web/src/test/java/org/jboss/test/metadata/web/WebApp11FragmentUnitTestCase.java b/web/src/test/java/org/jboss/test/metadata/web/WebApp11FragmentUnitTestCase.java new file mode 100644 index 000000000..c4162b813 --- /dev/null +++ b/web/src/test/java/org/jboss/test/metadata/web/WebApp11FragmentUnitTestCase.java @@ -0,0 +1,23 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.test.metadata.web; + +import org.jboss.metadata.merge.javaee.spec.JavaEEVersion; +import org.jboss.metadata.web.spec.WebFragmentMetaData; + +/** + * Test all entries of Jakarta EE 11 web-fragment. + * + * @author Eduardo Martins + * + */ +public class WebApp11FragmentUnitTestCase extends WebApp6FragmentUnitTestCase { + + public void testEverything() throws Exception { + WebFragmentMetaData webApp = unmarshal(); + assertEverything(webApp, Mode.SPEC, JavaEEVersion.V11); + } + +} diff --git a/web/src/test/resources/org/jboss/test/metadata/web/JBossWeb151_testClustering.xml b/web/src/test/resources/org/jboss/test/metadata/web/JBossWeb151_testClustering.xml new file mode 100644 index 000000000..bec3ad47c --- /dev/null +++ b/web/src/test/resources/org/jboss/test/metadata/web/JBossWeb151_testClustering.xml @@ -0,0 +1,12 @@ + + + + + + 10 + + diff --git a/web/src/test/resources/org/jboss/test/metadata/web/JBossWeb151_testReplicationConfig.xml b/web/src/test/resources/org/jboss/test/metadata/web/JBossWeb151_testReplicationConfig.xml new file mode 100644 index 000000000..b54e29d5f --- /dev/null +++ b/web/src/test/resources/org/jboss/test/metadata/web/JBossWeb151_testReplicationConfig.xml @@ -0,0 +1,15 @@ + + + + + + + testCache + SESSION + + + diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp11Fragment_testEverything.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp11Fragment_testEverything.xml index ce1a10af0..047a6c437 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp11Fragment_testEverything.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp11Fragment_testEverything.xml @@ -6,7 +6,7 @@