Ticket #19407: 19407.printwriter.patch

File 19407.printwriter.patch, 1.7 KB (added by taylor.smock, 4 years ago)

Use StringWriter/PrintWriter to produce the output to be checked. This ensures that the appropriate line endings are used for the platform.

  • test/unit/org/openstreetmap/josm/command/SequenceCommandTest.java

     
    339339        ReportedException reportedException = assertThrows(ReportedException.class, command::executeCommand);
    340340        StringWriter stringWriter = new StringWriter();
    341341        reportedException.printReportDataTo(new PrintWriter(stringWriter));
    342         assertEquals("=== REPORTED CRASH DATA ===\n" +
    343                 "sequence_information:\n" +
    344                 " - sequence_name: Sequence: test\n" +
    345                 " - sequence_command: foo command\n" +
    346                 " - sequence_index: 0\n" +
    347                 " - sequence_commands: [null]\n" +
    348                 " - sequence_commands_descriptions: [foo command]\n" +
    349                 "\n", stringWriter.toString());
     342
     343        StringWriter expected = new StringWriter();
     344        PrintWriter expectedPrintWriter = new PrintWriter(expected);
     345        expectedPrintWriter.println("=== REPORTED CRASH DATA ===");
     346        expectedPrintWriter.println("sequence_information:");
     347        expectedPrintWriter.println(" - sequence_name: Sequence: test");
     348        expectedPrintWriter.println(" - sequence_command: foo command");
     349        expectedPrintWriter.println(" - sequence_index: 0");
     350        expectedPrintWriter.println(" - sequence_commands: [null]");
     351        expectedPrintWriter.println(" - sequence_commands_descriptions: [foo command]");
     352        expectedPrintWriter.println("");
     353        assertEquals(expected.toString(), stringWriter.toString());
    350354    }
    351355}