### Question:
ServiceComponent implements ApplicationEventPublisherAware, ApplicationContextAware { public void closeApplication() { publisher.publishEvent(new CleanConnEvent(context)); }  @Override void setApplicationContext(ApplicationContext applicationContext); @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher); void closeApplication();  }### Answer:
@Test public void testContextClosedEvent() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-annotationEvent.xml"); ServiceComponent serviceComponent = context.getBean(ServiceComponent.class); serviceComponent.closeApplication(); }