Package org.apache.tuscany.sca

Examples of org.apache.tuscany.sca.Node


    }
    }

    @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

public class StopStartTestCase {

    @Test
    public void startStopInstall() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        Node node1 = runtime.createNode("uri:StartStopTestCase?wka=127.0.0.1:9876");
        Assert.assertEquals("Hello Amelia", node1.getService(HelloworldService.class, "HelloworldComponent").sayHello("Amelia"));
       
        String curi = node1.getInstalledContributionURIs().get(0);
       
        node1.stopComposite(curi, "Helloworld.composite");
        try {
            node1.getService(HelloworldService.class, "HelloworldComponent").sayHello("Amelia");
            Assert.fail();
        } catch (NoSuchServiceException e) {
            // expected
        }

        List<String> nodes = node1.getNodeNames();
        nodes.remove(node1.getLocalNodeName());
        String remoteNode = nodes.get(0);
        node1.startComposite(curi, "Helloworld.composite", remoteNode);

// TUSCANY-3870: this next invoke doesn't work:       
//        Assert.assertEquals("Hello Amelia", node1.getService(HelloworldService.class, "HelloworldComponent").sayHello("Amelia"));
    }
View Full Code Here

    @Test
    public void testCalculate() throws NoSuchServiceException {

        // Run the SCA composite in a Tuscany runtime
         //TuscanyRuntime.runComposite("Calculator.composite", "target/classes");
        Node node = null;
           
        try {
            TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
            node = tuscanyRuntime.createNode();
            node.installContribution("AsyncSample", "target/classes", null, null);
            node.startComposite("AsyncSample", "Calculator.composite");
            node.startComposite("AsyncSample", "CalculatorClient.composite");
           
            SCAClientFactory scaClientFactory = SCAClientFactory.newInstance(URI.create("default"));
            CalculatorClient calculatorClient = scaClientFactory.getService(CalculatorClient.class, "CalculatorClient");
           
            calculatorClient.calculate();
        }catch (Exception e){
            e.printStackTrace();     
        } finally {
            // Stop the Tuscany runtime Node
            node.stop();       
        }
    }
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
            URL url = new URL("http://localhost:8080/HelloworldComponent/Helloworld/sayHello?name=Amelia&callback=someFunc");
            Assert.assertEquals("someFunc(\"Hello Amelia\");", read(url.openStream()));

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

public class CalculatorActivator implements BundleActivator {
    private Logger logger = Logger.getLogger(CalculatorActivator.class.getName());

    public void start(BundleContext context) throws Exception {
        logger.info("Starting " + context.getBundle());
        Node node = TuscanyRuntime.runComposite("Calculator.composite", context.getBundle().getLocation());
        node.stop();
    }
View Full Code Here

    @Test
    public void testCalculate() throws NoSuchServiceException {

        // Run the SCA composite in a Tuscany runtime
        Node node = TuscanyRuntime.runComposite("Calculator.composite", "target/classes");
        try {
           

           
        } finally {
            // Stop the Tuscany runtime Node
            node.stop();       
        }
    }
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
            // to keep this test simple just do ?wsdl on the endpoint 
            URL url = new URL("http://localhost:8080/HelloworldComponent/Helloworld?wsdl");
            Assert.assertTrue(read(url.openStream()).contains("address location="));

        } finally {
            // Stop the Tuscany runtime Node
            node.stop();       
        }
    }
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");
            String response = read(url.openStream());
            System.out.println(response);
            Assert.assertTrue(response.contains("\"id\":1,\"result\":\"Hello World\""));

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

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

        // Run the SCA composite in a Tuscany runtime
        Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes");
        try {
           
            // test that has exposed an HTTP endpoint that works as expected
            URL url = new URL("http://localhost:8080/HelloworldComponent/Helloworld/sayHello?name=Amelia");
            Assert.assertEquals("Hello Amelia", read(url.openStream()));
           
        } 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.