use of org.datanucleus.ClassLoaderResolverImpl in project datanucleus-core by datanucleus.
the class PluginParserTest method testRequireBundleVersionLogged.
public void testRequireBundleVersionLogged() {
final java.util.Set messages = new HashSet();
Logger.getLogger("DataNucleus.General").addAppender(new Appender() {
public void setName(String arg0) {
}
public void setLayout(Layout arg0) {
}
public void setErrorHandler(ErrorHandler arg0) {
}
public boolean requiresLayout() {
return false;
}
public String getName() {
return "testappender123";
}
public Layout getLayout() {
return null;
}
public Filter getFilter() {
return null;
}
public ErrorHandler getErrorHandler() {
return null;
}
public void doAppend(LoggingEvent arg0) {
if (arg0.getLevel() != Level.DEBUG) {
messages.add(arg0.getRenderedMessage());
}
}
public void close() {
}
public void clearFilters() {
}
public void addFilter(Filter arg0) {
}
});
ClassLoaderResolver clr = new ClassLoaderResolverImpl();
NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION", true);
assertEquals(0, mgr.getExtensionPoints().length);
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST10.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST11.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST12.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST13.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST14.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST15.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST16.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST17.MF", null));
mgr.resolveConstraints();
try {
assertEquals(3, messages.size());
assertTrue(messages.contains("Bundle \"org.datanucleus.plugin.test12\" requires \"org.datanucleus.plugin.test11\" version \"(1.2.0.b2\" but the resolved bundle has version \"1.2.0.b2\" which is outside the expected range."));
assertTrue(messages.contains("Bundle \"org.datanucleus.plugin.test13\" requires \"org.datanucleus.plugin.test11\" version \"(1.2.0.c1\" but the resolved bundle has version \"1.2.0.b2\" which is outside the expected range."));
assertTrue(messages.contains("Bundle \"org.datanucleus.plugin.test15\" requires \"org.datanucleus.plugin.test11\" version \"(1.0.0.b2,1.2.0.b2)\" but the resolved bundle has version \"1.2.0.b2\" which is outside the expected range."));
} finally {
Logger.getLogger("DataNucleus.General").removeAppender("testappender123");
}
}
use of org.datanucleus.ClassLoaderResolverImpl in project datanucleus-core by datanucleus.
the class MyConstructorClass method testClassesAreDescendents.
/**
* Test for whether classes are descendents of each other.
*/
public void testClassesAreDescendents() {
ClassLoaderResolver clr = new ClassLoaderResolverImpl(null);
assertTrue("java.util.Collection and java.util.ArrayList should have been direct descendents but weren't", ClassUtils.classesAreDescendents(clr, "java.util.Collection", "java.util.ArrayList"));
assertTrue("java.util.ArrayList and java.util.Collection should have been direct descendents but weren't", ClassUtils.classesAreDescendents(clr, "java.util.ArrayList", "java.util.Collection"));
assertTrue("java.util.ArrayList and java.lang.String shouldn't have been direct descendents but were", !ClassUtils.classesAreDescendents(clr, "java.util.ArrayList", "java.lang.String"));
}
use of org.datanucleus.ClassLoaderResolverImpl in project hive by apache.
the class ObjectStore method clearClr.
private static void clearClr(ClassLoaderResolver clr) throws Exception {
if (clr != null) {
if (clr instanceof ClassLoaderResolverImpl) {
ClassLoaderResolverImpl clri = (ClassLoaderResolverImpl) clr;
long resourcesCleared = clearFieldMap(clri, "resources");
long loadedClassesCleared = clearFieldMap(clri, "loadedClasses");
long unloadedClassesCleared = clearFieldMap(clri, "unloadedClasses");
LOG.debug("Cleared ClassLoaderResolverImpl: {}, {}, {}", resourcesCleared, loadedClassesCleared, unloadedClassesCleared);
}
}
}
use of org.datanucleus.ClassLoaderResolverImpl in project hive by apache.
the class PersistenceManagerProvider method clearClr.
private static void clearClr(ClassLoaderResolver clr) throws Exception {
if (clr instanceof ClassLoaderResolverImpl) {
ClassLoaderResolverImpl clri = (ClassLoaderResolverImpl) clr;
int resourcesCleared = clearFieldMap(clri, "resources");
int loadedClassesCleared = clearFieldMap(clri, "loadedClasses");
int unloadedClassesCleared = clearFieldMap(clri, "unloadedClasses");
LOG.debug("Cleared ClassLoaderResolverImpl: resources: {}, loaded classes: {}, unloaded classes: {}", resourcesCleared, loadedClassesCleared, unloadedClassesCleared);
}
}
use of org.datanucleus.ClassLoaderResolverImpl in project datanucleus-core by datanucleus.
the class PluginParserTest method testParseSymbolicName.
public void testParseSymbolicName() {
ClassLoaderResolver clr = new ClassLoaderResolverImpl();
NonManagedPluginRegistry mgr = new NonManagedPluginRegistry(clr, "EXCEPTION", true);
Bundle bundle1 = mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST1.MF", null));
mgr.registerExtensionsForPlugin(clr.getResource("/org/datanucleus/samples/plugin/plugin1expoint.xml", null), bundle1);
assertEquals(2, mgr.getExtensionPoints().length);
assertNull(mgr.getExtensionPoint("testID"));
assertNull(mgr.getExtensionPoint("testID2"));
assertNotNull(mgr.getExtensionPoint("org.datanucleus.plugin.test1.testID"));
assertNotNull(mgr.getExtensionPoint("org.datanucleus.plugin.test1.testID2"));
Bundle bundle2 = mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST2.MF", null));
mgr.registerExtensionsForPlugin(clr.getResource("/org/datanucleus/samples/plugin/plugin1expoint.xml", null), bundle2);
assertEquals(4, mgr.getExtensionPoints().length);
assertNotNull(mgr.getExtensionPoint("org.datanucleus.plugin.test2.testID"));
assertNotNull(mgr.getExtensionPoint("org.datanucleus.plugin.test2.testID2"));
Extension[] ex = mgr.getExtensionPoint("org.datanucleus.plugin.test2.testID").getExtensions();
assertEquals(ex.length, 0);
/*assertEquals("org.datanucleus.plugin.test2",ex[ex.length-1].getPlugin().getSymbolicName());*/
}
Aggregations