-
-
Save rmannibucau/86152958d9c139a45d4d80adbcc2c653 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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