Package org.osgi.service.monitor

Examples of org.osgi.service.monitor.MonitorAdmin


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

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

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

        try {
            monitorAdmin.switchEvents(null, true);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }
        try {
            monitorAdmin.switchEvents("/&%(/=", true);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }
        try {
            monitorAdmin.switchEvents("com.aaa/sv.id1", true);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }
        try {
            monitorAdmin.switchEvents("com.acme.pid/sv.id_u", true);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.switchEvents("*", true);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }
        try {
            monitorAdmin.switchEvents("**", true);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }
        try {
            monitorAdmin.switchEvents("**/*", true);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        monitorAdmin.switchEvents("com.acme.pid/sv.id1", false);

        String[] paths = common.getDisabledNotificationPaths();
        Assert.assertNotNull(paths);
        Assert.assertEquals(1, paths.length);
        Assert.assertEquals("com.acme.pid/sv.id1", paths[0]);

        monitorAdmin.switchEvents("com.acme.pid/sv.id1", true);
        paths = common.getDisabledNotificationPaths();
        Assert.assertEquals(0, paths.length);

        monitorAdmin.switchEvents("*/sv.id1", false);
        paths = common.getDisabledNotificationPaths();
        Assert.assertEquals(1, paths.length);
        Assert.assertEquals("com.acme.pid/sv.id1", paths[0]);

        monitorAdmin.switchEvents("*/*", true);
        paths = common.getDisabledNotificationPaths();
        Assert.assertEquals(0, paths.length);
    }
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);

        monitorable.setListener(common);
        monitorable.setMonitorableId("com.acme.pid");

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

        Event[] events = osgiVisitor.getPostedEvents();
        Assert.assertEquals(1, events.length);
        Assert.assertEquals(ConstantsMonitorAdmin.TOPIC, events[0].getTopic());
        Assert.assertEquals("com.acme.pid", events[0].getProperty(ConstantsMonitorAdmin.MON_MONITORABLE_PID));
        Assert.assertEquals("sv.id1", events[0].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_NAME));
        Assert.assertEquals("15", events[0].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_VALUE));
        Assert.assertNull(events[0].getProperty(ConstantsMonitorAdmin.MON_LISTENER_ID));

        monitorAdmin.switchEvents("com.acme.pid/sv.id1", false);
        osgiVisitor.cleanPostedEvents();

        monitorable.setNewStatusVariableValue("sv.id1", "25");
        events = osgiVisitor.getPostedEvents();
        Assert.assertEquals(0, events.length);

        monitorAdmin.switchEvents("com.acme.pid/sv.id1", true);
        monitorable.setNewStatusVariableValue("sv.id1", "25");
        events = osgiVisitor.getPostedEvents();
        Assert.assertEquals(1, events.length);
        Assert.assertEquals(ConstantsMonitorAdmin.TOPIC, events[0].getTopic());
        Assert.assertEquals("com.acme.pid", events[0].getProperty(ConstantsMonitorAdmin.MON_MONITORABLE_PID));
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);

        monitorable.setListener(common);
        monitorable.setMonitorableId("com.acme.pid");

        try {
            monitorAdmin.startJob("init1", new String[]{"com.acme.pid/sv.id11"}, 1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.startJob("init1", new String[]{"com.acme.pid/sv.id2"}, 1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.startJob(null, new String[]{"com.acme.pid/sv.id2"}, 1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.startJob("init1", new String[]{"com.acme.pid1/sv.id1"}, 1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.startJob("init1", new String[]{"com.acme.pid/sv.id1"}, -1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

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

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

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

        Event[] events = osgiVisitor.getPostedEvents();
        Assert.assertEquals(2, events.length);
        Assert.assertEquals(ConstantsMonitorAdmin.TOPIC, events[0].getTopic());
        Assert.assertEquals("com.acme.pid", events[0].getProperty(ConstantsMonitorAdmin.MON_MONITORABLE_PID));
        Assert.assertEquals("sv.id1", events[0].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_NAME));
        Assert.assertEquals("15", events[0].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_VALUE));
        Assert.assertNull(events[0].getProperty(ConstantsMonitorAdmin.MON_LISTENER_ID));

        Assert.assertEquals(ConstantsMonitorAdmin.TOPIC, events[1].getTopic());
        Assert.assertEquals("com.acme.pid", events[1].getProperty(ConstantsMonitorAdmin.MON_MONITORABLE_PID));
        Assert.assertEquals("sv.id1", events[1].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_NAME));
        Assert.assertEquals("15", events[1].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_VALUE));
        Assert.assertEquals("init1", events[1].getProperty(ConstantsMonitorAdmin.MON_LISTENER_ID));

        job.stop();
        jobs = monitorAdmin.getRunningJobs();
        Assert.assertEquals(0, jobs.length);

        osgiVisitor.cleanPostedEvents();

        monitorable.setNewStatusVariableValue("sv.id1", "25");
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);

        monitorable.setListener(common);
        monitorable.setMonitorableId("com.acme.pid");

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

        try {
            monitorAdmin.startScheduledJob("init1", new String[]{"com.acme.pid/sv.id11"}, 1, 1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.startScheduledJob("init1", new String[]{"com.acme.pid1/sv.id1"}, 1, 1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.startScheduledJob(null, new String[]{"com.acme.pid1/sv.id1"}, 1, 1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.startScheduledJob("init1", new String[]{"com.acme.pid/sv.id1"}, -1, 1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        try {
            monitorAdmin.startScheduledJob("init1", new String[]{"com.acme.pid/sv.id1"}, 1, -1);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }

        MonitoringJob job = monitorAdmin.startScheduledJob("init1", new String[]{"com.acme.pid/sv.id1"}, 5, 0);

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

        TimeUnit.SECONDS.sleep(7);

        Event[] events = osgiVisitor.getPostedEvents();
        Assert.assertEquals(2, events.length);
        Assert.assertEquals(ConstantsMonitorAdmin.TOPIC, events[0].getTopic());
        Assert.assertEquals("com.acme.pid", events[0].getProperty(ConstantsMonitorAdmin.MON_MONITORABLE_PID));
        Assert.assertEquals("sv.id1", events[0].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_NAME));
        Assert.assertEquals("15", events[0].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_VALUE));
        Assert.assertEquals("init1", events[0].getProperty(ConstantsMonitorAdmin.MON_LISTENER_ID));

        job.stop();
        jobs = monitorAdmin.getRunningJobs();
        Assert.assertEquals(0, jobs.length);

        osgiVisitor.cleanPostedEvents();

        monitorable.setNewStatusVariableValue("sv.id1", "25");
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.