From b8d68b1f47a347d50dbe50ef2bad0ddb1d99d59d Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 3 Dec 2008 10:17:21 +0000 Subject: TUSCANY-2686 - Thanks for the patch Yiwen. Constraining type vtests. I don;t believe we exploit constraining type information just yet but the tests are inplace in the case that we decide to implement this feature.The negative test needs a little work still. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@722833 13f79535-47bb-0310-9956-ffa450edef68 --- .../ctypefile/CompomnentTypeFileTestCase.java | 84 ++++++++++++++++++++-- 1 file changed, 78 insertions(+), 6 deletions(-) (limited to 'branches/sca-java-1.x/vtest/assembly/ctypefile/src/test/java/org') diff --git a/branches/sca-java-1.x/vtest/assembly/ctypefile/src/test/java/org/apache/tuscany/sca/vtest/assembly/ctypefile/CompomnentTypeFileTestCase.java b/branches/sca-java-1.x/vtest/assembly/ctypefile/src/test/java/org/apache/tuscany/sca/vtest/assembly/ctypefile/CompomnentTypeFileTestCase.java index f8f7e45f61..d2d2257277 100644 --- a/branches/sca-java-1.x/vtest/assembly/ctypefile/src/test/java/org/apache/tuscany/sca/vtest/assembly/ctypefile/CompomnentTypeFileTestCase.java +++ b/branches/sca-java-1.x/vtest/assembly/ctypefile/src/test/java/org/apache/tuscany/sca/vtest/assembly/ctypefile/CompomnentTypeFileTestCase.java @@ -31,23 +31,25 @@ import org.junit.Test; */ public class CompomnentTypeFileTestCase { - protected static String compositeName = "typefile.composite"; + //protected static String compositeName = "typefile.composite"; protected static AService aService = null; protected static BService bService2 = null; + protected static CService cService = null; + protected static DService dService = null; - @BeforeClass - public static void init() throws Exception { + //@BeforeClass + public static void init(String compositeName) throws Exception { try { System.out.println("Setting up"); ServiceFinder.init(compositeName); - aService = ServiceFinder.getService(AService.class, "AComponent/AService"); - bService2 = ServiceFinder.getService(BService.class, "BComponent2/BService"); + //aService = ServiceFinder.getService(AService.class, "AComponent/AService"); + //bService2 = ServiceFinder.getService(BService.class, "BComponent2/BService"); } catch (Exception ex) { ex.printStackTrace(); } } - @AfterClass + //@AfterClass public static void destroy() throws Exception { System.out.println("Cleaning up"); @@ -74,7 +76,11 @@ public class CompomnentTypeFileTestCase { */ @Test public void typeFile1() throws Exception { + init("typefile.composite"); + aService = ServiceFinder.getService(AService.class, "AComponent/AService"); + bService2 = ServiceFinder.getService(BService.class, "BComponent2/BService"); Assert.assertSame("SomeStateFromB", aService.getState()); + destroy(); } /** @@ -89,8 +95,12 @@ public class CompomnentTypeFileTestCase { */ @Test public void typeFile2() throws Exception { + init("typefile.composite"); + aService = ServiceFinder.getService(AService.class, "AComponent/AService"); + bService2 = ServiceFinder.getService(BService.class, "BComponent2/BService"); Assert.assertSame("SomeStateFromB", aService.getState()); Assert.assertSame("SomeStateFromB", aService.getState2()); + destroy(); } /** @@ -101,11 +111,73 @@ public class CompomnentTypeFileTestCase { */ @Test public void typeFile3() throws Exception { + init("typefile.composite"); + aService = ServiceFinder.getService(AService.class, "AComponent/AService"); + bService2 = ServiceFinder.getService(BService.class, "BComponent2/BService"); Assert.assertEquals("compositeValue", aService.getBProperty()); + destroy(); } public void typeFile31() throws Exception { + init("typefile.composite"); + aService = ServiceFinder.getService(AService.class, "AComponent/AService"); + bService2 = ServiceFinder.getService(BService.class, "BComponent2/BService"); Assert.assertEquals("componentTypeValue", bService2.getSomeProperty()); + destroy(); } + + /** + * Lines 2204-2205: + *

+ * A constrainingType can be applied to an implementation. In this case, + * the implementation's componentType has a constrainingType attribute set to + * the QName of the constrainingType. + *

+ * ASM40002 + *

+ * If present, the @constrainingType attribute of a element + * MUST reference a element in the Domain through its QName. + *

+ * Description of how the OSOA function differs from the OASIS function: + *

+ * The OASIS spec explicitly requires the element, + * whereas the OSOA spec implies the element is needed. + *

+ */ + @Test + public void ASM40002_positive() throws Exception { + System.out.println("Running ASM40002 positive test"); + init("constrainingtype.composite"); + cService = ServiceFinder.getService(CService.class, "CComponent/CService"); + cService.getSomeProperty(); + destroy(); + } + + /** + * Lines 2204-2205: + *

+ * A constrainingType can be applied to an implementation. In this case, + * the implementation's componentType has a constrainingType attribute set to + * the QName of the constrainingType. + *

+ * ASM40002 + *

+ * If present, the @constrainingType attribute of a element + * MUST reference a element in the Domain through its QName. + *

+ * Description of how the OSOA function differs from the OASIS function: + *

+ * The OASIS spec explicitly requires the element, + * whereas the OSOA spec implies the element is needed. + *

+ */ + @Test + public void ASM40002_negative() throws Exception { + System.out.println("Running ASM40002 negative test"); + init("noconstrainingtype.composite"); + dService = ServiceFinder.getService(DService.class, "DComponent/DService"); + dService.getSomeProperty(); + destroy(); + } } -- cgit v1.2.3