You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ds...@apache.org on 2025/09/02 12:42:09 UTC
(tomcat) branch 11.0.x updated (c47aaa6952 -> 9d74f0580e)
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a change to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from c47aaa6952 Document implementation expectations
new 98414c4da1 Add WebappLogCapture to capture webapp-scoped logs at CONFIGURE_START
new 415ab0a789 Add TestStrictComplianceDeployment for STRICT_SERVLET_COMPLIANCE web.xml parsing
new 2a947b2108 Add helper method getProgrammaticRootContextWithManager() in TomcatBaseTest
new 8ae5e5aa66 Create two tests, one testing that the XML validation works (configured using the Context attributes) and one testing that setting STRICT_SERVLET_COMPLIANCE sets the attributes it is documented to set.
new 9d74f0580e Fix continuation indentation
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../TestStrictServletComplianceAttributes.java | 76 ++++++++++++
.../startup/TestXmlValidationUsingContext.java | 87 ++++++++++++++
.../apache/catalina/startup/TomcatBaseTest.java | 128 ++++++++++++++++++++-
3 files changed, 289 insertions(+), 2 deletions(-)
create mode 100644 test/org/apache/catalina/startup/TestStrictServletComplianceAttributes.java
create mode 100644 test/org/apache/catalina/startup/TestXmlValidationUsingContext.java
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/05: Add TestStrictComplianceDeployment for STRICT_SERVLET_COMPLIANCE web.xml parsing
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 415ab0a7891a103c6d88fc37de715734a9d93ad9
Author: Dimitris Soumis <ji...@gmail.com>
AuthorDate: Fri Aug 29 23:11:26 2025 +0300
Add TestStrictComplianceDeployment for STRICT_SERVLET_COMPLIANCE web.xml parsing
---
.../startup/TestStrictComplianceDeployment.java | 112 +++++++++++++++++++++
1 file changed, 112 insertions(+)
diff --git a/test/org/apache/catalina/startup/TestStrictComplianceDeployment.java b/test/org/apache/catalina/startup/TestStrictComplianceDeployment.java
new file mode 100644
index 0000000000..55e3fcf9d0
--- /dev/null
+++ b/test/org/apache/catalina/startup/TestStrictComplianceDeployment.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.startup;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.logging.Level;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.catalina.Context;
+
+/**
+ * Verification for STRICT_SERVLET_COMPLIANCE and web.xml parsing.
+ */
+public class TestStrictComplianceDeployment extends TomcatBaseTest {
+ private static final String STRICT_SERVLET_COMPLIANCE = "org.apache.catalina.STRICT_SERVLET_COMPLIANCE";
+ private static String originalPropertyValue;
+ @BeforeClass
+ public static void enableStrictServletCompliance() {
+ originalPropertyValue = System.getProperty(STRICT_SERVLET_COMPLIANCE);
+ System.setProperty(STRICT_SERVLET_COMPLIANCE, "true");
+ }
+
+ @AfterClass
+ public static void restoreStrictServletCompliance() {
+ if (originalPropertyValue == null) {
+ System.clearProperty(STRICT_SERVLET_COMPLIANCE);
+ } else {
+ System.setProperty(STRICT_SERVLET_COMPLIANCE, originalPropertyValue);
+ }
+ }
+
+ @Test
+ public void testWebAppDeployWithStrictComplianceWithSaxParseException() throws Exception {
+ File appDir = getTemporaryDirectory();
+ File webInf = new File(appDir, "WEB-INF");
+ Assert.assertTrue(webInf.isDirectory() || webInf.mkdirs());
+ writeInvalidXml(new File(webInf, "web.xml"));
+ Tomcat tomcat = getTomcatInstance();
+ Context ctx = tomcat.addWebapp(null,"", appDir.getAbsolutePath());
+
+ try(WebappLogCapture capture = attachWebappLogCapture(
+ ctx, Level.SEVERE,"org.apache.tomcat.util.digester.Digester")) {
+ tomcat.start();
+ Assert.assertTrue("A 'Parse error' was found in the logs.", capture.containsText("Parse error at line"));
+ Assert.assertTrue("A SAXParseException was found in the logs.", capture.hasException(org.xml.sax.SAXParseException.class));
+
+ }
+ }
+
+ @Test
+ public void testWebAppDeployWithStrictComplianceNoSaxParseException() throws Exception {
+ File appDir = getTemporaryDirectory();
+ File webInf = new File(appDir, "WEB-INF");
+ Assert.assertTrue(webInf.isDirectory() || webInf.mkdirs());
+ writeValidXml(new File(webInf, "web.xml"));
+ Tomcat tomcat = getTomcatInstance();
+ Context ctx = tomcat.addWebapp(null,"", appDir.getAbsolutePath());
+
+ try(WebappLogCapture capture = attachWebappLogCapture(
+ ctx, Level.SEVERE,"org.apache.tomcat.util.digester.Digester")) {
+ tomcat.start();
+ Assert.assertFalse("A 'Parse error' was found in the logs.", capture.containsText("Parse error at line"));
+ Assert.assertFalse("A SAXParseException was found in the logs.", capture.hasException(org.xml.sax.SAXParseException.class));
+
+ }
+ }
+ private void writeValidXml(File webXml) throws IOException {
+ try (FileWriter fw = new FileWriter(webXml)) {
+ fw.write(
+ """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <web-app 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_6_0.xsd"
+ version="6.0">
+ </web-app>
+ """);
+ }
+ }
+ private void writeInvalidXml(File webXml) throws IOException {
+ try (FileWriter fw = new FileWriter(webXml)) {
+ fw.write(
+ """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <web-app>
+ </web-app>
+ """);
+ }
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 04/05: Create two tests, one testing that the XML validation works (configured using the Context attributes) and one testing that setting STRICT_SERVLET_COMPLIANCE sets the attributes it is documented to set.
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 8ae5e5aa66d64ff1113ab1a816170b261d893e34
Author: Dimitris Soumis <ji...@gmail.com>
AuthorDate: Mon Sep 1 15:21:20 2025 +0300
Create two tests, one testing that the XML validation works (configured using the Context attributes) and one testing that setting STRICT_SERVLET_COMPLIANCE sets the attributes it is documented to set.
---
.../TestStrictServletComplianceAttributes.java | 76 ++++++++++++++++++++++
...ent.java => TestXmlValidationUsingContext.java} | 61 +++++------------
2 files changed, 94 insertions(+), 43 deletions(-)
diff --git a/test/org/apache/catalina/startup/TestStrictServletComplianceAttributes.java b/test/org/apache/catalina/startup/TestStrictServletComplianceAttributes.java
new file mode 100644
index 0000000000..e8ad97aef3
--- /dev/null
+++ b/test/org/apache/catalina/startup/TestStrictServletComplianceAttributes.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.startup;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Globals;
+import org.apache.catalina.Manager;
+import org.apache.catalina.session.ManagerBase;
+
+/**
+ * Tests STRICT_SERVLET_COMPLIANCE sets the attributes it is documented to set.
+ */
+public class TestStrictServletComplianceAttributes extends TomcatBaseTest {
+ private static final String STRICT_SERVLET_COMPLIANCE = "org.apache.catalina.STRICT_SERVLET_COMPLIANCE";
+ private static String originalPropertyValue;
+
+ @BeforeClass
+ public static void setup() {
+ originalPropertyValue = System.getProperty(STRICT_SERVLET_COMPLIANCE);
+ System.setProperty(STRICT_SERVLET_COMPLIANCE, "true");
+
+ // If Globals was already initialised in the same JVM (during the tests run through IDE),
+ // before the test sets the value to true, skip.
+ boolean globalsStrict = Globals.STRICT_SERVLET_COMPLIANCE;
+ Assume.assumeTrue("Globals was initialised before setting the property", globalsStrict);
+ }
+
+ @AfterClass
+ public static void restoreStrictServletCompliance() {
+ if (originalPropertyValue == null) {
+ System.clearProperty(STRICT_SERVLET_COMPLIANCE);
+ } else {
+ System.setProperty(STRICT_SERVLET_COMPLIANCE, originalPropertyValue);
+ }
+ }
+
+ @Test
+ public void contextFlagsSetWhenStrictComplianceIsEnabled() {
+ Context ctx = getProgrammaticRootContextWithManager();
+ Assert.assertTrue("xmlValidation should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getXmlValidation());
+ Assert.assertTrue("xmlNamespaceAware should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getXmlNamespaceAware());
+ Assert.assertTrue("tldValidation should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getTldValidation());
+ Assert.assertFalse("useRelativeRedirects should be false under STRICT_SERVLET_COMPLIANCE.", ctx.getUseRelativeRedirects());
+ Assert.assertTrue("alwaysAccessSession should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getAlwaysAccessSession());
+ Assert.assertTrue("contextGetResourceRequiresSlash should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getContextGetResourceRequiresSlash());
+ Assert.assertTrue("dispatcherWrapsSameObject should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getDispatcherWrapsSameObject());
+ Assert.assertFalse("All extension mapped servlets should be checked against welcome files under STRICT_SERVLET_COMPLIANCE.", ctx.isResourceOnlyServlet("jsp"));
+
+ Manager manager = ctx.getManager();
+ if (manager instanceof ManagerBase managerBase) {
+ Assert.assertTrue("ManagerBase.sessionActivityCheck should be true under STRICT", managerBase.getSessionActivityCheck());
+ Assert.assertTrue("ManagerBase.sessionLastAccessAtStart should be true under STRICT", managerBase.getSessionLastAccessAtStart());
+ }
+ }
+
+}
diff --git a/test/org/apache/catalina/startup/TestStrictComplianceDeployment.java b/test/org/apache/catalina/startup/TestXmlValidationUsingContext.java
similarity index 55%
rename from test/org/apache/catalina/startup/TestStrictComplianceDeployment.java
rename to test/org/apache/catalina/startup/TestXmlValidationUsingContext.java
index 55e3fcf9d0..8528b97f94 100644
--- a/test/org/apache/catalina/startup/TestStrictComplianceDeployment.java
+++ b/test/org/apache/catalina/startup/TestXmlValidationUsingContext.java
@@ -14,76 +14,52 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.catalina.startup;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.util.logging.Level;
-import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.apache.catalina.Context;
/**
- * Verification for STRICT_SERVLET_COMPLIANCE and web.xml parsing.
+ * Tests XML validation works on the Context.
*/
-public class TestStrictComplianceDeployment extends TomcatBaseTest {
- private static final String STRICT_SERVLET_COMPLIANCE = "org.apache.catalina.STRICT_SERVLET_COMPLIANCE";
- private static String originalPropertyValue;
- @BeforeClass
- public static void enableStrictServletCompliance() {
- originalPropertyValue = System.getProperty(STRICT_SERVLET_COMPLIANCE);
- System.setProperty(STRICT_SERVLET_COMPLIANCE, "true");
- }
-
- @AfterClass
- public static void restoreStrictServletCompliance() {
- if (originalPropertyValue == null) {
- System.clearProperty(STRICT_SERVLET_COMPLIANCE);
- } else {
- System.setProperty(STRICT_SERVLET_COMPLIANCE, originalPropertyValue);
- }
- }
-
+public class TestXmlValidationUsingContext extends TomcatBaseTest {
@Test
- public void testWebAppDeployWithStrictComplianceWithSaxParseException() throws Exception {
+ public void contextValidationWithInvalidWebXml() throws Exception {
File appDir = getTemporaryDirectory();
File webInf = new File(appDir, "WEB-INF");
Assert.assertTrue(webInf.isDirectory() || webInf.mkdirs());
writeInvalidXml(new File(webInf, "web.xml"));
Tomcat tomcat = getTomcatInstance();
- Context ctx = tomcat.addWebapp(null,"", appDir.getAbsolutePath());
-
- try(WebappLogCapture capture = attachWebappLogCapture(
- ctx, Level.SEVERE,"org.apache.tomcat.util.digester.Digester")) {
- tomcat.start();
- Assert.assertTrue("A 'Parse error' was found in the logs.", capture.containsText("Parse error at line"));
- Assert.assertTrue("A SAXParseException was found in the logs.", capture.hasException(org.xml.sax.SAXParseException.class));
-
- }
+ Context ctx = tomcat.addWebapp(null, "", appDir.getAbsolutePath());
+ ctx.setXmlValidation(true);
+ ctx.setXmlNamespaceAware(true);
+ tomcat.start();
+ Assert.assertFalse("Context should not be available when web.xml is invalid and validation is enabled",
+ ctx.getState().isAvailable());
}
@Test
- public void testWebAppDeployWithStrictComplianceNoSaxParseException() throws Exception {
+ public void contextValidationWithValidWebXml() throws Exception {
File appDir = getTemporaryDirectory();
File webInf = new File(appDir, "WEB-INF");
Assert.assertTrue(webInf.isDirectory() || webInf.mkdirs());
writeValidXml(new File(webInf, "web.xml"));
Tomcat tomcat = getTomcatInstance();
- Context ctx = tomcat.addWebapp(null,"", appDir.getAbsolutePath());
-
- try(WebappLogCapture capture = attachWebappLogCapture(
- ctx, Level.SEVERE,"org.apache.tomcat.util.digester.Digester")) {
- tomcat.start();
- Assert.assertFalse("A 'Parse error' was found in the logs.", capture.containsText("Parse error at line"));
- Assert.assertFalse("A SAXParseException was found in the logs.", capture.hasException(org.xml.sax.SAXParseException.class));
-
- }
+ Context ctx = tomcat.addWebapp(null, "", appDir.getAbsolutePath());
+ ctx.setXmlValidation(true);
+ ctx.setXmlNamespaceAware(true);
+ tomcat.start();
+ Assert.assertTrue("Context should be available when web.xml is valid and validation is enabled",
+ ctx.getState().isAvailable());
}
+
private void writeValidXml(File webXml) throws IOException {
try (FileWriter fw = new FileWriter(webXml)) {
fw.write(
@@ -108,5 +84,4 @@ public class TestStrictComplianceDeployment extends TomcatBaseTest {
""");
}
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/05: Add WebappLogCapture to capture webapp-scoped logs at CONFIGURE_START
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 98414c4da15c118db28d59e01711799ebf1dd1e1
Author: Dimitris Soumis <ji...@gmail.com>
AuthorDate: Fri Aug 29 23:10:37 2025 +0300
Add WebappLogCapture to capture webapp-scoped logs at CONFIGURE_START
---
.../apache/catalina/startup/TomcatBaseTest.java | 119 +++++++++++++++++++++
1 file changed, 119 insertions(+)
diff --git a/test/org/apache/catalina/startup/TomcatBaseTest.java b/test/org/apache/catalina/startup/TomcatBaseTest.java
index 8594e8aa13..8106aec718 100644
--- a/test/org/apache/catalina/startup/TomcatBaseTest.java
+++ b/test/org/apache/catalina/startup/TomcatBaseTest.java
@@ -31,10 +31,18 @@ import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
@@ -49,7 +57,10 @@ import org.junit.Before;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.Manager;
import org.apache.catalina.Server;
@@ -925,4 +936,112 @@ public abstract class TomcatBaseTest extends LoggingBaseTest {
session.setMaxInactiveInterval(newIntervalSecs);
}
}
+
+ /**
+ * Captures webapp-scoped logs (e.g. ContextConfig/Digester) during the
+ * CONFIGURE_START phase of a {@link Context}.
+ */
+ public static class WebappLogCapture implements LifecycleListener, AutoCloseable {
+ private final Level level;
+ private final String[] loggerNames;
+ private final List<LogRecord> logRecords = Collections.synchronizedList(new ArrayList<>());
+ private final Map<Logger, Level> previousLevelsOfLoggersMap = new IdentityHashMap<>();
+ private final List<Logger> attachedLoggers = new CopyOnWriteArrayList<>();
+ private volatile boolean installed = false;
+
+ private final Handler handler = new Handler() {
+ @Override
+ public void publish(LogRecord record) {
+ logRecords.add(record);
+ }
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() throws SecurityException {
+ logRecords.clear();
+ }
+ };
+ public WebappLogCapture(Level level, String... loggerNames) {
+ this.level = level == null ? Level.ALL : level;
+ this.loggerNames = loggerNames;
+ }
+
+ @Override
+ public void close() throws Exception {
+ for (Logger l : attachedLoggers) {
+ try {
+ l.removeHandler(handler);
+ } catch (Throwable ignore) {
+ }
+ try {
+ l.setLevel(previousLevelsOfLoggersMap.get(l));
+ } catch (Throwable ignore) {
+ }
+ }
+ attachedLoggers.clear();
+ previousLevelsOfLoggersMap.clear();
+ }
+
+ @Override
+ public void lifecycleEvent(LifecycleEvent event) {
+ if (Lifecycle.CONFIGURE_START_EVENT.equals(event.getType()) && !installed) {
+ installed = true;
+ for (String name : loggerNames) {
+ Logger logger = Logger.getLogger(name);
+ previousLevelsOfLoggersMap.put(logger, logger.getLevel());
+ logger.addHandler(handler);
+ logger.setLevel(level);
+ attachedLoggers.add(logger);
+ }
+ }
+ }
+
+ public boolean containsText(CharSequence s) {
+ for (LogRecord record : logRecords) {
+ if (record.getMessage().contains(s)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ public boolean hasException(Class<? extends Throwable> type) {
+ for (LogRecord record : logRecords) {
+ Throwable t = record.getThrown();
+ while (t != null) {
+ if (type.isInstance(t)) {return true;}
+ t = t.getCause();
+ }
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Installs a {@link WebappLogCapture} on the given {@link Context} so it runs
+ * before {@link ContextConfig} during CONFIGURE_START.
+ * @param ctx the webapp context
+ * @param level level for loggers (e.g. {@code Level.ALL})
+ * @param loggerNames fully-qualified logger names
+ * @return the active capture
+ */
+ public static WebappLogCapture attachWebappLogCapture(Context ctx, Level level, String... loggerNames) {
+ List<LifecycleListener> lifecycleListenersToReAdd = new ArrayList<>();
+ for (LifecycleListener l : ctx.findLifecycleListeners()) {
+ if (l instanceof ContextConfig) {
+ lifecycleListenersToReAdd.add(l);
+ }
+ }
+ for (LifecycleListener l : lifecycleListenersToReAdd) {
+ ctx.removeLifecycleListener(l);
+ }
+ WebappLogCapture webappLogCapture = new WebappLogCapture(level, loggerNames);
+ ctx.addLifecycleListener(webappLogCapture);
+ for (LifecycleListener l : lifecycleListenersToReAdd) {
+ ctx.addLifecycleListener(l);
+ }
+ return webappLogCapture;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 05/05: Fix continuation indentation
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 9d74f0580ed5a7cba5c62ce9921c7079e0c1dde7
Author: Dimitris Soumis <ji...@gmail.com>
AuthorDate: Tue Sep 2 15:17:40 2025 +0300
Fix continuation indentation
---
.../startup/TestXmlValidationUsingContext.java | 32 +++++++++++-----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/test/org/apache/catalina/startup/TestXmlValidationUsingContext.java b/test/org/apache/catalina/startup/TestXmlValidationUsingContext.java
index 8528b97f94..d55b9ff51f 100644
--- a/test/org/apache/catalina/startup/TestXmlValidationUsingContext.java
+++ b/test/org/apache/catalina/startup/TestXmlValidationUsingContext.java
@@ -42,7 +42,7 @@ public class TestXmlValidationUsingContext extends TomcatBaseTest {
ctx.setXmlNamespaceAware(true);
tomcat.start();
Assert.assertFalse("Context should not be available when web.xml is invalid and validation is enabled",
- ctx.getState().isAvailable());
+ ctx.getState().isAvailable());
}
@Test
@@ -57,31 +57,31 @@ public class TestXmlValidationUsingContext extends TomcatBaseTest {
ctx.setXmlNamespaceAware(true);
tomcat.start();
Assert.assertTrue("Context should be available when web.xml is valid and validation is enabled",
- ctx.getState().isAvailable());
+ ctx.getState().isAvailable());
}
private void writeValidXml(File webXml) throws IOException {
try (FileWriter fw = new FileWriter(webXml)) {
fw.write(
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app 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_6_0.xsd"
- version="6.0">
- </web-app>
- """);
+ """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <web-app 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_6_0.xsd"
+ version="6.0">
+ </web-app>
+ """);
}
}
private void writeInvalidXml(File webXml) throws IOException {
try (FileWriter fw = new FileWriter(webXml)) {
fw.write(
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app>
- </web-app>
- """);
+ """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <web-app>
+ </web-app>
+ """);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 03/05: Add helper method getProgrammaticRootContextWithManager() in TomcatBaseTest
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 2a947b2108270a58c4367b2dadfe7888da01607f
Author: Dimitris Soumis <ji...@gmail.com>
AuthorDate: Mon Sep 1 14:55:23 2025 +0300
Add helper method getProgrammaticRootContextWithManager() in TomcatBaseTest
---
test/org/apache/catalina/startup/TomcatBaseTest.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/test/org/apache/catalina/startup/TomcatBaseTest.java b/test/org/apache/catalina/startup/TomcatBaseTest.java
index 8106aec718..31bcd1acc5 100644
--- a/test/org/apache/catalina/startup/TomcatBaseTest.java
+++ b/test/org/apache/catalina/startup/TomcatBaseTest.java
@@ -148,8 +148,13 @@ public abstract class TomcatBaseTest extends LoggingBaseTest {
((StandardJarScanner) ctx.getJarScanner()).setScanClassPath(false);
return ctx;
}
-
-
+ public Context getProgrammaticRootContextWithManager() {
+ Context ctx = getProgrammaticRootContext();
+ if (ctx.getManager() == null) {
+ ctx.setManager(new StandardManager());
+ }
+ return ctx;
+ }
/*
* Sub-classes need to know port so they can connect
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org