Package org.apache.tuscany.core.context.impl

Examples of org.apache.tuscany.core.context.impl.CompositeContextImpl


        moduleContext.stop();
    }

    protected CompositeContext createContext() {
        List<ContextFactoryBuilder> builders = MockFactory.createSystemBuilders();
        return new CompositeContextImpl("test.context", null, new DefaultScopeStrategy(), new EventContextImpl(),
                new MockConfigContext(builders));
    }
View Full Code Here


public class JavaAtomicContextScopeTestCase extends TestCase {

    JavaAssemblyFactory factory = new JavaAssemblyFactoryImpl();

    public void testGetModuleInstance() throws Exception {
        CompositeContext mc = new CompositeContextImpl();
        mc.setName("mc");
        JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<ModuleScopeComponentImpl>(JavaIntrospectionHelper
                .getDefaultConstructor(ModuleScopeComponentImpl.class), null, null), false, null, null, false);
        GenericComponent service = (GenericComponent) c.getInstance(null);
        Assert.assertNotNull(service);
        service.setString("foo");
View Full Code Here

        Assert.assertNotNull(service2);
        Assert.assertSame(service, service2);
    }

    public void testGetSessionInstance() throws Exception {
        CompositeContext mc = new CompositeContextImpl();
        mc.setName("mc");
        JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<SessionScopeComponentImpl>(JavaIntrospectionHelper
                .getDefaultConstructor(SessionScopeComponentImpl.class), null, null), false, null, null, false);
        GenericComponent service = (GenericComponent) c.getInstance(null);
        Assert.assertNotNull(service);
        service.setString("foo");
View Full Code Here

        Assert.assertNotNull(service2);
        Assert.assertSame(service, service2);
    }

    public void testGetRequestInstance() throws Exception {
        CompositeContext mc = new CompositeContextImpl();
        mc.setName("mc");
        JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<RequestScopeComponentImpl>(JavaIntrospectionHelper
                .getDefaultConstructor(RequestScopeComponentImpl.class), null, null), false, null, null, false);
        GenericComponent service = (GenericComponent) c.getInstance(null);
        Assert.assertNotNull(service);
        service.setString("foo");
View Full Code Here

        Assert.assertNotNull(service2);
        Assert.assertSame(service, service2);
    }

    public void testGetStatelessInstance() throws Exception {
        CompositeContext mc = new CompositeContextImpl();
        mc.setName("fooContext");
        JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<StatelessComponentImpl>(JavaIntrospectionHelper
                .getDefaultConstructor(StatelessComponentImpl.class), null, null), false, null, null, true);
        GenericComponent service = (GenericComponent) c.getInstance(null);
        Assert.assertNotNull(service);
        service.setString("foo");
View Full Code Here

     * <p/>
     * <strong>NB:</strong> the test assumes an error with a message containing
     * "@ComponentName" is generated
     */
    public void testBadNameType() throws Exception {
        CompositeContext mc = new CompositeContextImpl();
        mc.setName("mc");
        try {
            MockFactory.createPojoContext("BadNamePojo", BadNamePojo.class, Scope.MODULE, mc);
        } catch (NoSuchMethodException e) {
            if (e.getMessage().indexOf("@ComponentName") < 0) {
                throw e;
View Full Code Here

     * <p/>
     * <strong>NB:</strong> the test assumes an error with a message containing
     * "@Context" is generated
     */
    public void testContextType() throws Exception {
        CompositeContext mc = new CompositeContextImpl();
        mc.setName("mc");
        try {
            MockFactory.createPojoContext("BadContextPojo", BadContextPojo.class, Scope.MODULE, mc);
        } catch (NoSuchMethodException e) {
            if (e.getMessage().indexOf("@Context") < 0) {
                throw e;
View Full Code Here

        targets = source.getTargetsThroughField();
        Assert.assertEquals(1, targets.size());
    }

    private CompositeContext createContext() {
        CompositeContextImpl context = new CompositeContextImpl();
        context.setName("system.context");
        List<ContextFactoryBuilder>builders = MockFactory.createSystemBuilders();
        WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
        builders.add(new JavaContextFactoryBuilder(wireService));
        List<WireBuilder> wireBuilders = new ArrayList<WireBuilder>();
        wireBuilders.add(new JavaTargetWireBuilder());
        context.setConfigurationContext(new MockConfigContext(builders,wireBuilders));
        return context;
    }
View Full Code Here

    /**
     * Ensures scope events are propagated in an composite scope
     */
    public void testCompositeScopePropagation() throws Exception {
        EventContext ctx = new EventContextImpl();
        CompositeContext moduleComponentCtx = new CompositeContextImpl();
        moduleComponentCtx.setName("testMC");
        moduleComponentCtx.start();
        CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
        scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
        scopeContainer.start();
        CompositeContext child = (CompositeContext) scopeContainer.getContext("CompositeComponent");
        List<Extensible> models = createAssembly();
View Full Code Here

    /**
     * Ensures only child entry points (and not components) are accessible from parents
     */
    public void testCompositeNoEntryPoint() throws Exception {
        EventContext ctx = new EventContextImpl();
        CompositeContext moduleComponentCtx = new CompositeContextImpl();
        moduleComponentCtx.setName("testMC");
        CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
        scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
        scopeContainer.start();
        CompositeContext child = (CompositeContext) scopeContainer.getContext("CompositeComponent");
        List<Extensible> parts = createAssembly();
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.context.impl.CompositeContextImpl

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.