tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r416319 - in /incubator/tuscany/java/sdo/impl/src: main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
Date Thu, 22 Jun 2006 10:25:58 GMT
Author: antelder
Date: Thu Jun 22 03:25:56 2006
New Revision: 416319

URL: http://svn.apache.org/viewvc?rev=416319&view=rev
Log:
Apply patch for TUSCANY-475 from Kelvin Goodson

Modified:
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
    incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java?rev=416319&r1=416318&r2=416319&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
(original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
Thu Jun 22 03:25:56 2006
@@ -23,6 +23,7 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -1995,8 +1996,16 @@
       return index;
     }
 
+    /*
+     * calling constraint, this method is not to be used for semantic of setting index to
NO_INDEX
+     */ 
     protected void setIndex(int index)
     {
+      if(index < 0) {
+        // The index value should be greater than 0.  An index value which is too high will
result in
+        // an index out of bounds generated later on accessing the data.
+        throw new IndexOutOfBoundsException("Index value is too low");
+      }
       this.index = index;
       if (!FeatureMapUtil.isMany(eObject, feature))
       {

Modified: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java?rev=416319&r1=416318&r2=416319&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
(original)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
Thu Jun 22 03:25:56 2006
@@ -59,4 +59,67 @@
          
         assertEquals(value, "2000-03-23");
     }
+    
+    public void testListIndexing() throws Exception {
+        TypeHelper typeHelper = SDOUtil.createTypeHelper();
+        XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
+        XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+
+        URL url = getClass().getResource(TEST_MODEL);
+        InputStream inputStream = url.openStream();
+        xsdHelper.define(inputStream, url.toString());
+
+        inputStream.close();
+
+        XMLDocument doc = xmlHelper.load(getClass().getResourceAsStream(XPATH_XML));
+
+        DataObject root = doc.getRootObject();
+        DataObject folder1 = root.getDataObject("Folder[1]");
+        assertNotNull(folder1);
+        DataObject folder1a = root.getDataObject("Folder.0");
+        assertEquals(folder1, folder1a);
+        folder1a = root.getDataObject("Folder[FolderName=Folder00000000000]");
+        assertEquals(folder1, folder1a);
+
+        DataObject noFolder = null;
+
+        try {
+            noFolder = root.getDataObject("Folder[3]");
+            assertFalse("bad indexing passed", true);
+        } catch (IndexOutOfBoundsException iobe) {
+            // as expected
+        } catch (Exception e) {
+            assertFalse("bad indexing generated wrong exception" + e, true);
+        }
+
+        try {
+            noFolder = root.getDataObject("Folder[0]");
+            assertFalse("bad indexing passed", true);
+        } catch (IndexOutOfBoundsException iobe) {
+            // as expected
+        } catch (Exception e) {
+            assertFalse("bad indexing generated wrong exception" + e, true);
+        }
+
+        try {
+            noFolder = root.getDataObject("Folder.2");
+            assertFalse("bad indexing passed", true);
+        } catch (IndexOutOfBoundsException iobe) {
+            // as expected
+        } catch (Exception e) {
+            assertFalse("bad indexing generated wrong exception" + e, true);
+        }
+
+        try {
+            noFolder = root.getDataObject("Folder.-1");
+            assertFalse("bad indexing passed", true);
+        } catch (IndexOutOfBoundsException iobe) {
+            // as expected
+        } catch (Exception e) {
+            assertFalse("bad indexing generated wrong exception" + e, true);
+        }
+
+        noFolder = root.getDataObject("Folder[FolderName=foo]");
+        assertNull(noFolder);
+    }
 }



---------------------------------------------------------------------
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