Program: 73587
Project: 73587
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()) {
          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","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);
    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();
}