Package org.rhq.enterprise.server.test

Examples of org.rhq.enterprise.server.test.TransactionCallback


    }

    @Test(enabled = ENABLE_TESTS)
    public void testGetResourceAvailabilities_2() throws Exception {

        executeInTransaction(false, new TransactionCallback() {
            public void execute() throws Exception {
                setupResource();
            }
        });
        // platform: UNKNOWN(0) -->       
View Full Code Here


    }

    @Test(enabled = ENABLE_TESTS)
    public void testGetResourceGroupAvailabilities() throws Exception {

        executeInTransaction(false, new TransactionCallback() {
            public void execute() throws Exception {
                setupResource();
                setupAnotherResource(1, theResource);
                setupAnotherResource(2, theResource);
            }
        });

        // Create some various group availability situations:
        //  T:  0         10000     20000    30000    40000
        // R1:  UNKNOWN   DOWN      UP        
        // R2:  UNKNOWN   DOWN      UP     
        // R3:  UNKNOWN   DOWN               UP       DISABLED 
        // ----------------------------------------------------------
        // AV:  WARN      DOWN      WARN     UP       DISABLED

        final Resource r1 = theResource;
        final Resource r2 = additionalResources.get(0);
        final Resource r3 = additionalResources.get(1);

        AvailabilityReport report = new AvailabilityReport(false, theAgent.getName());

        report.addAvailability(new Availability(r1, 10000L, DOWN));
        report.addAvailability(new Availability(r2, 10000L, DOWN));
        report.addAvailability(new Availability(r3, 10000L, DOWN));
        report.addAvailability(new Availability(r1, 20000L, UP));
        report.addAvailability(new Availability(r2, 20000L, UP));
        report.addAvailability(new Availability(r3, 30000L, UP));
        report.addAvailability(new Availability(r3, 40000L, DISABLED));
        availabilityManager.mergeAvailabilityReport(report);

        executeInTransaction(new TransactionCallback() {
            public void execute() throws Exception {
                // Create the test group
                final Subject subject = SessionTestHelper.createNewSubject(em, "testSubject");
                final Role roleWithSubject = SessionTestHelper
                    .createNewRoleForSubject(em, subject, "role with subject");
View Full Code Here

        templateDef.setPinned(true);

        final DriftDefinitionTemplate template = templateMgr.createTemplate(getOverlord(), resourceType.getId(), true,
            templateDef);

        executeInTransaction(false, new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                EntityManager em = getEntityManager();

                em.persist(driftFile1);
View Full Code Here

                return newTestData;
            }
        });
        testData.setResources(new ArrayList<Resource>(NUMBER_OF_RESOURCES_TO_CREATE));
        while (testData.getResources().size() < NUMBER_OF_RESOURCES_TO_CREATE) {
            executeInTransaction(false, new TransactionCallback() {
                // Create resources in batches to avoid too big transactions
                @Override
                public void execute() throws Exception {
                    for (int i = 0; i < 50 && testData.getResources().size() < NUMBER_OF_RESOURCES_TO_CREATE; i++) {
                        testData.getResources().add(
View Full Code Here

        }
    }

    private void removeEntity(final Class<?> entityClass, final Object entityId) {
        try {
            executeInTransaction(false, new TransactionCallback() {
                @Override
                public void execute() throws Exception {
                    Object object = em.find(entityClass, entityId);
                    if (object instanceof Resource) {
                        ResourceTreeHelper.deleteResource(em, (Resource) object);
View Full Code Here

        }
    }

    private void removeAlerts() {
        try {
            executeInTransaction(false, new TransactionCallback() {
                @Override
                public void execute() throws Exception {
                    alertManager.deleteAlertsByContext(subjectManager.getOverlord(), EntityContext.forSubsystemView());
                }
            });
View Full Code Here

        }
    }

    private void removeEntity(final Class<?> entityClass, final Object entityId) {
        try {
            executeInTransaction(false, new TransactionCallback() {
                @Override
                public void execute() throws Exception {
                    Object object = em.find(entityClass, entityId);
                    if (object instanceof Resource) {
                        ResourceTreeHelper.deleteResource(em, (Resource) object);
View Full Code Here

        }
    }

    @Test
    public void testDeleteAlertsByResourceContext() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                int resourceAlertDefinitionId = createResourceAlertDefinitionAndGetId("fake resource alertdef");
                alertManager.fireAlert(resourceAlertDefinitionId);
View Full Code Here

        });
    }

    @Test
    public void testDeleteAlertsByGroupContext() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                int resourceAlertDefinitionId = createResourceAlertDefinitionAndGetId("fake resource alertdef");
                alertManager.fireAlert(resourceAlertDefinitionId);
View Full Code Here

        });
    }

    @Test
    public void testAcknowledgeAlertCriteria() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                int resourceAlertDefinitionId = createResourceAlertDefinitionAndGetId("fake resource alertdef");
                alertManager.fireAlert(resourceAlertDefinitionId);
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.test.TransactionCallback

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.