Developer's Daily Java Education - Test Projects
  front page | java | perl | unix | DevDirectory
   
Front Page
Java
Education
   
 


package com.devdaily.opensource.web.utilTest;

//  need to add "junit.ui.TestRunner" to
//  Project  Project Properties  Run ... VM Parameters for JBuilder

import junit.framework.*;
import com.devdaily.opensource.web.util.Validator;

public class ValidatorTest extends TestCase
{

  /**
   * Set up work to be done before each test.
   */
  protected void setUp()
  {
    //sum   = 0.0;
    //price = 0.0;
  }

  /**
   * Cleanup work to do after each test.
   */
  protected void tearDown()
  {
  }

  //---------------------------------------------------------------------------------------------//

  public void testNull()
  {
    String address = null;
    boolean expectedResult = false;
    boolean actualResult = Validator.isValidEmailAddress(address);
    assert( "\ntestNull, EXPECTED: " + expectedResult + ", GOT: " + actualResult,
            (expectedResult==actualResult) );
            asse
  }

  //---------------------------------------------------------------------------------------------//

  public void testBlank()
  {
    String address = "";
    boolean expectedResult = true;
    boolean actualResult = Validator.isValidEmailAddress(address);
    assert( "\ntestFred, EXPECTED: " + expectedResult + ", GOT: " + actualResult,
            (expectedResult==actualResult) );
  }

  //---------------------------------------------------------------------------------------------//

  public void testJim()
  {
    String address = "jim";
    boolean expectedResult = false;
    boolean actualResult = Validator.isValidEmailAddress(address);
    assert( "\ntestJim, EXPECTED: " + expectedResult + ", GOT: " + actualResult,
            (expectedResult==actualResult) );
  }

  //---------------------------------------------------------------------------------------------//

  public void testJimAt()
  {
    String address = "jim@missiondata";
    boolean expectedResult = false;
    boolean actualResult = Validator.isValidEmailAddress(address);
    assert( "\ntestJim, EXPECTED: " + expectedResult + ", GOT: " + actualResult,
            (expectedResult==actualResult) );
  }

  //---------------------------------------------------------------------------------------------//

  public static void main(String args[])
  {
    junit.textui.TestRunner.run(ValidatorTest.class);
  }

  public ValidatorTest(String name)
  {
    super(name);
  }

  /**
   * add one line here for each test in the suite
   */
  public static Test suite()
  {
    TestSuite suite = new TestSuite();

    // run tests manually
    //suite.addTest( newValidatorTest("testBlank") );
    //suite.addTest( newValidatorTest("testNull") );
    //suite.addTest( newValidatorTest("testAtSymbols") );
    //return suite;

    // or, run tests dynamically
    return new TestSuite(ValidatorTest.class);
  }

}
Copyright 1998-2003 DevDaily Interactive, Inc.
All Rights Reserved.