Log4JAccessLog extends AbstractLifeCycle implements RequestLog { public Log4JAccessLog(String accessConfigFilePath) { this(accessConfigFilePath, () -> true); } Log4JAccessLog(String accessConfigFilePath);  Log4JAccessLog(String accessConfigFilePath, Supplier<Boolean> isEnabledSupplier); @Override final void log(Request request, Response response);  }
@Test public void testLog4JAccessLog() throws Exception { try { failedAccessLog.startLog(); fail("Non existing access log; should fail, but didn't"); } catch(Exception e) { if (!e.getMessage().contains("Log4J access config file not found")) { fail("Non existing access log; but failed with some other error: " + e.getMessage()); } } try { enabledAccessLog.startLog(); } catch(Exception e) { fail("Existing access log; shouldn't fail: " + e.getMessage()); } enabledAccessLog.log(mockRequest, mockResponse); verify(mockLogger, times(1)).log(Level.INFO, mockAccessLog); try { disabledAccessLog.startLog(); } catch (Exception e) { fail("Existing access log; shouldn't fail: " + e.getMessage()); } disabledAccessLog.log(mockRequest, mockResponse); verify(mockLogger, times(1)).log(Level.INFO, mockAccessLog); }