@Test public void callsPreDestroyMethodsForSingletonComponentsOnStop() throws Exception { EchoResource resource = new EchoResource(); Application application = mock(Application.class); when(application.getSingletons()).thenReturn(newHashSet(resource)); when(requestHandler.getResources()).thenReturn(mock(ResourceBinder.class)); everrestProcessor.addApplication(application); everrestProcessor.stop(); assertEquals(1, resource.preDestroyActionInvocationsCounter.get()); }