From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/test/spec/ComponentContextTester.java | 45 ++++++++ .../sca/test/spec/ComponentContextTesterImpl.java | 56 ++++++++++ .../sca/test/spec/IdentifiableComponent.java | 34 ++++++ .../tuscany/sca/test/spec/IdentityService.java | 26 +++++ .../tuscany/sca/test/spec/MyListService.java | 28 +++++ .../tuscany/sca/test/spec/MyListServiceByYear.java | 26 +++++ .../apache/tuscany/sca/test/spec/MyService.java | 29 +++++ .../tuscany/sca/test/spec/MyServiceByDate.java | 28 +++++ .../tuscany/sca/test/spec/MyTotalService.java | 23 ++++ .../tuscany/sca/test/spec/SCAComponentService.java | 28 +++++ .../sca/test/spec/impl/MyListServiceImpl.java | 73 ++++++++++++ .../tuscany/sca/test/spec/impl/MyServiceImpl.java | 122 +++++++++++++++++++++ .../sca/test/spec/impl/MyTotalServiceImpl.java | 83 ++++++++++++++ .../src/main/resources/META-INF/sca/default.scdl | 43 ++++++++ .../main/resources/META-INF/sca/myListService.scdl | 34 ++++++ .../META-INF/sca/myServiceInComposite.scdl | 49 +++++++++ .../META-INF/sca/myServiceInRecursive.scdl | 53 +++++++++ .../resources/META-INF/sca/mySimpleService.scdl | 34 ++++++ .../META-INF/sca/mySimpleServiceInRecursive.scdl | 44 ++++++++ .../META-INF/sca/mySimpleServiceInRecursive2.scdl | 47 ++++++++ .../resources/META-INF/sca/myTotalService.scdl | 32 ++++++ .../META-INF/sca/myTotalServiceInComposite.scdl | 43 ++++++++ ...otalServiceInCompositeForReferenceOverride.scdl | 81 ++++++++++++++ .../META-INF/sca/myTotalServiceInRecursive.scdl | 60 ++++++++++ ...otalServiceInRecursiveForReferenceOverride.scdl | 52 +++++++++ .../src/main/resources/META-INF/sca/myservice.scdl | 51 +++++++++ .../test/spec/ComponentContextTestComponent.java | 48 ++++++++ .../spec/ComponentServiceReferenceListTest.java | 39 +++++++ .../test/spec/ComponentServiceReferenceTest.java | 60 ++++++++++ .../tuscany/sca/test/spec/ComponentTest.java | 71 ++++++++++++ .../test/spec/CompositeOneService2LevelTest.java | 89 +++++++++++++++ .../sca/test/spec/CompositeOneServiceTest.java | 45 ++++++++ ...ompositeServiceReferenceForRefOverrideTest.java | 70 ++++++++++++ .../test/spec/CompositeServiceReferenceTest.java | 81 ++++++++++++++ .../tuscany/sca/test/spec/CompositeTest.java | 55 ++++++++++ .../itest/specTest/src/test/resources/itest.scdl | 30 +++++ 36 files changed, 1812 insertions(+) create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/default.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myListService.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInComposite.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInRecursive.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleService.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive2.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalService.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInComposite.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInCompositeForReferenceOverride.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursive.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursiveForReferenceOverride.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myservice.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/resources/itest.scdl (limited to 'sandbox/old/contrib/itest/specTest/src') diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java new file mode 100644 index 0000000000..6e1b8dc612 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.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 org.apache.tuscany.sca.test.spec; + +/** + * @version $Rev$ $Date$ + */ +public interface ComponentContextTester extends IdentityService { + /** + * Returns true if the ComponentContext was injected + * @return true if the ComponentContext was injected + */ + boolean isContextInjected(); + + /** + * Looks up a reference with the supplied name and returns the identity of the referenced component. + * @param name the name of a reference + * @return the identity of the referenced component + */ + String getServiceIdentity(String name); + + /** + * Looks up a reference with the supplied name using a ServiceReference + * and returns the identity of the referenced component. + * @param name the name of a reference + * @return the identity of the referenced component + */ + String getServiceReferenceIdentity(String name); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java new file mode 100644 index 0000000000..df6366dbef --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java @@ -0,0 +1,56 @@ +/* + * 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 org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; + +/** + * Component that tests ComponentContext functions. + * + * @version $Rev$ $Date$ + */ +public class ComponentContextTesterImpl implements ComponentContextTester { + @Context + public ComponentContext context; + + @Reference + public IdentityService getServiceTest; + + public boolean isContextInjected() { + return context != null; + } + + public String getURI() { + return context.getURI(); + } + + public String getServiceIdentity(String name) { + IdentityService service = context.getService(IdentityService.class, name); + return service.getURI(); + } + + public String getServiceReferenceIdentity(String name) { + ServiceReference ref = context.getServiceReference(IdentityService.class, name); + IdentityService service = ref.getService(); + return service.getURI(); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java new file mode 100644 index 0000000000..cab690eafd --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java @@ -0,0 +1,34 @@ +/* + * 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 org.osoa.sca.annotations.Context; +import org.osoa.sca.ComponentContext; + +/** + * @version $Rev$ $Date$ + */ +public class IdentifiableComponent implements IdentityService { + @Context + public ComponentContext context; + + public String getURI() { + return context.getURI(); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java new file mode 100644 index 0000000000..25435a3cc4 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java @@ -0,0 +1,26 @@ +/* + * 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; + +/** + * @version $Rev$ $Date$ + */ +public interface IdentityService { + String getURI(); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java new file mode 100644 index 0000000000..7fe9fa4909 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java @@ -0,0 +1,28 @@ +/* + * 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 org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyListService { + String[] getHolidays(); + + String getYear(); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java new file mode 100644 index 0000000000..28a26dddde --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java @@ -0,0 +1,26 @@ +/* + * 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 org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyListServiceByYear { + String[] getHolidays(int year); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java new file mode 100644 index 0000000000..fbb2161df3 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java @@ -0,0 +1,29 @@ +/* + * 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; + +public interface MyService extends SCAComponentService { + Date nextHoliday(); + + String getLocation(); + + String getYear(); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java new file mode 100644 index 0000000000..892b36e1a1 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java @@ -0,0 +1,28 @@ +/* + * 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 org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyServiceByDate { + Date nextHoliday(Date date); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java new file mode 100644 index 0000000000..6a4cfc1f79 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java @@ -0,0 +1,23 @@ +/* + * 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; + +public interface MyTotalService extends MyListService, MyListServiceByYear, MyService, MyServiceByDate { + +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java new file mode 100644 index 0000000000..2ba1cb41cb --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java @@ -0,0 +1,28 @@ +/* + * 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 org.osoa.sca.ComponentContext; + +public interface SCAComponentService { + String getComponentName(); + + ComponentContext getContext(); + +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java new file mode 100644 index 0000000000..6f3f761432 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java @@ -0,0 +1,73 @@ +/* + * 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.impl; + +import java.util.List; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + + +@Service(interfaces = {MyListService.class, MyListServiceByYear.class}) +public class MyListServiceImpl implements MyListService, MyListServiceByYear { + + // This is multiplicity=1:n + @Reference(name = "myListServiceList", required = false) + public List myListServicesList; + + // This is multiplicity=0:n + @Reference(name = "myListServiceArray", required = false) + public MyListService[] myListServicesArray; + + @Property(name = "serviceYear") + protected String year = "2006"; + + public String[] getHolidays() { + return getHolidays(Integer.parseInt(year)); + } + + public String[] getHolidays(int year) { + MyListService myService; + if (myListServicesList != null) { + for (MyListService aMyListServicesList : myListServicesList) { + myService = aMyListServicesList; + if (Integer.parseInt(myService.getYear()) == year) { + return myService.getHolidays(); + } + } + } + if (myListServicesArray != null) { + for (MyListService aMyListServicesArray : myListServicesArray) { + myService = aMyListServicesArray; + if (Integer.parseInt(myService.getYear()) == year) { + return myService.getHolidays(); + } + } + } + return null; + } + + public String getYear() { + return year; + } + +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java new file mode 100644 index 0000000000..3aa2c2a136 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java @@ -0,0 +1,122 @@ +/* + * 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.impl; + +import java.util.Date; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.apache.tuscany.sca.test.spec.MyService; +import org.apache.tuscany.sca.test.spec.MyServiceByDate; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.ComponentName; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Service; + + +@Service(interfaces = {MyService.class, MyServiceByDate.class, MyListService.class, MyListServiceByYear.class}) +public class MyServiceImpl implements MyService, MyServiceByDate, MyListService, MyListServiceByYear { + static String[][] holidays = + { + {"2006/01/02", "2006/05/29", "2006/07/03", "2006/07/04", "2006/09/04", "2006/11/23", "2006/11/23", + "2006/11/24", "2006/12/25"}, + {"2007/01/01", "2007/05/28", "2007/07/04", "2007/09/03", "2007/11/22", "2007/11/23", "2007/12/25"}}; + + @Property(name = "location") + protected String location = "RTP"; + + @Property(name = "year") + protected String year = "2006"; + + @ComponentName + protected String componentName; + + @Context + protected ComponentContext context; + + public MyServiceImpl() { + System.out.println("creating service instance..."); + } + + public Date nextHoliday() { + + return nextHoliday(new Date()); + } + + @SuppressWarnings("deprecation") + public Date nextHoliday(Date today) { + Date d1; + String[] days = getHolidays(); + for (String day : days) { + d1 = new Date(day); + if (d1.after(today)) + return d1; + } + return null; + } + + public String[] getHolidays(int year) { + int index = year - 2006; + if (index >= 0 && index < holidays.length) + return holidays[index]; + return null; + } + + public String[] getHolidays() { + + Integer theYear; + if (year == null || year.length() == 0) + theYear = new Integer("2006"); + else + theYear = new Integer(year); + + return getHolidays(theYear.intValue()); + } + + @Init + public void start() { + System.out.println("Start service.."); + } + + @Destroy + public void stop() { + System.out.println("Stop service.."); + + } + + public String getComponentName() { + return componentName; + } + + public ComponentContext getContext() { + return context; + } + + public String getLocation() { + return location; + } + + public String getYear() { + return year; + } + +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java new file mode 100644 index 0000000000..d56e9aede4 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.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.impl; + +import java.util.Date; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.apache.tuscany.sca.test.spec.MyService; +import org.apache.tuscany.sca.test.spec.MyServiceByDate; +import org.apache.tuscany.sca.test.spec.MyTotalService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + + +@Service(MyTotalService.class) +public class MyTotalServiceImpl implements MyTotalService { + + // This is multiplicity=1:1 + @Reference(required = true) + public MyListService myListService; + + // default required==true so it is 1:1 + @Reference + public MyListServiceByYear myListServiceByYear = new MyServiceImpl(); + + // default required==true so it is 1:1 + @Reference + public MyService myService; + + // This is multiplicity=0:1 + @Reference(required = false) + public MyServiceByDate myServiceByDate = new MyServiceImpl(); + + public String[] getHolidays() { + return myListService.getHolidays(); + } + + public String[] getHolidays(int year) { + return myListServiceByYear.getHolidays(year); + } + + public String getComponentName() { + return myService.getComponentName(); + } + + public ComponentContext getContext() { + return myService.getContext(); + } + + public Date nextHoliday(Date date) { + return myServiceByDate.nextHoliday(date); + } + + public String getLocation() { + return myService.getLocation(); + } + + public String getYear() { + return myService.getYear(); + } + + public Date nextHoliday() { + return myService.nextHoliday(); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/default.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/default.scdl new file mode 100644 index 0000000000..0f09f102b9 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/default.scdl @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myListService.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myListService.scdl new file mode 100644 index 0000000000..55293b00f1 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myListService.scdl @@ -0,0 +1,34 @@ + + + + + + + + 2007 + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInComposite.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInComposite.scdl new file mode 100644 index 0000000000..14b1261604 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInComposite.scdl @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInRecursive.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInRecursive.scdl new file mode 100644 index 0000000000..5d13f75970 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInRecursive.scdl @@ -0,0 +1,53 @@ + + + + + + + MyServiceInRecursive/MyService + + + + + + MyServiceInRecursive/MyListService + + + + + + MyServiceInRecursive/MyListServiceByYear + + + + + + MyServiceInRecursive/MyServiceByDate + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleService.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleService.scdl new file mode 100644 index 0000000000..700ae21b25 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleService.scdl @@ -0,0 +1,34 @@ + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive.scdl new file mode 100644 index 0000000000..1354fc2ba4 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive.scdl @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive2.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive2.scdl new file mode 100644 index 0000000000..79287745b7 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive2.scdl @@ -0,0 +1,47 @@ + + + + + + + MySimpleServiceInRecursiveComponent/MySimpleService + + + + + MySimpleServiceInRecursiveComponent/MySimpleServiceNo + + + + + MySimpleServiceInRecursiveComponent/MySimpleServiceMay + + + + + MySimpleServiceInRecursiveComponent/MySimpleServiceMust + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalService.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalService.scdl new file mode 100644 index 0000000000..8e676fedf8 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalService.scdl @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInComposite.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInComposite.scdl new file mode 100644 index 0000000000..825e3777b6 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInComposite.scdl @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInCompositeForReferenceOverride.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInCompositeForReferenceOverride.scdl new file mode 100644 index 0000000000..29bfa3cd23 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInCompositeForReferenceOverride.scdl @@ -0,0 +1,81 @@ + + + + + + + MyTotalServiceComponentNo + + + + + + + + + + + + + + + + + + + MyTotalServiceComponentMay + + + + + + + + + + + + + + + + + + + MyTotalServiceComponentMust + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursive.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursive.scdl new file mode 100644 index 0000000000..98c19b6116 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursive.scdl @@ -0,0 +1,60 @@ + + + + + + + + + + + + MyServiceInComposite/MyListService + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursiveForReferenceOverride.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursiveForReferenceOverride.scdl new file mode 100644 index 0000000000..51cd181b00 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursiveForReferenceOverride.scdl @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myservice.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myservice.scdl new file mode 100644 index 0000000000..845cbbf9fd --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myservice.scdl @@ -0,0 +1,51 @@ + + + + + + + + + + + NC + 2007 + + + + + + + + + + + + + 2006 + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java new file mode 100644 index 0000000000..c7bce6e65f --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.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 org.apache.tuscany.sca.test.spec; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +/** + * @version $Rev$ $Date$ + */ +public class ComponentContextTestComponent extends TestCase { + @Reference + public ComponentContextTester tester; + + public void testContextWasInjected() { + assertTrue(tester.isContextInjected()); + } + + public void testComponentURI() { + assertEquals("itest://localhost/testDomain/testHarness/ComponentContextTester", tester.getURI()); + } + + public void testGetService() { + assertEquals("itest://localhost/testDomain/testHarness/ReferencedService", + tester.getServiceIdentity("getServiceTest")); + } + + public void testGetServiceReference() { + assertEquals("itest://localhost/testDomain/testHarness/ReferencedService", + tester.getServiceReferenceIdentity("getServiceTest")); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTest.java new file mode 100644 index 0000000000..c06ce947ea --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTest.java @@ -0,0 +1,39 @@ +/* + * 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.osoa.sca.annotations.Reference; + +public class ComponentServiceReferenceListTest extends TestCase { + @Reference + public MyListService myListService; + @Reference + public MyListServiceByYear myListServiceByYear; + + public void testDefaultProperty() { + assertEquals("2007", myListService.getYear()); + + } + + public void testDefaultService() { + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidays(2007)[0]); + + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTest.java new file mode 100644 index 0000000000..30a4959d8f --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTest.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 org.apache.tuscany.sca.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; + +public class ComponentServiceReferenceTest extends TestCase { + @Reference + public MyTotalService myService; + + @Context + public ComponentContext context; + + public void testDefaultProperty() { + assertEquals("NC", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testDefaultService() { + assertNotSame(myService.nextHoliday(), myService.nextHoliday(new Date())); + assertEquals(myService.getHolidays()[0], myService.getHolidays(2007)[0]); + + } + + public void testMyServiceContext() { + 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()); + + } + + public void testContext() { + assertNotNull("service context is null", context); + + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTest.java new file mode 100644 index 0000000000..d039a066a7 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTest.java @@ -0,0 +1,71 @@ +/* + * 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 org.osoa.sca.annotations.Reference; + +import junit.framework.TestCase; + +public class ComponentTest extends TestCase { + @Reference + public MyService myService; + @Reference + public MyServiceByDate myServiceByDate; + @Reference + public MyListService myListService; + @Reference + public MyListServiceByYear myListServiceByYear; + @Reference + public MyService myNCService; + @Reference + public MyListService myListServiceFor2006; + + public void testDefaultProperty() { + assertEquals("RTP", myService.getLocation()); + assertEquals("2006", myService.getYear()); + + } + + public void testDefaultService() { + assertEquals(myService.nextHoliday(), myServiceByDate.nextHoliday(new Date())); + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidays(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.getHolidays(2006)[0]); + + } + + public void testContext() { + 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()); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTest.java new file mode 100644 index 0000000000..2a50cdc8df --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTest.java @@ -0,0 +1,89 @@ +/* + * 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.osoa.sca.annotations.Reference; + +public class CompositeOneService2LevelTest extends TestCase { + @Reference + public MyService myService; + @Reference + public MyService myServiceDefault; + @Reference + public MyService myServiceNo; + @Reference + public MyService myServiceMay; + @Reference + public MyService myServiceMust; + + public void testPropertyFromComponent() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testPropertyFromServiceDefault() { + assertEquals("CARY", myServiceDefault.getLocation()); + assertEquals("2007", myServiceDefault.getYear()); + + } + + public void testServiceDefault() { + assertEquals(myService.nextHoliday(), myServiceDefault.nextHoliday()); + } + + public void testPropertyFromServiceNo() { + assertEquals("CARY", myServiceNo.getLocation()); + assertEquals("2007", myServiceNo.getYear()); + + } + + public void testServiceNo() { + assertEquals(myService.nextHoliday(), myServiceNo.nextHoliday()); + } + + public void testPropertyFromServiceMay() { + assertEquals("CARY", myServiceMay.getLocation()); + assertEquals("2007", myServiceMay.getYear()); + + } + + public void testServiceMay() { + assertEquals(myService.nextHoliday(), myServiceMay.nextHoliday()); + } + + public void testPropertyFromServiceMust() { + assertEquals("CARY", myServiceMust.getLocation()); + assertEquals("2007", myServiceMust.getYear()); + + } + + public void testServiceMust() { + assertEquals(myService.nextHoliday(), myServiceMust.nextHoliday()); + } + + public void testContext() { + 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()); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTest.java new file mode 100644 index 0000000000..27deb92012 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTest.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 org.apache.tuscany.sca.test.spec; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class CompositeOneServiceTest extends TestCase { + @Reference + public MyService myService; + + public void testOverrideProperty() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testDefaultService() { + assertNotNull(myService.nextHoliday()); + } + + public void testContext() { + 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()); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTest.java new file mode 100644 index 0000000000..b312fd1e36 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTest.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.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class CompositeServiceReferenceForRefOverrideTest extends TestCase { + @Reference + public MyTotalService myService1; + @Reference + public MyTotalService myService2; + @Reference + public MyTotalService myService3; + + 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.nextHoliday(new Date())); + System.out.println("myService1.getHolidays()[0]" + myService1.getHolidays()[0]); + System.out.println("myService1.getHolidays(2007)[0]" + myService1.getHolidays(2007)[0]); + assertNotSame(myService1.nextHoliday(), myService1.nextHoliday(new Date())); + assertEquals(myService1.getHolidays()[0], myService1.getHolidays(2007)[0]); + } + + public void testServiceFromReferenceMay() { + assertEquals(myService2.getHolidays()[0], myService2.getHolidays(2007)[0]); + assertNotSame(myService2.nextHoliday(), myService2.nextHoliday(new Date())); + + } + + public void testServiceFromReferenceMust() { + assertEquals(myService3.getHolidays()[0], myService3.getHolidays(2007)[0]); + assertNotSame(myService3.nextHoliday(), myService3.nextHoliday(new Date())); + + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTest.java new file mode 100644 index 0000000000..edf8d05512 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTest.java @@ -0,0 +1,81 @@ +/* + * 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.osoa.sca.annotations.Reference; + +public class CompositeServiceReferenceTest extends TestCase { + @Reference + public MyTotalService myService1; + @Reference + public MyTotalService myService2; + @Reference + public MyTotalService myService3; + @Reference + public MyTotalService myService4; + @Reference + public MyTotalService myService5; + + 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.nextHoliday(new Date())); + assertEquals(myService1.getHolidays()[0], myService1.getHolidays(2007)[0]); + + } + + public void testServiceReferenceFromRecursive() { + assertEquals(myService2.getHolidays()[0], myService2.getHolidays(2007)[0]); + assertNotSame(myService2.nextHoliday(), myService2.nextHoliday(new Date())); + + } + + public void testServiceReferenceFromRecursiveUseService() { + assertNotSame(myService4.nextHoliday(), myService4.nextHoliday(new Date())); + assertEquals(myService4.getHolidays()[0], myService4.getHolidays(2007)[0]); + } + + public void testServiceReferenceFromComponent() { + assertEquals(myService3.getHolidays()[0], myService3.getHolidays(2007)[0]); + assertNotSame(myService3.nextHoliday(), myService3.nextHoliday(new Date())); + + } + + public void testServiceReferenceFromComponentUseService() { + assertNotSame(myService5.nextHoliday(), myService5.nextHoliday(new Date())); + assertEquals(myService5.getHolidays()[0], myService5.getHolidays(2007)[0]); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTest.java new file mode 100644 index 0000000000..98c368fdba --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTest.java @@ -0,0 +1,55 @@ +/* + * 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.osoa.sca.annotations.Reference; + +public class CompositeTest extends TestCase { + @Reference + public MyService myService; + @Reference + public MyServiceByDate myServiceByDate; + @Reference + public MyListService myListService; + @Reference + public MyListServiceByYear myListServiceByYear; + + public void testOverrideProperty() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testDefaultService() { + assertEquals(myService.nextHoliday(), myServiceByDate.nextHoliday(new Date())); + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidays(2007)[0]); + + } + + public void testContext() { + 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()); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/resources/itest.scdl b/sandbox/old/contrib/itest/specTest/src/test/resources/itest.scdl new file mode 100644 index 0000000000..62c5cece94 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/resources/itest.scdl @@ -0,0 +1,30 @@ + + + + + + + + + + + -- cgit v1.2.3