summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit')
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/README.html39
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/README.odtbin0 -> 12924 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/pom.xml50
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/src/test/java/launcher/LaunchCalculatorContributionTestCase.java51
5 files changed, 178 insertions, 0 deletions
diff --git a/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/README.html b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/README.html
new file mode 100644
index 0000000000..00d6592cb8
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/README.html
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><!--This file was converted to xhtml by OpenOffice.org - see http://xml.openoffice.org/odf2xhtml for more info.--><head profile="http://dublincore.org/documents/dcmi-terms/"><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/><title xml:lang="en-US">- no title specified</title><meta name="DCTERMS.title" content="" xml:lang="en-US"/><meta name="DCTERMS.language" content="en-US" scheme="DCTERMS.RFC4646"/><meta name="DCTERMS.source" content="http://xml.openoffice.org/odf2xhtml"/><meta name="DCTERMS.creator" content="ant "/><meta name="DCTERMS.issued" content="2011-03-15T09:48:55.71" scheme="DCTERMS.W3CDTF"/><meta name="DCTERMS.modified" content="2011-04-14T11:20:02.98" scheme="DCTERMS.W3CDTF"/><meta name="DCTERMS.provenance" content="" xml:lang="en-US"/><meta name="DCTERMS.subject" content="," xml:lang="en-US"/><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" hreflang="en"/><link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" hreflang="en"/><link rel="schema.DCTYPE" href="http://purl.org/dc/dcmitype/" hreflang="en"/><link rel="schema.DCAM" href="http://purl.org/dc/dcam/" hreflang="en"/><base href="."/><style type="text/css">
+ @page { }
+ table { border-collapse:collapse; border-spacing:0; empty-cells:show }
+ td, th { vertical-align:top; font-size:12pt;}
+ h1, h2, h3, h4, h5, h6 { clear:both }
+ ol, ul { margin:0; padding:0;}
+ li { list-style: none; margin:0; padding:0;}
+ <!-- "li span.odfLiEnd" - IE 7 issue-->
+ li span. { clear: both; line-height:0; width:0; height:0; margin:0; padding:0; }
+ span.footnodeNumber { padding-right:1em; }
+ span.annotation_style_by_filter { font-size:95%; font-family:Arial; background-color:#fff000; margin:0; border:0; padding:0; }
+ * { margin:0;}
+ .Heading_20_1 { font-size:115%; margin-bottom:0.212cm; margin-top:0.423cm; font-family:Arial; writing-mode:page; font-weight:bold; }
+ .P1 { font-size:10pt; font-family:Courier New; writing-mode:page; }
+ .Standard { font-size:12pt; font-family:Times New Roman; writing-mode:page; }
+ <!-- ODF styles with no properties representable as CSS -->
+ { }
+ </style></head><body dir="ltr" style="max-width:21.001cm;margin-top:2cm; margin-bottom:2cm; margin-left:2cm; margin-right:2cm; "><h1 class="Heading_20_1"><a id="a__Running_the_Tuscany_runtime_from_JUnit"><span/></a>Running the Tuscany runtime from JUnit</h1><p class="Standard"> </p><p class="Standard">The same Node API used to start the Tuscany runtime from Java can of course also be used from within a JUnit test case. This allows you to automatically test you SCA contributions. This sample uses the same sart-up code from the jse sample but this time inside:</p><p class="Standard"> </p><p class="P1">   launcher.LaunchCalculatorContributionTestCase.java</p><p class="Standard"> </p><p class="Standard">This JUnit test case can be run using you usually use to run JUnit tests. By default Maven will run JUnit tests for a module so this sample can be run by doing the following:</p><p class="Standard"> </p><p class="P1">cd junit</p><p class="P1">mvn</p><p class="Standard"> </p><p class="Standard">TODO – should we provide run-sample scripts. If so we need to ship JUnit or provide instructions on how to install it?</p></body></html> \ No newline at end of file
diff --git a/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/README.odt b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/README.odt
new file mode 100644
index 0000000000..6a8240d72e
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/README.odt
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/pom.xml b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/pom.xml
new file mode 100644
index 0000000000..f5198bcc59
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>tuscany-samples-running-tuscany</artifactId>
+ <version>2.0.1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>junit</artifactId>
+ <name>Apache Tuscany SCA Samples JUnit</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ </build>
+</project>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/src/test/java/launcher/LaunchCalculatorContributionTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/src/test/java/launcher/LaunchCalculatorContributionTestCase.java
new file mode 100644
index 0000000000..229a3fe223
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/samples/running-tuscany/junit/src/test/java/launcher/LaunchCalculatorContributionTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package launcher;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Test;
+
+import calculator.CalculatorService;
+
+/**
+ * Test sample contribution.
+ */
+public class LaunchCalculatorContributionTestCase {
+
+
+ @Test
+ public void testCalculatorContribution() throws Exception {
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../calculator-contribution.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ double result = calculator.add(3, 2);
+
+ System.out.println("3 + 2 = " + result);
+
+ Assert.assertEquals(5.0, result);
+
+ node.stop();
+ }
+}