Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.ComponentFactory$PrimitiveTypeDescription


        }
    }
   
    public void testNoTransition() {
        try {
            ComponentFactory cf = new ComponentFactory(getContext(), getNoTransition());
            cf.start();
            ComponentInstance ci = cf.createComponentInstance(props);
            ci.dispose();
            cf.stop();
            fail("A lifecycle callback with a missing transition must be rejected " + cf);
        } catch (ConfigurationException e) {
           // OK
        } catch (UnacceptableConfiguration e) {
            fail("Unexpected exception when creating an instance : " + e.getMessage());
View Full Code Here


        }
    }
   
    public void testNoMethod() {
        try {
            ComponentFactory cf = new ComponentFactory(getContext(), getNoMethod());
            cf.start();
            ComponentInstance ci = cf.createComponentInstance(props);
            ci.dispose();
            cf.stop();
            fail("A lifecycle callback with a missing method must be rejected " + cf);
        }catch (ConfigurationException e) {
           // OK
        } catch (UnacceptableConfiguration e) {
            fail("Unexpected exception when creating an instance : " + e.getMessage());
View Full Code Here

        }
    }
   
    public void testBadMethod() {
        try {
            ComponentFactory cf = new ComponentFactory(getContext(), getBadMethod());
            cf.start();
            ComponentInstance ci = cf.createComponentInstance(props);
            if (ci.isStarted()) {
                fail("A lifecycle callback with a bad method must be rejected (instance stills valid)" + cf);
            }
            ci.dispose();
            cf.stop();
        } catch (ConfigurationException e) {
            //The check does not happen in the configure method.
            fail("Unexpected exception when creating an instance : " + e.getMessage());
        } catch (UnacceptableConfiguration e) {
            fail("Unexpected exception when creating an instance : " + e.getMessage());
View Full Code Here

        }
    }
   
    public void testBadMethod2() {
        try {
            ComponentFactory cf = new ComponentFactory(getContext(), getBadMethod2());
            cf.start();
            ComponentInstance ci = cf.createComponentInstance(props);
            ci.stop();
            if (ci.isStarted()) {
                fail("A lifecycle callback with a bad method must be rejected (instance stills valid)" + cf);
            }
            ci.dispose();
            cf.stop();
        } catch (ConfigurationException e) {
            //The check does not happen in the configure method.
            fail("Unexpected exception when creating an instance : " + e.getMessage());
        } catch (UnacceptableConfiguration e) {
            fail("Unexpected exception when creating an instance : " + e.getMessage());
View Full Code Here

        }
    }
   
    public void testBadTransition() {
        try {
            ComponentFactory cf = new ComponentFactory(getContext(), getBadTransition());
            cf.start();
            ComponentInstance ci = cf.createComponentInstance(props);
            ci.dispose();
            cf.stop();
            fail("A lifecycle callback with a bad transition must be rejected " + cf);
        } catch (ConfigurationException e) {
           // OK
        } catch (UnacceptableConfiguration e) {
            fail("Unexpected exception when creating an instance : " + e.getMessage());
View Full Code Here

    } catch(Exception e) {
      fail("Cannot instantiate under : " + e.getMessage());
    }
    assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
   
    ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
    ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
    ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
   
    fact1.stop();
    assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
   
    fact2.stop();
    assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
   
    fact3.stop();
    assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
    ServiceContext sc = Utils.getServiceContext(under);
    assertNull("Check that no Bar Service is available", sc.getServiceReference(BarService.class.getName()));
   
    fact1.start();
    assertTrue("Check instance validity - 5", under.getState() == ComponentInstance.VALID);
   
    under.dispose();
    fact2.start();
    fact3.start();
  }
View Full Code Here

    } catch(Exception e) {
      fail("Cannot instantiate under : " + e.getMessage());
    }
    assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
   
    ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
    ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
    ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
   
    fact1.stop();
    assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
   
    fact2.stop();
    assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
   
    fact3.stop();
    assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
   
    fact1.start();
    assertTrue("Check instance validity - 5", under.getState() == ComponentInstance.VALID);
   
    under.dispose();
    fact2.start();
    fact3.start();
  }
View Full Code Here

    assertNotNull("Check contained not null", contained);
    assertEquals("Check contained instances count ("+contained.length+") - 1", contained.length, 1);
    assertEquals("Check instance name" , id.getName(), "under");
    assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");
   
    ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
    ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
    ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
   
   
    fact1.stop();
    assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
    ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
    assertNotNull("Check architecture availability", ref);
    arch = (Architecture) getContext().getService(ref);
    //id = arch.getInstanceDescription();
    assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
    contained = id.getContainedInstances();
    assertEquals("Check contained instances count", contained.length, 1);
    assertEquals("Check instance name" , id.getName(), "under");
    assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");
   
    fact2.stop();
    assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
    ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
    assertNotNull("Check architecture availability", ref);
    arch = (Architecture) getContext().getService(ref);
    //id = arch.getInstanceDescription();
    assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
    contained = id.getContainedInstances();
    assertEquals("Check contained instances count", contained.length, 1);
    assertEquals("Check instance name" , id.getName(), "under");
    assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");

    fact3.stop();
    assertTrue("Check instance invalidity", under.getState() == ComponentInstance.VALID);
    ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
    assertNotNull("Check architecture availability", ref);
    arch = (Architecture) getContext().getService(ref);
    //id = arch.getInstanceDescription();
    assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
    contained = id.getContainedInstances();
    assertEquals("Check contained instances count", contained.length, 0);
    assertEquals("Check instance name" , id.getName(), "under");
    assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");

    fact1.start();
    assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
    ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
    assertNotNull("Check architecture availability", ref);
    arch = (Architecture) getContext().getService(ref);
    //id = arch.getInstanceDescription();
    assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
    contained = id.getContainedInstances();
    assertEquals("Check contained instances count", contained.length, 1);
    assertEquals("Check instance name" , id.getName(), "under");
    assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");

    getContext().ungetService(ref);
    under.dispose();
    fact2.start();
    fact3.start();
  }
View Full Code Here

      fail("Cannot instantiate under : " + e.getMessage());
    }
    ServiceContext sc = Utils.getServiceContext(under);
    assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
   
    ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
    ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
    ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
   
    fact1.stop();
    assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
    assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 2);
   
    fact2.stop();
    assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
    assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 1);
   
    fact3.stop();
    assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
    assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 0);
   
    fact1.start();
    assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 1);
    assertTrue("Check instance validity - 5", under.getState() == ComponentInstance.VALID);
   
    under.dispose();
    fact2.start();
    fact3.start();
  }
View Full Code Here

      fail("Cannot instantiate under : " + e.getMessage());
    }
    assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
    ServiceContext sc2 = Utils.getServiceContext(under);
   
    ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
    ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
    ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
   
    fact1.stop();
    assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
    assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 2);
   
    fact2.stop();
    assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
    assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 1);
   
    fact3.stop();
    assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
    assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 0);
   
    fact1.start();
    assertTrue("Check instance validity - 5", under.getState() == ComponentInstance.VALID);
    assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 1);
   
    under.dispose();
    fact2.start();
    fact3.start();
  }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.ComponentFactory$PrimitiveTypeDescription

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.