cvs commit: xml-xindice/java/tests/src/org/apache/xindice/xml/dom NodeListTest.java

[email protected]
Newsgroups gmane.text.xml.xindice.devel
Message-ID <[email protected]>
vgritsenko    2005/03/31 18:46:43

  Modified:    java/src/org/apache/xindice/xml TextWriter.java
               java/tests/src/org/apache/xindice/integration/client/services
                        MetaTest.java XUpdateQueryTest.java
               java/tests/src/org/apache/xindice/xml TextWriterTest.java
               java/tests/src/org/apache/xindice/xml/dom NodeListTest.java
  Log:
  text writer now always prints utf-8 encoding in xml declaration
  
  Revision  Changes    Path
  1.18      +9 -6      xml-xindice/java/src/org/apache/xindice/xml/TextWriter.java
  
  Index: TextWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/TextWriter.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TextWriter.java	24 Feb 2004 02:17:20 -0000	1.17
  +++ TextWriter.java	1 Apr 2005 02:46:43 -0000	1.18
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 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.
  @@ -37,7 +37,10 @@
   
   /**
    * TextWriter takes a Document, DocumentFragment, or Element and
  - * streams it as text to an output source (or a String)
  + * streams it as text into an {@link OutputStream}, {@link Writer},
  + * or a {@link String}.
  + *
  + * UTF-8 output encoding is assumed.
    *
    * @version CVS $Revision$, $Date$
    */
  @@ -45,7 +48,7 @@
   
       private static final Log log = LogFactory.getLog(TextWriter.class);
   
  -    private Node node = null;
  +    private Node node;
   
   
       public TextWriter(Node node) {
  @@ -84,7 +87,7 @@
           switch (type) {
   
               case Node.DOCUMENT_NODE:
  -                writer.write("<?xml version=\"1.0\"?>\n");
  +                writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
                   writeChildren(writer, node);
                   break;
   
  
  
  
  1.6       +4 -4      xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/MetaTest.java
  
  Index: MetaTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/MetaTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MetaTest.java	10 Jun 2004 14:46:48 -0000	1.5
  +++ MetaTest.java	1 Apr 2005 02:46:43 -0000	1.6
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 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.
  @@ -227,7 +227,7 @@
           Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
           MetaService service = (MetaService) col.getService("MetaService", "1.0");
   
  -        String custom0 = "<?xml version=\"1.0\"?>\n<mycustom xmlns=\"\">meta</mycustom>";
  +        String custom0 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<mycustom xmlns=\"\">meta</mycustom>";
           // Get meta & set custom document
           MetaData data = service.getMetaData(DOCUMENT_ID1);
           data.setCustomDocument(DOMParser.toDocument(custom0));
  
  
  
  1.7       +10 -16    xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/XUpdateQueryTest.java
  
  Index: XUpdateQueryTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/XUpdateQueryTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XUpdateQueryTest.java	8 Feb 2004 03:57:02 -0000	1.6
  +++ XUpdateQueryTest.java	1 Apr 2005 02:46:43 -0000	1.7
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 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.
  @@ -30,8 +30,7 @@
   public class XUpdateQueryTest
           extends AbstractXmlDbClientTest {
   
  -    public void setUp()
  -            throws Exception {
  +    public void setUp() throws Exception {
           super.setUp();
   
           String document1 = "<?xml version=\"1.0\"?>" +
  @@ -51,16 +50,13 @@
           this.client.insertDocument(TEST_COLLECTION_PATH, "doc2", document2);
       }
   
  -    public void tearDown()
  -            throws Exception {
  +    public void tearDown() throws Exception {
           this.client.removeDocument(TEST_COLLECTION_PATH, "doc1");
           this.client.removeDocument(TEST_COLLECTION_PATH, "doc2");
  -
           super.tearDown();
       }
   
  -    public void testUpdateDocument()
  -            throws Exception {
  +    public void testUpdateDocument() throws Exception {
           String query =
                   "<xupdate:modifications version=\"1.0\" xmlns:xupdate=\"http://www.xmldb.org/xupdate\">" +
                   "   <xupdate:update select=\"/person/@status\">married</xupdate:update>" +
  @@ -68,7 +64,7 @@
                   "   <xupdate:update select=\"/person/phone[@type = 'work']\">480-300-3003</xupdate:update>" +
                   "</xupdate:modifications>";
   
  -        String updatedDocument = "<?xml version=\"1.0\"?>\n" +
  +        String updatedDocument = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                   "<person status=\"married\">" +
                   "<first>Ben</first>" +
                   "<last>Smith</last>" +
  @@ -86,8 +82,7 @@
           assertEquals(updatedDocument, doc);
       }
   
  -    public void testUpdateCollection()
  -            throws Exception {
  +    public void testUpdateCollection() throws Exception {
           String query =
                   "<xupdate:modifications version=\"1.0\" xmlns:xupdate=\"http://www.xmldb.org/xupdate\">" +
                   "   <xupdate:update select=\"/person/@status\">divorced</xupdate:update>" +
  @@ -95,13 +90,13 @@
                   "   <xupdate:update select=\"/person/phone[@type = 'work']\">480-300-3003</xupdate:update>" +
                   "</xupdate:modifications>";
   
  -        String updatedDocument1 = "<?xml version=\"1.0\"?>\n" +
  +        String updatedDocument1 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                   "<person status=\"divorced\">" +
                   "<first>Ben</first>" +
                   "<last>Smith</last>" +
                   "<phone type=\"work\">480-300-3003</phone>" +
                   "</person>";
  -        String updatedDocument2 = "<?xml version=\"1.0\"?>\n" +
  +        String updatedDocument2 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                   "<person status=\"divorced\">" +
                   "<first>Ben</first>" +
                   "<last>Benton</last>" +
  @@ -122,5 +117,4 @@
           assertNotNull(doc);
           assertEquals(updatedDocument2, doc);
       }
  -
   }
  
  
  
  1.2       +4 -4      xml-xindice/java/tests/src/org/apache/xindice/xml/TextWriterTest.java
  
  Index: TextWriterTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/xml/TextWriterTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TextWriterTest.java	24 Feb 2004 02:16:55 -0000	1.1
  +++ TextWriterTest.java	1 Apr 2005 02:46:43 -0000	1.2
  @@ -29,7 +29,7 @@
   
   /**
    * Tests TextWriter class
  - * 
  + *
    * @version CVS $Revision$, $Date$
    */
   public class TextWriterTest extends TestCase {
  @@ -43,7 +43,7 @@
               "</element>";
   
       private static final String XML =
  -            "<?xml version=\"1.0\"?>\n" + FRAGMENT;
  +            "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + FRAGMENT;
   
       private Node dom;
       private TextWriter writer;
  
  
  
  1.2       +3 -2      xml-xindice/java/tests/src/org/apache/xindice/xml/dom/NodeListTest.java
  
  Index: NodeListTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/xml/dom/NodeListTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NodeListTest.java	31 Mar 2005 03:46:02 -0000	1.1
  +++ NodeListTest.java	1 Apr 2005 02:46:43 -0000	1.2
  @@ -15,6 +15,7 @@
    *
    * CVS $Id$
    */
  +
   package org.apache.xindice.xml.dom;
   
   import org.apache.xindice.xml.dom.traversal.TreeWalkerImpl;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.