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

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


        assertEquals("Check foo equality", fooP, "oof");
        assertEquals("Check bar equality", barP, new Integer(0));
        assertEquals("Check baz equality", bazP, "zab");

        // Check field value
        FooService fs = (FooService) osgiHelper.getContext().getService(fooRef);
        Properties p = fs.fooProps();
        fooP = (String) p.get("foo");
        barP = (Integer) p.get("bar");

        assertEquals("Check foo field equality", fooP, "oof");
        assertEquals("Check bar field equality", barP, new Integer(0));
View Full Code Here


    @Test
    public void testComponentTypeConfiguration() {
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider1.getInstanceName());
        assertNotNull("Check FooService availability", ref);
        FooService fs = (FooService) osgiHelper.getRawServiceObject(ref);
        Properties toCheck = fs.fooProps();

        Integer intProp = (Integer) toCheck.get("intProp");
        Boolean boolProp = (Boolean) toCheck.get("boolProp");
        String strProp = (String) toCheck.get("strProp");
        String[] strAProp = (String[]) toCheck.get("strAProp");
        int[] intAProp = (int[]) toCheck.get("intAProp");

        // Check updated
        Integer updated = (Integer) toCheck.get("updated");
        Dictionary dict = (Dictionary) toCheck.get("lastupdated");

        assertEquals("Check intProp equality (1)", intProp, new Integer(2));
        assertEquals("Check longProp equality (1)", boolProp, false);
        assertEquals("Check strProp equality (1)", strProp, "foo");
        assertNotNull("Check strAProp not nullity (1)", strAProp);
        String[] v = new String[]{"foo", "bar"};
        for (int i = 0; i < strAProp.length; i++) {
            if (!strAProp[i].equals(v[i])) {
                fail("Check the strAProp Equality (1) : " + strAProp[i] + " != " + v[i]);
            }
        }
        assertNotNull("Check intAProp not nullity", intAProp);
        int[] v2 = new int[]{1, 2, 3};
        for (int i = 0; i < intAProp.length; i++) {
            if (intAProp[i] != v2[i]) {
                fail("Check the intAProp Equality (1) : " + intAProp[i] + " != " + v2[i]);
            }
        }

        assertEquals("updated count ", 1, updated.intValue());
        assertEquals("Last updated", 5, dict.size());

        // change the field value
        assertTrue("Invoke the fs service", fs.foo());
        toCheck = fs.fooProps();


        //  Re-check the property (change)
        intProp = (Integer) toCheck.get("intProp");
        boolProp = (Boolean) toCheck.get("boolProp");
View Full Code Here

    @Test
    public void testNoValue() {
        ServiceReference sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
        assertNotNull("Check the availability of the FS service", sr);

        FooService fs = (FooService) osgiHelper.getRawServiceObject(sr);
        Properties toCheck = fs.fooProps();

        // Check service properties
        Integer intProp = (Integer) toCheck.get("intProp");
        Boolean boolProp = (Boolean) toCheck.get("boolProp");
        String strProp = (String) toCheck.get("strProp");
        String[] strAProp = (String[]) toCheck.get("strAProp");
        int[] intAProp = (int[]) toCheck.get("intAProp");

        // Check updated
        Integer updated = (Integer) toCheck.get("updated");
        Dictionary dict = (Dictionary) toCheck.get("lastupdated");

        assertEquals("Check intProp equality", intProp, new Integer(0));
        assertEquals("Check longProp equality", boolProp, false);
        assertEquals("Check strProp equality", strProp, null);
        assertNull("Check strAProp nullity", strAProp);
        assertNull("Check intAProp  nullity", intAProp);

        assertEquals("updated count ", 1, updated.intValue());
        assertEquals("Last update", 0, dict.size());

        assertTrue("invoke fs", fs.foo());
        toCheck = fs.fooProps();

        // Re-check the property (change)
        intProp = (Integer) toCheck.get("intProp");
        boolProp = (Boolean) toCheck.get("boolProp");
        strProp = (String) toCheck.get("strProp");
View Full Code Here

        assertEquals("Check foo equality -2", fooP, "foo");
        assertEquals("Check bar equality -2", barP, new Integer(2));
        assertEquals("Check baz equality -2", bazP, "zab");

        // Get Service
        FooService fs = (FooService) osgiHelper.getRawServiceObject(fooRef);
        Integer updated = (Integer) fs.fooProps().get("updated");
        assertEquals("Check updated", 1, updated.intValue());
    }
View Full Code Here

        assertEquals("Check foo equality -2", fooP, "foo");
        assertEquals("Check bar equality -2", barP, new Integer(2));
        assertEquals("Check baz equality -2", bazP, "zab");

        // Get Service
        FooService fs = (FooService) osgiHelper.getRawServiceObject(fooRef);
        Integer updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated", 1, updated.intValue());

        conf.put("baz", "zab2");
        conf.put("foo", "oof2");
        conf.put("bar", new Integer(0));
        ms = (ManagedService) osgiHelper.getRawServiceObject(msRef);
        try {
            ms.updated(conf);
        } catch (ConfigurationException e) {
            fail("Configuration Exception : " + e);
        }

        updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated -2", 2, updated.intValue());
    }
View Full Code Here

        assertEquals("Check foo equality", fooP, "oof");
        assertEquals("Check bar equality", barP, new Integer(0));
        assertEquals("Check baz equality", bazP, "zab");

        // Check field value
        FooService fs = (FooService) osgiHelper.getRawServiceObject(fooRef);
        Properties p = fs.fooProps();
        fooP = (String) p.get("foo");
        barP = (Integer) p.get("bar");

        assertEquals("Check foo field equality", fooP, "oof");
        assertEquals("Check bar field equality", barP, new Integer(0));

        Integer updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated -1", 1, updated.intValue());

        conf.put("baz", "zab2");
        conf.put("foo", "oof2");
        conf.put("bar", new Integer(0));
        ms = (ManagedService) osgiHelper.getRawServiceObject(msRef);
        try {
            ms.updated(conf);
        } catch (ConfigurationException e) {
            fail("Configuration Exception : " + e);
        }

        updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated -2", 2, updated.intValue());

    }
View Full Code Here

        assertEquals("Check foo equality", fooP, "oof");
        assertEquals("Check bar equality", barP, new Integer(0));
        assertEquals("Check baz equality", bazP, "zab");

        // Check field value
        FooService fs = (FooService) osgiHelper.getRawServiceObject(fooRef);
        Properties p = fs.fooProps();
        fooP = (String) p.get("foo");
        barP = (Integer) p.get("bar");

        assertEquals("Check foo field equality", fooP, "oof");
        assertEquals("Check bar field equality", barP, new Integer(0));

        Integer updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated", 1, updated.intValue());

        conf.put("baz", "zab2");
        conf.put("foo", "oof2");
        conf.put("bar", new Integer(0));
        ms = (ManagedService) osgiHelper.getRawServiceObject(msRef);
        try {
            ms.updated(conf);
        } catch (ConfigurationException e) {
            fail("Configuration Exception : " + e);
        }

        updated = (Integer) fs.fooProps().get("updated");

        assertEquals("Check updated -2", 2, updated.intValue());
    }
View Full Code Here

                fail("Check the intAProp Equality (1)");
            }
        }

        // Invoke
        FooService fs = (FooService) osgiHelper.getRawServiceObject(sr);
        assertTrue("invoke fs", fs.foo());

        sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
        // Re-check the property (change)
        intProp = (Integer) sr.getProperty("int");
        boolProp = (Boolean) sr.getProperty("boolean");
View Full Code Here

                fail("Check the intAProp Equality (1)");
            }
        }

        // Invoke
        FooService fs = (FooService) osgiHelper.getRawServiceObject(sr);
        assertTrue("invoke fs", fs.getBoolean());

        sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
        // Re-check the property (change)
        intProp = (Integer) sr.getProperty("int");
        boolProp = (Boolean) sr.getProperty("boolean");
View Full Code Here

        assertEquals("Check foo equality -2", fooP, "foo");
        assertEquals("Check bar equality -2", barP, new Integer(2));
        assertEquals("Check baz equality -2", bazP, "zab");

        // Get Service
        FooService fs = (FooService) osgiHelper.getRawServiceObject(fooRef);
        Integer updated = (Integer) fs.fooProps().get("updated");
        Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");

        assertEquals("Check updated", 1, updated.intValue());
        assertEquals("Check last updated", 3, dict.size());

    }
View Full Code Here

TOP

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