You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-cvs@xml.apache.org by pc...@apache.org on 2004/03/18 05:31:35 UTC

cvs commit: xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam JamDiffer.java ReflectJamTest.java JamTestBase.java ParserJamTest.java SourcesJamTest.java ClassesJamTest.java

pcal        2004/03/17 20:31:35

  Modified:    v2/jam/src/org/apache/xmlbeans/impl/jam/internal
                        JamClassLoaderImpl.java JamServiceContextImpl.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements
                        ClassImpl.java UnresolvedClassImpl.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc
                        JavadocClassBuilder.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect
                        ReflectClassBuilder.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/xml
                        JamXmlWriter.java
               v2/jam/test build.xml
               v2/jam/test/tests/org/apache/xmlbeans/test/jam
                        JamTestBase.java ParserJamTest.java
                        SourcesJamTest.java
  Added:       v2/jam/test/dummyclasses DefaultPackageClass.java
               v2/jam/test/masters/javadoc testMultipleTags.xml
               v2/jam/test/tests/org/apache/xmlbeans/test/jam
                        JamDiffer.java ReflectJamTest.java
  Removed:     v2/jam/test/tests/org/apache/xmlbeans/test/jam
                        ClassesJamTest.java
  Log:
  jam/j2s updates
  
  Revision  Changes    Path
  1.8       +1 -2      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/JamClassLoaderImpl.java
  
  Index: JamClassLoaderImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/JamClassLoaderImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JamClassLoaderImpl.java	17 Mar 2004 23:29:45 -0000	1.7
  +++ JamClassLoaderImpl.java	18 Mar 2004 04:31:35 -0000	1.8
  @@ -86,8 +86,7 @@
         //something.  We need to break out a separate checkClass() method
         //or something for them which returns null rather than UnresolvedClass.
         out = new UnresolvedClassImpl(pkg,name,mContext);
  -      mContext.warning(new ClassNotFoundException("Failed to resolve class "+
  -                                                  pkg+"' '"+name+"'"));
  +      mContext.warning("Warning: failed to resolve class '"+pkg+"' '"+name+"'");
         mFd2ClassCache.put(fd,out);
         return out;
       }
  
  
  
  1.10      +1 -1      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/JamServiceContextImpl.java
  
  Index: JamServiceContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/JamServiceContextImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JamServiceContextImpl.java	17 Mar 2004 23:29:45 -0000	1.9
  +++ JamServiceContextImpl.java	18 Mar 2004 04:31:35 -0000	1.10
  @@ -456,7 +456,7 @@
       if (isVerbose(this)) verbose(PREFIX+"Getting root for "+sourceFile+"...");
       for(int i=0; i<sourcepath.length; i++) {
         if (isVerbose(this)) verbose(PREFIX+"...looking in "+sourcepath[i]);
  -      if (isContainingDir(sourcepath[i],sourceFile)) {
  +      if (isContainingDir(sourcepath[i].getAbsoluteFile(),sourceFile)) {
           if (isVerbose(this)) verbose(PREFIX+"...found it!");
           return sourcepath[i].getAbsoluteFile();
         }
  
  
  
  1.9       +31 -24    xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/ClassImpl.java
  
  Index: ClassImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/ClassImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ClassImpl.java	17 Mar 2004 23:29:45 -0000	1.8
  +++ ClassImpl.java	18 Mar 2004 04:31:35 -0000	1.9
  @@ -80,7 +80,7 @@
                      String[] importSpecs) {
       super(ctx);
       super.setSimpleName(simpleName);
  -    mPackageName = packageName;
  +    mPackageName = packageName.trim();
       mImports = importSpecs;
     }
   
  @@ -204,7 +204,15 @@
     // MClass implementation
   
     public void setSuperclass(String qualifiedClassName) {
  -    mSuperClassRef = QualifiedJClassRef.create(qualifiedClassName, this);
  +    if (qualifiedClassName == null) {
  +      mSuperClassRef = null;
  +    } else {
  +      if (qualifiedClassName.equals(getQualifiedName())) {
  +        throw new IllegalArgumentException
  +          ("A class cannot be it's own superclass: '"+qualifiedClassName+"'");
  +      }
  +      mSuperClassRef = QualifiedJClassRef.create(qualifiedClassName, this);
  +    }
     }
   
     public void setSuperclassUnqualified(String unqualifiedClassName) {
  @@ -221,12 +229,17 @@
   
     public void addInterface(JClass interf) {
       if (interf == null) throw new IllegalArgumentException("null interf");
  +
       addInterface(interf.getQualifiedName());
     }
   
  -  public void addInterface(String qcname) {
  +  public void addInterface(String qcName) {
       if (mInterfaceRefs == null) mInterfaceRefs = new ArrayList();
  -    mInterfaceRefs.add(QualifiedJClassRef.create(qcname,this));
  +    if (qcName.equals(getQualifiedName())) {
  +      throw new IllegalArgumentException
  +        ("A class cannot implement itself: '"+qcName+"'");
  +    }
  +    mInterfaceRefs.add(QualifiedJClassRef.create(qcName,this));
     }
   
     public void addInterfaceUnqualified(String ucname) {
  @@ -332,7 +345,8 @@
     public void setIsAnnotationType(boolean b) { mIsAnnotationType = b; }
   
     public String getQualifiedName() {
  -    return mPackageName+ '.' +mSimpleName;
  +    return ((mPackageName.length() > 0) ? (mPackageName + '.') : "") +
  +      mSimpleName;
     }
   
     // ========================================================================
  @@ -418,33 +432,26 @@
       return false;
     }
   
  -  private static void addFieldsRecursively(JClass clazz, Collection out) {
  +  private void addFieldsRecursively(JClass clazz, Collection out) {
       JField[] fields = clazz.getDeclaredFields();
       for (int i = 0; i < fields.length; i++) out.add(fields[i]);
  -    if (clazz.isInterface()) {
  -      JClass[] ints = clazz.getInterfaces();
  -      for (int i = 0; i < ints.length; i++) {
  -        addFieldsRecursively(ints[i], out);
  -      }
  -    } else {
  -      clazz = clazz.getSuperclass();
  -      if (clazz != null) addFieldsRecursively(clazz, out);
  +    JClass[] ints = clazz.getInterfaces();
  +    for (int i = 0; i < ints.length; i++) {
  +      addFieldsRecursively(ints[i], out);
       }
  +    clazz = clazz.getSuperclass();
  +    if (clazz != null) addFieldsRecursively(clazz, out);
     }
   
  -  private static void addMethodsRecursively(JClass clazz, Collection out) {
  +  private void addMethodsRecursively(JClass clazz, Collection out) {
       JMethod[] methods = clazz.getDeclaredMethods();
       for (int i = 0; i < methods.length; i++) out.add(methods[i]);
  -    if (clazz.isInterface()) {
  -      JClass[] ints = clazz.getInterfaces();
  -      for (int i = 0; i < ints.length; i++) {
  -        addMethodsRecursively(ints[i], out);
  -      }
  -    } else {
  -      clazz = clazz.getSuperclass();
  -      if (clazz != null) addMethodsRecursively(clazz, out);
  +    JClass[] ints = clazz.getInterfaces();
  +    for (int i = 0; i < ints.length; i++) {
  +      addMethodsRecursively(ints[i], out);
       }
  +    clazz = clazz.getSuperclass();
  +    if (clazz != null) addMethodsRecursively(clazz, out);
     }
  -
   
   }
  
  
  
  1.3       +2 -1      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/UnresolvedClassImpl.java
  
  Index: UnresolvedClassImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/UnresolvedClassImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnresolvedClassImpl.java	9 Mar 2004 11:47:10 -0000	1.2
  +++ UnresolvedClassImpl.java	18 Mar 2004 04:31:35 -0000	1.3
  @@ -47,7 +47,8 @@
     // JClass elements
   
     public String getQualifiedName() {
  -    return mPackageName+"."+getSimpleName();
  +    return ((mPackageName.length() > 0) ? (mPackageName + '.') : "") +
  +      mSimpleName;
     }
   
     public String getFieldDescriptor() { return getQualifiedName(); }
  
  
  
  1.14      +11 -10    xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocClassBuilder.java
  
  Index: JavadocClassBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocClassBuilder.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JavadocClassBuilder.java	17 Mar 2004 23:29:46 -0000	1.13
  +++ JavadocClassBuilder.java	18 Mar 2004 04:31:35 -0000	1.14
  @@ -145,16 +145,13 @@
       if (getLogger().isVerbose(this)) {
         getLogger().verbose("trying to build '"+packageName+"' '"+className+"'");
       }
  -    String cn = packageName.trim();
  -    if (cn.length() == 0) {
  -      cn = className;
  -    } else {
  -      cn = packageName + "." +className;
  -    }
  -    ClassDoc cd = mRootDoc.classNamed(cn);
  +    String loadme = (packageName.trim().length() > 0) ?
  +      (packageName + '.'  + className) :
  +      className;
  +    ClassDoc cd = mRootDoc.classNamed(loadme);
       if (cd == null) {
  -      if (getLogger().isVerbose(this)) {
  -        mServiceContext.getLogger().verbose("no ClassDoc for "+cn);
  +      if (true || getLogger().isVerbose(this)) {
  +        getLogger().verbose("no ClassDoc for "+loadme);
         }
         return null;
       }
  @@ -259,7 +256,11 @@
           out.write(primFd);
         } else {
           out.write("L");
  -        out.write(t.asClassDoc().qualifiedName());
  +        if (t.asClassDoc() != null) {
  +          out.write(t.asClassDoc().qualifiedName());
  +        } else {
  +          out.write(t.qualifiedTypeName());
  +        }
           out.write(";");
         }
         return out.toString();
  
  
  
  1.4       +4 -1      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectClassBuilder.java
  
  Index: ReflectClassBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectClassBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReflectClassBuilder.java	17 Mar 2004 23:29:46 -0000	1.3
  +++ ReflectClassBuilder.java	18 Mar 2004 04:31:35 -0000	1.4
  @@ -77,7 +77,10 @@
     {
       Class rclass;
       try {
  -      rclass = mLoader.loadClass(packageName+"."+className);
  +      String loadme = (packageName.trim().length() > 0) ?
  +        (packageName + '.'  + className) :
  +        className;
  +      rclass = mLoader.loadClass(loadme);
       } catch(ClassNotFoundException cnfe) {
        getLogger().verbose(cnfe,this);
         return null;
  
  
  
  1.6       +3 -2      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/xml/JamXmlWriter.java
  
  Index: JamXmlWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/xml/JamXmlWriter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JamXmlWriter.java	17 Mar 2004 23:29:46 -0000	1.5
  +++ JamXmlWriter.java	18 Mar 2004 04:31:35 -0000	1.6
  @@ -316,6 +316,7 @@
       for(int i=0; i<values.length; i++) {
         writeAnnotationValue(values[i]);
       }
  +    mOut.writeEndElement();
     }
   
     private void writeAnnotationValue(JAnnotationValue val)
  @@ -323,8 +324,8 @@
     {
       mOut.writeStartElement(ANNOTATIONVALUE_ELEMENT);
       writeValueElement(NAME_ELEMENT,val.getName());
  -
  -writeValueElement(VALUE_ELEMENT,val.asString());
  +    writeValueElement(VALUE_ELEMENT,val.asString());
  +    mOut.writeEndElement();
       //FIXME what about asAnnotationArray?
   /*    JAnnotation nestedAnn = val.asAnnotation();
       if (nestedAnn != null) {
  
  
  
  1.7       +3 -1      xml-xmlbeans/v2/jam/test/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/build.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- build.xml	16 Mar 2004 05:34:50 -0000	1.6
  +++ build.xml	18 Mar 2004 04:31:35 -0000	1.7
  @@ -11,6 +11,7 @@
     <property name='junit_jar' value='${jamroot}/external/lib/junit.jar' />
     <property name='jsr173api_jar' value='../../build/lib/jsr173_api.jar'/>
     <property name='jsr173ri_jar' value='../../build/lib/jsr173_ri.jar'/>
  +  <property name='tidy_jar' value='../external/lib/tidy.jar'/>
   
   
     <path id='classpath' >
  @@ -21,6 +22,7 @@
       <pathelement location='${junit_jar}'/>
       <pathelement path='${java.class.path}' />
   
  +    <pathelement location='${tidy_jar}' />
       <pathelement location='${jsr173api_jar}' />
       <pathelement location='${jsr173ri_jar}' />
   
  @@ -69,7 +71,7 @@
   
   
         <test name='org.apache.xmlbeans.test.jam.SourcesJamTest'/>
  -      <test name='org.apache.xmlbeans.test.jam.ClassesJamTest'/>
  +      <test name='org.apache.xmlbeans.test.jam.ReflectJamTest'/>
   
         <!--parser work is on hold for the moment-->
         <!--<test name='org.apache.xmlbeans.test.jam.ParserJamTest'/>-->
  
  
  
  1.1                  xml-xmlbeans/v2/jam/test/dummyclasses/DefaultPackageClass.java
  
  Index: DefaultPackageClass.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   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.
   */
  
  /**
   * This is a class in the default package, which is a slightly strange
   * case for JAM.
   *
   *
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public class DefaultPackageClass {
  
    public int getId() { return -1; }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/jam/test/masters/javadoc/testMultipleTags.xml
  
  Index: testMultipleTags.xml
  ===================================================================
  <class><name>org.apache.xmlbeans.test.jam.dummyclasses.MultipleTags</name><is-interface>false</is-interface><superclass>java.lang.Object</superclass><modifiers>1</modifiers><constructor><modifiers>1</modifiers><source-position><line>20</line><column>8</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/MultipleTags.java</source-uri></source-position></constructor><method><name>getId</name><return-type>int</return-type><modifiers>1</modifiers><annotation><name>foo</name><annotation-value><name>x</name><value>-43 y=124 z=79</value></annotation-value><annotation-value><name>y</name><value>2</value></annotation-value><annotation-value><name>z</name><value>3 </value></annotation-value><annotation-value><name>x</name><value>1</value></annotation-value><annotation-value><name>w</name><value> 0</value></annotation-value></annotation><annotation><name>baz</name><annotation-value><name>x</name><value>1</value></annotation-value></annotation><annotation><name>bar</name><annotation-value><name>x</name><value>-4343</value></annotation-value></annotation><source-position><line>33</line><column>14</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/MultipleTags.java</source-uri></source-position></method><comment><![CDATA[Tests case for javadoc tags is declared more than once in a document.]]></comment><source-position><line>20</line><column>8</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/MultipleTags.java</source-uri></source-position></class>
  
  
  1.9       +97 -17    xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
  
  Index: JamTestBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamTestBase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JamTestBase.java	17 Mar 2004 23:29:46 -0000	1.8
  +++ JamTestBase.java	18 Mar 2004 04:31:35 -0000	1.9
  @@ -58,17 +58,25 @@
   import junit.framework.TestCase;
   import org.apache.xmlbeans.impl.jam.*;
   import org.apache.xmlbeans.impl.jam.xml.JamXmlWriter;
  +import org.w3c.dom.Document;
   
   import javax.xml.stream.XMLStreamException;
  -import javax.xml.stream.XMLInputFactory;
  -import javax.xml.stream.XMLStreamReader;
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.DocumentBuilderFactory;
   import java.io.File;
   import java.io.FileWriter;
   import java.io.IOException;
   import java.io.PrintWriter;
  +import java.io.StringWriter;
  +import java.io.FileReader;
  +import java.io.StringReader;
  +import java.io.InputStream;
   import java.io.Writer;
   import java.util.*;
   
  +import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
  +import com.sun.org.apache.xml.internal.serialize.OutputFormat;
  +
   /**
    * <p>Abstract base class for basic jam test cases.  These test cases work
    * against an abstract JamService - they don't care how the java types
  @@ -83,6 +91,7 @@
     // ========================================================================
     // Constants
   
  +  private static final boolean WRITE_MASTER_ON_FAIL = true;
   
     protected static final String
             DUMMY = "org.apache.xmlbeans.test.jam.dummyclasses";
  @@ -90,6 +99,7 @@
     //this array must contain the names of all of the test classes under
     //dummyclasses
     private static final String[] ALL_CLASSES = {
  +    "DefaultPackageClass",
       DUMMY+".ejb.IEnv",
       DUMMY+".ejb.MyEjbException",
       DUMMY+".ejb.TraderEJB",
  @@ -188,6 +198,8 @@
   
     protected abstract boolean isCommentsAvailable();
   
  +  protected abstract File getMasterDir();
  +
     // ========================================================================
     // Utility methods
   
  @@ -222,6 +234,7 @@
       for(int i=0; i<classes.length; i++) {
         resolved(classes[i]);
         classNames.add(classes[i].getQualifiedName());
  +      //System.out.println("-- "+classes[i].getQualifiedName());
       }
       List expected = Arrays.asList(ALL_CLASSES);
       assertTrue("result does not contain all expected classes",
  @@ -233,7 +246,7 @@
   
     public void test175Annotations() throws IOException, XMLStreamException {
       JClass clazz = resolved(mLoader.loadClass(DUMMY+".jsr175.AnnotatedClass"));
  -    dump(clazz);
  +    //dump(clazz);
     }
   
     public void testRecursiveResolve() {
  @@ -347,7 +360,6 @@
     public void testMultipleTags() {
       if (!isAnnotationsAvailable()) return;
       JClass mt = resolved(mLoader.loadClass(DUMMY+".MultipleTags"));
  -    compare(mt,"testMultipleTags.xml");
       JMethod method = mt.getMethods()[0];
       assertTrue(method.getAllJavadocTags().length == 6);
       assertTrue(method.getAllJavadocTags("foo").length == 4);
  @@ -355,6 +367,7 @@
       assertTrue(method.getAllJavadocTags("bar").length == 1);
       assertTrue(method.getAllJavadocTags("bar")[0].getValue("x").asInt() == -4343);
       assertTrue(method.getAllJavadocTags("baz").length == 1);
  +    compare(mt,"testMultipleTags.xml");
     }
   
   
  @@ -363,7 +376,70 @@
     // Private methods
   
     private void compare(JElement element, String masterName) {
  -    dump(element);//FIXME
  +    try {
  +      String result = null;
  +      {
  +        StringWriter resultWriter = new StringWriter();
  +        PrintWriter out = new PrintWriter(resultWriter,true);
  +        JamXmlWriter jxw = null;
  +        jxw = new JamXmlWriter(out);
  +        jxw.write(element);
  +        out.flush();
  +        try {
  +          System.out.println("--------------- "+resultWriter.toString());
  +          result = prettyPrint(resultWriter.toString());
  +        } catch(Exception e) {
  +          e.printStackTrace();
  +          System.err.flush();
  +          System.out.println("Problem with result:");
  +          System.out.println(resultWriter.toString());
  +          System.out.flush();
  +          fail("failed to parse result");
  +          return;
  +        }
  +      }
  +      File masterFile = new File(getMasterDir(),masterName);
  +      FileReader inA = new FileReader(masterFile);
  +      StringReader inB = new StringReader(result);
  +      StringWriter diff = new StringWriter();
  +      boolean same = JamDiffer.getInstance().diff(inA,inB,diff);
  +      if (same) return;
  +      if (WRITE_MASTER_ON_FAIL) {
  +        File expected = new File(getMasterDir(),"expected-"+masterName);
  +        FileWriter eout = new FileWriter(expected);
  +        eout.write(result);
  +        eout.close();
  +      }
  +      fail("Result did not match master at "+masterFile+":\n"+
  +           diff.toString());
  +    } catch(XMLStreamException xse) {
  +      xse.printStackTrace();
  +      fail(xse.getMessage());
  +    } catch(IOException ioe) {
  +      ioe.printStackTrace();
  +      fail(ioe.getMessage());
  +    }
  +  }
  +
  +  private String prettyPrint(String xml) throws Exception {
  +    return xml;//FIXME
  +    //FIXME StringBufferInputStream is bad
  +    //return prettyPrint(new StringBufferInputStream(xml));
  +  }
  +
  +  //all this work just because the 173 RI won't pretty print
  +  private String prettyPrint(InputStream in)  throws Exception {
  +    StringWriter s = new StringWriter();
  +    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  +    DocumentBuilder builder = factory.newDocumentBuilder();
  +    Document doc = builder.parse(in);
  +    OutputFormat format = new OutputFormat(doc);
  +
  +    //format.setIndenting(true);
  +    //format.setIndent(2);
  +    XMLSerializer serializer = new FixedXMLSerializer(s, format);
  +    serializer.serialize(doc);
  +    return s.toString();
     }
   
   
  @@ -433,19 +509,23 @@
                   a == null);
     }
   
  -  private void dump(JElement j) {
  -    Writer out = new PrintWriter(System.out,true);
  -    JamXmlWriter jxw = null;
  -    try {
  -      jxw = new JamXmlWriter(out);
  -      jxw.write(j);
  -      out.flush();
  -    } catch (IOException e) {
  -      e.printStackTrace();
  -    } catch (XMLStreamException e) {
  -      e.printStackTrace();
  -    }
  +  private void dump(JElement j, PrintWriter out) throws XMLStreamException {
     }
   
  +
  +
  +  //THIS IS A HACK to fix Sun's stupid bug for them
  +  private class FixedXMLSerializer extends XMLSerializer {
  +    public FixedXMLSerializer( Writer writer, OutputFormat format ) {
  +      super(writer,format);
  +    }
  +
  +    protected boolean getFeature(String feature){
  +      if (fFeatures == null) return false;
  +      Boolean b = (Boolean)fFeatures.get(feature);
  +      if (b == null) return false;
  +      return b.booleanValue();
  +    }
  +  }
   
   }
  
  
  
  1.6       +5 -0      xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ParserJamTest.java
  
  Index: ParserJamTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ParserJamTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ParserJamTest.java	17 Mar 2004 02:25:54 -0000	1.5
  +++ ParserJamTest.java	18 Mar 2004 04:31:35 -0000	1.6
  @@ -20,6 +20,7 @@
   import org.apache.xmlbeans.impl.jam.provider.JamServiceFactoryImpl;
   
   import java.io.IOException;
  +import java.io.File;
   
   /**
    *
  @@ -55,5 +56,9 @@
   
     protected boolean isCommentsAvailable() {
       return true;
  +  }
  +
  +  protected File getMasterDir() {
  +    return new File("masters/parser");
     }
   }
  
  
  
  1.8       +3 -1      xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/SourcesJamTest.java
  
  Index: SourcesJamTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/SourcesJamTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SourcesJamTest.java	17 Mar 2004 23:29:46 -0000	1.7
  +++ SourcesJamTest.java	18 Mar 2004 04:31:35 -0000	1.8
  @@ -59,7 +59,6 @@
   import org.apache.xmlbeans.impl.jam.JamServiceParams;
   import org.apache.xmlbeans.impl.jam.JamService;
   import org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocClassBuilder;
  -import org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocRunner;
   
   import java.io.IOException;
   import java.io.File;
  @@ -86,6 +85,7 @@
       JamServiceParams params = jsf.createServiceParams();
   //    params.setVerbose(JavadocRunner.class);
   //    params.setVerbose(JavadocClassBuilder.class);
  +//    params.setVerbose(DirectoryScanner.class);
   //    params.includeSourceFile(new File("x:\\xml-xmlbeans\\v2\\jam\\test\\dummyclasses\\org\\apache\\xmlbeans\\test\\jam\\dummyclasses\\MyException.java"));
       params.includeSourcePattern(getDummyclassesSourcepath(),"**/*.java");
   
  @@ -104,4 +104,6 @@
     protected boolean isCommentsAvailable() {
       return true;
     }
  +
  +  protected File getMasterDir() { return new File("masters/javadoc"); }
   }
  
  
  
  1.1                  xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamDiffer.java
  
  Index: JamDiffer.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   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.xmlbeans.test.jam;
  
  import java.io.IOException;
  import java.io.Reader;
  import java.io.BufferedReader;
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.List;
  
  
  /**
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public class JamDiffer {
  
    // ========================================================================
    // Singleton
  
    public static JamDiffer getInstance() { return INSTANCE; }
  
    private static final JamDiffer INSTANCE = new JamDiffer();
  
    private JamDiffer() {}
  
    // ========================================================================
    // Public methods
  
    public boolean diff(Reader a,
                        Reader b,
                        Writer out) throws IOException
    {
      return true; //FIXME
      /*Object[] aContents = getContents(a);
      Object[] bContents = getContents(b);
      Diff diff = new Diff(aContents, bContents);
      Diff.change script = diff.diff_2(false);
      if (script != null) {
        DiffPrint.NormalPrint p = new DiffPrint.NormalPrint(aContents, bContents);
        p.setOutput(out);
        p.print_script(script);
        return false;
      }
      return true;*/
    }
  
  
    // ========================================================================
    // Private methods
  
    private static String[] getContents(Reader in) throws IOException {
      BufferedReader reader = new BufferedReader(in);
      List list = new ArrayList();
      String s;
      while((s = reader.readLine()) != null) list.add(s);
      String[] out = new String[list.size()];
      list.toArray(out);
      return out;
    }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ReflectJamTest.java
  
  Index: ReflectJamTest.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.test.jam;
  
  import org.apache.xmlbeans.impl.jam.JamServiceFactory;
  import org.apache.xmlbeans.impl.jam.JamServiceParams;
  import org.apache.xmlbeans.impl.jam.JamService;
  
  import java.io.IOException;
  import java.io.File;
  
  /**
   * Runs the JamTestBase cases by loading the types from source.
   *
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public class ReflectJamTest extends JamTestBase {
  
    // ========================================================================
    // Constructors
  
    public ReflectJamTest(String name) {
      super(name);
    }
  
    // ========================================================================
    // JamTestBase implementation
  
    protected JamService getResultToTest() throws IOException {
      JamServiceFactory jsf = JamServiceFactory.getInstance();
      JamServiceParams params = jsf.createServiceParams();
      params.includeClassPattern(getDummyclassesClassPath(),"**/*.class");
      return jsf.createService(params);
    }
  
    protected boolean isAnnotationsAvailable() {
      return false;
    }
  
    protected boolean isParameterNamesKnown() { return false; }
  
    protected boolean isCommentsAvailable() {
      return false;
    }
  
    protected File getMasterDir() { return new File("masters/reflect"); }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org