injecting overlord in tests
John Sanda
jsanda at redhat.com
Thu Jan 24 03:27:57 UTC 2013
In lots of our server integration tests we obtain and use the overlord. I added a small utility to eliminate the boiler plate as well as the round trips to the database. Instead of doing,
public void myTest() {
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
Subject overlord = subjectManager.getOverlord();
….
}
you can alternatively do,
public class MyTest {
@Inject @Overlord
private Subject overlord;
}
This is more succinct, eliminating the dependency on SubjectManagerLocal for those frequent cases when you only want to get the overlord, and it eliminates the calls to the database.
- John
More information about the rhq-devel
mailing list