Package org.apache.felix.ipojo.architecture

Examples of org.apache.felix.ipojo.architecture.Architecture


    }

    @Test
    public void testArchitectureForInstance2() {
        Architecture arch = osgiHelper.getServiceObject(Architecture.class, "(architecture.instance=instance-2)");
        assertNotNull(arch);

        // Test on String representation.
        String desc = arch.getInstanceDescription().getDescription().toString();
        assertTrue(desc.contains("managed.service.pid=\"instance\""));

        // Test on handler description
        ConfigurationHandlerDescription hd = (ConfigurationHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
        assertNotNull(hd);

        assertEquals(2, hd.getProperties().length);
        assertEquals("instance", hd.getManagedServicePid());

        // Check the getInstance() method
        assertSame(arch.getInstanceDescription().getInstance(), instance2);

    }
View Full Code Here


     */
    @Test
    public void testArchitectureServiceAvailability() {
        String instanceName = instance1.getInstanceName();
        // Check architecture of instance1
        Architecture arch = ipojoHelper.getArchitectureByName(instanceName);
        assertNotNull(arch);
        assertEquals(ComponentInstance.VALID, arch.getInstanceDescription().getState());

        // We stop the instance
        instance1.stop();
        arch = ipojoHelper.getArchitectureByName(instanceName);
        assertNotNull(arch);
        assertEquals(ComponentInstance.STOPPED, arch.getInstanceDescription().getState());

        // Restart.
        instance1.start();
        arch = ipojoHelper.getArchitectureByName(instanceName);
        assertNotNull(arch);
        assertEquals(ComponentInstance.VALID, arch.getInstanceDescription().getState());

        // Disposal
        instance1.dispose();
        arch = ipojoHelper.getArchitectureByName(instanceName);
        assertNull(arch);
View Full Code Here

        osgiHelper.waitForService(Architecture.class.getName(), "(architecture.instance=c)", 10000);
        osgiHelper.waitForService(Architecture.class.getName(), "(architecture.instance=d)", 10000);

        Object[] arch = osgiHelper.getServiceObjects(Architecture.class.getName(), null);
        for (Object o : arch) {
            Architecture a = (Architecture) o;
            if (a.getInstanceDescription().getState() != ComponentInstance.VALID) {
                Assert.fail("Instance " + a.getInstanceDescription().getName() + " not valid : " + a.getInstanceDescription().getDescription());
            }
        }
    }
View Full Code Here

        osgiHelper.waitForService(Architecture.class.getName(), "(architecture.instance=d)", 10000);
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "d");
        Assert.assertNotNull(ref);

        Architecture arch = (Architecture) osgiHelper.getRawServiceObject(ref);

        System.out.println(arch.getInstanceDescription().getDescription());

        Assert.assertEquals(ComponentInstance.VALID, arch.getInstanceDescription().getState());
        DependencyDescription dd = getDependency(arch, "org.apache.felix.ipojo.runtime.core.components.inheritance.b.IB");

        Assert.assertTrue(!dd.getServiceReferences().isEmpty());

        ServiceReference dref = (ServiceReference) dd.getServiceReferences().get(0);
View Full Code Here

        } catch (Exception e) {
            fail("Cannot instantiate under : " + e.getMessage());
        }
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");
        assertNotNull("Check architecture availability", ref);
        Architecture arch = (Architecture) getContext().getService(ref);
        CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();

        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
        InstanceDescription[] contained = id.getContainedInstances();
        assertEquals("Check contained instances count", contained.length, 1);
        assertEquals("Check instance name", id.getName(), "under");
View Full Code Here

            fail("Cannot instantiate under : " + e.getMessage());
        }
        ServiceReference ref = osgiHelper.getServiceReference(Architecture.class.getName(),
                "(architecture.instance=under)");
        assertNotNull("Check architecture availability", ref);
        Architecture arch = (Architecture) getContext().getService(ref);
        CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();

        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
        InstanceDescription[] contained = id.getContainedInstances();
        assertEquals("Check contained instances count (" + contained.length + ")", contained.length, 1);
        assertEquals("Check instance name", id.getName(), "under");
View Full Code Here

      fail("Cannot instantiate under : " + e.getMessage());
    }
   
    ServiceReference ref = ipojoHelper.getServiceReferenceByName( Architecture.class.getName(), "under");
    assertNotNull("Check architecture availability", ref);
    Architecture arch = (Architecture) getContext().getService(ref);
    assertNotNull("Check architecture", arch);
        CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();
    assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
    InstanceDescription[] contained = id.getContainedInstances();
    assertNotNull("Check contained not null", contained);
    assertEquals("Check contained instances count ("+contained.length+") - 1", contained.length, 1);
    assertEquals("Check instance name" , id.getName(), "under");
View Full Code Here

    @Test
    public void testScope() {
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance.getInstanceName());
        assertNotNull("Check architecture availability", ref);
        Architecture arch = (Architecture) getContext().getService(ref);
        assertTrue("Validity", arch.getInstanceDescription().getState() == ComponentInstance.VALID);

        // Get internal service
        ServiceContext sc = getServiceContext(instance);
        ServiceReference ref2 = ipojoHelper.getServiceReference(sc, CheckService.class.getName(), null);
        assertNotNull("Check CheckService availability", ref2);
View Full Code Here

        } catch (Exception e) {
            fail("Cannot instantiate under : " + e.getMessage());
        }
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");
        assertNotNull("Check architecture availability", ref);
        Architecture arch = (Architecture) getContext().getService(ref);
        CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();

        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
        InstanceDescription[] contained = id.getContainedInstances();
        assertEquals("Check contained instances count", contained.length, 3);
        assertEquals("Check instance name", id.getName(), "under");
View Full Code Here

     */
    @Test
    public void testCreationOfIgnoreCase1() {
          ServiceReference refv1 = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "IgnoreCase-1");
          Assert.assertNotNull(refv1);
          Architecture arch = (Architecture) osgiHelper.getRawServiceObject(refv1);
          Assert.assertEquals(ComponentInstance.VALID, arch.getInstanceDescription().getState());

          HandlerDescription desc = arch.getInstanceDescription()
              .getHandlerDescription("orG.apAche.feliX.iPOJO.tests.CORE.hAnDlEr:EmPtY")// Check with the declared name.

          Assert.assertNotNull(desc);
          Assert.assertTrue(desc.isValid());
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.architecture.Architecture

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.