@Test(expected = IllegalStateException.class)
public void testNullSubject() {

    SubjectConnectionReference reference =
            new SubjectConnectionReference(new ConnectionContext(), new ConnectionInfo(),
                    new DefaultEnvironment(), new SubjectAdapter());
    reference.getConnectionContext().setSecurityContext(new SubjectSecurityContext(reference) {
        @Override
        public Subject getSubject() {
            return null;
        }
    });
    ConnectionSubjectResolver resolver = new ConnectionSubjectResolver(reference);
    resolver.getSubject();
}