Package org.apache.sling.hc.support.impl

Examples of org.apache.sling.hc.support.impl.DefaultLoginsHealthCheck


import org.mockito.stubbing.Answer;

public class DefaultLoginsHealthCheckTest {
   
    private Result getTestResult(String login) throws Exception {
        final DefaultLoginsHealthCheck c = new DefaultLoginsHealthCheck();
        SetField.set(c, "logins", Arrays.asList(new String[] { login }));
       
        final SlingRepository repo = Mockito.mock(SlingRepository.class);
        SetField.set(c, "repository", repo);
        final Session s = Mockito.mock(Session.class);
        Mockito.when(repo.login(Matchers.any(Credentials.class))).thenAnswer(new Answer<Session>() {
            @Override
            public Session answer(InvocationOnMock invocation) {
                final SimpleCredentials c = (SimpleCredentials)invocation.getArguments()[0];
                if("admin".equals(c.getUserID())) {
                    return s;
                }
                return null;
            }
        });
       
        return c.execute();
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.hc.support.impl.DefaultLoginsHealthCheck

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.