From be6f6fdf5f4d17e5eabacf6473031a212914cfcc Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 29 Jan 2010 19:03:27 +0000 Subject: Java SCA 1.6 RC2a Release Tag git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@904591 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/java/context/access/CalculatorClient.java | 60 ++++++++++++++++ .../java/context/access/ContextAccessTestCase.java | 32 +++++++++ .../java/context/imports/CalculatorClient.java | 54 +++++++++++++++ .../context/imports/ContextImportsTestCase.java | 32 +++++++++ .../context/multiple/MultipleContextTestCase.java | 32 +++++++++ .../java/context/multiple/StockQuoteServer.java | 50 ++++++++++++++ .../implementation/policies/CalculatorClient.java | 79 ++++++++++++++++++++++ .../policies/ImplementationPoliciesTestCase.java | 32 +++++++++ .../folder/SpringFolderLocationTestCase.java | 45 ++++++++++++ .../folder/SpringFolderNoManifestTestCase.java | 45 ++++++++++++ .../location/jar/SpringJarLocationTestCase.java | 45 ++++++++++++ .../location/jar/SpringJarNoManifestTestCase.java | 45 ++++++++++++ .../itest/spring/AbstractHelloWorldTestCase.java | 43 ++++++++++++ .../sca/itest/spring/AbstractSCATestCase.java | 70 +++++++++++++++++++ .../tuscany/sca/itest/spring/HelloWorld.java | 31 +++++++++ .../tuscany/sca/itest/spring/HelloWorldProxy.java | 41 +++++++++++ .../spring/SpringDelegationHelloWorldTestCase.java | 35 ++++++++++ .../sca/itest/spring/SpringHelloWorldTestCase.java | 36 ++++++++++ .../sca/itest/spring/TestHelloWorldBean.java | 38 +++++++++++ .../itest/spring/TestHelloWorldDelegatorBean.java | 42 ++++++++++++ .../SpringExplicitReferenceTestCase.java | 45 ++++++++++++ .../SpringImplicitReferenceTestCase.java | 48 +++++++++++++ .../services/SpringExplicitServiceTestCase.java | 40 +++++++++++ .../services/SpringImplicitServiceTestCase.java | 38 +++++++++++ .../java/spring/annotations/CalculatorClient.java | 64 ++++++++++++++++++ .../annotations/SpringAnnotationsTestCase.java | 32 +++++++++ 26 files changed, 1154 insertions(+) create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/access/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/access/ContextAccessTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/imports/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/imports/ContextImportsTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/multiple/MultipleContextTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/multiple/StockQuoteServer.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/implementation/policies/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/folder/SpringFolderLocationTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/folder/SpringFolderNoManifestTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/jar/SpringJarLocationTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/jar/SpringJarNoManifestTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/spring/annotations/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java (limited to 'sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test') diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/access/CalculatorClient.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/access/CalculatorClient.java new file mode 100644 index 0000000000..9b7202d951 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/access/CalculatorClient.java @@ -0,0 +1,60 @@ +/* + * 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 context.access; + +import java.io.File; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.SCAContribution; +import org.springframework.context.ApplicationContext; + +import context.access.SCAApplicationContextProvider; +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 { + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANode(new File("src/main/resources/context/access/Calculator.composite").toURL().toString(), + new SCAContribution("TestContribution", new File("src/main/resources/context/access/").toURL().toString())); + node.start(); + + // Code: To access the Spring Application Context instance + ApplicationContext ctx = SCAApplicationContextProvider.getApplicationContext(); + if (ctx.containsBean("CalculatorServiceBean")) + System.out.println("CalculatorServiceBean is now available for use..."); + + CalculatorService calculatorService = + ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + + 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(); + } + +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/access/ContextAccessTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/access/ContextAccessTestCase.java new file mode 100644 index 0000000000..5feb293bc8 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/access/ContextAccessTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 context.access; + +import junit.framework.TestCase; + +/** + * Tests out the big bank service + * + */ +public class ContextAccessTestCase extends TestCase { + + public void testServer() throws Exception { + CalculatorClient.main(new String[] {""}); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/imports/CalculatorClient.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/imports/CalculatorClient.java new file mode 100644 index 0000000000..12ced16785 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/imports/CalculatorClient.java @@ -0,0 +1,54 @@ +/* + * 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 context.imports; + +import java.io.File; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.SCAContribution; + +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 { + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANode(new File("src/main/resources/context/imports/Calculator.composite").toURL().toString(), + new SCAContribution("TestContribution", new File("src/main/resources/context/imports/").toURL().toString())); + node.start(); + + CalculatorService calculatorService = + ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent/CalculatorServiceBean"); + + 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(); + } + +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/imports/ContextImportsTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/imports/ContextImportsTestCase.java new file mode 100644 index 0000000000..3940bf65fa --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/imports/ContextImportsTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 context.imports; + +import junit.framework.TestCase; + +/** + * Tests out the big bank service + * + */ +public class ContextImportsTestCase extends TestCase { + + public void testServer() throws Exception { + CalculatorClient.main(new String[] {""}); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/multiple/MultipleContextTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/multiple/MultipleContextTestCase.java new file mode 100644 index 0000000000..75b296bf32 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/multiple/MultipleContextTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 context.multiple; + +import junit.framework.TestCase; + +/** + * Tests out the big bank service + * + */ +public class MultipleContextTestCase extends TestCase { + + public void testServer() throws Exception { + StockQuoteServer.main(new String[] {"1000"}); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/multiple/StockQuoteServer.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/multiple/StockQuoteServer.java new file mode 100644 index 0000000000..18c7ca6a74 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/context/multiple/StockQuoteServer.java @@ -0,0 +1,50 @@ +/* + * 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 context.multiple; + +import java.io.File; + +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.springframework.context.ApplicationContext; +import context.access.SCAApplicationContextProvider; + +/** + * This server program shows how to bootstrap SCA from a simple J2SE program + * and start it which activates the StockQuote Web service endpoint. + */ +public class StockQuoteServer { + + public static void main(String[] args) throws Exception { + + System.out.println("Starting the Sample SCA StockQuote Service..."); + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANode(new File("src/main/resources/context/multiple/StockQuote.composite").toURL().toString(), + new SCAContribution("TestContribution", new File("src/main/resources/context/multiple/").toURL().toString())); + node.start(); + + System.out.println("Press Enter to Exit..."); + Thread.sleep(1000); + + node.stop(); + System.out.println("Bye"); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/implementation/policies/CalculatorClient.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/implementation/policies/CalculatorClient.java new file mode 100644 index 0000000000..bc29f54d86 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/implementation/policies/CalculatorClient.java @@ -0,0 +1,79 @@ +/* + * 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 java.io.File; + +import javax.security.auth.login.Configuration; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +import calculator.CalculatorService; +import calculator.CalculatorServiceImpl; + + +/** + * 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()); + } + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANode(new File("src/main/resources/implementation/policies/Calculator.composite").toURL().toString(), + new SCAContribution("TestContribution", new File("src/main/resources/implementation/policies/").toURL().toString())); + node.start(); + + CalculatorService calculatorService = + ((SCAClient)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 = + ((SCAClient)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/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java new file mode 100644 index 0000000000..1e759f98a0 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java @@ -0,0 +1,32 @@ +/* + * 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; + +/** + * Tests out the big bank service + * + */ +public class ImplementationPoliciesTestCase extends TestCase { + + public void testServer() throws Exception { + CalculatorClient.main(new String[] {""}); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/folder/SpringFolderLocationTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/folder/SpringFolderLocationTestCase.java new file mode 100644 index 0000000000..bd1150e99a --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/folder/SpringFolderLocationTestCase.java @@ -0,0 +1,45 @@ +/* + * 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 location.folder; + +import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase; + +/** + * A test case designed to test the implementation of Properties from a Spring application + * context, where the properties are explicit, through the presence of an sca:property + * element within the Spring application context + * + * The artifacts involved in this test are: + * + * 1) A composite containing a component with a Spring implementation + * 2) The element references an application context that + * uses an explicit sca:property element which is used to compute the response to an invocation + * of the service of the implementation + * + * @version $Rev$ $Date$ + */ +public class SpringFolderLocationTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringFolderLocationTestCase() { + super("SpringFolderLocation.composite", "location/folder"); + } +} + diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/folder/SpringFolderNoManifestTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/folder/SpringFolderNoManifestTestCase.java new file mode 100644 index 0000000000..c9876fd947 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/folder/SpringFolderNoManifestTestCase.java @@ -0,0 +1,45 @@ +/* + * 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 location.folder; + +import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase; + +/** + * A test case designed to test the implementation of Properties from a Spring application + * context, where the properties are explicit, through the presence of an sca:property + * element within the Spring application context + * + * The artifacts involved in this test are: + * + * 1) A composite containing a component with a Spring implementation + * 2) The element references an application context that + * uses an explicit sca:property element which is used to compute the response to an invocation + * of the service of the implementation + * + * @version $Rev$ $Date$ + */ +public class SpringFolderNoManifestTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringFolderNoManifestTestCase() { + super("SpringFolderNoManifest.composite", "location/folder"); + } +} + diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/jar/SpringJarLocationTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/jar/SpringJarLocationTestCase.java new file mode 100644 index 0000000000..102cd69874 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/jar/SpringJarLocationTestCase.java @@ -0,0 +1,45 @@ +/* + * 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 location.jar; + +import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase; + +/** + * A test case designed to test the implementation of Properties from a Spring application + * context, where the properties are explicit, through the presence of an sca:property + * element within the Spring application context + * + * The artifacts involved in this test are: + * + * 1) A composite containing a component with a Spring implementation + * 2) The element references an application context that + * uses an explicit sca:property element which is used to compute the response to an invocation + * of the service of the implementation + * + * @version $Rev$ $Date$ + */ +public class SpringJarLocationTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringJarLocationTestCase() { + super("SpringJarLocation.composite", "location/jar"); + } +} + diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/jar/SpringJarNoManifestTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/jar/SpringJarNoManifestTestCase.java new file mode 100644 index 0000000000..e32227cbe9 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/location/jar/SpringJarNoManifestTestCase.java @@ -0,0 +1,45 @@ +/* + * 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 location.jar; + +import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase; + +/** + * A test case designed to test the implementation of Properties from a Spring application + * context, where the properties are explicit, through the presence of an sca:property + * element within the Spring application context + * + * The artifacts involved in this test are: + * + * 1) A composite containing a component with a Spring implementation + * 2) The element references an application context that + * uses an explicit sca:property element which is used to compute the response to an invocation + * of the service of the implementation + * + * @version $Rev$ $Date$ + */ +public class SpringJarNoManifestTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringJarNoManifestTestCase() { + super("SpringJarNoManifest.composite", "location/jar"); + } +} + diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java new file mode 100644 index 0000000000..aa63fbd5c2 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java @@ -0,0 +1,43 @@ +/* + * 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 org.apache.tuscany.sca.itest.spring; + +/** + * Basic "hello world" style test case for testing Spring component implementation + * + */ +public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase { + + /** + * Calls the hello world service and checks that it gives the right response... + */ + public AbstractHelloWorldTestCase(String compositeName, String contributionLocation) { + super(compositeName, contributionLocation); + } + + public void testHello() throws Exception { + assertEquals("Hello petra", service.sayHello("petra")); + } + + @Override + protected Class getServiceClass() { + return HelloWorld.class; + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java new file mode 100644 index 0000000000..a2698cf9a3 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java @@ -0,0 +1,70 @@ +/* + * 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 org.apache.tuscany.sca.itest.spring; + +import junit.framework.TestCase; + +import java.io.File; +import java.net.MalformedURLException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public abstract class AbstractSCATestCase extends TestCase { + + protected SCADomain domain; + protected String compositeName; + protected String contributionLocation; + protected T service; + + public AbstractSCATestCase(String compositeName, String contributionLocation) { + super(); + this.compositeName = compositeName; + this.contributionLocation = contributionLocation; + try { + if (contributionLocation != null) { + File f = new File("target/classes/" + contributionLocation); + this.contributionLocation = f.toURL().toString(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("http://localhost", contributionLocation, compositeName); + service = domain.getService(getServiceClass(), "ClientComponent"); + } + + abstract protected Class getServiceClass(); + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + String compositeName = className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + System.out.println("Using composite: " + compositeName); + return compositeName; + } + +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java new file mode 100644 index 0000000000..1405310100 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java @@ -0,0 +1,31 @@ +/* + * 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 org.apache.tuscany.sca.itest.spring; + +/** + * Interface for the "hello world" service - predictably simple with a single operation + * "sayHello" + * + */ +public interface HelloWorld { + + public String sayHello(String s); + +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java new file mode 100644 index 0000000000..d75d19295d --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java @@ -0,0 +1,41 @@ +/* + * 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 org.apache.tuscany.sca.itest.spring; + +import org.osoa.sca.annotations.Reference; + +/** + * A simple proxy Java class which implements the HelloWorld interface but which uses + * a reference "delegate" to actually provide the HelloWorld service + * + */ +public class HelloWorldProxy implements HelloWorld { + + // Here is the reference "delegate" - it implements the HelloWorld interface... + @Reference + public HelloWorld delegate; + + public String sayHello(String s) { + // Simply call the reference to satisfy the service request... + System.out.println("HelloWorldProxy - calling sayHello"); + return delegate.sayHello(s); + } + +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java new file mode 100644 index 0000000000..11ed16e6b4 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.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 org.apache.tuscany.sca.itest.spring; + +/** + * A basic test case of: + * 1) A composite containing a component with a Spring implementation + * 2) The composite has a component with a Java POJO implementation which uses the + * Spring implementation to satisfy a reference + * + */ +public class SpringDelegationHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringDelegationHelloWorldTestCase() { + super("SpringDelegationHelloWorld.composite", "org/apache/tuscany/sca/itest/spring"); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java new file mode 100644 index 0000000000..bec19b76de --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java @@ -0,0 +1,36 @@ +/* + * 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 org.apache.tuscany.sca.itest.spring; + +/** + * A basic test case of: + * 1) A composite containing a component with a Spring implementation + * 2) The composite has a component with a Java POJO implementation which uses the + * Spring implementation to satisfy a reference + * 3) The Spring component delegates function to a second spring bean + * + */ +public class SpringHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringHelloWorldTestCase() { + super("SpringHelloWorld.composite", "org/apache/tuscany/sca/itest/spring"); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java new file mode 100644 index 0000000000..45b47b47a8 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.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 org.apache.tuscany.sca.itest.spring; + +import helloworld.HelloWorld; + +/** + * A simple test Spring bean which provides the HelloWorld service + * + */ + +public class TestHelloWorldBean implements HelloWorld { + + static String hello = "Hello "; + + // Classic "Hello xxx" response to any input message + public String sayHello(String message) { + System.out.println("TestHelloWorldBean - sayHello called"); + return (hello + message); + } + +} // end class TestHelloWorldBean diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java new file mode 100644 index 0000000000..5dfeeffd97 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java @@ -0,0 +1,42 @@ +/* + * 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 org.apache.tuscany.sca.itest.spring; + +import helloworld.HelloWorld; + +/** + * A simple test Spring bean which delgates to another bean + * + */ + +public class TestHelloWorldDelegatorBean implements HelloWorld { + + HelloWorld delegate; + + public void setDelegate(HelloWorld delegate) { + this.delegate = delegate; + } + + // Classic "Hello xxx" response to any input message + public String sayHello(String message) { + System.out.println("TestHelloWorldDelegatorBean - sayHello called"); + return delegate.sayHello(message); + } + +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java new file mode 100644 index 0000000000..603d2524f6 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java @@ -0,0 +1,45 @@ +/* + * 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 sca.references; + +import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase; + +/** + * A test case designed to test the implementation of References from a Spring application + * context, where the references are explicit, through the presence of an sca:reference + * element within the Spring application context + * + * The artifacts involved in this test are: + * + * 1) A composite containing a component with a Spring implementation which makes + * a reference to a second component + * 2) The composite has a component with a Java POJO implementation which satisfies the reference + * 3) The element references an application context that + * uses an explicit sca:reference element to identify the reference made by the Spring application + * + * @version $Rev$ $Date$ + */ +public class SpringExplicitReferenceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringExplicitReferenceTestCase() { + super("SpringExplicitReference.composite", "sca/references"); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java new file mode 100644 index 0000000000..757f12c08b --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java @@ -0,0 +1,48 @@ +/* + * 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 sca.references; + +import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase; + +/** + * A test case designed to test the implementation of References from a Spring application + * context, where the references are implicit, through the presence of Bean properties with a + * ref attribute which is not satisfied by a Bean within the application context. + * + * The artifacts involved in this test are: + * + * 1) A composite containing a component with a Spring implementation which makes + * a reference to a second component + * 2) The composite has a component with a Java POJO implementation which satisfies the reference + * 3) The element references an application context that + * does not use an explicit sca:reference element to identify the reference made by the + * Spring application, but relies on an unsatisfied Bean property with a ref attribute. + * + * @version $Rev$ $Date$ + */ +public class SpringImplicitReferenceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringImplicitReferenceTestCase() { + super("SpringImplicitReference.composite", "sca/references"); + } +} + + diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java new file mode 100644 index 0000000000..03af1e6b12 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java @@ -0,0 +1,40 @@ +/* + * 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 sca.services; + +import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase; + +/** + * A basic test case of: + * 1) A composite containing a component with a Spring implementation + * 2) The composite has a component with a Java POJO implementation which uses the + * Spring implementation to satisfy a reference + * 3) The element references an application context that + * uses an explicit sca: element to identify the service offered by the Spring application + * + * @version $Rev$ $Date$ + */ +public class SpringExplicitServiceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringExplicitServiceTestCase() { + super("SpringExplicitService.composite", "sca/services"); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java new file mode 100644 index 0000000000..6f17be1970 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/sca/services/SpringImplicitServiceTestCase.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 sca.services; + +import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase; + +/** + * A basic test case of: + * 1) A composite containing a component with a Spring implementation + * 2) The composite has a component with a Java POJO implementation which uses the + * Spring implementation to satisfy a reference + * + * @version $Rev$ $Date$ + */ +public class SpringImplicitServiceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + public SpringImplicitServiceTestCase() { + super("SpringImplicitService.composite", "sca/services"); + } +} diff --git a/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/spring/annotations/CalculatorClient.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/spring/annotations/CalculatorClient.java new file mode 100644 index 0000000000..34e10de85b --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/spring/annotations/CalculatorClient.java @@ -0,0 +1,64 @@ +/* + * 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 spring.annotations; + +import java.io.File; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +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 { + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANode(new File("src/main/resources/spring/annotations/Calculator.composite").toURL().toString(), + new SCAContribution("TestContribution", new File("src/main/resources/spring/annotations/").toURL().toString())); + node.start(); + + CalculatorService calculatorService = + ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + + 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 = + ((SCAClient)node).getService(CalculatorService.class, "AnotherCalculatorServiceComponent"); + + 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/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java new file mode 100644 index 0000000000..3a9ec4bbb2 --- /dev/null +++ b/sca-java-1.x/tags/1.6-RC2a/itest/spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 spring.annotations; + +import junit.framework.TestCase; + +/** + * Tests out the big bank service + * + */ +public class SpringAnnotationsTestCase extends TestCase { + + public void testServer() throws Exception { + CalculatorClient.main(new String[] {""}); + } +} -- cgit v1.2.3