xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ce...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases RedefineTest.java SmokeTests.java
Date Wed, 05 May 2004 17:42:59 GMT
cezar       2004/05/05 10:42:59

  Modified:    v2/test/src/drt/drtcases SmokeTests.java
  Added:       v2/test/src/drt/drtcases RedefineTest.java
  Log:
  Adding the redefine test case.
  
  DRT: passes
  
  Revision  Changes    Path
  1.14      +1 -1      xml-xmlbeans/v2/test/src/drt/drtcases/SmokeTests.java
  
  Index: SmokeTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/SmokeTests.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SmokeTests.java	5 May 2004 16:49:31 -0000	1.13
  +++ SmokeTests.java	5 May 2004 17:42:59 -0000	1.14
  @@ -52,7 +52,7 @@
           suite.addTest(ValidatingXMLStreamReaderTests.suite());
           suite.addTest(SelectChldAttTests.suite());
           suite.addTest(ValidatorTests.suite());
  -//        suite.addTest(RedefineTest.suite());
  +        suite.addTest(RedefineTest.suite());
           return suite;
       }
   }
  
  
  
  1.1                  xml-xmlbeans/v2/test/src/drt/drtcases/RedefineTest.java
  
  Index: RedefineTest.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 drtcases;
  
  import junit.framework.TestCase;
  import junit.framework.Test;
  import junit.framework.TestSuite;
  import junit.framework.Assert;
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.XmlOptions;
  import org.apache.xmlbeans.XmlError;
  import org.apache.xmlbeans.XmlObject;
  import org.example.prod.NewSizeDocument;
  
  import java.util.List;
  import java.util.ArrayList;
  
  /**
   * @author Cezar Andrei (cezar.andrei at bea.com)
   * Date: May 4, 2004
   */
  public class RedefineTest extends TestCase
  {
      public RedefineTest(String name) { super(name); }
      public static Test suite() { return new TestSuite(RedefineTest.class); }
  
      public void testRedefine()
      {
          try
          {
              String xml = "<newSize xmlns='http://example.org/prod'>7</newSize>";
              NewSizeDocument nsDoc = NewSizeDocument.Factory.parse(xml);
  
              boolean valid = nsDoc.validate();
  
              if (!valid)
                  print(nsDoc);
  
              Assert.assertTrue(valid);
  
              Assert.assertTrue(nsDoc.getNewSize()==7);
  
              nsDoc.setNewSize(20);
  
              List errors = new ArrayList();
              XmlOptions options = new XmlOptions();
              options.setErrorListener(errors);
  
              valid = nsDoc.validate(options);
  
              if (valid || errors.size()!=1)
                  print(nsDoc);
  
              Assert.assertTrue(!valid);
  
              Assert.assertTrue(errors.size()==1);
          }
          catch (XmlException e)
          {
              Assert.assertTrue(false);
          }
      }
  
      private static void print(XmlObject xo)
      {
          List errors = new ArrayList();
          XmlOptions options = new XmlOptions();
          options.setErrorListener(errors);
  
          System.out.println("Doc:\n" + xo + "\nValid: " + xo.validate(options));
  
          for (int i = 0; i < errors.size(); i++)
          {
              XmlError xmlError = (XmlError) errors.get(i);
              System.out.println(xmlError);
          }
      }
  }
  
  
  

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


Mime
View raw message