Package org.apache.tuscany.sca

Examples of org.apache.tuscany.sca.TuscanyRuntime


    @Test
    public void testConstructorExceptionShutdownC() throws Exception{
       
        HelloworldClientImplC.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.testConstructorExceptionShutdownC");
        }
       
        // send a message to the appropriate client
        try {
            Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientC");
            System.out.println(hwCE.sayHello("name"));
        } catch (Exception exception) {
            // the component throws an error on construction
            StatusImpl.appendStatus("Exception caught on sayHello()", "LifecycleTestCase.testConstructorExceptionShutdownC");
        }
       
        // stop a composite
        try {
            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.testConstructorExceptionShutdownC");
        }           
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplC.throwTestExceptionOnConstruction = false;       
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here


    @Test
    public void testConstructorExceptionShutdownS() throws Exception{
       
        HelloworldClientImplS.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.testConstructorExceptionShutdownS");
        }
       
        // send a message to the appropriate client
        try {
            Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientS");
            System.out.println(hwCE.sayHello("name"));
        } catch (Exception exception) {
            // the component throws an error on construction
            StatusImpl.appendStatus("Exception caught on sayHello()", "LifecycleTestCase.testConstructorExceptionShutdownS");
        }       
       
        // stop a composite
        try {
            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.testConstructorExceptionShutdownS");
        }           
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplS.throwTestExceptionOnConstruction = false;
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here

    @Test
    public void testInitExceptionShutdownCE() throws Exception{
       
        HelloworldClientImplCE.throwTestExceptionOnInit = 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.testInitExceptionShutdownCE");
        }
       
        // don't need to send a message as eager init ensures that
        // the component instance is created and inited 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.testInitExceptionShutdownCE");
        }           
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplCE.throwTestExceptionOnInit = false;       
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here

    @Test
    public void testInitExceptionShutdownC() throws Exception{
       
        HelloworldClientImplC.throwTestExceptionOnInit = 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.testInitExceptionShutdownC");
        }
       
        // send a message to the appropriate client
        try {
            Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientC");
            System.out.println(hwCE.sayHello("name"));
        } catch (Exception exception) {
            // the component throws an error on init
            StatusImpl.appendStatus("Exception caught on sayHello()", "LifecycleTestCase.testInitExceptionShutdownC");
        }       
       
        // stop a composite
        try {
            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.testInitExceptionShutdownC");
        }           
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplC.throwTestExceptionOnInit = false;       
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here

    @Test
    public void testInitExceptionShutdownS() throws Exception{
       
        HelloworldClientImplS.throwTestExceptionOnInit = 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.testInitExceptionShutdownS");
        }
       
        // send a message to the appropriate client
        try {
            Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientS");
            System.out.println(hwCE.sayHello("name"));
        } catch (Exception exception) {
            // the component throws an error on init
            StatusImpl.appendStatus("Exception caught on sayHello()", "LifecycleTestCase.testInitExceptionShutdownS");
        }        
       
        // stop a composite
        try {
            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.testInitExceptionShutdownS");
        }           
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplS.throwTestExceptionOnInit = false;       
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here

    @Test
    public void testDestroyExceptionShutdownCE() throws Exception{
       
        HelloworldClientImplCE.throwTestExceptionOnDestroy = 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 @Destroy method
            StatusImpl.appendStatus("Exception caught on node.startComposite", "LifecycleTestCase.testDestroyExceptionShutdownCE");
        }
       
        // don't need to send a message as eager init ensures that
        // the component instance is created start time and hence should
        // be destroyed
       
        // 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.testDestroyExceptionShutdownCE");
        }  
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplCE.throwTestExceptionOnDestroy = false;       
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here

    @Test
    public void testDestroyExceptionShutdownC() throws Exception{
       
        HelloworldClientImplC.throwTestExceptionOnDestroy = 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 @Destroy method
            StatusImpl.appendStatus("Exception caught on node.startComposite", "LifecycleTestCase.testDestroyExceptionShutdownC");
        }
       
        // send a message to the appropriate client
        Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientC");
        System.out.println(hwCE.sayHello("name"))
        // don't need to catch exception here as the component instance won't
        // be destroyed until shutdown
       
        // stop a composite
        try {
            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.testDestroyExceptionShutdownC");
        }  
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplC.throwTestExceptionOnDestroy = false;       
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here

    @Test
    public void testDestroyExceptionShutdownS() throws Exception{
       
        HelloworldClientImplS.throwTestExceptionOnDestroy = 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 @Destroy method
            StatusImpl.appendStatus("Exception caught on node.startComposite", "LifecycleTestCase.testDestroyExceptionShutdownS");
        }
       
        // send a message to the appropriate client
        try {
            Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientS");
            System.out.println(hwCE.sayHello("name"));
        } catch (Exception exception) {
            // exception will be thrown when component instance is discarded
            // after the message has been processed
        }             
       
        // stop a composite
        try {
            node.stopComposite("HelloworldContrib", "lifecycle.composite");
        } catch (Exception exception) {
            // it will complain about the composite not being started
            StatusImpl.appendStatus("Exception caught on sayHello()", "LifecycleTestCase.testDestroyExceptionShutdownS");
        }  
       
        // uninstall a constribution
        node.uninstallContribution("HelloworldContrib");
       
        // stop a Tuscany node
        node.stop();
       
        // stop the runtime
        tuscanyRuntime.stop();
       
        HelloworldClientImplS.throwTestExceptionOnDestroy = false;       
       
        // see what happened
        System.out.println(StatusImpl.statusString);
View Full Code Here

     * same as just sending normal messages and stopping the runtime
     */ 
    @Test
    public void testAppExceptionShutdown() 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. The last one throws and exception
        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"));  
        try {
            Helloworld hw = node.getService(Helloworld.class, "HelloworldC");
            hw.throwException("name");
        } catch (Exception ex) {
            // do nothing
            StatusImpl.appendStatus("Exception caught on throwException()", "LifecycleTestCase.testAppExceptionShutdown");
        }
       
        // 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

        Assert.assertNotNull(c);
    }

    @Test
    public void DistributedInstall() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        try {
        Node nodeA = runtime.createNode("uri:DistributedInstall");
        nodeA.installContribution("https://repository.apache.org/content/groups/snapshots/org/apache/tuscany/sca/samples/helloworld/2.0-SNAPSHOT/helloworld-2.0-SNAPSHOT.jar");
        nodeA.installContribution("src/test/resources/export.jar");

        Assert.assertEquals(2, nodeA.getInstalledContributionURIs().size());
        Assert.assertTrue(nodeA.getInstalledContributionURIs().contains("export"));
        Assert.assertTrue(nodeA.getInstalledContributionURIs().contains("helloworld"));
        Contribution cA = nodeA.getContribution("helloworld");
        Assert.assertNotNull(cA);
       
        Node nodeB = runtime.createNode("uri:DistributedInstall");
        Assert.assertEquals(2, nodeB.getInstalledContributionURIs().size());
        Assert.assertTrue(nodeB.getInstalledContributionURIs().contains("export"));
        Assert.assertTrue(nodeB.getInstalledContributionURIs().contains("helloworld"));
        Contribution cB = nodeB.getContribution("helloworld");
        Assert.assertNotNull(cB);

        ContributionDescription cd = ((NodeImpl)nodeB).getInstalledContribution("export");
        Assert.assertEquals(1, cd.getJavaExports().size());
        Assert.assertEquals("sample", cd.getJavaExports().get(0));
        } finally {
            runtime.stop();
        }
    }
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.