db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fuzzylo...@apache.org
Subject svn commit: r148965 - in incubator/derby/code/branches/10.0/java: testing/org/apache/derbyTesting/functionTests/master testing/org/apache/derbyTesting/functionTests/tests/derbynet testing/org/apache/derbyTesting/functionTests/tests/tools tools/org/apache/derby/impl/tools/dblook tools/org/apache/derby/tools
Date Sat, 29 Jan 2005 00:33:17 GMT
Author: fuzzylogic
Date: Fri Jan 28 16:33:16 2005
New Revision: 148965

URL: http://svn.apache.org/viewcvs?view=rev&rev=148965
Log:
Merge revision 111185 to 10.0 branch.

Added:
   incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
      - copied unchanged from r111185, incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
   incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_sed.properties
      - copied unchanged from r111185, incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_sed.properties
Modified:
   incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
   incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net.java
   incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/copyfiles.ant
   incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java
   incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties
   incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/DB_Jar.java
   incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/Logs.java
   incubator/derby/code/branches/10.0/java/tools/org/apache/derby/tools/dblook.java

Modified: incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out?view=diff&rev=148965&p1=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out&r1=148964&p2=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out&r2=148965
==============================================================================
--- incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
(original)
+++ incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
Fri Jan 28 16:33:16 2005
@@ -1,4 +1,4 @@
--= Start Test. =-
+-= Start dblook Functional Tests. =-
 Creating database 'wombat' from ddl script 'dblook_makeDB.sql'
 Dumping system tables for 'wombat'
 ----------------=================---------------
@@ -4628,7 +4628,11 @@
 Dumping DDL w/ invalid url, and writing
 error to the log:
 *******************************************
-File dblook.log was NOT empty; refer to that file (in the test directory) to see its contents.
+File dblook.log was NOT empty.  Contents are:
+############## Begin File Contents ################
+java.sql.SQLException: No suitable driver
+-- **--> DEBUG: No suitable driver
+############## End File Contents ################
 Creating database 'wombat_new' from ddl script 'wombat.sql'
 Dumping system tables for 'wombat_new'
 ----------------=================---------------
@@ -4655,4 +4659,205 @@
 ========== SYSTRIGGERS ==========
 ========== SYSVIEWS ==========
 Database 'wombat_new' deleted.
+-= Start dblook Message Tests =-
+Database 'wombat' deleted.
+Creating database 'wombat' from ddl script 'dblook_makeDB_2.sql'
+************
+Msg Test 1
+************
+--
+*******************************************
+Dumping full schema for 'wombat'
+to file 'wombat.sql':
+*******************************************
+File wombat.sql was NOT empty.  Contents are:
+############## Begin File Contents ################
+-- ============================
+-- This file was created using Derby's dblook utility.
+-- Timestamp: xxxxxxFILTERED-TIMESTAMPxxxxx
+-- Source database is: <dbPath>
+-- Connection URL is: <dbURL>
+-- appendLogs: false
+-- ----------------------------------------------
+-- DDL Statements for schemas
+-- ----------------------------------------------
+CREATE SCHEMA "BAR"
+-- ----------------------------------------------
+-- DDL Statements for jars
+-- **** NOTE **** In order for jar files to be loaded correctly,
+-- you must either 1) ensure that the DBJARS directory (created
+-- automatically by dblook) exists where it was created (i.e. at
+-- the path shown in the statements below), or else 2) change the
+-- path in the statements below to reflect the current location of
+-- DBJARS.  If the DBJARS directory does not exist, or if it
+-- has been moved and the path is not correct, the following DDL
+-- statements will throw errors, and the jar files will NOT be
+-- loaded.
+-- ----------------------------------------------
+CALL SQLJ.INSTALL_JAR(<maskedOutJarDesc>)
+-- ----------------------------------------------
+-- DDL Statements for stored procedures
+-- ----------------------------------------------
+CREATE PROCEDURE "APP"."PROC1" (INOUT A CHAR(10),IN B INTEGER) LANGUAGE JAVA PARAMETER STYLE
JAVA CONTAINS SQL DYNAMIC RESULT SETS 4 EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.ProcedureTest.inoutparams3'

+-- ----------------------------------------------
+-- DDL Statements for tables
+-- ----------------------------------------------
+CREATE TABLE "BAR"."T1" ("C" CHAR(5) NOT NULL, "I" INTEGER, "VC" VARCHAR(10), "FKCHAR" CHAR(5))
+-- ----------------------------------------------
+-- DDL Statements for indexes
+-- ----------------------------------------------
+CREATE INDEX "BAR"."IX1" ON "BAR"."T1" ("I" DESC)
+-- ----------------------------------------------
+-- DDL Statements for keys
+-- ----------------------------------------------
+-- primary/unique
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "xxxxGENERATED-IDxxxx" PRIMARY KEY ("C")
+-- foreign
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "xxxxGENERATED-IDxxxx" FOREIGN KEY ("FKCHAR") REFERENCES
"BAR"."T1" ("C") ON DELETE NO ACTION ON UPDATE NO ACTION
+-- ----------------------------------------------
+-- DDL Statements for checks
+-- ----------------------------------------------
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "NOTEVIL" CHECK (vc != 'evil')
+-- ----------------------------------------------
+-- DDL Statements for views
+-- ----------------------------------------------
+SET SCHEMA "APP"
+create view v1 (dum, dee, dokie) as select a.c, a.i, a.vc from bar.t1 as a
+-- Reverting back to default schema 'APP'
+SET SCHEMA "APP"
+-- ----------------------------------------------
+-- DDL Statements for triggers
+-- ----------------------------------------------
+CREATE TRIGGER "APP"."TRIGONE" AFTER INSERT ON "BAR"."T1" FOR EACH ROW MODE DB2SQL update
bar.t1 set i = 4 where i = 2
+############## End File Contents ################
+File dblook.log was empty.
+************
+Msg Test 2
+************
+File wombat.sql was NOT empty.  Contents are:
+############## Begin File Contents ################
+-- ============================
+-- This file was created using Derby's dblook utility.
+-- Timestamp: xxxxxxFILTERED-TIMESTAMPxxxxx
+-- Source database is: <dbPath>
+-- Connection URL is: <dbURL>
+-- The dblook utility will consider only specified tables.
+-- Specified schema is: bar
+-- appendLogs: false
+-- ----------------------------------------------
+-- DDL Statements for schemas
+-- ----------------------------------------------
+CREATE SCHEMA "BAR";
+-- ----------------------------------------------
+-- DDL Statements for tables
+-- ----------------------------------------------
+CREATE TABLE "BAR"."T1" ("C" CHAR(5) NOT NULL, "I" INTEGER, "VC" VARCHAR(10), "FKCHAR" CHAR(5));
+-- ----------------------------------------------
+-- DDL Statements for indexes
+-- ----------------------------------------------
+CREATE INDEX "BAR"."IX1" ON "BAR"."T1" ("I" DESC);
+-- ----------------------------------------------
+-- DDL Statements for keys
+-- ----------------------------------------------
+-- primary/unique
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "xxxxGENERATED-IDxxxx" PRIMARY KEY ("C");
+-- foreign
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "xxxxGENERATED-IDxxxx" FOREIGN KEY ("FKCHAR") REFERENCES
"BAR"."T1" ("C") ON DELETE NO ACTION ON UPDATE NO ACTION;
+-- ----------------------------------------------
+-- DDL Statements for checks
+-- ----------------------------------------------
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "NOTEVIL" CHECK (vc != 'evil');
+############## End File Contents ################
+File dblook.log was empty.
+************
+Msg Test 3
+************
+ USAGE:
+ java org.apache.derby.tools.dblook -d <sourceDBUrl> [OPTIONS]
+ 	where the source URL is the full URL, including the connection protocol
+ 	and any connection attributes that might apply.  For example, use
+ 	'jdbc:derby:myDB', or 'jdbc:derby:net://localhost:1527/myDB:user=usr;'. 
+ 	options include: 
+ 	-z <schemaName> to specify a schema to which the DDL generation
+ 	 should be limited.  Only database objects with that schema will have
+ 	 their DDL generated.
+ 	-t <tableOne> <tableTwo> ... to specify a list of tables for which
+ 	 the DDL will be generated; any tables not in the list will be ignored.
+ 	-td <value> to specify what should be appended to the end
+ 	 of each DDL statement.
+		This defaults to ';'.
+ 	-noview to prevent the generation of DDL for views.
+ 	-append to keep from overwriting the output files.
+ 	-verbose to have error messages printed to the console (in addition
+ 	 to the log file).  If not specified, errors will only be printed to the
+ 	 log file.
+ 	-o <filename> to specify the file name to which the generated DDL
+ 	 will be written.
+ 		If not specified, default is the console. 
+************
+Msg Test 4
+************
+-- Timestamp: xxxxxxFILTERED-TIMESTAMPxxxxx
+-- Source database is: <dbPath>
+-- Connection URL is: <dbURL>
+-- appendLogs: false
+-- ----------------------------------------------
+-- DDL Statements for schemas
+-- ----------------------------------------------
+CREATE SCHEMA "BAR" #
+-- ----------------------------------------------
+-- DDL Statements for jars
+-- **** NOTE **** In order for jar files to be loaded correctly,
+-- you must either 1) ensure that the DBJARS directory (created
+-- automatically by dblook) exists where it was created (i.e. at
+-- the path shown in the statements below), or else 2) change the
+-- path in the statements below to reflect the current location of
+-- DBJARS.  If the DBJARS directory does not exist, or if it
+-- has been moved and the path is not correct, the following DDL
+-- statements will throw errors, and the jar files will NOT be
+-- loaded.
+-- ----------------------------------------------
+CALL SQLJ.INSTALL_JAR(<maskedOutJarDesc>)
+-- ----------------------------------------------
+-- DDL Statements for stored procedures
+-- ----------------------------------------------
+CREATE PROCEDURE "APP"."PROC1" (INOUT A CHAR(10),IN B INTEGER) LANGUAGE JAVA PARAMETER STYLE
JAVA CONTAINS SQL DYNAMIC RESULT SETS 4 EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.ProcedureTest.inoutparams3'
 #
+-- ----------------------------------------------
+-- DDL Statements for tables
+-- ----------------------------------------------
+CREATE TABLE "BAR"."T1" ("C" CHAR(5) NOT NULL, "I" INTEGER, "VC" VARCHAR(10), "FKCHAR" CHAR(5))
#
+-- ----------------------------------------------
+-- DDL Statements for indexes
+-- ----------------------------------------------
+CREATE INDEX "BAR"."IX1" ON "BAR"."T1" ("I" DESC) #
+-- ----------------------------------------------
+-- DDL Statements for keys
+-- ----------------------------------------------
+-- primary/unique
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "xxxxGENERATED-IDxxxx" PRIMARY KEY ("C") #
+-- foreign
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "xxxxGENERATED-IDxxxx" FOREIGN KEY ("FKCHAR") REFERENCES
"BAR"."T1" ("C") ON DELETE NO ACTION ON UPDATE NO ACTION #
+-- ----------------------------------------------
+-- DDL Statements for checks
+-- ----------------------------------------------
+ALTER TABLE "BAR"."T1" ADD CONSTRAINT "NOTEVIL" CHECK (vc != 'evil') #
+-- ----------------------------------------------
+-- DDL Statements for views
+-- ----------------------------------------------
+SET SCHEMA "APP" #
+create view v1 (dum, dee, dokie) as select a.c, a.i, a.vc from bar.t1 as a #
+-- Reverting back to default schema 'APP'
+SET SCHEMA "APP" #
+-- ----------------------------------------------
+-- DDL Statements for triggers
+-- ----------------------------------------------
+CREATE TRIGGER "APP"."TRIGONE" AFTER INSERT ON "BAR"."T1" FOR EACH ROW MODE DB2SQL update
bar.t1 set i = 4 where i = 2 #
+************
+Msg Test 5
+************
+File dblook.log was NOT empty.  Contents are:
+############## Begin File Contents ################
+-- **--> DEBUG: Failed to load jar file <jarFilePath>
+java.io.FileNotFoundException: <filePath>
+############## End File Contents ################
 [ Done. ]

Modified: incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net.java?view=diff&rev=148965&p1=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net.java&r1=148964&p2=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net.java&r2=148965
==============================================================================
--- incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net.java
(original)
+++ incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net.java
Fri Jan 28 16:33:16 2005
@@ -47,7 +47,7 @@
 
 		try {
 
-			createTestDatabase();
+			createTestDatabase(dbCreationScript_1);
 
 			// Don't let error stream ruin the diff.
 			System.err.close();

Modified: incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/copyfiles.ant
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/copyfiles.ant?view=diff&rev=148965&p1=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/copyfiles.ant&r1=148964&p2=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/copyfiles.ant&r2=148965
==============================================================================
--- incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/copyfiles.ant
(original)
+++ incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/copyfiles.ant
Fri Jan 28 16:33:16 2005
@@ -1,5 +1,7 @@
 default_app.properties
 default_derby.properties
 dblook_makeDB.sql
+dblook_makeDB_2.sql
 dblook_test.jar
 dblook_test_app.properties
+dblook_test_sed.properties

Copied: incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
(from r111185, incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql)
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql?view=diff&rev=148965&p1=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql&r1=111185&p2=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql&r2=148965
==============================================================================

Modified: incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java?view=diff&rev=148965&p1=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java&r1=148964&p2=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java&r2=148965
==============================================================================
--- incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java
(original)
+++ incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java
Fri Jan 28 16:33:16 2005
@@ -53,7 +53,8 @@
 	private static final int FRONT = -1;
 	private static final int REAR = 1;
 
-	private static final String testDBCreationScript = "dblook_makeDB.sql";
+	protected static final String dbCreationScript_1 = "dblook_makeDB.sql";
+	protected static final String dbCreationScript_2 = "dblook_makeDB_2.sql";
 	private static final char TEST_DELIMITER='#';
 
 	protected static String testDirectory = "dblook_test/";
@@ -72,7 +73,6 @@
 
 	public static void main (String[] args) {
 
-		System.out.println("\n-= Start Test. =-");
 		separator = System.getProperty("file.separator");
 		new dblook_test().doTest();
 		System.out.println("\n[ Done. ]\n");
@@ -88,23 +88,30 @@
 
 		try {
 
-			createTestDatabase();
-			runCSLook(testDBName);
+			// Test full dblook functionality.
+			System.out.println("\n-= Start dblook Functional Tests. =-");
+			createTestDatabase(dbCreationScript_1);
+			runDBLook(testDBName);
+
+			// Test dblook messages.
+			System.out.println("\n-= Start dblook Message Tests =-");
+			createTestDatabase(dbCreationScript_2);
+			runMessageCheckTest(testDBName);
 
 		} catch (SQLException se) {
 
 			System.out.println("FAILED: to complete the test:");
-			se.printStackTrace();
+			se.printStackTrace(System.out);
 			for (se = se.getNextException(); se != null;
 				se = se.getNextException())
 			{
-				se.printStackTrace();
+				se.printStackTrace(System.out);
 			}
 		
 		} catch (Exception e) {
 
 			System.out.println("FAILED: to complete the test:");
-			e.printStackTrace();
+			e.printStackTrace(System.out);
 
 		}
 
@@ -116,18 +123,28 @@
 	 * the test package, create the database that
 	 * will be used as the basis for all dblook
 	 * tests.
+	 * @param scriptName The name of the sql script
+	 *  to use for creating the test database.
 	 * @return The test database has been created
 	 *  in the current test directory, which is
 	 *  "./dblook/" (as created by the harness).
 	 ****/
 
-	protected void createTestDatabase()
+	protected void createTestDatabase(String scriptName)
 		throws Exception
 	{
 
+		// Delete existing database, if it exists.
+		try {
+			deleteDB(testDBName);
+		} catch (Exception e) {
+			System.out.println("** Warning: failed to delete " +
+				"old test db before creating a new one...");
+		}
+
 		Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
 		jdbcProtocol = "jdbc:derby:";
-		createDBFromDDL(testDBName, testDBCreationScript);
+		createDBFromDDL(testDBName, scriptName);
 
 		// Figure out where our database directory is (abs path).
 		dbPath = (new File(testDirectory)).getAbsolutePath();
@@ -136,7 +153,7 @@
 	}
 
 	/* **********************************************
-	 * runCSLook:
+	 * runDBLook:
 	 * Runs a series of tests using dblook on
 	 * the received database.
 	 * @param dbName The name of the database on which to
@@ -146,7 +163,7 @@
 	 *  has been run.
 	 ****/
 
-	private void runCSLook(String dbName)
+	private void runDBLook(String dbName)
 		throws Exception
 	{
 
@@ -169,7 +186,6 @@
 		lookOne(dbName);
 		dumpFileToSysOut("dblook.log");
 
-
 		// Now, create new db from the DDL that
 		// was generated by dblook.
 		String newDBName = dbName + "_new";
@@ -273,17 +289,17 @@
 		} catch (SQLException e) {
 
 			System.out.println("FAILED: Test # : " + whichTest);
-			System.out.println(e.getMessage());
+			e.printStackTrace(System.out);
 			for (e = e.getNextException(); e != null;
 				e = e.getNextException())
 			{
-				System.out.println(e.getMessage());
+				e.printStackTrace(System.out);
 			}
 
 		} catch (Exception e) {
 
 			System.out.println("FAILED: Test # : " + whichTest);
-			System.out.println(e.getMessage());
+			e.printStackTrace(System.out);
 
 		}
 
@@ -382,18 +398,17 @@
 		} catch (SQLException e) {}
 
 		// Run the test.
+		try {
 
-		dblook looker = new dblook(new String[] {
-			"-d", sourceDBUrl,
-			"-o", dbName + ".sql",
-			"-td", "" }
-		);
+			new dblook(new String[] {
+				"-d", sourceDBUrl,
+				"-o", dbName + ".sql",
+				"-td", "" }
+			);
 
-		try {
-			looker.go(sourceDBUrl, dbPath + separator + dbName);
 		} catch (Exception e) {
 			System.out.println("FAILED: ");
-			e.printStackTrace();
+			e.printStackTrace(System.out);
 		}
 
 		return;
@@ -483,15 +498,10 @@
 			"writing\nerror to the log:\n");
  
 		// Url is intentionally incorrect; it will cause an error.
-		dblook looker = new dblook(new String[] {
+		new dblook(new String[] {
 			"-o", dbName + ".sql",
 			"-d", dbName }
 		);
-		try {
-			looker.go(dbName, dbName);
-		} catch (Exception e) {
-		// we expect it to go wrong.
-		}
 
 	}
 
@@ -540,19 +550,129 @@
 		String sourceDBUrl = jdbcProtocol + dbPath +
 			separator + dbName;
 
-		String [] fullArgs = new String[args.length+3];
+		String [] fullArgs = new String[args.length+2];
 		fullArgs[0] = "-d";
 		fullArgs[1] = sourceDBUrl;
-		fullArgs[2] = "-append";
-		for (int i = 3; i < fullArgs.length; i++)
-			fullArgs[i] = args[i-3];
+		for (int i = 2; i < fullArgs.length; i++)
+			fullArgs[i] = args[i-2];
 
-		dblook looker = new dblook(fullArgs);
 		try {
-			looker.go(sourceDBUrl, dbPath + separator + dbName);
+			new dblook(fullArgs);
 		} catch (Exception e) {
-			System.out.println("FAILED: ");
-			e.printStackTrace();
+			System.out.println("FAILED: to run dblook: ");
+			e.printStackTrace(System.out);
+		}
+
+	}
+
+	/* **********************************************
+	 * runMessageCheckTest
+	 * Run dblook and verify that all of the dblook
+	 * messages are correctly displayed.
+	 * @param dbName The name of the source database (i.e.
+	 *  the database for which the DDL is generated).
+	 * @return The DDL for a simple database, plus all
+	 *  dblook messages, have been generated and written
+	 *  to System.out.
+	 ****/
+	private void runMessageCheckTest(String dbName)
+		throws Exception
+	{
+
+		// #1: First, run DB look standard to check for
+		// all of the "header" messages that are printed
+		// out along with DDL.
+		System.out.println("\n************\n" +
+			"Msg Test 1\n" +
+			"************\n");
+		lookOne(dbName);
+		dumpFileToSysOut(dbName + ".sql");
+		dumpFileToSysOut("dblook.log");
+
+		// Now, we have to run some additional dblook commands
+		// to get the "non-standard" messages.
+
+		// #2: Specify a target table and target schema, to
+		// make sure they are echoed correctly.  Also, specify
+		// an output file to make sure the file creation header
+		// is printed in the file.
+		System.out.println(
+			"\n************\n" +
+			"Msg Test 2\n" +
+			"************\n");
+		go(dbName, new String [] {
+				"-t", "t1",
+				"-z", "bar",
+				"-o", dbName + ".sql"
+			});
+		dumpFileToSysOut(dbName + ".sql");
+		dumpFileToSysOut("dblook.log");
+
+		// #3: Run without specifying a database, to make
+		// sure the usage message is printed to System.out
+		System.out.println(
+			"\n************\n" +
+			"Msg Test 3\n" +
+			"************\n");
+		try {
+			new dblook(new String[] { "-verbose" });
+		} catch (Exception e) {
+			System.out.println("FAILED: to run dblook: ");
+			e.printStackTrace(System.out);
+		}
+
+		// #4: Just to confirm, try once with a statement
+		// delimiter, to make sure it's actually working
+		// correctly (this isn't a "message" per se, but
+		// still, it's worth verifying).
+		System.out.println(
+			"\n************\n" +
+			"Msg Test 4\n" +
+			"************\n");
+		go(dbName, new String [] {
+				"-td", " " + TEST_DELIMITER
+			});
+
+		// #5: Intentionally create an error while loading
+		// a jar file, to make sure the resultant message is
+		// printed correctly.
+		System.out.println(
+			"\n************\n" +
+			"Msg Test 5\n" +
+			"************\n");
+
+		// We'll cause the error by going in and deleting
+		// the jar file from the test database.  First,
+		// get the jar path.
+		String jarPath = (new
+			File(dbPath + separator + dbName)).getAbsolutePath();
+
+		// Have to shut db down before we can mess with it.
+		try {
+			Connection conn =
+				DriverManager.getConnection("jdbc:derby:" + 
+					jarPath + ";shutdown=true");
+			conn.close();
+		} catch (SQLException se) {
+		// shutdown exception.
+		}
+
+		jarPath = jarPath + separator + "jar";
+		deleteFile(new File(jarPath));
+
+		// Now that we've deleted the jar file, run dblook
+		// and check the error.
+		go(dbName, new String [] { 
+				"-verbose",
+				"-o", dbName + ".sql"
+			});
+		dumpFileToSysOut("dblook.log");
+
+		// Clean up.
+		try {
+			deleteFile(new File(dbName + ".sql"));
+		} catch (Exception e) {
+		// not too big of a deal if we fail; just ignore...
 		}
 
 	}
@@ -1388,19 +1508,30 @@
 
 		try {
 
-			BufferedReader logFile =
+			BufferedReader dumpFile =
 				new BufferedReader(new FileReader(fName));
 
-			if (logFile.readLine() != null)
+			String line = dumpFile.readLine();
+			if (line != null) {
 				System.out.println("File " + fName + " was NOT " +
-					"empty; refer to that file (in the test " +
-					"directory) to see its contents.");
+					"empty.  Contents are:\n" +
+					"############## Begin File Contents ################\n");
+				do {
+					System.out.println(line);
+					line = dumpFile.readLine();
+				} while (line != null);
+				System.out.println(
+					"############## End File Contents ################");
+			}
 			else
 				System.out.println("File " + fName + " was empty.");
 
+			// Close the file.
+			dumpFile.close();
+
 		} catch (Exception e) {
-			System.out.println("FAILED: to dump log file.");
-			e.printStackTrace();
+			System.out.println("FAILED: to dump file '" + fName + "'");
+			e.printStackTrace(System.out);
 		}
 
 		return;

Modified: incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties?view=diff&rev=148965&p1=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties&r1=148964&p2=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties&r2=148965
==============================================================================
--- incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties
(original)
+++ incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties
Fri Jan 28 16:33:16 2005
@@ -1 +1 @@
-supportfiles=tests/tools/dblook_makeDB.sql,tests/tools/dblook_test.jar
+supportfiles=tests/tools/dblook_makeDB.sql,tests/tools/dblook_makeDB_2.sql,tests/tools/dblook_test.jar

Copied: incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_sed.properties
(from r111185, incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_sed.properties)
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_sed.properties?view=diff&rev=148965&p1=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_sed.properties&r1=111185&p2=incubator/derby/code/branches/10.0/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_sed.properties&r2=148965
==============================================================================

Modified: incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/DB_Jar.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/DB_Jar.java?view=diff&rev=148965&p1=incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/DB_Jar.java&r1=148964&p2=incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/DB_Jar.java&r2=148965
==============================================================================
--- incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/DB_Jar.java
(original)
+++ incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/DB_Jar.java
Fri Jan 28 16:33:16 2005
@@ -89,13 +89,13 @@
 			oldJarPath.append(schemaWithoutQuotes);
 			oldJarPath.append(jarFullName);
 
-			// Copy jar file to CSJARS directory.
+			// Copy jar file to DBJARS directory.
 			String absJarDir = null;
 			try {
 
-				// Create the CSJARS directory.
+				// Create the DBJARS directory.
 				File jarDir = new File(System.getProperty("user.dir") +
-					separator + "CSJARS" + separator + schemaWithoutQuotes);
+					separator + "DBJARS" + separator + schemaWithoutQuotes);
 				absJarDir = jarDir.getAbsolutePath();
 				jarDir.mkdirs();
 
@@ -126,7 +126,7 @@
 				continue;
 			}
 
-			// Now, add the DDL to read the jar from CSJARS.
+			// Now, add the DDL to read the jar from DBJARS.
 			StringBuffer loadJarString = new StringBuffer();
 			loadJarString.append("CALL SQLJ.INSTALL_JAR('file:");
 			loadJarString.append(absJarDir);

Modified: incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/Logs.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/Logs.java?view=diff&rev=148965&p1=incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/Logs.java&r1=148964&p2=incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/Logs.java&r2=148965
==============================================================================
--- incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/Logs.java
(original)
+++ incubator/derby/code/branches/10.0/java/tools/org/apache/derby/impl/tools/dblook/Logs.java
Fri Jan 28 16:33:16 2005
@@ -64,8 +64,8 @@
 		try {
 
 			logFile = new PrintWriter(new FileOutputStream(logFileName, appendLogs));
-			if (ddlFileName != null)
-				ddlFile = new PrintWriter(new FileOutputStream(ddlFileName, appendLogs));
+			ddlFile = (ddlFileName == null) ? null
+					: new PrintWriter(new FileOutputStream(ddlFileName, appendLogs));
 			verbose = doVerbose;
 			stmtEnd = endOfStmt;
 			atLeastOneDebug = false;

Modified: incubator/derby/code/branches/10.0/java/tools/org/apache/derby/tools/dblook.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.0/java/tools/org/apache/derby/tools/dblook.java?view=diff&rev=148965&p1=incubator/derby/code/branches/10.0/java/tools/org/apache/derby/tools/dblook.java&r1=148964&p2=incubator/derby/code/branches/10.0/java/tools/org/apache/derby/tools/dblook.java&r2=148965
==============================================================================
--- incubator/derby/code/branches/10.0/java/tools/org/apache/derby/tools/dblook.java	(original)
+++ incubator/derby/code/branches/10.0/java/tools/org/apache/derby/tools/dblook.java	Fri Jan
28 16:33:16 2005
@@ -89,12 +89,14 @@
 
 	public static void main(String[] args) {
 
-		dblook looker = new dblook(args);
 		try {
-			looker.go(sourceDBUrl, sourceDBName);
+			new dblook(args);
 		} catch (Exception e) {
-		// Errors are logged and printed to console according
-		// to command line arguments, so just ignore here.
+		// All "normal" errors are logged and printed to
+		// console according to command line arguments,
+		// so if we get here, something unexpected must
+		// have happened; print to error stream.
+			e.printStackTrace();
 		}
 
 	}
@@ -103,11 +105,10 @@
 	 * Constructor:
 	 * Parse the command line, initialize logs, echo program variables,
 	 * and load the Derby driver.
-	 * @param args args[0] is the database URL.  All other command-line
-	 *  parameters are read as system properties.
+	 * @param args Array of dblook command-line arguments.
 	 * ****/
 
-	public dblook(String[] args) {
+	public dblook(String[] args) throws Exception {
 
         // Adjust the application in accordance with derby.ui.locale
 		// and derby.ui.codeset
@@ -119,13 +120,13 @@
 		// Parse the command line.
 		if (!parseArgs(args)) {
 			System.out.println(lookupMessage("DBLOOK_Usage"));
-			System.exit(1);
+			return;
 		}
 
 		showVariables();
 
 		if (!loadDriver()) {
-		// Failed when loading the driver.  We already printed
+		// Failed when loading the driver.  We already logged
 		// the exception, so just return.
 			return;
 		}
@@ -133,6 +134,9 @@
 		schemaMap = new HashMap();
 		tableIdToNameMap = new HashMap();
 
+		// Now run the utility.
+		go();
+
 	}
 
 	/* ************************************************
@@ -158,9 +162,7 @@
 
 	/* ************************************************
 	 * parseArgs:
-	 * Parse the command-line arguments.  There is only one
-	 * actual argument (database url); the rest of the parameters
-	 * are read in as System properties.
+	 * Parse the command-line arguments.
 	 * @param args args[0] is the url for the source database.
 	 * @return true if all parameters were loaded and the output
 	 *  files were successfully created; false otherwise.
@@ -258,10 +260,11 @@
 				// list of tables.
 					return extractTableNamesFromList(args, start+1);
 				return -1;
+
 			case 'o':
 				if (!haveVal)
 					return -1;
-				if ((args[start].length() == 2) && (args[start+1].length() > 0)){
+				if ((args[start].length() == 2) && (args[start+1].length() > 0)) {
 					ddlFileName = args[++start];
 					return start;
 				}
@@ -492,18 +495,12 @@
 	 * line), then we enforce that here.
 	 * @precondition all user-specified parameters have
 	 *  been loaded.
-	 * @param srcUrl The full url of the database, as obtained
-	 *  from parseArgs().
-	 * @param srcName The name of the database (as opposed to
-	 *  the URL), as obtained from parseArgs().  This is
-	 *  needed for locating any jar files that might'
-	 *  exist in the source database.
 	 * @return DDL for the source database has been
 	 *  generated and printed to output, subject to
 	 *  user-specified restrictions.
 	 * ****/
 
-	public void go(String srcUrl, String srcName)
+	private void go()
 		throws Exception
 	{
 
@@ -512,20 +509,8 @@
 
 			// Connect to the database, prepare statements,
 			// and load id-to-name mappings.
-			this.conn = DriverManager.getConnection(srcUrl);
-			try {
-				prepForDump();
-			} catch (SQLException sqlE) {
-				Logs.debug(sqlE);
-				Logs.debug(Logs.unRollExceptions(sqlE), (String)null);
-				Logs.cleanup();
-				return;
-			}
-			catch (Exception e) {
-				Logs.debug(e);
-				Logs.cleanup();
-				return;
-			}
+			this.conn = DriverManager.getConnection(sourceDBUrl);
+			prepForDump();
 
 			// Generate DDL.
 
@@ -536,7 +521,7 @@
 
 			if (tableList == null) {
 			// Don't do these if user just wants table-related objects.
-				DB_Jar.doJars(srcName, this.conn);
+				DB_Jar.doJars(sourceDBName, this.conn);
 				DB_StoredProcedure.doStoredProcedures(this.conn);
 			}
 
@@ -561,18 +546,20 @@
 			Logs.debug(sqlE);
 			Logs.debug(Logs.unRollExceptions(sqlE), (String)null);
 			Logs.cleanup();
-			throw sqlE;
+			return;
 		}
 		catch (Exception e)
 		{
 			Logs.debug(e);
 			Logs.cleanup();
-			throw e;
+			return;
 		}
 		finally {
 		// Close our connection.
-			conn.commit();
-			conn.close();
+			if (conn != null) {
+				conn.commit();
+				conn.close();
+			}
 		}
 
 	}
@@ -757,11 +744,15 @@
 		if (quotedName == null)
 			return null;
 
-		if ((quotedName.indexOf("\"") == -1) &&
-			(quotedName.indexOf("'") == -1))
-		// nothing to do.
+		if (!(quotedName.startsWith("'") || quotedName.startsWith("\"")))
+		// name doesn't _start_ with a quote, so we do nothing.
+			return quotedName;
+
+		if (!(quotedName.endsWith("'") || quotedName.endsWith("\"")))
+		// name doesn't _end_ with a quote, so we do nothing.
 			return quotedName;
 
+		// Remove starting and ending quotes.
 		return quotedName.substring(1, quotedName.length() - 1);
 
 	}
@@ -1127,7 +1118,7 @@
 		} catch (Exception e) {
 		// if something went wrong, just return the string as is--
 		// worst case is that the generated DDL is correct, it just
-		// can't be run in a DB2 CLP script (because of the newline
+		// can't be run in some SQL script apps (because of the newline
 		// characters).
 			return str;
 		}

Mime
View raw message