Program: 73584
Project: 73584
Buggy source:
/** 
 * Test subQuery in crosstab
 * @throws Exception
 */
public void testSubQuery3() 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");
  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);
    Scriptable subSubScope=cx.newObject(sharedScope);
    subSubScope.setParentScope(sharedScope);
    int depth=0;
    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++;
        this.testPrintln("String_Node_Str" + cubeCursor.getObject("String_Node_Str").toString());
        ICubeCursor subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subScope);
        EdgeCursor subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        EdgeCursor subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            this.testPrintln("String_Node_Str" + subCubeCursor.getObject("String_Node_Str").toString() + "String_Node_Str");
            ICubeCursor subSubCubeCursor=subCubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subSubScope);
            EdgeCursor subSubEdge1=(EdgeCursor)(subSubCubeCursor.getOrdinateEdge().get(0));
            EdgeCursor subSubEdge2=(EdgeCursor)(subSubCubeCursor.getOrdinateEdge().get(1));
            subSubEdge2.beforeFirst();
            this.testPrintln("String_Node_Str");
            while (subSubEdge2.next()) {
              subSubEdge1.beforeFirst();
              while (subSubEdge1.next()) {
                depth++;
                this.testPrint(subSubCubeCursor.getObject("String_Node_Str").toString() + "String_Node_Str");
              }
            }
          }
        }
      }
    }
    close(cubeCursor);
  }
  finally {
    if (cx != null)     cx.exit();
  }
  this.checkOutputFile();
}

Fixed version (ground truth):
/** 
 * Test subQuery in crosstab
 * @throws Exception
 */
public void testSubQuery3() 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");
  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);
    Scriptable subSubScope=cx.newObject(sharedScope);
    subSubScope.setParentScope(sharedScope);
    int depth=0;
    EdgeCursor edge1=(EdgeCursor)(cubeCursor.getOrdinateEdge().get(0));
    EdgeCursor edge2=(EdgeCursor)(cubeCursor.getOrdinateEdge().get(1));
    edge1.beforeFirst();
    while (edge2.next()) {
      edge1.beforeFirst();
      while (edge1.next()) {
        this.testPrintln("String_Node_Str" + cubeCursor.getObject("String_Node_Str").toString());
        ICubeCursor subCubeCursor=cubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subScope);
        EdgeCursor subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        EdgeCursor subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        while (subEdge2.next()) {
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            this.testPrintln("String_Node_Str" + subCubeCursor.getObject("String_Node_Str").toString() + "String_Node_Str");
            ICubeCursor subSubCubeCursor=subCubeCursor.getSubCubeCursor("String_Node_Str","String_Node_Str",null,subSubScope);
            EdgeCursor subSubEdge1=(EdgeCursor)(subSubCubeCursor.getOrdinateEdge().get(0));
            EdgeCursor subSubEdge2=(EdgeCursor)(subSubCubeCursor.getOrdinateEdge().get(1));
            subSubEdge2.beforeFirst();
            this.testPrintln("String_Node_Str");
            while (subSubEdge2.next()) {
              subSubEdge1.beforeFirst();
              while (subSubEdge1.next()) {
                depth++;
                this.testPrint(subSubCubeCursor.getObject("String_Node_Str").toString() + "String_Node_Str");
              }
            }
          }
        }
      }
    }
    close(cubeCursor);
  }
  finally {
    if (cx != null)     cx.exit();
  }
  this.checkOutputFile();
}