@Test
public void unexpectedOutput() throws Exception {

  // To reproduce, create a source file with two duplicate string item definitions
  createTempXmlFile();
  String output =
    "This output is not expected.\n" +
    "Nor is this.\n" +
    "java.io.SurpriseSurpriseError: Bet you didn't expect to see this\n" +
    "\tat com.android.ide.common.res2.ValueResourceParser2.checkSurpriseSurprise(ValueResourceParser2.java:249)\n" +
    "\tat com.android.ide.common.res2.ValueResourceParser2.parseFile(ValueResourceParser2.java:103)\n" +
    "\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)\n" +
    "\tat java.lang.Thread.run(Thread.java:680)\n" +
    "More unexpected output.\n" +
    "\n" +
    "FAILURE: Build failed with an exception.\n" +
    "\n" +
    "* What went wrong:\n" +
    "Execution failed for task ':MyApp:mergeDebugResources'.\n" +
    "> I was surprised\n" +
    "\n" +
    "* Try:\n" +
    "Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.\n";
  assertEquals("0: Simple:This output is not expected.\n" +
               "1: Simple:Nor is this.\n" +
               "2: Simple:java.io.SurpriseSurpriseError: Bet you didn't expect to see this\n" +
               "3: Simple:\tat com.android.ide.common.res2.ValueResourceParser2.checkSurpriseSurprise(ValueResourceParser2.java:249)\n" +
               "4: Simple:\tat com.android.ide.common.res2.ValueResourceParser2.parseFile(ValueResourceParser2.java:103)\n" +
               "5: Simple:\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)\n" +
               "6: Simple:\tat java.lang.Thread.run(Thread.java:680)\n" +
               "7: Simple:More unexpected output.\n" +
               "8: Error:Execution failed for task ':MyApp:mergeDebugResources'.\n" +
               "> I was surprised\n",
               toString(parser.parseGradleOutput(output)));
}