[#if coverImage??]
    [#if coverImage?is_hash]
        [#if coverImage.alt??]
            ${coverImage.alt}
        [/#if]
    [/#if]
[/#if]

[JAVA] Comment tester un println?

Pour tester un println sur la console en Java, il faut détourner l'output stream et tester sa valeur.

En code:

PrintStream out = System.out;
try {
    ByteArrayOutputStream bo = new ByteArrayOutputStream();
    System.setOut(new PrintStream(bo));
    classUnderTest.fire();
    bo.flush();
    String allWrittenLines = new String(bo.toByteArray());
    assertTrue(allWrittenLines.contains("Running action associated with '1:initial_TO_in progress'"));
} catch (Exception e) {
    e.printStackTrace();
    fail("Exception raised");
} finally {
    System.setOut(out);
}