summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java74
-rw-r--r--branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java35
2 files changed, 109 insertions, 0 deletions
diff --git a/branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java b/branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java
new file mode 100644
index 0000000000..3f26b8c6db
--- /dev/null
+++ b/branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java
@@ -0,0 +1,74 @@
+/*
+ * 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 implementation.policies;
+
+import javax.security.auth.login.Configuration;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import calculator.CalculatorService;
+
+
+/**
+ * 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("implementation/policies/CalculatorJass.config").toString());
+ }
+
+ String location = ContributionLocationHelper.getContributionLocation("implementation/policies/ImplementationPolicies.composite");
+ Node node = NodeFactory.newInstance().createNode("implementation/policies/ImplementationPolicies.composite", new Contribution("c1", location));
+ node.start();
+
+ CalculatorService calculatorService =
+ ((Client)node).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 =
+ ((Client)node).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));
+
+ node.stop();
+ System.out.println("Bye");
+ }
+
+}
diff --git a/branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java b/branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java
new file mode 100644
index 0000000000..efd5fd22df
--- /dev/null
+++ b/branches/sca-java-2.0-M3/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java
@@ -0,0 +1,35 @@
+/*
+ * 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 implementation.policies;
+
+import junit.framework.TestCase;
+
+import org.junit.Ignore;
+
+/**
+ * Tests out the big bank service
+ *
+ */
+@Ignore("TUSCANY-3027")
+public class ImplementationPoliciesTestCase extends TestCase {
+
+ public void testServer() throws Exception {
+ CalculatorClient.main(new String[] {""});
+ }
+}