@DeployableTestMethod
  @Test(timeout = 5000)
  public void testWritingAndReadingADataFileWithLotsOfVariables()
      throws IOException, RepeatDataBufferEntryException {
    File fileOne = new File(TEST_DIRECTORY + "fileOne.data.gz");

    if (fileOne.exists()) fileOne.delete();

    long seed = 1776L;
    int numberOfVariables = 2000; // 12000 for when testing long files for efficiency;
    Random random = new Random(seed);
    ArrayList<YoVariable<?>> variables = createALargeNumberOfVariables(random, numberOfVariables);
    YoVariableList originalVarList = new YoVariableList("originalVarList");
    originalVarList.addVariables(variables);

    int bufferSize = 50;
    DataBuffer dataBuffer = new DataBuffer(bufferSize);

    dataBuffer.addVariables(variables);

    for (int i = 0; i < bufferSize / 2; i++) {
      dataBuffer.setDataAtIndexToYoVariableValues();
      dataBuffer.tick(1);
    }

    dataBuffer.setInOutPointFullBuffer();

    Robot robot = new Robot("testWritingRobot");
    writeALongDataFile(fileOne, dataBuffer, variables, robot);

    System.out.println("Wrote File. Now reading it.");

    DataFileReader dataFileReader = new DataFileReader(fileOne);

    YoVariableList newVarList = new YoVariableList("newVarList");
    YoVariableRegistry registry = new YoVariableRegistry("rootRegistry");

    DataBuffer newDataBuffer = new DataBuffer();
    dataFileReader.readData(newVarList, registry, newDataBuffer);

    assertEquals(originalVarList.size(), newVarList.size());

    for (int i = 0; i < originalVarList.size(); i++) {
      YoVariable<?> originalVariable = originalVarList.getVariable(i);
      YoVariable<?> newVariable = newVarList.getVariable(originalVariable.getName());

      assertFalse(originalVariable == newVariable);
      assertEquals(originalVariable.getValueAsDouble(), newVariable.getValueAsDouble(), 1e-7);
    }

    fileOne.delete();
  }
  @DeployableTestMethod
  @Test(timeout = 5000)
  public void testWritingAndReadingALongStateFile() throws IOException {
    File fileOne = new File(TEST_DIRECTORY + "fileOne.state");

    if (fileOne.exists()) fileOne.delete();

    long seed = 1776L;
    int numberOfVariables = 2000; // 12000 for when testing long files for efficiency;
    Random random = new Random(seed);
    ArrayList<YoVariable<?>> variables = createALargeNumberOfVariables(random, numberOfVariables);
    YoVariableList originalVarList = new YoVariableList("originalVarList");
    originalVarList.addVariables(variables);

    writeALongStateFile(fileOne, variables);

    DataFileReader dataFileReader = new DataFileReader(fileOne);

    YoVariableList newVarList = new YoVariableList("newVarList");
    boolean createMissingVariables = true;
    boolean printErrorForMissingVariables = false;
    YoVariableRegistry registry = new YoVariableRegistry("root");

    dataFileReader.readState(
        newVarList, createMissingVariables, printErrorForMissingVariables, registry);

    assertEquals(originalVarList.size(), newVarList.size());

    for (int i = 0; i < originalVarList.size(); i++) {
      YoVariable<?> originalVariable = originalVarList.getVariable(i);
      YoVariable<?> newVariable = newVarList.getVariable(originalVariable.getName());

      assertFalse(originalVariable == newVariable);
      assertEquals(originalVariable.getValueAsDouble(), newVariable.getValueAsDouble(), 1e-7);
    }

    fileOne.delete();
  }
 public boolean compare(SimulationConstructionSet scs1, SimulationConstructionSet scs2) {
   // compare variables
   YoVariable var0 = getRootJoint(scs1).getQx();
   YoVariable var1 = getRootJoint(scs2).getQx();
   return (MathTools.epsilonEquals(var0.getValueAsDouble(), var1.getValueAsDouble(), epsilon));
 }