summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample')
-rw-r--r--sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/C.java32
-rw-r--r--sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/CImpl.java80
-rw-r--r--sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/NestedTestCase.java96
-rw-r--r--sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/RecursiveCompositeTestCaseFIXME.java53
-rw-r--r--sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/X.java32
-rw-r--r--sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/XImpl.java37
-rw-r--r--sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/Y.java32
-rw-r--r--sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/YImpl.java38
8 files changed, 400 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/C.java b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/C.java
new file mode 100644
index 0000000000..bf8391348b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/C.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 sample;
+
+/**
+ * Simple Service
+ */
+public interface C {
+
+ /**
+ * Sample operation
+ *
+ * @return A String
+ */
+ String cOp();
+}
diff --git a/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/CImpl.java b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/CImpl.java
new file mode 100644
index 0000000000..466284983e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/CImpl.java
@@ -0,0 +1,80 @@
+/*
+ * 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 sample;
+
+import junit.framework.Assert;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a simple service
+ */
+@Service(C.class)
+public class CImpl implements C {
+
+ /**
+ * Reference to X
+ */
+ private X xRef;
+
+ /**
+ * Reference to Y
+ */
+ private Y yRef;
+
+ /**
+ * Setter for refX
+ *
+ * @param x Reference to X
+ */
+ @Reference(name="refX")
+ protected void setX(X x)
+ {
+ System.out.println("Setting X on CImpl to " + x);
+ xRef = x;
+ }
+
+ /**
+ * Setter for refY
+ *
+ * @param y Reference to Y
+ */
+ @Reference(name="refY")
+ protected void setY(Y y)
+ {
+ System.out.println("Setting Y on CImpl to " + y);
+ yRef = y;
+ }
+
+ /**
+ * Simple operation that uses the injected references to X and Y
+ *
+ * @return "C:cOp() - xResult = " + xRef.xOP() + " yResult = " + yRef.yOp();
+ */
+ public String cOp() {
+ Assert.assertNotNull(xRef);
+ Assert.assertNotNull(yRef);
+
+ String xResult = xRef.xOp();
+ String yResult = yRef.yOp();
+
+ return "C:cOp() - xResult = " + xResult + " yResult = " + yResult;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/NestedTestCase.java b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/NestedTestCase.java
new file mode 100644
index 0000000000..fc5d251460
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/NestedTestCase.java
@@ -0,0 +1,96 @@
+/*
+ * 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 sample;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+
+/**
+ * Test for implementation.composite using implementation.composite
+ */
+public class NestedTestCase extends TestCase {
+
+ /**
+ * Reference to the domain
+ */
+ private SCADomain domain;
+
+ /**
+ * Tear down the domain
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ if (domain != null) {
+ domain.close();
+ }
+ }
+
+ /**
+ * This tests having:
+ *
+ * AComponent -> implementation.composite(BComposite)
+ * BComposite -> implementation.composite(CComposite)
+ *
+ * This test fails.
+ *
+ * @throws Exception Failed
+ */
+ public void testAComponent() throws Exception {
+ domain = SCADomain.newInstance("AComposite.composite");
+
+ System.out.println("Deployed names = " + domain.getComponentManager().getComponentNames());
+
+ C c = domain.getService(C.class, "AComponent");
+
+ String result = c.cOp();
+ System.out.println("Method call returned [" + result + "]");
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result.indexOf("C:cOp()") != -1);
+ Assert.assertTrue(result.indexOf("X:xOp()") != -1);
+ Assert.assertTrue(result.indexOf("Y:yOp()") != -1);
+ }
+
+
+ /**
+ * This tests having:
+ *
+ * BComposite -> implementation.composite(CComposite)
+ *
+ * This test works.
+ *
+ * @throws Exception Failed
+ */
+ public void testBComponent() throws Exception {
+ domain = SCADomain.newInstance("BComposite.composite");
+
+ System.out.println("Deployed names = " + domain.getComponentManager().getComponentNames());
+
+ C c = domain.getService(C.class, "BComponent");
+
+ String result = c.cOp();
+ System.out.println("Method call returned [" + result + "]");
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result.indexOf("C:cOp()") != -1);
+ Assert.assertTrue(result.indexOf("X:xOp()") != -1);
+ Assert.assertTrue(result.indexOf("Y:yOp()") != -1);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/RecursiveCompositeTestCaseFIXME.java b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/RecursiveCompositeTestCaseFIXME.java
new file mode 100644
index 0000000000..a543add69b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/RecursiveCompositeTestCaseFIXME.java
@@ -0,0 +1,53 @@
+/*
+ * 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 sample;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+//FIXME Fix this test case
+public class RecursiveCompositeTestCaseFIXME extends TestCase {
+
+ private SCADomain domain;
+ private Service1 tracker, tracker2;
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("http://localhost", "/", "Composite1.composite", "Composite2.composite");
+ tracker = domain.getService(Service1.class, "ComponentC");
+ tracker2 = domain.getService(Service1.class, "ComponentB");
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+ public void test() throws Exception {
+ try {
+ System.out.println("Main thread " + Thread.currentThread());
+ System.out.println(tracker.track("Client"));
+ System.out.println(tracker2.track("Client"));
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/X.java b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/X.java
new file mode 100644
index 0000000000..e3a9335068
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/X.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 sample;
+
+/**
+ * Simple Service
+ */
+public interface X {
+
+ /**
+ * Simple Operation
+ *
+ * @return A String
+ */
+ String xOp();
+}
diff --git a/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/XImpl.java b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/XImpl.java
new file mode 100644
index 0000000000..e430807568
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/XImpl.java
@@ -0,0 +1,37 @@
+/*
+ * 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 sample;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a simple service
+ */
+@Service(X.class)
+public class XImpl implements X {
+
+ /**
+ * Simple operation
+ *
+ * @return "X:xOp()"
+ */
+ public String xOp() {
+ return "X:xOp()";
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/Y.java b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/Y.java
new file mode 100644
index 0000000000..c15a4f635a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/Y.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 sample;
+
+/**
+ * Simple Service
+ */
+public interface Y {
+
+ /**
+ * Simple Operation
+ *
+ * @return A String
+ */
+ String yOp();
+}
diff --git a/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/YImpl.java b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/YImpl.java
new file mode 100644
index 0000000000..994c9eb95f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.2.1/itest/recursive/src/test/java/sample/YImpl.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 sample;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a Simple Service
+ */
+@Service(Y.class)
+public class YImpl implements Y {
+
+ /**
+ * A simple operation
+ *
+ * @return "Y:yOp()"
+ */
+ public String yOp() {
+ return "Y:yOp()";
+ }
+
+}