Examples of Architecture


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

    @Test
    public void testInstanceArchitecture() {
          // Version 1.0
          ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-v1");
          Assert.assertNotNull(refv1);
          Architecture archv1 = (Architecture) osgi.getServiceObject(refv1);

          String version = archv1.getInstanceDescription().getComponentDescription().getVersion();
          Assert.assertEquals("1.0", version);

          // Version 1.1
          ServiceReference refv11 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-v1.1");
          Assert.assertNotNull(refv11);
          Architecture archv11 = (Architecture) osgi.getServiceObject(refv11);

          String version11 = archv11.getInstanceDescription().getComponentDescription().getVersion();
          Assert.assertEquals("1.1", version11);

          // No Version
          ServiceReference refany = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-any");
          Assert.assertNotNull(refany);
          Architecture archany = (Architecture) osgi.getServiceObject(refany);

          String any = archany.getInstanceDescription().getComponentDescription().getVersion();
          Assert.assertNotNull(any);

          // No version set in the factory, so no version.
          ServiceReference refmci = ipojo.getServiceReferenceByName(Architecture.class.getName(), "MyComponentInstance");
          Assert.assertNotNull(refmci);
          Architecture archmcy = (Architecture) osgi.getServiceObject(refmci);

          String mci = archmcy.getInstanceDescription().getComponentDescription().getVersion();
          Assert.assertNull(mci);

    }
View Full Code Here

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

    } catch(Exception e) {
      fail("Cannot instantiate under : " + e.getMessage());
    }
    ServiceReference ref = Utils.getServiceReference(getContext(), 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

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

    }
   
    public void testScope() {
        ServiceReference ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceContext(instance);
        ServiceReference ref2 = Utils.getServiceReference(sc, CheckService.class.getName(), null);
        assertNotNull("Check CheckService availability", ref2);
View Full Code Here

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

    } catch(Exception e) {
      fail("Cannot instantiate under : " + e.getMessage());
    }
    ServiceReference ref = Utils.getServiceReferenceByName(getContext(), 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

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

    } catch(Exception e) {
      fail("Cannot instantiate under : " + e.getMessage());
    }
    ServiceReference ref = Utils.getServiceReferenceByName(getContext(), 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

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

      fail("Cannot instantiate under : " + e.getMessage());
    }
   
    ServiceReference ref = Utils.getServiceReferenceByName(getContext(), 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

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

        instance1 = null;
        instance2 = null;
    }
   
    public void testArchitectureForInstance1() {
        Architecture arch = (Architecture) Utils.getServiceObject(context, Architecture.class.getName(), "(architecture.instance=instance)");
        assertNotNull(arch);
       
        // Test on String representation.
        String desc = arch.getInstanceDescription().getDescription().toString();
        assertTrue(desc.contains("managed.service.pid=\"FooProvider-3\""));
       
        // Test on handler description
        ConfigurationHandlerDescription hd = (ConfigurationHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
        assertNotNull(hd);
       
        assertEquals(2, hd.getProperties().length);
        assertEquals("FooProvider-3", hd.getManagedServicePid());
View Full Code Here

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

        assertEquals("FooProvider-3", hd.getManagedServicePid());

    }
   
    public void testArchitectureForInstance2() {
        Architecture arch = (Architecture) Utils.getServiceObject(context, Architecture.class.getName(), "(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());
View Full Code Here

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

        try {
            ServiceReference[] refs = internal.getServiceReferences(Architecture.class.getName(), null);
            if (refs != null) {
                InstanceDescription[] desc = new InstanceDescription[refs.length];
                for (int i = 0; i < refs.length; i++) {
                    Architecture arch = (Architecture) internal.getService(refs[i]);
                    desc[i] = arch.getInstanceDescription();
                    internal.ungetService(refs[i]);
                }
                return desc;
            }
        } catch (InvalidSyntaxException e) {
View Full Code Here

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

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

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

        assertEquals("Is valid ?", ComponentInstance.VALID, arch.getInstanceDescription().getState());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.