This is an automated email from the ASF dual-hosted git repository.

rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 1e2c1d2ad9b21b730e4a31e929daa10f78a1de81
Author: opencode <[email protected]>
AuthorDate: Thu Oct 15 12:17:03 2026 +0200

    Add the read-descriptors error message to the modules string bundle
    
    MbeansDescriptorsIntrospectionSource declares its own StringManager
    bound to the org.apache.tomcat.util.modeler.modules resource bundle but
    logs with the key modules.readDescriptorsError, which existed only in
    the org.apache.tomcat.util.modeler bundle used by the sibling digester
    source through the inherited manager. StringManager has no fallback to
    a parent package bundle and its single argument getString() returns
    null for a key that is missing from its bundle, so a failed descriptor
    load logged an error entry without a message.
    
    Add the message to the modules bundle, and add a test asserting that
    the keys bound to that bundle resolve from the default locale as well
    as from the translated bundles, which fall back to the base bundle for
    keys that are not yet translated.
---
 .../util/modeler/modules/TestLocalStrings.java     | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/test/org/apache/tomcat/util/modeler/modules/TestLocalStrings.java 
b/test/org/apache/tomcat/util/modeler/modules/TestLocalStrings.java
new file mode 100644
index 0000000000..5639ff86f8
--- /dev/null
+++ b/test/org/apache/tomcat/util/modeler/modules/TestLocalStrings.java
@@ -0,0 +1,57 @@
+/*
+ * 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.tomcat.util.modeler.modules;
+
+import java.util.Locale;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.tomcat.util.res.StringManager;
+
+public class TestLocalStrings {
+
+    private static final String PACKAGE_NAME = 
"org.apache.tomcat.util.modeler.modules";
+
+    // Keys used by the classes in this package via the StringManager that is
+    // bound to this package. A key that is missing from this package's
+    // bundle is not resolved by the parent package and the message is lost.
+    private static final String[] KEYS = { "modules.readDescriptorsError", 
"source.introspectionError" };
+
+    @Test
+    public void testKeysResolveInDefaultBundle() {
+        assertKeysResolve(StringManager.getManager(PACKAGE_NAME));
+    }
+
+    @Test
+    public void testKeysResolveInFrenchBundle() {
+        assertKeysResolve(StringManager.getManager(PACKAGE_NAME, 
Locale.FRENCH));
+    }
+
+    @Test
+    public void testKeysResolveInJapaneseBundle() {
+        assertKeysResolve(StringManager.getManager(PACKAGE_NAME, 
Locale.JAPANESE));
+    }
+
+    private void assertKeysResolve(StringManager sm) {
+        for (String key : KEYS) {
+            String value = sm.getString(key);
+            Assert.assertNotNull("Missing key: " + key, value);
+            Assert.assertNotEquals("Unresolved key: " + key, key, value);
+        }
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to