@Test
    void testSimple() {
        //1.  Build the Subject instance for the test to run:
        Subject subjectUnderTest = new Subject.Builder(getSecurityManager()).buildSubject();

        //2. Bind the subject to the current thread:
        setSubject(subjectUnderTest);

        //perform test logic here.  Any call to
        //SecurityUtils.getSubject() directly (or nested in the
        //call stack) will work properly.
    }
Simple example test class to be used to show how one might write Shiro-compatible unit tests.

@since 1.2
core/src/test/java/org/apache/shiro/test/ExampleShiroIntegrationTest.java