Package org.apache.tuscany.model.assembly

Examples of org.apache.tuscany.model.assembly.ExternalService


        assertEquals(GET_GREETINGS_QN, opInvoker.getWSDLOperationName());
    }

    public void testCreateExternalServiceContextFactory() {
        ExternalWebServiceBuilder builder = new ExternalWebServiceBuilder();
        ExternalService es = createMockExternalService();
        ExternalServiceContextFactory cf = builder.createExternalServiceContextFactory(es);
        assertNotNull(cf);
        Axis2ServiceInvoker si = (Axis2ServiceInvoker) cf.createContext().getHandler();
        assertNotNull(si);
    }
View Full Code Here


    interface Foo {
        public void getGreetings();
    };

    private ExternalService createMockExternalService() {
        ExternalService es = new ExternalService() {

            public List<Binding> getBindings() {
                return Arrays.asList(new Binding[] { createMockBinding() });
            }
View Full Code Here

    /**
     * Creates an external service configured with a {@link SystemBinding}
     */
    public static ExternalService createESSystemBinding(String name, String refName) {
        ExternalService es = systemFactory.createExternalService();
        es.setName(name);
        ConfiguredService configuredService = systemFactory.createConfiguredService();
        es.setConfiguredService(configuredService);
        SystemBinding binding = systemFactory.createSystemBinding();
        binding.setTargetName(refName);
        es.getBindings().add(binding);
        es.initialize(null);
        return es;
    }
View Full Code Here

    /**
     * Creates an external service that specifies an autowire of the given type
     */
    public static ExternalService createAutowirableExternalService(String name, Class type) {
        ExternalService es = systemFactory.createExternalService();
        es.setName(name);
        JavaServiceContract inter = systemFactory.createJavaServiceContract();
        inter.setInterface(type);
        Service service = systemFactory.createService();
        service.setServiceContract(inter);
        ConfiguredService cService = systemFactory.createConfiguredService();
        cService.setPort(service);
        cService.initialize(assemblyContext);
        es.setConfiguredService(cService);
        es.getBindings().add(systemFactory.createSystemBinding());
        es.initialize(null);
        return es;
    }
View Full Code Here

public class ExternalServiceLoaderTestCase extends LoaderTestSupport {

    public void testMinimal() throws XMLStreamException, ConfigurationLoadException {
        String xml = "<externalService xmlns='http://www.osoa.org/xmlns/sca/0.9' name='test'></externalService>";
        XMLStreamReader reader = getReader(xml);
        ExternalService es = (ExternalService) registry.load(reader, loaderContext);
        assertNotNull(es);
        assertEquals("test", es.getName());
        reader.require(XMLStreamConstants.END_ELEMENT, EXTERNAL_SERVICE.getNamespaceURI(), EXTERNAL_SERVICE.getLocalPart());
        assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next());
    }
View Full Code Here

    public void testInterface() throws XMLStreamException, ConfigurationLoadException {
        String interfaceName = MockService.class.getName();
        String xml = "<externalService xmlns='http://www.osoa.org/xmlns/sca/0.9' name='test'><interface.java interface='" + interfaceName + "'/></externalService>";
        XMLStreamReader reader = getReader(xml);
        ExternalService es = (ExternalService) registry.load(reader, loaderContext);
        reader.require(XMLStreamConstants.END_ELEMENT, EXTERNAL_SERVICE.getNamespaceURI(), EXTERNAL_SERVICE.getLocalPart());
        assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next());
        assertNotNull(es);
        assertEquals("test", es.getName());
        ConfiguredService configuredService = es.getConfiguredService();
        JavaServiceContract serviceContract = (JavaServiceContract) configuredService.getPort().getServiceContract();
        assertEquals(interfaceName, serviceContract.getInterfaceName());
    }
View Full Code Here

        // create a test module and wire an external service to the system entry point
        Component moduleComponent = MockFactory.createCompositeComponent("test.module");
        runtime.registerModelObject(moduleComponent);
        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("test.module");
        Assert.assertNotNull(moduleContext);
        ExternalService es = MockFactory.createESSystemBinding("TestService2ES", "tuscany.system/TestService2EP");
        moduleContext.registerModelObject(es);
        moduleContext.publish(new ModuleStart(this));
        Assert.assertNotNull(moduleContext.getContext("TestService2ES").getInstance(null));

        moduleContext.publish(new ModuleStop(this));
View Full Code Here

        // create a test module and wire an external service to the system entry point
        Component moduleComponent = MockFactory.createCompositeComponent("test.module");
        runtime.registerModelObject(moduleComponent);
        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("test.module");
        Assert.assertNotNull(moduleContext);
        ExternalService es = MockFactory.createAutowirableExternalService("TestService2ES", ModuleScopeSystemComponent.class);
        moduleContext.registerModelObject(es);

        system.publish(new ModuleStart(this));
        moduleContext.publish(new ModuleStart(this));
        // test that the autowire was resolved
View Full Code Here

        // create a test module
        Component moduleComponent = MockFactory.createCompositeComponent("module");
        runtime.registerModelObject(moduleComponent);
        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("module");
        ExternalService es = MockFactory.createESSystemBinding("TestServiceES", "tuscany.system/TestService1xEP");
        moduleContext.registerModelObject(es);

        // start the modules and test inter-module system wires
        system.publish(new ModuleStart(this));
        moduleContext.publish(new ModuleStart(this));
View Full Code Here

        CompositeContextImpl moduleContext1 = (CompositeContextImpl) runtime.getContext("module1");
        CompositeContextImpl moduleContext2 = (CompositeContextImpl) runtime.getContext("module2");

        Component component1 = factory.createSystemComponent("Component1", ModuleScopeSystemComponent.class, ModuleScopeSystemComponentImpl.class, Scope.MODULE);
        EntryPoint entryPoint1 = MockFactory.createEPSystemBinding("EntryPoint1", ModuleScopeSystemComponent.class, "Component1", component1);
        ExternalService externalService1 = MockFactory.createESSystemBinding("ExternalService1", "module2/EntryPoint2");
        moduleContext1.registerModelObject(component1);
        moduleContext1.registerModelObject(entryPoint1);
        moduleContext1.registerModelObject(externalService1);

        Component component2 = factory.createSystemComponent("Component2", ModuleScopeSystemComponent.class, ModuleScopeSystemComponentImpl.class, Scope.MODULE);
        EntryPoint entryPoint2 = MockFactory.createEPSystemBinding("EntryPoint2", ModuleScopeSystemComponent.class, "Component2", component2);
        ExternalService externalService2 = MockFactory.createESSystemBinding("ExternalService2", "module1/EntryPoint1");
        moduleContext2.registerModelObject(component2);
        moduleContext2.registerModelObject(entryPoint2);
        moduleContext2.registerModelObject(externalService2);

        moduleContext1.publish(new ModuleStart(this));
View Full Code Here

TOP

Related Classes of org.apache.tuscany.model.assembly.ExternalService

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.