You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2008/10/19 03:11:00 UTC

svn commit: r705945 - in /db/derby/code/trunk: ./ java/build/org/apache/derbyBuild/ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/tests/i18n/

Author: myrnavl
Date: Sat Oct 18 18:11:00 2008
New Revision: 705945

URL: http://svn.apache.org/viewvc?rev=705945&view=rev
Log:
DERBY-1458; implement a message check from the build; 
  third attempt - rewritten as an ant-taskdef (not junit).

Added:
    db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java
      - copied, changed from r703259, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/MessageBundleTest.java
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/MessageBundleTest.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/MessageBundleTest.java
Modified:
    db/derby/code/trunk/build.xml

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?rev=705945&r1=705944&r2=705945&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Sat Oct 18 18:11:00 2008
@@ -32,7 +32,7 @@
 <!-- Targets -->
 
   <target name="buildsource" depends="checkCompilerLevel,init,prebuild,setCompilerProperties,jsr169stubs,engine,storeless,tools,drda,client,build,versioninfo,localeinfo"/>
-  <target name="all" depends="buildsource,demo,testing,pptesting"/>
+  <target name="all" depends="buildsource,demo,testing,pptesting,runmessagecheck"/>
 
 <!-- ==================================================================== -->
 <!--                       Initialize targets                             -->
@@ -471,28 +471,13 @@
   </target>
 
   <!-- Run the MessageBundleTest -->
-    <target name="runmessagecheck" depends="checkjunittask,runmessagechecktest,nojunittask">
-  </target>
-
-  <target name="runmessagechecktest" depends="junit-init" if="optionaljunit.available">
-    <property name="derby.junit.testclass" value="org.apache.derbyTesting.functionTests.tests.i18n.MessageBundleTest"/>
-    <antcall target="junit-single"/>
-    <antcall target="cleanjunit"/>
-  </target>
-
-  <!-- junit.jar must be available or we couldn't build, but can we run a junit task? -->
-  <target name="checkjunittask">
-    <available property="optionaljunit.available" 
-      classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTest"/>
-  </target>
-
-  <target name="nojunittask" unless="optionaljunit.available">
-    <echo message="no junit task available; no message check run"/>
-    <antcall target="cleanjunit"/>
-  </target>
-
-  <target name="cleanjunit">
-    <delete dir="junit_${derby.junit.timestamp}"/>
+  <target name="runmessagecheck">
+    <taskdef 
+      name="runMessageBundleTest"
+      classname="org.apache.derbyBuild.MessageBundleTest"
+      classpath="${out.dir}"
+    />
+    <runMessageBundleTest/>
   </target>
 
 <!-- ==================================================================== -->

Copied: db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java (from r703259, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/MessageBundleTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java?p2=db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/MessageBundleTest.java&r1=703259&r2=705945&rev=705945&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/MessageBundleTest.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java Sat Oct 18 18:11:00 2008
@@ -1,6 +1,6 @@
 /*
  
-   Derby - Class org.apache.derbyTesting.functionTests.tests.i18n.MessageBundleTest
+   Derby - Class org.apache.derbyMessageBundleTest
  
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -19,9 +19,8 @@
  
  */
 
-package org.apache.derbyTesting.functionTests.tests.i18n;
+package org.apache.derbyBuild;
 
-import org.apache.derbyTesting.junit.BaseTestCase;
 import org.apache.derby.shared.common.reference.SQLState;
 import org.apache.derby.shared.common.reference.MessageId;
 
@@ -31,6 +30,10 @@
 import java.util.Locale;
 import java.util.Iterator;
 
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+
 /**
  * This class does everything we can to validate that the messages_en.properties
  * file is in synch with SQLState.java and MessageId.java.  We want to make sure
@@ -39,11 +42,34 @@
  * that don't have matching ids in the SQLState and MessageId files.   The
  * first is a bug, the second is something to be aware of.
  */
-public class MessageBundleTest extends BaseTestCase {
-    public MessageBundleTest(String name) {
-        super(name);
-    }
+public class MessageBundleTest extends Task {
 
+    static boolean failbuild = false;
+
+    /**
+     * <p>
+     * Let Ant conjure us out of thin air.
+     * </p>
+     */
+    public MessageBundleTest()
+    {}
+    
+    public void execute() throws BuildException
+    {
+        MessageBundleTest t = new MessageBundleTest();
+        try {
+            t.testMessageBundleOrphanedMessages();
+            t.testMessageIdOrphanedIds();
+            t.testSQLStateOrphanedIds();
+        } catch (Exception e) {
+            System.out.println("Message check failed: ");
+            e.printStackTrace();
+        }
+        if (failbuild) 
+            throw new BuildException("Message check failed. \n" +
+                "See error in build output or call ant runmessagecheck.");
+    }    
+    
     // The list of ids.  We use a HashSet so we can detect duplicates easily
     static HashSet sqlStateIds          = new HashSet();
     static HashSet messageIdIds         = new HashSet();
@@ -87,6 +113,7 @@
             
             if ( ! set.add(id) )
             {
+                failbuild=true;
                 System.err.println("ERROR: The id " + id + 
                     " was found twice in " + idclass.getName());
             }
@@ -121,6 +148,7 @@
             String key = (String)keys.nextElement();                
 
             if ( ! messageBundleIds.add(key) ) {
+                failbuild=true;
                 System.err.println("ERROR: the key " + key +
                     " exists twice in messages_en.properties");
             }
@@ -142,14 +170,15 @@
                 // messages.xml:
                 // XCL32: will never be exposed to users (see DERBY-1414)
                 // XSAX1: shared SQLState explains; not exposed to users. 
-                // 
                 if (!(sqlStateId.equalsIgnoreCase("XCL32.S") ||
-                    sqlStateId.equalsIgnoreCase("XSAX1")))
+                    sqlStateId.equalsIgnoreCase("XSAX1"))) {
                 // Don't fail out on the first one, we want to catch
                 // all of them.  Just note there was a failure and continue
+                    failbuild=true;
                     System.err.println("ERROR: Message id " + sqlStateId +
                         " in SQLState.java was not found in" +
-                        " messages_en.properties");                     
+                        " messages_en.properties");         
+                }
              }
         }
     }
@@ -167,6 +196,7 @@
             if ( ! messageBundleIds.contains(sqlStateId) ) {
                 // Don't fail out on the first one, we want to catch
                 // all of them.  Just note there was a failure and continue
+                failbuild=true;
                 System.err.println("ERROR: Message id " + sqlStateId +
                     " in MessageId.java was not found in" +
                     " messages_en.properties");                    
@@ -194,6 +224,7 @@
             
             // Don't fail out on the first one, we want to catch
             // all of them.  Just note there was a failure and continue
+            failbuild=true;
             System.err.println("WARNING: Message id " + msgid + 
                 " in messages_en.properties is not " +
                 "referenced in either SQLState.java or MessageId.java");