summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:13:31 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:13:31 +0000
commit3caf8614f25d6b1962e20331fdf423c863bc02f3 (patch)
tree069fa30b63dd4804846385d8571928bdaa7b73ad /sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache
parent6d0e93c68d3aeaeb4bb6d96ac0460eec40ef786e (diff)
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835144 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache')
-rw-r--r--sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTestCase.java53
-rw-r--r--sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTestCase.java88
-rw-r--r--sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTestCase.java110
-rw-r--r--sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTestCase.java191
-rw-r--r--sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTestCase.java84
-rw-r--r--sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTestCase.java83
-rw-r--r--sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTestCase.java95
-rw-r--r--sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTestCase.java96
8 files changed, 800 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTestCase.java b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTestCase.java
new file mode 100644
index 0000000000..fe2780ed9d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTestCase.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 org.apache.tuscany.sca.test.spec;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class ComponentServiceReferenceListTestCase extends TestCase {
+ private MyListService myListService;
+ private MyListServiceByYear myListServiceByYear;
+
+ private CompositeContext context;
+
+ public void testDefaultProperty() {
+ assertEquals("2007", myListService.getYear());
+
+ }
+
+ public void testDefaultService() {
+ assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidaysByYear(2007)[0]);
+
+ }
+
+ protected void setUp() throws Exception {
+ SCARuntime.start("CompositeTest.composite");
+ context = CurrentCompositeContext.getContext();
+ myListService = context.locateService(MyListService.class, "MyNewListService");
+ myListServiceByYear = context.locateService(MyListServiceByYear.class, "MyNewListService");
+ }
+
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTestCase.java b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTestCase.java
new file mode 100644
index 0000000000..087f77c950
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTestCase.java
@@ -0,0 +1,88 @@
+/*
+ * 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.test.spec;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.RequestContext;
+
+public class ComponentServiceReferenceTestCase extends TestCase {
+ private MyTotalService myService;
+ private CompositeContext context;
+
+ public void testDefaultProperty() {
+ assertEquals("NC", myService.getLocation());
+ assertEquals("2007", myService.getYear());
+
+ }
+
+ public void testDefaultService() {
+ assertNotSame(myService.nextHoliday(), myService.nextHolidayByDate(new Date()));
+ assertEquals(myService.getHolidays()[0], myService.getHolidaysByYear(2007)[0]);
+
+ }
+
+ public void testContext() {
+ //FIXME TUSCANY-1174 - Need support for @ComponentName
+ /*
+ assertNotNull("Service component name is null", myService.getComponentName());
+ assertNotNull("service context is null", myService.getContext());
+
+ System.out.println("Service component name :" + myService.getComponentName());
+ System.out.println("service context :" + myService.getContext());
+
+ test(context);
+ */
+ }
+
+ private void test(CompositeContext context) {
+ assertNotNull("composite name is null", context.getName());
+ assertNotNull("composite URI is null", context.getURI());
+
+ System.out.println("composite name :" + context.getName());
+ System.out.println("composite URI:" + context.getURI());
+
+ if (context.getRequestContext() == null)
+ System.out.println("Request context:" + context.getRequestContext());
+ else
+ display(context.getRequestContext());
+ }
+
+ private void display(RequestContext context) {
+ System.out.println("\tService name:" + context.getServiceName());
+ System.out.println("\tSecurity subject:" + context.getSecuritySubject());
+ //System.out.println("\tService reference:" + context.getServiceReference());
+
+ }
+
+ protected void setUp() throws Exception {
+ SCARuntime.start("CompositeTest.composite");
+ context = CurrentCompositeContext.getContext();
+ myService = context.locateService(MyTotalService.class, "MyTotalService");
+ }
+
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTestCase.java b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTestCase.java
new file mode 100644
index 0000000000..ca3ed8051d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTestCase.java
@@ -0,0 +1,110 @@
+/*
+ * 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.test.spec;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.RequestContext;
+
+public class ComponentTestCase extends TestCase {
+ private MyService myService;
+ private MyServiceByDate myServiceByDate;
+ private MyListService myListService;
+ private MyListServiceByYear myListServiceByYear;
+ private MyService myNCService;
+ private MyListService myListServiceFor2006;
+
+ private CompositeContext context;
+
+ public void testDefaultProperty() {
+ assertEquals("RTP", myService.getLocation());
+ assertEquals("2006", myService.getYear());
+
+ }
+
+ public void testDefaultService() {
+ assertEquals(myService.nextHoliday(), myServiceByDate.nextHolidayByDate(new Date()));
+ assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidaysByYear(2006)[0]);
+
+ }
+
+ public void testOverrideProperty() {
+ assertEquals("NC", myNCService.getLocation());
+ assertEquals("2007", myNCService.getYear());
+ }
+
+ public void testServiceWithOverrideProperty() {
+ assertFalse(myNCService.nextHoliday() == myService.nextHoliday());
+ assertEquals(myListServiceFor2006.getHolidays()[0], myListServiceByYear.getHolidaysByYear(2006)[0]);
+
+ }
+
+ public void testContext() {
+ //FIXME TUSCANY-1174 - Need support for @ComponentName
+ /*
+ assertNotNull("Service component name is null", myService.getComponentName());
+ assertNotNull("service context is null", myService.getContext());
+
+ System.out.println("Service component name :" + myService.getComponentName());
+ System.out.println("service context :" + myService.getContext());
+
+ test(context);
+ */
+ }
+
+ private void test(CompositeContext context) {
+ assertNotNull("composite name is null", context.getName());
+ assertNotNull("composite URI is null", context.getURI());
+
+ System.out.println("composite name :" + context.getName());
+ System.out.println("composite URI:" + context.getURI());
+
+ if (context.getRequestContext() == null)
+ System.out.println("Request context:" + context.getRequestContext());
+ else
+ display(context.getRequestContext());
+ }
+
+ private void display(RequestContext context) {
+ System.out.println("\tService name:" + context.getServiceName());
+ System.out.println("\tSecurity subject:" + context.getSecuritySubject());
+ //System.out.println("\tService reference:" + (Object)context.getServiceReference());
+
+ }
+
+ protected void setUp() throws Exception {
+ SCARuntime.start("CompositeTest.composite");
+ context = CurrentCompositeContext.getContext();
+ myService = context.locateService(MyService.class, "MyService");
+ myServiceByDate = context.locateService(MyServiceByDate.class, "MyServiceByDate");
+ myListService = context.locateService(MyListService.class, "MyListService");
+ myListServiceByYear = context.locateService(MyListServiceByYear.class, "MyListServiceByYear");
+ myNCService = context.locateService(MyService.class, "MyNCService");
+ myListServiceFor2006 = context.locateService(MyListService.class, "MyListServiceFor2006");
+ }
+
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTestCase.java b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTestCase.java
new file mode 100644
index 0000000000..ad89590600
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTestCase.java
@@ -0,0 +1,191 @@
+/*
+ * 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.test.spec;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.RequestContext;
+
+@SuppressWarnings("deprecation")
+public class CompositeOneService2LevelTestCase extends TestCase {
+ private static MyService myService;
+ private static MyService myServiceDefault;
+ private static MyService myServiceNo;
+ private static MyService myServiceMay;
+ private static MyService myServiceMust;
+
+ static private CompositeContext context;
+
+ public static Test suite() {
+
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(CompositeOneService2LevelTestCase.class);
+ TestSetup wrapper = new TestSetup(suite) {
+ public void setUp() {
+ setupStatic();
+ }
+
+ public void tearDown() {
+ tearDownStatic();
+ }
+
+ };
+ return wrapper;
+ }
+
+ public static void setupStatic() {
+ if (null != context)
+ return;
+ SCARuntime.start("CompositeTest.composite");
+ context = CurrentCompositeContext.getContext();
+ assertNotNull(context);
+ myService = context.locateService(MyService.class, "MySimpleServiceInRecursiveComponent/MySimpleService");
+ myServiceDefault = context.locateService(MyService.class, "MySimpleServiceDefault");
+ myServiceNo = context.locateService(MyService.class, "MySimpleServiceNo");
+ myServiceMay = context.locateService(MyService.class, "MySimpleServiceMay");
+ myServiceMust = context.locateService(MyService.class, "MySimpleServiceMust");
+
+ }
+
+ public static void tearDownStatic() {
+ if (context != null) {
+
+ context = null;
+ SCARuntime.stop();
+ }
+ }
+
+ public void setUp() {
+ setupStatic();
+ }
+
+ static Object foo = new Object() {
+ public void finalize() throws Throwable {
+ foo = null;
+ tearDownStatic();
+ }
+
+ };
+
+ public void testPropertyFromComponent() {
+
+ assertNotNull(myService);
+ assertEquals("CARY", myService.getLocation());
+ assertEquals("2007", myService.getYear());
+
+ }
+
+ public void testPropertyFromServiceDefault() {
+
+ assertNotNull(myServiceDefault);
+ assertEquals("CARY", myServiceDefault.getLocation());
+ assertEquals("2007", myServiceDefault.getYear());
+
+ }
+
+ public void testServiceDefault() {
+
+ assertNotNull(myService);
+ assertEquals(myService.nextHoliday(), myServiceDefault.nextHoliday());
+ }
+
+ public void testPropertyFromServiceNo() {
+
+ assertNotNull(myServiceNo);
+ assertEquals("CARY", myServiceNo.getLocation());
+ assertEquals("2007", myServiceNo.getYear());
+
+ }
+
+ public void testServiceNo() {
+
+ assertNotNull(myService);
+ assertEquals(myService.nextHoliday(), myServiceNo.nextHoliday());
+ }
+
+ public void testPropertyFromServiceMay() {
+
+ assertNotNull(myServiceMay);
+ assertEquals("CARY", myServiceMay.getLocation());
+ assertEquals("2007", myServiceMay.getYear());
+
+ }
+
+ public void testServiceMay() {
+
+ assertNotNull(myService);
+ assertEquals(myService.nextHoliday(), myServiceMay.nextHoliday());
+ }
+
+ public void testPropertyFromServiceMust() {
+
+ assertNotNull(myServiceMust);
+ assertEquals("CARY", myServiceMust.getLocation());
+ assertEquals("2007", myServiceMust.getYear());
+
+ }
+
+ public void testServiceMust() {
+
+ assertNotNull(myService);
+ assertEquals(myService.nextHoliday(), myServiceMust.nextHoliday());
+ }
+
+ public void testContext() {
+ // FIXME TUSCANY-1174 - Need support for @ComponentName
+ /*
+ * assertNotNull("Service component name is null",
+ * myService.getComponentName()); assertNotNull("service context is
+ * null", myService.getContext()); System.out.println("Service component
+ * name :" + myService.getComponentName()); System.out.println("service
+ * context :" + myService.getContext()); test(context);
+ */
+ }
+
+ private void test(CompositeContext context) {
+
+ assertNotNull("composite name is null", context.getName());
+ assertNotNull("composite URI is null", context.getURI());
+
+ System.out.println("composite name :" + context.getName());
+ System.out.println("composite URI:" + context.getURI());
+
+ if (context.getRequestContext() == null)
+ System.out.println("Request context:" + context.getRequestContext());
+ else
+ display(context.getRequestContext());
+ }
+
+ private void display(RequestContext context) {
+ System.out.println("\tService name:" + context.getServiceName());
+ System.out.println("\tSecurity subject:" + context.getSecuritySubject());
+ // System.out.println("\tService reference:" +
+ // (Object)context.getServiceReference());
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTestCase.java b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTestCase.java
new file mode 100644
index 0000000000..1b41672700
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTestCase.java
@@ -0,0 +1,84 @@
+/*
+ * 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.test.spec;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.RequestContext;
+
+public class CompositeOneServiceTestCase extends TestCase {
+ private MyService myService;
+ private CompositeContext context;
+
+ public void testOverrideProperty() {
+ assertEquals("CARY", myService.getLocation());
+ assertEquals("2007", myService.getYear());
+
+ }
+
+ public void testDefaultService() {
+ assertNotNull(myService.nextHoliday());
+ }
+
+ public void testContext() {
+ //FIXME TUSCANY-1174 - Need support for @ComponentName
+ /*
+ assertNotNull("Service component name is null", myService.getComponentName());
+ assertNotNull("service context is null", myService.getContext());
+
+ System.out.println("Service component name :" + myService.getComponentName());
+ System.out.println("service context :" + myService.getContext());
+
+ test(context);
+ */
+ }
+
+ private void test(CompositeContext context) {
+ assertNotNull("composite name is null", context.getName());
+ assertNotNull("composite URI is null", context.getURI());
+
+ System.out.println("composite name :" + context.getName());
+ System.out.println("composite URI:" + context.getURI());
+
+ if (context.getRequestContext() == null)
+ System.out.println("Request context:" + context.getRequestContext());
+ else
+ display(context.getRequestContext());
+ }
+
+ private void display(RequestContext context) {
+ System.out.println("\tService name:" + context.getServiceName());
+ System.out.println("\tSecurity subject:" + context.getSecuritySubject());
+ //System.out.println("\tService reference:" + context.getServiceReference());
+
+ }
+
+ protected void setUp() throws Exception {
+ SCARuntime.start("CompositeTest.composite");
+ context = CurrentCompositeContext.getContext();
+ myService = context.locateService(MyService.class, "MySimpleServiceInRecursive");
+ }
+
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTestCase.java b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTestCase.java
new file mode 100644
index 0000000000..7023d7981c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * 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.test.spec;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class CompositeServiceReferenceForRefOverrideTestCase extends TestCase {
+ private MyTotalService myService1;
+ private MyTotalService myService2;
+ private MyTotalService myService3;
+ private CompositeContext context;
+
+ public void testPropertyWithServiceFromReferenceNo() {
+ assertEquals("CARY", myService1.getLocation());
+ assertEquals("2007", myService1.getYear());
+ }
+
+ public void testPropertyWithServiceFromReferenceMay() {
+ assertEquals("CARY", myService2.getLocation());
+ assertEquals("2007", myService2.getYear());
+
+ }
+
+ public void testPropertyWithServiceFromReferenceMust() {
+ assertEquals("CARY", myService3.getLocation());
+ assertEquals("2007", myService3.getYear());
+ }
+
+ public void testServiceFromReferenceNo() {
+ System.out.println("nextHolday()" + myService1.nextHoliday());
+ System.out.println("nextHolday(Date)" + myService1.nextHolidayByDate(new Date()));
+ System.out.println("myService1.getHolidays()[0]" + myService1.getHolidays()[0]);
+ System.out.println("myService1.getHolidays(2007)[0]" + myService1.getHolidaysByYear(2007)[0]);
+ assertNotSame(myService1.nextHoliday(), myService1.nextHolidayByDate(new Date()));
+ assertEquals(myService1.getHolidays()[0], myService1.getHolidaysByYear(2007)[0]);
+ }
+
+ public void testServiceFromReferenceMay() {
+ assertEquals(myService2.getHolidays()[0], myService2.getHolidaysByYear(2007)[0]);
+ assertNotSame(myService2.nextHoliday(), myService2.nextHolidayByDate(new Date()));
+
+ }
+
+ public void testServiceFromReferenceMust() {
+ assertEquals(myService3.getHolidays()[0], myService3.getHolidaysByYear(2007)[0]);
+ assertNotSame(myService3.nextHoliday(), myService3.nextHolidayByDate(new Date()));
+
+ }
+
+ protected void setUp() throws Exception {
+ SCARuntime.start("CompositeTest.composite");
+ context = CurrentCompositeContext.getContext();
+ myService1 = context.locateService(MyTotalService.class, "MyTotalServiceNo");
+ myService2 = context.locateService(MyTotalService.class, "MyTotalServiceMay");
+ myService3 = context.locateService(MyTotalService.class, "MyTotalServiceMust");
+ }
+
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTestCase.java b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTestCase.java
new file mode 100644
index 0000000000..6128d108ba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * 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.test.spec;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class CompositeServiceReferenceTestCase extends TestCase {
+ private MyTotalService myService1;
+ private MyTotalService myService2;
+ private MyTotalService myService3;
+ private MyTotalService myService4;
+ private MyTotalService myService5;
+ private CompositeContext context;
+
+ public void testPropertyWithServiceFromRecursive() {
+ assertEquals("CARY", myService1.getLocation());
+ assertEquals("2007", myService1.getYear());
+ }
+
+ public void testPropertyWithServiceInCompositeFromRecursive() {
+ assertEquals("CARY", myService2.getLocation());
+ assertEquals("2007", myService2.getYear());
+
+ }
+
+ public void testPropertyWithServiceInCompositeFromComponent() {
+ assertEquals("CARY", myService3.getLocation());
+ assertEquals("2007", myService3.getYear());
+ }
+
+ public void testServiceFromRecursive() {
+ assertNotSame(myService1.nextHoliday(), myService1.nextHolidayByDate(new Date()));
+ assertEquals(myService1.getHolidays()[0], myService1.getHolidaysByYear(2007)[0]);
+
+ }
+
+ public void testServiceReferenceFromRecursive() {
+ assertEquals(myService2.getHolidays()[0], myService2.getHolidaysByYear(2007)[0]);
+ assertNotSame(myService2.nextHoliday(), myService2.nextHolidayByDate(new Date()));
+
+ }
+
+ public void testServiceReferenceFromRecursiveUseService() {
+ assertNotSame(myService4.nextHoliday(), myService4.nextHolidayByDate(new Date()));
+ assertEquals(myService4.getHolidays()[0], myService4.getHolidaysByYear(2007)[0]);
+ }
+
+ public void testServiceReferenceFromComponent() {
+ assertEquals(myService3.getHolidays()[0], myService3.getHolidaysByYear(2007)[0]);
+ assertNotSame(myService3.nextHoliday(), myService3.nextHolidayByDate(new Date()));
+
+ }
+
+ public void testServiceReferenceFromComponentUseService() {
+ assertNotSame(myService5.nextHoliday(), myService5.nextHolidayByDate(new Date()));
+ assertEquals(myService5.getHolidays()[0], myService5.getHolidaysByYear(2007)[0]);
+ }
+
+ protected void setUp() throws Exception {
+ SCARuntime.start("CompositeTest.composite");
+ context = CurrentCompositeContext.getContext();
+ myService1 = context.locateService(MyTotalService.class, "MyTotalServiceFromRecursive");
+ myService2 = context.locateService(MyTotalService.class, "MyTotalServiceInCompositeWithRecursive");
+ myService3 = context.locateService(MyTotalService.class, "MyTotalServiceInCompositeWithComponentService");
+ myService4 = context.locateService(MyTotalService.class, "MyTotalServiceInCompositeWithRecursiveUseService");
+ myService5 =
+ context.locateService(MyTotalService.class, "MyTotalServiceInCompositeWithComponentServiceUseService");
+ }
+
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTestCase.java b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTestCase.java
new file mode 100644
index 0000000000..7c50a90e60
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/spec/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTestCase.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 org.apache.tuscany.sca.test.spec;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.RequestContext;
+
+public class CompositeTestCase extends TestCase {
+ private MyService myService;
+ private MyServiceByDate myServiceByDate;
+ private MyListService myListService;
+ private MyListServiceByYear myListServiceByYear;
+
+ private CompositeContext context;
+
+ public void testOverrideProperty() {
+ assertEquals("CARY", myService.getLocation());
+ assertEquals("2007", myService.getYear());
+
+ }
+
+ public void testDefaultService() {
+ assertEquals(myService.nextHoliday(), myServiceByDate.nextHolidayByDate(new Date()));
+ assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidaysByYear(2007)[0]);
+
+ }
+
+ public void testContext() {
+ //FIXME TUSCANY-1174 - Need support for @ComponentName
+ /*
+ assertNotNull("Service component name is null", myService.getComponentName());
+ assertNotNull("service context is null", myService.getContext());
+
+ System.out.println("Service component name :" + myService.getComponentName());
+ System.out.println("service context :" + myService.getContext());
+
+ test(context);
+ */
+ }
+
+ private void test(CompositeContext context) {
+ assertNotNull("composite name is null", context.getName());
+ assertNotNull("composite URI is null", context.getURI());
+
+ System.out.println("composite name :" + context.getName());
+ System.out.println("composite URI:" + context.getURI());
+
+ if (context.getRequestContext() == null)
+ System.out.println("Request context:" + context.getRequestContext());
+ else
+ display(context.getRequestContext());
+ }
+
+ private void display(RequestContext context) {
+ System.out.println("\tService name:" + context.getServiceName());
+ System.out.println("\tSecurity subject:" + context.getSecuritySubject());
+ //System.out.println("\tService reference:" + (Object)context.getServiceReference());
+
+ }
+
+ protected void setUp() throws Exception {
+ SCARuntime.start("CompositeTest.composite");
+ context = CurrentCompositeContext.getContext();
+ myService = context.locateService(MyService.class, "MyServiceInRecursiveMyService");
+ myServiceByDate = context.locateService(MyServiceByDate.class, "MyServiceInRecursiveMyServiceByDate");
+ myListService = context.locateService(MyListService.class, "MyServiceInRecursiveMyListService");
+ myListServiceByYear =
+ context.locateService(MyListServiceByYear.class, "MyServiceInRecursiveMyListServiceByYear");
+ }
+
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+}