import java.util.Arrays;
import java.util.List;
import javax.xml.bind.JAXBException;
-import org.apache.karaf.features.internal.model.Feature;
import org.apache.karaf.features.internal.model.Features;
import org.apache.karaf.features.internal.model.JaxbUtil;
import org.junit.runner.Description;
private static final String[] FEATURES_FILENAMES = new String[] { "features.xml", "feature.xml" };
private static boolean isURLStreamHandlerFactorySet = false;
- // Do NOT static { URL.setURLStreamHandlerFactory(new CustomBundleUrlStreamHandlerFactory()); }
- // This is VERY BAD practice, because it leads to VERY HARD TO TRACK errors in case ANYTHING
- // goes wrong in this. For example, we had a case where (following an upgrade of PAX Exam)
- // a dependency was missing. This appeared as a confusing error because the root cause
- // of static initialization errors is typically lost in Java; so best is NOT to use it!
+ // Do NOT static {@code { URL.setURLStreamHandlerFactory(new CustomBundleUrlStreamHandlerFactory()); }}
+ // This is VERY BAD practice, because it leads to VERY HARD TO TRACK errors in case ANYTHING goes wrong in this.
+ // For example, we had a case where (following an upgrade of PAX Exam) a dependency was missing. This appeared
+ // as a confusing error because the root cause of static initialization errors is typically lost in Java; so best is
+ // NOT to use it!
// ("NoClassDefFoundError: Could not initialize class ...PerRepoTestRunner")
private final List<PerFeatureRunner> children = new ArrayList<>();
URL.setURLStreamHandlerFactory(new CustomBundleUrlStreamHandlerFactory());
isURLStreamHandlerFactorySet = true;
} catch (Error e) {
- LOG.warn("Failed to setURLStreamHandlerFactory to CustomBundleUrlStreamHandlerFactory "
- + "(depending on which is already set, this may or may not actually be a problem"
- + "; e.g. Karaf 4 already registers the neccessary handlers, so OK to ignore)", e);
+ LOG.warn("""
+ Failed to setURLStreamHandlerFactory to CustomBundleUrlStreamHandlerFactory (depending on which is
+ already set, this may or may not actually be a problem; e.g. Karaf 4 already registers
+ the neccessary handlers, so OK to ignore)""", e);
}
}
}
protected List<PerFeatureRunner> runnersFromRepoUrl(final URL repoUrl, final Class<?> testClass)
throws JAXBException, IOException, InitializationError {
- final List<PerFeatureRunner> runners = new ArrayList<>();
- final Features features = getFeatures(repoUrl);
- runners.addAll(runnersFromFeatures(repoUrl, features, testClass));
- return runners;
+ return runnersFromFeatures(repoUrl, getFeatures(repoUrl), testClass);
}
protected List<PerFeatureRunner> recursiveRunnersFromRepoUrl(final URL repoUrl, final Class<?> testClass)
protected List<PerFeatureRunner> runnersFromFeatures(
final URL repoUrl, final Features features, final Class<?> testClass) throws InitializationError {
- final List<PerFeatureRunner> runners = new ArrayList<>();
- final List<Feature> featureList = features.getFeature();
- for (final Feature f : featureList) {
+ final var runners = new ArrayList<PerFeatureRunner>();
+ final var featureList = features.getFeature();
+ for (var f : featureList) {
// If the features have more than one feature, ignore any feature with the same name as the
// repository — these are the aggregator features generated by the Karaf Maven plugin, and
// which are expensive to test