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


package PACKAGE_NAME;

import java.sql.*;
import junit.framework.*;
import NEEDED_IMPORTS;

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

public class TEST_CLASS_NAME extends TestCase
{

  Connection connection;

  /**
   * Set up work to be done before test cases.
   */
  protected void setUp()
  {
    try
    {
      //Class.forName("org.gjt.mm.mysql.Driver");
      //String url = "jdbc:mysql://localhost/junit_test";
      Class.forName("org.postgresql.Driver");
      String url = "jdbc:postgresql://localhost/junit_test";
      connection = DriverManager.getConnection(url,"username","password");
    }
    catch (SQLException se)
    {
      System.err.println( "SQLException in setUp(): " + se.getMessage() );
    }
    catch (ClassNotFoundException cnfe)
    {
      System.err.println( "ClassNotFoundException in setUp(): " + cnfe.getMessage() );
    }
  }

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

  public void testSELECT()
  {
    HandlingCharge handlingCharge = null;
    try
    {
      HandlingChargeContainer hcc = new HandlingChargeContainer();
      handlingCharge = hcc.getHandlingChargeInformation(1,connection);
      System.out.println(handlingCharge.getMallId());
      System.out.println(handlingCharge.getHandlingChargeId());
      System.out.println(handlingCharge.getPercentFaceValue());
      System.out.println(handlingCharge.getPercentTransactionAmount());
      System.out.println(handlingCharge.getPercentHandlingFee());
      System.out.println(handlingCharge.getAmountPerCertificate());

      assert( "\ntestSELECT", true );
    }
    catch (SQLException se)
    {
      System.err.println( "SQLException - " + se.getMessage() );
      assert( "\ntestSELECT", false );
    }
    finally { }
  }


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

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

  public TEST_CLASS_NAME(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( new TEST_CLASS_NAME("test1") );
    //return suite;

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

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