Author: jsong
Date: Fri Aug 27 14:33:23 2004
New Revision: 37134

Modified:
   incubator/beehive/trunk/controls/test/infra/tch/tchx.jar
   incubator/beehive/trunk/controls/test/tools/tch/build.xml
   incubator/beehive/trunk/controls/test/tools/tch/setenv.sh
   
incubator/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/SchemaValidate.java
   
incubator/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/update/clazz/JavadocComment.java
Log:
Submit for Joe Pemberton, changes made to tch and update tch.jar to include 
these updates.


Modified: incubator/beehive/trunk/controls/test/infra/tch/tchx.jar
==============================================================================
Binary files. No diff available.

Modified: incubator/beehive/trunk/controls/test/tools/tch/build.xml
==============================================================================
--- incubator/beehive/trunk/controls/test/tools/tch/build.xml   (original)
+++ incubator/beehive/trunk/controls/test/tools/tch/build.xml   Fri Aug 27 
14:33:23 2004
@@ -2,6 +2,8 @@
 
   <property name="buildenv-props" value="buildenv.properties"/>
   <property file="${buildenv-props}"/>
+    <property environment="os"/>
+    <property file="${os.BEEHIVE_HOME}/beehive.properties"/>
 
   <property file="common.props"/>
 
@@ -11,6 +13,16 @@
   <property name="nativegendir" value="${nativedir}/gen"/>
  
   <property name="nop4" value="false"/>
+  
+  <!-- Stuff for schema compilation -->
+  <property name="schema.compiler" 
value="org.apache.xmlbeans.impl.tool.SchemaCompiler"/>
+  <property name="schema.jar.file" location="deploy/schema.jar"/>
+    
+    <path id="classpath">
+        <pathelement path="3rdparty/xbean-1.0.2.jar"/>
+    </path>
+  
+  
 
   <target name="all" depends="build, jar, gen-root"/> 
   
@@ -27,13 +39,20 @@
     <available file="${buildenv-props}" property="${propfile-found}"/>
     <fail unless="${propfile-found}" message="Cannot load ${buildenv-props}"/>
 
+    <antcall target="compile.schema"/>
+    
     <mkdir dir="${classes}"/> 
     <echo message="java-src is: ${java-src}"/>
     <javac 
       debug="${debug}" srcdir="${java-src}" destdir="${classes}" 
       excludes="tch/version.java,
                 tch/**"
-    />
+    >
+        <classpath>
+            <pathelement path="${os.CLASSPATH}"/>
+            <pathelement location="${schema.jar.file}"/>
+        </classpath>
+    </javac>
 
     <!-- rmic -->
 
@@ -218,6 +237,35 @@
       />
     </zip>
   </target>
+
+  
+  
+  <!-- compiles the schema using xbeans -->
+  <target name="compile.schema">
+    <echo message="Using compiler from: ${schema.compiler}"/>
+    
+    <property name="schema.file" 
location="deploy/schema/everything-suite.xsd"/>
+    <property name="temp.dir" location="temp"/>
+    
+    <echo message="schema.file: ${schema.file}"/>
+    
+    <delete file="${schema.jar.file}"/>
+    <delete dir="${temp.dir}"/>
+    <mkdir dir="${temp.dir}"/>
+
+
+    <java classname="${schema.compiler}"
+               classpathref="classpath"
+        fork="true">
+        <arg line="-out ${schema.jar.file}"/>
+        <arg line="-d ${temp.dir}"/>
+        <arg line="${schema.file}"/>
+    </java>
+
+    <echo message="schema.jar.file: ${schema.jar.file}"/>
+    <delete dir="${temp.dir}"/>
+  </target>
+
 
 </project>
 

Modified: incubator/beehive/trunk/controls/test/tools/tch/setenv.sh
==============================================================================
--- incubator/beehive/trunk/controls/test/tools/tch/setenv.sh   (original)
+++ incubator/beehive/trunk/controls/test/tools/tch/setenv.sh   Fri Aug 27 
14:33:23 2004
@@ -1,95 +1,96 @@
-#!/bin/sh
-
-TCH_HOME=`pwd`
-export TCH_HOME
-
-TCH_SRC="${TCH_HOME}/src"
-export TCH_SRC
-
-echo "$TCH_HOME"
-
-# read version file, will be used when generating tch.version
-TCH_VERSION=`cat version`
-echo "version: ${TCH_VERSION}"
-export TCH_VERSION
-
-# should probably provide a default
-JAVA_HOME=${JAVA_HOME:-$JAVAHOME}
-
-
-EXTERNAL_DIR=${BEEHIVE_HOME}/external
-ANT_HOME=${ANT_HOME:-${BEEHIVE_HOME}/installed/apache-ant-1.6.1}
-ANT_JAR=${ANT_JAR:-$ANT_HOME/lib/ant.jar}
-ANT_LAUNCHER_JAR=${ANT_LAUNCHER_JAR:-$ANT_HOME/lib/ant-launcher.jar}
-JUNIT_JAR=${JUNIT_JAR:-${EXTERNAL_DIR}/junit/junit.jar}
-XERCES_JAR=${EXTERNAL_DIR}/xerces/xerces-1.4.4.jar
-CRIMSON_JAR=${EXTERNAL_DIR}/crimson/crimson-1.1.jar
-JAKARTA_JAR=${EXTERNAL_DIR}/jakarta/jakarta-regexp-1.2.jar
-JAXP_JAR=${EXTERNAL_DIR}/jaxp/jaxp.jar
-
-PATHSEP=":"
-myos=`uname`
-case "$myos" in
-  Window*)
-  PATHSEP=";"
-  ;;
-esac
-
-
-cd ${TCH_HOME}/3rdparty
-THIRDPARTY_DIR=`pwd`
-for A in \
-j2ee12.jar
-do
-  echo "Adding ${THIRDPARTY_DIR}/$A to CLASSPATH"
-  CLASSPATH="${THIRDPARTY_DIR}/$A${PATHSEP}$CLASSPATH"
-done
-echo ""
-cd $TCH_HOME
-
-
-echo "Adding ${JUNIT_JAR} to CLASSPATH"
-CLASSPATH="${JUNIT_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${ANT_JAR} to CLASSPATH"
-CLASSPATH="${ANT_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${ANT_LAUNCHER_JAR} to CLASSPATH"
-CLASSPATH="${ANT_LAUNCHER_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${XERCES_JAR} to CLASSPATH"
-CLASSPATH="${XERCES_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${CRIMSON_JAR} to CLASSPATH"
-CLASSPATH="${CRIMSON_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${JAKARTA_JAR} to CLASSPATH"
-CLASSPATH="${JAKARTA_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${JAXP_JAR} to CLASSPATH"
-CLASSPATH="${JAXP_JAR}${PATHSEP}$CLASSPATH"
-
-
-
-
-
-echo "Adding $JAVA_HOME/lib/tools.jar to CLASSPATH"
-CLASSPATH="$JAVA_HOME/lib/tools.jar${PATHSEP}$CLASSPATH"
-echo ""
-
-export CLASSPATH
-
-echo "Adding ${JAVA_HOME}/bin to PATH"
-PATH="$JAVA_HOME/bin/${PATHSEP}$PATH"
-ANT_SCRIPT="${TCH_HOME}/"
-echo "Adding ${ANT_SCRIPT} to PATH"
-PATH="${ANT_SCRIPT}${PATHSEP}$PATH"
-
-rm -f $TCH_HOME/buildenv.properties
-echo TCH_HOME=${TCH_HOME} >> $TCH_HOME/buildenv.properties
-echo >> $TCH_HOME/buildenv.properties
-echo optimize=false >> $TCH_HOME/buildenv.properties
-echo debug=true >> $TCH_HOME/buildenv.properties
-
-unset TCH_HOME optimize debug ANT_SCRIPT
-echo ""
+#!/bin/sh
+
+TCH_HOME=`pwd`
+export TCH_HOME
+
+TCH_SRC="${TCH_HOME}/src"
+export TCH_SRC
+
+echo "$TCH_HOME"
+
+# read version file, will be used when generating tch.version
+TCH_VERSION=`cat version`
+echo "version: ${TCH_VERSION}"
+export TCH_VERSION
+
+# should probably provide a default
+JAVA_HOME=${JAVA_HOME:-$JAVAHOME}
+
+
+EXTERNAL_DIR=${BEEHIVE_HOME}/external
+ANT_HOME=${ANT_HOME:-${BEEHIVE_HOME}/installed/apache-ant-1.6.1}
+ANT_JAR=${ANT_JAR:-$ANT_HOME/lib/ant.jar}
+ANT_LAUNCHER_JAR=${ANT_LAUNCHER_JAR:-$ANT_HOME/lib/ant-launcher.jar}
+JUNIT_JAR=${JUNIT_JAR:-${EXTERNAL_DIR}/junit/junit.jar}
+#XERCES_JAR=${EXTERNAL_DIR}/xerces/xerces-1.4.4.jar
+CRIMSON_JAR=${EXTERNAL_DIR}/crimson/crimson-1.1.jar
+JAKARTA_JAR=${EXTERNAL_DIR}/jakarta/jakarta-regexp-1.2.jar
+JAXP_JAR=${EXTERNAL_DIR}/jaxp/jaxp.jar
+
+PATHSEP=":"
+myos=`uname`
+case "$myos" in
+  Window*)
+  PATHSEP=";"
+  ;;
+esac
+
+
+cd ${TCH_HOME}/3rdparty
+THIRDPARTY_DIR=`pwd`
+for A in \
+j2ee12.jar \
+xbean-1.0.2.jar
+do
+  echo "Adding ${THIRDPARTY_DIR}/$A to CLASSPATH"
+  CLASSPATH="${THIRDPARTY_DIR}/$A${PATHSEP}$CLASSPATH"
+done
+echo ""
+cd $TCH_HOME
+
+
+echo "Adding ${JUNIT_JAR} to CLASSPATH"
+CLASSPATH="${JUNIT_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${ANT_JAR} to CLASSPATH"
+CLASSPATH="${ANT_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${ANT_LAUNCHER_JAR} to CLASSPATH"
+CLASSPATH="${ANT_LAUNCHER_JAR}${PATHSEP}$CLASSPATH"
+
+#echo "Adding ${XERCES_JAR} to CLASSPATH"
+#CLASSPATH="${XERCES_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${CRIMSON_JAR} to CLASSPATH"
+CLASSPATH="${CRIMSON_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${JAKARTA_JAR} to CLASSPATH"
+CLASSPATH="${JAKARTA_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${JAXP_JAR} to CLASSPATH"
+CLASSPATH="${JAXP_JAR}${PATHSEP}$CLASSPATH"
+
+
+
+
+
+echo "Adding $JAVA_HOME/lib/tools.jar to CLASSPATH"
+CLASSPATH="$JAVA_HOME/lib/tools.jar${PATHSEP}$CLASSPATH"
+echo ""
+
+export CLASSPATH
+
+echo "Adding ${JAVA_HOME}/bin to PATH"
+PATH="$JAVA_HOME/bin/${PATHSEP}$PATH"
+ANT_SCRIPT="${TCH_HOME}/"
+echo "Adding ${ANT_SCRIPT} to PATH"
+PATH="${ANT_SCRIPT}${PATHSEP}$PATH"
+
+rm -f $TCH_HOME/buildenv.properties
+echo TCH_HOME=${TCH_HOME} >> $TCH_HOME/buildenv.properties
+echo >> $TCH_HOME/buildenv.properties
+echo optimize=false >> $TCH_HOME/buildenv.properties
+echo debug=true >> $TCH_HOME/buildenv.properties
+
+unset TCH_HOME optimize debug ANT_SCRIPT
+echo ""

Modified: 
incubator/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/SchemaValidate.java
==============================================================================
--- 
incubator/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/SchemaValidate.java
 (original)
+++ 
incubator/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/core/SchemaValidate.java
 Fri Aug 27 14:33:23 2004
@@ -1,6 +1,8 @@
 package org.apache.beehive.test.tools.tch.core;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.lang.StringBuffer;
 
 import org.apache.tools.ant.BuildException;
 import org.xml.sax.HandlerBase;
@@ -10,6 +12,9 @@
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.ParserFactory;
 
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.XmlError;
+
 class MyHandlerBase extends HandlerBase
 {
 
@@ -106,79 +111,31 @@
 
   public void validatingParse(String uri) throws Exception
   {
-    try
-    {
-      MyHandlerBase handler = new MyHandlerBase();
-      Parser parser = ParserFactory.makeParser(parserName);
-      parser.setDocumentHandler(handler);
-      parser.setErrorHandler(handler);
-      String classname = parser.getClass().getName();
-      //set the schema location
-      if (debug)
-        org.apache.beehive.test.tools.tch.util.DebugLogger.log(
-          "Parser Class Name is : " + classname);
-      if (debug)
-        org.apache.beehive.test.tools.tch.util.DebugLogger.log(
-          "Schema Name is : " + schemaName);
-      //add check that the file specified actually exists
-      File f = new File(schemaName);
-      if (f.exists())
-      {
-        if (debug)
-          org.apache.beehive.test.tools.tch.util.DebugLogger.log(
-            "Schema " + schemaName + " exists!!");
-      }
-      else
-      {
-        org.apache.beehive.test.tools.tch.util.DebugLogger.log(
-          "WARNING: Schema " + schemaName + " does not exist!!");
-        throw new BuildException(
-          "Schema file " + schemaName + " does not exist");
+      File f = new File(uri);
+      noNamespace.ProjectDocument projectDoc = 
noNamespace.ProjectDocument.Factory.parse(f);
+      
+      //parse the document
+      XmlOptions validateOptions = new XmlOptions();
+      ArrayList errorList = new ArrayList();
+      validateOptions.setErrorListener(errorList);
+
+      try{
+        projectDoc.validate(validateOptions);
       }
-      try
-      {
-        //if (validate && parser instanceof XMLReader)
-        if (parser instanceof XMLReader)
+      finally{
+        if (errorList.size() > 0)
         {
-          ((XMLReader)parser).setProperty(
-            
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";,
-            schemaName);
-          ((XMLReader)parser).setFeature(
-            "http://xml.org/sax/features/validation";,
-            true);
-          ((XMLReader)parser).setFeature(
-            "http://xml.org/sax/features/namespaces";,
-            true);
-          ((XMLReader)parser).setFeature(
-            "http://apache.org/xml/features/validation/schema";,
-            true);
-          ((XMLReader)parser).setFeature(
-            "http://apache.org/xml/features/nonvalidating/load-external-dtd";,
-            true);
-          ((XMLReader)parser).setFeature(
-            "http://apache.org/xml/features/validation/schema-full-checking";,
-            true);
-        }
-      }
-      catch (Exception ex)
-      {
-        throw new BuildException("Exception setting properties on parser", ex);
+          StringBuffer str = new StringBuffer();
+         for (int i = 0; i < errorList.size(); i++)
+         {
+           XmlError error = (XmlError) errorList.get(i);
+           str.append("\n");
+           str.append("Message: " + error.getMessage() + "\n");
+           str.append("Location of invalid XML: " + 
error.getCursorLocation().xmlText() + "\n");
+         }
+         throw new BuildException(str.toString());
+       }
       }
-      //parse the document
-      parser.parse(uri);
-      if (handler.errorFound())
-      {
-        throw new BuildException(
-          "Error(s) found during validation of file "
-            + uri
-            + "\n"
-            + handler.getBuildErrorString());
-      }
-    }
-    catch (Exception e)
-    {
-      throw new BuildException("Exception during parse", e);
-    }
   }
 
   public void setSchemaName(String inName)

Modified: 
incubator/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/update/clazz/JavadocComment.java
==============================================================================
--- 
incubator/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/update/clazz/JavadocComment.java
       (original)
+++ 
incubator/beehive/trunk/controls/test/tools/tch/src/java/org/apache/beehive/test/tools/tch/extension/update/clazz/JavadocComment.java
       Fri Aug 27 14:33:23 2004
@@ -8,8 +8,6 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import org.apache.xml.serialize.LineSeparator;
-
 import org.apache.beehive.test.tools.tch.util.OrderedMap;
 
 public class JavadocComment

Reply via email to