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/plugins-build/database/src/test/org/apache/commons/periodicity/database DriverMDNullValueTests.java DriverMetaDataTestSuite.java DriverMDContextNameNullTest.java DriverMDContextNullTest.java DriverMDGetContextTest.java DriverMDGetNameTest.java DriverMDNameNullTest.java
Date Sun, 27 Oct 2002 22:27:19 GMT
prickett    2002/10/27 14:27:19

  Modified:    periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database
                        DriverMetaData.java DriverMetaDataImpl.java
               periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database
                        DriverMetaDataTestSuite.java
  Added:       periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database
                        DriverMDNullValueTests.java
  Removed:     periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database
                        DriverMDContextNameNullTest.java
                        DriverMDContextNullTest.java
                        DriverMDGetContextTest.java
                        DriverMDGetNameTest.java DriverMDNameNullTest.java
  Log:
  Added a test case to test the expected response of the Driver Meta Data
  Implementation to null inputs.
  
  Removed the Driver Meta Data Context and Name Null Test Case
  
  Removed the Driver Meta Data Context Null Test Case
  
  Removed the Driver Meta Data Get Context Test Case
  
  Removed the Driver Meta Data Get Name Test Case
  
  Removed the Driver Meta Data Name Null Test Case
  
  Fixed a possible problem handling null protocol maps.
  
  Moved the definition of Default Protocol Name to Driver Meta Data instead
  of in its implementation.
  
  Revision  Changes    Path
  1.4       +4 -3      jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverMetaData.java
  
  Index: DriverMetaData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverMetaData.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DriverMetaData.java	27 Oct 2002 12:22:39 -0000	1.3
  +++ DriverMetaData.java	27 Oct 2002 22:27:18 -0000	1.4
  @@ -68,6 +68,7 @@
   
   public interface DriverMetaData
   {
  +    public static final String DEFAULT_PROTOCOL_NAME = "default.protocol";
       
       /**
        * The purpose of this method is to return the name of this driver
  
  
  
  1.7       +8 -5      jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverMetaDataImpl.java
  
  Index: DriverMetaDataImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverMetaDataImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DriverMetaDataImpl.java	27 Oct 2002 12:22:39 -0000	1.6
  +++ DriverMetaDataImpl.java	27 Oct 2002 22:27:18 -0000	1.7
  @@ -72,7 +72,6 @@
   public class DriverMetaDataImpl implements DriverMetaData
   {
   
  -    public static final String DEFAULT_PROTOCOL_NAME = "default.protocol";
   
       /** A variable to store the name of the driver */
       private String name = null;
  @@ -281,6 +280,10 @@
                               if(rawScheme != null && 
                                      rawScheme instanceof String)
                               {       
  +                                if(protocols == null)
  +                                {
  +                                    protocols = new Hashtable();
  +                                }    
                                   protocols.put(rawName, rawScheme);
                               }
                               else if(rawScheme == null)
  @@ -321,7 +324,7 @@
       
       void setProtocols(Map newProtocols) throws Exception
       {
  -        protocols = new Hashtable();
  +        protocols = null;
           addProtocols(newProtocols);
       }
   
  
  
  
  1.2       +5 -3      jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMetaDataTestSuite.java
  
  Index: DriverMetaDataTestSuite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMetaDataTestSuite.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DriverMetaDataTestSuite.java	24 Oct 2002 06:17:20 -0000	1.1
  +++ DriverMetaDataTestSuite.java	27 Oct 2002 22:27:18 -0000	1.2
  @@ -72,6 +72,7 @@
       public static Test suite()
       {
           DriverMetaDataTestSuite returnValue = new DriverMetaDataTestSuite();
  +        /*
           returnValue.addTest(new DriverMDContextNameNullTest(
                  DriverMDContextNameNullTest.TEST_NAME));
           returnValue.addTest(new DriverMDContextNullTest(
  @@ -82,6 +83,7 @@
                  DriverMDGetNameTest.TEST_NAME));
           returnValue.addTest(new DriverMDNameNullTest(
                  DriverMDNameNullTest.TEST_NAME));
  +        */       
           return returnValue;
       }
   
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMDNullValueTests.java
  
  Index: DriverMDNullValueTests.java
  ===================================================================
  
  package org.apache.commons.periodicity.database;
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMDNullValueTests.java,v
1.1 2002/10/27 22:27:18 prickett Exp $
   * $Revision: 1.1 $
   * $Date: 2002/10/27 22:27:18 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  import junit.framework.Test;
  import org.apache.commons.periodicity.junit.TestWithMavenLogging;
  
  public class DriverMDNullValueTests extends TestWithMavenLogging
  {
  
      public static final String TEST_NAME =
             "DriverMetaDataImpl.null_tests";
  
      public static final String NON_NULL_STRING = "This is a non null string.";       
      public static final String SHORT_DESC_SET_NULL_FAIL_MESG =
             "The value of the short description after setting the short " +
             "description to null should be null.";
      
      public static final String DESC_SET_NULL_FAIL_MESG =
             "The value of the description after setting the description to " +
             "null should be null.";
      
      public static final String WEB_URL_NULL_FAIL_MESG =
             "The value of the web url should be null after the web url is set "
             + "to null.";
      
      public static final String CLASS_NAME_NULL_FAIL_MESG =
             "Setting the class name to null should throw an exception.";
  
      public static final String ADD_PROTOCOL_BOTH_NULL_EXCEPTION_MESG =
             "Attempting to add a protocol with a null name and a null scheme " +
             "should throw an exception.";
      
      public static final String ADD_PROTOCOL_SCHEME_NULL_EXCEPTION_MESG =
             "Attempting to add a protocol with a non null name and a null " +
             "scheme should throw an exception.";
      
      public static final String ADD_PROTOCOL_DEFAULT_SCHEME_MESG =
             "Adding a protocol with a null name and a non null scheme should "
             + "add a protocol with the default name and the given scheme.";
      
      public static final String ADD_PROTOCOL_UNEXPECTED_EXCEPTION_MESG =
             "Adding a protocol with a null name and a non-null scheme should " +
             "not throw an exception.";
      
      public static final String ADD_PROTOCOLS_UNEXPECTED_EXCEPTION_MESG =
             "Adding protocols from a null java.util.Map should not throw an " +
             "exception. It should return without doing anything.";
             
      public static final String SET_PROTOCOL_EXPECTED_NULL_MESG = 
             "Setting a null protocol map should result in getProtocols() " +
             "returning null.";
      
      public static final String SET_PROTOCOL_UNEXPECTED_EXCEPTION_MESG =
             "Setting a null protocol map should not throw an exception.";
      
      public static final String GETTING_NULL_PROTOCOL_EXPECT_EXCEPTION =
             "Attempting to retrieve a protocol with a null name should " +
             "throw an exception.";
      
      public DriverMDNullValueTests(String name)
      {
          super(name);
      }
  
      protected void runTest()
      {
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl(null);
              fail("Expected an exception when creating a DriverMetaDataImpl " +
                     "with a null name.");
          }
          catch(Exception e)
          {
              if(getLogger() != null)
              {
                  getLogger().info("Expected Exception", e);
              }
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.setShortDescription(null);
              assertNull(SHORT_DESC_SET_NULL_FAIL_MESG, 
                     driverMeta.getShortDescription());
              driverMeta.setShortDescription(NON_NULL_STRING);
              driverMeta.setShortDescription(null);
              assertNull(SHORT_DESC_SET_NULL_FAIL_MESG,
                     driverMeta.getShortDescription());
                     
          }
          catch(Exception e)
          {
              fail("We should be able to set a null value for "
                     + "the shortDescription property of the jdbc driver.");
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.setDescription(null);
              assertNull(DESC_SET_NULL_FAIL_MESG,
                     driverMeta.getDescription());
              driverMeta.setDescription(NON_NULL_STRING);
              driverMeta.setDescription(null);
              assertNull(DESC_SET_NULL_FAIL_MESG,
                     driverMeta.getDescription());
          }
          catch(Exception e)
          {
              fail("We should be able to set a null value for the description "
                     + "property of the jdbc driver.");
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.setWebUrl(null);
              assertNull(WEB_URL_NULL_FAIL_MESG, driverMeta.getWebUrl());
              driverMeta.setWebUrl(NON_NULL_STRING);
              driverMeta.setWebUrl(null);
              assertNull(WEB_URL_NULL_FAIL_MESG, driverMeta.getWebUrl());
          }
          catch(Exception e)
          {
              fail("We should be able to set a null value for the web url " +
                     "property of the jdbc driver.");
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.setClassName(null);
              fail(CLASS_NAME_NULL_FAIL_MESG);
          }
          catch(Exception e)
          {
              if(getLogger() != null)
              {
                  getLogger().info("Expected Exception", e);
              }
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl(
                     "driver");
              driverMeta.setClassName(NON_NULL_STRING);
              driverMeta.setClassName(null);
              fail(CLASS_NAME_NULL_FAIL_MESG);
          }
          catch(Exception e)
          {
              if(getLogger() != null)
              {
                  getLogger().info("Expected Exception", e);
              }
          }    
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.addProtocol(null, null);
              fail(ADD_PROTOCOL_BOTH_NULL_EXCEPTION_MESG);
          }
          catch(Exception e)
          {
              if(getLogger() != null)
              {
                  getLogger().info("Expected Exception", e);
              }
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.addProtocol(NON_NULL_STRING, null);
              fail(ADD_PROTOCOL_SCHEME_NULL_EXCEPTION_MESG);
          }
          catch(Exception e)
          {
              if(getLogger() != null)
              {
                  getLogger().info("Expected Exception", e);
              }
          }    
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.addProtocol(null, NON_NULL_STRING);
              String scheme = driverMeta.getUrlScheme(
                     DriverMetaData.DEFAULT_PROTOCOL_NAME);
              assertEquals(ADD_PROTOCOL_DEFAULT_SCHEME_MESG, NON_NULL_STRING,
                     scheme);
          }
          catch(Exception e)
          {
              fail(ADD_PROTOCOL_UNEXPECTED_EXCEPTION_MESG);
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.addProtocols(null);
          }
          catch(Exception e)
          {
              fail(ADD_PROTOCOLS_UNEXPECTED_EXCEPTION_MESG);
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              driverMeta.setProtocols(null);
              assertNull(SET_PROTOCOL_EXPECTED_NULL_MESG, 
                     driverMeta.getProtocols());
          }
          catch(Exception e)
          {
              fail(SET_PROTOCOL_UNEXPECTED_EXCEPTION_MESG);
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl("driver");
              String scheme = driverMeta.getUrlScheme(null);
              fail(GETTING_NULL_PROTOCOL_EXPECT_EXCEPTION);
          }
          catch(Exception e)
          {
              if(getLogger() != null)
              {
                  getLogger().info("Expected Exception", e);
              }    
          }
      }    
  }            
              
              
          
              
              
  
  
  
  
  
  

--
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