Program: 66081
Project: 66081
Buggy source:
public void testSaveAndLoad() throws IOException, DataException {
  IDocArchiveWriter writer=new FileArchiveWriter(tempFile.getAbsolutePath());
  ICubeQueryDefinition toSave=createQueryDefn();
  CubeQueryDefinitionIOUtil.save(queryResultID,writer,toSave);
  writer.flush();
  writer.finish();
  IDocArchiveReader reader=new FileArchiveReader(tempFile.getAbsolutePath());
  ICubeQueryDefinition loaded=CubeQueryDefinitionIOUtil.load(queryResultID,reader);
  reader.close();
  assertEquals(toSave.getName(),loaded.getName());
  assertEquals(toSave.cacheQueryResults(),loaded.cacheQueryResults());
  assertEquals(toSave.getFilterOption(),loaded.getFilterOption());
  assertEqualBindings(toSave.getBindings(),loaded.getBindings());
  assertEquals(toSave.getFilters().size(),loaded.getFilters().size());
  for (int i=0; i < toSave.getFilters().size(); i++) {
    assertEqualFilter((IFilterDefinition)toSave.getFilters().get(i),(IFilterDefinition)loaded.getFilters().get(i));
  }
  assertEquals(toSave.getSorts().size(),loaded.getSorts().size());
  for (int i=0; i < toSave.getSorts().size(); i++) {
    assertEqualSortDefinition((ISortDefinition)toSave.getSorts().get(i),(ISortDefinition)loaded.getSorts().get(i));
  }
  assertEquals(toSave.getMeasures().size(),loaded.getMeasures().size());
  for (int i=0; i < toSave.getMeasures().size(); i++) {
    assertEqualMeasure((IMeasureDefinition)toSave.getMeasures().get(i),(IMeasureDefinition)loaded.getMeasures().get(i));
  }
  assertEquals(toSave.getComputedMeasures().size(),loaded.getComputedMeasures().size());
  for (int i=0; i < toSave.getComputedMeasures().size(); i++) {
    assertEqualComputedMeasure((IComputedMeasureDefinition)toSave.getComputedMeasures().get(i),(IComputedMeasureDefinition)loaded.getComputedMeasures().get(i));
  }
  assertEqualEdge(toSave.getEdge(ICubeQueryDefinition.ROW_EDGE),loaded.getEdge(ICubeQueryDefinition.ROW_EDGE));
  assertEqualEdge(toSave.getEdge(ICubeQueryDefinition.COLUMN_EDGE),loaded.getEdge(ICubeQueryDefinition.COLUMN_EDGE));
  assertEqualEdge(toSave.getEdge(ICubeQueryDefinition.PAGE_EDGE),loaded.getEdge(ICubeQueryDefinition.PAGE_EDGE));
  assertEquals(toSave.getCubeOperations().length,loaded.getCubeOperations().length);
  for (int i=0; i < toSave.getCubeOperations().length; i++) {
    assertEqualCubeOperation(toSave.getCubeOperations()[i],loaded.getCubeOperations()[i]);
  }
}

Fixed version (ground truth):
public void testSaveAndLoad() throws IOException, BirtException {
  IDocArchiveWriter writer=new FileArchiveWriter(tempFile.getAbsolutePath());
  ICubeQueryDefinition toSave=createQueryDefn();
  CubeQueryDefinitionIOUtil.save(queryResultID,writer,toSave);
  writer.flush();
  writer.finish();
  IDocArchiveReader reader=new FileArchiveReader(tempFile.getAbsolutePath());
  ICubeQueryDefinition loaded=CubeQueryDefinitionIOUtil.load(queryResultID,DataEngineContext.newInstance(DataEngineContext.MODE_UPDATE,null,reader,writer));
  reader.close();
  assertEquals(toSave.getName(),loaded.getName());
  assertEquals(toSave.cacheQueryResults(),loaded.cacheQueryResults());
  assertEquals(toSave.getFilterOption(),loaded.getFilterOption());
  assertEqualBindings(toSave.getBindings(),loaded.getBindings());
  assertEquals(toSave.getFilters().size(),loaded.getFilters().size());
  for (int i=0; i < toSave.getFilters().size(); i++) {
    assertEqualFilter((IFilterDefinition)toSave.getFilters().get(i),(IFilterDefinition)loaded.getFilters().get(i));
  }
  assertEquals(toSave.getSorts().size(),loaded.getSorts().size());
  for (int i=0; i < toSave.getSorts().size(); i++) {
    assertEqualSortDefinition((ISortDefinition)toSave.getSorts().get(i),(ISortDefinition)loaded.getSorts().get(i));
  }
  assertEquals(toSave.getMeasures().size(),loaded.getMeasures().size());
  for (int i=0; i < toSave.getMeasures().size(); i++) {
    assertEqualMeasure((IMeasureDefinition)toSave.getMeasures().get(i),(IMeasureDefinition)loaded.getMeasures().get(i));
  }
  assertEquals(toSave.getComputedMeasures().size(),loaded.getComputedMeasures().size());
  for (int i=0; i < toSave.getComputedMeasures().size(); i++) {
    assertEqualComputedMeasure((IComputedMeasureDefinition)toSave.getComputedMeasures().get(i),(IComputedMeasureDefinition)loaded.getComputedMeasures().get(i));
  }
  assertEqualEdge(toSave.getEdge(ICubeQueryDefinition.ROW_EDGE),loaded.getEdge(ICubeQueryDefinition.ROW_EDGE));
  assertEqualEdge(toSave.getEdge(ICubeQueryDefinition.COLUMN_EDGE),loaded.getEdge(ICubeQueryDefinition.COLUMN_EDGE));
  assertEqualEdge(toSave.getEdge(ICubeQueryDefinition.PAGE_EDGE),loaded.getEdge(ICubeQueryDefinition.PAGE_EDGE));
  assertEquals(toSave.getCubeOperations().length,loaded.getCubeOperations().length);
  for (int i=0; i < toSave.getCubeOperations().length; i++) {
    assertEqualCubeOperation(toSave.getCubeOperations()[i],loaded.getCubeOperations()[i]);
  }
}