tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agr...@apache.org
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 GMT
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("<catalog2><product2/><product2/></catalog2>");
+        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


Mime
View raw message