Пример #1
0
  @Test
  public void writeTest() {
    File file = new File("auditlog_test.log");
    if (file.exists()) {
      file.delete();
    }

    Audit audit = new Audit("TEST", ApplicationType.VIRKAILIJA);
    LogMessage logMessage = builder().id("ID").message("Virkailija kirjautui sisään").build();
    audit.log(logMessage);

    assertTrue(file.exists());
    assertTrue(file.length() > 100);
    file.delete();
    assertFalse(file.exists());
  }
Пример #2
0
 private void verifyLogMessage(
     final LogMessage.LogMessageBuilder msg, final String expectedMessage) {
   Date now = date("2015-12-01 15:30+02:00");
   audit.log(msg.timestamp(now).build());
   ArgumentCaptor<String> infoCapture = ArgumentCaptor.forClass(String.class);
   verify(loggerMock, times(1)).info(infoCapture.capture());
   final String logMessage = infoCapture.getValue();
   assertEquals(jsonToMap(expectedMessage), jsonToMap(logMessage));
 }