Package org.apache.felix.ipojo.architecture

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


        Assert.assertNotNull(refs);
        Assert.assertEquals(2, refs.length);

        ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "mycons");
        Assert.assertNotNull(refv1);
        Architecture arch = (Architecture) osgi.getServiceObject(refv1);

        HandlerDescription desc = arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
        Assert.assertNotNull(desc);

        DependencyHandlerDescription d = (DependencyHandlerDescription) desc;
        Assert.assertNotNull(d.getDependencies());
        Assert.assertEquals(1, d.getDependencies().length);
View Full Code Here


        Assert.assertNotNull(refs);
        Assert.assertEquals(2, refs.length);

        ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "mycons");
        Assert.assertNotNull(refv1);
        Architecture arch = (Architecture) osgi.getServiceObject(refv1);

        HandlerDescription desc = arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
        Assert.assertNotNull(desc);

        DependencyHandlerDescription d = (DependencyHandlerDescription) desc;
        Assert.assertNotNull(d.getDependencies());
        Assert.assertEquals(1, d.getDependencies().length);
View Full Code Here

        } catch (InterruptedException e1) {
            fail(e1.getMessage());
        }

        Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
        Architecture arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");

        Assert.assertEquals("Is valid ?", ComponentInstance.VALID, arch.getInstanceDescription().getState());
  }
View Full Code Here

            fail(e1.getMessage());
        }

        // Invalid ... controller effect
        Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
        Architecture arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");

        Assert.assertEquals("Is invalid ?", ComponentInstance.INVALID, arch.getInstanceDescription().getState());

    // Reconfigure
    props = new Properties();
    props.put("prop", "OK");

    try {
            configuration.update(props);
        } catch (IOException e) {
            fail(e.getMessage());
        }

        pid = configuration.getPid();

        // Wait for the processing of the first configuration.
        try {
            Thread.sleep(UPDATE_WAIT_TIME);
        } catch (InterruptedException e1) {
            fail(e1.getMessage());
        }

        Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
        arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");

        Assert.assertEquals("Is valid ?", ComponentInstance.VALID, arch.getInstanceDescription().getState());
  }
View Full Code Here

        } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}
        if(refs != null) { sr = refs[0]; }
    assertNotNull("Check the check service availability", sr);
   
    ServiceReference sr_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "HandlerTest-1");
    Architecture arch = (Architecture) getContext().getService(sr_arch);
   
    assertEquals("Check instance validity - 0", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
   
    CheckService cs = (CheckService) getContext().getService(sr);
    Properties p = cs.getProps();
    Integer changes = (Integer) p.get("changes");
    assertNotNull("Check changes no null", changes);
    assertEquals("Changes changes 1 ("+changes+")", changes.intValue(), 1);
    assertEquals("Check instance validity - 1", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
    cs.check();
    p = cs.getProps();
    changes = (Integer) p.get("changes");
    assertEquals("Changes changes 2 ("+changes+")", changes.intValue(), 2);
    assertEquals("Check instance validity - 2", arch.getInstanceDescription().getState(), ComponentInstance.INVALID);
    cs.check();
    p = cs.getProps();
    changes = (Integer) p.get("changes");
    assertEquals("Changes changes 3 ("+changes+")", changes.intValue(), 3);
    assertEquals("Check instance validity - 3", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
    cs.check();
    p = cs.getProps();
    changes = (Integer) p.get("changes");
    assertEquals("Changes changes 4 ("+changes+")", changes.intValue(), 4);
    assertEquals("Check instance validity - 4", arch.getInstanceDescription().getState(), ComponentInstance.INVALID);
   
    cs = null;
    arch = null;
    getContext().ungetService(sr_arch);
    getContext().ungetService(sr);
View Full Code Here

            fail(e1.getMessage());
        }

        // Invalid ... controller effect
        Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
        Architecture arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");

        Assert.assertEquals("Is invalid ?", ComponentInstance.INVALID, arch.getInstanceDescription().getState());

    // Reconfigure
    props = new Properties();
    props.put("controller", "true");

    try {
            configuration.update(props);
        } catch (IOException e) {
            fail(e.getMessage());
        }

        pid = configuration.getPid();

        // Wait for the processing of the first configuration.
        try {
            Thread.sleep(UPDATE_WAIT_TIME);
        } catch (InterruptedException e1) {
            fail(e1.getMessage());
        }

        Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
        arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");

        Assert.assertEquals("Is valid ?", ComponentInstance.VALID, arch.getInstanceDescription().getState());
  }
View Full Code Here

        } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}
        if(refs != null) { sr = refs[0]; }
        assertNotNull("Check the check service availability", sr);
       
        ServiceReference sr_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "HandlerTest-1");
        Architecture arch = (Architecture) getContext().getService(sr_arch);
        assertEquals("Check validity", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
       
        // Kill the handler factory
        HandlerManagerFactory f = (HandlerManagerFactory) Utils.getHandlerFactoryByName(getContext(), "check");
        f.stop();
       
        sr = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "HandlerTest-1");
        assertNull("Check the check service unavailability", sr);
       
        sr_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "HandlerTest-1");
        assertNull("Check the architecture unavailability", sr_arch);
       
        // The instance is disposed, restart the handler
        f.start();
       
        Properties props = new Properties();
        props.put("instance.name","HandlerTest-1");
        props.put("csh.simple", "simple");
        Properties p = new Properties();
        p.put("a", "a");
        p.put("b", "b");
        p.put("c", "c");
        props.put("csh.map", p);
        instance = Utils.getComponentInstance(getContext(), "HANDLER-HandlerTester", props);
       
        sr = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "HandlerTest-1");
        assertNotNull("Check the check service availability - 2", sr);
       
        sr_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "HandlerTest-1");
        arch = (Architecture) getContext().getService(sr_arch);
        assertEquals("Check validity - 2", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
  }
View Full Code Here

    @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

    } 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

    }
   
    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

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.