[UIMA-4743] add test case for delta binary serialization of mods to existing byte/short/long arrays. fix errors in CASSerializer. augment error message to reveal wrapped exception as part of message (was being ignored).

git-svn-id: https://svn.apache.org/repos/asf/uima/uimaj/trunk@1755512 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java b/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
index e4795b1..1883936 100644
--- a/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
+++ b/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
@@ -151,7 +151,7 @@
   public static final String UNRECOGNIZED_SERIALIZED_CAS_FORMAT = "UNRECOGNIZED_SERIALIZED_CAS_FORMAT";
 	
 	/**
-   * Error trying to read BLOB data from an input stream and deserialize Stringo a CAS.
+   * Error while deserializing binary CAS. {0}.
    */
 	public static final String BLOB_DESERIALIZATION = "BLOB_DESERIALIZATION";
 
diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java b/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java
index 91f80fe..0a2734e 100644
--- a/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java
+++ b/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java
@@ -68,12 +68,6 @@
 
   static final long serialVersionUID = -7972011651957420295L;
 
-  /**
-   * Set this to true to not fix the Jira 4743 bug where it causes more bytes to be written
-   *   (the part that doesn't cause a serialized byte format change is still fixed)
-   */
-  private boolean bkwdCompatJira4743 = true;
-  
   // The heap itself.
   public int[] heapArray = null;
 
@@ -250,7 +244,7 @@
 
       // output the key and version number
       CommonSerDes.createHeader()
-      .seqVer(bkwdCompatJira4743 ? 0 : 1)     // version 1 for UIMA-4743
+      .seqVer(1)     // not a delta, set version 1 for UIMA-4743 to inform receiver that we can handle version 1 format
       .write(dos);
      
       // output the FS heap
@@ -416,8 +410,8 @@
       this.fsIndex = cas.getDeltaIndexedFSs(mark);
       
       CommonSerDes.createHeader()
-      .delta()
-      .seqVer(bkwdCompatJira4743 ? 0 : 1)     // version 1 for UIMA-4743
+      .delta()                                // is delta
+      .seqVer(1)
        .write(dos);    
 
       // output the new FS heap cells
@@ -542,7 +536,7 @@
 	    }
 
       // word alignment
-      align = (4 - (byteheapsz % 4)) % 4;
+      align = (4 - (byteHeapModifiedAddrs.length % 4)) % 4;
       for (int i = 0; i < align; i++) {
         dos.writeByte(0);
       }
@@ -552,19 +546,16 @@
       short[] shortValues = new short[shortHeapModifiedAddrs.length];
       dos.writeInt(shortHeapModifiedAddrs.length);
       for (int i=0; i < shortHeapModifiedAddrs.length; i++) {
-        if (bkwdCompatJira4743) {
-      	  dos.writeShort(shortHeapModifiedAddrs[i]);
-        } else {
-          dos.writeInt(shortHeapModifiedAddrs[i]);
-        }
-      	shortValues[i] = cas.getShortHeap().getHeapValue(shortHeapModifiedAddrs[i]);
+        int modifiedAddr = shortHeapModifiedAddrs[i]; 
+        dos.writeInt(modifiedAddr);
+      	shortValues[i] = cas.getShortHeap().getHeapValue(modifiedAddr);
       }
       for (int i=0; i < shortValues.length; i++) {  
     	  dos.writeShort(cas.getShortHeap().getHeapValue(shortHeapModifiedAddrs[i]));
 	  }
       
       // word alignment
-      if (shortheapsz % 2 != 0) {
+      if (shortHeapModifiedAddrs.length % 2 != 0) {
         dos.writeShort(0);
       }
       
@@ -573,12 +564,9 @@
       long[] longValues = new long[longHeapModifiedAddrs.length];
       dos.writeInt(longHeapModifiedAddrs.length);
       for (int i=0; i < longHeapModifiedAddrs.length; i++) {
-        if (bkwdCompatJira4743) {
-          dos.writeShort(longHeapModifiedAddrs[i]);
-        } else {
-          dos.writeInt(longHeapModifiedAddrs[i]);
-        }
-        longValues[i] = cas.getLongHeap().getHeapValue(longHeapModifiedAddrs[i]);
+        int modifiedAddr = longHeapModifiedAddrs[i];
+        dos.writeInt(modifiedAddr);
+        longValues[i] = cas.getLongHeap().getHeapValue(modifiedAddr);
       }
       for (int i=0; i < longValues.length; i++) {  
     	  dos.writeLong(cas.getLongHeap().getHeapValue(longHeapModifiedAddrs[i]));
@@ -663,20 +651,4 @@
     return this.longHeapArray;
   }
 
-  /**
-   * @return true if writing backward compatible delta 
-   */
-  public boolean isBkwdCompatJira4743() {
-    return bkwdCompatJira4743;
-  }
-
-  /**
-   * @param keepBackwardCompatible
-   *          set to true to write backward compatible delta, false to fix this bug set to false by
-   *          uima-as version 2.9.0, and other users of delta binary serialization to fix this bug
-   */
-  public void setBkwdCompatJira4743(boolean keepBackwardCompatible) {
-    this.bkwdCompatJira4743 = keepBackwardCompatible;
-  }
-
 }
diff --git a/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties b/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
index 4f0ee1c..d331b61 100644
--- a/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
+++ b/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
@@ -556,7 +556,7 @@
 INVALID_FEATURE_PATH = The feature path "{0}" is not valid.
 NO_PRIMITIVE_TAIL = The feature path does not end in a primitive valued feature.
 BLOB_SERIALIZATION = Error trying to do binary serialization of CAS data and write the BLOB to an output stream.
-BLOB_DESERIALIZATION = Error trying to read BLOB data from an input stream and deserialize into a CAS.
+BLOB_DESERIALIZATION = Error while deserializing binary CAS. {0}.
 UNRECOGNIZED_SERIALIZED_CAS_FORMAT = Unrecognized serialized CAS format.
 SOFADATASTREAM_ERROR = Error trying to open a stream to Sofa data.
 INVALID_BASE_CAS_METHOD = Can''t call method "{0}" on the base CAS.
diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java
index 84c9e94..6c2998f 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas/test/SerializationReinitTest.java
@@ -40,6 +40,7 @@
 import org.apache.uima.cas.FSIterator;
 import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.LongArrayFS;
 import org.apache.uima.cas.Marker;
 import org.apache.uima.cas.ShortArrayFS;
 import org.apache.uima.cas.StringArrayFS;
@@ -66,7 +67,7 @@
 import org.apache.uima.util.XMLInputSource;
 
 /**
- * Class comment for TokenizerTest.java goes here.
+ * Test for binary serialization and deserialization (no compression)
  * 
  */
 public class SerializationReinitTest extends TestCase {
@@ -103,7 +104,9 @@
   public static final String OBYTEA_TYPE_FEAT = "theByteArray";
   
   public static final String OSHORTA_TYPE_FEAT = "theShortArray";
-  
+
+  public static final String OLONGA_TYPE_FEAT = "theLongArray";
+
   public static final String OLONG_TYPE_FEAT = "theLong";
 
   private CASMgr casMgr;
@@ -140,6 +143,8 @@
   
   private Feature theShortArrayFeature;
   
+  private Feature theLongArrayFeature;
+  
   private Feature theLongFeature;
   
   private FsIndexDescription[] indexes;
@@ -155,6 +160,14 @@
    * @see junit.framework.TestCase#setUp()
    */
   public void setUp() throws Exception {
+    
+    /**
+     * sets up two type systems:
+     *   One defined via API calls, and set into the global var cas = casMgr
+     *   One defined by parsing ExampleCas/testTypeSystem and setting
+     *     typeSystem and indexes
+     */
+    
     super.setUp();
     casMgr = initCAS();
     cas = (CASImpl)casMgr;
@@ -178,6 +191,7 @@
     theShortFeature = ts.getFeatureByFullName(OSTR_TYPE + TypeSystem.FEATURE_SEPARATOR + OSHORT_TYPE_FEAT);
     theShortArrayFeature = ts.getFeatureByFullName(OSTR_TYPE + TypeSystem.FEATURE_SEPARATOR + OSHORTA_TYPE_FEAT);
     theLongFeature = ts.getFeatureByFullName(OSTR_TYPE + TypeSystem.FEATURE_SEPARATOR + OLONG_TYPE_FEAT);
+    theLongArrayFeature = ts.getFeatureByFullName(OSTR_TYPE + TypeSystem.FEATURE_SEPARATOR + OLONGA_TYPE_FEAT);
  
   
     File typeSystemFile = JUnitExtension.getFile("ExampleCas/testTypeSystem.xml");
@@ -238,6 +252,7 @@
     Type byteArrayType = tsa.getType(CAS.TYPE_NAME_BYTE_ARRAY);
     Type shortType = tsa.getType(CAS.TYPE_NAME_SHORT);
     Type shortArrayType = tsa.getType(CAS.TYPE_NAME_SHORT_ARRAY);
+    Type longArrayType = tsa.getType(CAS.TYPE_NAME_LONG_ARRAY);
     Type longType = tsa.getType(CAS.TYPE_NAME_LONG);
     Type theTypeType = tsa.addType(OSTR_TYPE, annotType);
     tsa.addFeature(OSTR_TYPE_FEAT, theTypeType, stringType);
@@ -245,6 +260,7 @@
     tsa.addFeature(OSHORT_TYPE_FEAT, theTypeType, shortType);
     tsa.addFeature(OBYTEA_TYPE_FEAT, theTypeType, byteArrayType);
     tsa.addFeature(OSHORTA_TYPE_FEAT, theTypeType, shortArrayType);
+    tsa.addFeature(OLONGA_TYPE_FEAT,  theTypeType,  longArrayType);
     tsa.addFeature(OLONG_TYPE_FEAT, theTypeType, longType);
     // Commit the type system.
     ((CASImpl) aCas).commitTypeSystem();
@@ -407,7 +423,8 @@
     // System.out.println("Created " + endOfSentenceCounter + " sentences: " + new TimeSpan(time));
   }
   
-  private static final Pattern nlPattern = Pattern.compile("(?m)(.*?$)");
+  //?m (MULTILINE) makes $ match just before line terminator or end of input
+  private static final Pattern nlPattern = Pattern.compile("(?m)(.*?$)"); 
   /**
    * Test driver.
    */
@@ -504,124 +521,6 @@
 
   }
 
-  /**
-   * Test setCAS().
-   */
-  public void testSetCAS() throws Exception {
-
-    // Read the document into a String. 
-    File textFile = JUnitExtension.getFile("data/moby.txt");
-    String moby = FileUtils.file2String(textFile);
-    // String moby = file2String(System.getProperty("cas.data.test") + "moby.txt");
-    String line;
-//    BufferedReader br = new BufferedReader(new StringReader(moby));
-    StringBuffer buf = new StringBuffer(10000);
-    List<String> docs = new ArrayList<String>();
-    Matcher m = nlPattern.matcher(moby);
-    while (m.find()) {
-      line = m.group();
-      if (line.startsWith(".. <p")) {
-        docs.add(buf.toString());
-        buf.setLength(0);
-      } else {
-        buf.append(line + "\n");
-      }
-    }
-    
-//    while ((line = br.readLine()) != null) {
-//      if (line.startsWith(".. <p")) {
-//        docs.add(buf.toString());
-//        buf = new StringBuffer();
-//      } else {
-//        buf.append(line + "\n");
-//      }
-//    }
-//    docs.add(buf.toString());
-    m.appendTail(buf);
-    docs.add(buf.toString()); 
-    buf = null;
-
-    final int numDocs = docs.size();
-    final int max = 30;
-    int docCount = 0;
-    long overallTime = System.currentTimeMillis();
-    int numTok, numSent;
-    while (docCount < max) {
-      for (int i = 0; i < numDocs && docCount < max; i++) {
-        // System.out.println("Processing document: " + i);
-        // Set document text in first CAS.
-        cas.setDocumentText(docs.get(i));
-
-        tokenize();
-        numTok = cas.getAnnotationIndex(tokenType).size();
-        assertTrue(numTok > 0);
-        // System.out.println(" Number of tokens: " + numTok);
-
-        // System.out.println("Serializing...");
-        // CASMgr casMgr = CASFactory.createCAS();
-        // casMgr.setCAS(cas);
-        // cas = (CAS) casMgr.getCAS();
-        /* setCAS is no longer used or implemented
-         * You cannot use this method to set up a new cas with a copy of
-         * the contents of another cas, including its indexes
-        CASMgr realCasMgr = CASFactory.createCAS(cas.getTypeSystem());
-        realCasMgr.setCAS(((CASImpl) cas).getBaseCAS());
-        cas = ((CASImpl) realCasMgr).getCurrentView();
-        casMgr = (CASMgr) cas;
-        */
-
-        assertTrue(numTok == cas.getAnnotationIndex(tokenType).size());
-
-        createSentences();
-        numSent = cas.getAnnotationIndex(sentenceType).size();
-        assertTrue(numSent > 0);
-        // System.out.println(" Number of sentences: " + numSent);
-
-        // System.out.println("Serializing...");
-        // casMgr = CASFactory.createCAS();
-        // casMgr.setCAS(cas);
-        // cas = (CAS) casMgr.getCAS();
-        /* setCAS is no longer used or implemented
-         * You cannot use this method to set up a new cas with a copy of
-         * the contents of another cas, including its indexes
-        realCasMgr = CASFactory.createCAS();
-        realCasMgr.setCAS(((CASImpl) cas).getBaseCAS());
-        cas = ((CASImpl) realCasMgr).getCurrentView();
-        casMgr = (CASMgr) cas;
-        */
-
-        assertTrue(numTok == cas.getAnnotationIndex(tokenType).size());
-        assertTrue(numSent == cas.getAnnotationIndex(sentenceType).size());
-
-        // System.out.println("Serializing...");
-        // casMgr = CASFactory.createCAS();
-        // casMgr.setCAS(cas);
-        // cas = (CAS) casMgr.getCAS();
-        /* setCAS is no longer used or implemented
-         * You cannot use this method to set up a new cas with a copy of
-         * the contents of another cas, including its indexes
-        realCasMgr = CASFactory.createCAS();
-        realCasMgr.setCAS(((CASImpl) cas).getBaseCAS());
-        cas = ((CASImpl) realCasMgr).getCurrentView();
-        casMgr = (CASMgr) cas;
-        */
-
-        assertTrue(numTok == cas.getAnnotationIndex(tokenType).size());
-        assertTrue(numSent == cas.getAnnotationIndex(sentenceType).size());
-        // System.out.println(" Verify: " + numTok + " tokens, " + numSent + " sentences.");
-
-        casMgr.reset();
-
-        ++docCount;
-      }
-      // System.out.println("Number of documents processed: " + docCount);
-    }
-    overallTime = System.currentTimeMillis() - overallTime;
-    // System.out.println("Time taken over all: " + new TimeSpan(overallTime));
-
-  }
-
-
   /** Test basic blob serialization
    */
   public void testBlob() throws Exception {
@@ -708,6 +607,73 @@
     }  
   }
 
+  public void testDeltaBinaryShortLongArrayMods() throws Exception {
+    CASImpl cas2 = (CASImpl) initCAS();
+    CASImpl cas3 = (CASImpl) initCAS();
+
+    // create short array and long array
+    FeatureStructure newFS1 = cas.createFS(theTypeType); 
+    ByteArrayFS newBA1 = cas.createByteArrayFS(1); 
+    ShortArrayFS newSA1 = cas.createShortArrayFS(1); 
+    LongArrayFS newLA1 = cas.createLongArrayFS(1);
+    newBA1.set(0, (byte)1);
+    newSA1.set(0, (short)2);
+    newLA1.set(0, (long)4);
+    newFS1.setFeatureValue(theByteArrayFeature, newBA1);
+    newFS1.setFeatureValue(theShortArrayFeature, newSA1);
+    newFS1.setFeatureValue(theLongArrayFeature, newLA1);
+    cas.getIndexRepository().addFS(newFS1);
+        
+    //serialize binary, non compressed, not delta
+    ByteArrayOutputStream fos = new ByteArrayOutputStream();
+    Serialization.serializeCAS(cas, fos);
+
+    //deserialize into cas2
+    ByteArrayInputStream fis = new ByteArrayInputStream(fos.toByteArray());
+    Serialization.deserializeCAS(cas2, fis);
+    CasComparer.assertEquals(cas, cas2);
+
+    //=======================================================================
+    //create Marker, add/modify fs and serialize in delta xmi format.
+    Marker marker = cas2.createMarker();
+
+    // modify a value in the int arrays
+    Iterator<AnnotationFS> typeIterator = cas2.getAnnotationIndex(theTypeType).iterator();
+    assertTrue(typeIterator.hasNext());
+    FeatureStructure fsWithArrays = typeIterator.next();
+    
+    ((ByteArrayFS)fsWithArrays.getFeatureValue(theByteArrayFeature)).set(0, (byte) 11);
+    ((ShortArrayFS)fsWithArrays.getFeatureValue(theShortArrayFeature)).set(0, (short) 22);
+    ((LongArrayFS)fsWithArrays.getFeatureValue(theLongArrayFeature)).set(0, (long) 44);
+
+    // serialize cas2 in delta format 
+    ByteArrayOutputStream fosDelta = new ByteArrayOutputStream();
+    Serialization.serializeCAS(cas2, fosDelta, marker);
+    
+    //======================================================================
+    //deserialize delta binary into cas1
+    ByteArrayInputStream fisDelta = new ByteArrayInputStream(fosDelta.toByteArray());
+    Serialization.deserializeCAS(cas, fisDelta);
+    
+    //======================================================================
+    //serialize complete cas and deserialize into cas3 and compare with cas1.
+    ByteArrayOutputStream fosFull = new ByteArrayOutputStream();
+    Serialization.serializeCAS(cas2, fosFull);
+    ByteArrayInputStream fisFull = new ByteArrayInputStream(fosFull.toByteArray());
+    Serialization.deserializeCAS(cas3, fisFull);
+    CasComparer.assertEquals(cas, cas3); 
+
+  }
+  
+  
+  /**
+   * setup cas1, binary (not compressed) serialize to cas2
+   * modify cas2, binary (not compressed) delta serialize back into cas1 
+   * 
+   * serialize cas2 binary (not compressed) not delta into cas3, compare cas 1 and 3
+   * 
+   * @throws Exception
+   */
   public void testDeltaBlobSerialization() throws Exception {
    try {
       CAS cas1 = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(),
@@ -775,7 +741,7 @@
       firstNode.setFeatureValue(headFeat, anAnnot1);
       firstNode.setFeatureValue(tailFeat, secondNode);
       entityFS.setFeatureValue(linksFeat, firstNode);
-      
+            
       // create a view w/o setting document text
       CAS view1 = cas1.createView("View1");
       
@@ -795,7 +761,7 @@
       relArgs.setFeatureValue(domainFeat, person1Annot);
       ownerAnnot.setFeatureValue(argsFeat, relArgs);
       
-      //serialize complete 
+      //serialize binary, non compressed, not delta
       ByteArrayOutputStream fos = new ByteArrayOutputStream();
       Serialization.serializeCAS(cas1, fos);
 
@@ -875,7 +841,7 @@
       cas2strarrayFS.set(2, "class3");
       cas2strarrayFS.set(3, "class4");
       cas2strarrayFS.set(4, "class5");
-     
+           
       //add to FSList 
       FeatureStructure cas2linksFS = cas2EntityFS.getFeatureValue(linksFeat);
       FeatureStructure cas2secondNode = cas2linksFS.getFeatureValue(tailFeat);
@@ -890,7 +856,7 @@
       Serialization.serializeCAS(cas2, fosDelta, marker);
       
       //======================================================================
-      //deserialize delta xmi into cas1
+      //deserialize delta binary into cas1
       ByteArrayInputStream fisDelta = new ByteArrayInputStream(fosDelta.toByteArray());
       Serialization.deserializeCAS(cas1, fisDelta);
       
@@ -950,4 +916,121 @@
     junit.textui.TestRunner.run(SerializationReinitTest.class);
   }
 
+  /**
+   * Test setCAS().
+   * This test does nothing useful.  setCAS is a no-op
+   */
+//  public void testSetCAS() throws Exception {
+//
+//    // Read the document into a String. 
+//    File textFile = JUnitExtension.getFile("data/moby.txt");
+//    String moby = FileUtils.file2String(textFile);
+//    // String moby = file2String(System.getProperty("cas.data.test") + "moby.txt");
+//    String line;
+////    BufferedReader br = new BufferedReader(new StringReader(moby));
+//    StringBuffer buf = new StringBuffer(10000);
+//    List<String> docs = new ArrayList<String>();
+//    Matcher m = nlPattern.matcher(moby);
+//    while (m.find()) {
+//      line = m.group();
+//      if (line.startsWith(".. <p")) {
+//        docs.add(buf.toString());
+//        buf.setLength(0);
+//      } else {
+//        buf.append(line + "\n");
+//      }
+//    }
+//    
+////    while ((line = br.readLine()) != null) {
+////      if (line.startsWith(".. <p")) {
+////        docs.add(buf.toString());
+////        buf = new StringBuffer();
+////      } else {
+////        buf.append(line + "\n");
+////      }
+////    }
+////    docs.add(buf.toString());
+//    m.appendTail(buf);
+//    docs.add(buf.toString()); 
+//    buf = null;
+//
+//    final int numDocs = docs.size();
+//    final int max = 30;
+//    int docCount = 0;
+//    long overallTime = System.currentTimeMillis();
+//    int numTok, numSent;
+//    while (docCount < max) {
+//      for (int i = 0; i < numDocs && docCount < max; i++) {
+//        // System.out.println("Processing document: " + i);
+//        // Set document text in first CAS.
+//        cas.setDocumentText(docs.get(i));
+//
+//        tokenize();
+//        numTok = cas.getAnnotationIndex(tokenType).size();
+//        assertTrue(numTok > 0);
+//        // System.out.println(" Number of tokens: " + numTok);
+//
+//        // System.out.println("Serializing...");
+//        // CASMgr casMgr = CASFactory.createCAS();
+//        // casMgr.setCAS(cas);
+//        // cas = (CAS) casMgr.getCAS();
+//        /* setCAS is no longer used or implemented
+//         * You cannot use this method to set up a new cas with a copy of
+//         * the contents of another cas, including its indexes
+//        CASMgr realCasMgr = CASFactory.createCAS(cas.getTypeSystem());
+//        realCasMgr.setCAS(((CASImpl) cas).getBaseCAS());
+//        cas = ((CASImpl) realCasMgr).getCurrentView();
+//        casMgr = (CASMgr) cas;
+//        */
+//
+//        assertTrue(numTok == cas.getAnnotationIndex(tokenType).size());
+//
+//        createSentences();
+//        numSent = cas.getAnnotationIndex(sentenceType).size();
+//        assertTrue(numSent > 0);
+//        // System.out.println(" Number of sentences: " + numSent);
+//
+//        // System.out.println("Serializing...");
+//        // casMgr = CASFactory.createCAS();
+//        // casMgr.setCAS(cas);
+//        // cas = (CAS) casMgr.getCAS();
+//        /* setCAS is no longer used or implemented
+//         * You cannot use this method to set up a new cas with a copy of
+//         * the contents of another cas, including its indexes
+//        realCasMgr = CASFactory.createCAS();
+//        realCasMgr.setCAS(((CASImpl) cas).getBaseCAS());
+//        cas = ((CASImpl) realCasMgr).getCurrentView();
+//        casMgr = (CASMgr) cas;
+//        */
+//
+//        assertTrue(numTok == cas.getAnnotationIndex(tokenType).size());
+//        assertTrue(numSent == cas.getAnnotationIndex(sentenceType).size());
+//
+//        // System.out.println("Serializing...");
+//        // casMgr = CASFactory.createCAS();
+//        // casMgr.setCAS(cas);
+//        // cas = (CAS) casMgr.getCAS();
+//        /* setCAS is no longer used or implemented
+//         * You cannot use this method to set up a new cas with a copy of
+//         * the contents of another cas, including its indexes
+//        realCasMgr = CASFactory.createCAS();
+//        realCasMgr.setCAS(((CASImpl) cas).getBaseCAS());
+//        cas = ((CASImpl) realCasMgr).getCurrentView();
+//        casMgr = (CASMgr) cas;
+//        */
+//
+//        assertTrue(numTok == cas.getAnnotationIndex(tokenType).size());
+//        assertTrue(numSent == cas.getAnnotationIndex(sentenceType).size());
+//        // System.out.println(" Verify: " + numTok + " tokens, " + numSent + " sentences.");
+//
+//        casMgr.reset();
+//
+//        ++docCount;
+//      }
+//      // System.out.println("Number of documents processed: " + docCount);
+//    }
+//    overallTime = System.currentTimeMillis() - overallTime;
+//    // System.out.println("Time taken over all: " + new TimeSpan(overallTime));
+//
+//  }
 }