Package org.apache.felix.ipojo.runtime.core.services

Examples of org.apache.felix.ipojo.runtime.core.services.CheckService


        osgiHelper.waitForService(CheckService.class.getName(), null, 5000);

        assertFalse(osgiHelper.isServiceAvailable(FooService.class.getName()));

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

        check.getProps();

        assertFalse(osgiHelper.isServiceAvailable(CheckService.class.getName()));
        assertTrue(osgiHelper.isServiceAvailable(FooService.class.getName()));

        FooService fs = (FooService) osgiHelper.getServiceObject(FooService.class.getName(), null);
View Full Code Here


                .getHandlerDescription("org.apache.felix.ipojo:provides");

        ProvidedServiceDescription ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
        assertEquals("true", ps.getController());

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

        assertFalse(check.check());

        ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
        assertEquals("false", ps.getController());

        assertTrue(check.check());

        ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
        assertEquals("true", ps.getController());

    }
View Full Code Here

        under = ipojoHelper.createComponentInstance("LFC-Test", props);

        // The conf is correct, the PS must be provided
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -1", ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state 1", cs.check());
        bc.ungetService(ref);

        // Reconfigure the instance with a bad configuration
        props.put("conf", "bar"); // Bar is a bad conf
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
        }

        // The instance should now be invalid
        assertFalse("Check service availability -2",
                ipojoHelper.isServiceAvailableByName(CheckService.class.getName(), "under1"));

        // Reconfigure the instance with a valid configuration
        props.put("conf", "foo"); // Bar is a bad conf
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
        }

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -3", ref);
        cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state 2", cs.check());
        bc.ungetService(ref);

        under.dispose();
    }
View Full Code Here

        // The conf is incorrect, but the test can appears only when the object is created : the PS must be provided
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under2");
        assertNotNull("Check service availability -1", ref);

        System.out.println("CS received : " + osgiHelper.getRawServiceObject(ref));
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertNotNull("Assert CS not null", cs);
        try {
            assertFalse("Check state (false)", cs.check());
        } catch (Throwable e) {
            fail(e.getMessage());
        }

        // As soon as the instance is created, the service has to disappear :
        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under2");
        assertNull("Check service availability -2", ref);

        // Reconfigure the instance with a correct configuration
        props.put("conf", "foo");
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
        }

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under2");
        assertNotNull("Check service availability -3", ref);
        cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state ", cs.check());
        bc.ungetService(ref);

        under.dispose();
    }
View Full Code Here

        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

        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());

        // 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) 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.intValue() + ")", index.intValue(), 3);

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

        under = ipojoHelper.createComponentInstance("LFC-Test-Immediate", props);

        // The conf is correct, the PS must be provided
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -1", ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state 1", cs.check());
        bc.ungetService(ref);


        // Reconfigure the instance with a bad configuration
        props.put("conf", "bar"); // Bar is a bad conf
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
        }

        // The instance should now be invalid
        assertFalse("Check service availability -2",
                ipojoHelper.isServiceAvailableByName(CheckService.class.getName(), "under1"));

        // Reconfigure the instance with a valid configuration
        props.put("conf", "foo"); // Bar is a bad conf
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
        }

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -3", ref);
        cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state 2", cs.check());
        bc.ungetService(ref);

        under.dispose();
    }
View Full Code Here

            fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
        }

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under2");
        assertNotNull("Check service availability -2", ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state ", cs.check());
        bc.ungetService(ref);


        under.dispose();
    }
View Full Code Here

        under = factory.createComponentInstance(props);

        // The conf is correct, the PS must be provided
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -1", ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state 1", cs.check());
        bc.ungetService(ref);

        // Reconfigure the instance
        props.put("state", "false"); // Bar is a bad conf
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
        }

        // The instance should now be invalid
        assertFalse("Check service availability -2",
                ipojoHelper.isServiceAvailableByName(CheckService.class.getName(), "under1"));

        // Reconfigure the instance with a valid configuration
        props.put("state", "true");
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
        }

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -3", ref);
        cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state 2", cs.check());
        bc.ungetService(ref);

        under.dispose();
    }
View Full Code Here

//          System.out.println(a.getInstanceDescription().getDescription());
//        }

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -1", ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state 1", cs.check());
        bc.ungetService(ref);


        // Reconfigure the instance
        props.put("state", "false"); // Bar is a bad conf
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
        }

        // The instance should now be invalid
        assertFalse("Check service availability -2",
                ipojoHelper.isServiceAvailableByName(CheckService.class.getName(), "under1"));

        // Reconfigure the instance with a valid configuration
        props.put("state", "true");
        try {
            factory.reconfigure(props);
        } catch (Exception e) {
            fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
        }

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -3", ref);
        cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue("Check state 2", cs.check());
        bc.ungetService(ref);

        under.dispose();
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.runtime.core.services.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.