Program: 73585
Project: 73585
Buggy source:
/** 
 * Test subQuery with mirrored level in crosstab
 * @throws Exception
 */
public void testSubQuery2() throws Exception {
  ICubeQueryDefinition cqd=new CubeQueryDefinition(cubeName);
  IEdgeDefinition columnEdge=cqd.createEdge(ICubeQueryDefinition.COLUMN_EDGE);
  IEdgeDefinition rowEdge=cqd.createEdge(ICubeQueryDefinition.ROW_EDGE);
  IDimensionDefinition dim1=columnEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier1=dim1.createHierarchy("String_Node_Str");
  ILevelDefinition level11=hier1.createLevel("String_Node_Str");
  ILevelDefinition level12=hier1.createLevel("String_Node_Str");
  ILevelDefinition level13=hier1.createLevel("String_Node_Str");
  columnEdge.setMirrorStartingLevel(level13);
  IDimensionDefinition dim2=rowEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier2=dim2.createHierarchy("String_Node_Str");
  ILevelDefinition level21=hier2.createLevel("String_Node_Str");
  createSortTestBindings(cqd);
  Context cx=null;
  try {
    cx=Context.enter();
    Scriptable sharedScope=cx.initStandardObjects();
    DataEngineImpl engine=(DataEngineImpl)DataEngine.newDataEngine(DataEngineContext.newInstance(DataEngineContext.DIRECT_PRESENTATION,sharedScope,null,null));
    this.createCube(engine);
    IPreparedCubeQuery pcq=engine.prepare(cqd,null);
    ICubeQueryResults cqResults=pcq.execute(sharedScope);
    ICubeCursor cubeCursor=(ICubeCursor)cqResults.getCubeCursor();
    Scriptable subScope=cx.newObject(sharedScope);
    subScope.setParentScope(sharedScope);
    int depth=0;
    Object value;
    EdgeCursor edge1=(EdgeCursor)(cubeCursor.getOrdinateEdge().get(0));
    EdgeCursor edge2=(EdgeCursor)(cubeCursor.getOrdinateEdge().get(1));
    edge1.beforeFirst();
    while (edge2.next()) {
      edge1.beforeFirst();
      while (edge1.next()) {
        depth++;
        value=cubeCursor.getObject("String_Node_Str");
        this.testPrintln("String_Node_Str" + value);
        ICubeCursor subCubeCursor=null;
        EdgeCursor subEdge1, subEdge2;
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str",null,null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str",null,null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str",null,null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor(null,"String_Node_Str",null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor(null,null,null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
      }
    }
    close(cubeCursor);
  }
  finally {
    if (cx != null)     cx.exit();
  }
  this.checkOutputFile();
}

Fixed version (ground truth):
/** 
 * Test subQuery with mirrored level in crosstab
 * @throws Exception
 */
public void testSubQuery2() throws Exception {
  ICubeQueryDefinition cqd=new CubeQueryDefinition(cubeName);
  IEdgeDefinition columnEdge=cqd.createEdge(ICubeQueryDefinition.COLUMN_EDGE);
  IEdgeDefinition rowEdge=cqd.createEdge(ICubeQueryDefinition.ROW_EDGE);
  IDimensionDefinition dim1=columnEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier1=dim1.createHierarchy("String_Node_Str");
  ILevelDefinition level11=hier1.createLevel("String_Node_Str");
  ILevelDefinition level12=hier1.createLevel("String_Node_Str");
  ILevelDefinition level13=hier1.createLevel("String_Node_Str");
  columnEdge.setMirrorStartingLevel(level13);
  IDimensionDefinition dim2=rowEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier2=dim2.createHierarchy("String_Node_Str");
  ILevelDefinition level21=hier2.createLevel("String_Node_Str");
  createSortTestBindings(cqd);
  Context cx=null;
  try {
    cx=Context.enter();
    Scriptable sharedScope=cx.initStandardObjects();
    DataEngineImpl engine=(DataEngineImpl)DataEngine.newDataEngine(DataEngineContext.newInstance(DataEngineContext.DIRECT_PRESENTATION,sharedScope,null,null));
    this.createCube(engine);
    IPreparedCubeQuery pcq=engine.prepare(cqd,null);
    ICubeQueryResults cqResults=pcq.execute(sharedScope);
    ICubeCursor cubeCursor=(ICubeCursor)cqResults.getCubeCursor();
    Scriptable subScope=cx.newObject(sharedScope);
    subScope.setParentScope(sharedScope);
    int depth=0;
    Object value;
    EdgeCursor edge1=(EdgeCursor)(cubeCursor.getOrdinateEdge().get(0));
    EdgeCursor edge2=(EdgeCursor)(cubeCursor.getOrdinateEdge().get(1));
    edge1.beforeFirst();
    while (edge2.next()) {
      edge1.beforeFirst();
      while (edge1.next()) {
        value=cubeCursor.getObject("String_Node_Str");
        if (value != null)         this.testPrintln("String_Node_Str" + value);
 else         continue;
        ICubeCursor subCubeCursor=null;
        EdgeCursor subEdge1, subEdge2;
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str",null,null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str",null,null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            if (value != null)             this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str",null,null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor(null,"String_Node_Str",null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
        subCubeCursor=cubeCursor.getSubCubeCursor(null,null,null,subScope);
        subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            this.testPrint(subCubeCursor.getObject("String_Node_Str") + "String_Node_Str");
          }
        }
      }
    }
    close(cubeCursor);
  }
  finally {
    if (cx != null)     cx.exit();
  }
  this.checkOutputFile();
}