From eb11fd83f7908876fe6041086d6025c9468de672 Mon Sep 17 00:00:00 2001 From: lresende Date: Tue, 10 Nov 2009 21:17:39 +0000 Subject: Moving SDO CTS git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834672 13f79535-47bb-0310-9956-ffa450edef68 --- .../sdo21/tests/api/Sequence/SequenceTest.java | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java (limited to 'sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java') diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java new file mode 100644 index 0000000000..b09d0597f3 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceTest.java @@ -0,0 +1,100 @@ +/* + * 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 test.sdo21.tests.api.Sequence; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +import commonj.sdo.DataObject; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; + +import test.sdo21.framework.CTSTestCase; + +/** + * Set of tests for Sequence APIs. + */ +public class SequenceTest extends CTSTestCase { + + + @Before + public void setUp() throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Test to ensure that once an isMany=false property within a sequenced type + * retains an existing position in the sequence following an update. + *@see SDO Spec Jira 242 + */ + @Test + public void testSeqWhenIsManyFalseAndValueUpdated() + { + + DataFactory df = getScope().getDataFactory(); + TypeHelper th = getScope().getTypeHelper(); + + Type stringType = th.getType("commonj.sdo", "String"); + + DataObject typeModel = df.create("commonj.sdo", "Type"); + typeModel.set("name", "name"); + typeModel.set("uri", "example.org"); + typeModel.set("sequenced", true); + + DataObject property1 = typeModel.createDataObject("property"); + property1.set("name", "givenname"); + property1.set("type", stringType); + + DataObject property2 = typeModel.createDataObject("property"); + property2.set("name", "familyname"); + property2.set("type", stringType); + + th.define(typeModel); + + DataObject aName = df.create("example.org", "name"); + + aName.set("familyname", "Smith"); + aName.set("givenname", "John"); + + Sequence seq = aName.getSequence(); + // System.out.println(getScope().getXMLHelper().save(aName, "example./org", "aName")); + + assertEquals(seq.getValue(0), "Smith"); + assertEquals(seq.getValue(1), "John"); + + aName.set("familyname", "Jones"); + // System.out.println(getScope().getXMLHelper().save(aName, "example./org", "aName")); + + assertEquals(seq.size(), 2); + + assertEquals(seq.getValue(0), "Jones"); + assertEquals(seq.getValue(1), "John"); + + } +} -- cgit v1.2.3