Package org.apache.felix.ipojo.architecture

Examples of org.apache.felix.ipojo.architecture.Architecture


    helper.createComponentInstance(factName, props);

    ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
    assertNotNull("Architecture not available", arch_ref);

    Architecture arch = (Architecture) getServiceObject(arch_ref);
    InstanceDescription id = arch.getInstanceDescription();
   
    assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
    assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.test.scenarios.component.FooProviderType1");
   
    HandlerDescription[] handlers = id.getHandlers();
View Full Code Here


    helper.createComponentInstance(factName, compName);

    ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
    assertNotNull("Architecture not available", arch_ref);

    Architecture arch = (Architecture) getServiceObject(arch_ref);
    InstanceDescription id = arch.getInstanceDescription();
   
    assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
    assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1");
   
    HandlerDescription[] handlers = id.getHandlers();
View Full Code Here

        helper.createComponentInstance(factName, compName);
   
      ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
      assertNotNull("Architecture not available", arch_ref);
   
      Architecture arch = (Architecture) getServiceObject(arch_ref);
      InstanceDescription id = arch.getInstanceDescription();
     
      assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
      assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.test.scenarios.component.FooProviderType1");
     
      HandlerDescription[] handlers = id.getHandlers();
View Full Code Here

        osgi.waitForService(Architecture.class.getName(), "(architecture.instance=c)", 2000);
        osgi.waitForService(Architecture.class.getName(), "(architecture.instance=d)", 2000);

        Object[] arch = osgi.getServiceObjects(Architecture.class.getName(), null);
        for (Object o : arch) {
            Architecture a = (Architecture) o;
            if ( a.getInstanceDescription().getState() != ComponentInstance.VALID) {
                Assert.fail("Instance " + a.getInstanceDescription().getName() + " not valid : " + a.getInstanceDescription().getDescription());
            }
        }
    }
View Full Code Here

    public void testArchitecture() {
        osgi.waitForService(Architecture.class.getName(), "(architecture.instance=d)", 2000);
        ServiceReference ref = ipojo.getServiceReferenceByName(Architecture.class.getName(), "d");
        Assert.assertNotNull(ref);

        Architecture arch = (Architecture) osgi.getServiceObject(ref);

        System.out.println(arch.getInstanceDescription().getDescription());

        Assert.assertEquals(ComponentInstance.VALID, arch.getInstanceDescription().getState());
        DependencyDescription dd = getDependency(arch, "org.apache.felix.ipojo.tests.inheritance.b.IB");

        Assert.assertTrue(! dd.getServiceReferences().isEmpty());

        ServiceReference dref = (ServiceReference) dd.getServiceReferences().get(0);
View Full Code Here

        } catch (Exception e) {
            fail(e.getMessage());
        }
       
       
        Architecture arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
       
        ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), conf.getPid());
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);
       
       // arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        FooService fs = (FooService) getContext().getService(ref);
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = ((Integer) p.get("count")).intValue();
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertEquals("Check message", "message", mes);
        assertEquals("Check count", 1, count);
       
        //Update
        Configuration configuration;
        try {
            configuration = admin.getConfiguration(msp);
            Dictionary prc = configuration.getProperties();
            if (prc == null) {
                prc = new Properties();
            }
            prc.put("message", "message2");
            configuration.update(prc);
            //Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
            listener.waitForEvent(configuration.getPid(), "1");
        } catch (Exception e) {
            fail(e.getMessage());
        }
       
      //  arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), conf.getPid());
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

       // arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        fs = (FooService) getContext().getService(ref);
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = ((Integer) p.get("count")).intValue();
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        if (mes.equals("message")) {
            System.out.println("Warning, configuration not yet applied");
            assertEquals("Check count - W", 1, count);
        } else {
            assertEquals("Check message", "message2", mes);
View Full Code Here

            fail(e1.getMessage());
        }
       
        //  The instance should be created, wait for the architecture service
        Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
        Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Check object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = ((Integer) p.get("count")).intValue();
        //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Assert Message", "message", mes);
        assertEquals("Assert count", 1, count);
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        props.put("message", "message2");
        try {
            configuration.update(props);
            // Update the configuration ...
            Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
        } catch (Exception e) {
            fail(e.getMessage());
        }
       
        fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = ((Integer) p.get("count")).intValue();
        //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Assert Message", "message2", mes);
        assertEquals("Assert count", 2, count);
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        try {
            configuration.delete();
            Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
        } catch (Exception e) {
View Full Code Here

            fail(e1.getMessage());
        }
       
        //  The instance should be created, wait for the architecture service
        Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
        Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Check object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        props.put("message", "message2");
        try {
            configuration.update(props);
            // Update the configuration ...
            Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
        } catch (Exception e) {
            fail(e.getMessage());
        }
       
        //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Check object -2", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        //Invoke
        FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = ((Integer) p.get("count")).intValue();
       // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Assert Message", "message2", mes);
        assertEquals("Assert count", 2, count);
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
               
        try {
            configuration.delete();
            Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
        } catch (Exception e) {
View Full Code Here

        }

       
        //  The instance should be created, wait for the architecture service
        Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
        Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Check object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = ((Integer) p.get("count")).intValue();
        //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Assert Message", "message", mes);
        assertEquals("Assert count", 1, count);
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        props.put("message", "message2");
        try {
            configuration.update(props);
            // Update the configuration ...
            Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
        } catch (Exception e) {
            fail(e.getMessage());
        }
       
        fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = ((Integer) p.get("count")).intValue();
       // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Assert Message", "message2", mes);
        //assertEquals("Assert count", 2, count);
        // This test was removed as the result can be 3.
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        try {
            configuration.delete();
            Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
        } catch (Exception e) {
View Full Code Here

        }

       
        //  The instance should be created, wait for the architecture service
        Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
        Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Check object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        props.put("message", "message2");
        try {
            configuration.update(props);
            // Update the configuration ...
            Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
        } catch (Exception e) {
            fail(e.getMessage());
        }
       
        //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Check object -1", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
       
        //Invoke
        FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = ((Integer) p.get("count")).intValue();
       // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
       
        assertEquals("Assert Message", "message2", mes);
        assertEquals("Assert count", 2, count);
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
               
        try {
            configuration.delete();
            Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.architecture.Architecture

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.