Program: 73616
Project: 73616
Buggy source:
/** 
 * Test subQuery in crosstab
 * @throws Exception
 */
public void testSubQuery1() 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);
    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();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          List dimension=subEdge2.getDimensionCursor();
          for (int i=0; i < dimension.size(); i++) {
            DimensionCursor dim=(DimensionCursor)dimension.get(i);
            System.out.println("String_Node_Str" + i + "String_Node_Str"+ dim.getEdgeStart()+ "String_Node_Str"+ dim.getEdgeEnd()+ "String_Node_Str");
          }
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            depth++;
            List dimensions=subEdge1.getDimensionCursor();
            for (int i=0; i < dimensions.size(); i++) {
              DimensionCursor dim=(DimensionCursor)dimensions.get(i);
              System.out.println("String_Node_Str" + i + "String_Node_Str"+ dim.getEdgeStart()+ "String_Node_Str"+ dim.getEdgeEnd()+ "String_Node_Str");
            }
            this.testPrint(subCubeCursor.getObject("String_Node_Str").toString() + "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").toString() + "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").toString() + "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").toString() + "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").toString() + "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").toString() + "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").toString() + "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").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 testSubQuery1() 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);
    ISubCubeQueryDefinition subQuery1=new SubCubeQueryDefinition("String_Node_Str","String_Node_Str","String_Node_Str");
    ISubCubeQueryDefinition subQuery2=new SubCubeQueryDefinition("String_Node_Str","String_Node_Str","String_Node_Str");
    ISubCubeQueryDefinition subQuery3=new SubCubeQueryDefinition("String_Node_Str","String_Node_Str","String_Node_Str");
    ISubCubeQueryDefinition subQuery4=new SubCubeQueryDefinition("String_Node_Str","String_Node_Str",null);
    ISubCubeQueryDefinition subQuery5=new SubCubeQueryDefinition("String_Node_Str","String_Node_Str",null);
    ISubCubeQueryDefinition subQuery6=new SubCubeQueryDefinition("String_Node_Str","String_Node_Str",null);
    ISubCubeQueryDefinition subQuery7=new SubCubeQueryDefinition("String_Node_Str",null,"String_Node_Str");
    ISubCubeQueryDefinition subQuery8=new SubCubeQueryDefinition("String_Node_Str",null,null);
    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=engine.prepare(subQuery1,null).execute(cqResults,subScope).getCubeCursor();
        EdgeCursor subEdge1=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(0));
        EdgeCursor subEdge2=(EdgeCursor)(subCubeCursor.getOrdinateEdge().get(1));
        subEdge2.beforeFirst();
        this.testPrintln("String_Node_Str");
        while (subEdge2.next()) {
          List dimension=subEdge2.getDimensionCursor();
          for (int i=0; i < dimension.size(); i++) {
            DimensionCursor dim=(DimensionCursor)dimension.get(i);
            System.out.println("String_Node_Str" + i + "String_Node_Str"+ dim.getEdgeStart()+ "String_Node_Str"+ dim.getEdgeEnd()+ "String_Node_Str");
          }
          subEdge1.beforeFirst();
          while (subEdge1.next()) {
            List dimensions=subEdge1.getDimensionCursor();
            for (int i=0; i < dimensions.size(); i++) {
              DimensionCursor dim=(DimensionCursor)dimensions.get(i);
              System.out.println("String_Node_Str" + i + "String_Node_Str"+ dim.getEdgeStart()+ "String_Node_Str"+ dim.getEdgeEnd()+ "String_Node_Str");
            }
            this.testPrint(subCubeCursor.getObject("String_Node_Str").toString() + "String_Node_Str");
          }
        }
        subCubeCursor=engine.prepare(subQuery2,null).execute(cqResults,subScope).getCubeCursor();
        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").toString() + "String_Node_Str");
          }
        }
        subCubeCursor=engine.prepare(subQuery3,null).execute(cqResults,subScope).getCubeCursor();
        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").toString() + "String_Node_Str");
          }
        }
        subCubeCursor=engine.prepare(subQuery4,null).execute(cqResults,subScope).getCubeCursor();
        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").toString() + "String_Node_Str");
          }
        }
        subCubeCursor=engine.prepare(subQuery5,null).execute(cqResults,subScope).getCubeCursor();
        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").toString() + "String_Node_Str");
          }
        }
        subCubeCursor=engine.prepare(subQuery6,null).execute(cqResults,subScope).getCubeCursor();
        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").toString() + "String_Node_Str");
          }
        }
        subCubeCursor=engine.prepare(subQuery7,null).execute(cqResults,subScope).getCubeCursor();
        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").toString() + "String_Node_Str");
          }
        }
        subCubeCursor=engine.prepare(subQuery8,null).execute(cqResults,subScope).getCubeCursor();
        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").toString() + "String_Node_Str");
          }
        }
      }
    }
    close(cubeCursor);
  }
  finally {
    if (cx != null)     cx.exit();
  }
  this.checkOutputFile();
}