Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.PrimitiveInstanceDescription


    @Test
    public void testCallback() {
        // Check instance is invalid
        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance.getInstanceName());
        assertNotNull("Check architecture availability", arch_ref);
        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) osgiHelper
                .getRawServiceObject(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);

        // Start fooprovider
        fooProvider.start();

        // Check instance validity
        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);

        // Check service providing
        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(cs_ref);
        assertTrue("check CheckService invocation", cs.check());

        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
        // Check int property
        Integer index = (Integer) (cs.getProps().get("int"));
        assertEquals("Check int property - 1 (" + index + ")", index.intValue(), 1);

        fooProvider.stop();

        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);

        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);

        fooProvider.start();

        // Check instance validity
        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);

        // Check service providing
        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        cs = (CheckService) osgiHelper.getRawServiceObject(cs_ref);
        assertTrue("check CheckService invocation", cs.check());

        // Check int property
        index = (Integer) (cs.getProps().get("int"));
        assertEquals("Check int property - 2 (" + index + ")", index.intValue(), 3);

        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
    }
View Full Code Here


   
    public void testCallback() {
        // Check instance is invalid
        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
        assertNotNull("Check architecture availability", arch_ref);
        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription)((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
       
        // Start fooprovider
        fooProvider.start();
       
        // Check instance validity
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
       
        // Check service providing
        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        CheckService cs = (CheckService) getContext().getService(cs_ref);
        assertTrue("check CheckService invocation", cs.check());
       
        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
        // Check int property
        Integer index = (Integer) (cs.getProps().get("int"));
        assertEquals("Check int property - 1 (" + index.intValue() +")", index.intValue(), 1);
       
        fooProvider.stop();
       
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
       
        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
       
        fooProvider.start();
       
        // Check instance validity
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
       
        // Check service providing
        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        cs = (CheckService) getContext().getService(cs_ref);
        assertTrue("check CheckService invocation", cs.check());
       
        // Check int property
        index = (Integer) (cs.getProps().get("int"));
        assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
       
        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
       
        // Clean up
        getContext().ungetService(arch_ref);
        getContext().ungetService(cs_ref);
        cs = null;
View Full Code Here

   
    public void testCallback() {
        // Check instance is invalid
        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
        assertNotNull("Check architecture availability", arch_ref);
        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
       
        // Start fooprovider
        fooProvider.start();
       
        // Check instance validity
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
       
        // Check service providing
        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        CheckService cs = (CheckService) getContext().getService(cs_ref);
        assertTrue("check CheckService invocation", cs.check());
       
        // Check int property
        Integer index = (Integer) (cs.getProps().get("int"));
        assertEquals("Check int property - 1", index.intValue(), 1);
       
        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
       
        fooProvider.stop();
       
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
       
        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
       
        fooProvider.start();
       
        // Check instance validity
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
       
        // Check service providing
        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        cs = (CheckService) getContext().getService(cs_ref);
        assertTrue("check CheckService invocation", cs.check());
       
        // Check int property
        index = (Integer) (cs.getProps().get("int"));
        assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
       
        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
       
        // Clean up
        getContext().ungetService(arch_ref);
        getContext().ungetService(cs_ref);
        cs = null;
View Full Code Here

   
    public void testCallback() {
        // Check instance is invalid
        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
        assertNotNull("Check architecture availability", arch_ref);
        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
       
        // Start fooprovider
        fooProvider.start();
       
        // Check instance validity
       // id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
       
        // Check service providing
        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        CheckService cs = (CheckService) getContext().getService(cs_ref);
        assertTrue("check CheckService invocation", cs.check());
       
        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
        // Check int property
        Integer index = (Integer) (cs.getProps().get("int"));
        assertEquals("Check int property - 1 (" + index.intValue() +")", index.intValue(), 1);
       
        fooProvider.stop();
       
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
       
        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
       
        fooProvider.start();
       
        // Check instance validity
       // id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
       
        // Check service providing
        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        cs = (CheckService) getContext().getService(cs_ref);
        assertTrue("check CheckService invocation", cs.check());
       
        // Check int property
        index = (Integer) (cs.getProps().get("int"));
        assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
       
        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
       
        // Clean up
        getContext().ungetService(arch_ref);
        getContext().ungetService(cs_ref);
        cs = null;
View Full Code Here

 
  public void testCallback() {
    // Check instance is invalid
    ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
    assertNotNull("Check architecture availability", arch_ref);
    PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
    assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
   
    // Start fooprovider
    fooProvider.start();
   
    // Check instance validity
    //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
    assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
   
    // Check service providing
    ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
    assertNotNull("Check CheckService availability", cs_ref);
    CheckService cs = (CheckService) getContext().getService(cs_ref);
   
    // Check int property   
    assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
   
    fooProvider.stop();
   
    //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
    assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
   
    fooProvider.start();
   
    // Check instance validity
    //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
    assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
   
    // Check service providing
    cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
    assertNotNull("Check CheckService availability", cs_ref);
    cs = (CheckService) getContext().getService(cs_ref);
View Full Code Here

   
    public void testCallback() {
        // Check instance is invalid
        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
        assertNotNull("Check architecture availability", arch_ref);
        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
       
        // Start fooprovider
        fooProvider.start();
       
        // Check instance validity
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
       
        // Check service providing
        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        CheckService cs = (CheckService) getContext().getService(cs_ref);
        assertTrue("check CheckService invocation", cs.check());
       
        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
        // Check int property
        Integer index = (Integer) (cs.getProps().get("int"));
        Integer count = (Integer) (cs.getProps().get("count"));
        assertEquals("Check int property - 1 (" + index.intValue() +")", index.intValue(), 1);
        assertEquals("Check count property - 1 (" + count.intValue() +")", count.intValue(), 1);
       
        fooProvider.stop();
       
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
       
        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
       
        fooProvider.start();
       
        // Check instance validity
        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
       
        // Check service providing
        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        cs = (CheckService) getContext().getService(cs_ref);
        assertTrue("check CheckService invocation", cs.check());
       
        // Check int property
        index = (Integer) (cs.getProps().get("int"));
        count = (Integer) (cs.getProps().get("count"));
        assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
        assertEquals("Check count property - 2 ("+count.intValue()+")", count.intValue(), 1);
       
        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
       
        // Clean up
        getContext().ungetService(arch_ref);
        getContext().ungetService(cs_ref);
        cs = null;
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.PrimitiveInstanceDescription

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.