Search in sources :

Example 1 with IPentahoPublisher

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);
}
Also used : IPentahoPublisher(org.pentaho.platform.api.engine.IPentahoPublisher) Test(org.junit.Test)

Example 2 with IPentahoPublisher

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);
}
Also used : IPentahoPublisher(org.pentaho.platform.api.engine.IPentahoPublisher) Node(org.dom4j.Node) Iterator(java.util.Iterator) List(java.util.List) Document(org.dom4j.Document)

Example 3 with IPentahoPublisher

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;
}
Also used : IPentahoPublisher(org.pentaho.platform.api.engine.IPentahoPublisher) Element(org.dom4j.Element) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) Document(org.dom4j.Document)

Example 4 with IPentahoPublisher

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();
}
Also used : PluginAdapter(org.pentaho.platform.plugin.services.pluginmgr.PluginAdapter) IPentahoPublisher(org.pentaho.platform.api.engine.IPentahoPublisher) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession)

Aggregations

IPentahoPublisher (org.pentaho.platform.api.engine.IPentahoPublisher)4 Iterator (java.util.Iterator)2 Document (org.dom4j.Document)2 List (java.util.List)1 ListIterator (java.util.ListIterator)1 Element (org.dom4j.Element)1 Node (org.dom4j.Node)1 Test (org.junit.Test)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)1 PluginAdapter (org.pentaho.platform.plugin.services.pluginmgr.PluginAdapter)1