You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by da...@apache.org on 2004/09/08 22:50:37 UTC

cvs commit: xml-xmlbeans/v2/test/src/compile/scomp/incr/schemaCompile/detailed IncrCompilationTests.java

daveremy    2004/09/08 13:50:37

  Modified:    v2/test/src/compile/scomp/checkin CompilationTests.java
  Added:       v2/test/src/compile/scomp/common CompileCommon.java
                        CompileTestBase.java
               v2/test/src/compile/scomp/incr/schemaCompile/detailed
                        IncrCompilationTests.java
  Log:
  Contributed By: Jacob Danner
  Added some detailed tests for radu's incremental compilation checkin
  from a few weeks ago.
  
  Revision  Changes    Path
  1.3       +23 -0     xml-xmlbeans/v2/test/src/compile/scomp/checkin/CompilationTests.java
  
  Index: CompilationTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/compile/scomp/checkin/CompilationTests.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CompilationTests.java	7 Aug 2004 01:33:32 -0000	1.2
  +++ CompilationTests.java	8 Sep 2004 20:50:37 -0000	1.3
  @@ -111,6 +111,14 @@
           SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem();
           system = XmlBeans.compileXsd(schemas, builtin, options);
           Assert.assertNotNull("Compilation failed during inititial compile.", system);
  +        System.out.println("-= Initial Compile =-");
  +        for (int i = 0; i < system.globalTypes().length; i++) {
  +            System.out.println("[" + i + "]-" + system.globalTypes()[i].getName());
  +        }
  +
  +        for (int i = 0; i < system.globalElements().length; i++) {
  +            System.out.println("[" + i + "]=" + system.globalElements()[i].getName());
  +        }
   
           // Incremental compile
           String url = schemas[n - 2].documentProperties().getSourceName();
  @@ -121,14 +129,28 @@
           system = XmlBeans.compileXsd(system, schemas1, builtin, options);
           Assert.assertNotNull("Compilation failed during incremental compile.", system);
           SchemaCodeGenerator.saveTypeSystem(system, outincr, null, null, null);
  +        System.out.println("-= Incremental Compile =-");
  +        for (int i = 0; i < system.globalTypes().length; i++) {
  +            System.out.println("[" + i + "]-" + system.globalTypes()[i].getName());
  +        }
   
  +        for (int i = 0; i < system.globalElements().length; i++) {
  +            System.out.println("[" + i + "]=" + system.globalElements()[i].getName());
  +        }
           // Now compile non-incrementally for the purpose of comparing the result
           errors.clear();
           schemas[n-2] = schemas1[0];
           system = XmlBeans.compileXsd(schemas, builtin, options);
           Assert.assertNotNull("Compilation failed during reference compile.", system);
           SchemaCodeGenerator.saveTypeSystem(system, out, null, null, null);
  +        System.out.println("-= Sanity Compile =-");
  +        for (int i = 0; i < system.globalTypes().length; i++) {
  +            System.out.println("[" + i + "]-" + system.globalTypes()[i].getName());
  +        }
   
  +        for (int i = 0; i < system.globalElements().length; i++) {
  +            System.out.println("[" + i + "]=" + system.globalElements()[i].getName());
  +        }
           // Compare the results
           String oldPropValue = System.getProperty("xmlbeans.diff.diffIndex");
           System.setProperty("xmlbeans.diff.diffIndex", "false");
  @@ -142,6 +164,7 @@
                   message.write(((String) errors.get(i)) + "\n");
               Assert.fail("Differences encountered:" + message);
           }
  +        throw new Exception("AHHH");
       }
   
       public void testSchemaBookmarks() throws Throwable
  
  
  
  1.1                  xml-xmlbeans/v2/test/src/compile/scomp/common/CompileCommon.java
  
  Index: CompileCommon.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 compile.scomp.common;
  
  import org.apache.xmlbeans.XmlError;
  
  import java.io.File;
  import java.io.IOException;
  import java.util.List;
  
  /**
   * @author jacobd
   * Date: Aug 4, 2004
   */
  public class CompileCommon {
  
      public static final String P = File.separator;
  
      public static File fwroot = getRootFile();
      public static File caseroot = new File(fwroot, "test" + P + "cases");
      //location of files under "cases folder"
      public static String fileLocation = P + "xbean" + P + "compile" + P + "scomp" + P;
      public static File outputroot = new File(fwroot, "build" + P + "test" + P + "output");
  
      public static File getRootFile() throws IllegalStateException {
          try {
              return new File(System.getProperty("xbean.rootdir")).getCanonicalFile();
          } catch (IOException e) {
              throw new IllegalStateException(e.toString());
          }
      }
  
      public static File xbeanCase(String str) {
          return (new File(caseroot.getPath() + fileLocation, str));
      }
  
      public static File xbeanOutput(String str) {
          File result = (new File(outputroot, str));
          File parentdir = result.getParentFile();
          parentdir.mkdirs();
          return result;
      }
  
      public static void deltree(File dir) {
          if (dir.exists()) {
              if (dir.isDirectory()) {
                  String[] list = dir.list();
                  for (int i = 0; i < list.length; i++)
                      deltree(new File(dir, list[i]));
              }
              if (!dir.delete())
                  System.out.println("Could not delete " + dir);
              //throw new IllegalStateException("Could not delete " + dir);
          }
      }
  
      public static void listErrors(List errors) {
          for (int i = 0; i < errors.size(); i++) {
              XmlError error = (XmlError) errors.get(i);
              if (error.getSeverity() == XmlError.SEVERITY_ERROR)
                  System.out.println(error.toString());
          }
      }
  
      public static boolean isJDK14() {
          return System.getProperty("java.version").startsWith("1.4");
      }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/test/src/compile/scomp/common/CompileTestBase.java
  
  Index: CompileTestBase.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 compile.scomp.common;
  
  import junit.framework.TestCase;
  import junit.framework.Assert;
  import org.apache.xmlbeans.impl.tool.SchemaCompiler;
  import org.apache.xmlbeans.impl.tool.Diff;
  import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator;
  import org.apache.xmlbeans.*;
  import org.w3.x2001.xmlSchema.SchemaDocument;
  
  import javax.xml.namespace.QName;
  import java.io.File;
  import java.io.IOException;
  import java.io.StringWriter;
  import java.util.List;
  import java.util.ArrayList;
  
  /**
   * @author jacobd
   * Date: Aug 5, 2004
   */
  public class CompileTestBase extends TestCase {
  
      public static final String P = File.separator;
      public static String outputDir = "compile" + P + "scomp" + P + "incr";
      public static String outPath = P + outputDir + P + "out";
  
      public static String sanityPath = P + outputDir + P + "sanity";
      public static String incrPath = P + outputDir + P + "outincr";
  
      public SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem();
      public File out;
      public File outincr;
      public File sanity;
      public List errors;
      public XmlOptions xm;
  
      public CompileTestBase(String name) {
          super(name);
          out = CompileCommon.xbeanOutput(outPath);
          sanity = CompileCommon.xbeanOutput(sanityPath);
          outincr = CompileCommon.xbeanOutput(incrPath);
  
          errors = new ArrayList();
          xm = new XmlOptions();
          xm.setErrorListener(errors);
          xm.setSavePrettyPrint();
      }
  
      protected SchemaCompiler.Parameters getCompilerParams() {
          SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
          params.setDownload(true);
          params.setVerbose(true);
          return params;
      }
  
  
      protected SchemaCompiler.Parameters getIncrCompilerParams() {
          SchemaCompiler.Parameters params = getCompilerParams();
          params.setIncrementalSrcGen(true);
          return params;
      }
  
      protected boolean runCompiler(File[] schemas, String srcDir,
                                    String classesDir, String outputDir,
                                    SchemaCompiler.Parameters params) {
  
          File srcdir = CompileCommon.xbeanOutput(srcDir);
          File classesdir = CompileCommon.xbeanOutput(classesDir);
          File outputjar = CompileCommon.xbeanOutput(outputDir);
          params.setXsdFiles(schemas);
          params.setSrcDir(srcdir);
          params.setClassesDir(classesdir);
          params.setOutputJar(outputjar);
          return SchemaCompiler.compile(params);
      }
  
      public void log(SchemaTypeSystem sts) {
          System.out.println("SchemaTypes: " + sts);
      }
  
      public void log(Object[] arr) {
          for (int i = 0; i < arr.length; i++)
              System.out.print(arr[i].toString());
      }
  
  
      /**
       * compares type systems and populates error list based on differences in files
       *
       * @param out
       * @param outincr
       * @param errors
       */
      public void compareandPopErrors(File outDir, File outIncrDir, List errors) {
          // Compare the results
          String oldPropValue = System.getProperty("xmlbeans.diff.diffIndex");
          System.setProperty("xmlbeans.diff.diffIndex", "false");
          errors.clear();
          Diff.dirsAsTypeSystems(outDir, outIncrDir, errors);
          System.setProperty("xmlbeans.diff.diffIndex", oldPropValue == null ? "true" : oldPropValue);
  
      }
  
      /**
       * compares type systems and populates error list based on
       * default out and outincr directories
       *
       * @param out
       * @param outincr
       * @param errors
       */
      public void compareandPopErrors(List errors) {
          // Compare the results
          String oldPropValue = System.getProperty("xmlbeans.diff.diffIndex");
          System.setProperty("xmlbeans.diff.diffIndex", "false");
          errors.clear();
          Diff.dirsAsTypeSystems(out, outincr, errors);
          System.setProperty("xmlbeans.diff.diffIndex", oldPropValue == null ? "true" : oldPropValue);
  
      }
  
  
      /**
       * take the type system that gets created in compileSchemas()
       */
      public SchemaTypeSystem incrCompileXsd(SchemaTypeSystem system, XmlObject[] schemas,
                                             SchemaTypeLoader typepath, XmlOptions options) throws XmlException, IOException {
  
          SchemaTypeSystem sts;
          sts = XmlBeans.compileXsd(system, schemas, builtin, options);
          Assert.assertNotNull("Compilation failed during Incremental Compile.", sts);
          SchemaCodeGenerator.saveTypeSystem(sts, outincr, null, null, null);
          return sts;
  
      }
  
      /**
       * Original Compilation to directory specified
       */
      public SchemaTypeSystem compileSchemas(XmlObject[] schemas, SchemaTypeLoader typepath,
                                             XmlOptions options, File outDir) throws XmlException, IOException {
          SchemaTypeSystem system;
          SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem();
          system = XmlBeans.compileXsd(schemas, builtin, options);
          Assert.assertNotNull("Compilation failed during compile.", system);
          SchemaCodeGenerator.saveTypeSystem(system, outDir, null, null, null);
          return system;
      }
  
  
      //original compile to get base type system
      public SchemaTypeSystem compileSchemas(XmlObject[] schemas, SchemaTypeLoader typepath,
                                             XmlOptions options) throws XmlException, IOException {
          SchemaTypeSystem system;
          SchemaTypeSystem builtin = XmlBeans.getBuiltinTypeSystem();
          system = XmlBeans.compileXsd(schemas, builtin, options);
          Assert.assertNotNull("Compilation failed during compile.", system);
          SchemaCodeGenerator.saveTypeSystem(system, out, null, null, null);
          return system;
      }
  
      public void handleErrors(List errors) {
          if (errors.size() > 0) {
              StringWriter message = new StringWriter();
              for (int i = 0; i < errors.size(); i++)
                  message.write(((String) errors.get(i)) + "\n");
              Assert.fail("\nDifferences encountered:\n" + message);
          }
      }
  
      public String getBaseSchema(String namespace, String elTypeName,
                                  String elType, String attrTypeName, String attrType) {
          return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                  "<xs:schema " +
                  "attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" " +
                  "targetNamespace=\"http://" + namespace + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" +
                  "<xs:element name=\"" + elTypeName + "\" type=\"bas:aType\" xmlns:bas=\"http://" + namespace + "\" />" +
                  "<xs:complexType name=\"aType\">" +
                  "<xs:simpleContent>" +
                  "<xs:extension base=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" >" +
                  "<xs:attribute type=\"xs:" + attrType + "\" name=\"" + attrTypeName + "\" />" +
                  "</xs:extension>" +
                  "</xs:simpleContent>" +
                  "</xs:complexType>" +
                  "</xs:schema>";
      }
  
      public SchemaDocument.Schema[] getSchema(XmlObject schemaObj) throws XmlException {
          SchemaDocument.Schema[] schemas = new SchemaDocument.Schema[1];
          schemas[0] = SchemaDocument.Factory.parse(schemaObj.xmlText()).getSchema();
          return schemas;
      }
  
      public SchemaDocument.Schema[] getSchema(XmlObject[] schemaObj) throws XmlException {
          SchemaDocument.Schema[] schemas = new SchemaDocument.Schema[schemaObj.length];
  
          for (int i = 0; i < schemaObj.length; i++)
              schemas[i] = SchemaDocument.Factory.parse(schemaObj[i].xmlText()).getSchema();
  
          return schemas;
      }
  
      public void echoSts(SchemaTypeSystem base, SchemaTypeSystem incr) {
          System.out.println("-= Base =-");
          log(base, "base");
          System.out.println("-= Incr =-");
          log(incr, "incr");
      }
  
      public void log(SchemaTypeSystem base, String msg) {
          for (int i = 0; i < base.globalTypes().length; i++) {
              System.out.println(msg + " [" + i + "]-" + base.globalTypes()[i].getName());
          }
      }
  
      public void findElementbyQName(SchemaTypeSystem sts, QName[] lookup) throws Exception {
          for (int i = 0; i < lookup.length; i++) {
              if (sts.findElement(lookup[i]) == null)
                  throw new Exception("Element was expected but not found\n" + lookup[i]);
          }
      }
  
      public static String[] invalidSchemas = {
          "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" +
              "  <xs:complexType name='base' final='extension'/>\n" +
              "  <xs:complexType name='ext'>\n" +
              "    <xs:complexContent>\n" +
              "      <xs:extension base='base'/>\n" +
              "    </xs:complexContent>\n" +
              "  </xs:complexType>\n" +
              "</xs:schema>\n",
  
          "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" +
              "  <xs:complexType name='base' final='#all'/>\n" +
              "  <xs:complexType name='ext'>\n" +
              "    <xs:complexContent>\n" +
              "      <xs:extension base='base'/>\n" +
              "    </xs:complexContent>\n" +
              "  </xs:complexType>\n" +
              "</xs:schema>\n",
  
          "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='#all'>\n" +
              "  <xs:complexType name='base'/>\n" +
              "  <xs:complexType name='rest'>\n" +
              "    <xs:complexContent>\n" +
              "      <xs:restriction base='base'/>\n" +
              "    </xs:complexContent>\n" +
              "  </xs:complexType>\n" +
              "</xs:schema>\n",
  
          "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='restriction'>\n" +
              "  <xs:complexType name='base'/>\n" +
              "  <xs:complexType name='rest'>\n" +
              "    <xs:complexContent>\n" +
              "      <xs:restriction base='base'/>\n" +
              "    </xs:complexContent>\n" +
              "  </xs:complexType>\n" +
              "</xs:schema>\n",
      };
  
      public static String[] validSchemas = {
          "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" +
              "  <xs:complexType name='base' final='extension'/>\n" +
              "  <xs:complexType name='rest'>\n" +
              "    <xs:complexContent>\n" +
              "      <xs:restriction base='base'/>\n" +
              "    </xs:complexContent>\n" +
              "  </xs:complexType>\n" +
              "</xs:schema>\n",
  
          "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" +
              "  <xs:complexType name='base' final='restriction'/>\n" +
              "  <xs:complexType name='ext'>\n" +
              "    <xs:complexContent>\n" +
              "      <xs:extension base='base'/>\n" +
              "    </xs:complexContent>\n" +
              "  </xs:complexType>\n" +
              "</xs:schema>\n",
  
          "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='restriction'>\n" +
              "  <xs:complexType name='base'/>\n" +
              "  <xs:complexType name='ext'>\n" +
              "    <xs:complexContent>\n" +
              "      <xs:extension base='base'/>\n" +
              "    </xs:complexContent>\n" +
              "  </xs:complexType>\n" +
              "</xs:schema>\n",
  
          "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' finalDefault='extension'>\n" +
              "  <xs:complexType name='base'/>\n" +
              "  <xs:complexType name='rest'>\n" +
              "    <xs:complexContent>\n" +
              "      <xs:restriction base='base'/>\n" +
              "    </xs:complexContent>\n" +
              "  </xs:complexType>\n" +
              "</xs:schema>\n",
      };
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/test/src/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java
  
  Index: IncrCompilationTests.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 compile.scomp.incr.schemaCompile.detailed;
  
  import junit.framework.TestCase;
  import junit.framework.Assert;
  import junit.framework.Test;
  import junit.framework.TestSuite;
  import org.apache.xmlbeans.impl.common.QNameHelper;
  import org.apache.xmlbeans.impl.tool.SchemaCompiler;
  import org.apache.xmlbeans.impl.tool.CodeGenUtil;
  import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator;
  import org.apache.xmlbeans.impl.tool.Diff;
  import org.w3.x2001.xmlSchema.SchemaDocument;
  import org.w3.x2001.xmlSchema.TopLevelComplexType;
  import org.apache.xmlbeans.*;
  
  import java.io.File;
  import java.io.StringWriter;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Arrays;
  import java.util.Collections;
  
  import tools.util.TestRunUtil;
  import compile.scomp.common.CompileCommon;
  import compile.scomp.common.CompileTestBase;
  
  import javax.xml.namespace.QName;
  
  
  /**
   * @author jacobd
   * Date: Aug 2, 2004
   */
  public class IncrCompilationTests extends CompileTestBase {
  
  
      public IncrCompilationTests(String name) {
          super(name);
      }
  
      public static Test suite() {
          return new TestSuite(IncrCompilationTests.class);
      }
  
      public void setUp() throws IOException {
          CompileCommon.deltree(CompileCommon.xbeanOutput(outputDir));
          out = CompileCommon.xbeanOutput(outPath);
          sanity = CompileCommon.xbeanOutput(sanityPath);
          outincr = CompileCommon.xbeanOutput(incrPath);
  
          errors = new ArrayList();
          xm = new XmlOptions();
          xm.setErrorListener(errors);
          xm.setSavePrettyPrint();
      }
  
      public void tearDown() throws IOException {
          if (errors.size() > 0)
              errors.clear();
      }
  
  
      public void test_dupetype_diffns() throws Exception {
          XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "string"));
          XmlObject obj2 = XmlObject.Factory.parse(getBaseSchema("bar", "elName", "string", "attrName", "string"));
          XmlObject[] schemas = new XmlObject[]{obj1};
          XmlObject[] schemas2 = new XmlObject[]{obj2};
          schemas[0].documentProperties().setSourceName("obj1");
          schemas2[0].documentProperties().setSourceName("obj2");
  
          SchemaTypeSystem base = compileSchemas(schemas, builtin, xm);
          SchemaTypeSystem incr;
          try {
              incr = incrCompileXsd(base, schemas2, builtin, xm);
          } catch (XmlException xmlEx) {
              throw new Exception(xmlEx.getError().toString());
          }
          if (base.findElement(new QName("http://baz", "elName")) == null)
              throw new Exception("BASE: Baz elName was not found");
  
          if (incr.findElement(new QName("http://baz", "elName")) == null)
              throw new Exception("INCR: Baz elName was not found");
  
          for (int i = 0; i < incr.globalElements().length; i++) {
              System.out.println("[" + i + "]-" + incr.globalElements()[i].getName());
          }
  
          for (int i = 0; i < base.globalElements().length; i++) {
              System.out.println("[" + i + "]-" + base.globalElements()[i].getName());
          }
  
          if (incr.findElement(new QName("http://bar", "elName")) == null)
              throw new Exception("INCR: Bar elName was not found");
  
          compareandPopErrors(out, outincr, errors);
          handleErrors(errors);
      }
  
  
      public void test_dupens_difftypename() throws Exception {
          XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "string"));
          XmlObject obj2 = XmlObject.Factory.parse(getBaseSchema("baz", "elName2", "string", "attrName2", "string"));
          XmlObject[] schemas = new XmlObject[]{obj1};
          XmlObject[] schemas2 = new XmlObject[]{obj2};
          schemas[0].documentProperties().setSourceName("obj1");
          schemas2[0].documentProperties().setSourceName("obj2");
  
          SchemaTypeSystem base = compileSchemas(schemas, builtin, xm);
          SchemaTypeSystem incr = incrCompileXsd(base, schemas2, builtin, xm);
  
          echoSts(base, incr);
          QName[] baseTypes = new QName[]{new QName("http://baz", "elName")};
          QName[] incrTypes = new QName[]{new QName("http://baz", "elName"),
                                          new QName("http://baz", "elName2")};
  
          findElementbyQName(base, baseTypes);
          findElementbyQName(incr, incrTypes);
  
          compareandPopErrors(out, outincr, errors);
          handleErrors(errors);
      }
  
  
      /**
       * This test should not change sts since xmlobject is same
       * @throws Exception
       */
      public void test_dupens_dupetypename() throws Exception {
          XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "string"));
          XmlObject obj2 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "string"));
          XmlObject[] schemas = new XmlObject[]{obj1};
          XmlObject[] schemas2 = new XmlObject[]{obj2};
          schemas[0].documentProperties().setSourceName("obj1");
          schemas2[0].documentProperties().setSourceName("obj2");
  
          SchemaTypeSystem base = compileSchemas(schemas, builtin, xm);
          SchemaTypeSystem incr = incrCompileXsd(base, schemas2, builtin, xm);
  
          echoSts(base, incr);
          QName[] baseTypes = new QName[]{new QName("http://baz", "elName")};
          QName[] incrTypes = new QName[]{new QName("http://baz", "elName")};
  
          findElementbyQName(base, baseTypes);
          findElementbyQName(incr, incrTypes);
  
          Assert.assertEquals(base, incr);
  
          compareandPopErrors(out, outincr, errors);
          handleErrors(errors);
      }
  
      public void test_dupens_attrnamechange() throws Exception {
          //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType"));
          XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "string"));
          XmlObject obj2 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName2", "string"));
          XmlObject[] schemas = new XmlObject[]{obj1};
          XmlObject[] schemas2 = new XmlObject[]{obj2};
          schemas[0].documentProperties().setSourceName("obj1");
          schemas2[0].documentProperties().setSourceName("obj2");
  
          SchemaTypeSystem base = compileSchemas(schemas, builtin, xm);
          SchemaTypeSystem incr = incrCompileXsd(base, schemas2, builtin, xm);
  
          echoSts(base, incr);
          QName[] baseTypes = new QName[]{new QName("http://baz", "elName")};
          QName[] incrTypes = new QName[]{new QName("http://baz", "elName")};
  
          findElementbyQName(base, baseTypes);
          findElementbyQName(incr, incrTypes);
  
          Assert.assertNotSame(base, incr);
  
          compareandPopErrors(out, outincr, errors);
          handleErrors(errors);
      }
  
      public void test_dupens_attrtypechange() throws Exception {
          //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType"));
          XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "string"));
          XmlObject obj2 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "int"));
          XmlObject[] schemas = new XmlObject[]{obj1};
          XmlObject[] schemas2 = new XmlObject[]{obj2};
          schemas[0].documentProperties().setSourceName("obj1");
          schemas2[0].documentProperties().setSourceName("obj2");
  
          SchemaTypeSystem base = compileSchemas(schemas, builtin, xm);
          SchemaTypeSystem incr = incrCompileXsd(base, schemas2, builtin, xm);
  
          echoSts(base, incr);
          QName[] baseTypes = new QName[]{new QName("http://baz", "elName")};
          QName[] incrTypes = new QName[]{new QName("http://baz", "elName")};
  
          findElementbyQName(base, baseTypes);
          findElementbyQName(incr, incrTypes);
  
          Assert.assertNotSame(base, incr);
  
          compareandPopErrors(out, outincr, errors);
          handleErrors(errors);
      }
  
  
      public void test_dupens_eltypechange() throws Exception {
          //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType"));
          XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "string"));
          XmlObject obj2 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "int", "attrName", "string"));
          XmlObject[] schemas = new XmlObject[]{obj1};
          XmlObject[] schemas2 = new XmlObject[]{obj2};
          schemas[0].documentProperties().setSourceName("obj1");
          schemas2[0].documentProperties().setSourceName("obj2");
  
          SchemaTypeSystem base = compileSchemas(schemas, builtin, xm);
          SchemaTypeSystem incr = incrCompileXsd(base, schemas2, builtin, xm);
  
          echoSts(base, incr);
          QName[] baseTypes = new QName[]{new QName("http://baz", "elName")};
          QName[] incrTypes = new QName[]{new QName("http://baz", "elName")};
  
          findElementbyQName(base, baseTypes);
          findElementbyQName(incr, incrTypes);
  
          //        if (incr.findElement(incrTypes[0]).getType().g
          Assert.assertNotSame(base, incr);
  
          compareandPopErrors(out, outincr, errors);
          handleErrors(errors);
      }
  
      public void test_typechange() throws Exception {
          //XmlObject.Factory.parse(getBaseSchema("baz","elName", "elType", "attrName","attrType"));
          XmlObject obj1 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "string", "attrName", "string"));
          XmlObject obj2 = XmlObject.Factory.parse(getBaseSchema("baz", "elName", "int", "attrName2", "string"));
          XmlObject[] schemas = new XmlObject[]{obj1};
          XmlObject[] schemas2 = new XmlObject[]{obj2};
          schemas[0].documentProperties().setSourceName("obj1");
          schemas2[0].documentProperties().setSourceName("obj2");
  
          SchemaTypeSystem base = compileSchemas(schemas, builtin, xm);
          SchemaTypeSystem incr = incrCompileXsd(base, schemas2, builtin, xm);
  
          echoSts(base, incr);
          QName[] baseTypes = new QName[]{new QName("http://baz", "elName")};
          QName[] incrTypes = new QName[]{new QName("http://baz", "elName")};
  
          findElementbyQName(base, baseTypes);
          findElementbyQName(incr, incrTypes);
  
          System.out.println("Type: " + incr.findElement(incrTypes[0]).getType());
          System.out.println("Name: " + incr.findElement(incrTypes[0]).getType().getName());
          System.out.println("Name: " + incr.findElement(incrTypes[0]).getType().getElementProperties()[0].getType());
  
          Assert.assertNotSame(base, incr);
  
          compareandPopErrors(out, outincr, errors);
          handleErrors(errors);
      }
  
  
  }
  
  
  

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