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 DriverServiceGetInitTest.java
Date Fri, 29 Nov 2002 03:32:28 GMT
prickett    2002/11/28 19:32:28

  Modified:    periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database
                        DriverContentHandler.java
                        PeriodicityDriverService.java
               periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database
                        DriverServiceGetInitTest.java
  Log:
  Removed the processProtocol variable from the DriverContentHandler
  
  Fixed bug where the PeriodicityDrvierService was not adding all the drivers.
  
  Revision  Changes    Path
  1.7       +33 -20    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DriverContentHandler.java	28 Nov 2002 22:42:36 -0000	1.6
  +++ DriverContentHandler.java	29 Nov 2002 03:32:28 -0000	1.7
  @@ -70,6 +70,8 @@
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.DefaultHandler;
  +import org.apache.log4j.Logger;
  +import org.apache.log4j.LogManager;
   import org.apache.commons.periodicity.util.JUnitUtils;
   
   public class DriverContentHandler extends DefaultHandler
  @@ -109,9 +111,6 @@
       /** A flag to tell us whether we should be looking to add new drivers */
       private boolean lookForDrivers = false;
   
  -    /** A flag to tell us whether we should process protocols */
  -    private boolean processProtocol = false;
  -
       /** A variable to hold the url scheme for the current jdbc protocol */
       private String scheme = null;
   
  @@ -131,6 +130,8 @@
   
       private Set drivers = null;
   
  +    private static Logger logger = null;
  +
   
       public void startElement(String uri, String localName, String qName,
              Attributes attributes) throws SAXException
  @@ -139,6 +140,10 @@
                  qName.equals(DRIVERS_ELEMENT_QNAME))
           {
               lookForDrivers = true;
  +            if(getLogger() != null)
  +            {
  +                getLogger().debug("Looking for drivers...");
  +            }    
           }
           else if(lookForDrivers && qName != null && 
                  qName.equals(DRIVER_ELEMENT_QNAME))
  @@ -150,6 +155,11 @@
                   {
                       try
                       {
  +                        if(getLogger() != null)
  +                        {
  +                            getLogger().debug("Found driver - \"" +
  +                                   rawName + "\"");
  +                        }           
                           driverMeta = new DriverMetaDataImpl(rawName);
                       }
                       catch(Exception e)
  @@ -193,18 +203,17 @@
       {
           try
           {
  -            if(lookForDrivers && processProtocol && qName != null &&
  +            if(lookForDrivers && qName != null &&
                      qName.equals(PROTOCOL_ELEMENT_QNAME))
               {
                   driverMeta.addProtocol(protocolName, scheme);
  -                processProtocol = false;
               }
  -            else if(lookForDrivers && processProtocol && qName != null
&&
  +            else if(lookForDrivers && qName != null &&
                      qName.equals(SCHEME_QNAME))
               {
                   scheme = buffy.toString();
               }    
  -            else if(lookForDrivers && !processProtocol && qName != null
&& 
  +            else if(lookForDrivers && qName != null && 
                      qName.equals(DRIVER_ELEMENT_QNAME))
               {
                   if(drivers == null)
  @@ -214,34 +223,29 @@
                   if(driverMeta != null)
                   {
                       drivers.add(driverMeta);
  +                    driverMeta = null;
                   }    
               }
  -            else if(lookForDrivers && !processProtocol && qName != null
&& 
  +            else if(lookForDrivers && qName != null && 
                      qName.equals(SHORT_DESC_QNAME))
               {
                   driverMeta.setShortDescription(buffy.toString());
               }
  -            else if(lookForDrivers && !processProtocol && qName != null
&&
  +            else if(lookForDrivers && qName != null &&
                      qName.equals(DESCRIPTION_QNAME))
               {
                   driverMeta.setDescription(buffy.toString());
               }
  -            else if(lookForDrivers && !processProtocol && qName != null
&&
  +            else if(lookForDrivers && qName != null &&
                      qName.equals(WEB_URL_QNAME))
               {
                   driverMeta.setWebUrl(buffy.toString());
               }
  -            else if(lookForDrivers && !processProtocol && qName != null
&& 
  +            else if(lookForDrivers && qName != null && 
                      qName.equals(DRIVER_CLASS_QNAME))
               {
                   driverMeta.setClassName(buffy.toString());
               }
  -            else if(!lookForDrivers && processProtocol)
  -            {
  -                throw new SAXException(
  -                       "We should not be processing protocols if we are not " +
  -                       "looking for drivers.");
  -            }
               else if(qName == null)
               {
                   throw new SAXException("qName == null");
  @@ -269,5 +273,14 @@
       public Set getDrivers()
       {
           return drivers;
  +    }    
  +
  +    private Logger getLogger()
  +    {
  +        if(logger == null)
  +        {
  +            logger = LogManager.getRootLogger();
  +        }
  +        return logger;
       }    
   }    
  
  
  
  1.7       +15 -12    jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/PeriodicityDriverService.java
  
  Index: PeriodicityDriverService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/PeriodicityDriverService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PeriodicityDriverService.java	29 Nov 2002 01:52:44 -0000	1.6
  +++ PeriodicityDriverService.java	29 Nov 2002 03:32:28 -0000	1.7
  @@ -189,16 +189,19 @@
               Iterator iter = drivers.iterator();
               if(iter != null)
               {
  -                Object drvr = iter.next();
  -                if(drvr instanceof DriverMetaData)
  +                while(iter.hasNext())
                   {
  -                    addDriver((DriverMetaData) drvr);
  -                }
  -                else
  -                {
  -                    throw new InitializationException(
  -                           "drvr not a DriverMetaData object.");
  -                }
  +                    Object drvr = iter.next();
  +                    if(drvr instanceof DriverMetaData)
  +                    {
  +                        addDriver((DriverMetaData) drvr);
  +                    }
  +                    else
  +                    {
  +                        throw new InitializationException(
  +                               "drvr not a DriverMetaData object.");
  +                    }
  +                }    
               }
               else
               {
  
  
  
  1.7       +14 -13    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DriverServiceGetInitTest.java	29 Nov 2002 01:52:44 -0000	1.6
  +++ DriverServiceGetInitTest.java	29 Nov 2002 03:32:28 -0000	1.7
  @@ -91,6 +91,11 @@
       public static final String PERIODICITY_DRIVER_SERVICE_NAME =
              "PeriodicityDriverService";
       
  +    public static final String[] DRIVERS = 
  +           { "mysql.default", "postgresql.default", "oracle.default",
  +             "axion.default", "cloudscape.default", "hypersonic.default",
  +             "interbase.default" };
  +    
       public DriverServiceGetInitTest(String name)
       {
           super(name);
  @@ -140,19 +145,15 @@
   
       private void logDrivers(PeriodicityDriverService service)
       {
  -        if(service != null)
  +        if(service != null && getLogger() != null)
           {
  -            Iterator iter = service.getDrivers();
  -            if(iter != null && getLogger() != null)
  +            getLogger().info("BEGIN DRIVERS");
  +            for(int i=0; i<DRIVERS.length; i++)
               {
  -                getLogger().info("BEGIN DRIVERS");
  -                while(iter.hasNext())
  -                {
  -                    getLogger().info(
  -                           getLogMessage((DriverMetaData) iter.next()));
  -                }
  -                getLogger().info("END DRIVERS");
  +                getLogger().info(getLogMessage(
  +                       service.getMetaData(DRIVERS[i])));
               }
  +            getLogger().info("END DRIVERS");
           }
       }    
       
  
  
  

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