Package org.apache.tuscany.sca

Examples of org.apache.tuscany.sca.TuscanyRuntime


public class TwoNodesTestCase {

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

        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"));
    } finally { runtime.stop(); }
    }
View Full Code Here


        testIt(node);
    }

    @Test
    public void distributedDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        try {
        Node node = runtime.createNode("uri:DomainCompositeTestCase");
        testIt(node);
        } finally { runtime.stop(); }
    }
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");
View Full Code Here

        // 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"));
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");
       
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
       
/*       
        org.apache.tuscany.sca.Node nodeA = runtime.createNode("default");   
        nodeA.installContribution("nodeAContrib", "./target/classes", null, null);
        nodeA.startComposite("node1Contrib", "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedClient.composite");
View Full Code Here

    private Composer composer;

    @Before
    public void startClient() throws Exception {
        try {
            TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
            node = tuscanyRuntime.createNode("myDomain");
           
            node.installContribution("contrib1", "src/main/resources/recursive", null, null);
            node.startComposite("contrib1", "Outer.composite");
            node.startComposite("contrib1", "Client.composite");
View Full Code Here

    private Composer composer;

    @Before
    public void startClient() throws Exception {
        try {
            TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
            node = tuscanyRuntime.createNode("myDomain");
           
            node.installContribution("contrib1", "src/main/resources/recursive", null, null);
           
            node.startComposite("contrib1", "Inner.composite");
            node.startComposite("contrib1", "Outer.composite");
View Full Code Here

    @Test
    public void testNoExceptionNoMessageShutdown() throws Exception{
       
        StatusImpl.statusString = "";
       
        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();

        // create a Tuscany node
        node = tuscanyRuntime.createNode();
       
        // install a contribution
        node.installContribution("HelloworldContrib", "target/classes", null, null);
       
        // start a composite
        node.startComposite("HelloworldContrib", "lifecycle.composite");
       
        // we don't send any messages in this case and just shut down directly
       
        // stop a composite
        node.stopComposite("HelloworldContrib", "lifecycle.composite");
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        // see what happened
        System.out.println(StatusImpl.statusString);
        Assert.assertEquals("Service binding start - Endpoint:  URI = HelloworldService#service-binding(Helloworld/lifecycle)\n" +
                            "Implementation start - HelloworldServiceTestImpl\n" +
View Full Code Here

     * should be thrown.
     */   
    @Test
    public void testNoExceptionMessageShutdown() throws Exception{
       
        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();

        // create a Tuscany node
        node = tuscanyRuntime.createNode();
       
        // install a contribution
        node.installContribution("HelloworldContrib", "target/classes", null, null);
       
        // start a composite
        node.startComposite("HelloworldContrib", "lifecycle.composite");
       
        // send a message to each client
        Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientCE");
        System.out.println(hwCE.sayHello("name"));
        Helloworld hwC = node.getService(Helloworld.class, "HelloworldClientC");
        System.out.println(hwC.sayHello("name"));
        Helloworld hwS = node.getService(Helloworld.class, "HelloworldClientC");
        System.out.println(hwS.sayHello("name"));       
       
        // stop a composite
        node.stopComposite("HelloworldContrib", "lifecycle.composite");
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        // see what happened
        System.out.println(StatusImpl.statusString);
        Assert.assertEquals("Service binding start - Endpoint:  URI = HelloworldService#service-binding(Helloworld/lifecycle)\n" +
                            "Implementation start - HelloworldServiceTestImpl\n" +
View Full Code Here

    @Test
    public void testConstructorExceptionShutdownCE() throws Exception{
       
        HelloworldClientImplCE.throwTestExceptionOnConstruction = true;
       
        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();

        // create a Tuscany node
        node = tuscanyRuntime.createNode();
       
        // install a contribution
        node.installContribution("HelloworldContrib", "target/classes", null, null);
       
        // start a composite
        try {
            node.startComposite("HelloworldContrib", "lifecycle.composite");
        } catch (Exception exception) {
            // it's thrown from the HelloworldClientImpl @Init method
            StatusImpl.appendStatus("Exception caught on node.startComposite", "LifecycleTestCase.testConstructorExceptionShutdownCE");
        }
       
        // don't need to send a message as eager init ensures that
        // the component instance is created at start time
       
        // stop a composite
        try {
            // not required in this test as the exception during EagerInit will cause the stop        
            //node.stopComposite("HelloworldContrib", "lifecycle.composite");
        } catch (Exception exception) {
            // it will complain about the composite not being started
            StatusImpl.appendStatus("Exception caught on node.stopComposite", "LifecycleTestCase.testConstructorExceptionShutdownCE");
        }           
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplCE.throwTestExceptionOnConstruction = false;
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here

TOP

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

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.