All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.example.struts.MockAuthenticationStrategy Maven / Gradle / Ivy

Go to download

Mockrunner is a lightweight framework for unit testing applications in the J2EE environment. It supports servlets, filters, tag classes and Struts actions. It includes a JDBC a JMS and a JCA test framework and can be used to test EJB based applications.

The newest version!
package com.mockrunner.example.struts;

/**
 * Mock implementation of {@link AuthenticationStrategy}
 * because we do not want a database connection into the tests.
 * Used by {@link AuthenticationActionTest}.
 */
public class MockAuthenticationStrategy implements AuthenticationStrategy
{
    private boolean isLoginOk;
    private boolean isUserKnown;
    private boolean isPasswordOk;
    
    public void setupLoginOk(boolean isLoginOk)
    {
        this.isLoginOk = isLoginOk;
    }

    public void setupPasswordOk(boolean isPasswordOk)
    {
        this.isPasswordOk = isPasswordOk;
    }

    public void setupUserKnown(boolean isUserKnown)
    {
        this.isUserKnown = isUserKnown;
    }
    
    public boolean authenticate(String username, String password)
    {        
        return isLoginOk;
    }

    public boolean wasLastPasswordOk()
    {
        return isPasswordOk;
    }

    public boolean wasLastUserKnown()
    {
        return isUserKnown;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy