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

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


        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


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

        // The conf is correct, the PS must be provided
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under");
        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(), "under"));

        // 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(), "under");
        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(), "under");
        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

        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);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(cs_ref);
        assertTrue("check CheckService invocation", cs.check());

        // Clean up
        bc.ungetService(arch_ref);
        bc.ungetService(cs_ref);
    }
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"));
        Integer count = (Integer) (cs.getProps().get("count"));
        assertEquals("Check int property - 1 (" + index + ")", index.intValue(), 1);
        assertEquals("Check count property - 1 (" + count + ")", 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 = 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"));
        count = (Integer) (cs.getProps().get("count"));
        assertEquals("Check int property - 2 (" + index + ")", index.intValue(), 3);
        assertEquals("Check count property - 2 (" + count + ")", count.intValue(), 1);

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

    @Test
    public void testConfigurationPrimitiveArraysNoValue() {
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
        assertNotNull("Test check service availability", ref);
        CheckService check = (CheckService) osgiHelper.getRawServiceObject(ref);
        Properties props = check.getProps();


        byte[] b = (byte[]) props.get("bs");
        short[] s = (short[]) props.get("ss");
        int[] i = (int[]) props.get("is");
        long[] l = (long[]) props.get("ls");
        double[] d = (double[]) props.get("ds");
        float[] f = (float[]) props.get("fs");
        char[] c = (char[]) props.get("cs");
        boolean[] bool = (boolean[]) props.get("bools");

        assertNull("Check b nullity", b);
        assertNull("Check s nullity", s);
        assertNull("Check i nullity", i);
        assertNull("Check l nullity", l);
        assertNull("Check d nullity", d);
        assertNull("Check f nullity", f);
        assertNull("Check c nullity", c);
        assertNull("Check bool nullity", bool);

        Integer upb = (Integer) props.get("upbs");
        Integer ups = (Integer) props.get("upss");
        Integer upi = (Integer) props.get("upis");
        Integer upl = (Integer) props.get("upls");
        Integer upd = (Integer) props.get("upds");
        Integer upf = (Integer) props.get("upfs");
        Integer upc = (Integer) props.get("upcs");
        Integer upbool = (Integer) props.get("upbools");

        assertEquals("Check upb", upb, new Integer(0));
        assertEquals("Check ups", ups, new Integer(0));
        assertEquals("Check upi", upi, new Integer(0));
        assertEquals("Check upl", upl, new Integer(0));
        assertEquals("Check upd", upd, new Integer(0));
        assertEquals("Check upf", upf, new Integer(0));
        assertEquals("Check upc", upc, new Integer(0));
        assertEquals("Check upbool", upbool, new Integer(0));

        reconfigure(instance3);

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
        assertNotNull("Test check service availability", ref);
        check = (CheckService) osgiHelper.getRawServiceObject(ref);
        props = check.getProps();

        b = (byte[]) props.get("bs");
        s = (short[]) props.get("ss");
        i = (int[]) props.get("is");
        l = (long[]) props.get("ls");
View Full Code Here

    @Test
    public void testConfigurationPrimitiveArraysStringNoValue() {
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
        assertNotNull("Test check service availability", ref);
        CheckService check = (CheckService) osgiHelper.getRawServiceObject(ref);
        Properties props = check.getProps();

        byte[] b = (byte[]) props.get("bs");
        short[] s = (short[]) props.get("ss");
        int[] i = (int[]) props.get("is");
        long[] l = (long[]) props.get("ls");
        double[] d = (double[]) props.get("ds");
        float[] f = (float[]) props.get("fs");
        char[] c = (char[]) props.get("cs");
        boolean[] bool = (boolean[]) props.get("bools");

        assertNull("Check b nullity", b);
        assertNull("Check s nullity", s);
        assertNull("Check i nullity", i);
        assertNull("Check l nullity", l);
        assertNull("Check d nullity", d);
        assertNull("Check f nullity", f);
        assertNull("Check c nullity", c);
        assertNull("Check bool nullity", bool);

        Integer upb = (Integer) props.get("upbs");
        Integer ups = (Integer) props.get("upss");
        Integer upi = (Integer) props.get("upis");
        Integer upl = (Integer) props.get("upls");
        Integer upd = (Integer) props.get("upds");
        Integer upf = (Integer) props.get("upfs");
        Integer upc = (Integer) props.get("upcs");
        Integer upbool = (Integer) props.get("upbools");

        assertEquals("Check upb", upb, new Integer(0));
        assertEquals("Check ups", ups, new Integer(0));
        assertEquals("Check upi", upi, new Integer(0));
        assertEquals("Check upl", upl, new Integer(0));
        assertEquals("Check upd", upd, new Integer(0));
        assertEquals("Check upf", upf, new Integer(0));
        assertEquals("Check upc", upc, new Integer(0));
        assertEquals("Check upbool", upbool, new Integer(0));


        reconfigureString(instance3);

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
        assertNotNull("Test check service availability", ref);
        check = (CheckService) osgiHelper.getRawServiceObject(ref);
        props = check.getProps();

        b = (byte[]) props.get("bs");
        s = (short[]) props.get("ss");
        i = (int[]) props.get("is");
        l = (long[]) props.get("ls");
View Full Code Here

    @Test
    public void testConfigurationObjNoValue() {
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
        assertNotNull("Test check service availability", ref);
        CheckService check = (CheckService) osgiHelper.getRawServiceObject(ref);
        Properties props = check.getProps();

        String s = (String) props.get("string");
        String[] ss = (String[]) props.get("strings");

        assertEquals("Check string", s, null);
        assertEquals("Check strings", ss, null);


        Integer upString = (Integer) props.get("upstring");
        Integer upStrings = (Integer) props.get("upstrings");

        assertEquals("Check upString", upString, new Integer(0));
        assertEquals("Check upStrings", upStrings, new Integer(0));

        reconfigure(instance3);

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
        assertNotNull("Test check service availability", ref);
        check = (CheckService) osgiHelper.getRawServiceObject(ref);
        props = check.getProps();

        s = (String) props.get("string");
        ss = (String[]) props.get("strings");

        assertEquals("2) Check string", s, "bar");
View Full Code Here

    @Test
    public void testConfigurationObjStringNoValue() {
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
        assertNotNull("Test check service availability", ref);
        CheckService check = (CheckService) osgiHelper.getRawServiceObject(ref);
        Properties props = check.getProps();

        String s = (String) props.get("string");
        String[] ss = (String[]) props.get("strings");

        assertEquals("Check string", s, null);
        assertEquals("Check strings", ss, null);


        Integer upString = (Integer) props.get("upstring");
        Integer upStrings = (Integer) props.get("upstrings");

        assertEquals("Check upString", upString, new Integer(0));
        assertEquals("Check upStrings", upStrings, new Integer(0));

        reconfigureString(instance3);

        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
        assertNotNull("Test check service availability", ref);
        check = (CheckService) osgiHelper.getRawServiceObject(ref);
        props = check.getProps();

        s = (String) props.get("string");
        ss = (String[]) props.get("strings");

        assertEquals("2) Check string", s, "bar");
View Full Code Here

        ServiceReference ref = null;

        ref = ipojoHelper.getServiceReferenceByName(sc, CheckService.class.getName(), "2"); // 2

        assertNotNull("Check ref", ref);
        CheckService cs = (CheckService) sc.getService(ref);
        assertTrue("Check invoke", cs.check());

        comp3.dispose();
        comp2.dispose();
        empty.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.