Return-Path: Delivered-To: apmail-ws-tuscany-commits-archive@locus.apache.org Received: (qmail 27635 invoked from network); 2 Jul 2007 14:19:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jul 2007 14:19:08 -0000 Received: (qmail 88642 invoked by uid 500); 2 Jul 2007 14:19:11 -0000 Delivered-To: apmail-ws-tuscany-commits-archive@ws.apache.org Received: (qmail 88563 invoked by uid 500); 2 Jul 2007 14:19:11 -0000 Mailing-List: contact tuscany-commits-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: tuscany-dev@ws.apache.org Delivered-To: mailing list tuscany-commits@ws.apache.org Received: (qmail 88554 invoked by uid 99); 2 Jul 2007 14:19:11 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2007 07:19:11 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2007 07:19:07 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 67CD51A981A; Mon, 2 Jul 2007 07:18:47 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r552500 - /incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java Date: Mon, 02 Jul 2007 14:18:47 -0000 To: tuscany-commits@ws.apache.org From: agrove@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070702141847.67CD51A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: agrove Date: Mon Jul 2 07:18:46 2007 New Revision: 552500 URL: http://svn.apache.org/viewvc?view=rev&rev=552500 Log: Adding two new list tests to DataObjectTest. Both tests pass against Tuscany. Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java?view=diff&rev=552500&r1=552499&r2=552500 ============================================================================== --- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java (original) +++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/api/DataObject/DataObjectTest.java Mon Jul 2 07:18:46 2007 @@ -23,6 +23,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; @@ -36,6 +39,10 @@ import commonj.sdo.Property; import commonj.sdo.Type; import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; + +import java.util.List; +import java.util.ArrayList; /** * Set of tests for DataObject APIs. @@ -326,6 +333,48 @@ assertEquals( (long) 0, testDO.getLong( "foo" ) ); assertEquals( (double) 0, testDO.getDouble( "foo" ) ); assertEquals( (float) 0, testDO.getFloat( "foo" ) ); + } + + /** + * Test that getList() returns null for an unset open content property. + * + */ + @Test + public void testGetList() { + + // define an open type with no properties + HelperContext helperContext = getScope(); + String typeName = getTypeName(); + DataObject typeDef = CTSUtil.createTypeDef("", typeName, true, helperContext); + helperContext.getTypeHelper().define(typeDef); + + // create a DataObject that uses this type + DataObject testDO = helperContext.getDataFactory().create("", typeName); + + // test that getList() returns null for an unst open content property + assertNull( testDO.getList("foo") ); + testDO.set("foo", new ArrayList()); + assertNotNull( testDO.getList("foo") ); + testDO.unset("foo"); + assertNull( testDO.getList("foo") ); + } + + /** + * Test that it is possible to add a null value to a List retrieved by calling DataObject.getList() + * + */ + @Test + public void testAddNullToList() { + HelperContext helperContext = getScope(); + XMLDocument doc = helperContext.getXMLHelper().load(""); + List listTest = doc.getRootObject().getList("product2"); + assertNotNull(listTest); + assertEquals(2, listTest.size()); + listTest.add( null ); + assertEquals(3, listTest.size()); + String xml = helperContext.getXMLHelper().save( doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName() ); + assertTrue( xml.indexOf("xsi:nil=\"true\"") > 0 ); + } /** --------------------------------------------------------------------- To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org For additional commands, e-mail: tuscany-commits-help@ws.apache.org