@Test public void handleContextStoppedEventTest() { processApplicationEventPublisher.setApplicationContext(publisherMock); ContextClosedEvent contextClosedEventMock = mock(ContextClosedEvent.class); processApplicationEventPublisher.handleContextStoppedEvent(contextClosedEventMock); verify(publisherMock, never()).publishEvent(Mockito.any(ProcessApplicationStoppedEvent.class)); when(contextClosedEventMock.getApplicationContext()).thenReturn(publisherMock); processApplicationEventPublisher.handleContextStoppedEvent(contextClosedEventMock); verify(publisherMock).publishEvent(Mockito.any(ProcessApplicationStoppedEvent.class)); }
@EventListener public void handleContextStoppedEvent(final ContextClosedEvent contextStoppedEvent) { if (parentContext == contextStoppedEvent.getApplicationContext()) { publisher.publishEvent(new ProcessApplicationStoppedEvent(contextStoppedEvent)); } }
ProcessApplicationEventPublisher implements ApplicationContextAware { @EventListener public void handleContextStoppedEvent(final ContextClosedEvent contextStoppedEvent) { if (parentContext == contextStoppedEvent.getApplicationContext()) { publisher.publishEvent(new ProcessApplicationStoppedEvent(contextStoppedEvent)); } } }
ProcessApplicationEventPublisher implements ApplicationContextAware { @EventListener public void handleContextStoppedEvent(final ContextClosedEvent contextStoppedEvent) { if (parentContext == contextStoppedEvent.getApplicationContext()) { publisher.publishEvent(new ProcessApplicationStoppedEvent(contextStoppedEvent)); } } ProcessApplicationEventPublisher(final ApplicationEventPublisher publisher); }
ProcessApplicationEventPublisher implements ApplicationContextAware { @EventListener public void handleContextStoppedEvent(final ContextClosedEvent contextStoppedEvent) { if (parentContext == contextStoppedEvent.getApplicationContext()) { publisher.publishEvent(new ProcessApplicationStoppedEvent(contextStoppedEvent)); } } ProcessApplicationEventPublisher(final ApplicationEventPublisher publisher); @EventListener void handleApplicationReadyEvent(final ApplicationReadyEvent applicationReadyEvent); @EventListener void handleContextStoppedEvent(final ContextClosedEvent contextStoppedEvent); @Override void setApplicationContext(ApplicationContext applicationContext); }
ProcessApplicationEventPublisher implements ApplicationContextAware { @EventListener public void handleContextStoppedEvent(final ContextClosedEvent contextStoppedEvent) { if (parentContext == contextStoppedEvent.getApplicationContext()) { publisher.publishEvent(new ProcessApplicationStoppedEvent(contextStoppedEvent)); } } ProcessApplicationEventPublisher(final ApplicationEventPublisher publisher); @EventListener void handleApplicationReadyEvent(final ApplicationReadyEvent applicationReadyEvent); @EventListener void handleContextStoppedEvent(final ContextClosedEvent contextStoppedEvent); @Override void setApplicationContext(ApplicationContext applicationContext);  }