Skip to content

Instantly share code, notes, and snippets.

@rmannibucau
Created July 13, 2017 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmannibucau/86152958d9c139a45d4d80adbcc2c653 to your computer and use it in GitHub Desktop.
Save rmannibucau/86152958d9c139a45d4d80adbcc2c653 to your computer and use it in GitHub Desktop.
@Classes
@SimpleLog
public class AppResourceLifecycleTest {
@Resource(name = "test")
private Resource resource;
@Module
public Resources resources() {
return new Resources() {{
getResource().add(new org.apache.openejb.config.sys.Resource() {{
setId("test");
setClassName(Resource.class.getName());
}});
}};
}
@Test
public void lifecycle() throws Exception {
new ApplicationComposers(this).evaluate(this, new Runnable() {
@Override
public void run() {
assertTrue(resource.init);
assertFalse(resource.destroy);
}
});
assertTrue(resource.init);
assertTrue(resource.destroy);
}
public static class Resource {
private boolean init;
private boolean destroy;
@PostConstruct
private void init() {
init = true;
}
@PreDestroy
private void destroy() {
destroy = true;
}
public boolean isInit() {
return init;
}
public boolean isDestroy() {
return destroy;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment