You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2006/12/14 16:14:19 UTC

svn commit: r487229 - /incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java

Author: alally
Date: Thu Dec 14 07:14:18 2006
New Revision: 487229

URL: http://svn.apache.org/viewvc?view=rev&rev=487229
Log:
added a testcase

Modified:
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java?view=diff&rev=487229&r1=487228&r2=487229
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java Thu Dec 14 07:14:18 2006
@@ -301,6 +301,37 @@
     // System.out.println(sb.toString());
   }
 
+  public void testClone() throws Exception {
+    createExampleFS(cas);
+    // get the example FS
+    CAS englishView = cas.getView("EnglishDocument");
+    FSIterator iter = englishView.getAnnotationIndex().iterator();
+    // skip document annotation
+    iter.moveToNext();
+    // the exampleType fs
+    AnnotationFS fs = (AnnotationFS) iter.get();
+
+    // clone it
+    AnnotationFS clone = (AnnotationFS) fs.clone();
+
+    // subsitute the clone for the original in the index,
+    // and validate that it was correctly copied
+    englishView.removeFsFromIndexes(fs);
+    englishView.addFsToIndexes(clone);
+    validateFSData(cas);
+
+    // editing the original FS should not change the clone
+    fs.setStringValue(stringFeature, "foo");
+    fs.setFloatValue(floatFeature, -1f);
+    fs.setByteValue(byteFeature, (byte) -1);
+    fs.setBooleanValue(booleanFeature, false);
+    fs.setShortValue(shortFeature, (short) -1);
+    fs.setLongValue(longFeature, -1);
+    fs.setDoubleValue(doubleFeature, -1);
+
+    validateFSData(cas);
+  }
+
   private void validateFSData(CAS cas) throws Exception {
     CAS englishView = cas.getView("EnglishDocument");
     assertNotNull(englishView);
@@ -470,8 +501,6 @@
     fs.setFeatureValue(longArrayFeature, longArrayFS);
     fs.setDoubleValue(doubleFeature, Double.MAX_VALUE);
     fs.setFeatureValue(doubleArrayFeature, doubleArrayFS);
-
-    englishView.getIndexRepository().addFS(fs);
   }
 
   // public void testUimaTypeSystem2Ecore() throws Exception