From 3dd7e2c4da9c80b8182a2d04dc129a67aa7910df Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:58 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835121 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/itest/OuterPropertyTestCase.java | 92 +++++++++ .../apache/tuscany/sca/itest/PropertyTestCase.java | 208 +++++++++++++++++++++ 2 files changed, 300 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java (limited to 'sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca') diff --git a/sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java b/sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java new file mode 100644 index 0000000000..b2ac537dec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java @@ -0,0 +1,92 @@ +/* + * 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.itest; + +import static junit.framework.Assert.assertEquals; + +import java.util.Iterator; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class OuterPropertyTestCase { + + private static SCADomain domain; + private static ABComponent outerABService; + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("OuterPropertyTest.composite"); + outerABService = domain.getService(ABComponent.class, "OuterComponent"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } + + @Test + public void testOverridenA() { + assertEquals("Overriden A", outerABService.getA()); + } + + @Test + public void testOverridenB() { + assertEquals("Overriden B", outerABService.getB()); + } + + @Test + public void testOverridenF() { + assertEquals("Overriden A", outerABService.getF()); + } + + @Test + public void testOverridenZ() { + assertEquals("Overriden Z", outerABService.getZ()); + } + + @Test + public void testOverridenIntValue() { + assertEquals(125, outerABService.getIntValue()); + } + + @Test + public void testDefaultValue() { + assertEquals(125, outerABService.getIntValue()); + } + + @Test + public void testManySimpleStringValues() { + Iterator iterator = outerABService.getManyStringValues().iterator(); + assertEquals("Apache", iterator.next()); + assertEquals("Tuscany", iterator.next()); + assertEquals("Java SCA", iterator.next()); + } + + @Test + public void testManySimpleIntegerValues() { + Iterator iterator = outerABService.getManyIntegers().iterator(); + assertEquals(123, iterator.next().intValue()); + assertEquals(456, iterator.next().intValue()); + assertEquals(789, iterator.next().intValue()); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java b/sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java new file mode 100644 index 0000000000..a01700920f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java @@ -0,0 +1,208 @@ +/* + * 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.itest; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.util.Iterator; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import commonj.sdo.DataObject; + +public class PropertyTestCase { + private static SCADomain domain; + private static ABComponent abService; + private static CDComponent cdService; + private static ABCDComponent abcdService; + private static PropertyComponent propertyService; + + @Test + public void testA() { + assertEquals("a", abService.getA()); + } + + @Test + public void testB() { + assertEquals("b", abService.getB()); + } + + @Test + public void testC() { + assertEquals("c", cdService.getC()); + } + + @Test + public void testC2() { + assertEquals("c", cdService.getC2()); + } + + @Test + public void testD() { + assertEquals("d", cdService.getD()); + } + + @Test + public void testF() { + assertEquals("a", abService.getF()); + } + + @Test + public void testZ() { + assertEquals("z", abService.getZ()); + } + + @Test + public void testIntValue() { + assertEquals(1, abService.getIntValue()); + } + + @Test + public void testDefaultValue() { + assertEquals(1, abService.getIntValue()); + } + + @Test + public void testDefaultValueOverride() { + assertEquals(1, cdService.getOverrideValue()); + } + + @Test + public void testNoSource() { + assertEquals("aValue", cdService.getNoSource()); + } + + @Test + public void testFileProperty() { + assertEquals("fileValue", cdService.getFileProperty()); + } + + @Test + public void testManyValuesFileProperty() { + Iterator iterator = cdService.getManyValuesFileProperty().iterator(); + iterator.next(); + String secondValue = iterator.next(); + assertEquals(4, cdService.getManyValuesFileProperty().size()); + assertEquals("fileValueTwo", secondValue); + } + + @Test + public void testABCD() { + assertEquals("a", abcdService.getA()); + assertEquals("b", abcdService.getB()); + assertEquals("c", abcdService.getC()); + assertEquals("d", abcdService.getD()); + } + + @Test + public void testDefaultProperty() { + assertEquals("RTP", propertyService.getLocation()); + assertEquals("2006", propertyService.getYear()); + + } + + @Test + public void testManySimpleStringValues() { + Iterator iterator = abService.getManyStringValues().iterator(); + assertEquals("Apache", iterator.next()); + assertEquals("Tuscany", iterator.next()); + assertEquals("Java SCA", iterator.next()); + } + + @Test + public void testManySimpleIntegerValues() { + Iterator iterator = abService.getManyIntegers().iterator(); + assertEquals(123, iterator.next().intValue()); + assertEquals(456, iterator.next().intValue()); + assertEquals(789, iterator.next().intValue()); + } + + @Test + public void testComplexPropertyOne() { + ComplexPropertyBean propBean = propertyService.getComplexPropertyOne(); + assertNotNull(propBean); + assertEquals("TestString_1", propBean.getStringArray()[0]); + assertEquals(2, propBean.numberSetArray[1].integerNumber); + } + + @Test + public void testComplexPropertyTwo() { + ComplexPropertyBean propBean = propertyService.getComplexPropertyTwo(); + assertNotNull(propBean); + assertEquals(10, propBean.intArray[0]); + assertEquals((float)22, propBean.numberSetArray[1].floatNumber); + } + + @Test + public void testComplexPropertyThree() { + ComplexPropertyBean propBean = propertyService.getComplexPropertyThree(); + assertNotNull(propBean); + assertEquals("TestElementString_1", propBean.stringArray[0]); + assertEquals((float)22, propBean.numberSetArray[1].floatNumber); + } + + @Test + public void testComplexPropertyFour() { + Object[] propBeanCollection = propertyService.getComplexPropertyFour().toArray(); + assertNotNull(propBeanCollection); + assertEquals(1, ((ComplexPropertyBean)propBeanCollection[0]).getIntegerNumber()); + assertEquals(222.222, ((ComplexPropertyBean)propBeanCollection[1]).getDoubleNumber()); + assertEquals(33, ((ComplexPropertyBean)propBeanCollection[2]).getNumberSet().getIntegerNumber()); + } + + @Test + public void testSDOProperty1() { + DataObject dataObject = propertyService.getSdoProperty(); + assertNotNull(dataObject); + assertEquals("Firstly Name", dataObject.get("firstName")); + assertEquals("Middler Name", dataObject.getString("middleName")); + assertEquals("Lasting Name", dataObject.getString("lastName")); + } + + @Test + public void testSDOProperty2() { + DataObject dataObject = propertyService.getCustomerSdo(); + assertNotNull(dataObject); + assertEquals("Sdo Firstly Name", dataObject.get("firstName")); + assertEquals("Sdo Middler Name", dataObject.getString("middleName")); + assertEquals("Sdo Lasting Name", dataObject.getString("lastName")); + } + + @BeforeClass + public static void init() throws Exception { + try { + domain = SCADomain.newInstance("PropertyTest.composite"); + } catch ( Exception e ) { e.printStackTrace(); } + abService = domain.getService(ABComponent.class, "ABComponent"); + cdService = domain.getService(CDComponent.class, "CDComponent"); + abcdService = domain.getService(ABCDComponent.class, "ABCDComponent"); + propertyService = + domain.getService(PropertyComponent.class, "PropertyComponent"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } +} -- cgit v1.2.3