From 1f81a54d49573dc5d1470af8c6385af42ae8f56b Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 19 Nov 2008 13:06:58 +0000 Subject: TUSCANY-2675 Patch from Jun Guo to start adding assembly spec vtests. Thanks Jun Guo git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@718951 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/vtest/assembly/component/DService.java | 29 ++++++++ .../sca/vtest/assembly/component/EEService.java | 31 ++++++++ .../sca/vtest/assembly/component/EService.java | 31 ++++++++ .../component/impl/ABServiceImpl.componentType | 32 +++++++++ .../assembly/component/impl/ABServiceImpl.java | 51 ++++++++++++++ .../component/impl/DServiceImpl.componentType | 31 ++++++++ .../assembly/component/impl/DServiceImpl.java | 29 ++++++++ .../component/impl/EServiceImpl.componentType | 31 ++++++++ .../assembly/component/impl/EServiceImpl.java | 38 ++++++++++ .../nonuniqueservicenameincomponenttype.composite | 29 ++++++++ .../nonuniqueservicenameincomposite.composite | 47 +++++++++++++ .../resources/notcompatibleinterface.composite | 38 ++++++++++ .../main/resources/notmatchofservicename.composite | 36 ++++++++++ .../assembly/component/ComponentTestCase.java | 82 +++++++++++++++++++++- 14 files changed, 534 insertions(+), 1 deletion(-) create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/DService.java create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/EEService.java create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/EService.java create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/ABServiceImpl.componentType create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/ABServiceImpl.java create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/DServiceImpl.componentType create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/DServiceImpl.java create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/EServiceImpl.componentType create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/EServiceImpl.java create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/resources/nonuniqueservicenameincomponenttype.composite create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/resources/nonuniqueservicenameincomposite.composite create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/resources/notcompatibleinterface.composite create mode 100644 branches/sca-java-1.x/vtest/assembly/component/src/main/resources/notmatchofservicename.composite (limited to 'branches/sca-java-1.x') diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/DService.java b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/DService.java new file mode 100644 index 0000000000..f5832aa7ce --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/DService.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.vtest.assembly.component; + +/** + * simple service + */ +public interface DService { + + public String sayHello(); + + +} diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/EEService.java b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/EEService.java new file mode 100644 index 0000000000..87de618ad3 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/EEService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.assembly.component; + +/** + * simple service + * + */ +public interface EEService { + + public String method1() ; + + public String method3() ; + +} diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/EService.java b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/EService.java new file mode 100644 index 0000000000..5d3bbb26c3 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/EService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.assembly.component; + +/** + * simple service + * + */ +public interface EService { + + public String method1() ; + + public String method2() ; + +} diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/ABServiceImpl.componentType b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/ABServiceImpl.componentType new file mode 100644 index 0000000000..7cc63afee1 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/ABServiceImpl.componentType @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/ABServiceImpl.java b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/ABServiceImpl.java new file mode 100644 index 0000000000..98f0291be3 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/ABServiceImpl.java @@ -0,0 +1,51 @@ +/* + * 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.vtest.assembly.component.impl; + +import org.apache.tuscany.sca.vtest.assembly.component.AService; +import org.apache.tuscany.sca.vtest.assembly.component.BService; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * service implementation of AService and BService + * + */ +@Service(interfaces={AService.class, BService.class}) +public class ABServiceImpl implements AService, BService{ + + public String getState() { + return "OK"; + } + + public String getBProperty() { + return ""; + } + + public String getB2Property() { + return ""; + } + + + public String getSomeProperty() { + return "SomeProperty"; + } + +} diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/DServiceImpl.componentType b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/DServiceImpl.componentType new file mode 100644 index 0000000000..899f84b2dd --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/DServiceImpl.componentType @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/DServiceImpl.java b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/DServiceImpl.java new file mode 100644 index 0000000000..fce89b7bb9 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/DServiceImpl.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.vtest.assembly.component.impl; + +public class DServiceImpl { + + public String sayHello() { + return "hello"; + } + +} + diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/EServiceImpl.componentType b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/EServiceImpl.componentType new file mode 100644 index 0000000000..86a7be9cc0 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/EServiceImpl.componentType @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/EServiceImpl.java b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/EServiceImpl.java new file mode 100644 index 0000000000..4adb361ee5 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/EServiceImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.assembly.component.impl; + +import org.apache.tuscany.sca.vtest.assembly.component.EService; +import org.osoa.sca.annotations.Service; + + +@Service(EService.class) +public class EServiceImpl { + + public String method1() { + + return "method1" ; + } + + public String method2() { + + return "method2" ; + } + +} diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/nonuniqueservicenameincomponenttype.composite b/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/nonuniqueservicenameincomponenttype.composite new file mode 100644 index 0000000000..0f859f908f --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/nonuniqueservicenameincomponenttype.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/nonuniqueservicenameincomposite.composite b/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/nonuniqueservicenameincomposite.composite new file mode 100644 index 0000000000..00f3d00a2d --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/nonuniqueservicenameincomposite.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/notcompatibleinterface.composite b/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/notcompatibleinterface.composite new file mode 100644 index 0000000000..b4d2abc011 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/notcompatibleinterface.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/notmatchofservicename.composite b/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/notmatchofservicename.composite new file mode 100644 index 0000000000..7d49f8baf1 --- /dev/null +++ b/branches/sca-java-1.x/vtest/assembly/component/src/main/resources/notmatchofservicename.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.x/vtest/assembly/component/src/test/java/org/apache/tuscany/sca/vtest/assembly/component/ComponentTestCase.java b/branches/sca-java-1.x/vtest/assembly/component/src/test/java/org/apache/tuscany/sca/vtest/assembly/component/ComponentTestCase.java index de4fbe39ce..2d245d10a8 100644 --- a/branches/sca-java-1.x/vtest/assembly/component/src/test/java/org/apache/tuscany/sca/vtest/assembly/component/ComponentTestCase.java +++ b/branches/sca-java-1.x/vtest/assembly/component/src/test/java/org/apache/tuscany/sca/vtest/assembly/component/ComponentTestCase.java @@ -33,6 +33,7 @@ public class ComponentTestCase { private void initDomain(String compositePath) { System.out.println("Setting up"); + ServiceFinder.init(compositePath); } @@ -40,6 +41,8 @@ public class ComponentTestCase { System.out.println("Cleaning up"); ServiceFinder.cleanup(); } + + /** * Lines 92-96: @@ -72,7 +75,7 @@ public class ComponentTestCase { /** * Lines 142-143: *

- * name (required) – the name of the component. The name must be unique + * name (required) ?the name of the component. The name must be unique * across all the components in the composite. */ @Test(expected = ServiceRuntimeException.class) @@ -146,5 +149,82 @@ public class ComponentTestCase { cleanupDomain(); } + /** + * Lines 599-601: + *

+ * ASM50001 + *

+ * The @name attribute of a child element of a MUST + * be unique amongst the service elements of that + * + */ + @Test(expected=ServiceRuntimeException.class) + @Ignore("TUSCANY-2675") + public void ASM50001() throws Exception { + initDomain("nonuniqueservicenameincomponenttype.composite"); + AService service = ServiceFinder.getService(AService.class, "ABComponent/AService"); + Assert.assertEquals("OK", service.getState()); + cleanupDomain(); + } + + /** + * Lines 695-697: + *

+ * ASM50002 + *

+ * The @name attribute of a service element of a MUST be unique amongst + * the service elements of that + * + */ + @Test(expected=ServiceRuntimeException.class) + public void ASM50002() throws Exception { + initDomain("nonuniqueservicenameincomposite.composite"); + DService service = ServiceFinder.getService(DService.class, "CDComponent/CServiceImpl"); + Assert.assertEquals("hello", service.sayHello()); + cleanupDomain(); + } + + /** + * Lines 697-699: + *

+ * ASM50003 + *

+ * OSOA + * The @name attribute of a service element of a MUST match the + * @name attribute of a service element of the componentType of the child element of the component. + *

+ * OASIS + * the name of the service has to match a name of a service defined by the implementation + * + */ + @Test(expected=ServiceRuntimeException.class) + public void ASM50003() throws Exception { + initDomain("notmatchofservicename.composite"); + DService service = ServiceFinder.getService(DService.class, "DComponent1/DService1"); + Assert.assertEquals("hello", service.sayHello()); + cleanupDomain(); + } + + /** + * Lines 709-715: + *

+ * ASM50004 + *

+ * If a element has an interface subelement specified, the interface MUST + * provide a compatible subset of the interface declared on the componentType of the + * implementation. + */ + @Test(expected=ServiceRuntimeException.class) + public void ASM50004() throws Exception { + //for this case, if you remove the method3() in the EEService + //the EEService will be a compatible subset of EService. + initDomain("notcompatibleinterface.composite"); + EEService service = ServiceFinder.getService(EEService.class, "EEComponent/EEService"); + Assert.assertEquals("method1", service.method1()); + cleanupDomain(); + } + + + } -- cgit v1.2.3