This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new ba6c28efc8 Improve test and fix additional issue found
ba6c28efc8 is described below
commit ba6c28efc8b7a3d2c07522508ddde6a87aa2cef6
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Apr 30 14:13:14 2025 +0100
Improve test and fix additional issue found
---
.../catalina/startup/MimeTypeMappings.properties | 2 +-
.../catalina/startup/TestTomcatNoServer.java | 43 ++++++++++++++--------
2 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/java/org/apache/catalina/startup/MimeTypeMappings.properties
b/java/org/apache/catalina/startup/MimeTypeMappings.properties
index 2cbb89bbd3..360f8ca6c0 100644
--- a/java/org/apache/catalina/startup/MimeTypeMappings.properties
+++ b/java/org/apache/catalina/startup/MimeTypeMappings.properties
@@ -526,7 +526,7 @@ msh=model/mesh
msi=application/x-msdownload
msl=application/vnd.mobius.msl
msty=application/vnd.muvee.style
-mts=model/vnd.mts
+mts=video/mp2t
mus=application/vnd.musician
musicxml=application/vnd.recordare.musicxml+xml
mvb=application/x-msmediaview
diff --git a/test/org/apache/catalina/startup/TestTomcatNoServer.java
b/test/org/apache/catalina/startup/TestTomcatNoServer.java
index 34f26c98dc..535893c07c 100644
--- a/test/org/apache/catalina/startup/TestTomcatNoServer.java
+++ b/test/org/apache/catalina/startup/TestTomcatNoServer.java
@@ -19,6 +19,7 @@ package org.apache.catalina.startup;
import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.jar.JarFile;
@@ -66,27 +67,37 @@ public class TestTomcatNoServer {
Set<String> embeddedExtensions = new
HashSet<>(Arrays.asList(ctx.findMimeMappings()));
- // Find entries present in conf/web.xml that are missing in embedded
- Set<String> missingInEmbedded = new
HashSet<>(webXmlMimeMappings.keySet());
- missingInEmbedded.removeAll(embeddedExtensions);
- if (missingInEmbedded.size() > 0) {
- for (String missingExtension : missingInEmbedded) {
- System.out.println("Missing in embedded: [" + missingExtension
+
- "]-[" + webXmlMimeMappings.get(missingExtension) +
"]");
+ boolean pass = true;
+
+ /*
+ * Check that each entry for embedded is present in web.xml with the
same media type.
+ * Also finds entries that are missing in conf/web.xml
+ */
+ Iterator<String> embeddedExtensionIterator =
embeddedExtensions.iterator();
+ while (embeddedExtensionIterator.hasNext()) {
+ String embeddedExtension = embeddedExtensionIterator.next();
+ String embeddedMediaType = ctx.findMimeMapping(embeddedExtension);
+
+ if
(!embeddedMediaType.equals(webXmlMimeMappings.get(embeddedExtension))) {
+ pass = false;
+ System.out.println("Extension [" + embeddedExtension + "] is
mapped to [" + embeddedMediaType +
+ "] in embedded but [" +
webXmlMimeMappings.get(embeddedExtension) + "] in conf/web.xml");
}
- Assert.fail("Embedded is missing [" + missingInEmbedded.size() +
"] entries compared to conf/web.xml");
+ // Remove from both whether they matched or not
+ embeddedExtensionIterator.remove();
+ webXmlMimeMappings.remove(embeddedExtension);
}
- // Find entries present in embedded that are missing in conf/web.xml
- Set<String> missingInWebXml = new HashSet<>(embeddedExtensions);
- missingInWebXml.removeAll(webXmlMimeMappings.keySet());
- if (missingInWebXml.size() > 0) {
- for (String missingExtension : missingInWebXml) {
- System.out.println("Missing in embedded: [" + missingExtension
+
- "]-[" + ctx.findMimeMapping(missingExtension) + "]");
+ // Check for entries missing in embedded
+ if (webXmlMimeMappings.size() > 0) {
+ pass = false;
+ for (Map.Entry<String,String> mapping :
webXmlMimeMappings.entrySet()) {
+ System.out.println("Extension [" + mapping.getKey() + "] is
mapped to [" + mapping.getValue() +
+ "] in conf/web.xml but [null] in embedded");
}
- Assert.fail("Embedded is missing [" + missingInWebXml.size() + "]
entries compared to conf/web.xml");
}
+
+ Assert.assertTrue(pass);
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]