prickett 2002/10/29 02:19:17
Modified: 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
DriverMDProtocolsTests.java
Removed: periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/ant
GetDatabaseConnectionTask.java
periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database
GetDatabaseConnectionTest.java
Log:
Added DriverMDProtocolsTests to the test suite.
Removed GetDatabaseConnectionTask.java
Removed GetDatabaseConnectionTest.java
Revision Changes Path
1.4 +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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DriverMetaDataTestSuite.java 28 Oct 2002 09:23:36 -0000 1.3
+++ DriverMetaDataTestSuite.java 29 Oct 2002 10:19:17 -0000 1.4
@@ -76,6 +76,8 @@
returnValue.addTest(nullTests);
DriverMDSetGetTests setGetTests = new DriverMDSetGetTests();
returnValue.addTest(setGetTests);
+ DriverMDProtocolsTests protocolsTest = new DriverMDProtocolsTests();
+ returnValue.addTest(protocolsTest);
return returnValue;
}
1.1 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMDProtocolsTests.java
Index: DriverMDProtocolsTests.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/DriverMDProtocolsTests.java,v
1.1 2002/10/29 10:19:17 prickett Exp $
* $Revision: 1.1 $
* $Date: 2002/10/29 10:19:17 $
*
* ====================================================================
*
* 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 java.util.Map;
import java.util.Hashtable;
import junit.framework.Test;
import org.apache.commons.periodicity.junit.TestWithMavenLogging;
public class DriverMDProtocolsTests extends TestWithMavenLogging
{
public static final String TEST_NAME =
"DriverMDProtocolsTest.protocols";
public static final String DRIVER_NAME = "driver";
public static final String protocolNames[] =
{ "protocol.default", "protocol.http", "protocol.hsqldb" };
public static final String protocolSchemes[] =
{ "jdbc:hsql", "jdbc:hsql:HTTP", "jdbc:hsql:HSQL" };
public static final String PROTOCOLS_DO_NOT_MATCH =
"The protocols returned to not match those that were set.";
public static final String ADDING_VALID_PROTOCOLS_NO_EXCEPTION =
"Adding a set of valid protocols should not cause an exception.";
public static final String PROTOCOL_SHOULD_BE_SUPPORTED =
"The test has detected that a protocol is missing.";
public static final String PROTOCOL_SHOULD_NOT_BE_SUPPORTED =
"The test has detected a protocol that should have been removed.";
public static final String REMOVING_A_VALID_PROTOCOL_NO_EXCEPTION =
"Removing a valid protocol should not cause an exception.";
public static final String REMOVING_A_MAP_OF_PROTOCOLS_NO_EXCEPTION =
"Removing a map of valid protocols should not cause an exception.";
public static final String REMOVING_ALL_PROTOCOLS_NO_EXCEPTION =
"Removing all protocols should not cause an exception.";
public static final String PROTOCOL_MAP_SHOULD_NOT_BE_NULL =
"The protocol map should not be null.";
public static final String PROTOCOL_MAP_SHOULD_BE_NULL =
"The protocol map should be null.";
public static final String NUMBER_OF_EXPECTED_PROTOCOLS_INCORRECT =
"The driver is reporting the wrong number of protocols.";
public static final String UNSUPPORTED_PROTOCOL_NAME =
"driver.unsupported";
public DriverMDProtocolsTests()
{
super(TEST_NAME);
}
protected void runTest()
{
try
{
DriverMetaDataImpl driverMeta =
new DriverMetaDataImpl(DRIVER_NAME);
for(int i=0; i < protocolNames.length; i++)
{
driverMeta.addProtocol(protocolNames[i], protocolSchemes[i]);
}
protocolsCorrect(driverMeta);
}
catch(Exception e)
{
fail(ADDING_VALID_PROTOCOLS_NO_EXCEPTION);
}
try
{
DriverMetaDataImpl driverMeta =
new DriverMetaDataImpl(DRIVER_NAME);
driverMeta.addProtocol(protocolNames[0], protocolSchemes[0]);
Hashtable protocolMap = new Hashtable();
for(int i=1; i < protocolNames.length; i++)
{
protocolMap.put(protocolNames[i], protocolSchemes[i]);
}
driverMeta.addProtocols(protocolMap);
protocolsCorrect(driverMeta);
}
catch(Exception e)
{
fail(ADDING_VALID_PROTOCOLS_NO_EXCEPTION);
}
try
{
DriverMetaDataImpl driverMeta =
new DriverMetaDataImpl(DRIVER_NAME);
Hashtable protocolMap = new Hashtable();
for(int i=0; i < protocolNames.length; i++)
{
protocolMap.put(protocolNames[i], protocolSchemes[i]);
}
driverMeta.setProtocols(protocolMap);
protocolsCorrect(driverMeta);
}
catch(Exception e)
{
fail(ADDING_VALID_PROTOCOLS_NO_EXCEPTION);
}
try
{
DriverMetaDataImpl driverMeta =
new DriverMetaDataImpl(DRIVER_NAME);
Hashtable protocolMap = new Hashtable();
for(int i=0; i < protocolNames.length; i++)
{
protocolMap.put(protocolNames[i], protocolSchemes[i]);
}
driverMeta.setProtocols(protocolMap);
driverMeta.removeProtocol(protocolNames[2]);
String protocol2 = driverMeta.getUrlScheme(protocolNames[2]);
assertNull(PROTOCOL_SHOULD_NOT_BE_SUPPORTED, protocol2);
String protocol0 = driverMeta.getUrlScheme(protocolNames[0]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[0],
protocol0);
String protocol1 = driverMeta.getUrlScheme(protocolNames[1]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[1],
protocol1);
}
catch(Exception e)
{
fail(REMOVING_A_VALID_PROTOCOL_NO_EXCEPTION);
}
try
{
DriverMetaDataImpl driverMeta =
new DriverMetaDataImpl(DRIVER_NAME);
Hashtable protocolMap = new Hashtable();
for(int i=0; i < protocolNames.length; i++)
{
protocolMap.put(protocolNames[i], protocolSchemes[i]);
}
driverMeta.setProtocols(protocolMap);
Hashtable removeMap = new Hashtable();
removeMap.put(protocolNames[2], protocolSchemes[2]);
removeMap.put(protocolNames[1], protocolNames[1]);
driverMeta.removeProtocols(removeMap);
String protocol0 = driverMeta.getUrlScheme(protocolNames[0]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[0],
protocol0);
String protocol1 = driverMeta.getUrlScheme(protocolNames[1]);
assertNull(PROTOCOL_SHOULD_NOT_BE_SUPPORTED, protocol1);
String protocol2 = driverMeta.getUrlScheme(protocolNames[2]);
assertNull(PROTOCOL_SHOULD_NOT_BE_SUPPORTED, protocol2);
}
catch(Exception e)
{
fail(REMOVING_A_MAP_OF_PROTOCOLS_NO_EXCEPTION);
}
try
{
DriverMetaDataImpl driverMeta =
new DriverMetaDataImpl(DRIVER_NAME);
Hashtable protocolMap = new Hashtable();
for(int i=0; i < protocolNames.length; i++)
{
protocolMap.put(protocolNames[i], protocolSchemes[i]);
}
driverMeta.setProtocols(protocolMap);
assertNotNull(PROTOCOL_MAP_SHOULD_NOT_BE_NULL,
driverMeta.getProtocols());
driverMeta.removeAllProtocols();
assertNull(PROTOCOL_MAP_SHOULD_BE_NULL, driverMeta.getProtocols());
}
catch(Exception e)
{
fail(REMOVING_ALL_PROTOCOLS_NO_EXCEPTION);
}
try
{
DriverMetaDataImpl driverMeta =
new DriverMetaDataImpl(DRIVER_NAME);
Hashtable protocolMap = new Hashtable();
for(int i=0; i < protocolNames.length; i++)
{
protocolMap.put(protocolNames[i], protocolSchemes[i]);
}
driverMeta.setProtocols(protocolMap);
String protocol0 = driverMeta.getUrlScheme(protocolNames[0]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[0],
protocol0);
String protocol1 = driverMeta.getUrlScheme(protocolNames[1]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[1],
protocol1);
String protocol2 = driverMeta.getUrlScheme(protocolNames[2]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[2],
protocol2);
}
catch(Exception e)
{
fail(ADDING_VALID_PROTOCOLS_NO_EXCEPTION);
}
try
{
DriverMetaDataImpl driverMeta =
new DriverMetaDataImpl(DRIVER_NAME);
Hashtable protocolMap = new Hashtable();
for(int i=0; i < protocolNames.length; i++)
{
protocolMap.put(protocolNames[i], protocolSchemes[i]);
}
driverMeta.setProtocols(protocolMap);
assertTrue(PROTOCOL_SHOULD_BE_SUPPORTED,
driverMeta.supportsProtocol(protocolNames[0]));
assertTrue(PROTOCOL_SHOULD_BE_SUPPORTED,
driverMeta.supportsProtocol(protocolNames[1]));
assertTrue(PROTOCOL_SHOULD_BE_SUPPORTED,
driverMeta.supportsProtocol(protocolNames[2]));
assertTrue(PROTOCOL_SHOULD_NOT_BE_SUPPORTED,
!driverMeta.supportsProtocol(UNSUPPORTED_PROTOCOL_NAME));
}
catch(Exception e)
{
fail(ADDING_VALID_PROTOCOLS_NO_EXCEPTION);
}
}
public void protocolsCorrect(DriverMetaDataImpl driverMeta)
throws Exception
{
Map protocolMap = driverMeta.getProtocols();
if(protocolMap != null)
{
assertEquals(NUMBER_OF_EXPECTED_PROTOCOLS_INCORRECT,
protocolNames.length, protocolMap.size());
String protocol0 = driverMeta.getUrlScheme(protocolNames[0]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[0],
protocol0);
String protocol1 = driverMeta.getUrlScheme(protocolNames[1]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[1],
protocol1);
String protocol2 = driverMeta.getUrlScheme(protocolNames[2]);
assertEquals(PROTOCOL_SHOULD_BE_SUPPORTED, protocolSchemes[2],
protocol2);
}
else
{
fail(PROTOCOL_MAP_SHOULD_NOT_BE_NULL);
}
}
}
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>
|