FileDocCategorySizeDatePackage
TestCalculatorServlet.javaAPI DocExample3351Sat Mar 15 19:39:50 GMT 2003com.oreilly.javaxp.cactus.servlet

TestCalculatorServlet

public class TestCalculatorServlet extends org.apache.cactus.ServletTestCase
author
Brian M. Coyner $version $Id: TestCalculatorServlet.java,v 1.3 2003/02/27 00:24:44 jepc Exp $

Fields Summary
Constructors Summary
public TestCalculatorServlet(String name)

        super(name);
    
Methods Summary
public voidbeginVerifyInvalidOperandOneParameter(org.apache.cactus.WebRequest req)

        req.addParameter(CalculatorServlet.OPERAND_ONE, "INVALID");
        req.addParameter(CalculatorServlet.OPERAND_TWO, "22");
        req.addParameter(CalculatorServlet.OPERATION, "+");
    
public voidbeginVerifyInvalidOperandTwoParameter(org.apache.cactus.WebRequest req)

        req.addParameter(CalculatorServlet.OPERAND_ONE, "22");
        req.addParameter(CalculatorServlet.OPERAND_TWO, "INVALID");
        req.addParameter(CalculatorServlet.OPERATION, "+");
    
public voidbeginVerifyInvalidOperatorParameter(org.apache.cactus.WebRequest req)

        req.addParameter(CalculatorServlet.OPERAND_ONE, "13");
        req.addParameter(CalculatorServlet.OPERAND_TWO, "22");
        req.addParameter(CalculatorServlet.OPERATION, "%");
    
public voidbeginVerifyValidAdditionRequestParameters(org.apache.cactus.WebRequest req)

        req.addParameter(CalculatorServlet.OPERAND_ONE, "4");
        req.addParameter(CalculatorServlet.OPERAND_TWO, "60");
        req.addParameter(CalculatorServlet.OPERATION, "+");
    
public voidbeginVerifyValidSubtractionRequestParameters(org.apache.cactus.WebRequest req)

        req.addParameter(CalculatorServlet.OPERAND_ONE, "45");
        req.addParameter(CalculatorServlet.OPERAND_TWO, "22");
        req.addParameter(CalculatorServlet.OPERATION, "-");
    
public voidtestVerifyInvalidOperandOneParameter()

        CalculatorServlet servlet = new CalculatorServlet();
        try {
            servlet.verifyRequestParameters(this.request);
            fail("Calculator Exception should have been caught because " +
                 "operand one was invalid.");
        } catch (ServletException e) {
        }
    
public voidtestVerifyInvalidOperandTwoParameter()

        CalculatorServlet servlet = new CalculatorServlet();
        try {
            servlet.verifyRequestParameters(this.request);
            fail("Calculator Exception should have been caught because " +
                 "operand two was invalid.");
        } catch (ServletException e) {
        }
    
public voidtestVerifyInvalidOperatorParameter()

        CalculatorServlet servlet = new CalculatorServlet();
        try {
            servlet.verifyRequestParameters(this.request);
            fail("Calculator Exception should have been caught because " +
                 "operator was invalid.");
        } catch (ServletException e) {
        }
    
public voidtestVerifyValidAdditionRequestParameters()

        CalculatorServlet servlet = new CalculatorServlet();
        servlet.verifyRequestParameters(this.request);
    
public voidtestVerifyValidSubtractionRequestParameters()

        CalculatorServlet servlet = new CalculatorServlet();
        servlet.verifyRequestParameters(this.request);