@SuppressWarnings("deprecation") @Test public void testLoad_Good() throws PlatformPluginRegistrationException { microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init(); PluginMessageLogger.clear(); List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession()); // should successfully load good-plugin1 and good-plugin2 and not load bad-plugin. The fact // that bad-plugin does not load should not prevent the good ones from being loaded assertTrue( "plugin1 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 1"))); assertTrue( "plugin2 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 2"))); // make sure that the bad plugin caused an error message to be logged assertEquals( "bad plugin did not log an error message", 1, PluginMessageLogger.count("SystemPathXmlPluginProvider.ERROR_0001")); for (String msg : PluginMessageLogger.getAll()) { System.err.println(msg); } }
@SuppressWarnings("deprecation") @Test public void testLoadWebservices() throws PlatformPluginRegistrationException { microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init(); List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession()); System.out.println(PluginMessageLogger.getAll()); IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1")); assertNotNull("Plugin 1 should have been found", plugin); Collection<PluginServiceDefinition> webservices = plugin.getServices(); Object wsobj = CollectionUtils.find( webservices, new Predicate() { public boolean evaluate(Object object) { PluginServiceDefinition ws = (PluginServiceDefinition) object; boolean ret = ws.getTitle().equals("%TestWS1.TITLE%"); return ret; } }); assertNotNull("Webservice \"%TestWS1.TITLE%\" should have been loaded", wsobj); PluginServiceDefinition wsDfn = (PluginServiceDefinition) wsobj; assertEquals("org.pentaho.test.platform.engine.core.EchoServiceBean", wsDfn.getServiceClass()); assertEquals("xml", wsDfn.getTypes()[0]); assertEquals("gwt", wsDfn.getTypes()[1]); assertEquals("A test webservice", wsDfn.getDescription()); assertEquals(1, wsDfn.getExtraClasses().size()); assertEquals("java.lang.String", wsDfn.getExtraClasses().iterator().next()); }