You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by aloleary <al...@gmail.com> on 2010/03/18 10:10:25 UTC
Shiro error on JUnit test
I'm not 100% sure whats going on here - probably just a local issue - but
just posting to see if anyone has had the same issue...
I have a simple JUnit test running in Eclipse - it runs fine in eclipse...
but when I run it on the command line I get the following error !?
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.088 sec
<<< FAILURE!
staffTest(xyz.ServiceTest) Time elapsed: 0 sec <<< ERROR!
org.apache.shiro.authc.UnknownAccountException: Realm
[xyz.security.PinAccountRealm@1e09eab] was unable to find account data for
the submitted AuthenticationToken
[org.apache.shiro.authc.UsernamePasswordToken - branch_staff,
rememberMe=false].
--
View this message in context: http://n2.nabble.com/Shiro-error-on-JUnit-test-tp4755410p4755410.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Shiro error on JUnit test
Posted by aloleary <al...@gmail.com>.
On further digging - each individual test is ok - but when I run two shiro
tests together with maven i get this errror
--
View this message in context: http://n2.nabble.com/Shiro-error-on-JUnit-test-tp4755410p4755531.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Shiro error on JUnit test
Posted by UncleTupelo <ma...@hpd.co.uk>.
I had a similar issue and it also caused me some confusion.
If I use SecurityUtils in any unit tests then I always make sure I logout in
an @After annotated method, for example:
@After
public void tearDown(){
SecurityUtils.getSubject().logout();
}
--
View this message in context: http://n2.nabble.com/Shiro-error-on-JUnit-test-tp4755410p4783703.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Shiro error on JUnit test
Posted by Les Hazlewood <lh...@apache.org>.
Hi Al,
All of the Shiro project's tests are run in Maven on the command line.
You might also consider to clear out everything in the set-up and
tear-down phases of each test - most if not all of the Shiro tests do
this just in case.
Regards,
Les
On Thu, Mar 18, 2010 at 3:05 AM, aloleary <al...@gmail.com> wrote:
>
> OK resolved...
>
> For anyone who comes up against this in future...
>
> SecurityUtils.getSubject() in test B was the subject from the previous test
> A !!
>
> Eclipse runs tests in different threads - I always assumed Maven command
> line did the same... but it seems to be a single test thread ...
>
> Anyway I was able to run tests with:
>
> %>mvn -DforkMode=always test
>
> And the problem went away
>
> I need to look at Maven using a single test thread a bit more -
> --
> View this message in context: http://n2.nabble.com/Shiro-error-on-JUnit-test-tp4755410p4755567.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>
Re: Shiro error on JUnit test
Posted by aloleary <al...@gmail.com>.
OK resolved...
For anyone who comes up against this in future...
SecurityUtils.getSubject() in test B was the subject from the previous test
A !!
Eclipse runs tests in different threads - I always assumed Maven command
line did the same... but it seems to be a single test thread ...
Anyway I was able to run tests with:
%>mvn -DforkMode=always test
And the problem went away
I need to look at Maven using a single test thread a bit more -
--
View this message in context: http://n2.nabble.com/Shiro-error-on-JUnit-test-tp4755410p4755567.html
Sent from the Shiro User mailing list archive at Nabble.com.