/*
 * Created on 30.03.2005
 *
 * $Id$
 */
package web;

import java.io.*;

import javax.servlet.ServletException;

import junit.framework.TestCase;
import web.LoginServlet;

public class LoginServletTest extends TestCase {
    
    private static StringWriter stringWriter = null;
    protected static PrintWriter out = null;
    protected static String username = "Bond";
    protected static String password = "007";
    private LoginServlet loginServlet = null;
    
    public static void main(String[] args) {
        junit.textui.TestRunner.run(LoginServletTest.class);
    }

    protected void setUp() throws Exception {
        stringWriter = new StringWriter();
        out = new PrintWriter(stringWriter);
        loginServlet = new LoginServlet();
    }

    /*
     * Class under test for void doPost(HttpServletRequest, HttpServletResponse)
     */
    public void testDoPostSuccessful() throws ServletException, IOException {
        username = "Bond";
        password = "007";
        loginServlet.doPost(null, null);
        assertTrue(stringWriter.toString().contains("Willkommen"));
    }

    public void testDoPostFail() throws ServletException, IOException {
        username = "Bond";
        password = "grottenfalsch";
        loginServlet.doPost(null, null);
        assertTrue(stringWriter.toString().contains("Sorry"));
    }

}
