From 3c7739e39343f9b2f80f5e6d2ee17cbe640879d2 Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 29 Jul 2008 15:17:29 +0000 Subject: Delete old rc3 tag git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@680733 13f79535-47bb-0310-9956-ffa450edef68 --- .../calculator-implementation-policies/README | 266 ----------------- .../calculator-implementation-policies/build.xml | 72 ----- .../calculator.png | Bin 20552 -> 0 bytes .../calculator.svg | 329 --------------------- .../calculator-implementation-policies/pom.xml | 78 ----- .../src/main/java/calculator/AddService.java | 28 -- .../src/main/java/calculator/AddServiceImpl.java | 35 --- .../src/main/java/calculator/CalculatorClient.java | 66 ----- .../main/java/calculator/CalculatorService.java | 35 --- .../java/calculator/CalculatorServiceImpl.java | 70 ----- .../src/main/java/calculator/DivideService.java | 28 -- .../main/java/calculator/DivideServiceImpl.java | 35 --- .../src/main/java/calculator/MultiplyService.java | 28 -- .../main/java/calculator/MultiplyServiceImpl.java | 35 --- .../src/main/java/calculator/SubtractService.java | 28 -- .../main/java/calculator/SubtractServiceImpl.java | 35 --- .../security/CalculatorCallbackHandler.java | 50 ---- .../java/calculator/security/JaasLoginModule.java | 178 ----------- .../java/calculator/security/UserPrincipal.java | 66 ----- .../src/main/resources/Calculator.composite | 61 ---- .../src/main/resources/CalculatorJass.config | 3 - .../resources/CalculatorLogMessages.properties | 18 -- .../src/main/resources/definitions.xml | 40 --- .../test/java/calculator/CalculatorTestCase.java | 74 ----- 24 files changed, 1658 deletions(-) delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/README delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/build.xml delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/calculator.png delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/calculator.svg delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/pom.xml delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/Calculator.composite delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/definitions.xml delete mode 100644 tags/java/sca/1.3/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java (limited to 'tags/java/sca/1.3/samples/calculator-implementation-policies') diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/README b/tags/java/sca/1.3/samples/calculator-implementation-policies/README deleted file mode 100644 index bd66eee1c9..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/README +++ /dev/null @@ -1,266 +0,0 @@ -Calculator Implementation Policies Sample -========================================= -This sample builds over simple calculator sample to demonstrate how Implementation Policies can -be use in Tuscany SCA Java. - -The README in the samples directory (the directory above this) provides -general instructions about building and running samples. Take a look there -first. - -If you just want to run the sample to see what happens open a command prompt, navigate -to this sample directory and do: - -ant run - -OR if you don't have ant, on Windows do - -java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator.jar calculator.CalculatorClient - -and on *nix do - -java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator.jar calculator.CalculatorClient - - -Sample Overview ---------------- -The sample provides the calculator service with a default SCA (java) binding. The 'logging' policy -which is handled by the Tuscany SCA java policy-logging module is used in this calculator -composite to specify the need for 'logging'. The MultiplyService Component specifies for 'jassAuthentication' -which is one way of implemention login authentication, using the Java Authentication and Authorization Service. - -The logging intent and policyset that is to be used by this calculator application must be -defined in the definitions.xml file. Here we use the policyset structure already defined in -Tuscany for logging under the policy-logging and hence there is no need to specify the policyset processors -and policy handler classes as part of this application. - -Similarly the jaasAuthentication intent and policyset also is defined in the definitions.xml file -of this sample. This sample uses the calculator.security.JaasLoginModule class for handling the -authentication functions. Right now there is a simply matching of userid and passwords that happens in this -class. Applications could implement their own sophisticated authentication mechanisms. For more information -on how to do this please look up Java Authentication and Authorization Service documentation. The sample -also use the calculator.security.CalculatorCallbackHandler to fetch the userid and password to be use for the -login authentication. This handler presently uses hardcoded userids and passwords. Applications could -typically use this handler to prompt for userid and passwords. - -There are two components that provide the calculator service namely 'CalculatorServiceComponent' -and 'AnotherCalculatorServiceComponent'. The logging intent is specified for the 'subtract' and 'divide' -operations of the 'CalculatorServiceCompnent' implementation, and on the entire implementation -(i.e. all operations) for the AddServiceComponent and AnotherCalculatorServiceComponent. - -The CalculatorClient first exercises the CalculatorServiceComponent calling add, -subtract, multiply and divide operations. This results in logging messages appearing on the -console for 'add', 'subtract' and 'divide' operations. The CalculatorClient then exercises the -AnotherCalculatorServiceComponent calling all the service methods. This will result in logging messages -printed on the console for all the operations. For the 'add' operation there will be two sets of messages -printed - one that has resulted from specifying the 'logging' intent on the implementation element of the -'AnotherCalculatorServiceComponent' and another from specifying the 'logging' intent on the -'AddServiceComponent' - -The jaasAuthentication intent is specified for the 'MultiplyServiceComponent'. So everytime this component -is invoke an authentication is attempted and only if it succeeds, is the multiply function is invoked. The -console prints messages that denote if the authentication has succeeded or failed. - -Thus this sample demonstrates how intents could be applied to either implementations as a whole or to some -selective operations on an implementation. - - -calculator/ - src/ - main/ - java/ - calculator/ - CalculatorService.java - the first component, calls +-/* as - appropriate - CalculatorServiceImpl.java - AddService.java - adds two numbers - AddServiceImpl.java - SubtractService.java - subtracts one number from another - SubtractServiceImpl.java - MultiplyService.java - multiplies two numbers - MultiplyServiceImpl.java - DivideService.java - divides one number by another - DivideServiceImpl.java - CalculatorClient.java - starts the SCA Runtime and - deploys the Calculator.composite. - It then calls the deployed Calculator - Components services - calculator/security - JaasLoginModule.java JaasLoginModule implementation for this sample - CalculatorCallbackHandler.java JAAS callbackhandler for fetching userid and password - - - resources/ - Calculator.composite - the SCA assembly for this sample - definitions.xml - sca definitions file that defines the 'logging' intent - and policyset - used by this application - CalculatorLogMessages.properties - A resource bundle contain the log messages to be - used. - CalculatorJaas.config - JAAS Login Configuration file - - test/ - java/ - calculator/ - CalculatorTestCase.java - JUnit test case - calculator.png - a pictorial representation of the sample - .composite file - build.xml - the Ant build file - pom.xml - the Maven build file - - - -Building And Running The Sample Using Ant ------------------------------------------ -With the binary distribution the sample can be built and run using Ant as -follows - -cd calculator-implementation-policies -ant compile -ant run - -You should see the following output from the run target. - -run: - [java] Calling CalculatorServiceComponent configured with 'logging' policy for subtract and divide operations... - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Invoking operation - add - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Returned from operation - add - [java] 3 + 2=5.0 - [java] 3 - 2=1.0 - [java] 3 * 2=6.0 - [java] 3 / 2=1.5 - [java] Calling CalculatorServiceComponent configured with 'logging' for all operations in the implementation... - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Invoking operation - subtract - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Returned from operation - subtract - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Invoking operation - divide - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Returned from operation - divide - [java] Nov 23, 2007 1:06:10 PM - [java] 3 + 2=5.0 - [java] 3 - 2=1.0 - [java] 3 * 2=6.0 - [java] INFO: Invoking operation - add - [java] 3 / 2=1.5 - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Invoking operation - add - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Returned from operation - add - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Returned from operation - add - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Invoking operation - subtract - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Returned from operation - subtract - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Invoking operation - multiply - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Returned from operation - multiply - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Invoking operation - divide - [java] Nov 23, 2007 1:06:10 PM - [java] INFO: Returned from operation - divide - -Building And Running The Sample Using Maven -------------------------------------------- -With either the binary or source distributions the sample can be built and run -using Maven as follows. - -cd calculator -mvn - -You should see the following output from the test phase. Notice the log messages. - -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running calculator.CalculatorTestCase -Dec 18, 2007 12:05:06 PM org.apache.tuscany.sca.contribution.processor.ValidatingXMLStreamReader$1 error -WARNING: XMLSchema validation problem in: file:/F:/LatestTrunk/sca/samples/calculator-implementation-policies/target/ -classes/Calculator.composite, line: 28, column: 4 -cvc-complex-type.2.4.a: Invalid content was found starting with element 'operation'. One of '{WC[##other:"http://www. -osoa.org/xmlns/sca/1.0"]}' is expected. -Dec 18, 2007 12:05:06 PM -INFO: Invoking operation - add -Dec 18, 2007 12:05:06 PM -FINER: Inovoking operation add with arguments 3.0, 2.0, -Dec 18, 2007 12:05:06 PM -INFO: Returned from operation - add -Dec 18, 2007 12:05:06 PM -FINER: Returning from operation add with return value 5 -Dec 18, 2007 12:05:06 PM -INFO: Invoking operation - subtract -Dec 18, 2007 12:05:06 PM -FINER: Inovoking operation subtract with arguments 3.0, 2.0, -Dec 18, 2007 12:05:06 PM -INFO: Returned from operation - subtract -Dec 18, 2007 12:05:06 PM -FINER: Returning from operation subtract with return value 1 -Successfully AUTHENTICATED!! -Dec 18, 2007 12:05:06 PM -INFO: Invoking operation - divide -Dec 18, 2007 12:05:06 PM -FINER: Inovoking operation divide with arguments 3.0, 2.0, -Dec 18, 2007 12:05:06 PM -INFO: Returned from operation - divide -Dec 18, 2007 12:05:06 PM -FINER: Returning from operation divide with return value 1.5 -Dec 18, 2007 12:05:06 PM org.apache.tuscany.sca.contribution.processor.ValidatingXMLStreamReader$1 error -WARNING: XMLSchema validation problem in: file:/F:/LatestTrunk/sca/samples/calculator-implementation-policies/target/ -classes/Calculator.composite, line: 28, column: 4 -cvc-complex-type.2.4.a: Invalid content was found starting with element 'operation'. One of '{WC[##other:"http://www. -osoa.org/xmlns/sca/1.0"]}' is expected. -Dec 18, 2007 12:05:06 PM -INFO: Invoking operation - add -Dec 18, 2007 12:05:06 PM -FINER: Inovoking operation add with arguments 3.0, 2.0, -Dec 18, 2007 12:05:06 PM -INFO: Invoking operation - add -Dec 18, 2007 12:05:06 PM -FINER: Inovoking operation add with arguments 3.0, 2.0, -Dec 18, 2007 12:05:06 PM -INFO: Returned from operation - add -Dec 18, 2007 12:05:06 PM -FINER: Returning from operation add with return value 5 -Dec 18, 2007 12:05:06 PM -INFO: Returned from operation - add -Dec 18, 2007 12:05:06 PM -FINER: Returning from operation add with return value 5 -Dec 18, 2007 12:05:06 PM -INFO: Invoking operation - subtract -Dec 18, 2007 12:05:06 PM -FINER: Inovoking operation subtract with arguments 3.0, 2.0, -Dec 18, 2007 12:05:06 PM -INFO: Returned from operation - subtract -Dec 18, 2007 12:05:06 PM -FINER: Returning from operation subtract with return value 1 -Dec 18, 2007 12:05:06 PM -INFO: Invoking operation - multiply -Dec 18, 2007 12:05:06 PM -FINER: Inovoking operation multiply with arguments 3.0, 2.0, -Successfully AUTHENTICATED!! -Dec 18, 2007 12:05:06 PM -INFO: Returned from operation - multiply -Dec 18, 2007 12:05:06 PM -FINER: Returning from operation multiply with return value 6 -Dec 18, 2007 12:05:06 PM -INFO: Invoking operation - divide -Dec 18, 2007 12:05:06 PM -FINER: Inovoking operation divide with arguments 3.0, 2.0, -Dec 18, 2007 12:05:06 PM -INFO: Returned from operation - divide -Dec 18, 2007 12:05:06 PM -FINER: Returning from operation divide with return value 1.5 -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.823 sec - -Results : - -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 - -Results : - -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 -This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/build.xml b/tags/java/sca/1.3/samples/calculator-implementation-policies/build.xml deleted file mode 100644 index 7afa23a07f..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/build.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/calculator.png b/tags/java/sca/1.3/samples/calculator-implementation-policies/calculator.png deleted file mode 100644 index 995a57b1fd..0000000000 Binary files a/tags/java/sca/1.3/samples/calculator-implementation-policies/calculator.png and /dev/null differ diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/calculator.svg b/tags/java/sca/1.3/samples/calculator-implementation-policies/calculator.svg deleted file mode 100644 index af34f07e04..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/calculator.svg +++ /dev/null @@ -1,329 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - Calculator - - CalculatorServiceComponent - - - CalculatorService - AddServiceComponent - - SubtractServiceComponent - - MultiplyServiceComponent - - DivideServiceComponent - addService - subtractService - multiplyService - divideService - - - - - - diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/pom.xml b/tags/java/sca/1.3/samples/calculator-implementation-policies/pom.xml deleted file mode 100644 index 1a8e4f572c..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-sca - 1.3 - ../../pom.xml - - sample-calculator-impl-policies - Apache Tuscany SCA Calculator Sample using Implementation Policies - - - - apache.incubator - http://people.apache.org/repo/m2-incubating-repository - - - - - - org.apache.tuscany.sca - tuscany-host-embedded - 1.3 - - - - org.apache.tuscany.sca - tuscany-implementation-java-runtime - 1.3 - runtime - - - - junit - junit - 4.2 - test - - - - org.apache.tuscany.sca - tuscany-policy-logging - 1.3 - runtime - - - - org.apache.tuscany.sca - tuscany-policy-security - 1.3 - runtime - - - - - - ${artifactId} - - diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java deleted file mode 100644 index 5a1e7a638a..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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; - -/** - * The Add service interface - */ -public interface AddService { - - double add(double n1, double n2); - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java deleted file mode 100644 index caf4d358df..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of the Add service - */ -public class AddServiceImpl implements AddService { - - public double add(double n1, double n2) { - Logger logger = Logger.getLogger("calculator"); - logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); - return n1 + n2; - } - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java deleted file mode 100644 index 2bce187049..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 javax.security.auth.login.Configuration; - -import org.apache.tuscany.sca.host.embedded.SCADomain; - -/** - * This client program shows how to create an SCA runtime, start it, - * and locate and invoke a SCA component - */ -public class CalculatorClient { - public static void main(String[] args) throws Exception { - try { - Configuration secConf = Configuration.getConfiguration(); - } catch (java.lang.SecurityException e) { - System.setProperty("java.security.auth.login.config", CalculatorClient.class.getClassLoader() - .getResource("CalculatorJass.config").toString()); - } - - SCADomain scaDomain = SCADomain.newInstance("Calculator.composite"); - - CalculatorService calculatorService = - scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); - - // Calculate - System.out.println("Calling CalculatorServiceComponent configured with 'logging' " + - "policy for subtract and divide operations..."); - System.out.println("3 + 2=" + calculatorService.add(3, 2)); - System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); - System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); - System.out.println("3 / 2=" + calculatorService.divide(3, 2)); - - calculatorService = - scaDomain.getService(CalculatorService.class, "AnotherCalculatorServiceComponent"); - - // Calculate - System.out.println("Calling CalculatorServiceComponent configured with 'logging' " + - "for all operations in the implementation..."); - System.out.println("3 + 2=" + calculatorService.add(3, 2)); - System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); - System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); - System.out.println("3 / 2=" + calculatorService.divide(3, 2)); - - scaDomain.close(); - } - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java deleted file mode 100644 index ad87375529..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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; - - -/** - * The Calculator service interface. - */ -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/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java deleted file mode 100644 index ae4ed12b7b..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.osoa.sca.annotations.Reference; - - -/** - * An implementation of the Calculator service. - */ -public class CalculatorServiceImpl implements CalculatorService { - - private AddService addService; - private SubtractService subtractService; - private MultiplyService multiplyService; - private DivideService divideService; - - @Reference - public void setAddService(AddService addService) { - this.addService = addService; - } - - @Reference - public void setSubtractService(SubtractService subtractService) { - this.subtractService = subtractService; - } - - @Reference - public void setDivideService(DivideService divideService) { - this.divideService = divideService; - } - - @Reference - public void setMultiplyService(MultiplyService multiplyService) { - this.multiplyService = multiplyService; - } - - public double add(double n1, double n2) { - return addService.add(n1, n2); - } - - public double subtract(double n1, double n2) { - return subtractService.subtract(n1, n2); - } - - public double multiply(double n1, double n2) { - return multiplyService.multiply(n1, n2); - } - - public double divide(double n1, double n2) { - return divideService.divide(n1, n2); - } - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java deleted file mode 100644 index ef6a8b375b..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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; - -/** - * The divide service interface - */ -public interface DivideService { - - double divide(double n1, double n2); - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java deleted file mode 100644 index cd91935f08..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of the Divide service. - */ -public class DivideServiceImpl implements DivideService { - - public double divide(double n1, double n2) { - Logger logger = Logger.getLogger("calculator"); - logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); - return n1 / n2; - } - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java deleted file mode 100644 index db568cc762..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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; - -/** - * The interface for the multiply service - */ -public interface MultiplyService { - - double multiply(double n1, double n2); - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java deleted file mode 100644 index c85357fcd8..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of the Multiply service. - */ -public class MultiplyServiceImpl implements MultiplyService { - - public double multiply(double n1, double n2) { - Logger logger = Logger.getLogger("calculator"); - logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); - return n1 * n2; - } - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java deleted file mode 100644 index 56ee372fc4..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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; - -/** - * The interface for the multiply service - */ -public interface SubtractService { - - double subtract(double n1, double n2); - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java deleted file mode 100644 index 1b669084d9..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of the subtract service. - */ -public class SubtractServiceImpl implements SubtractService { - - public double subtract(double n1, double n2) { - Logger logger = Logger.getLogger("calculator"); - logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); - return n1 - n2; - } - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java deleted file mode 100644 index b48fb90148..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.security; - -import java.io.IOException; - -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.UnsupportedCallbackException; - -/** - * @version $Rev$ $Date$ - */ -public class CalculatorCallbackHandler implements CallbackHandler { - - public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { - for (int i = 0; i < callbacks.length; i++) { - if (callbacks[i] instanceof NameCallback) { - NameCallback nc = (NameCallback)callbacks[i]; - nc.setName("CalculatorUser"); - } else if (callbacks[i] instanceof PasswordCallback) { - PasswordCallback pc = (PasswordCallback)callbacks[i]; - pc.setPassword("CalculatorUserPasswd".toCharArray()); - } else { - throw new UnsupportedCallbackException - (callbacks[i], "Unsupported Callback!"); - } - } - } - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java deleted file mode 100644 index fe4097640b..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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.security; - -import java.security.Principal; -import java.util.Map; - -import javax.security.auth.Subject; -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.login.LoginException; -import javax.security.auth.spi.LoginModule; - -/** - * @version $Rev$ $Date$ - */ -public class JaasLoginModule implements LoginModule { - - private CallbackHandler callbackHandler; - private Subject subject; - private Principal userPrincipal; - private String userId; - private String password; - private boolean succeeded; - private boolean commitSucceeded; - - public void initialize(Subject subject, - CallbackHandler callbackHandler, - Map sharedState, - Map options) { - this.callbackHandler = callbackHandler; - this.subject = subject; - } - - public boolean login() throws LoginException { - Callback[] callbacks = new Callback[2]; - callbacks[0] = new NameCallback("UserId:"); - callbacks[1] = new PasswordCallback("Password:", false); - - try { - callbackHandler.handle(callbacks); - userId = ((NameCallback)callbacks[0]).getName(); - password = new String(((PasswordCallback)callbacks[1]).getPassword()); - - if (userId.equals("CalculatorUser") && password.equals("CalculatorUserPasswd")) { - System.out.println("Successfully AUTHENTICATED!!"); - succeeded = true; - return true; - } else { - System.out.println("Incorrect userId / password! AUTHENTICATION FAILED!!"); - return false; - } - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - *

This method is called if the LoginContext's - * overall authentication succeeded - * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules - * succeeded). - * - *

If this LoginModule's own authentication attempt - * succeeded (checked by retrieving the private state saved by the - * login method), then this method associates a - * UserPrincipal - * with the Subject located in the - * LoginModule. If this LoginModule's own - * authentication attempted failed, then this method removes - * any state that was originally saved. - * - *

- * - * @exception LoginException if the commit fails. - * - * @return true if this LoginModule's own login and commit - * attempts succeeded, or false otherwise. - */ - public boolean commit() throws LoginException { - if (succeeded == false) { - return false; - } else { - // add a Principal (authenticated identity) to the Subject - - // assume the user we authenticated is the UserPrincipal - userPrincipal = new UserPrincipal(userId); - if (!subject.getPrincipals().contains(userPrincipal)) - subject.getPrincipals().add(userPrincipal); - - // in any case, clean out state - userId = null; - password = null; - commitSucceeded = true; - return true; - } - } - - /** - *

This method is called if the LoginContext's - * overall authentication failed. - * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules - * did not succeed). - * - *

If this LoginModule's own authentication attempt - * succeeded (checked by retrieving the private state saved by the - * login and commit methods), - * then this method cleans up any state that was originally saved. - * - *

- * - * @exception LoginException if the abort fails. - * - * @return false if this LoginModule's own login and/or commit attempts - * failed, and true otherwise. - */ - public boolean abort() throws LoginException { - if (succeeded == false) { - return false; - } else if (succeeded == true && commitSucceeded == false) { - // login succeeded but overall authentication failed - succeeded = false; - userId = null; - password = null; - userPrincipal = null; - } else { - // overall authentication succeeded and commit succeeded, - // but someone else's commit failed - logout(); - } - return true; - } - - /** - * Logout the user. - * - *

This method removes the SimplePrincipal - * that was added by the commit method. - * - *

- * - * @exception LoginException if the logout fails. - * - * @return true in all cases since this LoginModule - * should not be ignored. - */ - public boolean logout() throws LoginException { - subject.getPrincipals().remove(userPrincipal); - succeeded = false; - succeeded = commitSucceeded; - userId = null; - if (password != null) - password = null; - userPrincipal = null; - return true; - } - -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java deleted file mode 100644 index 595626e672..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * 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.security; - -import java.security.Principal; - -/** - * @version $Rev$ $Date$ - */ -public class UserPrincipal implements Principal { - - private final String name; - - public UserPrincipal(String name) { - if (name == null) - throw new IllegalArgumentException("name cannot be null"); - this.name = name; - } - - public String getName() { - return name; - } - - public String toString() { - return name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final UserPrincipal other = (UserPrincipal)obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } -} diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/Calculator.composite b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/Calculator.composite deleted file mode 100644 index d91bf88d96..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/Calculator.composite +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config deleted file mode 100644 index 0e7cb86633..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config +++ /dev/null @@ -1,3 +0,0 @@ -Calculator { - calculator.security.JaasLoginModule required debug=true; -}; diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties deleted file mode 100644 index f62125eaa9..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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. -CALLING_OPERATION=Inovoking operation {0} with arguments {1} -OPERATION_RETURNED=Returning from operation {0} with return value {1} \ No newline at end of file diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/definitions.xml b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/definitions.xml deleted file mode 100644 index 6cccde0d13..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/main/resources/definitions.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - Calculator - calculator.security.CalculatorCallbackHandler - - - - - - - FINER - - - \ No newline at end of file diff --git a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/1.3/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java deleted file mode 100644 index 157570c3df..0000000000 --- a/tags/java/sca/1.3/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 javax.security.auth.login.Configuration; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.SCADomain; - -/** - * This shows how to test the Calculator service component. - */ -public class CalculatorTestCase extends TestCase { - - private CalculatorService calculatorService; - private CalculatorService anotherCalculatorService; - private SCADomain scaDomain; - - @Override - protected void setUp() throws Exception { - try { - Configuration secConf = Configuration.getConfiguration(); - } catch ( java.lang.SecurityException e ) { - //FIXME: We should not compare exception strings as they are localized in various languages - //if ( e.getMessage().equals("Unable to locate a login configuration") ) { - System.setProperty("java.security.auth.login.config", - this.getClass().getClassLoader().getResource("CalculatorJass.config").toString()); - //} else { - // throw e; - //} - } - scaDomain = SCADomain.newInstance("Calculator.composite"); - calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); - anotherCalculatorService = scaDomain.getService(CalculatorService.class, "AnotherCalculatorServiceComponent"); - } - - @Override - protected void tearDown() throws Exception { - scaDomain.close(); - } - - 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); - } - - public void testAnotherCalculator() throws Exception { - // Calculate - assertEquals(anotherCalculatorService.add(3, 2), 5.0); - assertEquals(anotherCalculatorService.subtract(3, 2), 1.0); - assertEquals(anotherCalculatorService.multiply(3, 2), 6.0); - assertEquals(anotherCalculatorService.divide(3, 2), 1.5); - } -} -- cgit v1.2.3