injecting overlord in tests

John Mazzitelli mazz at redhat.com
Thu Jan 24 13:20:41 UTC 2013


You have to be careful if you cache or otherwise hold on to that overlord Subject object for long. Because its such a powerful authenticated/authorized user, we time out its session very quickly, something like 30 seconds.

This is why you often see us getting the overlord many times within a loop - because if the test loop takes a long time, the overlord user's session times out before the test can complete. So we constantly refresh its login.

----- Original Message -----
> 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
> _______________________________________________
> rhq-devel mailing list
> rhq-devel at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/rhq-devel
> 


More information about the rhq-devel mailing list