You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ppkarwasz (via GitHub)" <gi...@apache.org> on 2026/10/08 17:18:09 UTC

[PR] COMMONSXML-20: Load the Java 8 default XMLInputFactory from the bootstrap loader [commons-secure-xml]

ppkarwasz opened a new pull request, #114:
URL: https://github.com/apache/commons-secure-xml/pull/114

   Fixes [COMMONSXML-20](https://issues.apache.org/jira/browse/COMMONSXML-20).
   
   On Java 8, `SecureXMLInputFactory.newDefaultFactory()` instantiates the JDK's built-in `XMLInputFactory` by class name, through the library's own class loader.
   In OSGi that is a bundle class loader, which cannot see `com.sun.*`, so the call fails.
   The class is now loaded from the bootstrap class loader.
   
   ### OSGi integration test
   
   The second commit adds `OsgiIT`, which runs the unit test suite inside an OSGi framework against the built bundle:
   
   - The built jar is installed with its generated manifest, so the test also checks that `Import-Package` resolves.
   - The test classes are attached to it as a fragment, so they share its class loader. A second `maven-bundle-plugin` execution (`manifest` goal) writes the fragment manifest into `target/test-classes`, and the directory is installed in place. No test jar is built or deployed.
   - The test harness (JUnit, Mockito, JAXB) is boot-delegated to the class path, and the frameworks' implicit parent delegation is turned off.
   - Failsafe runs the class twice: once with Apache Felix 7.0.5 and once with Eclipse Equinox 3.24.300. Both run on Java 8.
   
   On Java 8 without the fix, both frameworks fail `SecureXMLInputFactoryTest`, `SecureFactoriesSmokeTest` and `JaxbTest`.
   
   The thread context class loader stays the application class loader. With a bundle TCCL, some other JDK fallbacks also fail; this will be tracked in a separate issue.
   
   πŸ€– Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4223800339


##########
pom.xml:
##########
@@ -391,6 +413,107 @@ limitations under the License.
           </execution>
         </executions>
       </plugin>
+      <!--
+        Writes a fragment manifest into the test output directory,
+        so OsgiIT can install it as an exploded bundle attached to the library.
+        The imports are optional:
+        the test harness (JUnit, Mockito, JAXB) is boot-delegated to the class path by OsgiIT.
+      -->
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>test-bundle-manifest</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>manifest</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
+              <manifestLocation>${project.build.testOutputDirectory}/META-INF</manifestLocation>
+              <instructions>
+                <Bundle-SymbolicName>${commons.osgi.symbolicName}.tests</Bundle-SymbolicName>
+                <Fragment-Host>${commons.osgi.symbolicName}</Fragment-Host>
+                <Export-Package>!*</Export-Package>
+                <Private-Package>org.apache.commons.xml.*</Private-Package>
+                <Import-Package>*;resolution:=optional</Import-Package>
+                <!-- The java11 test sources would otherwise raise the osgi.ee requirement to that of the build JDK. -->
+                <_noee>true</_noee>
+                <!-- The host is the bundle under test, not a dependency. -->
+                <_fixupmessages>"Host *cannot be found on the classpath";is:=ignore</_fixupmessages>

Review Comment:
   https://github.com/apache/commons-secure-xml/pull/114/commits/1549689556417dde1ff17b61e345007ff5dab5e9 replaces the wildcard with the precise message to ignore.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20: Load the Java 8 default XMLInputFactory from the bootstrap loader [commons-secure-xml]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4222518658


##########
pom.xml:
##########
@@ -591,6 +714,9 @@ limitations under the License.
                   <goal>verify</goal>
                 </goals>
                 <configuration>
+                  <includes>
+                    <include>**/DescriptorIT.java</include>

Review Comment:
   In `src/test/java9`, since it requires Java 9.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4223720643


##########
src/main/java/org/apache/commons/xml/secure/SecureXMLInputFactory.java:
##########
@@ -285,7 +285,8 @@ public static XMLInputFactory newDefaultFactory() {
         }
         try {
             // Java 8: the method does not exist, and XMLInputFactory has no class-name-taking lookup; instantiate the JDK's built-in default directly.
-            return secure((XMLInputFactory) Class.forName(JDK_XML_INPUT_FACTORY).getConstructor().newInstance());
+            // Load it from the bootstrap loader: our own loader may not see com.sun.* (for example, an OSGi bundle class loader).
+            return secure((XMLInputFactory) Class.forName(JDK_XML_INPUT_FACTORY, true, null).getConstructor().newInstance());
         } catch (final ReflectiveOperationException e) {

Review Comment:
   I would rather allow `SecurityException` to propagate directly to the caller, instead of wrapping it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "Copilot (via GitHub) via issues" <is...@commons.apache.org>.
Copilot commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4506059692


##########
src/test/java/org/apache/commons/xml/osgi/OsgiIT.java:
##########
@@ -0,0 +1,246 @@
+/*
+ * 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
+ *
+ *      https://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.commons.xml.osgi;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestFactory;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.platform.engine.FilterResult;
+import org.junit.platform.engine.discovery.DiscoverySelectors;
+import org.junit.platform.engine.support.descriptor.MethodSource;
+import org.junit.platform.launcher.PostDiscoveryFilter;
+import org.junit.platform.launcher.TagFilter;
+import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
+import org.junit.platform.launcher.core.LauncherFactory;
+import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
+import org.junit.platform.launcher.listeners.TestExecutionSummary;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.osgi.framework.wiring.BundleWiring;
+
+/**
+ * Runs the unit test suite inside an OSGi framework, against the built bundle.
+ *
+ * <p>
+ * The tests catch class-loading assumptions that only hold on a flat classpath: an OSGi bundle class loader sees its own classes, the packages it imports and
+ * {@code java.*}, but not JDK-internal packages such as {@code com.sun.*}. The built jar is installed with its generated manifest, so the bundle also proves
+ * that its {@code Import-Package} header resolves.
+ * </p>
+ * <p>
+ * The test output directory, which the build gives a fragment manifest, is attached to that bundle, so the tests share its class loader and keep their
+ * package-private access. The test harness (JUnit, Mockito, JAXB) is not under test and is boot-delegated to the class path. Only the JDK's built-in JAXP
+ * implementations are used, as in the {@code test-stockjdk} execution: provider lookups cannot see other bundles without a mediator such as SPI Fly.
+ * </p>
+ * <p>
+ * The framework is whichever single {@link FrameworkFactory} the class path provides; the build runs this class once with Apache Felix and once with Eclipse
+ * Equinox.
+ * </p>
+ */
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class OsgiIT {
+
+    /**
+     * Factory methods that reach the JDK's built-in implementations without a provider lookup: {@code SecureSchemaFactory} also initializes the
+     * {@code LSResourceResolver} floor.
+     */
+    private static final String[][] DEFAULT_FACTORIES = {{"SecureDocumentBuilderFactory", "newDefaultInstance"},
+        {"SecureSAXParserFactory", "newDefaultInstance"}, {"SecureSchemaFactory", "newDefaultInstance"}, {"SecureTransformerFactory", "newDefaultInstance"},
+        {"SecureXPathFactory", "newDefaultInstance"}, {"SecureXMLInputFactory", "newDefaultFactory"}};
+
+    /**
+     * Package roots the framework delegates to the class path: the test harness only, never the library or JDK internals.
+     */
+    private static final String[] HARNESS_PACKAGES = {"org.junit", "org.opentest4j", "org.apiguardian", "org.mockito", "net.bytebuddy", "org.objenesis",
+        "javax.xml.bind", "com.sun.xml.bind", "org.glassfish.jaxb", "com.sun.istack", "javax.activation", "jakarta.activation"};
+
+    /**
+     * Symbolic name of the library bundle.
+     */
+    private static final String HOST_SYMBOLIC_NAME = "org.apache.commons.xml.secure";
+
+    /**
+     * Test classes that cannot run inside a framework: {@code ShadingFootprintTest} reads {@code target/classes} directly.
+     */
+    private static final List<String> NOT_IN_OSGI = Collections.singletonList("org.apache.commons.xml.secure.ShadingFootprintTest");
+
+    /**
+     * Test methods that cannot run inside a framework.
+     *
+     * <p>
+     * They name a test class as the JAXP factory, which JAXP loads through the context class loader: that is the class path, which holds a second copy of the
+     * test classes.
+     * </p>
+     */
+    private static final List<String> METHODS_NOT_IN_OSGI = Arrays.asList("SecureDocumentBuilderFactoryTest#newDocumentBuilderWrapsDeclaredExceptions",
+            "SecureSAXParserFactoryTest#newXmlReaderWrapsDeclaredExceptions");
+
+    private static Framework framework;
+
+    private static Bundle host;
+
+    private static Path requiredPath(final String property) {
+        final String value = System.getProperty(property);
+        assertNotNull(value, "System property '" + property + "' must be set by the build");
+        return Paths.get(value).toAbsolutePath();
+    }
+
+    @BeforeAll
+    static void startFramework() throws Exception {
+        final List<FrameworkFactory> factories = new ArrayList<>();
+        ServiceLoader.load(FrameworkFactory.class).forEach(factories::add);
+        assertEquals(1, factories.size(), () -> "Expected exactly one OSGi framework on the class path, found " + factories);
+        final Path buildJar = requiredPath("buildJar");
+        final Path work = requiredPath("osgiWorkDirectory");
+        Files.createDirectories(work);
+        final Map<String, String> config = new HashMap<>();
+        config.put(Constants.FRAMEWORK_STORAGE, work.resolve("storage").toString());
+        config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
+        config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
+        // A trailing ".*" only matches subpackages, so each root is listed twice.
+        // sun.reflect, jdk.internal.reflect: the JDK defines generated reflection accessors under the bundle loader.
+        // leaked: XSLTC rejects the host of Felix bundle:// URLs (for example "5.0"), so the XML fixtures resolve as file: URLs instead.
+        config.put(Constants.FRAMEWORK_BOOTDELEGATION, Stream.concat(Stream.of(HARNESS_PACKAGES).flatMap(p -> Stream.of(p, p + ".*")),
+                Stream.of("sun.reflect", "jdk.internal.reflect", "leaked")).collect(Collectors.joining(",")));
+        // Both frameworks can fall back to the parent loader on their own; disable it so only the explicit list above is delegated.
+        config.put("felix.bootdelegation.implicit", "false");
+        config.put("osgi.compatibility.bootdelegation", "false");
+        config.put("osgi.context.bootdelegation", "false");
+        framework = factories.get(0).newFramework(config);
+        framework.start();
+        final BundleContext context = framework.getBundleContext();
+        host = context.installBundle(buildJar.toUri().toString());
+        // The test output directory carries the fragment manifest written by maven-bundle-plugin; install it in place.
+        context.installBundle("reference:" + requiredPath("testClassesDirectory").toUri());
+        host.start();
+        assertEquals(Bundle.ACTIVE, host.getState(), "library bundle must start");
+    }
+
+    @AfterAll
+    static void stopFramework() throws Exception {
+        if (framework != null) {
+            framework.stop();
+            final FrameworkEvent event = framework.waitForStop(10_000);
+            assertEquals(FrameworkEvent.STOPPED, event.getType(),
+                    () -> "framework did not stop cleanly: event type " + event.getType() + ", " + event.getThrowable());
+        }
+    }
+
+    /**
+     * Runs one test class, loaded through the library bundle, and fails with the inner failures if any.
+     */
+    private static void runTestClass(final Class<?> testClass) {
+        final SummaryGeneratingListener listener = new SummaryGeneratingListener();
+        final PostDiscoveryFilter notInOsgi = descriptor -> descriptor.getSource()
+                .filter(MethodSource.class::isInstance)
+                .map(MethodSource.class::cast)
+                .filter(source -> METHODS_NOT_IN_OSGI.contains(source.getJavaClass().getSimpleName() + "#" + source.getMethodName()))
+                .map(source -> FilterResult.excluded("cannot run inside an OSGi framework"))
+                .orElseGet(() -> FilterResult.included(null));
+        // The context class loader stays the class path's, as in a plain framework launcher.
+        LauncherFactory.create().execute(LauncherDiscoveryRequestBuilder.request()
+                .selectors(DiscoverySelectors.selectClass(testClass))
+                // Same exclusion as the test-stockjdk execution: xpath3 needs Saxon.
+                .filters(TagFilter.excludeTags("xpath3"), notInOsgi)
+                .build(), listener);
+        final TestExecutionSummary summary = listener.getSummary();
+        if (summary.getTotalFailureCount() > 0) {
+            final StringWriter failures = new StringWriter();
+            summary.printFailuresTo(new PrintWriter(failures), 25);
+            throw new AssertionError(summary.getTotalFailureCount() + " failure(s) in " + testClass.getName() + " under " + framework.getSymbolicName()
+                    + System.lineSeparator() + failures);
+        }
+    }
+
+    /**
+     * Checks that the default factories do not depend on the context class loader, with the library bundle's class loader as one.
+     *
+     * <p>
+     * Runs first: a class initializer, such as that of the {@code LSResourceResolver} floor, runs once per framework.
+     * </p>
+     */
+    @Test
+    @Order(1)
+    void defaultFactoriesIgnoreContextClassLoader() throws Exception {
+        final Thread thread = Thread.currentThread();
+        final ClassLoader contextClassLoader = thread.getContextClassLoader();
+        thread.setContextClassLoader(host.adapt(BundleWiring.class).getClassLoader());
+        try {
+            assertAll(Stream.of(DEFAULT_FACTORIES).map(factory -> () -> {
+                try {
+                    assertNotNull(host.loadClass(HOST_SYMBOLIC_NAME + "." + factory[0]).getMethod(factory[1]).invoke(null), factory[0] + "." + factory[1]);

Review Comment:
   On Java 8, the old DOM, SAX and schema implementations can pass this non-null assertion by falling back to ordinary provider lookup, so this check does not detect regressions in their class-loader fixes. Add a case that selects non-default test providers through the three JAXP system properties and verifies that `newDefaultInstance()` still wraps the JDK implementation with the bundle class loader as TCCL. Restore the properties in `finally`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4223954467


##########
src/test/java/org/apache/commons/xml/osgi/OsgiIT.java:
##########
@@ -0,0 +1,204 @@
+/*
+ * 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
+ *
+ *      https://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.commons.xml.osgi;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+import org.junit.platform.engine.FilterResult;
+import org.junit.platform.engine.discovery.DiscoverySelectors;
+import org.junit.platform.engine.support.descriptor.MethodSource;
+import org.junit.platform.launcher.PostDiscoveryFilter;
+import org.junit.platform.launcher.TagFilter;
+import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
+import org.junit.platform.launcher.core.LauncherFactory;
+import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
+import org.junit.platform.launcher.listeners.TestExecutionSummary;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Runs the unit test suite inside an OSGi framework, against the built bundle.
+ *
+ * <p>
+ * The tests catch class-loading assumptions that only hold on a flat classpath: an OSGi bundle class loader sees its own classes, the packages it imports and
+ * {@code java.*}, but not JDK-internal packages such as {@code com.sun.*}. The built jar is installed with its generated manifest, so the bundle also proves
+ * that its {@code Import-Package} header resolves.
+ * </p>
+ * <p>
+ * The test output directory, which the build gives a fragment manifest, is attached to that bundle, so the tests share its class loader and keep their
+ * package-private access. The test harness (JUnit, Mockito, JAXB) is not under test and is boot-delegated to the class path. Only the JDK's built-in JAXP implementations are used, as in the
+ * {@code test-stockjdk} execution: provider lookups cannot see other bundles without a mediator such as SPI Fly.
+ * </p>
+ * <p>
+ * The framework is whichever single {@link FrameworkFactory} the class path provides; the build runs this class once with Apache Felix and once with Eclipse
+ * Equinox.
+ * </p>
+ */
+class OsgiIT {
+
+    /**
+     * Package roots the framework delegates to the class path: the test harness only, never the library or JDK internals.
+     */
+    private static final String[] HARNESS_PACKAGES = {"org.junit", "org.opentest4j", "org.apiguardian", "org.mockito", "net.bytebuddy", "org.objenesis",
+        "javax.xml.bind", "com.sun.xml.bind", "org.glassfish.jaxb", "com.sun.istack", "javax.activation", "jakarta.activation"};
+
+    /**
+     * Symbolic name of the library bundle.
+     */
+    private static final String HOST_SYMBOLIC_NAME = "org.apache.commons.xml.secure";
+
+    /**
+     * Test classes that cannot run inside a framework: {@code ShadingFootprintTest} reads {@code target/classes} directly.
+     */
+    private static final List<String> NOT_IN_OSGI = Collections.singletonList("org.apache.commons.xml.secure.ShadingFootprintTest");
+
+    /**
+     * Test methods that cannot run inside a framework.
+     *
+     * <p>
+     * They name a test class as the JAXP factory, which JAXP loads through the context class loader: that is the class path, which holds a second copy of the
+     * test classes.
+     * </p>
+     */
+    private static final List<String> METHODS_NOT_IN_OSGI = Arrays.asList("SecureDocumentBuilderFactoryTest#newDocumentBuilderWrapsDeclaredExceptions",
+            "SecureSAXParserFactoryTest#newXmlReaderWrapsDeclaredExceptions");
+
+    /**
+     * Location of the test classes inside the fragment.
+     */
+    private static final String TEST_PACKAGE = HOST_SYMBOLIC_NAME.replace('.', '/');
+
+    private static Framework framework;
+
+    private static Bundle host;
+
+    private static Path requiredPath(final String property) {
+        final String value = System.getProperty(property);
+        assertNotNull(value, "System property '" + property + "' must be set by the build");
+        return Paths.get(value).toAbsolutePath();
+    }
+
+    @BeforeAll
+    static void startFramework() throws Exception {
+        final List<FrameworkFactory> factories = new ArrayList<>();
+        ServiceLoader.load(FrameworkFactory.class).forEach(factories::add);
+        assertEquals(1, factories.size(), () -> "Expected exactly one OSGi framework on the class path, found " + factories);
+        final Path buildJar = requiredPath("buildJar");
+        final Path work = requiredPath("osgiWorkDirectory");
+        Files.createDirectories(work);
+        final Map<String, String> config = new HashMap<>();
+        config.put(Constants.FRAMEWORK_STORAGE, work.resolve("storage").toString());
+        config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
+        config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
+        // A trailing ".*" only matches subpackages, so each root is listed twice.
+        // sun.reflect, jdk.internal.reflect: the JDK defines generated reflection accessors under the bundle loader.
+        // leaked: XSLTC rejects the host of Felix bundle:// URLs (for example "5.0"), so the XML fixtures resolve as file: URLs instead.
+        config.put(Constants.FRAMEWORK_BOOTDELEGATION, Stream.concat(Stream.of(HARNESS_PACKAGES).flatMap(p -> Stream.of(p, p + ".*")),
+                Stream.of("sun.reflect", "jdk.internal.reflect", "leaked")).collect(Collectors.joining(",")));
+        // Both frameworks can fall back to the parent loader on their own; disable it so only the explicit list above is delegated.
+        config.put("felix.bootdelegation.implicit", "false");
+        config.put("osgi.compatibility.bootdelegation", "false");
+        config.put("osgi.context.bootdelegation", "false");
+        framework = factories.get(0).newFramework(config);
+        framework.start();
+        final BundleContext context = framework.getBundleContext();
+        host = context.installBundle(buildJar.toUri().toString());
+        // The test output directory carries the fragment manifest written by maven-bundle-plugin; install it in place.
+        context.installBundle("reference:" + requiredPath("testClassesDirectory").toUri());
+        host.start();
+        assertEquals(Bundle.ACTIVE, host.getState(), "library bundle must start");
+    }
+
+    @AfterAll
+    static void stopFramework() throws Exception {
+        if (framework != null) {
+            framework.stop();
+            framework.waitForStop(10_000);
+        }
+    }
+
+    /**
+     * Runs one test class, loaded through the library bundle, and fails with the inner failures if any.
+     */
+    private static void runTestClass(final Class<?> testClass) {
+        final SummaryGeneratingListener listener = new SummaryGeneratingListener();
+        final PostDiscoveryFilter notInOsgi = descriptor -> descriptor.getSource()
+                .filter(MethodSource.class::isInstance)
+                .map(MethodSource.class::cast)
+                .filter(source -> METHODS_NOT_IN_OSGI.contains(source.getJavaClass().getSimpleName() + "#" + source.getMethodName()))
+                .map(source -> FilterResult.excluded("cannot run inside an OSGi framework"))
+                .orElseGet(() -> FilterResult.included(null));
+        // The context class loader stays the class path's, as in a plain framework launcher.
+        LauncherFactory.create().execute(LauncherDiscoveryRequestBuilder.request()
+                .selectors(DiscoverySelectors.selectClass(testClass))
+                // Same exclusion as the test-stockjdk execution: xpath3 needs Saxon.
+                .filters(TagFilter.excludeTags("xpath3"), notInOsgi)
+                .build(), listener);
+        final TestExecutionSummary summary = listener.getSummary();
+        if (summary.getTotalFailureCount() > 0) {
+            final StringWriter failures = new StringWriter();
+            summary.printFailuresTo(new PrintWriter(failures), 25);
+            throw new AssertionError(summary.getTotalFailureCount() + " failure(s) in " + testClass.getName() + " under " + framework.getSymbolicName()
+                    + System.lineSeparator() + failures);
+        }
+    }
+
+    @TestFactory
+    Stream<DynamicTest> unitTestsPassInsideFramework() throws ClassNotFoundException {
+        final List<DynamicTest> tests = new ArrayList<>();
+        final Enumeration<URL> entries = host.findEntries(TEST_PACKAGE, "*Test.class", false);
+        assertNotNull(entries, "test fragment must be attached to the library bundle");
+        while (entries.hasMoreElements()) {
+            final String path = entries.nextElement().getPath();
+            final String className = path.substring(path.indexOf(TEST_PACKAGE), path.length() - ".class".length()).replace('/', '.');
+            if (!NOT_IN_OSGI.contains(className)) {

Review Comment:
   Fixed in https://github.com/apache/commons-secure-xml/pull/114/commits/cf7e75995ac43595207aa617c3af9d00ee952129



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#issuecomment-6069962124

   Thanks, let's see what @kwin has to say about the OSGi test before merging.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4223759847


##########
pom.xml:
##########
@@ -391,6 +413,107 @@ limitations under the License.
           </execution>
         </executions>
       </plugin>
+      <!--
+        Writes a fragment manifest into the test output directory,
+        so OsgiIT can install it as an exploded bundle attached to the library.
+        The imports are optional:
+        the test harness (JUnit, Mockito, JAXB) is boot-delegated to the class path by OsgiIT.
+      -->
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>test-bundle-manifest</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>manifest</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
+              <manifestLocation>${project.build.testOutputDirectory}/META-INF</manifestLocation>
+              <instructions>
+                <Bundle-SymbolicName>${commons.osgi.symbolicName}.tests</Bundle-SymbolicName>
+                <Fragment-Host>${commons.osgi.symbolicName}</Fragment-Host>
+                <Export-Package>!*</Export-Package>
+                <Private-Package>org.apache.commons.xml.*</Private-Package>
+                <Import-Package>*;resolution:=optional</Import-Package>
+                <!-- The java11 test sources would otherwise raise the osgi.ee requirement to that of the build JDK. -->
+                <_noee>true</_noee>
+                <!-- The host is the bundle under test, not a dependency. -->
+                <_fixupmessages>"Host *cannot be found on the classpath";is:=ignore</_fixupmessages>

Review Comment:
   The `*` is a wildcard: bnd matches `-fixupmessages` patterns as globs. Without the instruction, the build prints:
   
   ```
   [WARNING] Manifest org.apache.commons:commons-secure-xml:jar:1.1.1-SNAPSHOT : Host org.apache.commons.xml.secure= for this fragment/require bundle cannot be found on the classpath
   ```
   
   so the `*` stands for `org.apache.commons.xml.secure= for this fragment/require bundle `.
   
   Why it appears: a fragment shares its host's class loader, so bnd looks the host bundle up on the build class path and removes the host's packages from the fragment's `Import-Package` ([`Analyzer.getHostPackages()`](https://github.com/bndtools/bnd/blob/6.3.1/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java#L483-L543)). Here the host is this module's own jar: it is not a dependency, and it is not built yet in `process-test-classes`, so the lookup fails.
   
   The warning is harmless: the test classes are in the host's packages and are included through `Private-Package`, so the generated fragment manifest imports no `org.apache.commons.xml.*` package anyway.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4223986639


##########
src/test/java/org/apache/commons/xml/osgi/OsgiIT.java:
##########
@@ -0,0 +1,246 @@
+/*
+ * 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
+ *
+ *      https://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.commons.xml.osgi;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestFactory;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.platform.engine.FilterResult;
+import org.junit.platform.engine.discovery.DiscoverySelectors;
+import org.junit.platform.engine.support.descriptor.MethodSource;
+import org.junit.platform.launcher.PostDiscoveryFilter;
+import org.junit.platform.launcher.TagFilter;
+import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
+import org.junit.platform.launcher.core.LauncherFactory;
+import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
+import org.junit.platform.launcher.listeners.TestExecutionSummary;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.osgi.framework.wiring.BundleWiring;
+
+/**
+ * Runs the unit test suite inside an OSGi framework, against the built bundle.
+ *
+ * <p>
+ * The tests catch class-loading assumptions that only hold on a flat classpath: an OSGi bundle class loader sees its own classes, the packages it imports and
+ * {@code java.*}, but not JDK-internal packages such as {@code com.sun.*}. The built jar is installed with its generated manifest, so the bundle also proves
+ * that its {@code Import-Package} header resolves.
+ * </p>
+ * <p>
+ * The test output directory, which the build gives a fragment manifest, is attached to that bundle, so the tests share its class loader and keep their
+ * package-private access. The test harness (JUnit, Mockito, JAXB) is not under test and is boot-delegated to the class path. Only the JDK's built-in JAXP
+ * implementations are used, as in the {@code test-stockjdk} execution: provider lookups cannot see other bundles without a mediator such as SPI Fly.
+ * </p>
+ * <p>
+ * The framework is whichever single {@link FrameworkFactory} the class path provides; the build runs this class once with Apache Felix and once with Eclipse
+ * Equinox.
+ * </p>
+ */
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class OsgiIT {
+
+    /**
+     * Factory methods that reach the JDK's built-in implementations without a provider lookup: {@code SecureSchemaFactory} also initializes the
+     * {@code LSResourceResolver} floor.
+     */
+    private static final String[][] DEFAULT_FACTORIES = {{"SecureDocumentBuilderFactory", "newDefaultInstance"},
+        {"SecureSAXParserFactory", "newDefaultInstance"}, {"SecureSchemaFactory", "newDefaultInstance"}, {"SecureTransformerFactory", "newDefaultInstance"},
+        {"SecureXPathFactory", "newDefaultInstance"}, {"SecureXMLInputFactory", "newDefaultFactory"}};
+
+    /**
+     * Package roots the framework delegates to the class path: the test harness only, never the library or JDK internals.
+     */
+    private static final String[] HARNESS_PACKAGES = {"org.junit", "org.opentest4j", "org.apiguardian", "org.mockito", "net.bytebuddy", "org.objenesis",
+        "javax.xml.bind", "com.sun.xml.bind", "org.glassfish.jaxb", "com.sun.istack", "javax.activation", "jakarta.activation"};
+
+    /**
+     * Symbolic name of the library bundle.
+     */
+    private static final String HOST_SYMBOLIC_NAME = "org.apache.commons.xml.secure";
+
+    /**
+     * Test classes that cannot run inside a framework: {@code ShadingFootprintTest} reads {@code target/classes} directly.
+     */
+    private static final List<String> NOT_IN_OSGI = Collections.singletonList("org.apache.commons.xml.secure.ShadingFootprintTest");
+
+    /**
+     * Test methods that cannot run inside a framework.
+     *
+     * <p>
+     * They name a test class as the JAXP factory, which JAXP loads through the context class loader: that is the class path, which holds a second copy of the
+     * test classes.
+     * </p>
+     */
+    private static final List<String> METHODS_NOT_IN_OSGI = Arrays.asList("SecureDocumentBuilderFactoryTest#newDocumentBuilderWrapsDeclaredExceptions",
+            "SecureSAXParserFactoryTest#newXmlReaderWrapsDeclaredExceptions");
+
+    private static Framework framework;
+
+    private static Bundle host;
+
+    private static Path requiredPath(final String property) {
+        final String value = System.getProperty(property);
+        assertNotNull(value, "System property '" + property + "' must be set by the build");
+        return Paths.get(value).toAbsolutePath();
+    }
+
+    @BeforeAll
+    static void startFramework() throws Exception {
+        final List<FrameworkFactory> factories = new ArrayList<>();
+        ServiceLoader.load(FrameworkFactory.class).forEach(factories::add);
+        assertEquals(1, factories.size(), () -> "Expected exactly one OSGi framework on the class path, found " + factories);
+        final Path buildJar = requiredPath("buildJar");
+        final Path work = requiredPath("osgiWorkDirectory");
+        Files.createDirectories(work);
+        final Map<String, String> config = new HashMap<>();
+        config.put(Constants.FRAMEWORK_STORAGE, work.resolve("storage").toString());
+        config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
+        config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
+        // A trailing ".*" only matches subpackages, so each root is listed twice.
+        // sun.reflect, jdk.internal.reflect: the JDK defines generated reflection accessors under the bundle loader.
+        // leaked: XSLTC rejects the host of Felix bundle:// URLs (for example "5.0"), so the XML fixtures resolve as file: URLs instead.
+        config.put(Constants.FRAMEWORK_BOOTDELEGATION, Stream.concat(Stream.of(HARNESS_PACKAGES).flatMap(p -> Stream.of(p, p + ".*")),
+                Stream.of("sun.reflect", "jdk.internal.reflect", "leaked")).collect(Collectors.joining(",")));
+        // Both frameworks can fall back to the parent loader on their own; disable it so only the explicit list above is delegated.
+        config.put("felix.bootdelegation.implicit", "false");
+        config.put("osgi.compatibility.bootdelegation", "false");
+        config.put("osgi.context.bootdelegation", "false");
+        framework = factories.get(0).newFramework(config);
+        framework.start();

Review Comment:
   @kwin,
   
   Claude generated this configuration to start the OSGi framework. Does it make sense?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4237605769


##########
pom.xml:
##########
@@ -391,6 +413,110 @@ limitations under the License.
           </execution>
         </executions>
       </plugin>
+      <!--
+        Writes a fragment manifest into the test output directory,
+        so OsgiIT can install it as an exploded bundle attached to the library.
+        The imports are optional:
+        the test harness (JUnit, Mockito, JAXB) is boot-delegated to the class path by OsgiIT.
+      -->
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>test-bundle-manifest</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>manifest</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
+              <manifestLocation>${project.build.testOutputDirectory}/META-INF</manifestLocation>
+              <instructions>
+                <Bundle-SymbolicName>${commons.osgi.symbolicName}.tests</Bundle-SymbolicName>
+                <Fragment-Host>${commons.osgi.symbolicName}</Fragment-Host>
+                <Export-Package>!*</Export-Package>
+                <Private-Package>org.apache.commons.xml.*</Private-Package>
+                <Import-Package>*;resolution:=optional</Import-Package>
+                <!-- The java11 test sources would otherwise raise the osgi.ee requirement to that of the build JDK. -->
+                <_noee>true</_noee>
+                <!--
+                  bnd looks the host up on the class path to drop its packages from Import-Package, but the host is this module's own jar, not built yet.
+                  Harmless: the tests are in the host's packages, so the fragment imports none of them anyway.
+                -->
+                <_fixupmessages>"Host ${commons.osgi.symbolicName}= for this fragment/require bundle cannot be found on the classpath";is:=ignore</_fixupmessages>
+              </instructions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!--
+        OsgiIT runs the unit tests inside an OSGi framework against the packaged bundle, once per framework.
+        Each framework jar embeds its own copy of the OSGi API,
+        so each execution keeps exactly one of them on the class path.
+        Saxon is dropped as in test-stockjdk,
+        so provider lookups reach the JDK's built-in implementations, as they do for a bundle.
+      -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <!-- The same permissive JDK defaults as the surefire executions. -->
+        <configuration>
+          <systemPropertyVariables>
+            <javax.xml.accessExternalDTD>all</javax.xml.accessExternalDTD>
+            <javax.xml.accessExternalSchema>all</javax.xml.accessExternalSchema>
+            <javax.xml.accessExternalStylesheet>all</javax.xml.accessExternalStylesheet>
+          </systemPropertyVariables>
+        </configuration>
+        <executions>
+          <execution>
+            <id>test-osgi-felix</id>
+            <goals>
+              <goal>integration-test</goal>
+              <goal>verify</goal>
+            </goals>
+            <configuration>
+              <includes>
+                <include>**/OsgiIT.java</include>
+              </includes>
+              <reportsDirectory>${project.build.directory}/failsafe-reports/felix</reportsDirectory>
+              <summaryFile>${project.build.directory}/failsafe-reports/felix/failsafe-summary.xml</summaryFile>
+              <classpathDependencyExcludes>

Review Comment:
   I'm not sure what that level kind of delegation looks like. Since the PR is already complex, maybe this can be proposed in a follow up PR. @ppkarwasz , WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4237549131


##########
pom.xml:
##########
@@ -391,6 +413,110 @@ limitations under the License.
           </execution>
         </executions>
       </plugin>
+      <!--
+        Writes a fragment manifest into the test output directory,
+        so OsgiIT can install it as an exploded bundle attached to the library.
+        The imports are optional:
+        the test harness (JUnit, Mockito, JAXB) is boot-delegated to the class path by OsgiIT.
+      -->
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>test-bundle-manifest</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>manifest</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
+              <manifestLocation>${project.build.testOutputDirectory}/META-INF</manifestLocation>
+              <instructions>
+                <Bundle-SymbolicName>${commons.osgi.symbolicName}.tests</Bundle-SymbolicName>
+                <Fragment-Host>${commons.osgi.symbolicName}</Fragment-Host>
+                <Export-Package>!*</Export-Package>
+                <Private-Package>org.apache.commons.xml.*</Private-Package>
+                <Import-Package>*;resolution:=optional</Import-Package>
+                <!-- The java11 test sources would otherwise raise the osgi.ee requirement to that of the build JDK. -->
+                <_noee>true</_noee>
+                <!--
+                  bnd looks the host up on the class path to drop its packages from Import-Package, but the host is this module's own jar, not built yet.
+                  Harmless: the tests are in the host's packages, so the fragment imports none of them anyway.
+                -->
+                <_fixupmessages>"Host ${commons.osgi.symbolicName}= for this fragment/require bundle cannot be found on the classpath";is:=ignore</_fixupmessages>
+              </instructions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!--
+        OsgiIT runs the unit tests inside an OSGi framework against the packaged bundle, once per framework.
+        Each framework jar embeds its own copy of the OSGi API,
+        so each execution keeps exactly one of them on the class path.
+        Saxon is dropped as in test-stockjdk,
+        so provider lookups reach the JDK's built-in implementations, as they do for a bundle.
+      -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <!-- The same permissive JDK defaults as the surefire executions. -->
+        <configuration>
+          <systemPropertyVariables>
+            <javax.xml.accessExternalDTD>all</javax.xml.accessExternalDTD>
+            <javax.xml.accessExternalSchema>all</javax.xml.accessExternalSchema>
+            <javax.xml.accessExternalStylesheet>all</javax.xml.accessExternalStylesheet>
+          </systemPropertyVariables>
+        </configuration>
+        <executions>
+          <execution>
+            <id>test-osgi-felix</id>
+            <goals>
+              <goal>integration-test</goal>
+              <goal>verify</goal>
+            </goals>
+            <configuration>
+              <includes>
+                <include>**/OsgiIT.java</include>
+              </includes>
+              <reportsDirectory>${project.build.directory}/failsafe-reports/felix</reportsDirectory>
+              <summaryFile>${project.build.directory}/failsafe-reports/felix/failsafe-summary.xml</summaryFile>
+              <classpathDependencyExcludes>

Review Comment:
   I know this pattern is used elsewhere as well, however instead of tweaking classpath (which is hard to reproduce e.g. in Eclipse) I would appreciate to just parameterize via classname passed via system property (here the FrameworkFactory impl). 



##########
src/test/java/org/apache/commons/xml/osgi/OsgiIT.java:
##########
@@ -0,0 +1,246 @@
+/*
+ * 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
+ *
+ *      https://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.commons.xml.osgi;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestFactory;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.platform.engine.FilterResult;
+import org.junit.platform.engine.discovery.DiscoverySelectors;
+import org.junit.platform.engine.support.descriptor.MethodSource;
+import org.junit.platform.launcher.PostDiscoveryFilter;
+import org.junit.platform.launcher.TagFilter;
+import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
+import org.junit.platform.launcher.core.LauncherFactory;
+import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
+import org.junit.platform.launcher.listeners.TestExecutionSummary;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.osgi.framework.wiring.BundleWiring;
+
+/**
+ * Runs the unit test suite inside an OSGi framework, against the built bundle.
+ *
+ * <p>
+ * The tests catch class-loading assumptions that only hold on a flat classpath: an OSGi bundle class loader sees its own classes, the packages it imports and
+ * {@code java.*}, but not JDK-internal packages such as {@code com.sun.*}. The built jar is installed with its generated manifest, so the bundle also proves
+ * that its {@code Import-Package} header resolves.
+ * </p>
+ * <p>
+ * The test output directory, which the build gives a fragment manifest, is attached to that bundle, so the tests share its class loader and keep their
+ * package-private access. The test harness (JUnit, Mockito, JAXB) is not under test and is boot-delegated to the class path. Only the JDK's built-in JAXP
+ * implementations are used, as in the {@code test-stockjdk} execution: provider lookups cannot see other bundles without a mediator such as SPI Fly.
+ * </p>
+ * <p>
+ * The framework is whichever single {@link FrameworkFactory} the class path provides; the build runs this class once with Apache Felix and once with Eclipse
+ * Equinox.
+ * </p>
+ */
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class OsgiIT {
+
+    /**
+     * Factory methods that reach the JDK's built-in implementations without a provider lookup: {@code SecureSchemaFactory} also initializes the
+     * {@code LSResourceResolver} floor.
+     */
+    private static final String[][] DEFAULT_FACTORIES = {{"SecureDocumentBuilderFactory", "newDefaultInstance"},
+        {"SecureSAXParserFactory", "newDefaultInstance"}, {"SecureSchemaFactory", "newDefaultInstance"}, {"SecureTransformerFactory", "newDefaultInstance"},
+        {"SecureXPathFactory", "newDefaultInstance"}, {"SecureXMLInputFactory", "newDefaultFactory"}};
+
+    /**
+     * Package roots the framework delegates to the class path: the test harness only, never the library or JDK internals.
+     */
+    private static final String[] HARNESS_PACKAGES = {"org.junit", "org.opentest4j", "org.apiguardian", "org.mockito", "net.bytebuddy", "org.objenesis",
+        "javax.xml.bind", "com.sun.xml.bind", "org.glassfish.jaxb", "com.sun.istack", "javax.activation", "jakarta.activation"};
+
+    /**
+     * Symbolic name of the library bundle.
+     */
+    private static final String HOST_SYMBOLIC_NAME = "org.apache.commons.xml.secure";
+
+    /**
+     * Test classes that cannot run inside a framework: {@code ShadingFootprintTest} reads {@code target/classes} directly.
+     */
+    private static final List<String> NOT_IN_OSGI = Collections.singletonList("org.apache.commons.xml.secure.ShadingFootprintTest");
+
+    /**
+     * Test methods that cannot run inside a framework.
+     *
+     * <p>
+     * They name a test class as the JAXP factory, which JAXP loads through the context class loader: that is the class path, which holds a second copy of the
+     * test classes.
+     * </p>
+     */
+    private static final List<String> METHODS_NOT_IN_OSGI = Arrays.asList("SecureDocumentBuilderFactoryTest#newDocumentBuilderWrapsDeclaredExceptions",
+            "SecureSAXParserFactoryTest#newXmlReaderWrapsDeclaredExceptions");
+
+    private static Framework framework;
+
+    private static Bundle host;
+
+    private static Path requiredPath(final String property) {
+        final String value = System.getProperty(property);
+        assertNotNull(value, "System property '" + property + "' must be set by the build");
+        return Paths.get(value).toAbsolutePath();
+    }
+
+    @BeforeAll
+    static void startFramework() throws Exception {
+        final List<FrameworkFactory> factories = new ArrayList<>();
+        ServiceLoader.load(FrameworkFactory.class).forEach(factories::add);
+        assertEquals(1, factories.size(), () -> "Expected exactly one OSGi framework on the class path, found " + factories);
+        final Path buildJar = requiredPath("buildJar");
+        final Path work = requiredPath("osgiWorkDirectory");
+        Files.createDirectories(work);
+        final Map<String, String> config = new HashMap<>();
+        config.put(Constants.FRAMEWORK_STORAGE, work.resolve("storage").toString());
+        config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
+        config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
+        // A trailing ".*" only matches subpackages, so each root is listed twice.
+        // sun.reflect, jdk.internal.reflect: the JDK defines generated reflection accessors under the bundle loader.
+        // leaked: XSLTC rejects the host of Felix bundle:// URLs (for example "5.0"), so the XML fixtures resolve as file: URLs instead.
+        config.put(Constants.FRAMEWORK_BOOTDELEGATION, Stream.concat(Stream.of(HARNESS_PACKAGES).flatMap(p -> Stream.of(p, p + ".*")),
+                Stream.of("sun.reflect", "jdk.internal.reflect", "leaked")).collect(Collectors.joining(",")));
+        // Both frameworks can fall back to the parent loader on their own; disable it so only the explicit list above is delegated.
+        config.put("felix.bootdelegation.implicit", "false");
+        config.put("osgi.compatibility.bootdelegation", "false");
+        config.put("osgi.context.bootdelegation", "false");
+        framework = factories.get(0).newFramework(config);
+        framework.start();

Review Comment:
   Looks ok to me.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20: Load the Java 8 default XMLInputFactory from the bootstrap loader [commons-secure-xml]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#issuecomment-6065781082

   Hi @ppkarwasz 
   It looks like this needs a tweak for Andoid builds.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#issuecomment-6097246917

   @kwin Please the [comment](https://github.com/apache/commons-secure-xml/pull/114#issuecomment-6069962124) above from @ppkarwasz from a couple of days ago.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "garydgregory (via GitHub) via issues" <is...@commons.apache.org>.
garydgregory merged PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20: Load the Java 8 default XMLInputFactory from the bootstrap loader [commons-secure-xml]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4222543064


##########
pom.xml:
##########
@@ -591,6 +714,9 @@ limitations under the License.
                   <goal>verify</goal>
                 </goals>
                 <configuration>
+                  <includes>
+                    <include>**/DescriptorIT.java</include>

Review Comment:
   In Java 11 ;)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4223949816


##########
src/test/java/org/apache/commons/xml/osgi/OsgiIT.java:
##########
@@ -0,0 +1,204 @@
+/*
+ * 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
+ *
+ *      https://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.commons.xml.osgi;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+import org.junit.platform.engine.FilterResult;
+import org.junit.platform.engine.discovery.DiscoverySelectors;
+import org.junit.platform.engine.support.descriptor.MethodSource;
+import org.junit.platform.launcher.PostDiscoveryFilter;
+import org.junit.platform.launcher.TagFilter;
+import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
+import org.junit.platform.launcher.core.LauncherFactory;
+import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
+import org.junit.platform.launcher.listeners.TestExecutionSummary;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Runs the unit test suite inside an OSGi framework, against the built bundle.
+ *
+ * <p>
+ * The tests catch class-loading assumptions that only hold on a flat classpath: an OSGi bundle class loader sees its own classes, the packages it imports and
+ * {@code java.*}, but not JDK-internal packages such as {@code com.sun.*}. The built jar is installed with its generated manifest, so the bundle also proves
+ * that its {@code Import-Package} header resolves.
+ * </p>
+ * <p>
+ * The test output directory, which the build gives a fragment manifest, is attached to that bundle, so the tests share its class loader and keep their
+ * package-private access. The test harness (JUnit, Mockito, JAXB) is not under test and is boot-delegated to the class path. Only the JDK's built-in JAXP implementations are used, as in the
+ * {@code test-stockjdk} execution: provider lookups cannot see other bundles without a mediator such as SPI Fly.
+ * </p>
+ * <p>
+ * The framework is whichever single {@link FrameworkFactory} the class path provides; the build runs this class once with Apache Felix and once with Eclipse
+ * Equinox.
+ * </p>
+ */
+class OsgiIT {
+
+    /**
+     * Package roots the framework delegates to the class path: the test harness only, never the library or JDK internals.
+     */
+    private static final String[] HARNESS_PACKAGES = {"org.junit", "org.opentest4j", "org.apiguardian", "org.mockito", "net.bytebuddy", "org.objenesis",
+        "javax.xml.bind", "com.sun.xml.bind", "org.glassfish.jaxb", "com.sun.istack", "javax.activation", "jakarta.activation"};
+
+    /**
+     * Symbolic name of the library bundle.
+     */
+    private static final String HOST_SYMBOLIC_NAME = "org.apache.commons.xml.secure";
+
+    /**
+     * Test classes that cannot run inside a framework: {@code ShadingFootprintTest} reads {@code target/classes} directly.
+     */
+    private static final List<String> NOT_IN_OSGI = Collections.singletonList("org.apache.commons.xml.secure.ShadingFootprintTest");
+
+    /**
+     * Test methods that cannot run inside a framework.
+     *
+     * <p>
+     * They name a test class as the JAXP factory, which JAXP loads through the context class loader: that is the class path, which holds a second copy of the
+     * test classes.
+     * </p>
+     */
+    private static final List<String> METHODS_NOT_IN_OSGI = Arrays.asList("SecureDocumentBuilderFactoryTest#newDocumentBuilderWrapsDeclaredExceptions",
+            "SecureSAXParserFactoryTest#newXmlReaderWrapsDeclaredExceptions");
+
+    /**
+     * Location of the test classes inside the fragment.
+     */
+    private static final String TEST_PACKAGE = HOST_SYMBOLIC_NAME.replace('.', '/');
+
+    private static Framework framework;
+
+    private static Bundle host;
+
+    private static Path requiredPath(final String property) {
+        final String value = System.getProperty(property);
+        assertNotNull(value, "System property '" + property + "' must be set by the build");
+        return Paths.get(value).toAbsolutePath();
+    }
+
+    @BeforeAll
+    static void startFramework() throws Exception {
+        final List<FrameworkFactory> factories = new ArrayList<>();
+        ServiceLoader.load(FrameworkFactory.class).forEach(factories::add);
+        assertEquals(1, factories.size(), () -> "Expected exactly one OSGi framework on the class path, found " + factories);
+        final Path buildJar = requiredPath("buildJar");
+        final Path work = requiredPath("osgiWorkDirectory");
+        Files.createDirectories(work);
+        final Map<String, String> config = new HashMap<>();
+        config.put(Constants.FRAMEWORK_STORAGE, work.resolve("storage").toString());
+        config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
+        config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
+        // A trailing ".*" only matches subpackages, so each root is listed twice.
+        // sun.reflect, jdk.internal.reflect: the JDK defines generated reflection accessors under the bundle loader.
+        // leaked: XSLTC rejects the host of Felix bundle:// URLs (for example "5.0"), so the XML fixtures resolve as file: URLs instead.
+        config.put(Constants.FRAMEWORK_BOOTDELEGATION, Stream.concat(Stream.of(HARNESS_PACKAGES).flatMap(p -> Stream.of(p, p + ".*")),
+                Stream.of("sun.reflect", "jdk.internal.reflect", "leaked")).collect(Collectors.joining(",")));
+        // Both frameworks can fall back to the parent loader on their own; disable it so only the explicit list above is delegated.
+        config.put("felix.bootdelegation.implicit", "false");
+        config.put("osgi.compatibility.bootdelegation", "false");
+        config.put("osgi.context.bootdelegation", "false");
+        framework = factories.get(0).newFramework(config);
+        framework.start();
+        final BundleContext context = framework.getBundleContext();
+        host = context.installBundle(buildJar.toUri().toString());
+        // The test output directory carries the fragment manifest written by maven-bundle-plugin; install it in place.
+        context.installBundle("reference:" + requiredPath("testClassesDirectory").toUri());
+        host.start();
+        assertEquals(Bundle.ACTIVE, host.getState(), "library bundle must start");
+    }
+
+    @AfterAll
+    static void stopFramework() throws Exception {
+        if (framework != null) {
+            framework.stop();
+            framework.waitForStop(10_000);
+        }
+    }

Review Comment:
   Fixed in https://github.com/apache/commons-secure-xml/pull/114/commits/69ea10c4ce4fdca0ba7ab09be0a67d0a1ef02ad1



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4237602253


##########
pom.xml:
##########
@@ -53,7 +53,8 @@ limitations under the License.
     <!-- OSGi bundle metadata: override commons-parent's org.apache.commons.* defaults. -->
     <commons.osgi.symbolicName>org.apache.commons.xml.secure</commons.osgi.symbolicName>
     <commons.osgi.export>org.apache.commons.xml.secure.*;version=${project.version};-noimport:=true</commons.osgi.export>
-    <!-- The negation drops the JDK-internal package bnd infers from the reflective Java 8 fallback in SecureXMLInputFactory.newDefaultFactory(). -->
+    <!-- The negation drops the JDK-internal package bnd infers from the Java 8 fallback in SecureXMLInputFactory.newDefaultFactory(),
+         which loads it from the bootstrap loader. -->
     <commons.osgi.import>
       !com.sun.xml.internal.stream,

Review Comment:
   Is Bnd really still generating an import if this is not set? Most probably this line can be removed due to the system classloader being used.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20: Load the Java 8 default XMLInputFactory from the bootstrap loader [commons-secure-xml]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4223198035


##########
pom.xml:
##########
@@ -391,6 +413,107 @@ limitations under the License.
           </execution>
         </executions>
       </plugin>
+      <!--
+        Writes a fragment manifest into the test output directory,
+        so OsgiIT can install it as an exploded bundle attached to the library.
+        The imports are optional:
+        the test harness (JUnit, Mockito, JAXB) is boot-delegated to the class path by OsgiIT.
+      -->
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>test-bundle-manifest</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>manifest</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
+              <manifestLocation>${project.build.testOutputDirectory}/META-INF</manifestLocation>
+              <instructions>
+                <Bundle-SymbolicName>${commons.osgi.symbolicName}.tests</Bundle-SymbolicName>
+                <Fragment-Host>${commons.osgi.symbolicName}</Fragment-Host>
+                <Export-Package>!*</Export-Package>
+                <Private-Package>org.apache.commons.xml.*</Private-Package>
+                <Import-Package>*;resolution:=optional</Import-Package>
+                <!-- The java11 test sources would otherwise raise the osgi.ee requirement to that of the build JDK. -->
+                <_noee>true</_noee>
+                <!-- The host is the bundle under test, not a dependency. -->
+                <_fixupmessages>"Host *cannot be found on the classpath";is:=ignore</_fixupmessages>

Review Comment:
   @ppkarwasz don't forget this bit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20: Load the Java 8 default XMLInputFactory from the bootstrap loader [commons-secure-xml]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4222450975


##########
pom.xml:
##########
@@ -391,6 +413,107 @@ limitations under the License.
           </execution>
         </executions>
       </plugin>
+      <!--
+        Writes a fragment manifest into the test output directory,
+        so OsgiIT can install it as an exploded bundle attached to the library.
+        The imports are optional:
+        the test harness (JUnit, Mockito, JAXB) is boot-delegated to the class path by OsgiIT.
+      -->
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>test-bundle-manifest</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>manifest</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
+              <manifestLocation>${project.build.testOutputDirectory}/META-INF</manifestLocation>
+              <instructions>
+                <Bundle-SymbolicName>${commons.osgi.symbolicName}.tests</Bundle-SymbolicName>
+                <Fragment-Host>${commons.osgi.symbolicName}</Fragment-Host>
+                <Export-Package>!*</Export-Package>
+                <Private-Package>org.apache.commons.xml.*</Private-Package>
+                <Import-Package>*;resolution:=optional</Import-Package>
+                <!-- The java11 test sources would otherwise raise the osgi.ee requirement to that of the build JDK. -->
+                <_noee>true</_noee>
+                <!-- The host is the bundle under test, not a dependency. -->
+                <_fixupmessages>"Host *cannot be found on the classpath";is:=ignore</_fixupmessages>

Review Comment:
   What is the "*" in "*cannot"?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20: Load the Java 8 default XMLInputFactory from the bootstrap loader [commons-secure-xml]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4222459541


##########
pom.xml:
##########
@@ -591,6 +714,9 @@ limitations under the License.
                   <goal>verify</goal>
                 </goals>
                 <configuration>
+                  <includes>
+                    <include>**/DescriptorIT.java</include>

Review Comment:
   Where is "DescriptorIT"?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20: Load the Java 8 default XMLInputFactory from the bootstrap loader [commons-secure-xml]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#discussion_r4222492028


##########
src/test/java/org/apache/commons/xml/osgi/OsgiIT.java:
##########
@@ -0,0 +1,204 @@
+/*
+ * 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
+ *
+ *      https://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.commons.xml.osgi;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+import org.junit.platform.engine.FilterResult;
+import org.junit.platform.engine.discovery.DiscoverySelectors;
+import org.junit.platform.engine.support.descriptor.MethodSource;
+import org.junit.platform.launcher.PostDiscoveryFilter;
+import org.junit.platform.launcher.TagFilter;
+import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
+import org.junit.platform.launcher.core.LauncherFactory;
+import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
+import org.junit.platform.launcher.listeners.TestExecutionSummary;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Runs the unit test suite inside an OSGi framework, against the built bundle.
+ *
+ * <p>
+ * The tests catch class-loading assumptions that only hold on a flat classpath: an OSGi bundle class loader sees its own classes, the packages it imports and
+ * {@code java.*}, but not JDK-internal packages such as {@code com.sun.*}. The built jar is installed with its generated manifest, so the bundle also proves
+ * that its {@code Import-Package} header resolves.
+ * </p>
+ * <p>
+ * The test output directory, which the build gives a fragment manifest, is attached to that bundle, so the tests share its class loader and keep their
+ * package-private access. The test harness (JUnit, Mockito, JAXB) is not under test and is boot-delegated to the class path. Only the JDK's built-in JAXP implementations are used, as in the
+ * {@code test-stockjdk} execution: provider lookups cannot see other bundles without a mediator such as SPI Fly.
+ * </p>
+ * <p>
+ * The framework is whichever single {@link FrameworkFactory} the class path provides; the build runs this class once with Apache Felix and once with Eclipse
+ * Equinox.
+ * </p>
+ */
+class OsgiIT {
+
+    /**
+     * Package roots the framework delegates to the class path: the test harness only, never the library or JDK internals.
+     */
+    private static final String[] HARNESS_PACKAGES = {"org.junit", "org.opentest4j", "org.apiguardian", "org.mockito", "net.bytebuddy", "org.objenesis",
+        "javax.xml.bind", "com.sun.xml.bind", "org.glassfish.jaxb", "com.sun.istack", "javax.activation", "jakarta.activation"};
+
+    /**
+     * Symbolic name of the library bundle.
+     */
+    private static final String HOST_SYMBOLIC_NAME = "org.apache.commons.xml.secure";
+
+    /**
+     * Test classes that cannot run inside a framework: {@code ShadingFootprintTest} reads {@code target/classes} directly.
+     */
+    private static final List<String> NOT_IN_OSGI = Collections.singletonList("org.apache.commons.xml.secure.ShadingFootprintTest");
+
+    /**
+     * Test methods that cannot run inside a framework.
+     *
+     * <p>
+     * They name a test class as the JAXP factory, which JAXP loads through the context class loader: that is the class path, which holds a second copy of the
+     * test classes.
+     * </p>
+     */
+    private static final List<String> METHODS_NOT_IN_OSGI = Arrays.asList("SecureDocumentBuilderFactoryTest#newDocumentBuilderWrapsDeclaredExceptions",
+            "SecureSAXParserFactoryTest#newXmlReaderWrapsDeclaredExceptions");
+
+    /**
+     * Location of the test classes inside the fragment.
+     */
+    private static final String TEST_PACKAGE = HOST_SYMBOLIC_NAME.replace('.', '/');
+
+    private static Framework framework;
+
+    private static Bundle host;
+
+    private static Path requiredPath(final String property) {
+        final String value = System.getProperty(property);
+        assertNotNull(value, "System property '" + property + "' must be set by the build");
+        return Paths.get(value).toAbsolutePath();
+    }
+
+    @BeforeAll
+    static void startFramework() throws Exception {
+        final List<FrameworkFactory> factories = new ArrayList<>();
+        ServiceLoader.load(FrameworkFactory.class).forEach(factories::add);
+        assertEquals(1, factories.size(), () -> "Expected exactly one OSGi framework on the class path, found " + factories);
+        final Path buildJar = requiredPath("buildJar");
+        final Path work = requiredPath("osgiWorkDirectory");
+        Files.createDirectories(work);
+        final Map<String, String> config = new HashMap<>();
+        config.put(Constants.FRAMEWORK_STORAGE, work.resolve("storage").toString());
+        config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
+        config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
+        // A trailing ".*" only matches subpackages, so each root is listed twice.
+        // sun.reflect, jdk.internal.reflect: the JDK defines generated reflection accessors under the bundle loader.
+        // leaked: XSLTC rejects the host of Felix bundle:// URLs (for example "5.0"), so the XML fixtures resolve as file: URLs instead.
+        config.put(Constants.FRAMEWORK_BOOTDELEGATION, Stream.concat(Stream.of(HARNESS_PACKAGES).flatMap(p -> Stream.of(p, p + ".*")),
+                Stream.of("sun.reflect", "jdk.internal.reflect", "leaked")).collect(Collectors.joining(",")));
+        // Both frameworks can fall back to the parent loader on their own; disable it so only the explicit list above is delegated.
+        config.put("felix.bootdelegation.implicit", "false");
+        config.put("osgi.compatibility.bootdelegation", "false");
+        config.put("osgi.context.bootdelegation", "false");
+        framework = factories.get(0).newFramework(config);
+        framework.start();
+        final BundleContext context = framework.getBundleContext();
+        host = context.installBundle(buildJar.toUri().toString());
+        // The test output directory carries the fragment manifest written by maven-bundle-plugin; install it in place.
+        context.installBundle("reference:" + requiredPath("testClassesDirectory").toUri());
+        host.start();
+        assertEquals(Bundle.ACTIVE, host.getState(), "library bundle must start");
+    }
+
+    @AfterAll
+    static void stopFramework() throws Exception {
+        if (framework != null) {
+            framework.stop();
+            framework.waitForStop(10_000);
+        }
+    }

Review Comment:
   `framework.waitForStop(10_000)` returns a `FrameworkEvent` that can indicate a timeout or error; ignoring it can leave the framework running (and threads/resources leaked), which is especially problematic in Failsafe where the same fork may continue executing. Consider checking the returned event type and failing the test on timeout/error (and/or increasing configurability of the timeout).



##########
src/main/java/org/apache/commons/xml/secure/SecureXMLInputFactory.java:
##########
@@ -285,7 +285,8 @@ public static XMLInputFactory newDefaultFactory() {
         }
         try {
             // Java 8: the method does not exist, and XMLInputFactory has no class-name-taking lookup; instantiate the JDK's built-in default directly.
-            return secure((XMLInputFactory) Class.forName(JDK_XML_INPUT_FACTORY).getConstructor().newInstance());
+            // Load it from the bootstrap loader: our own loader may not see com.sun.* (for example, an OSGi bundle class loader).
+            return secure((XMLInputFactory) Class.forName(JDK_XML_INPUT_FACTORY, true, null).getConstructor().newInstance());
         } catch (final ReflectiveOperationException e) {

Review Comment:
   This reflective path can also throw `SecurityException` (e.g., under a `SecurityManager` on Java 8) which is not a `ReflectiveOperationException` and will currently escape as an unchecked exception. If the intended contract is to surface provider/instantiation problems as `FactoryConfigurationError` (as in the catch below), consider also catching `SecurityException` here and wrapping it similarly so callers get a consistent failure mode.



##########
src/test/java/org/apache/commons/xml/osgi/OsgiIT.java:
##########
@@ -0,0 +1,204 @@
+/*
+ * 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
+ *
+ *      https://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.commons.xml.osgi;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+import org.junit.platform.engine.FilterResult;
+import org.junit.platform.engine.discovery.DiscoverySelectors;
+import org.junit.platform.engine.support.descriptor.MethodSource;
+import org.junit.platform.launcher.PostDiscoveryFilter;
+import org.junit.platform.launcher.TagFilter;
+import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
+import org.junit.platform.launcher.core.LauncherFactory;
+import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
+import org.junit.platform.launcher.listeners.TestExecutionSummary;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Runs the unit test suite inside an OSGi framework, against the built bundle.
+ *
+ * <p>
+ * The tests catch class-loading assumptions that only hold on a flat classpath: an OSGi bundle class loader sees its own classes, the packages it imports and
+ * {@code java.*}, but not JDK-internal packages such as {@code com.sun.*}. The built jar is installed with its generated manifest, so the bundle also proves
+ * that its {@code Import-Package} header resolves.
+ * </p>
+ * <p>
+ * The test output directory, which the build gives a fragment manifest, is attached to that bundle, so the tests share its class loader and keep their
+ * package-private access. The test harness (JUnit, Mockito, JAXB) is not under test and is boot-delegated to the class path. Only the JDK's built-in JAXP implementations are used, as in the
+ * {@code test-stockjdk} execution: provider lookups cannot see other bundles without a mediator such as SPI Fly.
+ * </p>
+ * <p>
+ * The framework is whichever single {@link FrameworkFactory} the class path provides; the build runs this class once with Apache Felix and once with Eclipse
+ * Equinox.
+ * </p>
+ */
+class OsgiIT {
+
+    /**
+     * Package roots the framework delegates to the class path: the test harness only, never the library or JDK internals.
+     */
+    private static final String[] HARNESS_PACKAGES = {"org.junit", "org.opentest4j", "org.apiguardian", "org.mockito", "net.bytebuddy", "org.objenesis",
+        "javax.xml.bind", "com.sun.xml.bind", "org.glassfish.jaxb", "com.sun.istack", "javax.activation", "jakarta.activation"};
+
+    /**
+     * Symbolic name of the library bundle.
+     */
+    private static final String HOST_SYMBOLIC_NAME = "org.apache.commons.xml.secure";
+
+    /**
+     * Test classes that cannot run inside a framework: {@code ShadingFootprintTest} reads {@code target/classes} directly.
+     */
+    private static final List<String> NOT_IN_OSGI = Collections.singletonList("org.apache.commons.xml.secure.ShadingFootprintTest");
+
+    /**
+     * Test methods that cannot run inside a framework.
+     *
+     * <p>
+     * They name a test class as the JAXP factory, which JAXP loads through the context class loader: that is the class path, which holds a second copy of the
+     * test classes.
+     * </p>
+     */
+    private static final List<String> METHODS_NOT_IN_OSGI = Arrays.asList("SecureDocumentBuilderFactoryTest#newDocumentBuilderWrapsDeclaredExceptions",
+            "SecureSAXParserFactoryTest#newXmlReaderWrapsDeclaredExceptions");
+
+    /**
+     * Location of the test classes inside the fragment.
+     */
+    private static final String TEST_PACKAGE = HOST_SYMBOLIC_NAME.replace('.', '/');
+
+    private static Framework framework;
+
+    private static Bundle host;
+
+    private static Path requiredPath(final String property) {
+        final String value = System.getProperty(property);
+        assertNotNull(value, "System property '" + property + "' must be set by the build");
+        return Paths.get(value).toAbsolutePath();
+    }
+
+    @BeforeAll
+    static void startFramework() throws Exception {
+        final List<FrameworkFactory> factories = new ArrayList<>();
+        ServiceLoader.load(FrameworkFactory.class).forEach(factories::add);
+        assertEquals(1, factories.size(), () -> "Expected exactly one OSGi framework on the class path, found " + factories);
+        final Path buildJar = requiredPath("buildJar");
+        final Path work = requiredPath("osgiWorkDirectory");
+        Files.createDirectories(work);
+        final Map<String, String> config = new HashMap<>();
+        config.put(Constants.FRAMEWORK_STORAGE, work.resolve("storage").toString());
+        config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
+        config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
+        // A trailing ".*" only matches subpackages, so each root is listed twice.
+        // sun.reflect, jdk.internal.reflect: the JDK defines generated reflection accessors under the bundle loader.
+        // leaked: XSLTC rejects the host of Felix bundle:// URLs (for example "5.0"), so the XML fixtures resolve as file: URLs instead.
+        config.put(Constants.FRAMEWORK_BOOTDELEGATION, Stream.concat(Stream.of(HARNESS_PACKAGES).flatMap(p -> Stream.of(p, p + ".*")),
+                Stream.of("sun.reflect", "jdk.internal.reflect", "leaked")).collect(Collectors.joining(",")));
+        // Both frameworks can fall back to the parent loader on their own; disable it so only the explicit list above is delegated.
+        config.put("felix.bootdelegation.implicit", "false");
+        config.put("osgi.compatibility.bootdelegation", "false");
+        config.put("osgi.context.bootdelegation", "false");
+        framework = factories.get(0).newFramework(config);
+        framework.start();
+        final BundleContext context = framework.getBundleContext();
+        host = context.installBundle(buildJar.toUri().toString());
+        // The test output directory carries the fragment manifest written by maven-bundle-plugin; install it in place.
+        context.installBundle("reference:" + requiredPath("testClassesDirectory").toUri());
+        host.start();
+        assertEquals(Bundle.ACTIVE, host.getState(), "library bundle must start");
+    }
+
+    @AfterAll
+    static void stopFramework() throws Exception {
+        if (framework != null) {
+            framework.stop();
+            framework.waitForStop(10_000);
+        }
+    }
+
+    /**
+     * Runs one test class, loaded through the library bundle, and fails with the inner failures if any.
+     */
+    private static void runTestClass(final Class<?> testClass) {
+        final SummaryGeneratingListener listener = new SummaryGeneratingListener();
+        final PostDiscoveryFilter notInOsgi = descriptor -> descriptor.getSource()
+                .filter(MethodSource.class::isInstance)
+                .map(MethodSource.class::cast)
+                .filter(source -> METHODS_NOT_IN_OSGI.contains(source.getJavaClass().getSimpleName() + "#" + source.getMethodName()))
+                .map(source -> FilterResult.excluded("cannot run inside an OSGi framework"))
+                .orElseGet(() -> FilterResult.included(null));
+        // The context class loader stays the class path's, as in a plain framework launcher.
+        LauncherFactory.create().execute(LauncherDiscoveryRequestBuilder.request()
+                .selectors(DiscoverySelectors.selectClass(testClass))
+                // Same exclusion as the test-stockjdk execution: xpath3 needs Saxon.
+                .filters(TagFilter.excludeTags("xpath3"), notInOsgi)
+                .build(), listener);
+        final TestExecutionSummary summary = listener.getSummary();
+        if (summary.getTotalFailureCount() > 0) {
+            final StringWriter failures = new StringWriter();
+            summary.printFailuresTo(new PrintWriter(failures), 25);
+            throw new AssertionError(summary.getTotalFailureCount() + " failure(s) in " + testClass.getName() + " under " + framework.getSymbolicName()
+                    + System.lineSeparator() + failures);
+        }
+    }
+
+    @TestFactory
+    Stream<DynamicTest> unitTestsPassInsideFramework() throws ClassNotFoundException {
+        final List<DynamicTest> tests = new ArrayList<>();
+        final Enumeration<URL> entries = host.findEntries(TEST_PACKAGE, "*Test.class", false);
+        assertNotNull(entries, "test fragment must be attached to the library bundle");
+        while (entries.hasMoreElements()) {
+            final String path = entries.nextElement().getPath();
+            final String className = path.substring(path.indexOf(TEST_PACKAGE), path.length() - ".class".length()).replace('/', '.');
+            if (!NOT_IN_OSGI.contains(className)) {

Review Comment:
   `host.findEntries(..., false)` only scans the immediate `TEST_PACKAGE` directory. Any tests located in subpackages will be silently skipped, so this IT won’t actually run the full unit test suite as intended. Consider using a recursive scan (`recurse = true`) or switching discovery to package-based selection so subpackages are included. Also, `assertNotNull(entries, \"test fragment must be attached...\")` is misleading because `findEntries` can return null when there are simply no matches; consider emitting an error that distinguishes 'fragment not attached' from 'no *Test.class found'.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] COMMONSXML-20, COMMONSXML-23: Find the JDK's XML implementations in OSGi [commons-secure-xml]

Posted by "garydgregory (via GitHub) via issues" <is...@commons.apache.org>.
garydgregory commented on PR #114:
URL: https://github.com/apache/commons-secure-xml/pull/114#issuecomment-6721255082

   Thank you @ppkarwasz , merged πŸš€ πŸ˜„ 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org