Package org.apache.tuscany.sca

Examples of org.apache.tuscany.sca.Node


    }

    @Test
    public void startTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
        Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
        node.installContribution("src/test/resources/sample-helloworld.jar");
        Assert.assertEquals(0, node.getStartedCompositeURIs().size());

        node.startComposite("sample-helloworld", "helloworld.composite");
        Assert.assertEquals(1, node.getStartedCompositeURIs().size());
        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
       
        node.stopComposite("sample-helloworld", "helloworld.composite");
//        Assert.assertEquals(0, node.getStartedComposites().size());
        node.startComposite("sample-helloworld", "helloworld.composite");
        Assert.assertEquals(1, node.getStartedCompositeURIs().size());
        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
        node.stopComposite("sample-helloworld", "helloworld.composite");
    }
View Full Code Here


    @Ignore("TUSCANY-3953")
    @Test
    public void startDistributedTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, InterruptedException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        try {
        Node node = runtime.createNode("uri:ImportTestCase");
        Node node2 = runtime.createNode("uri:ImportTestCase");
       
        node.installContribution("src/test/resources/sample-helloworld.jar");
        Assert.assertEquals(1, node.getInstalledContributionURIs().size());
        Assert.assertEquals(1, node2.getInstalledContributionURIs().size());

        node.startComposite("sample-helloworld", "helloworld.composite");
        Assert.assertEquals(1, node.getStartedCompositeURIs().size());
        Assert.assertEquals(1, node2.getStartedCompositeURIs().size());

        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
        Assert.assertEquals("helloworld.composite", node2.getStartedCompositeURIs().get("sample-helloworld").get(0));
       
        node.stopComposite("sample-helloworld", "helloworld.composite");
        Assert.assertEquals(0, node.getStartedCompositeURIs().size());
        Assert.assertEquals(0, node2.getStartedCompositeURIs().size());

        node2.startComposite("sample-helloworld", "helloworld.composite");
        Assert.assertEquals(1, node.getStartedCompositeURIs().size());
        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));

        Assert.assertEquals(1, node2.getStartedCompositeURIs().size());
        Assert.assertEquals("helloworld.composite", node2.getStartedCompositeURIs().get("sample-helloworld").get(0));

    } finally {
        runtime.stop();
    }
    }
View Full Code Here

    }
    }

    @Test
    public void addDeploymentCompositeTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
        Node node = TuscanyRuntime.newInstance().createNode("addDeploymentCompositeTest");
        String curi = node.installContribution("src/test/resources/sample-helloworld.jar");

        String compositeXML =
            "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
                + "     xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
                + "     targetNamespace=\"http://test/composite\""
                + "     name=\"TestComposite\">"
                + "   <component name=\"TestComponent\">"
                + "      <implementation.java class=\"sample.HelloworldImpl\"/>"
                + "   </component>"
                + "</composite>";
        String compositeURI = node.addDeploymentComposite(curi, new StringReader(compositeXML));

        node.startComposite(curi, compositeURI);
        Assert.assertEquals(1, node.getStartedCompositeURIs().size());
       
        Composite dc = node.getDomainComposite();
        Assert.assertEquals(1, dc.getIncludes().size());
        Composite runningComposite = dc.getIncludes().get(0);
        Assert.assertEquals("TestComposite", runningComposite.getName().getLocalPart());
    }
View Full Code Here

        Assert.assertEquals("TestComposite", runningComposite.getName().getLocalPart());
    }

    @Test
    public void invalidCompositeStartTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
        Node node = TuscanyRuntime.newInstance().createNode("invalidCompositeStartTest");
        String curi = node.installContribution("src/test/resources/helloworld-invalidComposite.jar");
        Assert.assertEquals(1, node.getInstalledContributionURIs().size());
        Assert.assertEquals(0, node.getStartedCompositeURIs().size());
        ContributionDescription cd = node.getInstalledContribution(curi);
        Assert.assertEquals(1, cd.getDeployables().size());
       
        String compositeXML =
            "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
                + "     xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
                + "     targetNamespace=\"http://test/composite\""
                + "     name=\"TestComposite\">"
                + "   <component name=\"TestComponent\">"
                + "      <implementation.java class=\"sample.HelloworldImpl\"/>"
                + "   </component>"
                + "</composite>";
        String compositeURI = node.addDeploymentComposite(curi, new StringReader(compositeXML));
        node.startComposite(curi, compositeURI);

//        node.startComposite("sample-helloworld", "helloworld.composite");
//        Assert.assertEquals(1, node.getStartedCompositeURIs().size());
//        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
//       
View Full Code Here

//        node.stopComposite("sample-helloworld", "helloworld.composite");
    }

    @Test
    public void stopAndUnistallTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
        Node node = TuscanyRuntime.newInstance().createNode("stopAndUnistallTest");
        node.installContribution("src/test/resources/import.jar");
        node.installContribution("src/test/resources/export.jar");
        String compositeXML =
            "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
                + "     xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
                + "     targetNamespace=\"http://test/composite\""
                + "     name=\"TestComposite\">"
                + "   <component name=\"TestComponent\">"
                + "      <implementation.java class=\"sample.HelloworldImpl\"/>"
                + "   </component>"
                + "</composite>";
        String compositeURI = node.addDeploymentComposite("export", new StringReader(compositeXML));
        node.startComposite("import", "helloworld.composite");
        node.startComposite("export", compositeURI);
        Assert.assertEquals(2, node.getInstalledContributionURIs().size());
        node.stopCompositeAndUninstallUnused("import", "helloworld.composite");
        Assert.assertEquals(1, node.getInstalledContributionURIs().size());
        node.stopCompositeAndUninstallUnused("export", compositeURI);
        Assert.assertEquals(0, node.getInstalledContributionURIs().size());
    }
View Full Code Here

public class DirectoryDomainTestCase {

    @Test
    public void testDefaultDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
        Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/default"));

        Assert.assertEquals("default", node.getDomainName());
        Assert.assertEquals(1, node.getInstalledContributionURIs().size());
        Assert.assertEquals("sample-helloworld", node.getInstalledContributionURIs().get(0));
        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
    }
View Full Code Here

        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
    }
   
    @Test
    public void testMyDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
        Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/MyDomain"));

        Assert.assertEquals("foo", node.getDomainName());
        Assert.assertEquals(1, node.getInstalledContributionURIs().size());
        Assert.assertEquals("helloworld-contribution", node.getInstalledContributionURIs().get(0));

        // validate additional deployable composite
        Map<String, List<String>> scs = node.getStartedCompositeURIs();
        Assert.assertEquals(2, scs.get("helloworld-contribution").size());
        Assert.assertTrue(scs.get("helloworld-contribution").contains("helloworld.composite"));
        Assert.assertTrue(scs.get("helloworld-contribution").contains("helloworld2.composite"));
       
        // validate metadata side file
        ContributionDescription ic = node.getInstalledContribution("helloworld-contribution");
        Assert.assertEquals(1, ic.getJavaExports().size());
        Assert.assertEquals("sample", ic.getJavaExports().get(0));
    }
View Full Code Here

        Assert.assertEquals("sample", ic.getJavaExports().get(0));
    }

    @Test
    public void testNodeXMLFile() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
        Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/helloworldNode.xml"));
        Assert.assertEquals("helloworld", node.getDomainName());
        List<String> cs = node.getInstalledContributionURIs();
        Assert.assertEquals(1, cs.size());
        Assert.assertEquals("sample-helloworld", cs.get(0));
        Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
        Assert.assertEquals(1, startedComposites.size());
        Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
    }
View Full Code Here

        Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
    }

    @Test
    public void testNodeXMLDomain() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
        Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/NodeXMLDomain"));
        Assert.assertEquals("helloworld", node.getDomainName());
        List<String> cs = node.getInstalledContributionURIs();
        Assert.assertEquals(1, cs.size());
        Assert.assertEquals("sample-helloworld", cs.get(0));
        Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
        Assert.assertEquals(1, startedComposites.size());
        Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
    }
View Full Code Here

        Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
    }

    @Test
    public void testExploded() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
        Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/exploded"));
        Assert.assertEquals("exploded", node.getDomainName());
        List<String> cs = node.getInstalledContributionURIs();
        Assert.assertEquals(1, cs.size());
        Assert.assertEquals("sample-helloworld", cs.get(0));
        Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
        Assert.assertEquals(1, startedComposites.size());
        Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.Node

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.