}
// Test merging with or without using delta CASes
private void testMerging(boolean useDeltas) throws Exception {
// deserialize a complex CAS from XCAS
CAS cas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
InputStream serCasStream = new FileInputStream(JUnitExtension.getFile("ExampleCas/cas.xml"));
XCASDeserializer.deserialize(serCasStream, cas);
serCasStream.close();
int numAnnotations = cas.getAnnotationIndex().size(); //for comparison later
String docText = cas.getDocumentText(); //for comparison later
//add a new Sofa to test that multiple Sofas in original CAS work
CAS preexistingView = cas.createView("preexistingView");
String preexistingViewText = "John Smith blah blah blah";
preexistingView.setDocumentText(preexistingViewText);
createPersonAnnot(preexistingView, 0, 10);
// do XMI serialization to a string, using XmiSerializationSharedData
// to keep track of maximum ID generated
XmiSerializationSharedData serSharedData = new XmiSerializationSharedData();
String xmiStr = serialize(cas, serSharedData);
int maxOutgoingXmiId = serSharedData.getMaxXmiId();
// deserialize into two new CASes, each with its own instance of XmiSerializationSharedData
// so we can get consistent IDs later when serializing back.
CAS newCas1 = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
XmiSerializationSharedData deserSharedData1 = new XmiSerializationSharedData();
deserialize(xmiStr, newCas1, deserSharedData1, false, -1);
CAS newCas2 = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
XmiSerializationSharedData deserSharedData2 = new XmiSerializationSharedData();
deserialize(xmiStr, newCas2, deserSharedData2, false, -1);
Marker marker1 = null;
Marker marker2 = null;