diff options
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.0/itest/properties/src/test')
3 files changed, 370 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java b/sca-java-1.x/branches/sca-java-1.0/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java new file mode 100644 index 0000000000..fa3b9c5404 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.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.itest; +import static junit.framework.Assert.assertEquals; +import mysca.test.myservice.impl.MyService; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class MyTotalServiceTestCase { + private static MyService service1; + private static MyService service2; + private static MyService service3; + + private static SCADomain domain; + + @Test + public void testPropertyDefault() { + assertEquals("RTP", service1.getLocation()); + assertEquals("2006", service1.getYear()); + } + + @Test + public void testPropertyOverride() { + assertEquals("Raleigh", service2.getLocation()); + assertEquals("2008", service2.getYear()); + } + + @Test + public void testPropertyNestedOverride() { + assertEquals("Durham", service3.getLocation()); + assertEquals("2009", service3.getYear()); + } + + @BeforeClass + /** + * Sets up for the test case execution such as locating services. + */ + public static void setUp() throws Exception { + + domain = SCADomain.newInstance("Outer.composite"); + service1 = domain.getService(MyService.class, "MyServiceComponent/MyService"); + service2 = domain.getService(MyService.class, "MyServiceComponentNew/MyService"); + service3 = domain.getService(MyService.class, "MySimpleServiceInRecursiveAnother"); + } + + @AfterClass + public static void tearDown() { + domain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java b/sca-java-1.x/branches/sca-java-1.0/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-1.0/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<String> iterator = outerABService.getManyStringValues().iterator();
+ assertEquals("Apache", iterator.next());
+ assertEquals("Tuscany", iterator.next());
+ assertEquals("Java SCA", iterator.next());
+ }
+
+ @Test
+ public void testManySimpleIntegerValues() {
+ Iterator<Integer> 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-1.0/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java b/sca-java-1.x/branches/sca-java-1.0/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-1.0/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<String> 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<String> iterator = abService.getManyStringValues().iterator(); + assertEquals("Apache", iterator.next()); + assertEquals("Tuscany", iterator.next()); + assertEquals("Java SCA", iterator.next()); + } + + @Test + public void testManySimpleIntegerValues() { + Iterator<Integer> 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(); + } +} |