Package org.apache.tuscany.model.assembly

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


    private SystemAssemblyFactory factory = new SystemAssemblyFactoryImpl();
    private AssemblyContext assemblyContext = new AssemblyContextImpl(factory, null, null);
    
    public void testModelVisit() throws Exception {
        ComponentType componentType;
        Service service;
        SystemImplementation impl;
        Component component;

        Module module = factory.createModule();

        // create target component
        componentType = factory.createComponentType();
        service = factory.createService();
        service.setName("target");
        componentType.getServices().add(service);
        impl = factory.createSystemImplementation();
        impl.setComponentType(componentType);
        component = factory.createSimpleComponent();
        component.setName("target");
        component.setImplementation(impl);
        component.initialize(assemblyContext);
        module.getComponents().add(component);

        // create source component
        componentType = factory.createComponentType();
        Reference ref = factory.createReference();
        ref.setName("ref");
        componentType.getReferences().add(ref);
        impl = factory.createSystemImplementation();
        impl.setComponentType(componentType);
        component = factory.createSimpleComponent();
        component.setName("source");
        component.setImplementation(impl);
View Full Code Here


     *
     * @return ComponentType representing the implementation type metadata
     * @throws ConfigurationLoadException if there is an error introspecting the implementation type
     */
    public ComponentType introspect(Class<?> implClass) throws ConfigurationLoadException {
        ComponentType compType = factory.createComponentType();
        return introspect(implClass, compType);
    }
View Full Code Here

    private ComponentTypeIntrospector introspector;
    private AssemblyFactory factory;

    public void testServiceBasicProcessing() throws Exception {
        ComponentType type = factory.createComponentType();
        introspector.introspect(TestComponentImpl.class, type);
        assertEquals(1, type.getServices().size());
        ServiceContract contract = type.getServices().get(0).getServiceContract();
        assertEquals(TestComponent.class, contract.getInterface());
        assertEquals(Scope.MODULE, contract.getScope());
    }
View Full Code Here

        assertEquals(TestComponent.class, contract.getInterface());
        assertEquals(Scope.MODULE, contract.getScope());
    }

    public void testServiceNameSet() throws Exception {
        ComponentType type = factory.createComponentType();
        introspector.introspect(TestComponentImpl.class, type);
        assertEquals(1, type.getServices().size());
        Service service = type.getServices().get(0);
        assertEquals(JavaIntrospectionHelper.getBaseName(TestComponent.class), service.getName());
    }
View Full Code Here

    /**
     * Tests the case where a class implements one interface not marked as with <code>Remotable</code>
     */
    public void testSingleServiceProcessing() throws Exception {
        ComponentType type = factory.createComponentType();
        introspector.introspect(TestLocalComponentImpl.class, type);
        assertEquals(1, type.getServices().size());
        ServiceContract contract = type.getServices().get(0).getServiceContract();
        assertEquals(TestLocalComponent.class, contract.getInterface());
        assertEquals(Scope.MODULE, contract.getScope());
    }
View Full Code Here

    /**
     * Tests the case where an implementation specifies a service interface of its parent as opposed to the
     * single interface it directly implements
     */
    public void testInteraceHierarchyServiceProcessing() throws Exception {
        ComponentType type = factory.createComponentType();
        introspector.introspect(SuperFooImpl.class, type);
        assertEquals(1, type.getServices().size());
        ServiceContract contract = type.getServices().get(0).getServiceContract();
        assertEquals(SuperSuperFoo.class, contract.getInterface());
    }
View Full Code Here

    /**
     * Tests the case where a class implements two interfaces, with one specified using <code>@Service</code>
     * and one marked with <code>@Remotable</code>
     */
    public void testMutlipleServiceProcessing() throws Exception {
        ComponentType type = factory.createComponentType();
        introspector.introspect(TestMultipleInterfacesComponentImpl.class, type);
        assertEquals(2, type.getServices().size());
        for (Service service : type.getServices()) {
            if (!service.getServiceContract().equals(TestComponent.class) &&
                    service.getServiceContract().equals(TestLocalComponent.class)) {
                fail("Expected multiple interfaces not found");
            }
        }
View Full Code Here

    /**
     * Test case when an class implements two non-Remotable interfaces and does not specify one with
     * <code>@Service</code>
     */
    public void testNonServiceProcessing() throws Exception {
        ComponentType type = factory.createComponentType();
        introspector.introspect(TestNonServiceInterfacesImpl.class, type);
        assertEquals(1, type.getServices().size());
        ServiceContract contract = type.getServices().get(0).getServiceContract();
        assertEquals(TestNonServiceInterfacesImpl.class, contract.getInterface());
        assertEquals(Scope.MODULE, contract.getScope());
    }
View Full Code Here

*/
public class ComponentTypeLoaderTestCase extends LoaderTestSupport {

    public void testMinimal() throws XMLStreamException, ConfigurationLoadException {
        XMLStreamReader reader = getReader("<componentType xmlns='http://www.osoa.org/xmlns/sca/0.9'><service name='service1'/></componentType>");
        ComponentType type = (ComponentType) registry.load(reader, loaderContext);
        type.initialize(null);
        assertNotNull(type);
        assertEquals(1, type.getServices().size());
        Service service = type.getService("service1");
        assertEquals("service1", service.getName());
        assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next());
    }
View Full Code Here

    /**
     * Tests the case where a class implements two non-Remotable interfaces, with one specified using
     * <code>@Service</code>
     */
    public void testNonServiceSpecifiedProcessing() throws Exception {
        ComponentType type = factory.createComponentType();
        introspector.introspect(TestNonServiceSpecifiedImpl.class, type);
        assertEquals(1, type.getServices().size());
        ServiceContract contract = type.getServices().get(0).getServiceContract();
        assertEquals(TestNonServiceInterface.class, contract.getInterface());
        assertEquals(Scope.MODULE, contract.getScope());
    }
View Full Code Here

TOP

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

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.