use of org.pentaho.platform.api.engine.IPentahoPublisher in project pentaho-platform by pentaho.
the class PluginAdapterIT method testPluginAdapterAsPublisher.
@SuppressWarnings("cast")
@Test
public void testPluginAdapterAsPublisher() throws Exception {
IPentahoPublisher asPublisher = (IPentahoPublisher) pluginAdapter;
// $NON-NLS-1$
assertEquals(Messages.getInstance().getString("PluginAdapter.USER_PLUGIN_MANAGER"), asPublisher.getName());
// $NON-NLS-1$
assertNotSame("!PluginAdapter.USER_PLUGIN_MANAGER!", asPublisher.getName());
assertEquals(Messages.getInstance().getString("PluginAdapter.USER_REFRESH_PLUGINS"), // $NON-NLS-1$
asPublisher.getDescription());
// $NON-NLS-1$
assertNotSame("!PluginAdapter.USER_REFRESH_PLUGINS!", asPublisher.getName());
String str = asPublisher.publish(session, ILogger.DEBUG);
// If we see 'Discovered plugin' anywhere in the result string we know that the plugin adapter was able to invoke
// the plugin manager properly
assertTrue("Result string '" + str + "' did not contain 'Discovered plugin'", str.indexOf("Discovered plugin") > 0);
}
use of org.pentaho.platform.api.engine.IPentahoPublisher in project pentaho-platform by pentaho.
the class SystemSettingsTest method testPublishers.
@SuppressWarnings("deprecation")
public void testPublishers() {
Assert.assertTrue("Initialization of the platform failed", init());
String publishersXml = null;
try {
Document publishersDocument = PentahoSystem.getPublishersDocument();
publishersXml = publishersDocument.asXML();
// $NON-NLS-1$
List publisherNodes = publishersDocument.selectNodes("publishers/publisher");
Iterator publisherIterator = publisherNodes.iterator();
while (publisherIterator.hasNext()) {
Node publisherNode = (Node) publisherIterator.next();
// $NON-NLS-1$
Assert.assertNotNull(publisherNode.selectSingleNode("name"));
// $NON-NLS-1$
Assert.assertNotNull(publisherNode.selectSingleNode("description"));
// $NON-NLS-1$
Assert.assertNotNull(publisherNode.selectSingleNode("class"));
// $NON-NLS-1$ //$NON-NLS-2$
Assert.assertNotSame("", publisherNode.selectSingleNode("class").getText());
// $NON-NLS-1$
String publisherClass = publisherNode.selectSingleNode("class").getText();
Object publisher = PentahoSystem.createObject(publisherClass, null);
Assert.assertNotNull(publisher);
Assert.assertTrue(publisher instanceof IPentahoPublisher);
}
} catch (Throwable e) {
// $NON-NLS-1$
Assert.assertTrue("Error trying to get publishers description document", false);
}
// TODO check the XML against the expected output
// $NON-NLS-1$
Assert.assertNotNull("Publishers description document could not be generated", publishersXml);
}
use of org.pentaho.platform.api.engine.IPentahoPublisher in project pentaho-platform by pentaho.
the class PentahoSystem method getPublishersDocument.
public static Document getPublishersDocument() {
Document document = DocumentHelper.createDocument();
// $NON-NLS-1$
Element root = document.addElement("publishers");
if (administrationPlugins != null) {
Iterator publisherIterator = PentahoSystem.administrationPlugins.iterator();
// refresh the system settings
while (publisherIterator.hasNext()) {
IPentahoPublisher publisher = (IPentahoPublisher) publisherIterator.next();
if (publisher != null) {
try {
// $NON-NLS-1$
Element publisherNode = root.addElement("publisher");
// $NON-NLS-1$
publisherNode.addElement("name").setText(publisher.getName());
// $NON-NLS-1$
publisherNode.addElement("description").setText(publisher.getDescription());
// $NON-NLS-1$
publisherNode.addElement("class").setText(publisher.getClass().getName());
} catch (Throwable e) {
// ignore
}
}
}
}
return document;
}
use of org.pentaho.platform.api.engine.IPentahoPublisher in project pentaho-platform by pentaho.
the class PluginManagerNotConfiguredIT method testPluginAdapterViaPublisherAPI.
@SuppressWarnings("cast")
public void testPluginAdapterViaPublisherAPI() throws Exception {
startTest();
// $NON-NLS-1$
IPentahoSession session = new StandaloneSession("test user");
PluginAdapter mgr = new PluginAdapter();
assertTrue(mgr instanceof IPentahoPublisher);
IPentahoPublisher publisher = (IPentahoPublisher) mgr;
// $NON-NLS-1$
assertEquals(Messages.getInstance().getString("PluginAdapter.USER_PLUGIN_MANAGER"), publisher.getName());
// $NON-NLS-1$
assertNotSame("!PluginAdapter.USER_PLUGIN_MANAGER!", publisher.getName());
// $NON-NLS-1$
assertEquals(Messages.getInstance().getString("PluginAdapter.USER_REFRESH_PLUGINS"), publisher.getDescription());
// $NON-NLS-1$
assertNotSame("!PluginAdapter.USER_REFRESH_PLUGINS!", publisher.getName());
String str = publisher.publish(session, ILogger.DEBUG);
// $NON-NLS-1$
assertEquals(str, Messages.getInstance().getString("PluginAdapter.ERROR_0001_PLUGIN_MANAGER_NOT_CONFIGURED"));
finishTest();
}
Aggregations