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

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


        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");
        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");
        assertNotNull("Assert toto service - 3", refToto);
        assertNotNull("Assert tata service - 3", refTata);
        Toto toto = (Toto) getContext().getService(refToto);
        Tata tata = (Tata) getContext().getService(refTata);

        invokeAll(tata);
        invokeToto(toto);

        // Check toto
        Properties props = toto.getProps();
        Integer toto_0 = (Integer) props.get("toto");
        Integer toto_2 = (Integer) props.get("toto_2");
        Integer toto_3 = (Integer) props.get("toto_3");
        Integer toto_4 = (Integer) props.get("toto_4");
        Integer toto_1 = (Integer) props.get("toto1");
        assertEquals("Assert toto - 3 (" + toto_0.intValue() + ")", toto_0.intValue(), 1);
        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
        assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);
        //Check tata
        props = tata.getPropsTata();
        Integer tata_0 = (Integer) props.get("tata");
        assertEquals("Assert tata - 3", tata_0.intValue(), 1);

        getContext().ungetService(refToto);
        getContext().ungetService(refTata);
        toto = null;
        tata = null;

        // Start a second import
        totoProv2.start();
        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");
        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");
        assertNotNull("Assert toto service - 4", refToto);
        assertNotNull("Assert tata service - 4", refTata);

        toto = (Toto) getContext().getService(refToto);
        tata = (Tata) getContext().getService(refTata);
        invokeAll(tata);
        invokeToto(toto);

        // Check toto
        props = toto.getProps();
        toto_0 = (Integer) props.get("toto");
        toto_2 = (Integer) props.get("toto_2");
        toto_3 = (Integer) props.get("toto_3");
        toto_4 = (Integer) props.get("toto_4");
        toto_1 = (Integer) props.get("toto1");
        assertEquals("Assert toto - 4 (" + toto_0.intValue() + ")", toto_0.intValue(), 2);
        assertEquals("Assert toto_2 - 4 (" + toto_2.intValue() + ")", toto_2.intValue(), 2);
        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
        assertEquals("Assert toto1 - 4", toto_1.intValue(), 3);
        //Check tata
        props = tata.getPropsTata();
        tata_0 = (Integer) props.get("tata");
        assertEquals("Assert tata - 4", tata_0.intValue(), 2);
        getContext().ungetService(refToto);
        getContext().ungetService(refTata);
        toto = null;
        tata = null;

        // Stop the factory
        tataFactory.stop();
        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");
        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");
        assertNull("Assert no toto service - 5", refToto);
        assertNull("Assert no tata service - 5", refTata);

        totoProv2.stop();
        totoProv.stop();
        tataFactory.start();
        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");
        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");
        assertNotNull("Assert toto service - 6", refToto);
        assertNotNull("Assert tata service - 6", refTata);
        toto = (Toto) getContext().getService(refToto);
        tata = (Tata) getContext().getService(refTata);

        invokeAll(tata);
        invokeTotoOpt(toto);
        //  Check tata
        props = tata.getPropsTata();
        tata_0 = (Integer) props.get("tata");
        assertEquals("Assert tata - 6", tata_0.intValue(), 1);
        getContext().ungetService(refToto);
        getContext().ungetService(refTata);
        toto = null;
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.runtime.core.services.Tata

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.