Examples of CheckService


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

    }

    @Test
    public void testTypedList() {
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), checker.getInstanceName());
        CheckService check = (CheckService) osgiHelper.getServiceObject(ref);
        assertNotNull("Checker availability", check);
        // Check without providers
        assertFalse("Empty list", check.check());

        // Start the first provider
        foo1.start();
        assertTrue("List with one element", check.check());
        Properties props = check.getProps();
        List<FooService> list = (List<FooService>) props.get("list");
        assertEquals("Check size - 1", 1, list.size());

        // Start the second provider
        foo2.start();
        assertTrue("List with two element", check.check());
        props = check.getProps();
        list = (List<FooService>) props.get("list");
        assertEquals("Check size - 2", 2, list.size());

        // Stop the first one
        foo1.stop();
        assertTrue("List with one element (2)", check.check());
        props = check.getProps();
        list = (List<FooService>) props.get("list");
        assertEquals("Check size - 3", 1, list.size());
    }
View Full Code Here

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

        InstanceDescription id = ((Architecture) osgiHelper.getRawServiceObject(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(cs_ref);
        Properties props = cs.getProps();
        //Check properties
        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);

        fooProvider1.start();

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

        cs = (CheckService) osgiHelper.getRawServiceObject(cs_ref);
        props = cs.getProps();
        //Check properties
        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);

        fooProvider2.start();

        id = ((Architecture) osgiHelper.getRawServiceObject(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

        cs = (CheckService) osgiHelper.getRawServiceObject(cs_ref);
        props = cs.getProps();
        //Check properties
        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 2.0, 0);

        fooProvider1.stop();

        id = ((Architecture) osgiHelper.getRawServiceObject(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

        cs = (CheckService) osgiHelper.getRawServiceObject(cs_ref);
        props = cs.getProps();
        //Check properties
        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one provider.
        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);

        fooProvider2.stop();

        id = ((Architecture) osgiHelper.getRawServiceObject(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

        cs = (CheckService) osgiHelper.getRawServiceObject(cs_ref);
        props = cs.getProps();
        //Check properties
        assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
        assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
        assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
        assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
View Full Code Here

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

            sr = refs[0];
        }

        assertNotNull("Check the check service availability", sr);

        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(sr);
        Dictionary<String, Object> p = cs.getProps();
        assertEquals("Assert 'simple' equality", p.get("Simple"), "simple");
        assertEquals("Assert 'a' equality", p.get("Map1"), "a");
        assertEquals("Assert 'b' equality", p.get("Map2"), "b");
        assertEquals("Assert 'c' equality", p.get("Map3"), "c");
    }
View Full Code Here

Examples of org.apache.felix.ipojo.runtime.test.dependencies.timeout.services.CheckService

        assertNotNull("Check foo availability", ref_fs);

        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
        assertNotNull("Check cs availability", ref_cs);

        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref_cs);
        assertTrue("Check invocation", cs.check());

        // Stop the provider.
        provider.stop();
        assertNull("No FooService", osgiHelper.getServiceReference(FooService.class.getName(), null));
        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
        assertNotNull("Check cs availability - 2", ref_cs);
        long begin = System.currentTimeMillis();
        DelayedProvider dp = new DelayedProvider(provider, 200);
        dp.start();
        cs = (CheckService) osgiHelper.getRawServiceObject(ref_cs);

        assertTrue("Check invocation - 2", cs.check());
        long end = System.currentTimeMillis();

        assertTrue("Assert delay (" + (end - begin) + ")", (end - begin) >= 200);

        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
        assertNotNull("Check cs availability - 3", ref_cs);
        cs = (CheckService) osgiHelper.getRawServiceObject(ref_cs);
        assertTrue("Check invocation - 3", cs.check());

        provider.stop();
        provider.dispose();
        under.stop();
        under.dispose();
View Full Code Here

Examples of org.apache.felix.ipojo.test.compatibility.service.CheckService

        };
    }

    @Test
    public void test() {
        CheckService checker = osgiHelper.getServiceObject(CheckService.class);
        assertThat(checker).isNotNull();
        assertThat(checker.data().get("result")).isEqualTo("hello john doe");
    }
View Full Code Here

Examples of org.apache.felix.ipojo.test.composite.service.CheckService

    } catch(Exception e) {
      fail("Cannot instantiate the provider : " + e.getMessage());
    }
   
    ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
    CheckService check = (CheckService) sc2.getService(ref);
   
    assertTrue("Check invocation", check.check());
   
    sc2.ungetService(ref);
   
    // Check visibility
    assertNotNull("Check foo service visible inside the composite", sc2.getServiceReference(FooService.class.getName()));
View Full Code Here

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

    }
   
    public void testConfigurationPrimitive() {
        ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Test check service availability", ref);
        CheckService check = (CheckService) getContext().getService(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(instance);
       
        ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
        assertNotNull("Test check service availability", ref);
        check = (CheckService) getContext().getService(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

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

        } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}
        if(refs != null) { sr = refs[0]; }
       
    assertNotNull("Check the check service availability", sr);
   
    CheckService cs = (CheckService) getContext().getService(sr);
    Properties p = cs.getProps();
    assertEquals("Assert 'simple' equality", p.get("Simple"), "simple");
    assertEquals("Assert 'a' equality", p.get("Map1"), "a");
    assertEquals("Assert 'b' equality", p.get("Map2"), "b");
    assertEquals("Assert 'c' equality", p.get("Map3"), "c");
   
View Full Code Here

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

        under = Utils.getComponentInstance(getContext(), "LFC-Test-Immediate", props);
       
        // The conf is correct, the PS must be provided
        ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -1", ref);
        CheckService cs = (CheckService) getContext().getService(ref);
        assertTrue("Check state 1", cs.check());
        getContext().ungetService(ref);
        cs = null;
       
        // 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
        ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
        assertNull("Check service availability -2", ref);
       
        // 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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
        assertNotNull("Check service availability -3", ref);
        cs = (CheckService) getContext().getService(ref);
        assertTrue("Check state 2", cs.check());
        getContext().ungetService(ref);
        cs = null;
       
        under.dispose();
    }
View Full Code Here

Examples of org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService

        under = Utils.getComponentInstance(getContext(), "LFC-Test-Immediate", props);
       
        // The conf is correct, the PS must be provided
        ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under");
        assertNotNull("Check service availability -1", ref);
        CheckService cs = (CheckService) getContext().getService(ref);
        assertTrue("Check state 1", cs.check());
        getContext().ungetService(ref);
        cs = null;
       
        // 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
        ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under");
        assertNull("Check service availability -2", ref);
       
        // 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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under");
        assertNotNull("Check service availability -3", ref);
        cs = (CheckService) getContext().getService(ref);
        assertTrue("Check state 2", cs.check());
        getContext().ungetService(ref);
        cs = null;
       
        under.dispose();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.