davidallen39
May 7th, 2008, 07:49 AM
Hi All,
I have a controller class that calls the following method.
SecurityContextHolder.getContext().getAuthenticati on();
I then extract the principal and pass that to a service. My problem is that I am trying to mock the service while performing a unit test for the controller.
Is it possible to set the Authentication object in the security context holder object in the unit test?
I am sure it is but not sure of the code. A small sample would be great
I have a controller class that calls the following method.
SecurityContextHolder.getContext().getAuthenticati on();
I then extract the principal and pass that to a service. My problem is that I am trying to mock the service while performing a unit test for the controller.
Is it possible to set the Authentication object in the security context holder object in the unit test?
I am sure it is but not sure of the code. A small sample would be great