Package org.apache.tuscany.sca

Examples of org.apache.tuscany.sca.TuscanyRuntime


        }
    }

    @Test
    public void testRunCompositeSharedRuntime() throws NoSuchServiceException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        Node node = TuscanyRuntime.runComposite(runtime, "helloworld.composite", "src/test/resources/sample-helloworld.jar");
        try {
        Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
        } finally {
            node.stop();
        }
        runtime.stop();
    }
View Full Code Here


public class DeployerTestCase {

    @Test
    public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
        Node node = tuscanyRuntime.createNode("myDomain");
       
        Deployer deployer = tuscanyRuntime.getDeployer();
        Monitor monitor = deployer.createMonitor();
        Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor);
        monitor.analyzeProblems();
       
        node.installContribution(contribution, null, true);
View Full Code Here

        Assert.assertEquals("foo", ics.get(0));
    }

    @Test
    public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
        Node node = tuscanyRuntime.createNode("myDomain");
       
        node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);

        Deployer deployer = tuscanyRuntime.getDeployer();
        Monitor monitor = deployer.createMonitor();
        Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor);
        monitor.analyzeProblems();
        composite.setURI("helloworld2.composite");
        node.start("foo", composite);
View Full Code Here

    public void execute() throws MojoExecutionException, MojoFailureException {
        if (id.length() < 1) {
            // if id is set to "" then stop all runtimes
            for (String id : TuscanyStartMojo.runtimes.keySet()) {
                TuscanyRuntime runtime = TuscanyStartMojo.runtimes.get(id);
                runtime.stop();
                getLog().info("stopped Tuscany runtime " + id);
            }
            TuscanyStartMojo.runtimes.clear();
        } else {
            TuscanyRuntime runtime = TuscanyStartMojo.runtimes.remove(id);
            if (runtime == null) {
                getLog().info("No started runtime found for ID " + id);
            } else {
                runtime.stop();
                getLog().info("stopped Tuscany runtime " + id);
            }
        }
    }
View Full Code Here

    private String[] contributions;

    public void execute() throws MojoExecutionException, MojoFailureException {
        getLog().info("Starting Tuscany Runtime...");
       
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        runtimes.put(id, runtime);

        if (nodeConfig != null && nodeConfig.length() > 0) {
            try {
                runtime.createNodeFromXML(nodeConfig);
            } catch (Exception e) {
                throw new MojoExecutionException("Exception creating node", e);
            }
        } else {
            List<String> contributionList = new ArrayList<String>();

            addProjectContribution(contributionList);

            addAdditionalContributions(contributionList);
           
            Node node = runtime.createNode(domainURI);
            for (String c : contributionList) {
                String curi;
                try {
                    curi = node.installContribution(null, c, null, null);
                } catch (Exception e) {
View Full Code Here

@Ignore("TUSCANY-3953")
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

    @Test
    public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, ClassNotFoundException, IntrospectionException, IllegalArgumentException, InvocationTargetException,
        IllegalAccessException {

        // get the various factories that will be needed
        TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
        ExtensionPointRegistry extensionPoints = tuscanyRuntime.getExtensionPointRegistry();
        FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);

        // Create a contribution
        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
        Contribution contribution = contributionFactory.createContribution();
        contribution.setURI("testContribution");
        ModelResolverExtensionPoint modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setClassLoader(new URLClassLoader(new URL[] {new File("src/test/resources/sample-helloworld.jar").toURI().toURL()}));

        // Create a composite
        AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
        Composite composite = assemblyFactory.createComposite();
        composite.setURI("testComposite");
        composite.setName(new QName("testComposite"));

        // create a component
        Component component = assemblyFactory.createComponent();
        component.setName("testComponent");
        JavaImplementationFactory javaImplementationFactory = modelFactories.getFactory(JavaImplementationFactory.class);
        JavaImplementation javaImplementation = javaImplementationFactory.createJavaImplementation(contribution.getClassLoader().loadClass("sample.HelloworldImpl"));
        javaImplementation.setJavaClass(contribution.getClassLoader().loadClass("sample.HelloworldImpl"));
        component.setImplementation(javaImplementation);

        // add the component to the composite
        composite.getComponents().add(component);

        // add the composite to the contribution
        contribution.addComposite(composite);

        // Now run the composite with a Tuscany Node
        Node node = tuscanyRuntime.createNode();
        node.installContribution(contribution, null);
        node.startComposite(contribution.getURI(), composite.getURI());

        // test that the service has started and can be invoked
        testService(node, contribution.getClassLoader());

        node.stop();
        tuscanyRuntime.stop();
    }
View Full Code Here

    }

    @Ignore("TUSCANY-3953")
    @Test
    public void DistributedInstall() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        try {
        Node nodeA = runtime.createNode("uri:DistributedInstall");
        nodeA.installContribution("http://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

    }

    @Ignore("TUSCANY-3953")
    @Test
    public void importExportDistributedValidate() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        try {
            Node nodeA = runtime.createNode("uri:ImportTestCase");
            nodeA.installContribution("src/test/resources/import.jar");
            try {
                nodeA.validateContribution("import");
            } catch (ValidationException e) {
                // expected
            }
            Node nodeB =runtime.createNode("uri:ImportTestCase");
            nodeB.installContribution("src/test/resources/export.jar");
            nodeA.validateContribution("import");
            nodeA.startComposite("import", "helloworld.composite");
            Map<String, List<String>> scs = nodeB.getStartedCompositeURIs();
            Assert.assertEquals(1, scs.size());           
        }finally {
            runtime.stop();
        }

    }
View Full Code Here

    }

    @Ignore("TUSCANY-3953")
    @Test
    public void startDistributedTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, InterruptedException {
        TuscanyRuntime runtime = TuscanyRuntime.newInstance();
        try {
        Node node = runtime.createNode("uri:ImportTestCase");
        Node node2 = runtime.createNode("uri:ImportTestCase");
       
        node.installContribution("src/test/resources/sample-helloworld.jar");
        Assert.assertEquals(1, node.getInstalledContributionURIs().size());
        Assert.assertEquals(1, node2.getInstalledContributionURIs().size());

        node.startComposite("sample-helloworld", "helloworld.composite");
        Assert.assertEquals(1, node.getStartedCompositeURIs().size());
        Assert.assertEquals(1, node2.getStartedCompositeURIs().size());

        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
        Assert.assertEquals("helloworld.composite", node2.getStartedCompositeURIs().get("sample-helloworld").get(0));
       
        node.stopComposite("sample-helloworld", "helloworld.composite");
        Assert.assertEquals(0, node.getStartedCompositeURIs().size());
        Assert.assertEquals(0, node2.getStartedCompositeURIs().size());

        node2.startComposite("sample-helloworld", "helloworld.composite");
        Assert.assertEquals(1, node.getStartedCompositeURIs().size());
        Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));

        Assert.assertEquals(1, node2.getStartedCompositeURIs().size());
        Assert.assertEquals("helloworld.composite", node2.getStartedCompositeURIs().get("sample-helloworld").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.