assertEquals("jacklord", targetAuth.getPrincipal());
assertTrue(targetAuth.getPrincipal() instanceof UserDetails); assertEquals("jacklord", ((User)targetAuth.getPrincipal()).getUsername());
    public void testSwitchRequestFromDanoToJackLord() throws Exception {        // set current user         UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("dano",                "hawaii50");        SecurityContextHolder.getContext().setAuthentication(auth);        // http request        MockHttpServletRequest request = new MockHttpServletRequest();        request.setRequestURI("/webapp/j_acegi_switch_user");        request.addParameter(SwitchUserProcessingFilter.ACEGI_SECURITY_SWITCH_USERNAME_KEY,            "jacklord");        // http response        MockHttpServletResponse response = new MockHttpServletResponse();        // setup filter        SwitchUserProcessingFilter filter = new SwitchUserProcessingFilter();        filter.setAuthenticationDao(new MockAuthenticationDaoUserJackLord());        filter.setSwitchUserUrl("/j_acegi_switch_user");        MockFilterChain chain = new MockFilterChain(true);        // test updates user token and context        filter.doFilter(request, response, chain);        // check current user        Authentication targetAuth = SecurityContextHolder.getContext()                                                         .getAuthentication();        assertNotNull(targetAuth);        assertEquals("jacklord", targetAuth.getPrincipal());    }