I could never run the test bed more than once because bookstore-data.sql
for some is put in the src/sqldb.map just as "bookstore-data.sql" not
"../bookstore-data.sql" as it should be (it 

Instead of tracking this down, perhaps I'll get to later as I
investigate what exactly these datadump/datadtd/datasql tasks do, I put
a delete call in the build-test.xml file that deletes the rttest/src dir
with each invocation of "ant test".

Also, while tracking down the bug, I cleaned up a method of
TorqueSQLExec.java. None of the logic changed, but I renamed the
variables to meaning things. E.g. instead of "h" representing a hash
table of databases and "x" representing a list of files throughout a
fairly lengthy method, I choose databases and files, respectively.

Thanks,
Stephen

Index: build-test.xml
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/build-test.xml,v
retrieving revision 1.32
diff -u -r1.32 build-test.xml
--- build-test.xml      11 Jul 2002 18:09:26 -0000      1.32
+++ build-test.xml      15 Jul 2002 06:23:24 -0000
@@ -22,6 +22,8 @@
     name="test-prepare"
     depends="filterTokens,test-libs,test-templates">
 
+    <delete dir="${build.test}/rttest/src"/>
+
     <!-- Use the profile as the build.properties file
          in the dist directory so that it is customizable
          by each tester. -->


Index: TorqueSQLExec.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueSQLExec.java,v
retrieving revision 1.9
diff -u -r1.9 TorqueSQLExec.java
--- TorqueSQLExec.java  7 May 2002 18:24:43 -0000       1.9
+++ TorqueSQLExec.java  15 Jul 2002 05:51:25 -0000
@@ -466,12 +466,12 @@
             throw new BuildException("Url attribute must be set!", location);
         }
 
-        Properties p = new Properties();
+        Properties map = new Properties();
 
         try
         {
             FileInputStream fis = new FileInputStream(getSqlDbMap());
-            p.load(fis);
+            map.load(fis);
             fis.close();
         }
         catch (IOException ioe)
@@ -479,51 +479,59 @@
             throw new BuildException("Cannot open and process the sqldbmap!");
         }
 
-        Hashtable h = new Hashtable();
-        TreeSet keys = new TreeSet(p.keySet());
+        Hashtable databases = new Hashtable();
 
-        for (Iterator e = keys.iterator(); e.hasNext(); )
+        for (Iterator eachProperty = map.keySet().iterator(); eachProperty.hasNext(); 
+)
         {
-            String sqlfile = (String) e.next();
-            String database = p.getProperty(sqlfile);
+            String sqlfile = (String) eachProperty.next();
+            String database = map.getProperty(sqlfile);
 
-            ArrayList x = (ArrayList) h.get(database);
+            ArrayList files = (ArrayList) databases.get(database);
 
-            if (x == null)
+            if (files == null)
             {
-                x = new ArrayList();
-                h.put(database, x);
+                files = new ArrayList();
+                databases.put(database, files);
             }
 
             // We want to make sure that the base schemas
             // are inserted first.
             if (sqlfile.indexOf("schema.sql") != -1)
             {
-                x.add(0, sqlfile);
+                files.add(0, sqlfile);
             }
             else
             {
-                x.add(sqlfile);
+                files.add(sqlfile);
             }
         }
 
-        Iterator k = h.keySet().iterator();
-
-        while (k.hasNext())
+        Iterator eachDatabase = databases.keySet().iterator();
+        while (eachDatabase.hasNext())
         {
-            String db = (String) k.next();
-            ArrayList l = (ArrayList) h.get(db);
-            Iterator j = l.iterator();
-            List ts = new ArrayList();
-            while (j.hasNext())
+            String db = (String) eachDatabase.next();
+            ArrayList files = (ArrayList) databases.get(db);
+            
+            Iterator eachFile = files.iterator();
+            List transactions = new ArrayList();
+            while (eachFile.hasNext())
             {
-                String s = (String) j.next();
-                Transaction t = new Transaction();
-                t.setSrc(new File(srcDir, s));
-                ts.add(t);
+                String fileName = (String) eachFile.next();
+                File file = new File(srcDir, fileName);
+                
+                if (file.exists())
+                {                
+                    Transaction transaction = new Transaction();
+                    transaction.setSrc(file);
+                    transactions.add(transaction);
+                }
+                else
+                {
+                    super.log("File '" + fileName + "' in sqldbmap does not exist, so 
+skipping it.");
+                }
             }
 
-            insertDatabaseSqlFiles(url, db, ts);
+            insertDatabaseSqlFiles(url, db, transactions);
         }
     }
 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to