newFS1.setStringValue(theStringFeature, testString);
newFS1.setByteValue(theByteFeature, (byte)cycle);
newFS1.setShortValue(theShortFeature, (short)cycle);
newFS1.setLongValue(theLongFeature, (long)cycle);
ByteArrayFS newBA1 = cas.createByteArrayFS(1);
ShortArrayFS newSA1 = cas.createShortArrayFS(1);
newBA1.set(0, (byte)cycle);
newSA1.set(0, (short)cycle);
newFS1.setFeatureValue(theByteArrayFeature, newBA1);
newFS1.setFeatureValue(theShortArrayFeature, newSA1);
FeatureStructure newFS2 = cas.createFS(theTypeType);
ByteArrayFS newBA2 = cas.createByteArrayFS(1);
ShortArrayFS newSA2 = cas.createShortArrayFS(1);
newFS2.setIntValue(startFeature, cycle+1);
newFS2.setIntValue(endFeature, cycle+2);
ir.addFS(newFS2);
// set string using lowlevel string create API
final int llfs2 = ll_cas.ll_getFSRef(newFS2);
final int llba2 = ll_cas.ll_getFSRef(newBA2);
final int llsa2 = ll_cas.ll_getFSRef(newSA2);
ll_cas.ll_setCharBufferValue(llfs2, ll_strfeatcode,
testString.toCharArray(), 0, testString.length());
ll_cas.ll_setByteValue(llfs2, ll_bytefeatcode, (byte)(cycle+1));
ll_cas.ll_setShortValue(llfs2, ll_shortfeatcode, (short)(cycle+1));
ll_cas.ll_setLongValue(llfs2, ll_longfeatcode, (long)(cycle+1));
ll_cas.ll_setByteArrayValue(llba2, 0, (byte)(cycle+1));
ll_cas.ll_setShortArrayValue(llsa2, 0, (short)(cycle+1));
newFS2.setFeatureValue(theByteArrayFeature, newBA2);
newFS2.setFeatureValue(theShortArrayFeature, newSA2);
ByteArrayOutputStream fos = new ByteArrayOutputStream();
Serialization.serializeCAS(cas, fos);
cas.reset();
ByteArrayInputStream fis = new ByteArrayInputStream(fos.toByteArray());
Serialization.deserializeCAS(cas, fis);
FSIndex<AnnotationFS> idx = cas.getAnnotationIndex(theTypeType);
FSIterator<AnnotationFS> iter = idx.iterator();
for (int tc=0; tc<cycle+1; tc++) {
FeatureStructure testFS = iter.get();
iter.moveToNext();
assertTrue(tc == testFS.getIntValue(startFeature));
assertTrue(testString.equals(testFS.getStringValue(theStringFeature)));
assertTrue(tc == testFS.getByteValue(theByteFeature));
assertTrue(tc == testFS.getShortValue(theShortFeature));
assertTrue(tc == testFS.getLongValue(theLongFeature));
ByteArrayFS ba = (ByteArrayFS)testFS.getFeatureValue(theByteArrayFeature);
assertTrue(tc == ba.get(0));
ShortArrayFS sa = (ShortArrayFS)testFS.getFeatureValue(theShortArrayFeature);
assertTrue(tc == sa.get(0));
}
}
}