Package org.apache.tuscany.sca.node

Examples of org.apache.tuscany.sca.node.Node


    @Test
    public void testPolicyDistributedRemotable() throws Exception {
       
       
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedClient.composite",
                                                                     contributions);
        node1.start();

        Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedService.composite",
                                                                     contributions);
        // force binding.ws on node2 to use a different port from node 1(which will default to 8080
        ((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
        node2.start();
       
        ClientComponent local = node1.getService(ClientComponent.class, "DistributedClientComponent");
        ParameterObject po = new ParameterObject();
       
        try {
            String response = local.foo1(po);
            Assert.assertEquals("AComponent", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception with foo " + ex.toString());
        }
       
        try {
            local.callback("Callback");
            String response = local.getCallbackValue();
            Assert.assertEquals("Callback", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception with callback" + ex.toString());
        }       
       
        node1.stop();
        node2.stop();
    }
View Full Code Here


    @Test
    public void testWSDistributedRemotable() throws Exception {
       
       
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedClient.composite",
                                                                     contributions);
        node1.start();

        Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedService.composite",
                                                                     contributions);
       
        // force default binding on node2 to use a different port from node 1(which will default to 8080)
        ((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
        ((NodeImpl)node2).getConfiguration().addBinding(SCABinding.TYPE, "http://localhost:8081/");
        node2.start();
       
        ClientComponent local = node1.getService(ClientComponent.class, "DistributedClientComponent");
        ParameterObject po = new ParameterObject();
       
        try {
            String response = local.foo1(po);
            Assert.assertEquals("AComponent", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception with foo " + ex.toString());
        }
       
        try {
            local.callback("Callback");
            String response = local.getCallbackValue();
            Assert.assertEquals("Callback", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception with callback" + ex.toString());
        }       
       
        node1.stop();
        node2.stop();
   
View Full Code Here

        nodeB.installContribution("nodeAContrib", "./target/classes", null, null);
        nodeB.startComposite("node1Contrib", "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedService.composite");
*/
       
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedClient.composite",
                                                                     contributions);
        node1.start();

        Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedService.composite",
                                                                     contributions);
       
        // force default binding on node2 to use a different port from node 1(which will default to 8080
        ((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
        ((NodeImpl)node2).getConfiguration().addBinding(SCABinding.TYPE, "http://localhost:8081/");
        node2.start();
       
        SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("default"));
        ClientComponent local  = clientFactory.getService(ClientComponent.class, "LocalClientClientComponent");

        ParameterObject po = new ParameterObject();
       
        try {
            String response = local.foo1(po);
            Assert.assertEquals("AComponent", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception with foo " + ex.toString());
        }        

/* Used to keep the composites alive when running the next (ignored) test manually
        System.out.println("Press a key to end");
        try {
            System.in.read();
        } catch (Exception ex) {
        }
        System.out.println("Continuing");
*/  
        node1.stop();
        node2.stop();
   
View Full Code Here

                           "{http://docs.oasis-open.org/ns/opencsa/sca/200912}binding.ws");
       
        // Make a reference target point across VMs to a component that has callback services
        String [] contributions = {"./target/classes"};
       
        Node node3 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedClientClient.composite",
                contributions);
        node3.start();
       
        SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("default"));
        ClientComponent clientClient  = clientFactory.getService(ClientComponent.class, "DistributedClientClientComponent");

        ParameterObject po = new ParameterObject();
       
        try {
            String response = clientClient.foo1(po);
            Assert.assertEquals("AComponent", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception with foo " + ex.toString());
        }
       
        // Make an SCAClient point across VMs to a component that has callback services
        ClientComponent client  = clientFactory.getService(ClientComponent.class, "DistributedClientComponent");
       
        try {
            String response = client.foo1(po);
            Assert.assertEquals("AComponent", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception with foo " + ex.toString());
       
       
        node3.stop();
    }
View Full Code Here

    @Test
    public  void init() throws Exception {
        try{
        String location = ContributionLocationHelper.getContributionLocation("StockQuote.composite");
        Node node = NodeFactory.newInstance().createNode("StockQuote.composite", new Contribution("c1", location));
        node.start();
        node.stop();
        } catch (Exception e) {
            Assert.assertTrue(e.getMessage().contains("[JCA100006]"));
        }
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testLocal() throws Exception {
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchLocal.composite",
                                                                     contributions);
        node1.start();
       
        ClientComponent local = node1.getService(ClientComponent.class, "LocalClientComponent");
        ParameterObject po = new ParameterObject();
       
        try {
            local.foo1(po);
            Assert.fail("Expection exteption indicating that interfaces don't match");
        } catch (ServiceRuntimeException ex){
            Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
        }
       
        node1.stop();
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testCallbackLocal() throws Exception {
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchCallbackLocal.composite",
                                                                     contributions);
        node1.start();
       
        ClientComponent local = node1.getService(ClientComponent.class, "LocalClientComponent");
        ParameterObject po = new ParameterObject();
       
        try {
            local.foo1(po);
            Assert.fail("Expection exteption indicating that interfaces don't match");
        } catch (ServiceRuntimeException ex){
            Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
        }
       
        node1.stop();
    }   
View Full Code Here

     */
    @Test
    public void testNonDistributedRemotable() throws Exception {
    
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchRemoteable.composite",
                                                                     contributions);
        node1.start();
       
        ClientComponent local = node1.getService(ClientComponent.class, "LocalClientComponent");
        ParameterObject po = new ParameterObject();
       
        try {
            local.foo1(po);
        } catch (ServiceRuntimeException ex){
            Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
        }
       
        node1.stop();
    }
View Full Code Here

        // Force the remote default binding to be web services
        System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding",
                           "{http://docs.oasis-open.org/ns/opencsa/sca/200912}binding.ws");
       
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchDistributedClient.composite",
                                                                     contributions);
        node1.start();

        Node node2 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchDistributedService.composite",
                                                                     contributions);
        // for default binding on node2 to use a different port from node 1(which will default to 8080
        ((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
        ((NodeImpl)node2).getConfiguration().addBinding(SCABinding.TYPE, "http://localhost:8081/");       
        node2.start();
       
        ClientComponent local = node1.getService(ClientComponent.class, "DistributedClientComponent");
        ParameterObject po = new ParameterObject();
       
        try {
            local.foo1(po);
            node1.stop();
            node2.stop();
            Assert.fail("Expected exception indicating that interfaces don't match");
        } catch (ServiceRuntimeException ex){
            node1.stop();
            node2.stop();
            Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
        }
       

    }
View Full Code Here

        // Force the remote default binding to be web services
        System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding",
                           "{http://docs.oasis-open.org/ns/opencsa/sca/200912}binding.ws");
       
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchDistributedClient.composite",
                                                                     contributions);
        node1.start();

        Node node2 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchCallbackDistributedService.composite",
                                                                     contributions);
        // for default binding on node2 to use a different port from node 1(which will default to 8080
        ((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
        ((NodeImpl)node2).getConfiguration().addBinding(SCABinding.TYPE, "http://localhost:8081/");       
        node2.start();
       
        ClientComponent local = node1.getService(ClientComponent.class, "DistributedClientComponent");
        ParameterObject po = new ParameterObject();
       
        try {
            local.foo1(po);
            node1.stop();
            node2.stop();
            Assert.fail("Expected exception indicating that interfaces don't match");
        } catch (ServiceRuntimeException ex){
            node1.stop();
            node2.stop();
            Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.node.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.