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

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


        ServiceReference ref = null;

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

        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


            refs = getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=Test)");
        } catch (InvalidSyntaxException e) {
            fail("Invalid filter : " + e.getMessage());
        }
        assertNotNull("Check refs not null", refs);
        CheckService cs = (CheckService) getContext().getService(refs[0]);

        assertTrue("Check invocation", cs.check());
        ci.dispose();

    }
View Full Code Here

        // Check the service property
        // Not exposed here:
        assertNull("Classes -0", ref.getProperty("classes"));

        CheckService check = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertTrue(check.check());

        // Property exposed now.
        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), ci.getInstanceName());
        Class[] str = (Class[]) ref.getProperty("classes");
        assertEquals("Classes size", 1, str.length);
        assertEquals("Classes[0]", FooService.class.getName(), str[0].getName());

        Properties p = check.getProps();
        Class[] str2 = (Class[]) p.get("classes");
        assertEquals("Classes size -2", 1, str2.length);
        assertEquals("Classes[0] -2", FooService.class.getName(), str2[0].getName());

        Properties props2 = new Properties();
        props2.put("cls", new String[]{FooService.class.getName(), CheckService.class.getName()});
        try {
            ci.reconfigure(props2);
        } catch (Exception e) {
            fail(e.getMessage());
        }

        // Check the service property
        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), ci.getInstanceName());
        assertNotNull("Check ref", ref);
        str = (Class[]) ref.getProperty("classes");
        assertEquals("Classes size -3", 2, str.length);
        assertEquals("Classes[0] -3", FooService.class.getName(), str[0].getName());
        assertEquals("Classes[1] -3", CheckService.class.getName(), str[1].getName());


        check = (CheckService) osgiHelper.getRawServiceObject(ref);
        p = check.getProps();
        str2 = (Class[]) p.get("classes");
        assertEquals("Classes size -4", 2, str2.length);
        assertEquals("Classes[0] -4", FooService.class.getName(), str2[0].getName());
        assertEquals("Classes[1] -4", CheckService.class.getName(), str2[1].getName());
View Full Code Here

        ServiceReference ref = osgiHelper.waitForService(CheckService.class.getName(),
                "(instance.name=" + instance.getInstanceName() +")",
                1000);

        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertEquals(cs.getProps().getProperty("message"), "message");
    }
View Full Code Here

        ServiceReference ref = osgiHelper.waitForService(CheckService.class.getName(),
                "(instance.name=" + instance.getInstanceName() +")",
                1000);

        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertEquals(cs.getProps().getProperty("message"), "message");
    }
View Full Code Here

        ServiceReference ref = osgiHelper.waitForService(CheckService.class.getName(),
                "(instance.name=" + instance.getInstanceName() +")",
                1000);

        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertEquals(cs.getProps().getProperty("message"), "message");
    }
View Full Code Here

        ServiceReference ref = osgiHelper.waitForService(CheckService.class.getName(),
                "(instance.name=" + instance.getInstanceName() +")",
                1000);

        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertEquals(cs.getProps().getProperty("message"), "message");
        assertEquals(cs.getProps().getProperty("product"), "ipojo");
    }
View Full Code Here

        ServiceReference ref = osgiHelper.waitForService(CheckService.class.getName(),
                "(instance.name=" + instance.getInstanceName() +")",
                1000);

        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
        assertEquals(cs.getProps().getProperty("message"), "message");
        assertNotNull(cs.getProps().get("context"));
        assertTrue(cs.getProps().get("context") instanceof BundleContext);
    }
View Full Code Here

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

        Byte b = (Byte) props.get("b");
        Short s = (Short) props.get("s");
        Integer i = (Integer) props.get("i");
        Long l = (Long) props.get("l");
        Double d = (Double) props.get("d");
        Float f = (Float) props.get("f");
        Character c = (Character) props.get("c");
        Boolean bool = (Boolean) props.get("bool");

        assertEquals("Check b", b, new Byte("1"));
        assertEquals("Check s", s, new Short("1"));
        assertEquals("Check i", i, new Integer("1"));
        assertEquals("Check l", l, new Long("1"));
        assertEquals("Check d", d, new Double("1"));
        assertEquals("Check f", f, new Float("1"));
        assertEquals("Check c", c, new Character('a'));
        assertEquals("Check bool", bool, new Boolean("true"));

//        Integer upb = (Integer) props.get("upb");
//        Integer ups = (Integer) props.get("ups");
//        Integer upi = (Integer) props.get("upi");
//        Integer upl = (Integer) props.get("upl");
//        Integer upd = (Integer) props.get("upd");
//        Integer upf = (Integer) props.get("upf");
//        Integer upc = (Integer) props.get("upc");
//        Integer upbool = (Integer) props.get("upbool");
//       
//        assertEquals("Check upb", upb, new Integer(1));
//        assertEquals("Check ups", ups, new Integer(1));
//        assertEquals("Check upi", upi, new Integer(1));
//        assertEquals("Check upl", upl, new Integer(1));
//        assertEquals("Check upd", upd, new Integer(1));
//        assertEquals("Check upf", upf, new Integer(1));
//        assertEquals("Check upc", upc, new Integer(1));
//        assertEquals("Check upbool", upbool, new Integer(1));

        reconfigure();

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

        b = (Byte) props.get("b");
        s = (Short) props.get("s");
        i = (Integer) props.get("i");
        l = (Long) props.get("l");
View Full Code Here

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

        Byte b = (Byte) props.get("b");
        Short s = (Short) props.get("s");
        Integer i = (Integer) props.get("i");
        Long l = (Long) props.get("l");
        Double d = (Double) props.get("d");
        Float f = (Float) props.get("f");
        Character c = (Character) props.get("c");
        Boolean bool = (Boolean) props.get("bool");

        assertEquals("Check b", b, new Byte("1"));
        assertEquals("Check s", s, new Short("1"));
        assertEquals("Check i", i, new Integer("1"));
        assertEquals("Check l", l, new Long("1"));
        assertEquals("Check d", d, new Double("1"));
        assertEquals("Check f", f, new Float("1"));
        assertEquals("Check c", c, new Character('a'));
        assertEquals("Check bool", bool, new Boolean("true"));

//        Integer upb = (Integer) props.get("upb");
//        Integer ups = (Integer) props.get("ups");
//        Integer upi = (Integer) props.get("upi");
//        Integer upl = (Integer) props.get("upl");
//        Integer upd = (Integer) props.get("upd");
//        Integer upf = (Integer) props.get("upf");
//        Integer upc = (Integer) props.get("upc");
//        Integer upbool = (Integer) props.get("upbool");
//       
//        assertEquals("Check upb", upb, new Integer(1));
//        assertEquals("Check ups", ups, new Integer(1));
//        assertEquals("Check upi", upi, new Integer(1));
//        assertEquals("Check upl", upl, new Integer(1));
//        assertEquals("Check upd", upd, new Integer(1));
//        assertEquals("Check upf", upf, new Integer(1));
//        assertEquals("Check upc", upc, new Integer(1));
//        assertEquals("Check upbool", upbool, new Integer(1));

        reconfigureString();

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

        b = (Byte) props.get("b");
        s = (Short) props.get("s");
        i = (Integer) props.get("i");
        l = (Long) props.get("l");
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.