prickett 2002/11/29 18:25:51 Modified: periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database DriverContentHandler.java DriverMetaDataImpl.java DriverProtocol.java periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database DriverMDProtocolsTests.java DriverServiceGetInitTest.java Log: Added debug logging to log raw values for protocol data in Driver Content Handler Changed getProtocols in DriverMetaDataImpl to return a Collection instead of a Map Added a toString method to DriverMetaDataImpl. Fixed a bug where the scheme was not getting set for a default protocol Fixed Get Init Test to use the toString method Added code to Get Init Test to write the protocols to the log file. Revision Changes Path 1.9 +22 -3 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverContentHandler.java Index: DriverContentHandler.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverContentHandler.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DriverContentHandler.java 30 Nov 2002 00:43:23 -0000 1.8 +++ DriverContentHandler.java 30 Nov 2002 02:25:51 -0000 1.9 @@ -223,6 +223,25 @@ protocol.setUrl(protocolUrl); protocol.setAdminUrl(protocolAdminUrl); driverMeta.addProtocol(protocol); + if(getLogger() != null) + { + StringBuffer buffy = new StringBuffer(); + buffy.append("RAW PROTOCOL DATA\n"); + buffy.append("protocolName=\""); + buffy.append(protocolName); + buffy.append("\nscheme=\""); + buffy.append(scheme); + buffy.append("\nprotocolUrl=\""); + buffy.append(protocolUrl); + buffy.append("\nprotocolAdminUrl=\""); + buffy.append(protocolAdminUrl); + buffy.append("\""); + getLogger().debug(buffy.toString()); + } + scheme = null; + protocolName = null; + protocolUrl = null; + protocolAdminUrl = null; } else if(lookForDrivers && qName != null && qName.equals(SCHEME_QNAME)) 1.10 +57 -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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- DriverMetaDataImpl.java 30 Nov 2002 00:43:23 -0000 1.9 +++ DriverMetaDataImpl.java 30 Nov 2002 02:25:51 -0000 1.10 @@ -68,6 +68,7 @@ import java.util.Hashtable; import java.util.Set; import java.util.Iterator; +import java.util.Collection; public class DriverMetaDataImpl implements DriverMetaData { @@ -390,9 +391,16 @@ * @return The set of jdbc drivers supported by this jdbc driver as * a java.util.Map. */ - Map getProtocols() + Collection getProtocols() { - return protocols; + if(protocols != null) + { + return protocols.values(); + } + else + { + return null; + } } /** @@ -448,6 +456,50 @@ } return driverMap; } + + public String toString() + { + StringBuffer buffy = new StringBuffer(); + buffy.append(getName()); + buffy.append("\n"); + buffy.append("getShortDescription()=\""); + buffy.append(getShortDescription()); + buffy.append("\"\ngetDescription()=\""); + buffy.append(getDescription()); + buffy.append("\"\ngetWebUrl()=\""); + buffy.append(getWebUrl()); + buffy.append("\"\ngetClassName()=\""); + buffy.append(getClassName()); + buffy.append("\"\n PROTOCOLS\n"); + Collection protocols = getProtocols(); + if(protocols != null) + { + Iterator iter = protocols.iterator(); + if(iter != null) + { + while(iter.hasNext()) + { + Object protocol = iter.next(); + if(protocol instanceof DriverProtocol) + { + DriverProtocol refinedProtocol = + (DriverProtocol) protocol; + buffy.append(" getName()=\""); + buffy.append(refinedProtocol.getName()); + buffy.append("\"\n getScheme()=\""); + buffy.append(refinedProtocol.getScheme()); + buffy.append("\"\n getUrl()=\""); + buffy.append(refinedProtocol.getUrl()); + buffy.append("\"\n getAdminUrl()=\""); + buffy.append(refinedProtocol.getAdminUrl()); + buffy.append("\"\n\n"); + } + } + } + } + buffy.append(" END PROTOCOLS"); + return buffy.toString(); + } /** * The purpose of this method is to set the properties that are associated 1.3 +4 -3 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverProtocol.java Index: DriverProtocol.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DriverProtocol.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DriverProtocol.java 30 Nov 2002 00:43:23 -0000 1.2 +++ DriverProtocol.java 30 Nov 2002 02:25:51 -0000 1.3 @@ -99,6 +99,7 @@ else if(newName == null) { setName(DEFAULT_PROTOCOL_NAME); + setScheme(newScheme); } else { 1.3 +5 -4 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMDProtocolsTests.java Index: DriverMDProtocolsTests.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverMDProtocolsTests.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DriverMDProtocolsTests.java 30 Nov 2002 00:43:23 -0000 1.2 +++ DriverMDProtocolsTests.java 30 Nov 2002 02:25:51 -0000 1.3 @@ -63,6 +63,7 @@ */ import java.util.Map; +import java.util.Collection; import java.util.Hashtable; import junit.framework.Test; import org.apache.commons.periodicity.junit.TestWithMavenLogging; @@ -327,7 +328,7 @@ public void protocolsCorrect(DriverMetaDataImpl driverMeta) throws Exception { - Map protocolMap = driverMeta.getProtocols(); + Collection protocolMap = driverMeta.getProtocols(); if(protocolMap != null) { assertEquals(NUMBER_OF_EXPECTED_PROTOCOLS_INCORRECT, 1.8 +38 -6 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceGetInitTest.java Index: DriverServiceGetInitTest.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceGetInitTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DriverServiceGetInitTest.java 29 Nov 2002 03:32:28 -0000 1.7 +++ DriverServiceGetInitTest.java 30 Nov 2002 02:25:51 -0000 1.8 @@ -64,6 +64,7 @@ import java.util.Iterator; +import java.util.Collection; import junit.framework.Test; import junit.framework.TestCase; import org.apache.commons.configuration.BaseConfiguration; @@ -150,8 +151,11 @@ getLogger().info("BEGIN DRIVERS"); for(int i=0; i<DRIVERS.length; i++) { - getLogger().info(getLogMessage( - service.getMetaData(DRIVERS[i]))); + DriverMetaData drvrMeta = service.getMetaData(DRIVERS[i]); + if(drvrMeta != null) + { + getLogger().info(drvrMeta.toString()); + } } getLogger().info("END DRIVERS"); } @@ -172,7 +176,35 @@ buffy.append(meta.getWebUrl()); buffy.append("\"\ngetClassName()=\""); buffy.append(meta.getClassName()); - buffy.append("\"\n"); + buffy.append("\"\n PROTOCOLS\n"); + DriverMetaDataImpl dimple = (DriverMetaDataImpl) meta; + Collection protocols = dimple.getProtocols(); + if(protocols != null) + { + Iterator iter = protocols.iterator(); + if(iter != null) + { + while(iter.hasNext()) + { + Object protocol = iter.next(); + if(protocol instanceof DriverProtocol) + { + DriverProtocol refinedProtocol = + (DriverProtocol) protocol; + buffy.append(" getName()=\""); + buffy.append(refinedProtocol.getName()); + buffy.append("\n getScheme()=\""); + buffy.append(refinedProtocol.getScheme()); + buffy.append("\n getUrl()=\""); + buffy.append(refinedProtocol.getUrl()); + buffy.append("\n getAdminUrl()=\""); + buffy.append(refinedProtocol.getAdminUrl()); + buffy.append("\n\n"); + } + } + } + } + buffy.append(" END PROTOCOLS"); return buffy.toString(); } else
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>