Package org.apache.tuscany.sca.assembly

Examples of org.apache.tuscany.sca.assembly.Composite


        TestUtils.checkProblems(customBuilder);
        checkScenario6and7Results("http://scenario6", true);
    }

    private void checkScenario6and7Results(String namespace, boolean nonWiring) {
        Composite domainComposite = customBuilder.getDomainComposite();

        // Should remove target= on ComponentB/reference2 (for Scenario 6) or
        //  CompositeC/reference2 (for Scenario 7), and add uri="http://foo.com/bar"
        //  to the <binding.ws> element on ComponentB/reference2
        // For nonWiring, ComponentB/reference2 should have target=
        //  and no uri= should be added
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        WebServiceBinding wsBinding = null;
        for (ComponentReference reference : componentB.getReferences()) {
            if ("reference2".equals(reference.getName())) {
                if (!nonWiring) {
                    assert reference.getTargets().size() == 0;
                } else {
                    assert reference.getTargets().size() == 1;
                }
                wsBinding = reference.getBinding(WebServiceBinding.class);
            }
        }
        if (!nonWiring) {
            assert "http://foo.com/bar".equals(wsBinding.getURI());
        } else {
            assert wsBinding.getURI() == null;
        }

        Definition def;
        javax.wsdl.Service svc;
        Port port;
        if (!nonWiring) {
            // Should create WSDL document for ComponentB/reference2 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        }

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
            // Should set <interface.wsdl> on inner component reference ComponentD/reference3
            wsBinding = null;
            for (ComponentReference reference : componentD.getReferences()) {
                if ("reference3".equals(reference.getName())) {
                    wsBinding = reference.getBinding(WebServiceBinding.class);
                    assert reference.getBindings().size() == 1;
                    assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
                }
            }
            assert "http://foo.com/bar".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not add <binding.ws> to any inner component references
            for (ComponentReference reference : componentD.getReferences()) {
                assert reference.getBinding(WebServiceBinding.class) == null;
            }
        }

        // No references on CompositeC should have <binding.ws> or <interface.wsdl>, except for
        //  reference2 in Scenario 7
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName(namespace, "CompositeC"));
        for (Reference reference : compositeC.getReferences()) {
            if ("http://scenario7".equals(namespace) && "reference2".equals(reference.getName())) {
                assert reference.getBinding(WebServiceBinding.class)!= null;
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            } else {
                assert reference.getBinding(WebServiceBinding.class) == null;
View Full Code Here


        TestUtils.checkProblems(customBuilder);
        checkScenario8Results(true);
    }

    private void checkScenario8Results(boolean nonWiring) {
        Composite domainComposite = customBuilder.getDomainComposite();

        // Should replace target= on ComponentD/reference3 by uri="http://foo.com/bar" on <binding.ws>
        // For nonWiring, the original target= is preserved and there is no uri=
        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        WebServiceBinding wsBinding = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3".equals(reference.getName())) {
                if (!nonWiring) {
                    assert reference.getTargets().size() == 0;
                } else {
                    assert reference.getTargets().size() == 1;
                }
                wsBinding = reference.getBinding(WebServiceBinding.class);
            }
        }
        if (!nonWiring) {
            assert "http://foo.com/bar".equals(wsBinding.getURI());
        } else {
            assert wsBinding.getURI() == null;
        }

        Definition def;
        javax.wsdl.Service svc;
        Port port;
        if (!nonWiring) {
            // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        }

        // Should add <binding.ws> and <interface.wsdl> to inner composite reference CompositeC/reference2
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario8", "CompositeC"));
        wsBinding = null;
        for (Reference reference : compositeC.getReferences()) {
            if ("reference2".equals(reference.getName())) {
                wsBinding = reference.getBinding(WebServiceBinding.class);
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            }
        }
View Full Code Here

        TestUtils.checkProblems(customBuilder);
        checkScenario9Results();
    }   

    private void checkScenario9Results() {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        ComponentReference componentRef = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3a".equals(reference.getName())) {
View Full Code Here

        TestUtils.checkProblems(customBuilder);
        checkScenario10And11Results();
    }

    private void checkScenario10And11Results() {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        ComponentReference componentRef = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3a".equals(reference.getName())) {
View Full Code Here

        TestUtils.checkProblems(customBuilder);
        checkScenario12Results();
    }

    private void checkScenario12Results() {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        ComponentReference componentRef = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3a".equals(reference.getName())) {
View Full Code Here

        TestUtils.checkProblems(customBuilder);
        checkScenario13Results();
    }

    private void checkScenario13Results() {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        ComponentReference componentRef = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3a".equals(reference.getName())) {
View Full Code Here

        XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
        CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, null, null);
       
        URL url = getClass().getResource("JavaScriptReference.composite");
        URI uri = URI.create("JavaScriptReference.composite");
        Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
        assertNotNull(composite);
    }
View Full Code Here

        XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
        CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, null, null);
       
        URL url = getClass().getResource("RMIBindingTest.composite");
        URI uri = URI.create("RMIBindingTest.composite");
        Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
        assertNotNull(composite);
    }
View Full Code Here

        assertNotNull(constrainingType);
        resolver.addModel(constrainingType);

        url = getClass().getResource("TestAllCalculator.composite");
        uri = URI.create("TestAllCalculator.constrainingType");
        Composite composite = (Composite)documentProcessor.read(null, uri, url);
        assertNotNull(composite);
       
        documentProcessor.resolve(composite, resolver);
       
        assertEquals(composite.getConstrainingType(), constrainingType);
        assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
    }
View Full Code Here

    }

    public void testResolveComposite() throws Exception {
        URL url = getClass().getResource("Calculator.composite");
        URI uri = URI.create("Calculator.composite");
        Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url);
        assertNotNull(nestedComposite);
        resolver.addModel(nestedComposite);

        url = getClass().getResource("TestAllCalculator.composite");
        uri = URI.create("TestAllCalculator.composite");
        Composite composite = (Composite)documentProcessor.read(null, uri, url);
       
        documentProcessor.resolve(composite, resolver);
       
        assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.assembly.Composite

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.