@@ -0,0 +1,2448 @@
+package org.springframework.security.web.authentication.preauth.websphere;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport org.junit.*;%0Aimport org.mockito.invocation.InvocationOnMock;%0Aimport org.mockito.stubbing.Answer;%0Aimport org.springframework.mock.web.MockHttpServletRequest;%0Aimport org.springframework.mock.web.MockHttpServletResponse;%0Aimport org.springframework.security.authentication.AuthenticationManager;%0Aimport org.springframework.security.core.Authentication;%0Aimport org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper;%0Aimport org.springframework.security.core.context.SecurityContextHolder;%0A%0Aimport javax.servlet.FilterChain;%0A%0A/**%0A * @author Luke Taylor%0A */%0Apublic class WebSpherePreAuthenticatedProcessingFilterTests %7B%0A%0A    @After%0A    public void clearContext() %7B%0A        SecurityContextHolder.clearContext();%0A    %7D%0A%0A    @Test%0A    public void principalsAndCredentialsAreExtractedCorrectly() throws Exception %7B%0A        new WebSpherePreAuthenticatedProcessingFilter();%0A        WASUsernameAndGroupsExtractor helper = mock(WASUsernameAndGroupsExtractor.class);%0A        when(helper.getCurrentUserName()).thenReturn(%22jerry%22);%0A        WebSpherePreAuthenticatedProcessingFilter filter = new WebSpherePreAuthenticatedProcessingFilter(helper);%0A        assertEquals(%22jerry%22, filter.getPreAuthenticatedPrincipal(new MockHttpServletRequest()));%0A        assertEquals(%22N/A%22, filter.getPreAuthenticatedCredentials(new MockHttpServletRequest()));%0A%0A        AuthenticationManager am = mock(AuthenticationManager.class);%0A        when(am.authenticate(any(Authentication.class))).thenAnswer(new Answer%3CAuthentication%3E() %7B%0A            public Authentication answer(InvocationOnMock invocation) throws Throwable %7B%0A                return (Authentication) invocation.getArguments()%5B0%5D;%0A            %7D%0A        %7D);%0A%0A        filter.setAuthenticationManager(am);%0A        WebSpherePreAuthenticatedWebAuthenticationDetailsSource ads =%0A                new WebSpherePreAuthenticatedWebAuthenticationDetailsSource(helper);%0A        ads.setWebSphereGroups2GrantedAuthoritiesMapper(new SimpleAttributes2GrantedAuthoritiesMapper());%0A        filter.setAuthenticationDetailsSource(ads);%0A%0A        filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), mock(FilterChain.class));%0A    %7D%0A%0A%0A%7D%0A

Test class to improve coverage of WAS-specific preauth code.