Package javax.management.openmbean

Examples of javax.management.openmbean.TabularData


        assertEquals("The blueprint bundle ids are: " + Arrays.toString(bpBundleIds), 3, bpBundleIds.length);
        // test getLastEvent
        BlueprintEventValidator sampleValidator = new BlueprintEventValidator(sampleBundleId, extenderBundleId, 2);
        sampleValidator.validate(stateProxy.getLastEvent(sampleBundleId));
        // test getLastEvents
        TabularData lastEvents = stateProxy.getLastEvents();
        assertEquals(BlueprintStateMBean.OSGI_BLUEPRINT_EVENTS_TYPE,lastEvents.getTabularType());
        sampleValidator.validate(lastEvents.get(new Long[]{sampleBundleId}));
       
        //////////////////////////////
        //Test BlueprintMetadataMBean
        //////////////////////////////
       
View Full Code Here


        // 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);
       
View Full Code Here

        long[] importingBundlesId = packagaState
                .getImportingBundles("org.osgi.jmx.framework", "1.5.0", exportingBundles[0]);
        assertTrue("Should find bundles importing org.osgi.jmx.framework", importingBundlesId.length > 0);

        TabularData table = packagaState.listPackages();
        assertNotNull("TabularData containing CompositeData with packages info shouldn't be null", table);
        assertEquals("TabularData should be a type PACKAGES", PackageStateMBean.PACKAGES_TYPE, table.getTabularType());
        Collection colData = table.values();
        assertNotNull("Collection of CompositeData shouldn't be null", colData);
        assertFalse("Collection of CompositeData should contain elements", colData.isEmpty());

        boolean isRemovalPending = packagaState.isRemovalPending("org.osgi.jmx.framework", "1.5.0", exportingBundles[0]);
        assertFalse("Should removal pending on org.osgi.jmx.framework be false", isRemovalPending);
View Full Code Here

        assertEquals(1, fragments.length);
        assertEquals(frag.getBundleId() , fragments[0]);

        //headers

        TabularData headers = mbean.getHeaders(b.getBundleId());
        assertNotNull(headers);
        assertEquals(BundleStateMBean.HEADERS_TYPE, headers.getTabularType());
        assertTrue(headers.values().size() >= 4 );
        assertEquals("org.apache.aries.jmx.test.bundleb", Header.from(headers.get(new Object[] {Constants.BUNDLE_SYMBOLICNAME})).getValue());

        //hosts

        long[] hosts = mbean.getHosts(frag.getBundleId());
        assertEquals(1, hosts.length);
        assertEquals(a.getBundleId() , hosts[0]);

        //imported packages

        String[] imports = mbean.getImportedPackages(a.getBundleId());
        assertTrue(imports.length >= 3);
        List<String> importedPackages = Arrays.asList(imports);

        Version version = getPackageVersion("org.osgi.framework");
        assertTrue(importedPackages.contains("org.osgi.framework;" + version.toString()));
        assertTrue(importedPackages.contains("org.apache.aries.jmx.test.bundleb.api;1.1.0"));

        //last modified

        assertTrue(mbean.getLastModified(b.getBundleId()) > 0);

        //location

        assertEquals(b.getLocation(), mbean.getLocation(b.getBundleId()));

        //registered services

        long[] serviceIds = mbean.getRegisteredServices(a.getBundleId());
        assertEquals(1, serviceIds.length);

        //required bundles

        long[] required = mbean.getRequiredBundles(d.getBundleId());
        assertEquals(1, required.length);
        assertEquals(a.getBundleId(), required[0]);

        //requiring bundles

        long[] requiring = mbean.getRequiringBundles(a.getBundleId());
        assertEquals(3, requiring.length);
        assertTrue(b.getSymbolicName(), arrayContains(b.getBundleId(), requiring));
        assertTrue(frag.getSymbolicName(), arrayContains(frag.getBundleId(), requiring));
        assertTrue(d.getSymbolicName(), arrayContains(d.getBundleId(), requiring));

        //services in use

        long[] servicesInUse = mbean.getServicesInUse(a.getBundleId());
        assertEquals(1, servicesInUse.length);

        //start level

        long startLevel = mbean.getStartLevel(b.getBundleId());
        assertTrue(startLevel >= 0);

        //state

        assertEquals("ACTIVE", mbean.getState(b.getBundleId()));

        //isFragment

        assertFalse(mbean.isFragment(b.getBundleId()));
        assertTrue(mbean.isFragment(frag.getBundleId()));

        //isRemovalPending
        assertFalse(mbean.isRemovalPending(b.getBundleId()));

        // isRequired

        assertTrue(mbean.isRequired(a.getBundleId()));
        assertTrue(mbean.isRequired(b.getBundleId()));

        // listBundles

        TabularData bundlesTable = mbean.listBundles();
        assertNotNull(bundlesTable);
        assertEquals(BundleStateMBean.BUNDLES_TYPE, bundlesTable.getTabularType());
        assertEquals(bundleContext.getBundles().length, bundlesTable.values().size());


        // notifications

        final List<Notification> received = new ArrayList<Notification>();
View Full Code Here

        assertTrue(classNames.contains(InterfaceA.class.getName()));
        assertTrue(classNames.contains(ManagedService.class.getName()));
       
        // getProperties
       
        TabularData serviceProperties = mbean.getProperties(serviceBId);
        assertNotNull(serviceProperties);
        assertEquals(JmxConstants.PROPERTIES_TYPE, serviceProperties.getTabularType());
        assertTrue(serviceProperties.values().size() > 1);
        assertEquals("org.apache.aries.jmx.test.ServiceB",
                PropertyData.from(serviceProperties.get(new Object[] { Constants.SERVICE_PID })).getValue());
       
        // getUsingBundles
       
        long[] usingBundles = mbean.getUsingBundles(serviceBId);
        assertEquals(1, usingBundles.length);
        assertEquals(a.getBundleId(), usingBundles[0]);
       
        // listServices
       
        TabularData allServices = mbean.listServices();
        assertNotNull(allServices);
        assertEquals(bundleContext.getAllServiceReferences(null, null).length, allServices.values().size());
       
        // notifications
       
        final List<Notification> received = new ArrayList<Notification>();
     
View Full Code Here

        assertEquals(1, fragments.length);
        assertEquals(frag.getBundleId() , fragments[0]);
      
        //headers

        TabularData headers = mbean.getHeaders(b.getBundleId());
        assertNotNull(headers);
        assertEquals(BundleStateMBean.HEADERS_TYPE, headers.getTabularType());
        assertTrue(headers.values().size() >= 4 );
        assertEquals("org.apache.aries.jmx.test.bundleb", Header.from(headers.get(new Object[] {Constants.BUNDLE_SYMBOLICNAME})).getValue());
       
        //hosts
       
        long[] hosts = mbean.getHosts(frag.getBundleId());
        assertEquals(1, hosts.length);
        assertEquals(a.getBundleId() , hosts[0]);
       
        //imported packages
          
        String[] imports = mbean.getImportedPackages(a.getBundleId());
        assertTrue(imports.length >= 3);
        List<String> importedPackages = Arrays.asList(imports);
        assertTrue(importedPackages.contains("org.osgi.framework;1.5.0"));
        assertTrue(importedPackages.contains("org.apache.aries.jmx.test.bundleb.api;1.1.0"));
       
        //last modified
       
        assertTrue(mbean.getLastModified(b.getBundleId()) > 0);
       
        //location
       
        assertEquals(b.getLocation(), mbean.getLocation(b.getBundleId()));
       
        //registered services
       
        long[] serviceIds = mbean.getRegisteredServices(a.getBundleId());
        assertEquals(1, serviceIds.length);
       
        //required bundles
       
        long[] required = mbean.getRequiredBundles(d.getBundleId());
        assertEquals(1, required.length);
        assertEquals(a.getBundleId(), required[0]);
       
        //requiring bundles
       
        long[] requiring = mbean.getRequiringBundles(a.getBundleId());
        assertEquals(3, requiring.length);
        assertTrue(b.getSymbolicName(), arrayContains(b.getBundleId(), requiring));
        assertTrue(frag.getSymbolicName(), arrayContains(frag.getBundleId(), requiring));
        assertTrue(d.getSymbolicName(), arrayContains(d.getBundleId(), requiring));
       
        //services in use
       
        long[] servicesInUse = mbean.getServicesInUse(a.getBundleId());
        assertEquals(1, servicesInUse.length);
       
        //start level
       
        long startLevel = mbean.getStartLevel(b.getBundleId());
        assertTrue(startLevel >= 0);
       
        //state
       
        assertEquals("ACTIVE", mbean.getState(b.getBundleId()));
       
        //isFragment
       
        assertFalse(mbean.isFragment(b.getBundleId()));
        assertTrue(mbean.isFragment(frag.getBundleId()));
       
        //isRemovalPending
        assertFalse(mbean.isRemovalPending(b.getBundleId()));
       
        // isRequired
      
        assertTrue(mbean.isRequired(a.getBundleId()));
        assertTrue(mbean.isRequired(b.getBundleId()));
       
        // listBundles
       
        TabularData bundlesTable = mbean.listBundles();
        assertNotNull(bundlesTable);
        assertEquals(BundleStateMBean.BUNDLES_TYPE, bundlesTable.getTabularType());
        assertEquals(bundleContext.getBundles().length, bundlesTable.values().size());
       
       
        // notifications
       
        final List<Notification> received = new ArrayList<Notification>();
View Full Code Here

        assertTrue(classNames.contains(InterfaceA.class.getName()));
        assertTrue(classNames.contains(ManagedService.class.getName()));
       
        // getProperties
       
        TabularData serviceProperties = mbean.getProperties(serviceBId);
        assertNotNull(serviceProperties);
        assertEquals(JmxConstants.PROPERTIES_TYPE, serviceProperties.getTabularType());
        assertTrue(serviceProperties.values().size() > 1);
        assertEquals("org.apache.aries.jmx.test.ServiceB",
                PropertyData.from(serviceProperties.get(new Object[] { Constants.SERVICE_PID })).getValue());
       
        // getUsingBundles
       
        long[] usingBundles = mbean.getUsingBundles(serviceBId);
        assertEquals(1, usingBundles.length);
        assertEquals(a.getBundleId(), usingBundles[0]);
       
        // listServices
       
        TabularData allServices = mbean.listServices();
        assertNotNull(allServices);
        assertEquals(bundleContext.getAllServiceReferences(null, null).length, allServices.values().size());
       
        // notifications
       
        final List<Notification> received = new ArrayList<Notification>();
     
View Full Code Here

        assertArrayEquals(new byte[] { 10, 20, 30 }, config);
       
       
        // test list information
       
        TabularData data = mbean.listInformation();
        assertNotNull(data);
        assertEquals(JmxConstants.PROPERTIES_TYPE, data.getTabularType());
        assertTrue(data.values().size() >= 1);
        PropertyData<byte[]> configEntry = PropertyData.from(data.get(new Object[] {PROVISIONING_AGENT_CONFIG }));
        assertNotNull(configEntry);
        assertArrayEquals(new byte[] { 10, 20, 30 }, configEntry.getValue());

       
        // test add information
       
        PropertyData<String> reference = PropertyData.newInstance(PROVISIONING_REFERENCE, "rsh://0.0.0.0/provX");
        data.put(reference.toCompositeData());
       
        mbean.addInformation(data);
       
        info = ps.getInformation();
        assertNotNull(info);
        assertTrue(info.size() >= 2);
        config = (byte[]) info.get(PROVISIONING_AGENT_CONFIG);
        assertNotNull(config);
        assertArrayEquals(new byte[] { 10, 20, 30 }, config);
        String ref = (String) info.get(PROVISIONING_REFERENCE);
        assertNotNull(ref);
        assertEquals("rsh://0.0.0.0/provX", ref);
       
       
        // test set information
       
        data.clear();
        PropertyData<String> newRef = PropertyData.newInstance(PROVISIONING_REFERENCE, "rsh://0.0.0.0/newProvRef");
        data.put(newRef.toCompositeData());
       
        mbean.setInformation(data);
        info = ps.getInformation();
        assertNotNull(info);
        assertTrue(info.size() >= 1);
View Full Code Here

        BundleData b = new BundleData(context, bundle, packageAdmin, startLevel);
        CompositeData compositeData = b.toCompositeData();
       
        assertEquals("test", compositeData.get(SYMBOLIC_NAME));
        assertEquals("0.0.0", (String) compositeData.get(VERSION));
        TabularData headerTable = (TabularData) compositeData.get(HEADERS);
        assertEquals(4, headerTable.values().size());
        CompositeData header = headerTable.get(new Object[]{Constants.BUNDLE_SYMBOLICNAME});
        assertNotNull(header);
        String value = (String) header.get(VALUE);
        assertEquals("test", value);
        String key = (String)header.get(KEY);
        assertEquals(Constants.BUNDLE_SYMBOLICNAME, key);
       
       
        TabularData bundleTable = new TabularDataSupport(BUNDLES_TYPE);
        bundleTable.put(b.toCompositeData());
  
        CompositeData bundleData = bundleTable.get(new Object[]{Long.valueOf(1)});
        assertNotNull(bundleData);
        String location = (String) bundleData.get(LOCATION);
        assertEquals("location", location);
       
        assertArrayEquals(new String[] { "org.apache.aries.jmx;1.0.0"} , (String[]) compositeData.get(EXPORTED_PACKAGES));
View Full Code Here

        items.put(SERVICES_IN_USE, new Long[] { new Long(15), new Long(16), new Long(17) });
        items.put(START_LEVEL, 1);
        items.put(STATE, "ACTIVE");
        items.put(SYMBOLIC_NAME, "test");
        items.put(VERSION, "0.0.0");
        TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
        headerTable.put(new Header("a", "a").toCompositeData());
        headerTable.put(new Header("b", "b").toCompositeData());
        items.put(HEADERS, headerTable);
        CompositeData compositeData = new CompositeDataSupport(BUNDLE_TYPE, items);
       
        BundleData b = BundleData.from(compositeData);
       
View Full Code Here

TOP

Related Classes of javax.management.openmbean.TabularData

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.