summaryrefslogtreecommitdiffstats
path: root/java/sca/samples/calculator-osgi/src/test
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-09-06 01:37:56 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-09-06 01:37:56 +0000
commit0884017406b691e5fea7b38e0f798760be763137 (patch)
tree0e63dca903fdfaed9ae030d06869d06686d3e145 /java/sca/samples/calculator-osgi/src/test
parent772d956afa3a4ec971d3f8013d66117ef462bf6b (diff)
Add a sample to use Equinox OSGi launcher
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@692602 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/samples/calculator-osgi/src/test')
-rw-r--r--java/sca/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/java/sca/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java b/java/sca/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..85bf73b264
--- /dev/null
+++ b/java/sca/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * This shows how to test the Calculator composition.
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class CalculatorTestCase extends TestCase {
+
+ private static CalculatorService calculatorService;
+ private NodeLauncher launcher;
+ private SCANode node;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ CalculatorTestCase.calculatorService = calculatorService;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ launcher = NodeLauncher.newInstance();
+ node = launcher.createNodeFromClassLoader("CalculatorTest.composite", getClass().getClassLoader());
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (launcher != null) {
+ node.stop();
+ launcher.destroy();
+ }
+ }
+
+ public void testDummy() {
+ }
+
+ @Init
+ public void init() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5);
+ }
+}