use of org.datanucleus.plugin.NonManagedPluginRegistry in project datanucleus-core by datanucleus.
the class PluginParserTest method testRequireBundleLogged.
public void testRequireBundleLogged() {
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.getRenderedMessage().indexOf("but it cannot be resolved") > 0) {
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/MANIFEST3.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST4.MF", null));
mgr.registerBundle(clr.getResource("/org/datanucleus/samples/plugin/MANIFEST5.MF", null));
mgr.resolveConstraints();
try {
assertEquals(2, messages.size());
assertTrue(messages.contains("Bundle \"org.datanucleus.plugin.test5\" requires \"org.datanucleus.plugin.test6\" but it cannot be resolved."));
assertTrue(messages.contains("Bundle \"org.datanucleus.plugin.test5\" has an optional dependency to \"org.datanucleus.plugin.test7\" but it cannot be resolved"));
} finally {
Logger.getLogger("DataNucleus.General").removeAppender("testappender123");
}
}
Aggregations