Package org.apache.tuscany.core.mock.component

Examples of org.apache.tuscany.core.mock.component.Source


        moduleComponent.setImplementation(module);
        runtime.getSystemContext().registerModelObject(moduleComponent);
        CompositeContext context = (CompositeContext) runtime.getSystemContext().getContext("test.system");
        context.publish(new ModuleStart(this));
        //context.registerModelObject(module);
        Source source = (Source) ((AtomicContext)context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        Target target = (Target) ((AtomicContext)context.getContext("target")).getTargetInstance();
        Assert.assertSame(target, targetRef);
        Source source2 = (Source) ((AtomicContext)context.getContext("source")).getTargetInstance();
        Assert.assertSame(target, source2.getTarget());
        context.publish(new ModuleStop(this));
        context.stop();
    }
View Full Code Here


        runtime.getSystemContext().registerModelObject(MockFactory.createSystemCompositeComponent("test.system"));
        CompositeContext context = (CompositeContext) runtime.getSystemContext().getContext("test.system");

        context.publish(new ModuleStart(this));
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.MODULE,Scope.MODULE));
        Source source = (Source) ((AtomicContext)context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        Target target = (Target) ((AtomicContext)context.getContext("target")).getTargetInstance();
        Assert.assertSame(target, targetRef);
        Source source2 = (Source) ((AtomicContext)context.getContext("source")).getTargetInstance();
        Assert.assertSame(target, source2.getTarget());
        context.publish(new ModuleStop(this));
        context.stop();
    }
View Full Code Here

    public void testSystemComponentResolution() throws NoSuchMethodException {
        CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
        parent.start();
        List<Class<?>> interfaces = new ArrayList<Class<?>>();
        interfaces.add(Source.class);
        Source originalSource = new SourceImpl();
        SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
        EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(component.getServiceInstance()).andReturn(originalSource);
        EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
        EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
        EasyMock.replay(component);
        parent.register(component);
        assertNull(parent.getChild("source"));
        AtomicComponent target = (AtomicComponent) parent.getSystemChild("source");
        Source source = (Source) target.getServiceInstance();
        assertNotNull(source);
        EasyMock.verify(component);
    }
View Full Code Here

    public void testLocateSystemService() throws NoSuchMethodException {
        CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
        parent.start();
        List<Class<?>> interfaces = new ArrayList<Class<?>>();
        interfaces.add(Source.class);
        Source originalSource = new SourceImpl();
        SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
        EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(component.getServiceInstance()).andReturn(originalSource);
        EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
        EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
        EasyMock.replay(component);
        parent.register(component);
        Source source = parent.locateSystemService(Source.class, "source");
        assertNotNull(source);
        EasyMock.verify(component);
    }
View Full Code Here

    public void testLocateService() throws NoSuchMethodException {
        CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
        parent.start();
        List<Class<?>> interfaces = new ArrayList<Class<?>>();
        interfaces.add(Source.class);
        Source originalSource = new SourceImpl();
        AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
        EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(component.getServiceInstance()).andReturn(originalSource);
        EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
        EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
        EasyMock.replay(component);
        parent.register(component);
        Source source = parent.locateService(Source.class, "source");
        assertNotNull(source);
        EasyMock.verify(component);
    }
View Full Code Here

    public void testComponentResolution() throws NoSuchMethodException {
        CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
        parent.start();
        List<Class<?>> interfaces = new ArrayList<Class<?>>();
        interfaces.add(Source.class);
        Source originalSource = new SourceImpl();
        AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
        EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(component.getServiceInstance()).andReturn(originalSource);
        EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
        EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
        EasyMock.replay(component);
        parent.register(component);
        assertNull(parent.getSystemChild("source"));
        AtomicComponent target = (AtomicComponent) parent.getChild("source");
        Source source = (Source) target.getServiceInstance();
        assertNotNull(source);
        EasyMock.verify(component);
    }
View Full Code Here

        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

        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

    }

    public void testSystemRestart() throws NoSuchMethodException {
        List<Class<?>> interfaces = new ArrayList<Class<?>>();
        interfaces.add(Source.class);
        Source originalSource = new SourceImpl();
        SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
        component.start();
        component.stop();
        EasyMock.expectLastCall().times(2);
        EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
        EasyMock.expect(component.getServiceInstance()).andReturn(originalSource).atLeastOnce();
        EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
        EasyMock.replay(component);

        CompositeComponent composite = new CompositeComponentImpl("foo", null, null, null);
        composite.start();
        composite.register(component);

        AtomicComponent atomicComponent = (AtomicComponent) composite.getSystemChild("source");
        Source source = (Source) atomicComponent.getServiceInstance();
        assertNotNull(source);
        composite.stop();
        composite.start();
        atomicComponent = (AtomicComponent) composite.getSystemChild("source");
        Source source2 = (Source) atomicComponent.getServiceInstance();
        assertNotNull(source2);
        composite.stop();
        EasyMock.verify(component);
    }
View Full Code Here

    }

    public void testRestart() throws NoSuchMethodException {
        List<Class<?>> interfaces = new ArrayList<Class<?>>();
        interfaces.add(Source.class);
        Source originalSource = new SourceImpl();
        AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
        component.start();
        component.stop();
        EasyMock.expectLastCall().times(2);
        EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
        EasyMock.expect(component.getServiceInstance()).andReturn(originalSource).atLeastOnce();
        EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
        EasyMock.replay(component);

        CompositeComponent composite = new CompositeComponentImpl("foo", null, null, null);
        composite.start();
        composite.register(component);

        AtomicComponent atomicComponent = (AtomicComponent) composite.getChild("source");
        Source source = (Source) atomicComponent.getServiceInstance();
        assertNotNull(source);
        composite.stop();
        composite.start();
        atomicComponent = (AtomicComponent) composite.getChild("source");
        Source source2 = (Source) atomicComponent.getServiceInstance();
        assertNotNull(source2);
        composite.stop();
        EasyMock.verify(component);
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.mock.component.Source

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.