Package org.apache.tuscany.core.context.scope

Examples of org.apache.tuscany.core.context.scope.RequestScopeContext.stop()


        // end request
        scope.onEvent(new RequestEnd(this, new Object()));
        Assert.assertTrue(initDestroy.isDestroyed());
        Assert.assertTrue(destroyOnly.isDestroyed());

        scope.stop();
    }

    /**
     * Test instances destroyed in proper (i.e. reverse) order
     */
 
View Full Code Here


        // end request
        scope.onEvent(new RequestEnd(this, new Object()));

        Assert.assertEquals(0, one.getNumberInstantiated());
        scope.stop();
    }


    JavaContextFactoryBuilder builder;
View Full Code Here

        Assert.assertNotNull(comp2);
        Assert.assertNotSame(comp1, comp2);
        Object id2 = new Object();
        scope.onEvent(new RequestEnd(this,id2));

        scope.stop();
    }

    public void testRegisterContextBeforeRequest() throws Exception {
        EventContext ctx = new EventContextImpl();
        RequestScopeContext scope = new RequestScopeContext(ctx);
View Full Code Here

        Assert.assertNotNull(comp1);
        RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
        Assert.assertNotNull(comp2);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));
        scope.stop();
    }

    public void testRegisterContextAfterRequest() throws Exception {
        EventContext ctx = new EventContextImpl();
        RequestScopeContext scope = new RequestScopeContext(ctx);
View Full Code Here

        scope.registerFactory(createConfiguration("NewTestService"));
        RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
        Assert.assertNotNull(comp2);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));
        scope.stop();
    }

    /**
     * Tests setting no components in the scope
     */
 
View Full Code Here

    public void testSetNullComponents() throws Exception {
        EventContext ctx = new EventContextImpl();
        RequestScopeContext scope = new RequestScopeContext(ctx);
        scope.registerFactories(createConfigurations());
        scope.start();
        scope.stop();
    }

    public void testGetComponentByKey() throws Exception {
        EventContext ctx = new EventContextImpl();
        RequestScopeContext scope = new RequestScopeContext(ctx);
View Full Code Here

        // second request
        // should be null since the other context (thread) expired w/ onEvent(..)
        Assert.assertNull(scope.getContextByKey("TestService1", Thread.currentThread()));
        // Note should test better using concurrent threads to pull the instance

        scope.stop();
    }


    private List<ContextFactory<Context>> createConfigurations() throws BuilderException, ConfigurationLoadException {
        AtomicComponent component = MockFactory.createComponent("TestService1", RequestScopeComponentImpl.class,
View Full Code Here

        assertNotNull(source.getPojo());
        // expire module
        assertEquals(2,source.getNumberInstantiated());
        scope.onEvent(new RequestEnd(this,request));
        assertEquals(0,source.getNumberInstantiated());
        scope.stop();
    }

}
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.