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

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



        // Increase the second provider grade.
        ServiceReference fs_ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider2.getInstanceName());
        assertNotNull("Check foo service (2) reference", fs_ref);
        FooService fs = (FooService) getContext().getService(fs_ref);

        fs.foo(); // Increase the grade (now = 2)

        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        cs = (CheckService) getContext().getService(cs_ref);
        // Check grade
        grade = (Integer) cs.getProps().get("int");
        assertEquals("Check fourth grade", 2, grade.intValue());

        // Increase the other provider grade.
        fs_ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider.getInstanceName());
        assertNotNull("Check foo service (1) reference", fs_ref);
        fs = (FooService) getContext().getService(fs_ref);
        fs.foo(); //(grade = 3)

        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        cs = (CheckService) getContext().getService(cs_ref);
        // Check grade
View Full Code Here


        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
        assertNotNull(ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);

        Properties props = cs.getProps();
        FooService helper = (FooService) props.get("helper.fs");
        assertNotNull(helper);
        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.

        assertTrue(cs.check());

        fooProvider1.dispose();
        instance1.dispose();
View Full Code Here

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
        assertNotNull(ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);

        Properties props = cs.getProps();
        FooService helper = (FooService) props.get("helper.fs");
        assertNotNull(helper);
        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.

        assertFalse(cs.check()); // Nullable.

        instance1.dispose();
    }
View Full Code Here

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
        assertNotNull(ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);

        Properties props = cs.getProps();
        FooService helper = (FooService) props.get("helper.fs");
        assertNotNull(helper);
        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.


        assertTrue(cs.check());

        fooProvider1.dispose();
View Full Code Here

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
        assertNotNull(ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);

        Properties props = cs.getProps();
        FooService helper = (FooService) props.get("helper.fs");
        assertNotNull(helper);
        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.

        assertFalse(cs.check()); // Nullable.


        instance1.dispose();
View Full Code Here

        ServiceReference ref = osgiHelper.getServiceReference(CheckService.class.getName(), "(service.pid=Helper)");
        assertNotNull(ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);

        Properties props = cs.getProps();
        FooService helper = (FooService) props.get("helper.fs");
        assertNotNull(helper);
        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.

        assertTrue(cs.check());

        fooProvider1.dispose();
        instance1.dispose();
View Full Code Here

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
        assertNotNull(ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);

        Properties props = cs.getProps();
        FooService helper = (FooService) props.get("helper.fs");
        System.out.println("helper : " + helper.toString());
        assertNotNull(helper);
        assertFalse(helper.toString().contains("$$Proxy")); // Not a proxy.

        assertTrue(cs.check());

        fooProvider1.dispose();
        instance1.dispose();
View Full Code Here

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
        assertNotNull(ref);
        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);

        Properties props = cs.getProps();
        FooService helper = (FooService) props.get("helper.fs");
        assertNotNull(helper);
        assertFalse(helper.toString().contains("$$Proxy")); // Dynamic proxy.
        assertTrue(helper.toString().contains("DynamicProxyFactory"));
        assertTrue(helper.hashCode() > 0);

        assertTrue(helper.equals(helper));
        assertFalse(helper.equals(i1)); // This is a quite stupid test...

        assertTrue(cs.check());

        fooProvider1.dispose();
        instance1.dispose();
View Full Code Here

        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
        assertEquals("check modify -1", ((Integer) props.get("modified")).intValue(), 1); // Already called inside the method


        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider.getInstanceName());
        FooService fs = (FooService) osgiHelper.getRawServiceObject(ref);

        fs.foo(); // Update

        props = cs.getProps();
        //Check properties
        assertTrue("check CheckService invocation -1.1", ((Boolean) props.get("result")).booleanValue());
        assertEquals("check void bind invocation -1.1 (" + ((Integer) props.get("voidB")).intValue() + ")", ((Integer) props.get("voidB")).intValue(), 1);
View Full Code Here

        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
        assertEquals("check modify -1 (" + ((Integer) props.get("modified")).intValue() + ")", ((Integer) props.get("modified")).intValue(), 1);

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider.getInstanceName());
        FooService fs = (FooService) osgiHelper.getRawServiceObject(ref);

        fs.foo(); // Update

        props = cs.getProps();
        //Check properties
        assertEquals("check modify -1.1", ((Integer) props.get("modified")).intValue(), 3);
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.runtime.core.test.services.FooService

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.