You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2004/11/15 23:53:20 UTC

cvs commit: xml-xmlbeans/v2/test/src/xmlobject/xmlloader/detailed PiccoloParseTests.java XmlStreamBeanReader.java

cezar       2004/11/15 14:53:19

  Modified:    v2/test/src/scomp/derivation/restriction/facets/detailed
                        FacetRestrictionTest.java
               v2/test/src/scomp/elements/detailed GlobalEltNillable.java
               v2/test/src/xmlcursor/detailed SelectionsTest.java
  Added:       v2/test/cases/xbean/xmlcursor CR196679.xsd
               v2/test/src/xmlobject/detailed TypedObjectCursor.java
               v2/test/src/xmlobject/xmlloader/detailed
                        PiccoloParseTests.java XmlStreamBeanReader.java
  Log:
  Contributed by:Yana Kadiyska. Adding some tests for bug regressions
  
  Revision  Changes    Path
  1.1                  xml-xmlbeans/v2/test/cases/xbean/xmlcursor/CR196679.xsd
  
  Index: CR196679.xsd
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <xs:schema
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="qualified" 
      targetNamespace="http://xbean.test/xmlcursor/CR196679"
      xmlns:ns="http://xbean.test/xmlcursor/CR196679">
  
    <xs:element name="test" type="ns:testType"/>
  
    <xs:complexType name="testType">
      <xs:sequence>
        <xs:element name="name" type="xs:string" minOccurs="0"/>
        <xs:element name="value" type="xs:int" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  
  </xs:schema>
  
  
  
  1.2       +1 -0      xml-xmlbeans/v2/test/src/scomp/derivation/restriction/facets/detailed/FacetRestrictionTest.java
  
  Index: FacetRestrictionTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/scomp/derivation/restriction/facets/detailed/FacetRestrictionTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FacetRestrictionTest.java	8 Nov 2004 22:49:08 -0000	1.1
  +++ FacetRestrictionTest.java	15 Nov 2004 22:53:19 -0000	1.2
  @@ -61,6 +61,7 @@
                  XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID};
              assertTrue(!doc.validate(validateOptions));
              assertTrue(compareErrorCodes(errExpected));
  +      
   
   
          }
  
  
  
  1.6       +11 -0     xml-xmlbeans/v2/test/src/scomp/elements/detailed/GlobalEltNillable.java
  
  Index: GlobalEltNillable.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/scomp/elements/detailed/GlobalEltNillable.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GlobalEltNillable.java	4 Nov 2004 00:25:32 -0000	1.5
  +++ GlobalEltNillable.java	15 Nov 2004 22:53:19 -0000	1.6
  @@ -119,6 +119,17 @@
           }
           assertTrue ( testElt.isNilGlobalEltNillableInt());
           assertEquals(0, testElt.getGlobalEltNillableInt());
  +
  +        //after setting the value, the nil attribute should be gone
  +        testElt.setGlobalEltNillableInt(3);
  +        assertEquals(
  +                "<GlobalEltNillableInt" +
  +                " xmlns=\"http://xbean/scomp/element/GlobalEltNillable\"" +
  +                " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
  +                ">3</GlobalEltNillableInt>",
  +                testElt.xmlText() );
  +
  +
       }
   
   
  
  
  
  1.6       +37 -5     xml-xmlbeans/v2/test/src/xmlcursor/detailed/SelectionsTest.java
  
  Index: SelectionsTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/detailed/SelectionsTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SelectionsTest.java	3 Nov 2004 18:04:59 -0000	1.5
  +++ SelectionsTest.java	15 Nov 2004 22:53:19 -0000	1.6
  @@ -16,17 +16,13 @@
   
   package xmlcursor.detailed;
   
  -import org.apache.xmlbeans.XmlOptions;
   import junit.framework.*;
   import junit.framework.Assert.*;
   
   import java.io.*;
   
  -import org.apache.xmlbeans.XmlObject;
  -import org.apache.xmlbeans.XmlCursor;
  -import org.apache.xmlbeans.XmlBeans;
   import org.apache.xmlbeans.XmlCursor.TokenType;
  -import org.apache.xmlbeans.XmlDocumentProperties;
  +import org.apache.xmlbeans.*;
   import org.apache.xmlbeans.XmlCursor.XmlBookmark;
   
   import javax.xml.namespace.QName;
  @@ -35,6 +31,9 @@
   
   import java.net.URL;
   
  +import test.xbean.xmlcursor.cr196679.TestType;
  +import test.xbean.xmlcursor.cr196679.TestDocument;
  +
   
   /**
    *
  @@ -112,7 +111,40 @@
   
       }
   
  +    public void testCR196679() throws Exception
  +  {
  +      TestDocument testDoc = null;
  +      String input="<ns:test xmlns:ns=\"http://xbean.test/xmlcursor/CR196679\">\n" +
  +              "  <ns:name>myTest</ns:name>" +
  +              "  <ns:value>5</ns:value>" +
  +              "  </ns:test>";
  +      testDoc = TestDocument.Factory.parse(input);
  +      TestType test = testDoc.getTest();
  +
  +      String queryName =
  +        "declare namespace ns='http://xbean.test/xmlcursor/CR196679'" +
  +        "$this/ns:name";
  +
  +      String queryValue =
  +        "declare namespace ns='http://xbean.test/xmlcursor/CR196679'" +
  +        "$this/ns:value";
  +
  +      XmlCursor cursor = test.newCursor();
  +      cursor.push();
  +      cursor.selectPath(queryName);
  +      cursor.toNextSelection();
  +
  +      assertEquals("myTest",cursor.getTextValue());
  +
  +      cursor.pop();
  +      cursor.selectPath(queryValue);
  +      cursor.toNextSelection();
  +
  +      assertEquals("5",cursor.getTextValue());//expected output is value=5
  +
  +      cursor.dispose();
   
  +  }
       public void setUp()throws Exception{
   	m_xo=XmlObject.Factory.parse(sXml);
   	m_xc= m_xo.newCursor();
  
  
  
  1.1                  xml-xmlbeans/v2/test/src/xmlobject/detailed/TypedObjectCursor.java
  
  Index: TypedObjectCursor.java
  ===================================================================
  package xmlobject.detailed;
  
  import xmlcursor.common.BasicCursorTestCase;
  import xmlcursor.detailed.*;
  import junit.framework.Test;
  import junit.framework.TestSuite;
  import junit.framework.TestCase;
  import com.easypo.XmlPurchaseOrderDocumentBean;
  import com.easypo.XmlCustomerBean;
  import org.apache.xmlbeans.XmlCursor;
  
  /**
   * Date: Sep 10, 2004
   * Time: 10:31:36 AM
   *
   * @owner ykadiysk
   */
  public class TypedObjectCursor extends TestCase{
      public TypedObjectCursor(String name){
          super(name);
      }
       public static Test suite() {
          return new TestSuite(TypedObjectCursor.class);
      }
  
      public void testObjectCursor(){
      XmlPurchaseOrderDocumentBean.PurchaseOrder po= XmlPurchaseOrderDocumentBean.PurchaseOrder.Factory.newInstance();
      XmlCursor cur=po.newCursor();
      XmlCustomerBean cust=po.addNewCustomer();
      cust.setAddress("123 Fake Street");
      cust.setAge(23);
      cust.setName("Lisa Simpson");
      cur.toFirstContentToken();
      assertEquals(XmlCursor.TokenType.START, cur.currentTokenType());
        assertEquals(XmlCursor.TokenType.ATTR,cur.toNextToken());
          assertEquals("<xml-fragment age=\"23\"/>", cur.xmlText());
              assertEquals(XmlCursor.TokenType.START,cur.toNextToken());
           assertEquals(XmlCursor.TokenType.TEXT,cur.toNextToken());
          assertEquals("<xml-fragment>Lisa Simpson</xml-fragment>", cur.xmlText());
             assertEquals(XmlCursor.TokenType.END,cur.toNextToken());
              assertEquals(XmlCursor.TokenType.START,cur.toNextToken());
           assertEquals(XmlCursor.TokenType.TEXT,cur.toNextToken());
          assertEquals("<xml-fragment>123 Fake Street</xml-fragment>", cur.xmlText());
          cur.toPrevToken();
          cur.setTextValue("456".toCharArray(),0,3);
  }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/test/src/xmlobject/xmlloader/detailed/PiccoloParseTests.java
  
  Index: PiccoloParseTests.java
  ===================================================================
  package xmlobject.xmlloader.detailed;
  
  import junit.framework.TestCase;
  import tools.util.JarUtil;
  
  import java.io.InputStream;
  
  import org.apache.xmlbeans.XmlObject;
  
  /**
   * Date: Sep 13, 2004
   * Time: 9:51:38 AM
   *
   * @owner ykadiysk
   */
  public class PiccoloParseTests extends TestCase{
      String filename="xbean/xmlobject/japanese/core_generated_wsdl_src.xml";
      String temp="xbean/xmlobject/japanese/UCS2Encoding.xml";
  
      public void testParseInputStream() throws Exception{
          InputStream is=JarUtil.getResourceFromJarasStream(filename);
          assertTrue (is != null );
          XmlObject obj=XmlObject.Factory.parse(is);
      }
  
      public void testParseString() throws Exception{
          String str=JarUtil.getResourceFromJar(filename);
          assertTrue (str != null );
          XmlObject obj=XmlObject.Factory.parse(str);
      }
  
      public void testParseInputStreamUCS2() throws Exception{
            InputStream is=JarUtil.getResourceFromJarasStream(temp);
            assertTrue (is != null );
            XmlObject obj=XmlObject.Factory.parse(is);
        }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/test/src/xmlobject/xmlloader/detailed/XmlStreamBeanReader.java
  
  Index: XmlStreamBeanReader.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 xmlobject.xmlloader.detailed;
  
  import junit.framework.TestCase;
  import org.apache.xmlbeans.XmlOptions;
  import org.apache.xmlbeans.XmlObject;
  import org.apache.xmlbeans.XmlException;
  import org.openuri.bea.samples.workshop.CreditCardDataDocument;
  
  import javax.xml.stream.XMLInputFactory;
  import javax.xml.stream.XMLStreamReader;
  import javax.xml.stream.XMLStreamException;
  import java.io.ByteArrayInputStream;
  
  /**
   * Date: Oct 29, 2004
   * Time: 11:43:06 AM
   *
   * @owner ykadiysk
   */
  public class XmlStreamBeanReader extends TestCase{
  
      String creditCardXmlwPrefix =
                  " <cc:credit-card-data xmlns:cc=\"http://openuri.org/bea/samples/workshop\">\n" +
                  " <cc:customer id=\"1\">\n" +
                  " <cc:card name=\"MasterCard\" number=\"15385\">\n" +
                  " <cc:available-credit>0</cc:available-credit>\n" +
                  " <cc:credit-used>0</cc:credit-used>\n" +
                  " </cc:card>\n" +
                  " <cc:card name=\"Visa\" number=\"12346\">\n" +
                  " <cc:available-credit>0</cc:available-credit>\n" +
                  " <cc:credit-used>0</cc:credit-used>\n" +
                  " </cc:card>\n" +
                  " </cc:customer>\n" +
                  " <cc:customer id=\"2\">\n" +
                  " <cc:card name=\"MasterCard\" number=\"String\">\n" +
                  " <cc:available-credit>0</cc:available-credit>\n" +
                  " <cc:credit-used>0</cc:credit-used>\n" +
                  " </cc:card>\n" +
                  " <cc:card name=\"MasterCard\" number=\"String\">\n" +
                  " <cc:available-credit>0</cc:available-credit>\n" +
                  " <cc:credit-used>0</cc:credit-used>\n" +
                  " </cc:card>\n" +
                  " </cc:customer>\n" +
                  " </cc:credit-card-data>";
  
      //from CR192525
      public void testXMLStreamReaderLoader () throws XMLStreamException, XmlException {
             XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(creditCardXmlwPrefix.getBytes()));
                  CreditCardDataDocument ccdoc = (CreditCardDataDocument) XmlObject.Factory.parse(reader, new XmlOptions().setDocumentType(CreditCardDataDocument.type));
                  assertEquals(1,ccdoc.getCreditCardData().getCustomerArray(0).getId());
  
  
          }
  
  }
  
  
  

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