Package org.apache.tuscany.sca.assembly

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


    }

    @Test
    public void testReadWriteComposite() throws Exception {
        InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
        Composite composite = staxProcessor.read(is, Composite.class, context);
       
        verifyComposite(composite);
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(composite, bos, context);
View Full Code Here


    }

    @Test
    public void testReadWireWriteComposite() throws Exception {
        InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
        Composite composite = staxProcessor.read(is, Composite.class, context);
       
        URL url = getClass().getResource("test_definitions.xml");
        URI uri = URI.create("test_definitions.xml");
        Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
        assertNotNull(scaDefns);
View Full Code Here

    @Test
    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, context);
        assertNotNull(nestedComposite);
        resolver.addModel(nestedComposite, context);

        url = getClass().getResource("TestAllCalculator.composite");
        uri = URI.create("TestAllCalculator.composite");
        Composite composite = (Composite)documentProcessor.read(null, uri, url, context);

        documentProcessor.resolve(composite, resolver, context);

        assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
    }
View Full Code Here

    @Test
    public void testReadWriteCompositeWithAttributeProcessor() throws Exception {
      init(new TestAttributeProcessor());

      XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
      Composite composite = (Composite) staxProcessor.read(reader, context);
      assertNotNull(composite);
      reader.close();

      verifyComposite(composite);
     
View Full Code Here

    @Test
    public void testDefaultReadWriteComposite() throws Exception {
      init(null);

      XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
      Composite composite = (Composite) staxProcessor.read(reader, context);
      assertNotNull(composite);
      reader.close();

      verifyComposite(composite);
     
View Full Code Here

    public void testReadWriteComposite() throws Exception {
       
        // Read
        InputStream is = getClass().getResourceAsStream("NestedCalculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = compositeProcessor.read(reader, context);
        Component component = composite.getComponents().get(0);
        Composite implementation = (Composite)component.getImplementation();
        QName qname = implementation.getName();

        // Write
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
        compositeProcessor.write(composite, writer, context);
        writer.close();
        System.out.println("Writtent ouput is:\n" + bos);
       
        // Read again
        is = new ByteArrayInputStream(bos.toByteArray());
        reader = inputFactory.createXMLStreamReader(is);
        composite = compositeProcessor.read(reader, context);
       
        // Compare
        component = composite.getComponents().get(0);
        implementation = (Composite)component.getImplementation();
       
        assertEquals(qname, implementation.getName());
    }
View Full Code Here

    }

    @Test
    public void testReadComposite() throws Exception {
        InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
        Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
        assertNotNull(composite);
        assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator"));
        assertTrue(composite.isLocal());
        assertFalse(composite.getAutowire() == Boolean.TRUE);
        assertEquals(((PolicySubject)composite).getRequiredIntents().get(0).getName(), new QName("http://test",
                                                                                "confidentiality"));
        assertEquals(((PolicySubject)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));

        Composite include = composite.getIncludes().get(0);
        assertEquals(include.getName(), new QName("http://calc", "TestAllDivide"));

        CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0);
        assertEquals(calcCompositeService.getName(), "CalculatorService");
        assertTrue(calcCompositeService.getPromotedService().isUnresolved());
        assertEquals(calcCompositeService.getPromotedService().getName(),
View Full Code Here


    @Test
    public void testReadWriteComposite() throws Exception {
        InputStream is = getClass().getResourceAsStream("Multiplicity.composite");
        Composite composite = staxProcessor.read(is, Composite.class, context);
       
        verifyComposite(composite);
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(composite, bos, context);
View Full Code Here

            // Resolve deployable composites
            List<Composite> deployables = contribution.getDeployables();
            Artifact oldArtifact = context.setArtifact(contribution);
            try {
                for (int i = 0, n = deployables.size(); i < n; i++) {
                    Composite deployable = deployables.get(i);
                    Composite resolved =
                        (Composite)contributionResolver.resolveModel(Composite.class, deployable, context);
                    if (resolved != deployable) {
                        deployables.set(i, resolved);
                    }
                } // end for
View Full Code Here

    public CompositeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
        this.contribution = contribution;
    }

    public void addModel(Object resolved) {
        Composite composite = (Composite)resolved;
        map.put(composite.getName(), composite);
    }
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.