Package org.apache.aries.blueprint.testbundleb

Examples of org.apache.aries.blueprint.testbundleb.TestBean


        assertNotNull(beanContainer);

        //TestBeanA should have the values below, no interference should be present from other sources.
        Object obj1 = beanContainer.getComponentInstance("TestBeanA");
        assertTrue(obj1 instanceof TestBean);
        TestBean testBeanA = (TestBean)obj1;
        org.junit.Assert.assertEquals("RED", testBeanA.getRed());
        org.junit.Assert.assertEquals("GREEN", testBeanA.getGreen());
        org.junit.Assert.assertEquals("BLUE", testBeanA.getBlue());

        //TestBeanB tests that a custom ns handler is able to inject custom components to the blueprint,
        //and modify existing components, and use injected components as modifications.
        Object obj2 = beanContainer.getComponentInstance("TestBeanB");
        assertTrue(obj2 instanceof TestBean);
        TestBean testBeanB = (TestBean)obj2;
        //value should be set in via the added passthroughmetadata via the nshandler.
        org.junit.Assert.assertEquals("ONE_VALUE", testBeanB.getRed());
        org.junit.Assert.assertEquals("GREEN", testBeanB.getGreen());
        org.junit.Assert.assertEquals("BLUE", testBeanB.getBlue());       
       
        //TestBeanC tests that custom ns handlers can add interceptors to beans.
        Object obj3 = beanContainer.getComponentInstance("TestBeanC");
        assertTrue(obj3 instanceof TestBean);
        TestBean testBeanC = (TestBean)obj3;
      
        //handlers are in bundlea, with its own container.
        BlueprintContainer handlerContainer =
            Helper.getBlueprintContainerForBundle( context(), "org.apache.aries.blueprint.testbundlea");
        assertNotNull(handlerContainer);
       
        Object ns1 = handlerContainer.getComponentInstance("NSHandlerOne");
        assertTrue(ns1 instanceof NSHandlerOne);
       
        Object ns2 = handlerContainer.getComponentInstance("NSHandlerTwo");
        assertTrue(ns2 instanceof NSHandlerTwo);
        NSHandlerTwo nstwo = (NSHandlerTwo)ns2;
       
        //now we have a handle to the nshandler2, we can query what it 'saw', and ensure
        //that the interceptors are functioning as expected.
        List<String> log = nstwo.getLog();
       
        //TestBeanC has the interceptor configured, and is injected to OtherBeanA & OtherBeanB
        //which then uses the injected bean during their init method call, to invoke a method
        checkInterceptorLog(new String[] {
        "PRECALL:TestBeanC:methodToInvoke:[RED]:",
        "POSTCALL[true]:TestBeanC:methodToInvoke:[RED]:",
        "PRECALL:TestBeanC:methodToInvoke:[BLUE]:",
        "POSTCALL[false]:TestBeanC:methodToInvoke:[BLUE]:"
         }, log);
       
        //invoking GREEN is hardwired to cause an exception response, we do this
        //from here to ensure the exception occurs and is visible as expected
        RuntimeException re=null;
        try{
          testBeanC.methodToInvoke("GREEN");
        }catch(RuntimeException e){
            re=e;
        }
        assertNotNull("invocation of Green did not cause an exception as expected",re);
       
View Full Code Here


        assertNotNull(beanContainer);

        //TestBeanA should have the values below, no interference should be present from other sources.
        Object obj1 = beanContainer.getComponentInstance("TestBeanA");
        assertTrue(obj1 instanceof TestBean);
        TestBean testBeanA = (TestBean)obj1;
        org.junit.Assert.assertEquals("RED", testBeanA.getRed());
        org.junit.Assert.assertEquals("GREEN", testBeanA.getGreen());
        org.junit.Assert.assertEquals("BLUE", testBeanA.getBlue());

        //TestBeanB tests that a custom ns handler is able to inject custom components to the blueprint,
        //and modify existing components, and use injected components as modifications.
        Object obj2 = beanContainer.getComponentInstance("TestBeanB");
        assertTrue(obj2 instanceof TestBean);
        TestBean testBeanB = (TestBean)obj2;
        //value should be set in via the added passthroughmetadata via the nshandler.
        org.junit.Assert.assertEquals("ONE_VALUE", testBeanB.getRed());
        org.junit.Assert.assertEquals("GREEN", testBeanB.getGreen());
        org.junit.Assert.assertEquals("BLUE", testBeanB.getBlue());       
       
        //TestBeanC tests that custom ns handlers can add interceptors to beans.
        Object obj3 = beanContainer.getComponentInstance("TestBeanC");
        assertTrue(obj3 instanceof TestBean);
        TestBean testBeanC = (TestBean)obj3;
      
        //handlers are in bundlea, with its own container.
        BlueprintContainer handlerContainer =
            getBlueprintContainerForBundle( bundleContext , "org.apache.aries.blueprint.testbundlea", DEFAULT_TIMEOUT);
        assertNotNull(handlerContainer);
       
        Object ns1 = handlerContainer.getComponentInstance("NSHandlerOne");
        assertTrue(ns1 instanceof NSHandlerOne);
       
        Object ns2 = handlerContainer.getComponentInstance("NSHandlerTwo");
        assertTrue(ns2 instanceof NSHandlerTwo);
        NSHandlerTwo nstwo = (NSHandlerTwo)ns2;
       
        //now we have a handle to the nshandler2, we can query what it 'saw', and ensure
        //that the interceptors are functioning as expected.
        List<String> log = nstwo.getLog();
       
        //TestBeanC has the interceptor configured, and is injected to OtherBeanA & OtherBeanB
        //which then uses the injected bean during their init method call, to invoke a method
        checkInterceptorLog(new String[] {
        "PRECALL:TestBeanC:methodToInvoke:[RED]:",
        "POSTCALL[true]:TestBeanC:methodToInvoke:[RED]:",
        "PRECALL:TestBeanC:methodToInvoke:[BLUE]:",
        "POSTCALL[false]:TestBeanC:methodToInvoke:[BLUE]:"
         }, log);
       
        //invoking GREEN is hardwired to cause an exception response, we do this
        //from here to ensure the exception occurs and is visible as expected
        RuntimeException re=null;
        try{
          testBeanC.methodToInvoke("GREEN");
        }catch(RuntimeException e){
            re=e;
        }
        assertNotNull("invocation of Green did not cause an exception as expected",re);
       
View Full Code Here

        assertNotNull(beanContainer);

        //TestBeanA should have the values below, no interference should be present from other sources.
        Object obj1 = beanContainer.getComponentInstance("TestBeanA");
        assertTrue(obj1 instanceof TestBean);
        TestBean testBeanA = (TestBean)obj1;
        org.junit.Assert.assertEquals("RED", testBeanA.getRed());
        org.junit.Assert.assertEquals("GREEN", testBeanA.getGreen());
        org.junit.Assert.assertEquals("BLUE", testBeanA.getBlue());

        //TestBeanB tests that a custom ns handler is able to inject custom components to the blueprint,
        //and modify existing components, and use injected components as modifications.
        Object obj2 = beanContainer.getComponentInstance("TestBeanB");
        assertTrue(obj2 instanceof TestBean);
        TestBean testBeanB = (TestBean)obj2;
        //value should be set in via the added passthroughmetadata via the nshandler.
        org.junit.Assert.assertEquals("ONE_VALUE", testBeanB.getRed());
        org.junit.Assert.assertEquals("GREEN", testBeanB.getGreen());
        org.junit.Assert.assertEquals("BLUE", testBeanB.getBlue());       
       
        //TestBeanC tests that custom ns handlers can add interceptors to beans.
        Object obj3 = beanContainer.getComponentInstance("TestBeanC");
        assertTrue(obj3 instanceof TestBean);
        TestBean testBeanC = (TestBean)obj3;
      
        //handlers are in bundlea, with its own container.
        BlueprintContainer handlerContainer =
            getBlueprintContainerForBundle( bundleContext , "org.apache.aries.blueprint.testbundlea", 5000);
        assertNotNull(handlerContainer);
       
        Object ns1 = handlerContainer.getComponentInstance("NSHandlerOne");
        assertTrue(ns1 instanceof NSHandlerOne);
       
        Object ns2 = handlerContainer.getComponentInstance("NSHandlerTwo");
        assertTrue(ns2 instanceof NSHandlerTwo);
        NSHandlerTwo nstwo = (NSHandlerTwo)ns2;
       
        //now we have a handle to the nshandler2, we can query what it 'saw', and ensure
        //that the interceptors are functioning as expected.
        List<String> log = nstwo.getLog();
       
        //TestBeanC has the interceptor configured, and is injected to OtherBeanA & OtherBeanB
        //which then uses the injected bean during their init method call, to invoke a method
        checkInterceptorLog(new String[] {
        "PRECALL:TestBeanC:methodToInvoke:[RED]:",
        "POSTCALL[true]:TestBeanC:methodToInvoke:[RED]:",
        "PRECALL:TestBeanC:methodToInvoke:[BLUE]:",
        "POSTCALL[false]:TestBeanC:methodToInvoke:[BLUE]:"
         }, log);
       
        //invoking GREEN is hardwired to cause an exception response, we do this
        //from here to ensure the exception occurs and is visible as expected
        RuntimeException re=null;
        try{
          testBeanC.methodToInvoke("GREEN");
        }catch(RuntimeException e){
            re=e;
        }
        assertNotNull("invocation of Green did not cause an exception as expected",re);
       
View Full Code Here

        assertNotNull(beanContainer);

        //TestBeanA should have the values below, no interference should be present from other sources.
        Object obj1 = beanContainer.getComponentInstance("TestBeanA");
        assertTrue(obj1 instanceof TestBean);
        TestBean testBeanA = (TestBean)obj1;
        org.junit.Assert.assertEquals("RED", testBeanA.getRed());
        org.junit.Assert.assertEquals("GREEN", testBeanA.getGreen());
        org.junit.Assert.assertEquals("BLUE", testBeanA.getBlue());

        //TestBeanB tests that a custom ns handler is able to inject custom components to the blueprint,
        //and modify existing components, and use injected components as modifications.
        Object obj2 = beanContainer.getComponentInstance("TestBeanB");
        assertTrue(obj2 instanceof TestBean);
        TestBean testBeanB = (TestBean)obj2;
        //value should be set in via the added passthroughmetadata via the nshandler.
        org.junit.Assert.assertEquals("ONE_VALUE", testBeanB.getRed());
        org.junit.Assert.assertEquals("GREEN", testBeanB.getGreen());
        org.junit.Assert.assertEquals("BLUE", testBeanB.getBlue());       
       
        //TestBeanC tests that custom ns handlers can add interceptors to beans.
        Object obj3 = beanContainer.getComponentInstance("TestBeanC");
        assertTrue(obj3 instanceof TestBean);
        TestBean testBeanC = (TestBean)obj3;
      
        //handlers are in bundlea, with its own container.
        BlueprintContainer handlerContainer =
            Helper.getBlueprintContainerForBundle( context(), "org.apache.aries.blueprint.testbundlea");
        assertNotNull(handlerContainer);
       
        Object ns1 = handlerContainer.getComponentInstance("NSHandlerOne");
        assertTrue(ns1 instanceof NSHandlerOne);
       
        Object ns2 = handlerContainer.getComponentInstance("NSHandlerTwo");
        assertTrue(ns2 instanceof NSHandlerTwo);
        NSHandlerTwo nstwo = (NSHandlerTwo)ns2;
       
        //now we have a handle to the nshandler2, we can query what it 'saw', and ensure
        //that the interceptors are functioning as expected.
        List<String> log = nstwo.getLog();
       
        //TestBeanC has the interceptor configured, and is injected to OtherBeanA & OtherBeanB
        //which then uses the injected bean during their init method call, to invoke a method
        checkInterceptorLog(new String[] {
        "PRECALL:TestBeanC:methodToInvoke:[RED]:",
        "POSTCALL[true]:TestBeanC:methodToInvoke:[RED]:",
        "PRECALL:TestBeanC:methodToInvoke:[BLUE]:",
        "POSTCALL[false]:TestBeanC:methodToInvoke:[BLUE]:"
         }, log);
       
        //invoking GREEN is hardwired to cause an exception response, we do this
        //from here to ensure the exception occurs and is visible as expected
        RuntimeException re=null;
        try{
          testBeanC.methodToInvoke("GREEN");
        }catch(RuntimeException e){
            re=e;
        }
        assertNotNull("invocation of Green did not cause an exception as expected",re);
       
View Full Code Here

TOP

Related Classes of org.apache.aries.blueprint.testbundleb.TestBean

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.