private ArrayList<YoVariable<?>> createALargeNumberOfVariables(
      Random random, int numberOfVariables) {
    YoVariableRegistry rootRegistry = new YoVariableRegistry("rootRegistry");
    YoVariableRegistry registryOne = new YoVariableRegistry("registryOne");
    YoVariableRegistry registryTwo = new YoVariableRegistry("registryTwo");
    YoVariableRegistry registryThree = new YoVariableRegistry("registryThree");

    rootRegistry.addChild(registryOne);
    registryOne.addChild(registryTwo);
    registryTwo.addChild(registryThree);

    DoubleYoVariable t = new DoubleYoVariable("t", registryThree);
    DoubleYoVariable time = new DoubleYoVariable("time", registryThree);
    t.set(1.1);
    time.set(2.2);

    for (int i = 0; i < numberOfVariables; i++) {
      DoubleYoVariable variable = new DoubleYoVariable("variable" + i, registryThree);
      variable.set(Math.random());
    }

    return rootRegistry.getAllVariablesIncludingDescendants();
  }
  @DeployableTestMethod
  @Test(timeout = 300000)
  public void testDataFileWriterAndReader() throws IOException, RepeatDataBufferEntryException {
    int numDataPoints = 10000;

    DataBuffer dataBuffer = new DataBuffer(numDataPoints);

    YoVariableRegistry rootRegistry = new YoVariableRegistry("rootRegistry");
    YoVariableRegistry registryOne = new YoVariableRegistry("registryOne");
    YoVariableRegistry registryTwo = new YoVariableRegistry("registryTwo");
    YoVariableRegistry registryThree = new YoVariableRegistry("registryThree");

    rootRegistry.addChild(registryOne);
    rootRegistry.addChild(registryTwo);
    registryTwo.addChild(registryThree);

    DoubleYoVariable variableOne = new DoubleYoVariable("variableOne", rootRegistry);
    DoubleYoVariable variableTwo = new DoubleYoVariable("variableTwo", rootRegistry);
    DoubleYoVariable variableThree = new DoubleYoVariable("variableThree", rootRegistry);
    DoubleYoVariable variableFour = new DoubleYoVariable("variableFour", registryOne);
    DoubleYoVariable variableFive = new DoubleYoVariable("variableFive", registryTwo);
    BooleanYoVariable variableSix = new BooleanYoVariable("variableSix", rootRegistry);
    IntegerYoVariable variableSeven = new IntegerYoVariable("variableSeven", registryThree);

    dataBuffer.addVariable(variableOne);
    dataBuffer.addVariable(variableTwo);
    dataBuffer.addVariable(variableThree);
    dataBuffer.addVariable(variableFour);
    dataBuffer.addVariable(variableFive);
    dataBuffer.addVariable(variableSix);
    dataBuffer.addVariable(variableSeven);

    for (int i = 0; i < numDataPoints; i++) {
      variableOne.set(Math.random());
      variableTwo.set(Math.random());
      variableThree.set((int) (Math.random() * 100.0));
      variableFour.set((int) (Math.random() * 100.0));
      variableFive.set(Math.random());
      variableSix.set(Math.random() > 0.5);
      variableSeven.set((int) (Math.random() * 1000.0));

      dataBuffer.tickAndUpdate();
    }

    Robot robot = new Robot("testRobot");

    ArrayList<YoVariable<?>> allVariables = rootRegistry.getAllVariablesIncludingDescendants();

    boolean binary = false;
    boolean compress = false;
    boolean spreadsheetFormatted = true;
    testDataWriteReadIsTheSame(
        dataBuffer, allVariables, binary, compress, spreadsheetFormatted, robot);

    spreadsheetFormatted = false;
    testDataWriteReadIsTheSame(
        dataBuffer, allVariables, binary, compress, spreadsheetFormatted, robot);

    binary = true;
    compress = false;
    testDataWriteReadIsTheSame(
        dataBuffer, allVariables, binary, compress, spreadsheetFormatted, robot);

    binary = false;
    compress = true;
    testDataWriteReadIsTheSame(
        dataBuffer, allVariables, binary, compress, spreadsheetFormatted, robot);

    binary = true;
    compress = true;
    testDataWriteReadIsTheSame(
        dataBuffer, allVariables, binary, compress, spreadsheetFormatted, robot);
  }