Package org.apache.tuscany.core.component.scope

Examples of org.apache.tuscany.core.component.scope.ModuleScopeContainer$ComponentInitComparator


* @version $$Rev: 451895 $$ $$Date: 2006-10-01 23:58:18 -0700 (Sun, 01 Oct 2006) $$
*/
public class AtomicComponentWireInvocationTestCase extends TestCase {

    public void testWireResolution() throws NoSuchMethodException {
        ModuleScopeContainer scope = new ModuleScopeContainer(null);
        scope.start();
        Target target = new TargetImpl();
        SystemInboundWire inboundWire = EasyMock.createMock(SystemInboundWire.class);
        EasyMock.expect(inboundWire.getTargetService()).andReturn(target);
        EasyMock.replay(inboundWire);

View Full Code Here


    }

    public <I extends Implementation<?>> Component deploy(CompositeComponent parent,
                                                             ComponentDefinition<I> componentDefinition)
        throws LoaderException {
        ScopeContainer moduleScope = new ModuleScopeContainer();
        DeploymentContext deploymentContext = new RootDeploymentContext(null, xmlFactory, moduleScope, null);
        try {
            load(parent, componentDefinition, deploymentContext);
        } catch (LoaderException e) {
            e.addContextName(componentDefinition.getName());
View Full Code Here

public class ReferenceInjectionTestCase extends TestCase {

    private Map<String, Member> members;

    public void testProxiedReferenceInjection() throws Exception {
        ScopeContainer scope = new ModuleScopeContainer(null);
        scope.start();
        Map<String, AtomicComponent> contexts =
            MockFactory.createWiredComponents("source", SourceImpl.class, scope,
                members, "target", Target.class, TargetImpl.class, scope);
        AtomicComponent sourceComponent = contexts.get("source");
        Source source = (Source) sourceComponent.getServiceInstance();
        Target target = source.getTarget();
        assertTrue(Proxy.isProxyClass(target.getClass()));

        assertNotNull(target);
        scope.stop();
    }
View Full Code Here

    /**
     * Tests a basic invocation to a target
     */
    public void testTargetInvocation() throws Exception {
        ModuleScopeContainer scope = new ModuleScopeContainer(null);
        scope.start();
        List<Class<?>> services = new ArrayList<Class<?>>();
        services.add(Greeting.class);
        Map<String, Object> properties = new Hashtable<String,Object>();
        properties.put("greeting","HeyThere");
       
        RubyComponent context = new RubyComponent("source",
                                                                      implClass2,
                                                                      null,
                                                                      services,
                                                                      properties,
                                                                      null,
                                                                      scope,
                                                                      ArtifactFactory.createWireService(),
                                                                      null);
        scope.register(context);
        DataType<String> returnDataType = new DataType<String>(String.class, String.class.getName());
//        Operation<String> operation = new Operation<String>("greet",
//                                                        returnDataType,
//                                                        null,
//                                                        null,
//                                                        false,
//                                                        null);
//       
//        TargetInvoker invoker = context.createTargetInvoker(null,
//                                                            operation);
//        assertEquals("foo",
//                     invoker.invokeTarget(new String[]{"foo"}));
        scope.stop();
    }
View Full Code Here

    /**
     * Tests a basic invocation down a target wire
     */
    public void testTargetWireInvocation() throws Exception {
        ModuleScopeContainer scope = new ModuleScopeContainer(null);
        scope.start();
        List<Class<?>> services = new ArrayList<Class<?>>();
        services.add(Greeting.class);
        Map<String, Object> properties = new Hashtable<String,Object>();
        properties.put("greeting","HeyThere");
        RubyComponent context = new RubyComponent("source",
                                                                      implClass2,
                                                                      null,
                                                                      services,
                                                                      properties,
                                                                      null,
                                                                      scope,
                                                                      ArtifactFactory.createWireService(),
                                                                      null);
        scope.register(context);

        InboundWire wire = ArtifactFactory.createInboundWire("Greeting",
                                                                Greeting.class);
        ArtifactFactory.terminateWire(wire);
        for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
            chain.setTargetInvoker(context.createTargetInvoker(null,
                                                               chain.getOperation()));
        }
        context.addInboundWire(wire);
        Greeting greeting = (Greeting) context.getServiceInstance("Greeting");
        assertEquals("foo",
                     greeting.greet("foo"));
        scope.stop();
    }
View Full Code Here

    }

    protected void setUp() throws Exception {
        super.setUp();
        wireService = new JDKWireService();
        container = new ModuleScopeContainer();
        container.start();
        context = createMock(DeploymentContext.class);
        context.getModuleScope();
        expectLastCall().andReturn(container).anyTimes();
        replay(context);
View Full Code Here

    /**
     * Validates building a wire from an atomic context to an atomic context
     */
    public void testAtomicWireBuild() throws Exception {
        WorkContext work = new WorkContextImpl();
        ScopeContainer scope = new ModuleScopeContainer(work);
        scope.start();

        Connector connector = new ConnectorImpl();
        SystemComponentBuilder builder = new SystemComponentBuilder();

        CompositeComponent parent = new CompositeComponentImpl(null, null, connector, null);

        ComponentDefinition<SystemImplementation> targetComponentDefinition = MockComponentFactory.createTarget();
        ComponentDefinition<SystemImplementation> sourceComponentDefinition =
            MockComponentFactory.createSourceWithTargetReference();

        AtomicComponent sourceComponent = builder.build(parent, sourceComponentDefinition, deploymentContext);
        AtomicComponent targetComponent = builder.build(parent, targetComponentDefinition, deploymentContext);

        parent.register(sourceComponent);
        parent.register(targetComponent);
        parent.prepare();
        parent.start();
        scope.onEvent(new CompositeStart(this, parent));
        Source source = (Source) parent.getSystemChild("source").getServiceInstance();
        assertNotNull(source);
        Target target = (Target) parent.getSystemChild("target").getServiceInstance();
        assertNotNull(target);
        assertSame(target, source.getTarget());
        scope.onEvent(new CompositeStop(this, parent));
        parent.stop();
        scope.stop();
    }
View Full Code Here

    /**
     * Validates building a wire from an atomic context to a reference context
     */
    public void testAtomicToReferenceWireBuild() throws Exception {
        WorkContext work = new WorkContextImpl();
        ScopeContainer scope = new ModuleScopeContainer(work);
        scope.start();

        Connector connector = new ConnectorImpl();
        SystemComponentBuilder builder = new SystemComponentBuilder();
        SystemBindingBuilder bindingBuilder = new SystemBindingBuilder();

        CompositeComponent grandParent = new CompositeComponentImpl("grandparent", null, null, null);
        CompositeComponent parent = new CompositeComponentImpl("parent", grandParent, null, null);

        // create a context in the grandparent that the reference will be autowired to
        ComponentDefinition<SystemImplementation> targetComponentDefinition = MockComponentFactory.createTarget();
        AtomicComponent targetComponentComponent = builder.build(parent, targetComponentDefinition, deploymentContext);
        grandParent.register(targetComponentComponent);

        BoundReferenceDefinition<SystemBinding> targetReferenceDefinition = MockComponentFactory.createBoundReference();
        ComponentDefinition<SystemImplementation> sourceComponentDefinition =
            MockComponentFactory.createSourceWithTargetReference();

        AtomicComponent sourceComponent = builder.build(parent, sourceComponentDefinition, deploymentContext);
        Reference reference = bindingBuilder.build(parent, targetReferenceDefinition, deploymentContext);

        parent.register(sourceComponent);
        parent.register(reference);
        connector.connect(reference.getInboundWire(), reference.getOutboundWire(), true);
        connector.connect(sourceComponent);
        grandParent.register(parent);
        grandParent.start();
        scope.onEvent(new CompositeStart(this, parent));
        Source source = (Source) parent.getSystemChild("source").getServiceInstance();
        assertNotNull(source);
        Target target = (Target) parent.getSystemChild("target").getServiceInstance();
        assertNotNull(target);
        assertSame(target, source.getTarget());
        scope.onEvent(new CompositeStop(this, parent));
        grandParent.stop();
        scope.stop();
    }
View Full Code Here

    /**
     * Validates building a wire from a service context to an atomic context
     */
    public void testServiceToAtomicWireBuild() throws Exception {
        WorkContext work = new WorkContextImpl();
        ScopeContainer scope = new ModuleScopeContainer(work);
        scope.start();

        ConnectorImpl connector = new ConnectorImpl();
        SystemComponentBuilder builder = new SystemComponentBuilder();
        SystemBindingBuilder bindingBuilder = new SystemBindingBuilder();

        CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);

        BoundServiceDefinition<SystemBinding> serviceDefinition = MockComponentFactory.createBoundService();
        ComponentDefinition<SystemImplementation> componentDefinition = MockComponentFactory.createTarget();

        AtomicComponent sourceComponent = builder.build(parent, componentDefinition, deploymentContext);
        parent.register(sourceComponent);

        Service service = bindingBuilder.build(parent, serviceDefinition, deploymentContext);
        parent.register(service);

        connector.connect(sourceComponent);
        connector.connect(service);

        parent.start();
        scope.onEvent(new CompositeStart(this, parent));
        Target target = (Target) parent.getSystemChild("serviceDefinition").getServiceInstance();
        assertNotNull(target);
        Target target2 = (Target) parent.getSystemChild("target").getServiceInstance();
        assertNotNull(target);
        assertSame(target, target2);
        scope.onEvent(new CompositeStop(this, parent));
        parent.stop();
        scope.stop();

    }
View Full Code Here

    }

    protected void setUp() throws Exception {
        super.setUp();
        ModuleScopeContainer moduleScope = new ModuleScopeContainer();
        moduleScope.start();
        deploymentContext = new RootDeploymentContext(null, null, moduleScope, null);

    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.component.scope.ModuleScopeContainer$ComponentInitComparator

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.