Package org.rhq.core.domain.resource

Examples of org.rhq.core.domain.resource.Resource


            "Expected to see empty string for Resource.currentAvailability when property is null");
    }

    @Test
    public void resourceTypeShouldBeLastResourcePropertyPrinted() {
        Resource resource = createResource();

        writer.print(resource);

        assertLineEquals(5, "\t" + padResourceField("resourceType") + ": " + resource.getResourceType().getName(),
            "Expected short version of Resource.resourceType to be the fifth property printed");
    }
View Full Code Here


            .withUuid("12345").withVersion("1.0").notInInventory().build();
    }

    @Test
    public void printCollectionOfUncommittedResource() {
        Resource parent = new ResourceBuilder().createServer().usingDefaultResourceType().withName("test-server")
            .withUuid("12345").withVersion("1.0").inInventory().with(2).randomChildServices()
            //                .notInInventory()
            //                .included()
            .build();

        writer.print(parent.getChildResources());
    }
View Full Code Here

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        Query q = em.createQuery("SELECT r FROM Resource r");
        List<Resource> resources = q.getResultList();
        Resource res = resources.get(0);
        if (!(res.getResourceType().getCategory()== ResourceCategory.PLATFORM))
            res = resourceManager.getPlaformOfResource(overlord,res.getId());
        ResourceType type = res.getResourceType();
        MeasurementDefinition def = null;
        Set<MeasurementDefinition> definitions = type.getMetricDefinitions();
        for (MeasurementDefinition d : definitions) {
            if (d.getName().equals("myCallTime"))
                def = d;
View Full Code Here

                em.persist(resourceType);

                agent = new Agent(AGENT_NAME, "localhost", 9999, "", "randomToken");
                em.persist(agent);

                resource = new Resource(RESOURCE_KEY, RESOURCE_NAME, resourceType);
                resource.setUuid(RESOURCE_UUID);
                resource.setAgent(agent);

                em.persist(resource);
            }
View Full Code Here

                // Note that the order of deletes is important due to FK
                // constraints.
                if (!r.isEmpty()) {
                    assertTrue("Should be only 1 resource", r.size() == 1);
                    Resource doomedResource = r.get(0);
                    deleteMeasurementSchedules();
                    deleteResource(doomedResource);
                }
                deleteAgent();
                deleteDynamicMeasurementDef();
View Full Code Here

            resourceType = new ResourceType("resourcetype-" + System.currentTimeMillis(), "TestPlugin",
                ResourceCategory.PLATFORM, null);
            em.persist(resourceType);

            // Create resource against which we'll be retrieving packages
            resource = new Resource("parent" + System.currentTimeMillis(), "name", resourceType);
            resource.setUuid("" + new Random().nextInt());
            resource.setVersion("1.0");
            em.persist(resource);

            // Product versions
View Full Code Here

        definitionCt2 = new MeasurementDefinition("CT-Def2", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MILLISECONDS, DataType.CALLTIME, true, 60000, DisplayType.SUMMARY);
        definitionCt2.setResourceType(theResourceType);
        em.persist(definitionCt2);

        resource1 = new Resource("test-platform-key1", "test-platform-name", theResourceType);
        resource1.setUuid("" + new Random().nextInt());
        resource1.setAgent(theAgent);
        em.persist(resource1);
        resource2 = new Resource("test-platform-key2", "test-platform-name", theResourceType);
        resource2.setUuid("" + new Random().nextInt());
        resource2.setAgent(theAgent);
        em.persist(resource2);

        schedule1 = new MeasurementSchedule(definitionCt1, resource1);
View Full Code Here

        definitionCt3 = new MeasurementDefinition("CT-Def3", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MILLISECONDS, DataType.CALLTIME, true, 60000, DisplayType.SUMMARY);
        definitionCt3.setResourceType(theResourceType);
        em.persist(definitionCt3);

        resource1 = new Resource("test-platform-key1", "test-platform-name", theResourceType);
        resource1.setUuid("" + new Random().nextInt());
        resource1.setAgent(theAgent);
        em.persist(resource1);

        resource2 = new Resource("test-platform-key2", "test-platform-name", theResourceType);
        resource2.setUuid("" + new Random().nextInt());
        resource2.setAgent(theAgent);
        em.persist(resource2);

        schedule1 = new MeasurementSchedule(definitionCt1, resource1);
View Full Code Here

     * @throws Exception
     */
    @Test(enabled = ENABLED)
    public void testRenameServer() throws Exception {

        Resource testResource = null;
        MeasurementSchedule sched = null;
        MeasurementBaseline baseline = null;
        EventDefinition eDef = null;

        // Note, plugins are registered in new transactions. for tests, this means
        // you can't do everything in a trans and roll back at the end. You must clean up
        // manually.  Still, some work can be performed transactionally, as done below.
        try {
            registerPlugin("update6-1.xml");
            ResourceType server = getResourceType("testServer1");

            getTransactionManager().begin();

            getPluginId();

            Set<MeasurementDefinition> definitions1 = server.getMetricDefinitions();
            // for metric counts, add one for the built in AvailabilityType metric
            assert definitions1.size() == 2;

            /*
             * Create a Fake Resource and a MeasurementSchedule
             */
            testResource = new Resource("-test-", "-test resource-", server);
            testResource.setUuid("" + new Random().nextInt());
            em.persist(testResource);

            sched = new MeasurementSchedule(definitions1.iterator().next(), testResource);
            em.persist(sched);

View Full Code Here

            assert definitions1.size() == 1;

            /*
             * Create a Fake Resource and a MeasurementSchedule
             */
            Resource testResource = new Resource("-test-", "-test resource", platform);
            testResource.setUuid("" + new Random().nextInt());
            em.persist(testResource);

            setUpAgent(testResource);

            getTransactionManager().commit();
        } catch (Exception e) {
            getTransactionManager().rollback();
            fail("Setup of v1 failed: " + e);
        }

        // Set up done, now replace the plugin with a new one.

        System.out.println("Done with v1");

        try {
            registerPlugin("update7-2.xml");
        } catch (Throwable t) {
            System.err.println(t);
        }

        ResourceType platform = getResourceType("myPlatform7");
        Set<MeasurementDefinition> definitions2 = platform.getMetricDefinitions();
        assert definitions2.size() == 2;

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();
        ResourceCriteria c = new ResourceCriteria();
        c.addFilterResourceTypeId(platform.getId());
        c.addFilterInventoryStatus(InventoryStatus.NEW);
        c.fetchSchedules(true);
        List<Resource> resources = LookupUtil.getResourceManager().findResourcesByCriteria(overlord, c);
        assert resources != null;
        assertEquals(1, resources.size());

        Resource res = resources.get(0);
        Set<MeasurementSchedule> schedules = res.getSchedules();
        assert schedules != null;
        /*
         * We only expect one schedule for the freshly created metric, as the resource we
         * created earlier has no schedule attached yet (in the test).
         * In the "real world" it would get its schedules on inventory sync time.
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.Resource

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.