@@ -0,0 +1,2852 @@
+/*%0A * Copyright (c) 2019 Nova Ordis LLC%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.apache.shiro.authc.pam;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNull;%0A%0Aimport org.apache.shiro.authc.AuthenticationInfo;%0Aimport org.apache.shiro.authc.MergableAuthenticationInfo;%0Aimport org.apache.shiro.authc.SimpleAuthenticationInfo;%0Aimport org.apache.shiro.subject.PrincipalCollection;%0Aimport org.apache.shiro.subject.SimplePrincipalCollection;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A/**%0A * Created by lei.li4 on 2019/1/23%0A */%0Apublic class FirstSuccessfulStrategyTest %7B%0A%0A    private FirstSuccessfulStrategy strategy;%0A%0A    @Before%0A    public void setUp() %7B%0A        strategy = new FirstSuccessfulStrategy();%0A    %7D%0A%0A    @Test%0A    public void beforeAllAttempts() %7B%0A        AuthenticationInfo authenticationInfo = strategy.beforeAllAttempts(null, null);%0A        assertNull(authenticationInfo);%0A    %7D%0A%0A    @Test%0A    public void testMergeWithValidAggregateInfo() %7B%0A        AuthenticationInfo aggregate = new MergableAuthenticationInfo() %7B%0A            @Override%0A            public void merge(AuthenticationInfo info) %7B%0A%0A            %7D%0A%0A            @Override%0A            public PrincipalCollection getPrincipals() %7B%0A                return new SimplePrincipalCollection(%22principals%22, %22realmName%22);%0A            %7D%0A%0A            @Override%0A            public Object getCredentials() %7B%0A                return null;%0A            %7D%0A        %7D;%0A        AuthenticationInfo mergeResult = strategy.merge(new SimpleAuthenticationInfo(), aggregate);%0A        assertEquals(aggregate, mergeResult);%0A    %7D%0A%0A    @Test%0A    public void testMergeWithInvalidAggregateInfo() %7B%0A        AuthenticationInfo aggregate = new MergableAuthenticationInfo() %7B%0A            @Override%0A            public void merge(AuthenticationInfo info) %7B%0A%0A            %7D%0A%0A            @Override%0A            public PrincipalCollection getPrincipals() %7B%0A                return new SimplePrincipalCollection();%0A            %7D%0A%0A            @Override%0A            public Object getCredentials() %7B%0A                return null;%0A            %7D%0A        %7D;%0A%0A        AuthenticationInfo authInfo = new SimpleAuthenticationInfo();%0A        AuthenticationInfo mergeResult = strategy.merge(authInfo, aggregate);%0A        assertEquals(authInfo, mergeResult);%0A    %7D%0A%0A%7D%0A

add unit test for FirstSuccessfulStrategy