Package org.osgi.service.provisioning

Examples of org.osgi.service.provisioning.ProvisioningService


        ProvisioningServiceMBean mbean = getMBean(ProvisioningServiceMBean.OBJECTNAME, ProvisioningServiceMBean.class);
        assertNotNull(mbean);
       
        ServiceTracker tracker = new ServiceTracker(bundleContext, ProvisioningService.class.getName(), null);
        tracker.open();
        ProvisioningService ps = (ProvisioningService) tracker.getService();
        assertNotNull(ps);
       
        Dictionary<String, Object> info;
       
        // add information URL (create temp zip file)
       
        File  provZip = File.createTempFile("Prov-jmx-itests", ".zip");
        Manifest man = new Manifest();
        man.getMainAttributes().putValue("Manifest-Version", "1.0");
        man.getMainAttributes().putValue("Content-Type", "application/zip");
        JarOutputStream jout = new JarOutputStream(new FileOutputStream(provZip), man);
        ZipEntry entry = new ZipEntry(PROVISIONING_AGENT_CONFIG);
        jout.putNextEntry( entry );
        jout.write(new byte[] { 10, 20, 30 });
        jout.closeEntry();
        jout.flush();
        jout.close();
       
        provZip.deleteOnExit();
       
        mbean.addInformationFromZip(provZip.toURL().toExternalForm());
       
        //check the info has been added
       
        info = ps.getInformation();
        assertNotNull(info);
        assertTrue(info.size() >= 1);
        byte[] config = (byte[]) info.get(PROVISIONING_AGENT_CONFIG);
        assertNotNull(config);
        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);
        assertNull(info.get(PROVISIONING_AGENT_CONFIG));
      
        ref = (String) info.get(PROVISIONING_REFERENCE);
View Full Code Here


        ProvisioningServiceMBean mbean = getMBean(ProvisioningServiceMBean.OBJECTNAME, ProvisioningServiceMBean.class);
        assertNotNull(mbean);
       
        ServiceTracker tracker = new ServiceTracker(bundleContext, ProvisioningService.class.getName(), null);
        tracker.open();
        ProvisioningService ps = (ProvisioningService) tracker.getService();
        assertNotNull(ps);
       
        Dictionary<String, Object> info;
       
        // add information URL (create temp zip file)
       
        File  provZip = File.createTempFile("Prov-jmx-itests", ".zip");
        Manifest man = new Manifest();
        man.getMainAttributes().putValue("Manifest-Version", "1.0");
        man.getMainAttributes().putValue("Content-Type", "application/zip");
        JarOutputStream jout = new JarOutputStream(new FileOutputStream(provZip), man);
        ZipEntry entry = new ZipEntry(PROVISIONING_AGENT_CONFIG);
        jout.putNextEntry( entry );
        jout.write(new byte[] { 10, 20, 30 });
        jout.closeEntry();
        jout.flush();
        jout.close();
       
        provZip.deleteOnExit();
       
        mbean.addInformationFromZip(provZip.toURL().toExternalForm());
       
        //check the info has been added
       
        info = ps.getInformation();
        assertNotNull(info);
        assertTrue(info.size() >= 1);
        byte[] config = (byte[]) info.get(PROVISIONING_AGENT_CONFIG);
        assertNotNull(config);
        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);
        assertNull(info.get(PROVISIONING_AGENT_CONFIG));
      
        ref = (String) info.get(PROVISIONING_REFERENCE);
View Full Code Here

  private void foundProvisioningService(final ServiceReference reference)
  {
    registerMBean(ProvisioningServiceMBean.class.getName(), new Factory<ProvisioningServiceMBean>() {
        public ProvisioningServiceMBean create()
        {
          ProvisioningService service = (ProvisioningService) ctx.getService(reference);

          if (service == null) return null;
          else return new org.apache.aries.jmx.provisioning.ProvisioningService(service);
        }
      }, ProvisioningServiceMBean.OBJECTNAME, _provisioningMBeans, reference, PROVISIONING_SERVICE);
View Full Code Here

    public void testConstructInjectMBean() {
       
        BundleContext bundleContext = mock(BundleContext.class);
        Logger agentLogger = mock(Logger.class);  
        JMXAgentContext agentContext = new JMXAgentContext(bundleContext, null, agentLogger);
        ProvisioningService provService = mock(ProvisioningService.class);
       
        ProvisioningServiceMBeanHandler handler = new ProvisioningServiceMBeanHandler(agentContext);
        StandardMBean mbean = handler.constructInjectMBean(provService);
        assertNotNull(mbean);
       
View Full Code Here

  private void foundProvisioningService(final ServiceReference reference)
  {
    registerMBean(ProvisioningServiceMBean.class.getName(), new Factory<ProvisioningServiceMBean>() {
        public ProvisioningServiceMBean create()
        {
          ProvisioningService service = (ProvisioningService) ctx.getService(reference);
         
          if (service == null) return null;
          else return new org.apache.aries.jmx.provisioning.ProvisioningService(service);
        }
      }, ProvisioningServiceMBean.OBJECTNAME, _provisioningMBeans, reference, PROVISIONING_SERVICE);
View Full Code Here

     * osgi.framework.ServiceReference)
     */
    public Object addingService(ServiceReference reference) {
      log.fine("Registering provisioning service with MBeanServer: "
          + mbeanServer + " with name: " + name);
      ProvisioningService admin = (ProvisioningService) bundleContext
          .getService(reference);
      try {
        provisioning = new StandardMBean(new Provisioning(admin),
            ProvisioningMBean.class);
      } catch (NotCompliantMBeanException e1) {
View Full Code Here

    public void testConstructInjectMBean() {
       
        BundleContext bundleContext = mock(BundleContext.class);
        Logger agentLogger = mock(Logger.class);  
        JMXAgentContext agentContext = new JMXAgentContext(bundleContext, null, agentLogger);
        ProvisioningService provService = mock(ProvisioningService.class);
       
        ProvisioningServiceMBeanHandler handler = new ProvisioningServiceMBeanHandler(agentContext);
        StandardMBean mbean = handler.constructInjectMBean(provService);
        assertNotNull(mbean);
       
View Full Code Here

    public void testConstructInjectMBean() {
       
        BundleContext bundleContext = mock(BundleContext.class);
        Logger agentLogger = mock(Logger.class);  
        JMXAgentContext agentContext = new JMXAgentContext(bundleContext, null, agentLogger);
        ProvisioningService provService = mock(ProvisioningService.class);
       
        ProvisioningServiceMBeanHandler handler = new ProvisioningServiceMBeanHandler(agentContext);
        StandardMBean mbean = handler.constructInjectMBean(provService);
        assertNotNull(mbean);
       
View Full Code Here

        ProvisioningServiceMBean mbean = getMBean(ProvisioningServiceMBean.OBJECTNAME, ProvisioningServiceMBean.class);
        assertNotNull(mbean);
       
        ServiceTracker tracker = new ServiceTracker(bundleContext, ProvisioningService.class.getName(), null);
        tracker.open();
        ProvisioningService ps = (ProvisioningService) tracker.getService();
        assertNotNull(ps);
       
        Dictionary<String, Object> info;
       
        // add information URL (create temp zip file)
       
        File  provZip = File.createTempFile("Prov-jmx-itests", ".zip");
        Manifest man = new Manifest();
        man.getMainAttributes().putValue("Manifest-Version", "1.0");
        man.getMainAttributes().putValue("Content-Type", "application/zip");
        JarOutputStream jout = new JarOutputStream(new FileOutputStream(provZip), man);
        ZipEntry entry = new ZipEntry(PROVISIONING_AGENT_CONFIG);
        jout.putNextEntry( entry );
        jout.write(new byte[] { 10, 20, 30 });
        jout.closeEntry();
        jout.flush();
        jout.close();
       
        provZip.deleteOnExit();
       
        mbean.addInformationFromZip(provZip.toURL().toExternalForm());
       
        //check the info has been added
       
        info = ps.getInformation();
        assertNotNull(info);
        assertTrue(info.size() >= 1);
        byte[] config = (byte[]) info.get(PROVISIONING_AGENT_CONFIG);
        assertNotNull(config);
        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);
        assertNull(info.get(PROVISIONING_AGENT_CONFIG));
      
        ref = (String) info.get(PROVISIONING_REFERENCE);
View Full Code Here

        ProvisioningServiceMBean mbean = getMBean(ProvisioningServiceMBean.OBJECTNAME, ProvisioningServiceMBean.class);
        assertNotNull(mbean);
       
        ServiceTracker tracker = new ServiceTracker(bundleContext, ProvisioningService.class.getName(), null);
        tracker.open();
        ProvisioningService ps = (ProvisioningService) tracker.getService();
        assertNotNull(ps);
       
        Dictionary<String, Object> info;
       
        // add information URL (create temp zip file)
       
        File  provZip = File.createTempFile("Prov-jmx-itests", ".zip");
        Manifest man = new Manifest();
        man.getMainAttributes().putValue("Manifest-Version", "1.0");
        man.getMainAttributes().putValue("Content-Type", "application/zip");
        JarOutputStream jout = new JarOutputStream(new FileOutputStream(provZip), man);
        ZipEntry entry = new ZipEntry(PROVISIONING_AGENT_CONFIG);
        jout.putNextEntry( entry );
        jout.write(new byte[] { 10, 20, 30 });
        jout.closeEntry();
        jout.flush();
        jout.close();
       
        provZip.deleteOnExit();
       
        mbean.addInformationFromZip(provZip.toURL().toExternalForm());
       
        //check the info has been added
       
        info = ps.getInformation();
        assertNotNull(info);
        assertTrue(info.size() >= 1);
        byte[] config = (byte[]) info.get(PROVISIONING_AGENT_CONFIG);
        assertNotNull(config);
        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);
        assertNull(info.get(PROVISIONING_AGENT_CONFIG));
      
        ref = (String) info.get(PROVISIONING_REFERENCE);
View Full Code Here

TOP

Related Classes of org.osgi.service.provisioning.ProvisioningService

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.