summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca')
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java43
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java70
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java31
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java41
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java35
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java36
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java38
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java42
8 files changed, 336 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/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<HelloWorld> {
+
+ /**
+ * 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<HelloWorld> getServiceClass() {
+ return HelloWorld.class;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/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<T> 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<T> 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/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java b/sca-java-1.x/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java b/sca-java-1.x/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java b/sca-java-1.x/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java b/sca-java-1.x/branches/sca-java-1.6.2/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/branches/sca-java-1.6.2/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);
+ }
+
+}