MessageLoggingToggle implements ApplicationListener<ContextRefreshedEvent> { @Override public void onApplicationEvent(final ContextRefreshedEvent event) { PropertyDto properties = configurationAccess.getProperties(); String messageLogging = properties.getMessageLogging(); if (messageLogging != null && "off".equals(messageLogging)) { switchOffMessageLogging(); } }  @Override void onApplicationEvent(final ContextRefreshedEvent event); void switchOffMessageLogging(); void switchOnMessageLogging(); boolean isRequestLoggingOn(); boolean isResponseLoggingOn();  }
@Test public final void testOnApplicationEventShouldSwitchOffMessageLoggingWhenPropertyIsOff() { String messageLogging = "off"; PropertyDto properties = builder.messageLogging(messageLogging).build(); given(configurationAccess.getProperties()).willReturn(properties); underTest.onApplicationEvent(event); verify(requestHandler).disableProcessor(jmsRequestLogger); verify(responseHandler).disableProcessor(jmsResponseProcessor); }
@Test public final void testOnApplicationEventShouldNotSwitchOffMessageLoggingWhenPropertyIsOn() { String messageLogging = "on"; PropertyDto properties = builder.messageLogging(messageLogging).build(); given(configurationAccess.getProperties()).willReturn(properties); underTest.onApplicationEvent(event); verify(requestHandler, never()).disableProcessor(jmsRequestLogger); verify(responseHandler, never()).disableProcessor(jmsResponseProcessor); }
@Test public final void testOnApplicationEventShouldNotSwitchOffMessageLoggingWhenPropertyIsNull() { PropertyDto properties = builder.messageLogging(null).build(); given(configurationAccess.getProperties()).willReturn(properties); underTest.onApplicationEvent(event); verify(requestHandler, never()).disableProcessor(jmsRequestLogger); verify(responseHandler, never()).disableProcessor(jmsResponseProcessor); }