@Test
public void testIterationApp() throws Exception
{

  LocalMode lma = LocalMode.newInstance();
  Configuration conf = new Configuration(false);
  Application app = new Application();
  String outputFileName = "target/output.txt";
  long timeout = 10 * 1000; // 10 seconds
  new File(outputFileName).delete();
  app.setExtraOutputFileName(outputFileName);
  lma.prepareDAG(app, conf);
  LocalMode.Controller lc = lma.getController();
  lc.runAsync();
  long startTime = System.currentTimeMillis();
  do {
    try {
      Thread.sleep(500);
    } catch (InterruptedException ex) {
      break;
    }
    File file = new File(outputFileName);
    if (file.length() > 50) {
      break;
    }
  }
  while (System.currentTimeMillis() - startTime < timeout);
  lc.shutdown();
  try (BufferedReader br = new BufferedReader(new FileReader(outputFileName))) {
    Assert.assertEquals("1", br.readLine());
    Assert.assertEquals("1", br.readLine());
    Assert.assertEquals("2", br.readLine());
    Assert.assertEquals("3", br.readLine());
    Assert.assertEquals("5", br.readLine());
    Assert.assertEquals("8", br.readLine());
    Assert.assertEquals("13", br.readLine());
    Assert.assertEquals("21", br.readLine());
    Assert.assertEquals("34", br.readLine());
    Assert.assertEquals("55", br.readLine());
    Assert.assertEquals("89", br.readLine());
    Assert.assertEquals("144", br.readLine());
    Assert.assertEquals("233", br.readLine());
    Assert.assertEquals("377", br.readLine());
    Assert.assertEquals("610", br.readLine());
    Assert.assertEquals("987", br.readLine());
  }
}