Package org.rhq.core.clientapi.descriptor.plugin

Examples of org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor


@Test
public class PluginMetadataParserTest {

    @Test
    void discoveryCallback() throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <discovery-callbacks>" + //
            "     <type-callback type='testServerType' plugin='TestServer' callbackClass='TestCallback' />" + //
            "  </discovery-callbacks>" + //
            "  <server name='testServerType'" + //
            "          class='org.rhq.plugins.test.TestServer'" + //
            "          discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
            "</plugin>");

        Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
        PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);

        Map<ResourceType, List<String>> map = parser.getDiscoveryCallbackClasses();
        assertEquals(map.size(), 1, "Should have one discovery callback: " + map);
        ResourceType rt = new ResourceType("testServerType", "TestServer", null, null);
        assertEquals(map.get(rt).get(0), "org.rhq.plugins.test.TestCallback", "incorrect classname in map: " + map);

        // in a second plugin, define a discovery callback that points back to a type in the first plugin
        PluginDescriptor pluginDescriptor2 = toPluginDescriptor("" + //
                "<plugin name='TestServer2' displayName='Test Server' package='org.rhq.plugins.test2'" + //
                "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
                "    xmlns='urn:xmlns:rhq-plugin'>" + //
                "  <discovery-callbacks>" + //
                "     <type-callback type='testServerType' plugin='TestServer' callbackClass='TestCallback2' />" + //
                "  </discovery-callbacks>" + //
                "  <server name='testServerType2'" + //
                "          class='org.rhq.plugins.test2.TestServer2'" + //
                "          discovery='org.rhq.plugins.test2.TestServerDiscoveryComponent2'/>" + //
                "</plugin>");

        parsersByPlugin.put("TestServer", parser);
        PluginMetadataParser parser2 = new PluginMetadataParser(pluginDescriptor2, parsersByPlugin);
        map = parser2.getDiscoveryCallbackClasses();
        assertEquals(map.size(), 1, "Should have one discovery callback: " + map);
        rt = new ResourceType("testServerType", "TestServer", null, null);
        assertEquals(map.get(rt).get(0), "org.rhq.plugins.test2.TestCallback2", "incorrect classname in map: " + map);

        // define multiple callbacks to multiple plugins
        PluginDescriptor pluginDescriptor3 = toPluginDescriptor("" + //
                "<plugin name='TestServer3' displayName='Test Server' package='org.rhq.plugins.test3'" + //
                "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
                "    xmlns='urn:xmlns:rhq-plugin'>" + //
                "  <discovery-callbacks>" + //
                "     <type-callback type='testServerType' plugin='TestServer' callbackClass='TestCallback31' />" + //
View Full Code Here


    }

    @Test
    void allTypesShouldHaveOneElementForDescriptorWithOnlyOneResourceType() throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <server name='testServer'" + //
            "          class='org.rhq.plugins.test.TestServer'" + //
View Full Code Here

            "Expected to find resource type named 'testServer' in allTypes.");
    }

    @Test
    void allTypesShouldHaveTwoElementsForDescriptorWithOneServerAndOneService() throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <server name='testServer'" + //
            "          class='TestServer'" + //
View Full Code Here

        return null; // no-op since the above assert should always throw exception
    }

    @Test
    void rootResourceTypesShouldHaveOneElementForDescriptorWithOnlyOneResourceType() throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <server name='testServer'" + //
            "          class='org.rhq.plugins.test.TestServer'" + //
View Full Code Here

        assertNotNull(root, "Expected to find resource type named 'testServer' in rootResouceTypes.");
    }

    @Test
    void getComponentClassShouldReturnValueOfClassAttributeWhenPackageNameIncludedInAttribute() throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <server name='testServer'" + //
            "          class='org.rhq.plugins.test.TestServer'" + //
View Full Code Here

            "Expected the package and class name from the 'class' attribute when it includes the package name.");
    }

    @Test
    void getComponentClassShouldIncludePluginPackageWhenClassAttributeDoesNotSpecifyPackageName() throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <server name='testServer'" + //
            "          class='TestServer'" + //
View Full Code Here

    }

    @Test
    void getDiscoveryComponentClassShouldReturnValueOfDiscoveryComponentAttributeWhenPackageNameIncludedInAttribute()
        throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <server name='testServer'" + //
            "          class='org.rhq.plugins.test.TestServer'" + //
View Full Code Here

    }

    @Test
    void getDiscoveryComponentClassShouldIncludePluginPackageWhenDiscoveryAttributeDoesNotSpecifyPackageName()
        throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <server name='testServer'" + //
            "          class='TestServer'" + //
View Full Code Here

                + "pacage is not included in the 'discovery' attribute.");
    }

    @Test
    void childServiceResourceTypeShouldBeAddedToParentServerResourceType() throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'>" + //
            "  <server name='testServer'" + //
            "          class='TestServer'" + //
View Full Code Here

    }

    @Test
    void resourceTypeHavingResourceConfigurationDefinitionShouldBeBuiltForServerWithResourceConfiguration()
        throws Exception {
        PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
            "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
            "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
            "    xmlns='urn:xmlns:rhq-plugin'" + //
            "    xmlns:c='urn:xmlns:rhq-configuration'>" + //
            "  <server name='testServer'" + //
View Full Code Here

TOP

Related Classes of org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.