Package org.apache.aries.jmx.test.bundleb.api

Examples of org.apache.aries.jmx.test.bundleb.api.MSF


        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(Constants.SERVICE_PID, "org.apache.aries.jmx.test.ServiceB");
        plainRegistration = context.registerService(InterfaceB.class.getName(), new B(), props);
        Dictionary<String, Object> fprops = new Hashtable<String, Object>();
        fprops.put(Constants.SERVICE_PID, "jmx.test.B.factory");
        msfRegistration = context.registerService(ManagedServiceFactory.class.getName(), new MSF(), fprops);
    }
View Full Code Here


        assertNotNull(managedServiceA);
       
        Filter filter = bundleContext.createFilter("(" + Constants.SERVICE_PID + "=jmx.test.B.factory)");
        ServiceTracker trackerMSF = new ServiceTracker(bundleContext, filter, null);
        trackerMSF.open();
        MSF managedFactory = (MSF) trackerMSF.getService();
        assertNotNull(managedFactory);
       
        ServiceTracker tracker = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
        tracker.open();
        ConfigurationAdmin configAdmin = (ConfigurationAdmin) tracker.getService();
        assertNotNull(configAdmin);
       
        // ManagedService operations
       
        assertNull(managedServiceA.getConfig());
       
        // create a configuration for A
        TabularData data = mbean.getProperties("org.apache.aries.jmx.test.ServiceA");
        assertEquals(0, data.size());
       
        PropertyData<String> p1 = PropertyData.newInstance("A1", "first");
        data.put(p1.toCompositeData());
        PropertyData<Integer> p2 = PropertyData.newInstance("A2", 2);
        data.put(p2.toCompositeData());
       
        mbean.update("org.apache.aries.jmx.test.ServiceA", data);
       
        Thread.sleep(1000);
        Dictionary<String, Object> config = managedServiceA.getConfig();
        assertNotNull(config);
        assertEquals(3, config.size());
        assertEquals("org.apache.aries.jmx.test.ServiceA", config.get(Constants.SERVICE_PID));
        assertEquals("first", config.get("A1"));
        assertEquals(2, config.get("A2"));
       
        //delete
        mbean.deleteForLocation("org.apache.aries.jmx.test.ServiceA", a.getLocation());
       
        Thread.sleep(1000);
        assertNull(managedServiceA.getConfig());
       
       
        // ManagedServiceFactory operations
       
        String cpid = mbean.createFactoryConfiguration("jmx.test.B.factory");
        assertNotNull(cpid);
        assertTrue(cpid.contains("jmx.test.B.factory"));
       
        TabularData fConfig = mbean.getProperties(cpid);
        assertNotNull(fConfig);
        assertEquals(0, fConfig.values().size());
       
        PropertyData<String> prop1 = PropertyData.newInstance("B1", "value1");
        fConfig.put(prop1.toCompositeData());
        PropertyData<Boolean> prop2 = PropertyData.newInstance("B2", true);
        fConfig.put(prop2.toCompositeData());
       
        mbean.update(cpid, fConfig);
       
        Thread.sleep(1000);
       
        InterfaceB configured = managedFactory.getConfigured(cpid);
        assertNotNull(configured);
        config = configured.getConfig();
        assertNotNull(config);
        assertTrue(config.size() >= 4);
        assertEquals("jmx.test.B.factory", config.get(ConfigurationAdmin.SERVICE_FACTORYPID));
        assertEquals(cpid, config.get(Constants.SERVICE_PID));
        assertEquals("value1", config.get("B1"));
        assertEquals("true", config.get("B2"));
       
        assertEquals("jmx.test.B.factory", mbean.getFactoryPid(cpid));
       
        mbean.delete(cpid);
       
        Thread.sleep(1000);
       
        assertNull(managedFactory.getConfigured(cpid));
      
        // list operations
       
        data = mbean.getProperties("org.apache.aries.jmx.test.ServiceA");
        assertEquals(0, data.size());
View Full Code Here

        assertNotNull(managedServiceA);
       
        Filter filter = bundleContext.createFilter("(" + Constants.SERVICE_PID + "=jmx.test.B.factory)");
        ServiceTracker trackerMSF = new ServiceTracker(bundleContext, filter, null);
        trackerMSF.open();
        MSF managedFactory = (MSF) trackerMSF.getService();
        assertNotNull(managedFactory);
       
        ServiceTracker tracker = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
        tracker.open();
        ConfigurationAdmin configAdmin = (ConfigurationAdmin) tracker.getService();
        assertNotNull(configAdmin);
       
        // ManagedService operations
       
        assertNull(managedServiceA.getConfig());
       
        // create a configuration for A
        TabularData data = mbean.getProperties("org.apache.aries.jmx.test.ServiceA");
        assertEquals(0, data.size());
       
        PropertyData<String> p1 = PropertyData.newInstance("A1", "first");
        data.put(p1.toCompositeData());
        PropertyData<Integer> p2 = PropertyData.newInstance("A2", 2);
        data.put(p2.toCompositeData());
       
        mbean.update("org.apache.aries.jmx.test.ServiceA", data);
       
        Thread.sleep(1000);
        Dictionary<String, Object> config = managedServiceA.getConfig();
        assertNotNull(config);
        assertEquals(3, config.size());
        assertEquals("org.apache.aries.jmx.test.ServiceA", config.get(Constants.SERVICE_PID));
        assertEquals("first", config.get("A1"));
        assertEquals(2, config.get("A2"));
       
        //delete
        mbean.deleteForLocation("org.apache.aries.jmx.test.ServiceA", a.getLocation());
       
        Thread.sleep(1000);
        assertNull(managedServiceA.getConfig());
       
       
        // ManagedServiceFactory operations
       
        String cpid = mbean.createFactoryConfiguration("jmx.test.B.factory");
        assertNotNull(cpid);
        assertTrue(cpid.contains("jmx.test.B.factory"));
       
        TabularData fConfig = mbean.getProperties(cpid);
        assertNotNull(fConfig);
        assertEquals(0, fConfig.values().size());
       
        PropertyData<String> prop1 = PropertyData.newInstance("B1", "value1");
        fConfig.put(prop1.toCompositeData());
        PropertyData<Boolean> prop2 = PropertyData.newInstance("B2", true);
        fConfig.put(prop2.toCompositeData());
       
        mbean.update(cpid, fConfig);
       
        Thread.sleep(1000);
       
        InterfaceB configured = managedFactory.getConfigured(cpid);
        assertNotNull(configured);
        config = configured.getConfig();
        assertNotNull(config);
        assertTrue(config.size() >= 4);
        assertEquals("jmx.test.B.factory", config.get(ConfigurationAdmin.SERVICE_FACTORYPID));
        assertEquals(cpid, config.get(Constants.SERVICE_PID));
        assertEquals("value1", config.get("B1"));
        assertEquals("true", config.get("B2"));
       
        assertEquals("jmx.test.B.factory", mbean.getFactoryPid(cpid));
       
        mbean.delete(cpid);
       
        Thread.sleep(1000);
       
        assertNull(managedFactory.getConfigured(cpid));
      
        // list operations
       
        data = mbean.getProperties("org.apache.aries.jmx.test.ServiceA");
        assertEquals(0, data.size());
View Full Code Here

        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(Constants.SERVICE_PID, "org.apache.aries.jmx.test.ServiceB");
        plainRegistration = context.registerService(InterfaceB.class.getName(), new B(), props);
        Dictionary<String, Object> fprops = new Hashtable<String, Object>();
        fprops.put(Constants.SERVICE_PID, "jmx.test.B.factory");
        msfRegistration = context.registerService(ManagedServiceFactory.class.getName(), new MSF(), fprops);
    }
View Full Code Here

        assertNotNull(managedServiceA);
       
        Filter filter = bundleContext.createFilter("(" + Constants.SERVICE_PID + "=jmx.test.B.factory)");
        ServiceTracker trackerMSF = new ServiceTracker(bundleContext, filter, null);
        trackerMSF.open();
        MSF managedFactory = (MSF) trackerMSF.getService();
        assertNotNull(managedFactory);
       
        ServiceTracker tracker = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
        tracker.open();
        ConfigurationAdmin configAdmin = (ConfigurationAdmin) tracker.getService();
        assertNotNull(configAdmin);
       
        // ManagedService operations
       
        assertNull(managedServiceA.getConfig());
       
        // create a configuration for A
        TabularData data = mbean.getProperties("org.apache.aries.jmx.test.ServiceA");
        assertEquals(0, data.size());
       
        PropertyData<String> p1 = PropertyData.newInstance("A1", "first");
        data.put(p1.toCompositeData());
        PropertyData<Integer> p2 = PropertyData.newInstance("A2", 2);
        data.put(p2.toCompositeData());
       
        mbean.update("org.apache.aries.jmx.test.ServiceA", data);
       
        Thread.sleep(1000);
        Dictionary<String, Object> config = managedServiceA.getConfig();
        assertNotNull(config);
        assertEquals(3, config.size());
        assertEquals("org.apache.aries.jmx.test.ServiceA", config.get(Constants.SERVICE_PID));
        assertEquals("first", config.get("A1"));
        assertEquals(2, config.get("A2"));
       
        //delete
        mbean.deleteForLocation("org.apache.aries.jmx.test.ServiceA", a.getLocation());
       
        Thread.sleep(1000);
        assertNull(managedServiceA.getConfig());
       
       
        // ManagedServiceFactory operations
       
        String cpid = mbean.createFactoryConfiguration("jmx.test.B.factory");
        assertNotNull(cpid);
        assertTrue(cpid.contains("jmx.test.B.factory"));
       
        TabularData fConfig = mbean.getProperties(cpid);
        assertNotNull(fConfig);
        assertEquals(0, fConfig.values().size());
       
        PropertyData<String> prop1 = PropertyData.newInstance("B1", "value1");
        fConfig.put(prop1.toCompositeData());
        PropertyData<Boolean> prop2 = PropertyData.newInstance("B2", true);
        fConfig.put(prop2.toCompositeData());
       
        mbean.update(cpid, fConfig);
       
        Thread.sleep(1000);
       
        InterfaceB configured = managedFactory.getConfigured(cpid);
        assertNotNull(configured);
        config = configured.getConfig();
        assertNotNull(config);
        assertTrue(config.size() >= 4);
        assertEquals("jmx.test.B.factory", config.get(ConfigurationAdmin.SERVICE_FACTORYPID));
        assertEquals(cpid, config.get(Constants.SERVICE_PID));
        assertEquals("value1", config.get("B1"));
        assertEquals("true", config.get("B2"));
       
        assertEquals("jmx.test.B.factory", mbean.getFactoryPid(cpid));
       
        mbean.delete(cpid);
       
        Thread.sleep(1000);
       
        assertNull(managedFactory.getConfigured(cpid));
      
        // list operations
       
        data = mbean.getProperties("org.apache.aries.jmx.test.ServiceA");
        assertEquals(0, data.size());
View Full Code Here

        assertNotNull(managedServiceA);
       
        Filter filter = bundleContext.createFilter("(" + Constants.SERVICE_PID + "=jmx.test.B.factory)");
        ServiceTracker trackerMSF = new ServiceTracker(bundleContext, filter, null);
        trackerMSF.open();
        MSF managedFactory = (MSF) trackerMSF.getService();
        assertNotNull(managedFactory);
       
        ServiceTracker tracker = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
        tracker.open();
        ConfigurationAdmin configAdmin = (ConfigurationAdmin) tracker.getService();
        assertNotNull(configAdmin);
       
        // ManagedService operations
       
        assertNull(managedServiceA.getConfig());
       
        // create a configuration for A
        TabularData data = mbean.getProperties("org.apache.aries.jmx.test.ServiceA");
        assertEquals(0, data.size());
       
        PropertyData<String> p1 = PropertyData.newInstance("A1", "first");
        data.put(p1.toCompositeData());
        PropertyData<Integer> p2 = PropertyData.newInstance("A2", 2);
        data.put(p2.toCompositeData());
       
        mbean.update("org.apache.aries.jmx.test.ServiceA", data);
       
        Thread.sleep(1000);
        Dictionary<String, Object> config = managedServiceA.getConfig();
        assertNotNull(config);
        assertEquals(3, config.size());
        assertEquals("org.apache.aries.jmx.test.ServiceA", config.get(Constants.SERVICE_PID));
        assertEquals("first", config.get("A1"));
        assertEquals(2, config.get("A2"));
       
        //delete
        mbean.deleteForLocation("org.apache.aries.jmx.test.ServiceA", a.getLocation());
       
        Thread.sleep(1000);
        assertNull(managedServiceA.getConfig());
       
       
        // ManagedServiceFactory operations
       
        String cpid = mbean.createFactoryConfiguration("jmx.test.B.factory");
        assertNotNull(cpid);
        assertTrue(cpid.contains("jmx.test.B.factory"));
       
        TabularData fConfig = mbean.getProperties(cpid);
        assertNotNull(fConfig);
        assertEquals(0, fConfig.values().size());
       
        PropertyData<String> prop1 = PropertyData.newInstance("B1", "value1");
        fConfig.put(prop1.toCompositeData());
        PropertyData<Boolean> prop2 = PropertyData.newInstance("B2", true);
        fConfig.put(prop2.toCompositeData());
       
        mbean.update(cpid, fConfig);
       
        Thread.sleep(1000);
       
        InterfaceB configured = managedFactory.getConfigured(cpid);
        assertNotNull(configured);
        config = configured.getConfig();
        assertNotNull(config);
        assertTrue(config.size() >= 4);
        assertEquals("jmx.test.B.factory", config.get(ConfigurationAdmin.SERVICE_FACTORYPID));
        assertEquals(cpid, config.get(Constants.SERVICE_PID));
        assertEquals("value1", config.get("B1"));
        assertEquals("true", config.get("B2"));
       
        assertEquals("jmx.test.B.factory", mbean.getFactoryPid(cpid));
       
        mbean.delete(cpid);
       
        Thread.sleep(1000);
       
        assertNull(managedFactory.getConfigured(cpid));
      
        // list operations
       
        data = mbean.getProperties("org.apache.aries.jmx.test.ServiceA");
        assertEquals(0, data.size());
View Full Code Here

TOP

Related Classes of org.apache.aries.jmx.test.bundleb.api.MSF

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.