@PreDestroy public void destroy() { ShiroModule.this.destroy(); } };
@Test public void testDestroy() throws Exception { final MockRealm mockRealm = createMock(MockRealm.class); final MyDestroyable myDestroyable = createMock(MyDestroyable.class); myDestroyable.destroy(); replay(myDestroyable); final ShiroModule shiroModule = new ShiroModule() { @Override protected void configureShiro() { bindRealm().to(MockRealm.class); bind(MyDestroyable.class).toInstance(myDestroyable); expose(MyDestroyable.class); } @Provides public MockRealm createRealm() { return mockRealm; } }; Injector injector = Guice.createInjector(shiroModule); injector.getInstance(MyDestroyable.class); shiroModule.destroy(); verify(myDestroyable); }
@PreDestroy public void destroy() { ShiroModule.this.destroy(); } };