Examples of TuscanyRuntime


Examples of org.apache.tuscany.sca.TuscanyRuntime

@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

Examples of org.apache.tuscany.sca.TuscanyRuntime

    @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

Examples of org.apache.tuscany.sca.TuscanyRuntime

    }

    @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

Examples of org.apache.tuscany.sca.TuscanyRuntime

    }

    @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

Examples of org.apache.tuscany.sca.TuscanyRuntime

    }

    @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

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

Examples of org.apache.tuscany.sca.TuscanyRuntime

        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

Examples of org.apache.tuscany.sca.TuscanyRuntime

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

Examples of org.apache.tuscany.sca.TuscanyRuntime

        // 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

Examples of org.apache.tuscany.sca.TuscanyRuntime

       
        // 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
TOP
Copyright © 2018 www.massapi.com. 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.