### Question:
FeaturableConfig { public static List<Feature> getFeatures(ClassLoader loader, Services services, Setup setup) { final Collection<Xml> children; final Xml root = setup.getRoot(); if (root.hasChild(NODE_FEATURES)) { children = setup.getRoot() .getChild(FeaturableConfig.NODE_FEATURES) .getChildren(FeaturableConfig.NODE_FEATURE); } else { children = Collections.emptyList(); } final List<Feature> features = new ArrayList<>(children.size()); for (final Xml featureNode : children) { final String className = featureNode.getText(); final Feature feature; try { final Class<? extends Feature> clazz = getClass(loader, className); feature = UtilReflection.createReduce(clazz, services, setup); } catch (final NoSuchMethodException exception) { throw new LionEngineException(exception); } features.add(feature); } children.clear(); return features; } FeaturableConfig(String clazz, String setup); static void clearCache(); static FeaturableConfig imports(Configurer configurer); static FeaturableConfig imports(Xml root); static Xml exportClass(String clazz); static Xml exportSetup(String setup); static List<Feature> getFeatures(ClassLoader loader, Services services, Setup setup); String getClassName(); String getSetupName(); @Override int hashCode(); @Override boolean equals(Object object); @Override String toString(); static final String DEFAULT_FILENAME; static final String NODE_FEATURABLE; static final String ATT_CLASS; static final String ATT_SETUP; static final String NODE_FEATURES; static final String NODE_FEATURE; }### Answer:
@Test void testGetFeaturesCache() { final Xml root = new Xml("test"); root.createChild(FeaturableConfig.NODE_FEATURES) .createChild(FeaturableConfig.NODE_FEATURE) .setText(FeatureModel.class.getName()); final Media media = Medias.create("Object.xml"); root.save(media); final ClassLoader loader = ClassLoader.getSystemClassLoader(); final Services services = new Services(); final Setup setup = new Setup(media); final List<Feature> a = FeaturableConfig.getFeatures(loader, services, setup); final List<Feature> b = FeaturableConfig.getFeatures(loader, services, setup); assertNotEquals(a.get(0), b.get(0)); }
@Test void testGetFeaturesUnknown() { final Xml root = new Xml("test"); root.createChild(FeaturableConfig.NODE_FEATURES) .createChild(FeaturableConfig.NODE_FEATURE) .setText(Feature.class.getName()); final Media media = Medias.create("Object.xml"); root.save(media); assertCause(() -> FeaturableConfig.getFeatures(ClassLoader.getSystemClassLoader(), new Services(), new Setup(media)), NoSuchMethodException.class); }