Package org.apache.tuscany.sca.node

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


    @Test
    public void testTwoNodesJIRACode2() throws Exception {
        String storeLocation = "src/test/resources/sample-store.jar";
        String storeClientLocation = "src/test/resources/sample-store-client.jar";

        Node node1 = NodeFactory.newInstance().createNode(new Contribution("store",storeLocation));
        node1.start();

        Node node2 = NodeFactory.newInstance().createNode("store-client.composite",new Contribution("storeClient", storeClientLocation));
        node2.start();    
    }
View Full Code Here


*/
public class ComposerServer {

    public final static void main(String[] args) throws Exception {
      NodeFactory factory = NodeFactory.newInstance();
        Node node = factory.createNode(new File("src/main/resources/Outer.composite").toURI().toURL().toString(),
                new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
        node.start();
        System.out.println("Press Enter to exit...");
        System.in.read();
        node.stop();
    }
View Full Code Here

*/
public class ComposerClient {

    public final static void main(String[] args) throws Exception {
      NodeFactory factory = NodeFactory.newInstance();
        Node node = factory.createNode(new File("src/main/resources/Client.composite").toURI().toURL().toString(),
                new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
        node.start();
        Composer composer = node.getService(Composer.class, "ClientComponent/Composer");
        System.out.println(composer.Compose("ABC"));
        node.stop();
    }
View Full Code Here

    private static final String PKG = "org/apache/tuscany/sca/itest/interfaces/invalid";
    private static String ROOT = new File("target/classes/" + PKG).toURI().toString();

    @Test
    public void testInvalidRemoteAttribute() throws Exception {
        Node node = null;

        try {
            String location = ROOT;
            node = NodeFactory.newInstance().createNode("InvalidRemoteAttribute.composite", new Contribution("c1", location));
            node.start();
        } catch (Exception e) {
            if (! e.getCause().getClass().equals(InvalidAnnotationException.class)) {
                throw e;
            }
        } finally {
            if (node != null) {
                node.stop();
            }
        }
    }
View Full Code Here

        }
        return new NodeImpl(this, configuration);
    }

    protected Node removeNode(NodeConfiguration configuration) {
        Node node = nodes.remove(getNodeKey(configuration));
        if (autoDestroy && nodes.isEmpty()) {
            destroy();
        }
        return node;
    }
View Full Code Here

     * Create and load a node
     * @param configuration
     * @return The node
     */
    public NodeExtension loadNode(NodeConfiguration configuration) {
        Node node = createNode(configuration);
       
        try {
            NodeImpl nodeImpl = ((NodeImpl) node);
            nodeImpl.load();
            return nodeImpl;
View Full Code Here

*/
public class StandaloneTestCase{

    @Test
    public void test1() throws Exception {
        Node node = NodeFactory.newInstance().createNode(URI.create("tuscany:foo"),"../helloworld/target/itest-domains-helloworld.zip");
        node.start();
        assertEquals(1, node.getServiceNames().size());
        assertEquals("HelloworldComponent/Helloworld", node.getServiceNames().get(0));
        Helloworld helloworld = SCAClientFactory.newInstance(URI.create("tuscany:foo")).getService(Helloworld.class, "HelloworldComponent");
        assertEquals("Hello petra", helloworld.sayHello("petra"));
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testLocal() throws Exception {
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/local/MatchLocal.composite",
                                                                     contributions);
        node1.start();
       
        ClientComponent local = node1.getService(ClientComponent.class, "LocalClientComponent");
        ParameterObject po = new ParameterObject();
       
        try {
            String response = local.foo1(po);
            Assert.assertEquals("AComponent", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception " + ex.toString());
        }
       
        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("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();
       
        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

        // WSDL so that I can test what happens when the registry tries to generate WSDL
        System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding",
                           "{http://tuscany.apache.org/xmlns/sca/1.1}binding.rmi");
       
        String [] contributions = {"./target/classes"};
        Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchNonJAXBDistributedClient.composite",
                                                                     contributions);
        node1.start();

        Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchNonJAXBDistributedService.composite",
                                                                     contributions);
       
        // force default binding on node2 to use a different port from node 1(which will default to 8080
        // Don't need to do this as not testing callbacks here
        //((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();
        po.field1 = "Test String";
       
        try {
            String response = local.foo1(po);
            Assert.assertEquals("Test String", response);
        } catch (ServiceRuntimeException ex){
            Assert.fail("Unexpected exception with foo " + ex.toString());
        }      
       
        node1.stop();
        node2.stop();
    }   
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.