Package org.apache.tuscany.spi.component

Examples of org.apache.tuscany.spi.component.ScopeRegistry


* @version $$Rev: 450456 $$ $$Date: 2006-09-27 07:28:36 -0700 (Wed, 27 Sep 2006) $$
*/
public class ScopeRegistryTestCase extends TestCase {
    public void testScopeContextCreation() throws Exception {
        WorkContext workContext = new WorkContextImpl();
        ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
        scopeRegistry.registerFactory(Scope.REQUEST, new RequestScopeObjectFactory());
        scopeRegistry.registerFactory(Scope.SESSION, new HttpSessionScopeObjectFactory(scopeRegistry));
        ScopeContainer request = scopeRegistry.getScopeContainer(Scope.REQUEST);
        assertTrue(request instanceof RequestScopeContainer);
        assertSame(request, scopeRegistry.getScopeContainer(Scope.REQUEST));
        ScopeContainer session = scopeRegistry.getScopeContainer(Scope.SESSION);
        assertTrue(session instanceof HttpSessionScopeContainer);
        assertSame(session, scopeRegistry.getScopeContainer(Scope.SESSION));
        assertNotSame(request, session);
    }
View Full Code Here


        assertNotSame(request, session);
    }

    public void testDeregisterFactory() throws Exception {
        WorkContext workContext = new WorkContextImpl();
        ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
        RequestScopeObjectFactory factory = new RequestScopeObjectFactory();
        scopeRegistry.registerFactory(Scope.REQUEST, factory);
        scopeRegistry.deregisterFactory(Scope.REQUEST);
        try {
            scopeRegistry.getScopeContainer(Scope.REQUEST);
            fail();
        } catch (ScopeNotFoundException e) {
            // expected
        }
    }
View Full Code Here

        }
    }

    public void testScopeNotRegistered() throws Exception {
        WorkContext workContext = new WorkContextImpl();
        ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
        try {
            scopeRegistry.getScopeContainer(Scope.REQUEST);
            fail();
        } catch (ScopeNotFoundException e) {
            // expected
        }
        try {
            scopeRegistry.getScopeContainer(Scope.SESSION);
            fail();
        } catch (ScopeNotFoundException e) {
            // expected
        }
        try {
            scopeRegistry.getScopeContainer(Scope.STATELESS);
            fail();
        } catch (ScopeNotFoundException e) {
            // expected
        }
    }
View Full Code Here

* @version $Rev: 441935 $ $Date: 2006-09-10 02:57:47 -0700 (Sun, 10 Sep 2006) $
*/
public class StatelessScopeObjectFactoryTestCase extends TestCase {

    public void testCreation() {
        ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class);
        registry.registerFactory(EasyMock.isA(Scope.class), EasyMock.isA(StatelessScopeObjectFactory.class));
        assertNotNull(new StatelessScopeObjectFactory(registry).getInstance());
    }
View Full Code Here

* @version $Rev: 441935 $ $Date: 2006-09-10 02:57:47 -0700 (Sun, 10 Sep 2006) $
*/
public class ModuleScopeObjectFactoryTestCase extends TestCase {

    public void testCreation() {
        ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class);
        registry.registerFactory(EasyMock.isA(Scope.class), EasyMock.isA(ModuleScopeObjectFactory.class));

        assertNotNull(new ModuleScopeObjectFactory(registry).getInstance());
    }
View Full Code Here

     * Create primordial deployer that can be used to load the system definition.
     *
     * @return the primordial deployer
     */
    public Deployer createDeployer() {
        ScopeRegistry scopeRegistry = createScopeRegistry(new WorkContextImpl());
        Builder builder = createBuilder(scopeRegistry);
        JavaInterfaceProcessorRegistry interfaceIntrospector = new JavaInterfaceProcessorRegistryImpl();
        Introspector introspector = createIntrospector(interfaceIntrospector);
        LoaderRegistry loader = createLoader(new PropertyObjectFactoryImpl(), introspector);
        return new DeployerImpl(xmlFactory, loader, builder);
View Full Code Here

     *
     * @param workContext the WorkContext the scopes should use
     * @return a new ScopeRegistry
     */
    public ScopeRegistry createScopeRegistry(WorkContext workContext) {
        ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
        new ModuleScopeObjectFactory(scopeRegistry); // self-registers
        return scopeRegistry;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.component.ScopeRegistry

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.