Package org.apache.felix.ipojo.test.scenarios.ps.service

Examples of org.apache.felix.ipojo.test.scenarios.ps.service.CheckService


      ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-reg-only");
        // Controller set to true.
        waitForService(FooService.class.getName(), null, 5000);
        waitForService(CheckService.class.getName(), null, 5000);

        CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
        assertNotNull(check);

        Integer reg = (Integer) check.getProps().get("registered");
        Integer unreg = (Integer) check.getProps().get("unregistered");
        assertNotNull(reg);
        assertNotNull(unreg);
        assertEquals(new Integer(1), reg);
        assertEquals(new Integer(0), unreg);

        ci.stop();

        reg = (Integer) check.getProps().get("registered");
        unreg = (Integer) check.getProps().get("unregistered");
        assertNotNull(reg);
        assertNotNull(unreg);
        assertEquals(new Integer(1), reg);
        assertEquals(new Integer(0), unreg);
    }
View Full Code Here


      ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-both");
        // Controller set to true.
        waitForService(FooService.class.getName(), null, 5000);
        waitForService(CheckService.class.getName(), null, 5000);

        CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
        assertNotNull(check);

        Integer reg = (Integer) check.getProps().get("registered");
        Integer unreg = (Integer) check.getProps().get("unregistered");
        assertNotNull(reg);
        assertNotNull(unreg);
        assertEquals(new Integer(1), reg);
        assertEquals(new Integer(0), unreg);

        ci.stop();

        reg = (Integer) check.getProps().get("registered");
        unreg = (Integer) check.getProps().get("unregistered");
        assertNotNull(reg);
        assertNotNull(unreg);
        assertEquals(new Integer(1), reg);
        assertEquals(new Integer(1), unreg);
    }
View Full Code Here

      ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-unreg-only");
        // Controller set to true.
        waitForService(FooService.class.getName(), null, 5000);
        waitForService(CheckService.class.getName(), null, 5000);

        CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
        assertNotNull(check);

        Integer reg = (Integer) check.getProps().get("registered");
        Integer unreg = (Integer) check.getProps().get("unregistered");
        assertNotNull(reg);
        assertNotNull(unreg);
        assertEquals(new Integer(0), reg);
        assertEquals(new Integer(0), unreg);

        ci.stop();

        reg = (Integer) check.getProps().get("registered");
        unreg = (Integer) check.getProps().get("unregistered");
        assertNotNull(reg);
        assertNotNull(unreg);
        assertEquals(new Integer(0), reg);
        assertEquals(new Integer(1), unreg);
    }
View Full Code Here

      ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-both-2");
        // Controller set to true.
        waitForService(FooService.class.getName(), null, 5000);
        waitForService(CheckService.class.getName(), null, 5000);

        CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
        assertNotNull(check);

        Integer reg = (Integer) check.getProps().get("registered");
        Integer unreg = (Integer) check.getProps().get("unregistered");
        Integer reg2 = (Integer) check.getProps().get("registered2");
        Integer unreg2 = (Integer) check.getProps().get("unregistered2");
        assertNotNull(reg);
        assertNotNull(unreg);
        assertNotNull(reg2);
        assertNotNull(unreg2);
        assertEquals(new Integer(1), reg);
        assertEquals(new Integer(0), unreg);
        assertEquals(new Integer(1), reg2);
        assertEquals(new Integer(0), unreg2);

        ci.stop();

        reg = (Integer) check.getProps().get("registered");
        unreg = (Integer) check.getProps().get("unregistered");
        reg2 = (Integer) check.getProps().get("registered2");
        unreg2 = (Integer) check.getProps().get("unregistered2");
        assertNotNull(reg2);
        assertNotNull(unreg2);
        assertEquals(new Integer(1), reg);
        assertEquals(new Integer(1), unreg);
        assertEquals(new Integer(1), reg2);
View Full Code Here

      ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-both-1");
        // Controller set to true.
        waitForService(FooService.class.getName(), null, 5000);
        waitForService(CheckService.class.getName(), null, 5000);

        CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
        assertNotNull(check);

        Integer reg = (Integer) check.getProps().get("registered");
        Integer unreg = (Integer) check.getProps().get("unregistered");
        assertNotNull(reg);
        assertNotNull(unreg);
        assertEquals(new Integer(2), reg);
        assertEquals(new Integer(0), unreg);

        ci.stop();

        reg = (Integer) check.getProps().get("registered");
        unreg = (Integer) check.getProps().get("unregistered");
        assertEquals(new Integer(2), reg);
        assertEquals(new Integer(2), unreg);
    }
View Full Code Here

        // Step 1 : create start one consumer
        cons1.start();
        ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
        assertNotNull("Cons1 Service available", refcons1);
       
        CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
        Properties props = cs_cons1.getProps();
        Long id = (Long) props.get("id");
        FooService fscons1 = (FooService) props.get("object");
        assertEquals("id 1", 1, id.intValue());
        checkCreatedObjects(prov, 1);

       
        // Step 2 : create a second consumer
        cons2.start();
        ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
        assertNotNull("Cons2 Service available", refcons2);
       
        CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
        Properties props2 = cs_cons2.getProps();
        Long id2 = (Long) props2.get("id");
        FooService fscons2 = (FooService) props2.get("object");
        assertEquals("id 2", 2, id2.intValue());
        checkCreatedObjects(prov, 2);
View Full Code Here

        prov.start();
       
        // The two consumers are started and use their own objects.
        ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
        assertNotNull("Cons1 Service available", refcons1);
        CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
        Properties props = cs_cons1.getProps();
        FooService fscons1 = (FooService) props.get("object");
       
        ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
        assertNotNull("Cons2 Service available", refcons2);
        CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
        Properties props2 = cs_cons2.getProps();
        FooService fscons2 = (FooService) props2.get("object");
       
        checkCreatedObjects(prov, 2);
        assertNotSame("Two objects", fscons1, fscons2);

        // Stop the provider
        prov.stop();
        // Cons1 and 2 are invalid.
        assertEquals("Cons1 invalidity", ComponentInstance.INVALID, cons1.getState());
        assertEquals("Cons2 invalidity", ComponentInstance.INVALID, cons2.getState());
       
        // No object created in prov
        checkCreatedObjects(prov, 0);

        // Restart the provider
        prov.start();
       
        // Consumers are valid.
        assertEquals("Cons1 validity", ComponentInstance.VALID, cons1.getState());
        assertEquals("Cons2 validity", ComponentInstance.VALID, cons2.getState());
       
        // Check objects
        refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
        assertNotNull("Cons1 Service available", refcons1);
        cs_cons1 = (CheckService) getServiceObject(refcons1);
        props = cs_cons1.getProps();
        Object fscons3 = (FooService) props.get("object");
       
        refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
        assertNotNull("Cons2 Service available", refcons2);
        cs_cons2 = (CheckService) getServiceObject(refcons2);
        props2 = cs_cons2.getProps();
        Object fscons4 = (FooService) props2.get("object");
       
        checkCreatedObjects(prov, 2);
        assertNotSame("Two objects", fscons3, fscons4);
        assertNotSame("Two new objects - 1", fscons3, fscons1);
View Full Code Here

        // Step 1 : create start one consumer
        cons1.start();
        ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
        assertNotNull("Cons1 Service available", refcons1);
       
        CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
        Properties props = cs_cons1.getProps();
        Long id = (Long) props.get("id");
        FooService fscons1 = (FooService) props.get("object");
        assertEquals("id 1", 1, id.intValue());
        checkCreatedObjects(prov2, 1);

       
        // Step 2 : create a second consumer
        cons3.start();
        ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons3.getInstanceName());
        assertNotNull("Cons2 Service available", refcons2);
       
        CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
        Properties props2 = cs_cons2.getProps();
        Long id2 = (Long) props2.get("id");
        FooService fscons2 = (FooService) props2.get("object");
        assertEquals("id 2", 2, id2.intValue());
        checkCreatedObjects(prov2, 2);
View Full Code Here

        // Step 1 : create start one consumer
        cons1.start();
        ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
        assertNotNull("Cons1 Service available", refcons1);
       
        CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
        Properties props = cs_cons1.getProps();
        Long id = (Long) props.get("id");
        FooService fscons1 = (FooService) props.get("object");
        assertEquals("id 1", 1, id.intValue());
        checkCreatedObjects(prov, 1);

       
        // Step 2 : create a second consumer
        cons2.start();
        ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
        assertNotNull("Cons2 Service available", refcons2);
       
        CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
        Properties props2 = cs_cons2.getProps();
        Long id2 = (Long) props2.get("id");
        FooService fscons2 = (FooService) props2.get("object");
        assertEquals("id 2", 2, id2.intValue());
        checkCreatedObjects(prov, 2);
View Full Code Here

        prov.start();
       
        // The two consumers are started and use their own objects.
        ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
        assertNotNull("Cons1 Service available", refcons1);
        CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
        Properties props = cs_cons1.getProps();
        FooService fscons1 = (FooService) props.get("object");
       
        ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
        assertNotNull("Cons2 Service available", refcons2);
        CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
        Properties props2 = cs_cons2.getProps();
        FooService fscons2 = (FooService) props2.get("object");
       
        checkCreatedObjects(prov, 2);
        assertNotSame("Two objects", fscons1, fscons2);

        // Stop the provider
        prov.stop();
        // Cons1 and 2 are invalid.
        assertEquals("Cons1 invalidity", ComponentInstance.INVALID, cons1.getState());
        assertEquals("Cons2 invalidity", ComponentInstance.INVALID, cons2.getState());
       
        // No object created in prov
        checkCreatedObjects(prov, 0);

        // Restart the provider
        prov.start();
       
        // Consumers are valid.
        assertEquals("Cons1 validity", ComponentInstance.VALID, cons1.getState());
        assertEquals("Cons2 validity", ComponentInstance.VALID, cons2.getState());
       
        // Check objects
        refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
        assertNotNull("Cons1 Service available", refcons1);
        cs_cons1 = (CheckService) getServiceObject(refcons1);
        props = cs_cons1.getProps();
        Object fscons3 = (FooService) props.get("object");
       
        refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
        assertNotNull("Cons2 Service available", refcons2);
        cs_cons2 = (CheckService) getServiceObject(refcons2);
        props2 = cs_cons2.getProps();
        Object fscons4 = (FooService) props2.get("object");
       
        checkCreatedObjects(prov, 2);
        assertNotSame("Two objects", fscons3, fscons4);
        assertNotSame("Two new objects - 1", fscons3, fscons1);
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.test.scenarios.ps.service.CheckService

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.