CAS cas1 = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(),
indexes);
CAS cas2 = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(),
indexes);
cas1.setDocumentText("This is a test document in the initial view");
Type referentType = cas1.getTypeSystem().getType("org.apache.uima.testTypeSystem.Referent");
FeatureStructure fs1 = cas1.createFS(referentType);
cas1.getIndexRepository().addFS(fs1);
//serialize complete
XmiSerializationSharedData sharedData = new XmiSerializationSharedData();
String xml = serialize(cas1, sharedData);
System.out.println(xml);
int maxOutgoingXmiId = sharedData.getMaxXmiId();
//deserialize into cas2
XmiSerializationSharedData sharedData2 = new XmiSerializationSharedData();
this.deserialize(xml, cas2, sharedData2, true, -1);
CasComparer.assertEquals(cas1, cas2);
//create Marker, add/modify fs and serialize in delta xmi format.
Marker marker = cas2.createMarker();
//create View
CAS view = cas2.createView("NewView");
//add FS to index
Type referentType2 = cas2.getTypeSystem().getType("org.apache.uima.testTypeSystem.Referent");
Iterator<FeatureStructure> fsIter = cas2.getIndexRepository().getAllIndexedFS(referentType2);
while (fsIter.hasNext()) {
FeatureStructure fs = fsIter.next();
view.getIndexRepository().addFS(fs);
}