Package org.apache.tuscany.sca

Examples of org.apache.tuscany.sca.Node


        Assert.assertEquals("helloworld.composite", dcs.get(0));
    }

    @Test
    public void testStaticCreateWithNullComposite() {
        Node node = TuscanyRuntime.runComposite(null, "src/test/resources/sample-helloworld.jar");
        List<String> cs = node.getInstalledContributionURIs();
        Assert.assertEquals(1, cs.size());
        List<String> dcs = node.getStartedCompositeURIs(cs.get(0));
        Assert.assertEquals(1, dcs.size());
        Assert.assertEquals("helloworld.composite", dcs.get(0));
    }
View Full Code Here


        Assert.assertEquals(1, dcs.size());
        Assert.assertEquals("helloworld.composite", dcs.get(0));
    }
    @Test
    public void testRunComposite() throws NoSuchServiceException {
        Node node = TuscanyRuntime.runComposite("helloworld.composite", "src/test/resources/sample-helloworld.jar");
        try {
        Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
        } finally {
            node.stop();
        }
    }
View Full Code Here

    }

    @Test
    public void testRunCompositeSharedRuntime() throws NoSuchServiceException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        Node node = TuscanyRuntime.runComposite(runtime, "helloworld.composite", "src/test/resources/sample-helloworld.jar");
        try {
        Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
        } finally {
            node.stop();
        }
        runtime.stop();
    }
View Full Code Here

public class TwoNodesTestCase {

    @Test
    public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
        Node node1 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44331");
        node1.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);

        Node node2 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44332&wka=127.0.0.1:44331");

        Helloworld helloworldService = node2.getService(Helloworld.class, "HelloworldComponent");
        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
    }
View Full Code Here

public class NodeXMLTestCase {

    @Test
    public void testHelloworldXML() throws ContributionReadException, ActivationException, ValidationException {
        Node node = TuscanyRuntime.newInstance().createNodeFromXML("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));
        List<String> compsoites = node.getStartedCompositeURIs("sample-helloworld");
        Assert.assertEquals(1, compsoites.size());
        Assert.assertEquals("helloworld.composite", compsoites.get(0));
    }
View Full Code Here

public class DeployerTestCase {

    @Test
    public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
        Node node = tuscanyRuntime.createNode("myDomain");
       
        Deployer deployer = tuscanyRuntime.getDeployer();
        Monitor monitor = deployer.createMonitor();
        Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor);
        monitor.analyzeProblems();
       
        node.installContribution(contribution, null, true);
        List<String> ics = node.getInstalledContributionURIs();
        Assert.assertEquals(1, ics.size());
        Assert.assertEquals("foo", ics.get(0));
    }
View Full Code Here

    }

    @Test
    public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
        Node node = tuscanyRuntime.createNode("myDomain");
       
        node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);

        Deployer deployer = tuscanyRuntime.getDeployer();
        Monitor monitor = deployer.createMonitor();
        Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor);
        monitor.analyzeProblems();
        composite.setURI("helloworld2.composite");
        node.start("foo", composite);
        List<String> dcs = node.getStartedCompositeURIs("foo");
        Assert.assertEquals(1, dcs.size());
        Assert.assertEquals("helloworld2.composite", dcs.get(0));
    }
View Full Code Here

    @Test
    public void testSayHello() throws NoSuchServiceException, IOException {

        // Run the SCA composite in a Tuscany runtime
        Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes");
        try {
           
            // Get the Helloworld service proxy
            Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
           
            // test that it works as expected
            Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia"));
           
            // test that has exposed an HTTP endpoint that works as expected
            // JSONRPC args are base64 encoded, ["World"] = WyJXb3JsZCJd 
            URL url = new URL("http://localhost:8080/HelloworldComponent/Helloworld?method=sayHello&params=WyJXb3JsZCJd&id=1");
            Assert.assertEquals("{\"id\":1,\"result\":\"Hello World\"}", read(url.openStream()));

        } finally {
            // Stop the Tuscany runtime Node
            node.stop();       
        }
    }
View Full Code Here

            addProjectContribution(contributionList);

            addAdditionalContributions(contributionList);
           
            Node node = runtime.createNode(domainURI);
            for (String c : contributionList) {
                String curi;
                try {
                    curi = node.installContribution(null, c, null, null);
                } catch (Exception e) {
                    throw new MojoExecutionException("Exception installing contribution", e);
                }
                try {
                    node.startDeployables(curi);
                } catch (Exception e) {
                    throw new MojoExecutionException("Exception starting deployables for contribution " + curi, e);
                }
            }
        }
View Full Code Here

    @Test
    public void testSayHello() throws NoSuchServiceException {

        // Run the SCA composite in a Tuscany runtime
        Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes");
        try {
           
            // Get the Helloworld service proxy
            Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
           
            // test that it works as expected
            Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia"));
           
        } finally {
            // Stop the Tuscany runtime Node
            node.stop();       
        }
    }
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.