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

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);
    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);
    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=engine.prepare(subQuery1,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") + "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") + "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") + "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") + "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") + "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") + "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") + "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") + "String_Node_Str");
          }
        }
      }
    }
    close(cubeCursor);
  }
  finally {
    if (cx != null)     cx.exit();
  }
  this.checkOutputFile();
}