Package org.rhq.core.pluginapi.inventory

Examples of org.rhq.core.pluginapi.inventory.ResourceContext


    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void loadResourceConfigurationWithType() throws Exception {
        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceContext mockResourceContext = mock(ResourceContext.class);

        ResourceType mockResourceType = mock(ResourceType.class);
        when(mockResourceContext.getResourceType()).thenReturn(mockResourceType);

        ConfigurationDefinition mockConfigurationDefinition = mock(ConfigurationDefinition.class);
        when(mockResourceType.getResourceConfigurationDefinition()).thenReturn(mockConfigurationDefinition);

        ConfigurationTemplate mockConfigurationTemplate = mock(ConfigurationTemplate.class);
        when(mockConfigurationDefinition.getDefaultTemplate()).thenReturn(mockConfigurationTemplate);

        Configuration mockConfiguration = mock(Configuration.class);
        when(mockConfigurationTemplate.getConfiguration()).thenReturn(mockConfiguration);

        Property mockProperty = mock(Property.class);
        when(mockConfiguration.get(eq("__type"))).thenReturn(mockProperty);

        Map<String, PropertyDefinition> mockMap = (Map<String, PropertyDefinition>) mock(Map.class);
        when(mockConfigurationDefinition.getPropertyDefinitions()).thenReturn(mockMap);

        ConfigurationLoadDelegate mockConfigurationLoadDelegate = mock(ConfigurationLoadDelegate.class);
        PowerMockito.whenNew(ConfigurationLoadDelegate.class)
            .withParameterTypes(ConfigurationDefinition.class, ASConnection.class, Address.class)
            .withArguments(any(ConfigurationDefinition.class), any(ASConnection.class), any(Address.class))
            .thenReturn(mockConfigurationLoadDelegate);

        when(mockConfigurationLoadDelegate.loadResourceConfiguration()).thenReturn(mockConfiguration);

        PropertySimple pathPropertySimple = new PropertySimple("path", "abc=def,xyz=test1");
        when(mockConfiguration.get(eq("path"))).thenReturn(pathPropertySimple);
        when(mockResourceContext.getPluginConfiguration()).thenReturn(mockConfiguration);

        ASConnection mockASConnection = mock(ASConnection.class);

        PropertySimple typePropertySimple = new PropertySimple("__type", "xyz");
        PowerMockito.whenNew(PropertySimple.class).withParameterTypes(String.class, Object.class)
View Full Code Here


    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void loadResourceConfigurationWithName() throws Exception {
        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceContext mockResourceContext = mock(ResourceContext.class);

        ResourceType mockResourceType = mock(ResourceType.class);
        when(mockResourceContext.getResourceType()).thenReturn(mockResourceType);

        ConfigurationDefinition mockConfigurationDefinition = mock(ConfigurationDefinition.class);
        when(mockResourceType.getResourceConfigurationDefinition()).thenReturn(mockConfigurationDefinition);

        ConfigurationTemplate mockConfigurationTemplate = mock(ConfigurationTemplate.class);
        when(mockConfigurationDefinition.getDefaultTemplate()).thenReturn(mockConfigurationTemplate);

        Configuration mockConfiguration = mock(Configuration.class);
        when(mockConfigurationTemplate.getConfiguration()).thenReturn(mockConfiguration);

        Property mockProperty = mock(Property.class);
        when(mockConfiguration.get("_type")).thenReturn(null);
        when(mockConfiguration.get(eq("__name"))).thenReturn(mockProperty);


        Map<String, PropertyDefinition> mockMap = (Map<String, PropertyDefinition>) mock(Map.class);
        when(mockConfigurationDefinition.getPropertyDefinitions()).thenReturn(mockMap);

        ConfigurationLoadDelegate mockConfigurationLoadDelegate = mock(ConfigurationLoadDelegate.class);
        PowerMockito.whenNew(ConfigurationLoadDelegate.class)
            .withParameterTypes(ConfigurationDefinition.class, ASConnection.class, Address.class)
            .withArguments(any(ConfigurationDefinition.class), any(ASConnection.class), any(Address.class))
            .thenReturn(mockConfigurationLoadDelegate);

        when(mockConfigurationLoadDelegate.loadResourceConfiguration()).thenReturn(mockConfiguration);

        PropertySimple pathPropertySimple = new PropertySimple("path", "abc=def,xyz=test1");
        when(mockConfiguration.get(eq("path"))).thenReturn(pathPropertySimple);
        when(mockResourceContext.getPluginConfiguration()).thenReturn(mockConfiguration);

        ASConnection mockASConnection = mock(ASConnection.class);

        PropertySimple namePropertySimple = new PropertySimple("__name", "test1");
        PowerMockito.whenNew(PropertySimple.class).withParameterTypes(String.class, Object.class)
View Full Code Here

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void updateResourceConfigurationWithType() throws Exception {
        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceContext mockResourceContext = mock(ResourceContext.class);

        ResourceType mockResourceType = mock(ResourceType.class);
        when(mockResourceContext.getResourceType()).thenReturn(mockResourceType);

        ConfigurationDefinition mockConfigurationDefinition = mock(ConfigurationDefinition.class);
        when(mockResourceType.getResourceConfigurationDefinition()).thenReturn(mockConfigurationDefinition);

        ConfigurationDefinition mockConfigurationDefinitionCopy = mock(ConfigurationDefinition.class);
View Full Code Here

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void updateResourceConfigurationWithName() throws Exception {
        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceContext mockResourceContext = mock(ResourceContext.class);

        ResourceType mockResourceType = mock(ResourceType.class);
        when(mockResourceContext.getResourceType()).thenReturn(mockResourceType);

        ConfigurationDefinition mockConfigurationDefinition = mock(ConfigurationDefinition.class);
        when(mockResourceType.getResourceConfigurationDefinition()).thenReturn(mockConfigurationDefinition);

        ConfigurationDefinition mockConfigurationDefinitionCopy = mock(ConfigurationDefinition.class);
View Full Code Here

    @Override
    public Set<DiscoveredResourceDetails> discoverResources(
            ResourceDiscoveryContext<BaseComponent<?>> context) throws Exception {

        ResourceContext parentContext = context.getParentResourceContext();


        if (!parentContext.getResourceType().getName().equals("Managed Server"))
            return super.discoverResources(context);

        PropertySimple pathProp = parentContext.getPluginConfiguration().getSimple("path");
        String path = pathProp.getStringValue();
        path = path.replaceAll("server-config=","server=");
        path = path + ",core-service=platform-mbean";

        Configuration config = new Configuration();
View Full Code Here

        rt.setName("Deployment");
        Resource resource = new Resource("deployment=" + TEST_WAR_FILE_NAME, TEST_WAR_FILE_NAME, rt); // TODO resource key?
        resource.setUuid(UUID.randomUUID().toString());
        StandaloneASComponent parentComponent = new StandaloneASComponent();
        parentComponent.setConnection(getDomainControllerASConnection());
        ResourceContext context = new ResourceContext(resource, parentComponent, null, null, null, null, null, null,
            null, null, null, null, null, null);
        bc.start(context);

        String bytes_value = uploadToAs(TEST_WAR_PATH);
View Full Code Here

        rt.setName("Deployment");
        Resource resource = new Resource("server-group=main-server-group", TEST_WAR_FILE_NAME, rt);
        resource.setUuid(UUID.randomUUID().toString());
        StandaloneASComponent parentComponent = new StandaloneASComponent();
        parentComponent.setConnection(getDomainControllerASConnection());
        ResourceContext context = new ResourceContext(resource, parentComponent, null, null, null, null, null, null,
            null, null, null, null, null, null);
        bc.start(context);

        String bytes_value = uploadToAs(TEST_WAR_PATH);
View Full Code Here

     * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
     */
    @Override
    public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) {

        ResourceContext parentCtx = context.getParentResourceContext();

        if (!(parentCtx.getParentResourceComponent() instanceof JMXComponent)) {
            return Collections.emptySet();
        }

        JMXComponent<JBossASServerComponent<?>> gparentComponent = (JMXComponent<JBossASServerComponent<?>>) parentCtx.getParentResourceComponent();

        Set<DiscoveredResourceDetails> discovered = super.performDiscovery(context.getDefaultPluginConfiguration(), gparentComponent, context.getResourceType(), false);

        Set<DiscoveredResourceDetails> results = new HashSet<DiscoveredResourceDetails>(discovered.size());

View Full Code Here

            ResourceDiscoveryComponent resourceDiscoveryComponent = new NothingDiscoveringDiscoveryComponent();
            EventContext eventContext = new EventContextImpl(resource, eventManager);
            AvailabilityContext availContext = new AvailabilityContextImpl(resource, pluginContainer.getInventoryManager());
            InventoryContext inventoryContext = new InventoryContextImpl(resource, pluginContainer.getInventoryManager());
            ResourceContext context = new ResourceContext(resource, parentResourceComponent, parentResourceContext,
                resourceDiscoveryComponent, systemInfo, temporaryDirectory, dataDirectory, pluginContainerName,
                eventContext, operationContext, contentContext, availContext, inventoryContext,
                pluginContainerDeployment);
            component.start(context);
View Full Code Here

        log.debug("rdc=" + rdc);

        EventContext eventContext = new EventContextImpl(resource, eventManager);
        AvailabilityContext availContext = new AvailabilityContextImpl(resource, pluginContainer.getInventoryManager());
        InventoryContext inventoryContext = new InventoryContextImpl(resource, pluginContainer.getInventoryManager());
        ResourceContext context = new ResourceContext(resource, component, parentContext, resourceDiscoveryComponent,
            systemInfo, temporaryDirectory, dataDirectory, pluginContainerName, eventContext, operationContext,
            contentContext, availContext, inventoryContext, pluginContainerDeployment);
        ResourceDiscoveryContext resourceDiscoveryContext = new ResourceDiscoveryContext(resourceType, component,
            context, systemInfo, Collections.emptyList(), Collections.emptyList(), pluginContainerName,
            pluginContainerDeployment);
        Assert.assertNotNull(context.getEventContext());
        Set<DiscoveredResourceDetails> d = rdc.discoverResources(resourceDiscoveryContext);
        for (DiscoveredResourceDetails drd : d) {
            log.debug("discovered " + drd);
            createChild(drd, resource, configuration, component, context);
        }
View Full Code Here

TOP

Related Classes of org.rhq.core.pluginapi.inventory.ResourceContext

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.