Package org.osgi.service.monitor

Examples of org.osgi.service.monitor.MonitorAdmin


        }
    }

    @Test
    public void testGetMonitorableNames_NoMonitorableAvailable() throws Exception {
        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);
        String[] monitorableNames = monitorAdmin.getMonitorableNames();
        Assert.assertNotNull(monitorableNames);
        Assert.assertEquals(0, monitorableNames.length);
    }
View Full Code Here


        map.put(new MonitorableMockServiceReference("com.acme.pid2"), new MockMonitorable());
        map.put(new MonitorableMockServiceReference("com.acme.pid3"), new MockMonitorable());
        map.put(new MonitorableMockServiceReference("com.acme.pid1"), new MockMonitorable());
        osgiVisitor.setReferences(map);

        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);

        String[] monitorableNames = monitorAdmin.getMonitorableNames();
        Assert.assertNotNull(monitorableNames);
        Assert.assertEquals(3, monitorableNames.length);
        Assert.assertEquals("com.acme.pid1", monitorableNames[0]);
        Assert.assertEquals("com.acme.pid2", monitorableNames[1]);
        Assert.assertEquals("com.acme.pid3", monitorableNames[2]);
View Full Code Here

    public void testGetMonitorableNames_MonitorableAvailable_InvalidId() throws Exception {
        HashMap<ServiceReference, Monitorable> map = new HashMap<ServiceReference, Monitorable>();
        map.put(new MonitorableMockServiceReference("com.acme.pid2.very.long.monitorable.id"), new MockMonitorable());
        osgiVisitor.setReferences(map);

        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);

        String[] monitorableNames = monitorAdmin.getMonitorableNames();
        Assert.assertNotNull(monitorableNames);
        Assert.assertEquals(0, monitorableNames.length);
    }
View Full Code Here

        monitorable.setStatusVariables(statusVariables);

        map.put(new MonitorableMockServiceReference("com.acme.pid"), monitorable);
        osgiVisitor.setReferences(map);

        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);

        try {
            monitorAdmin.getStatusVariable(null);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getStatusVariable("/&%(/=");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getStatusVariable("com.aaa/sv.id");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getStatusVariable("com.acme.pid/sv.id_u");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        StatusVariable sv = monitorAdmin.getStatusVariable("com.acme.pid/sv.id");
        Assert.assertNotNull(sv);
        Assert.assertEquals("sv.id", sv.getID());
        Assert.assertEquals(StatusVariable.CM_CC, sv.getCollectionMethod());
        Assert.assertEquals(StatusVariable.TYPE_INTEGER, sv.getType());
        Assert.assertEquals(0, sv.getInteger());
View Full Code Here

        monitorable.setStatusVariables(statusVariables);

        map.put(new MonitorableMockServiceReference("com.acme.pid"), monitorable);
        osgiVisitor.setReferences(map);

        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);

        try {
            monitorAdmin.getDescription(null);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getDescription("/&%(/=");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getDescription("com.aaa/sv.id");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getDescription("com.acme.pid/sv.id_u");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        String description = monitorAdmin.getDescription("com.acme.pid/sv.id");
        Assert.assertNotNull(description);
        Assert.assertEquals("sv.id", description);
    }
View Full Code Here

        monitorable.setStatusVariables(statusVariables);

        map.put(new MonitorableMockServiceReference("com.acme.pid"), monitorable);
        osgiVisitor.setReferences(map);

        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);

        try {
            monitorAdmin.getStatusVariables(null);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getStatusVariables("/&%(/=");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getStatusVariables("com.aaa");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        StatusVariable[] variables = monitorAdmin.getStatusVariables("com.acme.pid");
        Assert.assertNotNull(variables);
        Assert.assertEquals(2, variables.length);
        Assert.assertTrue("sv.id1".equals(variables[0].getID()));
        Assert.assertTrue("sv.id2".equals(variables[1].getID()));
    }
View Full Code Here

        monitorable.setStatusVariables(statusVariables);

        map.put(new MonitorableMockServiceReference("com.acme.pid"), monitorable);
        osgiVisitor.setReferences(map);

        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);

        try {
            monitorAdmin.getStatusVariableNames(null);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getStatusVariableNames("/&%(/=");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.getStatusVariableNames("com.aaa");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        String[] names = monitorAdmin.getStatusVariableNames("com.acme.pid");
        Assert.assertNotNull(names);
        Assert.assertEquals(2, names.length);
        Assert.assertTrue("sv.id1".equals(names[0]));
        Assert.assertTrue("sv.id2".equals(names[1]));
    }
View Full Code Here

        monitorable.setNotificationSupport("sv.id1", true);

        map.put(new MonitorableMockServiceReference("com.acme.pid"), monitorable);
        osgiVisitor.setReferences(map);

        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);

        MonitoringJob[] jobs = monitorAdmin.getRunningJobs();
        Assert.assertNotNull(jobs);
        Assert.assertEquals(0, jobs.length);

        MonitoringJob job = monitorAdmin.startJob("initiator", new String[]{"com.acme.pid/sv.id1"}, 1);

        jobs = monitorAdmin.getRunningJobs();
        Assert.assertNotNull(jobs);
        Assert.assertEquals(1, jobs.length);
        Assert.assertTrue(jobs[0].isRunning());

        job.stop();

        jobs = monitorAdmin.getRunningJobs();
        Assert.assertNotNull(jobs);
        Assert.assertEquals(0, jobs.length);
    }
View Full Code Here

        // assert MonitorListener Service
        ServiceAssert.assertServiceAvailable(MonitorListener.class);

        // get MonitorAdmin service
        MonitorAdmin monitorAdmin = ServiceUtils.getService(bc, MonitorAdmin.class);

        // get list of Monitorable names
        String[] monitorableNames = monitorAdmin.getMonitorableNames();
        Assert.assertNotNull(monitorableNames);
        Assert.assertEquals(1, monitorableNames.length);

        // get list of running Monitoring jobs
        MonitoringJob[] runningJobs = monitorAdmin.getRunningJobs();
        Assert.assertNotNull(runningJobs);
        Assert.assertEquals(0, runningJobs.length);

        // get bundle
        Bundle bundle = BundleUtils.findBundle(bc, "org.knowhowlab.osgi.monitoradmin");
View Full Code Here

        monitorable.setNotificationSupport("sv.id1", true);

        map.put(new MonitorableMockServiceReference("com.acme.pid"), monitorable);
        osgiVisitor.setReferences(map);

        MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);

        StatusVariable sv = monitorAdmin.getStatusVariable("com.acme.pid/sv.id1");
        Assert.assertNotNull(sv);
        Assert.assertEquals(0, sv.getInteger());

        monitorable.setNewStatusVariableValue("sv.id1", "15");

        sv = monitorAdmin.getStatusVariable("com.acme.pid/sv.id1");
        Assert.assertNotNull(sv);
        Assert.assertEquals(15, sv.getInteger());

        try {
            monitorAdmin.resetStatusVariable(null);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.resetStatusVariable("/&%(/=");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.resetStatusVariable("com.aaa/sv.id");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.resetStatusVariable("com.acme.pid/sv.id_u");
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        boolean result = monitorAdmin.resetStatusVariable("com.acme.pid/sv.id1");
        Assert.assertTrue(result);

        sv = monitorAdmin.getStatusVariable("com.acme.pid/sv.id1");
        Assert.assertNotNull(sv);
        Assert.assertEquals(0, sv.getInteger());
    }
View Full Code Here

TOP

Related Classes of org.osgi.service.monitor.MonitorAdmin

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.