db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r386187 - in /db/derby/code/trunk: ./ java/build/org/apache/derbyBuild/ java/engine/org/apache/derby/iapi/services/sanity/ java/shared/org/apache/derby/shared/common/i18n/ java/shared/org/apache/derby/shared/common/sanity/ tools/ant/propert...
Date Wed, 15 Mar 2006 22:28:45 GMT
Author: davidvc
Date: Wed Mar 15 14:28:41 2006
New Revision: 386187

URL: http://svn.apache.org/viewcvs?rev=386187&view=rev
Log:
DERBY-1116 : Add a shell-script test generator for internationalized
messages (client-side only).

This is the script that generates the test source code that is then
run to validate client-side internationalized mesages
A    tools/testing
A    tools/testing/i18nTestGenerator
A    tools/testing/i18nTestGenerator/genClient1.sed
A    tools/testing/i18nTestGenerator/genClient2.sed
AM   tools/testing/i18nTestGenerator/generateClientMessageTest.sh
AM   tools/testing/i18nTestGenerator/README


Moved the sanity package to the shared directory so that I could
use ASSERT in some shared code.
M    java/engine/org/apache/derby/iapi/services/sanity/SanityManager.java
D    java/engine/org/apache/derby/iapi/services/sanity/SanityState.tmpl
M    java/engine/org/apache/derby/iapi/services/sanity/AssertFailure.java
A    java/shared/org/apache/derby/shared/common/sanity
AM   java/shared/org/apache/derby/shared/common/sanity/SanityManager.java
A    java/shared/org/apache/derby/shared/common/sanity/SanityState.tmpl
AM   java/shared/org/apache/derby/shared/common/sanity/SanityState.java
AM   java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
M    build.xml
M    tools/ant/properties/dirs.properties

Modified MessageUtil so that it ASSERTs that the number of parameters
passed in to formatMessage() actually matches the placeholders in the
message string.  Also modified the default message string so that it
is something I can look for in my test to tell me something went wrong.
M    java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java

Found a bug by running the test, added a message id to the client
properties file
M    java/build/org/apache/derbyBuild/splitmessages.java

Added:
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
  (with props)
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityManager.java
  (with props)
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.java
  (with props)
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.tmpl
    db/derby/code/trunk/tools/testing/
    db/derby/code/trunk/tools/testing/i18nTestGenerator/
    db/derby/code/trunk/tools/testing/i18nTestGenerator/README   (with props)
    db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient1.sed
    db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed
    db/derby/code/trunk/tools/testing/i18nTestGenerator/generateClientMessageTest.sh   (with
props)
Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/SanityState.tmpl
Modified:
    db/derby/code/trunk/build.xml
    db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/AssertFailure.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/SanityManager.java
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java
    db/derby/code/trunk/tools/ant/properties/dirs.properties

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/build.xml?rev=386187&r1=386186&r2=386187&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Wed Mar 15 14:28:41 2006
@@ -295,7 +295,7 @@
     <ant dir="${derby.tools.src.dir}"/>
   </target>
 
-  <target name="shared" depends="init">
+  <target name="shared" depends="init,state">
     <ant dir="${derby.shared.src.dir}"/>
   </target>
   
@@ -507,7 +507,7 @@
     <propertyfile file="${state.file}" comment="${header}">
       <entry key="sanity" value="true" type="string"/>
     </propertyfile>
-    <delete file="${sanity.dir}/SanityState.java"/>
+    <delete file="${sanity.dir}/SanityState.java"/> 
     <delete dir="${sanity.out.dir}"/>
   </target>
   <target name="insane">
@@ -1079,6 +1079,7 @@
 		 	 org/apache/derby/client/jdbc/Client**,
                          org/apache/derby/jdbc/Client**,
                          org/apache/derby/iapi/services/info/**,
+                         org/apache/derby/iapi/services/sanity/SanityManager.class,
                          org/apache/derby/shared/**,
                          org/apache/derby/info/dnc.properties,
                          org/apache/derby/loc/clientmessages*.properties"

Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java?rev=386187&r1=386186&r2=386187&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java Wed Mar 15 14:28:41
2006
@@ -51,6 +51,7 @@
     {
         // Add message ids that don't start with XJ here
         clientMessageIds.add(SQLState.NO_CURRENT_CONNECTION);
+        clientMessageIds.add(SQLState.NOT_IMPLEMENTED);
     }
 
 	public static void main(String[] args) throws Exception {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/AssertFailure.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/AssertFailure.java?rev=386187&r1=386186&r2=386187&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/AssertFailure.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/AssertFailure.java
Wed Mar 15 14:28:41 2006
@@ -2,7 +2,7 @@
 
    Derby - Class org.apache.derby.iapi.services.sanity.AssertFailure
 
-   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
+   Copyright 1997, 2006 The Apache Software Foundation or its licensors, as applicable.
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -20,61 +20,21 @@
 
 package org.apache.derby.iapi.services.sanity;
 
-import java.io.*;
-
 /**
- * AssertFailure is raised when an ASSERT check fails.
- * Because assertions are not used in production code,
- * are never expected to fail, and recovering from their
- * failure is expected to be hard, they are under
- * RuntimeException so that no one needs to list them
- * in their throws clauses.  An AssertFailure at the
- * outermost system level will result in system shutdown.
+ * A refactoring wrapper around the shared location
  **/
-public class AssertFailure extends RuntimeException
+public class AssertFailure
+    extends org.apache.derby.shared.common.sanity.AssertFailure
 {
-	private Throwable nestedException;
-
-	/**
-	 * This constructor takes the pieces of information
-	 * expected for each error.
-	 *
-	 * @param message the message associated with
-	 * the error.
-	 *
-	 * @param nestedError errors can be nested together;
-	 * if this error has another error associated with it,
-	 * it is specified here. The 'outermost' error should be
-	 * the most sever error; inner errors should be providing
-	 * additional information about what went wrong.
-	 **/
 	public AssertFailure(String message, Throwable nestedError)
 	{
-		super(message);
-		nestedException = nestedError;
+		super(message, nestedError);
 	}
 
 	/**
 	 * This constructor expects no arguments or nested error.
 	 **/
-	public AssertFailure(String message)
-	{
-		super(message);
-	}
-
-	public void printStackTrace() {
-		super.printStackTrace();
-		if (nestedException != null)
-			nestedException.printStackTrace();
-	}
-	public void printStackTrace(PrintStream s) {
-		super.printStackTrace(s);
-		if (nestedException != null)
-			nestedException.printStackTrace(s);
-	}
-	public void printStackTrace(PrintWriter s) {
-		super.printStackTrace(s);
-		if (nestedException != null)
-			nestedException.printStackTrace(s);
-	}
+	public AssertFailure(String message) {
+        super(message);
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/SanityManager.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/SanityManager.java?rev=386187&r1=386186&r2=386187&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/SanityManager.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/SanityManager.java
Wed Mar 15 14:28:41 2006
@@ -2,7 +2,7 @@
 
    Derby - Class org.apache.derby.iapi.services.sanity.SanityManager
 
-   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
+   Copyright 1997, 2006 The Apache Software Foundation or its licensors, as applicable.
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -20,366 +20,10 @@
 
 package org.apache.derby.iapi.services.sanity;
 
-
-import org.apache.derby.iapi.services.sanity.AssertFailure;
-
-import java.util.Hashtable;
-import java.util.Enumeration;
-
 /**
- * The SanityService provides assertion checking and debug
- * control.
- * <p>
- * Assertions and debug checks
- * can only be used for testing conditions that might occur
- * in development code but not in production code.	
- * <b>They are compiled out of production code.</b>
- * <p>
- * Uses of assertions should not add AssertFailure catches or
- * throws clauses; AssertFailure is under RuntimeException
- * in the java exception hierarchy. Our outermost system block
- * will bring the system down when it detects an assertion
- * failure.
- * <p>
- * In addition to ASSERTs in code, classes can choose to implement
- * an isConsistent method that would be used by ASSERTs, UnitTests,
- * and any other code wanting to check the consistency of an object.
- * <p>
- * Assertions are meant to be used to verify the state of the system
- * and bring the system down if the state is not correct. Debug checks
- * are meant to display internal information about a running system.
- * <p>
- * @see org.apache.derby.iapi.services.sanity.AssertFailure
+ * A refactoring wrapper around the new shared location for SanityManager
  */
-public class SanityManager {
-	/**
-	 * The build tool may be configured to alter
-	 * this source file to reset the static final variables
-	 * so that assertion and debug checks can be compiled out
-	 * of the code.
-	 */
-
-	public static final boolean ASSERT = SanityState.ASSERT; // code should use DEBUG
-	public static final boolean DEBUG = SanityState.DEBUG;
-	
-	public static final String DEBUGDEBUG = "DumpSanityDebug";
-	
-	/**
-	 * debugStream holds a pointer to the debug stream for writing out
-	 * debug messages.  It is cached at the first debug write request.
-	 */
-	static private java.io.PrintWriter debugStream = new java.io.PrintWriter(System.err);
-	/**
-	 * DebugFlags holds the values of all debug flags in
-	 * the configuration file.
-	 */
-	static private Hashtable DebugFlags = new Hashtable();
-	/**
-	 * AllDebugOn and AllDebugOff override individual flags
-	 */
-	static private boolean AllDebugOn = false;
-	static private boolean AllDebugOff = false;
-
-	//
-	// class interface
-	//
-
-	/**
-	 * ASSERT checks the condition, and if it is
-	 * false, throws AssertFailure.
-	 * A message about the assertion failing is
-	 * printed.
-	 * <p>
-	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
-	 */
-	public static final void ASSERT(boolean mustBeTrue) {
-		if (DEBUG)
-			if (! mustBeTrue) {
-				if (DEBUG) {
-					AssertFailure af = new AssertFailure("ASSERT FAILED");
-					if (DEBUG_ON("AssertFailureTrace")) {
-						showTrace(af);
-					}
-					throw af;
-				}
-				else
-					throw new AssertFailure("ASSERT FAILED");
-			}
-	}
-
-	/**
-	 * ASSERT checks the condition, and if it is
-	 * false, throws AssertFailure. The message will
-	 * be printed and included in the assertion.
-	 * <p>
-	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
-	 */
-	public static final void ASSERT(boolean mustBeTrue, String msgIfFail) {
-		if (DEBUG)
-			if (! mustBeTrue) {
-				if (DEBUG) {
-					AssertFailure af = new AssertFailure("ASSERT FAILED " + msgIfFail);
-					if (DEBUG_ON("AssertFailureTrace")) {
-						showTrace(af);
-					}
-					throw af;
-				}
-				else
-					throw new AssertFailure("ASSERT FAILED " + msgIfFail);
-			}
-	}
-
-	/**
-	 * THROWASSERT throws AssertFailure. This is used in cases where
-	 * the caller has already detected the assertion failure (such as
-	 * in the default case of a switch). This method should be used,
-	 * rather than throwing AssertFailure directly, to allow us to 
-	 * centralize all sanity checking.  The message argument will
-	 * be printed and included in the assertion.
-     * <p>
-	 * @param msgIfFail message to print with the assertion
-	 *
-	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
-	 */
-	public static final void THROWASSERT(String msgIfFail) {
-		// XXX (nat) Hmm, should we check ASSERT here?  The caller is
-		// not expecting this function to return, whether assertions
-		// are compiled in or not.
-
-		if (DEBUG) {
-			AssertFailure af = new AssertFailure("ASSERT FAILED " + msgIfFail);
-			if (DEBUG_ON("AssertFailureTrace")) {
-				showTrace(af);
-			}
-			throw af;
-		}
-		else
-			throw new AssertFailure("ASSERT FAILED " + msgIfFail);
-	}
-
-	/**
-	 * THROWASSERT throws AssertFailure.
-	 * This flavor will print the stack associated with the exception.
-	 * The message argument will
-	 * be printed and included in the assertion.
-     * <p>
-	 * @param msg message to print with the assertion
-	 * @param t exception to print with the assertion
-	 *
-	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
-	 */
-	public static final void THROWASSERT(String msg, Throwable t) {
-
-		if (DEBUG) {
-			AssertFailure af = new AssertFailure("ASSERT FAILED " + t.toString(), t);
-			if (DEBUG_ON("AssertFailureTrace")) {
-				showTrace(af);
-			}
-			showTrace(t);
-			throw af;
-		}
-		else {
-			showTrace(t);
-			throw new AssertFailure("ASSERT FAILED " + t.toString(), t);
-		}
-	}
-
-	/**
-	 * THROWASSERT throws AssertFailure.
-	 * This flavor will print the stack associated with the exception.
-     * <p>
-	 * @param t exception to print with the assertion
-	 *
-	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
-	 */
-	public static final void THROWASSERT(Throwable t) {
-
-		if (DEBUG) {
-			AssertFailure af = new AssertFailure("ASSERT FAILED " + t.toString(), t);
-			if (DEBUG_ON("AssertFailureTrace")) {
-				showTrace(af);
-			}
-			showTrace(t);
-			throw af;
-		}
-		else {
-			showTrace(t);
-			throw new AssertFailure("ASSERT FAILED " + t.toString(), t);
-		}
-	}
-
-	/**
-     * The DEBUG calls provide the ability to print information or
-     * perform actions based on whether a debug flag is set or not.
-     * debug flags are set in configurations and picked up by the
-     * sanity manager when the monitor finds them (see CONFIG below).
-	 * <p>
-	 * The message is output to the trace stream, so it ends up in
-	 * db2j.LOG. It will include a header line of
-	 *   DEBUG <flagname> OUTPUT:
-	 * before the message.
-	 * <p>
-	 * If the debugStream stream cannot be found, the message is printed to
-	 * System.out.
-     */
-	public static final void DEBUG(String flag, String message) {
-		if (DEBUG) {
-			if (DEBUG_ON(flag)) {
-				DEBUG_PRINT(flag, message);
-			}
-		}
-	}
-
-	/**
-	 * This can be called directly if you want to control
-     * what is done once the debug flag has been verified --
-	 * for example, if you are calling a routine that prints to
-	 * the trace stream directly rather than returning a string to
-	 * be printed, or if you want to perform more (or fewer!)
-	 *
-	 * <p>
-     * Calls to this method should be surrounded with
-	 *     if (SanityManager.DEBUG) {
-	 *     }
-	 * so that they can be compiled out completely.
-	 *
-	 * @return true if the flag has been set to "true"; false
-	 * if the flag is not set, or is set to something other than "true".
-	 */
-	public static final boolean DEBUG_ON(String flag) {
-		if (DEBUG) {
-			if (AllDebugOn) return true;
-			else if (AllDebugOff) return false;
-			else {
-					Boolean flagValue = (Boolean) DebugFlags.get(flag);
-					if (! DEBUGDEBUG.equals(flag)) {
-						if (DEBUG_ON(DEBUGDEBUG)) {
-							DEBUG_PRINT(DEBUGDEBUG, "DEBUG_ON: Debug flag "+flag+" = "+flagValue);
-						}
-					}
-					if (flagValue == null) return false;
-					else return flagValue.booleanValue();
-			}
-		}
-		else return false;
-	}
-
-	/**
-	 * Set the named debug flag to true.
-	 *
-	 * <p>
-     * Calls to this method should be surrounded with
-	 *     if (SanityManager.DEBUG) {
-	 *     }
-	 * so that they can be compiled out completely.
-	 *
-	 * @param flag	The name of the debug flag to set to true
-	 */
-	public static final void DEBUG_SET(String flag) {
-		if (DEBUG) {
-			if (! DEBUGDEBUG.equals(flag)) {
-				if (DEBUG_ON(DEBUGDEBUG))
-					DEBUG_PRINT(DEBUGDEBUG, "DEBUG_SET: Debug flag " + flag);
-			}
-
-			DebugFlags.put(flag, Boolean.TRUE);
-		}
-	}
-
-	/**
-	 * Set the named debug flag to false.
-	 *
-	 * <p>
-     * Calls to this method should be surrounded with
-	 *     if (SanityManager.DEBUG) {
-	 *     }
-	 * so that they can be compiled out completely.
-	 *
-	 * @param flag	The name of the debug flag to set to false
-	 */
-	public static final void DEBUG_CLEAR(String flag) {
-		if (DEBUG) {
-			if (! DEBUGDEBUG.equals(flag)) {
-				if (DEBUG_ON(DEBUGDEBUG))
-					DEBUG_PRINT(DEBUGDEBUG, "DEBUG_CLEAR: Debug flag " + flag);
-			}
-
-			DebugFlags.put(flag, Boolean.FALSE);
-		}
-	}
-
-	/**
-	 * This can be used to have the SanityManager return TRUE
-	 * for any DEBUG_ON check. DEBUG_CLEAR of an individual
-	 * flag will appear to have no effect.
-	 */
-	public static final void DEBUG_ALL_ON() {
-		if (DEBUG) {
-			AllDebugOn = true;
-			AllDebugOff = false;
-		}
-	}
-
-	/**
-	 * This can be used to have the SanityManager return FALSE
-	 * for any DEBUG_ON check. DEBUG_SET of an individual
-	 * flag will appear to have no effect.
-	 */
-	public static final void DEBUG_ALL_OFF() {
-		if (DEBUG) {
-			AllDebugOff = true;
-			AllDebugOn = false;
-		}
-	}
-
-	//
-	// class implementation
-	//
-
-	static public void SET_DEBUG_STREAM(java.io.PrintWriter pw) {
-		debugStream = pw;
-	}
-
-	static public java.io.PrintWriter GET_DEBUG_STREAM() {
-		return debugStream;
-	}
-
-	static private void showTrace(AssertFailure af) {
-		af.printStackTrace();
-		java.io.PrintWriter assertStream = GET_DEBUG_STREAM();
-
-		assertStream.println("Assertion trace:");
-		af.printStackTrace(assertStream);
-		assertStream.flush();
-	}
-
-	static public void showTrace(Throwable t) {
-		java.io.PrintWriter assertStream = GET_DEBUG_STREAM();
-
-		assertStream.println("Exception trace: ");
-		t.printStackTrace(assertStream);
-	}
-
-	/**
-	 * The DEBUG_PRINT calls provides a convenient way to print debug
-	 * information to the db2j.LOG file,  The message includes a header
-	 *<p>
-	 *	DEBUG <flag> OUTPUT: 
-	 * before the message
-	 *<p>
-	 * If the debugStream stream cannot be found, the message is printed to
-	 * System.out.
-	 *
-	 */
-	static public void DEBUG_PRINT(String flag, String message) {
-		java.io.PrintWriter debugStream = GET_DEBUG_STREAM();
-
-		debugStream.println("DEBUG "+flag+" OUTPUT: " + message);
-		debugStream.flush();
-	}
-
-	public static void NOTREACHED() {
-		THROWASSERT("code should not be reached");
-	}
+public class SanityManager 
+    extends org.apache.derby.shared.common.sanity.SanityManager
+{
 }
-

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java?rev=386187&r1=386186&r2=386187&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java (original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java Wed
Mar 15 14:28:41 2006
@@ -19,6 +19,7 @@
 package org.apache.derby.shared.common.i18n;
 
 import org.apache.derby.shared.common.error.ExceptionSeverity;
+import org.apache.derby.shared.common.sanity.SanityManager;
 import java.util.Locale;
 import java.util.ResourceBundle;
 import java.util.MissingResourceException;
@@ -214,6 +215,7 @@
         Object[] arguments, boolean composeDefault) {
 
         String message = null;
+        String badArgsMessage = null;
         
         if (arguments == null)
             arguments = new Object[0];
@@ -222,16 +224,32 @@
 
             try {
                 message = bundle.getString(messageId);
+                
+                
+                // Ensure that the right number of arguments are passed in.
+                if ( SanityManager.DEBUG )
+                {
+                    int numExpected = countParams(message);
+                    SanityManager.ASSERT(numExpected == arguments.length,
+                        "Number of parameters expected for message id " +
+                        messageId + "(" + numExpected +
+                        ") does not match number of arguments received (" +
+                        arguments.length + ")");
+                }
 
                 try {
                     return MessageFormat.format(message, arguments);
                 }
                 catch (IllegalArgumentException iae) {
+                    if ( !composeDefault )
+                        throw iae;
                 }
                 catch (NullPointerException npe) {
                     //
                     //null arguments cause a NullPointerException. 
                     //This improves reporting.
+                    if ( !composeDefault )
+                        throw npe;
                 }
 
             } catch (MissingResourceException mre) {
@@ -241,7 +259,32 @@
             } 
         }
 
-        return composeDefaultMessage(messageId, arguments);
+        return composeDefaultMessage("UNKNOWN MESSAGE, id " + messageId, arguments);
+    }
+    
+    /**
+     * Count the number of substituation parameters in the message
+     */
+    private static int countParams(String message)
+    {
+        boolean openFound = false;
+        int numparams = 0;
+        
+        for ( int i = 0 ; i < message.length() ; i++ )
+        {
+            char ch = message.charAt(i);
+            if ( ch == '{' ) {
+                openFound = true;
+            }
+            
+            if ( ch == '}' && openFound )
+            {
+                numparams++;
+                openFound = false;
+            }
+        }
+        
+        return numparams;
     }
 
     /**
@@ -257,7 +300,7 @@
      */
     public static String composeDefaultMessage(String message, Object[] arguments)
     {
-           if (message == null)
+        if (message == null)
         {
             message = "UNKNOWN";
         }

Added: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java?rev=386187&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
(added)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
Wed Mar 15 14:28:41 2006
@@ -0,0 +1,80 @@
+/*
+
+   Derby - Class org.apache.derby.iapi.services.sanity.AssertFailure
+
+   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.shared.common.sanity;
+
+import java.io.*;
+
+/**
+ * AssertFailure is raised when an ASSERT check fails.
+ * Because assertions are not used in production code,
+ * are never expected to fail, and recovering from their
+ * failure is expected to be hard, they are under
+ * RuntimeException so that no one needs to list them
+ * in their throws clauses.  An AssertFailure at the
+ * outermost system level will result in system shutdown.
+ **/
+public class AssertFailure extends RuntimeException
+{
+	private Throwable nestedException;
+
+	/**
+	 * This constructor takes the pieces of information
+	 * expected for each error.
+	 *
+	 * @param message the message associated with
+	 * the error.
+	 *
+	 * @param nestedError errors can be nested together;
+	 * if this error has another error associated with it,
+	 * it is specified here. The 'outermost' error should be
+	 * the most sever error; inner errors should be providing
+	 * additional information about what went wrong.
+	 **/
+	public AssertFailure(String message, Throwable nestedError)
+	{
+		super(message);
+		nestedException = nestedError;
+	}
+
+	/**
+	 * This constructor expects no arguments or nested error.
+	 **/
+	public AssertFailure(String message)
+	{
+		super(message);
+	}
+
+	public void printStackTrace() {
+		super.printStackTrace();
+		if (nestedException != null)
+			nestedException.printStackTrace();
+	}
+	public void printStackTrace(PrintStream s) {
+		super.printStackTrace(s);
+		if (nestedException != null)
+			nestedException.printStackTrace(s);
+	}
+	public void printStackTrace(PrintWriter s) {
+		super.printStackTrace(s);
+		if (nestedException != null)
+			nestedException.printStackTrace(s);
+	}
+}

Propchange: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityManager.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityManager.java?rev=386187&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityManager.java
(added)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityManager.java
Wed Mar 15 14:28:41 2006
@@ -0,0 +1,383 @@
+/*
+
+   Derby - Class org.apache.derby.iapi.services.sanity.SanityManager
+
+   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.shared.common.sanity;
+
+
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+/**
+ * The SanityService provides assertion checking and debug
+ * control.
+ * <p>
+ * Assertions and debug checks
+ * can only be used for testing conditions that might occur
+ * in development code but not in production code.	
+ * <b>They are compiled out of production code.</b>
+ * <p>
+ * Uses of assertions should not add AssertFailure catches or
+ * throws clauses; AssertFailure is under RuntimeException
+ * in the java exception hierarchy. Our outermost system block
+ * will bring the system down when it detects an assertion
+ * failure.
+ * <p>
+ * In addition to ASSERTs in code, classes can choose to implement
+ * an isConsistent method that would be used by ASSERTs, UnitTests,
+ * and any other code wanting to check the consistency of an object.
+ * <p>
+ * Assertions are meant to be used to verify the state of the system
+ * and bring the system down if the state is not correct. Debug checks
+ * are meant to display internal information about a running system.
+ * <p>
+ * @see org.apache.derby.iapi.services.sanity.AssertFailure
+ */
+public class SanityManager {
+	/**
+	 * The build tool may be configured to alter
+	 * this source file to reset the static final variables
+	 * so that assertion and debug checks can be compiled out
+	 * of the code.
+	 */
+
+	public static final boolean ASSERT = SanityState.ASSERT; // code should use DEBUG
+	public static final boolean DEBUG = SanityState.DEBUG;
+	
+	public static final String DEBUGDEBUG = "DumpSanityDebug";
+	
+	/**
+	 * debugStream holds a pointer to the debug stream for writing out
+	 * debug messages.  It is cached at the first debug write request.
+	 */
+	static private java.io.PrintWriter debugStream = new java.io.PrintWriter(System.err);
+	/**
+	 * DebugFlags holds the values of all debug flags in
+	 * the configuration file.
+	 */
+	static private Hashtable DebugFlags = new Hashtable();
+	/**
+	 * AllDebugOn and AllDebugOff override individual flags
+	 */
+	static private boolean AllDebugOn = false;
+	static private boolean AllDebugOff = false;
+
+	//
+	// class interface
+	//
+
+	/**
+	 * ASSERT checks the condition, and if it is
+	 * false, throws AssertFailure.
+	 * A message about the assertion failing is
+	 * printed.
+	 * <p>
+	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
+	 */
+	public static final void ASSERT(boolean mustBeTrue) {
+		if (DEBUG)
+			if (! mustBeTrue) {
+				if (DEBUG) {
+					AssertFailure af = new AssertFailure("ASSERT FAILED");
+					if (DEBUG_ON("AssertFailureTrace")) {
+						showTrace(af);
+					}
+					throw af;
+				}
+				else
+					throw new AssertFailure("ASSERT FAILED");
+			}
+	}
+
+	/**
+	 * ASSERT checks the condition, and if it is
+	 * false, throws AssertFailure. The message will
+	 * be printed and included in the assertion.
+	 * <p>
+	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
+	 */
+	public static final void ASSERT(boolean mustBeTrue, String msgIfFail) {
+		if (DEBUG)
+			if (! mustBeTrue) {
+				if (DEBUG) {
+					AssertFailure af = new AssertFailure("ASSERT FAILED " + msgIfFail);
+					if (DEBUG_ON("AssertFailureTrace")) {
+						showTrace(af);
+					}
+					throw af;
+				}
+				else
+					throw new AssertFailure("ASSERT FAILED " + msgIfFail);
+			}
+	}
+
+	/**
+	 * THROWASSERT throws AssertFailure. This is used in cases where
+	 * the caller has already detected the assertion failure (such as
+	 * in the default case of a switch). This method should be used,
+	 * rather than throwing AssertFailure directly, to allow us to 
+	 * centralize all sanity checking.  The message argument will
+	 * be printed and included in the assertion.
+     * <p>
+	 * @param msgIfFail message to print with the assertion
+	 *
+	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
+	 */
+	public static final void THROWASSERT(String msgIfFail) {
+		// XXX (nat) Hmm, should we check ASSERT here?  The caller is
+		// not expecting this function to return, whether assertions
+		// are compiled in or not.
+
+		if (DEBUG) {
+			AssertFailure af = new AssertFailure("ASSERT FAILED " + msgIfFail);
+			if (DEBUG_ON("AssertFailureTrace")) {
+				showTrace(af);
+			}
+			throw af;
+		}
+		else
+			throw new AssertFailure("ASSERT FAILED " + msgIfFail);
+	}
+
+	/**
+	 * THROWASSERT throws AssertFailure.
+	 * This flavor will print the stack associated with the exception.
+	 * The message argument will
+	 * be printed and included in the assertion.
+     * <p>
+	 * @param msg message to print with the assertion
+	 * @param t exception to print with the assertion
+	 *
+	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
+	 */
+	public static final void THROWASSERT(String msg, Throwable t) {
+
+		if (DEBUG) {
+			AssertFailure af = new AssertFailure("ASSERT FAILED " + t.toString(), t);
+			if (DEBUG_ON("AssertFailureTrace")) {
+				showTrace(af);
+			}
+			showTrace(t);
+			throw af;
+		}
+		else {
+			showTrace(t);
+			throw new AssertFailure("ASSERT FAILED " + t.toString(), t);
+		}
+	}
+
+	/**
+	 * THROWASSERT throws AssertFailure.
+	 * This flavor will print the stack associated with the exception.
+     * <p>
+	 * @param t exception to print with the assertion
+	 *
+	 * @see org.apache.derby.iapi.services.sanity.AssertFailure
+	 */
+	public static final void THROWASSERT(Throwable t) {
+
+		if (DEBUG) {
+			AssertFailure af = new AssertFailure("ASSERT FAILED " + t.toString(), t);
+			if (DEBUG_ON("AssertFailureTrace")) {
+				showTrace(af);
+			}
+			showTrace(t);
+			throw af;
+		}
+		else {
+			showTrace(t);
+			throw new AssertFailure("ASSERT FAILED " + t.toString(), t);
+		}
+	}
+
+	/**
+     * The DEBUG calls provide the ability to print information or
+     * perform actions based on whether a debug flag is set or not.
+     * debug flags are set in configurations and picked up by the
+     * sanity manager when the monitor finds them (see CONFIG below).
+	 * <p>
+	 * The message is output to the trace stream, so it ends up in
+	 * db2j.LOG. It will include a header line of
+	 *   DEBUG <flagname> OUTPUT:
+	 * before the message.
+	 * <p>
+	 * If the debugStream stream cannot be found, the message is printed to
+	 * System.out.
+     */
+	public static final void DEBUG(String flag, String message) {
+		if (DEBUG) {
+			if (DEBUG_ON(flag)) {
+				DEBUG_PRINT(flag, message);
+			}
+		}
+	}
+
+	/**
+	 * This can be called directly if you want to control
+     * what is done once the debug flag has been verified --
+	 * for example, if you are calling a routine that prints to
+	 * the trace stream directly rather than returning a string to
+	 * be printed, or if you want to perform more (or fewer!)
+	 *
+	 * <p>
+     * Calls to this method should be surrounded with
+	 *     if (SanityManager.DEBUG) {
+	 *     }
+	 * so that they can be compiled out completely.
+	 *
+	 * @return true if the flag has been set to "true"; false
+	 * if the flag is not set, or is set to something other than "true".
+	 */
+	public static final boolean DEBUG_ON(String flag) {
+		if (DEBUG) {
+			if (AllDebugOn) return true;
+			else if (AllDebugOff) return false;
+			else {
+					Boolean flagValue = (Boolean) DebugFlags.get(flag);
+					if (! DEBUGDEBUG.equals(flag)) {
+						if (DEBUG_ON(DEBUGDEBUG)) {
+							DEBUG_PRINT(DEBUGDEBUG, "DEBUG_ON: Debug flag "+flag+" = "+flagValue);
+						}
+					}
+					if (flagValue == null) return false;
+					else return flagValue.booleanValue();
+			}
+		}
+		else return false;
+	}
+
+	/**
+	 * Set the named debug flag to true.
+	 *
+	 * <p>
+     * Calls to this method should be surrounded with
+	 *     if (SanityManager.DEBUG) {
+	 *     }
+	 * so that they can be compiled out completely.
+	 *
+	 * @param flag	The name of the debug flag to set to true
+	 */
+	public static final void DEBUG_SET(String flag) {
+		if (DEBUG) {
+			if (! DEBUGDEBUG.equals(flag)) {
+				if (DEBUG_ON(DEBUGDEBUG))
+					DEBUG_PRINT(DEBUGDEBUG, "DEBUG_SET: Debug flag " + flag);
+			}
+
+			DebugFlags.put(flag, Boolean.TRUE);
+		}
+	}
+
+	/**
+	 * Set the named debug flag to false.
+	 *
+	 * <p>
+     * Calls to this method should be surrounded with
+	 *     if (SanityManager.DEBUG) {
+	 *     }
+	 * so that they can be compiled out completely.
+	 *
+	 * @param flag	The name of the debug flag to set to false
+	 */
+	public static final void DEBUG_CLEAR(String flag) {
+		if (DEBUG) {
+			if (! DEBUGDEBUG.equals(flag)) {
+				if (DEBUG_ON(DEBUGDEBUG))
+					DEBUG_PRINT(DEBUGDEBUG, "DEBUG_CLEAR: Debug flag " + flag);
+			}
+
+			DebugFlags.put(flag, Boolean.FALSE);
+		}
+	}
+
+	/**
+	 * This can be used to have the SanityManager return TRUE
+	 * for any DEBUG_ON check. DEBUG_CLEAR of an individual
+	 * flag will appear to have no effect.
+	 */
+	public static final void DEBUG_ALL_ON() {
+		if (DEBUG) {
+			AllDebugOn = true;
+			AllDebugOff = false;
+		}
+	}
+
+	/**
+	 * This can be used to have the SanityManager return FALSE
+	 * for any DEBUG_ON check. DEBUG_SET of an individual
+	 * flag will appear to have no effect.
+	 */
+	public static final void DEBUG_ALL_OFF() {
+		if (DEBUG) {
+			AllDebugOff = true;
+			AllDebugOn = false;
+		}
+	}
+
+	//
+	// class implementation
+	//
+
+	static public void SET_DEBUG_STREAM(java.io.PrintWriter pw) {
+		debugStream = pw;
+	}
+
+	static public java.io.PrintWriter GET_DEBUG_STREAM() {
+		return debugStream;
+	}
+
+	static private void showTrace(AssertFailure af) {
+		af.printStackTrace();
+		java.io.PrintWriter assertStream = GET_DEBUG_STREAM();
+
+		assertStream.println("Assertion trace:");
+		af.printStackTrace(assertStream);
+		assertStream.flush();
+	}
+
+	static public void showTrace(Throwable t) {
+		java.io.PrintWriter assertStream = GET_DEBUG_STREAM();
+
+		assertStream.println("Exception trace: ");
+		t.printStackTrace(assertStream);
+	}
+
+	/**
+	 * The DEBUG_PRINT calls provides a convenient way to print debug
+	 * information to the db2j.LOG file,  The message includes a header
+	 *<p>
+	 *	DEBUG <flag> OUTPUT: 
+	 * before the message
+	 *<p>
+	 * If the debugStream stream cannot be found, the message is printed to
+	 * System.out.
+	 *
+	 */
+	static public void DEBUG_PRINT(String flag, String message) {
+		java.io.PrintWriter debugStream = GET_DEBUG_STREAM();
+
+		debugStream.println("DEBUG "+flag+" OUTPUT: " + message);
+		debugStream.flush();
+	}
+
+	public static void NOTREACHED() {
+		THROWASSERT("code should not be reached");
+	}
+}
+

Propchange: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.java?rev=386187&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.java
(added)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.java
Wed Mar 15 14:28:41 2006
@@ -0,0 +1,18 @@
+package org.apache.derby.shared.common.sanity;
+
+/*
+ **
+ * This class is intended for the use of the SanityManager in conjunction
+ * with making a build either Sane or Insane. An insane build is one which
+ * has the two booleans expressed here as "false"; a sane build should be
+ * have the booleans expressed as "true".
+ *
+ * @see com.ihost.cs.iapi.services.sanity.SanityManager
+ ** 
+*/
+
+public class SanityState
+{
+	public static final boolean ASSERT=true ;
+	public static final boolean DEBUG=true ;
+}

Propchange: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.tmpl
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.tmpl?rev=386187&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.tmpl
(added)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/SanityState.tmpl
Wed Mar 15 14:28:41 2006
@@ -0,0 +1,18 @@
+package org.apache.derby.shared.common.sanity;
+
+/*
+ **
+ * This class is intended for the use of the SanityManager in conjunction
+ * with making a build either Sane or Insane. An insane build is one which
+ * has the two booleans expressed here as "false"; a sane build should be
+ * have the booleans expressed as "true".
+ *
+ * @see com.ihost.cs.iapi.services.sanity.SanityManager
+ ** 
+*/
+
+public class SanityState
+{
+	public static final boolean ASSERT=@SANE@ ;
+	public static final boolean DEBUG=@SANE@ ;
+}

Modified: db/derby/code/trunk/tools/ant/properties/dirs.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/tools/ant/properties/dirs.properties?rev=386187&r1=386186&r2=386187&view=diff
==============================================================================
--- db/derby/code/trunk/tools/ant/properties/dirs.properties (original)
+++ db/derby/code/trunk/tools/ant/properties/dirs.properties Wed Mar 15 14:28:41 2006
@@ -53,8 +53,8 @@
 derby.tools.locales.dir=${derby.tools.dir}/loc
 derby.client.locales.dir=${derby.client.dir}/loc
 
-sanity.dir=${derby.engine.dir}/iapi/services/sanity
-sanity.out.dir=${out.dir}/${derby.dir}/iapi/services/sanity
+sanity.dir=${derby.shared.dir}/shared/common/sanity
+sanity.out.dir=${out.dir}/${derby.dir}/shared/common/sanity
 
 derby.testing.dir=org/apache/derbyTesting
 derby.testing.out.dir=${out.dir}/${derby.testing.dir}

Added: db/derby/code/trunk/tools/testing/i18nTestGenerator/README
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/tools/testing/i18nTestGenerator/README?rev=386187&view=auto
==============================================================================
--- db/derby/code/trunk/tools/testing/i18nTestGenerator/README (added)
+++ db/derby/code/trunk/tools/testing/i18nTestGenerator/README Wed Mar 15 14:28:41 2006
@@ -0,0 +1,37 @@
+This directory contains scripts to generate a test class for 
+testing whether we are correctly creating internationalized messages.
+This is the only real way we can catch misuses of message formatting,
+such as using a message id that has no matching message or using
+the incorrect number of parameters for the message.
+
+This script should be run by a user who (a) has access to /bin/sh
+and sed and (b) wants to verify the validity of our internationalized 
+messages.  You should run this *BEFORE* you do a build, as it generates
+a test source file that should then be compiled.
+
+It is generally expected that this be done as part of nightly regression
+and release tests on one or more platforms that support /bin/sh.  This
+test should be run with the sane build as it makes use of ASSERTs within the
+internationalization framework.
+
+Files in this directory
+=======================
+generateClientMessageTest.sh
+  This file is a shell script used to generate a test class for
+  client messages.  The file generated is 
+  functionTests/tests/i18n/TestClientMessages.java
+
+  This test is basically a copy of each construction of SqlException
+  that uses the MessageId class.  These copies are cleaned up so they
+  can be run out of context, and then sanity code in the message
+  construction utility class makes sure that the message id has a
+  matching message string available to the client and that the right
+  number of parameters are being used.
+
+genClient1.sed
+  A sed script used by generateClientMessageTest.sh to create the 
+  test file
+
+genClient2.sed
+  A sed script used by generateClientMessageTest.sh to create the 
+  test file

Propchange: db/derby/code/trunk/tools/testing/i18nTestGenerator/README
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient1.sed
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient1.sed?rev=386187&view=auto
==============================================================================
--- db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient1.sed (added)
+++ db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient1.sed Wed Mar 15 14:28:41
2006
@@ -0,0 +1,2 @@
+/new MessageId.*)\;/p 
+/new MessageId[^;]*$/,/);/p

Added: db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed?rev=386187&view=auto
==============================================================================
--- db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed (added)
+++ db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed Wed Mar 15 14:28:41
2006
@@ -0,0 +1,10 @@
+s/fileName/"fileName"/g
+s/e.getMessage()/"e.getMessage"/g
+s/new Long([^)]*/new Long(0/g
+s/new Integer([^)]*/new Integer(0/g
+s/)))/))/g
+/new MessageId/i\
+    e = new SqlException(null,
+/[^(]);/a \
+    if ( e.getMessage().startsWith("UNKNOWN") ) \
+      throw e; \

Added: db/derby/code/trunk/tools/testing/i18nTestGenerator/generateClientMessageTest.sh
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/tools/testing/i18nTestGenerator/generateClientMessageTest.sh?rev=386187&view=auto
==============================================================================
--- db/derby/code/trunk/tools/testing/i18nTestGenerator/generateClientMessageTest.sh (added)
+++ db/derby/code/trunk/tools/testing/i18nTestGenerator/generateClientMessageTest.sh Wed Mar
15 14:28:41 2006
@@ -0,0 +1,105 @@
+#!/bin/bash
+
+TESTDIR=java/testing/org/apache/derbyTesting/functionTests/tests/i18n
+ROOT=$1
+
+syntax()
+{
+  echo "syntax: $0 derby_rootdir"
+}
+
+if [ "$1" = "" ]
+then
+  echo "Please supply a root Derby directory"
+  syntax
+  exit 1
+fi
+
+if [ ! -d $ROOT ]
+then
+  echo "$ROOT is not found or is not a directory"
+  syntax
+  exit 1
+fi
+
+if [ ! -d $ROOT/$TESTDIR ]
+then
+  echo "$ROOT does not appear to be a valid Derby root directory:"
+  echo "  $ROOT/$TESTDIR is not found or is not a directory"
+  syntax
+  exit 1
+fi
+
+
+#
+# Create the top of the file
+#
+FILE=$ROOT/$TESTDIR/TestClientMessages.java
+
+echo "package org.apache.derbyTesting.functionTests.tests.i18n;" > $FILE
+echo "" >> $FILE
+echo "import org.apache.derby.client.am.MessageId;" >> $FILE
+echo "import org.apache.derby.client.am.SqlException;" >> $FILE
+echo "import org.apache.derby.shared.common.reference.SQLState;" >> $FILE
+echo "" >> $FILE
+echo "/**" >> $FILE
+echo " * This class is a GENERATED FILE that tests as many of the messages" >> $FILE
+echo " * in the client code as possible." >> $FILE
+echo " */" >> $FILE
+echo "public class TestClientMessages" >> $FILE
+echo "{" >> $FILE
+echo "  private static Exception e;" >> $FILE
+echo '  private static String feature = "testFeature";' >> $FILE
+echo "" >> $FILE
+echo "  public static void main(String[] args) {" >> $FILE
+echo "    try {" >> $FILE
+
+CLIENTROOT=$ROOT/java/client/org/apache/derby
+if [ ! -d $CLIENTROOT ]
+then
+  echo $CLIENTROOT is not a valid directory
+  exit 1
+fi
+
+FILES=`find $CLIENTROOT -name '*.java' -print`
+
+if [ $? != 0 ]
+then 
+  exit $?
+fi
+
+MYDIR=$ROOT/tools/testing/i18nTestGenerator
+
+#
+# Extract all uses of the new SqlException and put it in our
+# source file.  We'll then compile this file, run it, and make
+# sure we have valid uses of message ids
+#
+for i in $FILES
+do
+  echo "    // from source file $i" >> $FILE
+  sed -n -f $MYDIR/genClient1.sed $i >> $FILE 
+done
+
+#
+# Use this sed script to clean things up so the source compiles 
+#
+sed -f $MYDIR/genClient2.sed $FILE > $FILE.2 
+
+if [ $? != 0 ]
+then
+  rm -f $FILE
+  rm -f $FILE.2
+  exit 1
+fi
+
+mv $FILE.2 $FILE
+
+echo "    }" >> $FILE
+echo "    catch ( Throwable t ) {" >> $FILE
+echo "      t.printStackTrace();" >> $FILE
+echo "    }" >> $FILE
+echo "  }" >> $FILE
+echo "}" >> $FILE
+
+exit 0

Propchange: db/derby/code/trunk/tools/testing/i18nTestGenerator/generateClientMessageTest.sh
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message