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

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


        // architecture = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance="+pid+")");

        assertEquals("Check no object -2", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);

        //Invoke
        FooService fs = (FooService) osgiHelper.getServiceObject(FooService.class.getName(), "(instance.name=" + pid + ")");
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = (Integer) p.get("count");
        //architecture = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance="+pid+")");

        assertEquals("Assert Message", "message2", mes);
View Full Code Here


        Architecture architecture = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + pid + ")");

        assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);

        osgiHelper.waitForService(FooService.class.getName(), "(instance.name=" + pid + ")", 1000);
        FooService fs = (FooService) osgiHelper.getServiceObject(FooService.class.getName(), "(instance.name=" + pid + ")");

        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = (Integer) p.get("count");
        // architecture = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance="+pid+")");

        assertEquals("Assert Message", "message", mes);
        assertEquals("Assert count", 1, count);
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);

        // Wait for the processing of the first configuration.
        grace();

        System.out.println("===");

        props.put("message", "message2");
        try {
            configuration.update(props);
            // Update the configuration ...
            grace();
        } catch (Exception e) {
            fail(e.getMessage());
        }

        System.out.println("===");

        fs = (FooService) osgiHelper.getServiceObject(FooService.class.getName(), "(instance.name=" + pid + ")");
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = (Integer) p.get("count");
        // architecture = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance="+pid+")");

        assertEquals("Assert Message", "message2", mes);
View Full Code Here

        //architecture = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance="+pid+")");

        assertEquals("Check no object -2", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);

        //Invoke
        FooService fs = (FooService) osgiHelper.getServiceObject(FooService.class.getName(), "(instance.name=" + pid + ")");
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = (Integer) p.get("count");
        // architecture = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance="+pid+")");

        assertEquals("Assert Message", "message2", mes);
View Full Code Here

        props.put(".private", "wow");

        Configuration configuration = admin.createFactoryConfiguration(factoryName, "?");
        configuration.update(props);

        FooService fs = osgiHelper.waitForService(FooService.class,
                "(instance.name=" + configuration.getPid() + ")",
                1000);

        assertEquals(fs.getInt(), 1);

        // Update the property
        props.put("message", "message2");
        props.put("propagated", "propagated2");
        props.put(".private", "wow2");
        configuration.update(props);

        grace();

        assertEquals(fs.getInt(), 2);

        // Remove a property
        props.remove("propagated");
        configuration.update(props);

        grace();

        assertEquals(fs.getInt(), 3);


        configuration.delete();
    }
View Full Code Here

        props.put("managed.service.pid", "config");

        Configuration configuration = admin.createFactoryConfiguration(factoryName, "?");
        configuration.update(props);

        FooService fs = osgiHelper.waitForService(FooService.class,
                "(instance.name=" + configuration.getPid() + ")",
                1000);

        assertEquals(fs.getInt(), 1);

        // Update the property using the managed service.

        Configuration managedConfiguration = admin.getConfiguration("config", "?");
        props.put("message", "message2");
        props.put("propagated", "propagated2");
        props.put(".private", "wow2");
        managedConfiguration.update(props);

        grace();

        assertEquals(fs.getInt(), 2);

        // Remove a property
        props.remove("propagated");
        managedConfiguration.update(props);

        grace();

        assertEquals(fs.getInt(), 3);

        managedConfiguration.delete();
        configuration.delete();
    }
View Full Code Here

            return; // Test disabled on KF
        }
        TimeUtils.grace(500);
        osgiHelper.waitForService(FooService.class, null, 10000);

        FooService fs1 = ipojoHelper.getServiceObjectByName(FooService.class, "complex1");
        Properties props1 = fs1.fooProps();
        Assert.assertTrue(((String)props1.get("content")).contains("I'm file 1"));
        Assert.assertEquals(((Bean)props1.get("bean")).getMessage(), "I'm 1");
        Assert.assertEquals(((Bean)props1.get("bean")).getCount(), 1);
        Assert.assertEquals(((Map<String, String>)props1.get("map")).get("a"), "b");

        FooService fs2 = ipojoHelper.getServiceObjectByName(FooService.class, "complex2");
        Assert.assertNotNull(fs2);
        Properties props2 = fs2.fooProps();
        Assert.assertTrue(((String)props2.get("content")).contains("I'm file 2"));
        Assert.assertEquals(((Bean)props2.get("bean")).getMessage(), "I'm 2");
        Assert.assertEquals(((Bean)props2.get("bean")).getCount(), 2);
        Assert.assertEquals(((Map<String, String>)props2.get("map")).get("a"), "b2");
View Full Code Here

        TimeUtils.grace(500);
        osgiHelper.waitForService(FooService.class, null, 10000);

        // Check configuration
        FooService fs = osgiHelper.getServiceObject(FooService.class);
        Assert.assertTrue(fs.foo());
        Assert.assertEquals(fs.getDouble(), 1.0, 0);
        Assert.assertEquals(fs.getInt(), 1);
        Assert.assertEquals(fs.getLong(), 1l);
    }
View Full Code Here

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
        assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        FooService fs = (FooService) bc.getService(ref);
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = (Integer) p.get("count");
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
        assertEquals("Check message", "message", mes);
        assertEquals("Check count", 1, count);

        //Update
        Configuration configuration;
        try {
            configuration = admin.getConfiguration(msp, getTestBundle().getLocation());
            Dictionary prc = configuration.getProperties();
            if (prc == null) {
                prc = new Properties();
            }
            prc.put("message", "message2");
            configuration.update(prc);
            grace();
        } catch (Exception e) {
            fail(e.getMessage());
        }

        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        fs = (FooService) bc.getService(ref);
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = (Integer) p.get("count");
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
        if (mes.equals("message")) {
            System.out.println("Warning, configuration not yet applied");
View Full Code Here

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), conf.getPid());
        assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        // arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        FooService fs = (FooService) bc.getService(ref);
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = (Integer) p.get("count");
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertEquals("Check message", "message", mes);
        assertEquals("Check count", 1, count);

        //Update
        Configuration configuration;
        try {
            configuration = admin.getConfiguration(msp, getTestBundle().getLocation());
            Dictionary prc = configuration.getProperties();
            if (prc == null) {
                prc = new Properties();
            }
            prc.put("message", "message2");
            configuration.update(prc);
            grace();
        } catch (Exception e) {
            fail(e.getMessage());
        }

        // arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), conf.getPid());
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        // arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        fs = (FooService) bc.getService(ref);
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = (Integer) p.get("count");
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        if (mes.equals("message")) {
            System.out.println("Warning, configuration not yet applied");
View Full Code Here

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
        assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        FooService fs = (FooService) bc.getService(ref);
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = (Integer) p.get("count");
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
        assertEquals("Check message", "message2", mes); // Already reconfigured.
        assertEquals("Check count", 1, count);

        instance.dispose();

        //Reconfiguration
        try {
            configuration = admin.getConfiguration(msp, getTestBundle().getLocation());
            Dictionary prc = configuration.getProperties();
            if (prc == null) {
                prc = new Properties();
            }
            prc.put("message", "message3");
            configuration.update(prc);
            grace();
        } catch (Exception e) {
            fail(e.getMessage());
        }

        // Recreation of the instance.
        props = new Properties();
        props.put("managed.service.pid", msp);
        props.put("message", "message");
        instance = null;
        try {
            instance = factSvc.createComponentInstance(props);
            grace();
        } catch (Exception e) {
            fail(e.getMessage());
        }

        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
        assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        fs = (FooService) bc.getService(ref);
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = (Integer) p.get("count");
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
        assertEquals("Check message", "message3", mes); // Already reconfigured.
        assertEquals("Check count", 1, count);
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.