prickett    2002/10/28 01:23:36

  Modified:    
periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database
                        DriverMetaDataImpl.java
               
periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database
                        DriverMDNullValueTests.java
                        DriverMetaDataTestSuite.java
  Added:       
periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database
                        DriverMDSetGetTests.java
  Log:
  Added javadocs for addProtocols, setProtocols, removeProtocol,
  removeProtocols, removeAllProtocols, getProtocols, getUrlScheme
  
  Added a supportsProtocol methodto the jdbc driver and changed getUrlScheme
  to use it when returning a protocol.
  
  Changed DriverMDNullValueTests to take no arguments
  
  Removed the old tests that were commented out from the
  Driver Meta Data Test Suite and replaced them with the new tests
  
  Added DriverMDSetGetTests to the test suite.
  
  Revision  Changes    Path
  1.8       +62 -6     
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DriverMetaDataImpl.java   27 Oct 2002 22:27:18 -0000      1.7
  +++ DriverMetaDataImpl.java   28 Oct 2002 09:23:36 -0000      1.8
  @@ -261,6 +261,11 @@
           }    
       }
   
  +    /**
  +     * The purpose of this method is to add a protocols from a Map to
  +     * the jdbc driver.
  +     * @param newProtocols The new protocols to be added as a java.util.Map
  +     */
       void addProtocols(Map newProtocols) throws Exception
       {
           if(newProtocols != null)
  @@ -322,12 +327,22 @@
           }
       }    
       
  +    /**
  +     * The purpose of this method is to replace the current set of protocols
  +     * for this jdbc driver with a new set of protocols.
  +     * @param newProtocols The new protocols for the jdbc driver.
  +     */
       void setProtocols(Map newProtocols) throws Exception
       {
           protocols = null;
           addProtocols(newProtocols);
       }
   
  +    /**
  +     * The purpose of this method is to remove the protocol with the 
  +     * given name from the jdbc driver.
  +     * @param protocolName The name of the protocol to be removed.
  +     */
       void removeProtocol(String protocolName)
       {
           if(protocolName != null && protocols.containsKey(protocolName))
  @@ -336,6 +351,11 @@
           }
       }
   
  +    /**
  +     * The purpose of this method is to remove all the protocols in
  +     * the given Map from the jdbc driver.
  +     * @param oldProtocols The old protocols to be removed.
  +     */
       void removeProtocols(Map oldProtocols)
       {
           if(oldProtocols != null)
  @@ -359,26 +379,62 @@
           }    
       }    
   
  +    /**
  +     * The purpose of this method is to remove all protocols from this jdbc
  +     * driver.
  +     */
       void removeAllProtocols()
       {
           protocols = null;
       }
   
  +    /**
  +     * The purpose of this method is to retrieve all the protocols supported
  +     * by this jdbc driver.
  +     * @return The set of jdbc drivers supported by this jdbc driver as
  +     *         a java.util.Map.
  +     */
       Map getProtocols()
       {
           return protocols;
       }
   
  -    String getUrlScheme(String protocolName)
  +    /**
  +     * The purpose of this method is to get the url scheme for the given
  +     * protocol name.
  +     * @param protocolName The name of the protocol for which we want to
  +     *        retrieve the scheme.
  +     */
  +    String getUrlScheme(String protocolName) throws Exception
       {
  -        if(protocols != null && protocolName != null && 
  -               protocols.containsKey(protocolName))
  +        if(supportsProtocol(protocolName)) 
           {
               return (String) protocols.get(protocolName);
           }
  +        else if(protocolName == null)
  +        {
  +            throw new Exception("protocolName == null");
  +        }    
           else
           {
               return null;
  +        }
  +    }
  +
  +    /**
  +     * The purpose of this method is to test to see if a jdbc driver
  +     * supports a given protocol.
  +     * @param protocolName The name of the protocol that we wish to test for.
  +     */
  +    boolean supportsProtocol(String protocolName)
  +    {
  +        if(protocols != null && protocolName != null)
  +        {
  +            return protocols.containsKey(protocolName);
  +        }
  +        else
  +        {
  +            return false;
           }
       }    
   
  
  
  
  1.2       +10 -5     
jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMDNullValueTests.java
  
  Index: DriverMDNullValueTests.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMDNullValueTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DriverMDNullValueTests.java       27 Oct 2002 22:27:18 -0000      1.1
  +++ DriverMDNullValueTests.java       28 Oct 2002 09:23:36 -0000      1.2
  @@ -118,9 +118,9 @@
              "Attempting to retrieve a protocol with a null name should " +
              "throw an exception.";
       
  -    public DriverMDNullValueTests(String name)
  +    public DriverMDNullValueTests()
       {
  -        super(name);
  +        super(TEST_NAME);
       }
   
       protected void runTest()
  @@ -285,6 +285,11 @@
                   getLogger().info("Expected Exception", e);
               }    
           }
  +    }
  +
  +    public static Test suite()
  +    {
  +        return new DriverMDNullValueTests();
       }    
   }            
               
  
  
  
  1.3       +7 -15     
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DriverMetaDataTestSuite.java      27 Oct 2002 22:27:18 -0000      1.2
  +++ DriverMetaDataTestSuite.java      28 Oct 2002 09:23:36 -0000      1.3
  @@ -72,18 +72,10 @@
       public static Test suite()
       {
           DriverMetaDataTestSuite returnValue = new DriverMetaDataTestSuite();
  -        /*
  -        returnValue.addTest(new DriverMDContextNameNullTest(
  -               DriverMDContextNameNullTest.TEST_NAME));
  -        returnValue.addTest(new DriverMDContextNullTest(
  -               DriverMDContextNullTest.TEST_NAME));
  -        returnValue.addTest(new DriverMDGetContextTest(
  -               DriverMDGetContextTest.TEST_NAME));
  -        returnValue.addTest(new DriverMDGetNameTest(
  -               DriverMDGetNameTest.TEST_NAME));
  -        returnValue.addTest(new DriverMDNameNullTest(
  -               DriverMDNameNullTest.TEST_NAME));
  -        */       
  +        DriverMDNullValueTests nullTests = new DriverMDNullValueTests(); 
  +        returnValue.addTest(nullTests);
  +        DriverMDSetGetTests setGetTests = new DriverMDSetGetTests();
  +        returnValue.addTest(setGetTests);
           return returnValue;
       }
   
  
  
  
  1.1                  
jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMDSetGetTests.java
  
  Index: DriverMDSetGetTests.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/DriverMDSetGetTests.java,v
 1.1 2002/10/28 09:23:36 prickett Exp $
   * $Revision: 1.1 $
   * $Date: 2002/10/28 09:23:36 $
   *
   * ====================================================================
   * 
   * 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 [EMAIL PROTECTED]
   *
   * 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 DriverMDSetGetTests extends TestWithMavenLogging
  {
      public static final String TEST_NAME = 
             "DriverMetaDataImpl.set_and_get";
  
      public static final String DRIVER_NAME = "driver";       
  
      public static final String NON_NULL_STRING = "This is a non null string.";
      
      public DriverMDSetGetTests()
      {
          super(TEST_NAME);
      }
  
      protected void runTest()
      {
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl(
                     NON_NULL_STRING);
              String name = driverMeta.getName();
              assertEquals("The name that was set did not match the name " +
                     "that was retrieved.", NON_NULL_STRING, name);
          }
          catch(Exception e)
          {
              fail("Setting a non null name should not have caused an " +
                     "exception.");
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl(
                     DRIVER_NAME);
              driverMeta.setShortDescription(NON_NULL_STRING);       
              String shortDescription = driverMeta.getShortDescription();
              assertEquals("The short description that was set does not " +
                     "match the one that was returned.", NON_NULL_STRING, 
                     shortDescription);
          }
          catch(Exception e)
          {
              fail("Setting a non null short description should not have caused " 
                     + "an exception.");
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl(
                     DRIVER_NAME);
              driverMeta.setDescription(NON_NULL_STRING);
              String description = driverMeta.getDescription();
              assertEquals("The description that was set does not match " +
                     "the one that was returned.", NON_NULL_STRING,
                     description);
          }
          catch(Exception e)
          {
              fail("Setting a non null description should not have caused an "
                     + "exception.");
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl(
                     DRIVER_NAME);
              driverMeta.setWebUrl(NON_NULL_STRING);
              String webUrl = driverMeta.getWebUrl();
              assertEquals("The web url that was set does not match the one " +
                     "that was returned.", NON_NULL_STRING, webUrl);
          }
          catch(Exception e)
          {
              fail("Setting a non null web url should not have caused an " +
                     "exception.");
          }
          try
          {
              DriverMetaDataImpl driverMeta = new DriverMetaDataImpl(
                     DRIVER_NAME);
              driverMeta.setClassName(NON_NULL_STRING);
              String className = driverMeta.getClassName();
              assertEquals("The class name that was set does not match the one " 
                     + "that was returned.", NON_NULL_STRING, className);
          }           
          catch(Exception e)
          {
              fail("Setting a non null class name should not have caused an " +
                     "exception.");
          }
      }
  }    
  
  
  
  
  
  

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

Reply via email to