From 2ba431007c03a8af8365fd45047770390b989ea9 Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 10 Mar 2010 11:45:19 +0000 Subject: Example with nested jar for ML discussion git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@921315 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/slaws/calculator-with-nested-jar/pom.xml | 71 +++++++++++++++++++++ .../src/main/resources/Calculator.composite | 49 ++++++++++++++ .../test/java/calculator/CalculatorTestCase.java | 56 ++++++++++++++++ .../target/classes/Calculator.composite | 49 ++++++++++++++ .../target/classes/calculator.jar | Bin 0 -> 6041 bytes .../target/sample-calculator.jar | Bin 0 -> 9292 bytes .../calculator/CalculatorTestCase.class | Bin 0 -> 1932 bytes 7 files changed, 225 insertions(+) create mode 100644 sandbox/slaws/calculator-with-nested-jar/pom.xml create mode 100644 sandbox/slaws/calculator-with-nested-jar/src/main/resources/Calculator.composite create mode 100644 sandbox/slaws/calculator-with-nested-jar/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sandbox/slaws/calculator-with-nested-jar/target/classes/Calculator.composite create mode 100644 sandbox/slaws/calculator-with-nested-jar/target/classes/calculator.jar create mode 100644 sandbox/slaws/calculator-with-nested-jar/target/sample-calculator.jar create mode 100644 sandbox/slaws/calculator-with-nested-jar/target/test-classes/calculator/CalculatorTestCase.class (limited to 'sandbox/slaws') diff --git a/sandbox/slaws/calculator-with-nested-jar/pom.xml b/sandbox/slaws/calculator-with-nested-jar/pom.xml new file mode 100644 index 0000000000..8acac41750 --- /dev/null +++ b/sandbox/slaws/calculator-with-nested-jar/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.7-SNAPSHOT + ../../pom.xml + + sample-calculator + Apache Tuscany SCA Sample Calculator + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.7-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.7-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.7-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + diff --git a/sandbox/slaws/calculator-with-nested-jar/src/main/resources/Calculator.composite b/sandbox/slaws/calculator-with-nested-jar/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..90872041b0 --- /dev/null +++ b/sandbox/slaws/calculator-with-nested-jar/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/slaws/calculator-with-nested-jar/src/test/java/calculator/CalculatorTestCase.java b/sandbox/slaws/calculator-with-nested-jar/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..1b7476534a --- /dev/null +++ b/sandbox/slaws/calculator-with-nested-jar/src/test/java/calculator/CalculatorTestCase.java @@ -0,0 +1,56 @@ +/* + * 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.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorTestCase extends TestCase { + + private CalculatorService calculatorService; + private SCANode node; + + @Override + protected void setUp() throws Exception { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANodeFromClassLoader("Calculator.composite", getClass().getClassLoader()); + node.start(); + + calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + node.stop(); + } + + public void testCalculator() 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); + } +} diff --git a/sandbox/slaws/calculator-with-nested-jar/target/classes/Calculator.composite b/sandbox/slaws/calculator-with-nested-jar/target/classes/Calculator.composite new file mode 100644 index 0000000000..90872041b0 --- /dev/null +++ b/sandbox/slaws/calculator-with-nested-jar/target/classes/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/slaws/calculator-with-nested-jar/target/classes/calculator.jar b/sandbox/slaws/calculator-with-nested-jar/target/classes/calculator.jar new file mode 100644 index 0000000000..0bb0f7fffa Binary files /dev/null and b/sandbox/slaws/calculator-with-nested-jar/target/classes/calculator.jar differ diff --git a/sandbox/slaws/calculator-with-nested-jar/target/sample-calculator.jar b/sandbox/slaws/calculator-with-nested-jar/target/sample-calculator.jar new file mode 100644 index 0000000000..ec7e18a2ef Binary files /dev/null and b/sandbox/slaws/calculator-with-nested-jar/target/sample-calculator.jar differ diff --git a/sandbox/slaws/calculator-with-nested-jar/target/test-classes/calculator/CalculatorTestCase.class b/sandbox/slaws/calculator-with-nested-jar/target/test-classes/calculator/CalculatorTestCase.class new file mode 100644 index 0000000000..acbbf5c544 Binary files /dev/null and b/sandbox/slaws/calculator-with-nested-jar/target/test-classes/calculator/CalculatorTestCase.class differ -- cgit v1.2.3