commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prick...@apache.org
Subject cvs commit: jakarta-commons-sandbox/periodicity/src/test/org/apache/commons/periodicity/database GetDbConnectionTest.java
Date Wed, 09 Oct 2002 07:32:56 GMT
prickett    2002/10/09 00:32:56

  Added:       periodicity/src/test/org/apache/commons/periodicity/database
                        GetDbConnectionTest.java
  Log:
  This time I added a GetDbConnectionTest
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/periodicity/src/test/org/apache/commons/periodicity/database/GetDbConnectionTest.java
  
  Index: GetDbConnectionTest.java
  ===================================================================
  package org.apache.commons.periodicity.database;
  
  import java.sql.DriverManager;
  import junit.framework.TestCase;
  
  public class GetDbConnectionTest extends TestCase
  {
      public static final String FAILURE_MESSAGE_PREFIX = 
             "GetDatabaseConnection:";
      public static final String DATABASE_CONNECTION_FAILED =
             FAILURE_MESSAGE_PREFIX +
             "Could not successfully obtain a database connection";
      public static final String DATABASE_CLASS_NAME_NULL =
             FAILURE_MESSAGE_PREFIX + 
             "Driver class name is null.";
      public static final String DATABASE_URL_NULL =
             FAILURE_MESSAGE_PREFIX +
             "Database Url is null.";
      public static final String DATABASE_USER_NULL =
             FAILURE_MESSAGE_PREFIX +
             "Database User is null.";
      public static final String DATABASE_PASSWORD_NULL =
             FAILURE_MESSAGE_PREFIX +
             "Database Password is null.";
  
      private String driverClassName = null;
      private String databaseUrl = null;
      private String databaseUser = null;
      private String databasePassword = null;
  
      public GetDbConnectionTest(String name)
      {
          super(name);
      }
  
      public void runTest() throws Throwable
      {
          if(driverClassName != null && databaseUrl != null)
          {
              try
              {
                  Class.forName(driverClassName);
                  DriverManager.getConnection(databaseUrl, databaseUser,
                         databasePassword);
              }
              catch(Exception e)
              {
                  fail(DATABASE_CONNECTION_FAILED);
              }
          }
          else if(driverClassName == null)
          {
              fail(DATABASE_CLASS_NAME_NULL);
          }
          else if(databaseUrl == null)
          {
              fail(DATABASE_URL_NULL);
          }
          else if(databaseUser == null)
          {
              fail(DATABASE_USER_NULL);
          }
          else if(databasePassword == null)
          {
              fail(DATABASE_PASSWORD_NULL);
          }
          else
          {
              fail("Unexpected Exception"); 
          }    
      }
  }    
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message