ServerPlugin plugin = new ServerPlugin(0, descriptor.getName(), jar.getName(), descriptor.getDisplayName(),
true, PluginStatusType.INSTALLED, descriptor.getDescription(), null, MessageDigestGenerator
.getDigestString(jar), descriptor.getVersion(), descriptor.getApiVersion(), null, null, type
.stringify(), System.currentTimeMillis(), System.currentTimeMillis());
ServerPluginManagerLocal serverPluginsLocal = LookupUtil.getServerPluginManager();
Map<ServerPluginType, List<PluginKey>> original = serverPluginsLocal.getInstalledServerPluginsGroupedByType();
serverPluginsLocal.registerServerPlugin(LookupUtil.getSubjectManager().getOverlord(), plugin, jar);
try {
Map<ServerPluginType, List<PluginKey>> map = serverPluginsLocal.getInstalledServerPluginsGroupedByType();
List<PluginKey> pluginKeys = map.get(type);
if (original.containsKey(type)) {
assert map.size() == original.size();
assert pluginKeys.size() == original.get(type).size() + 1;
} else {
assert map.size() == original.size() + 1;
assert pluginKeys.size() == 1;
}
boolean got_it = false;
for (PluginKey pluginKey : pluginKeys) {
if (pluginKey.getPluginName().equals("TestSimpleGenericPlugin")) {
got_it = true;
break;
}
}
assert got_it == true;
} finally {
// make sure we clean this up, even on error
serverPluginsLocal.purgeServerPlugin(plugin.getId());
}
// test that purge really deleted it
Map<ServerPluginType, List<PluginKey>> map = serverPluginsLocal.getInstalledServerPluginsGroupedByType();
List<PluginKey> pluginKeys = map.get(type);
assert map.size() == original.size();
if (pluginKeys == null) {
assert !original.containsKey(type) : "we dont have any plugins of this type, neither should original";