tests/libjava-mauve/src/gnu/testlet/javax/xml/parsers/DocumentBuilder/parseSimpleXML.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: JDK1.2
       
     2 // Uses: Verifyer
       
     3 
       
     4 // Copyright (C) 2004, 2005 Audrius Meskauskas <audriusa@bluewin.ch>
       
     5 
       
     6 // This file is part of Mauve.
       
     7 
       
     8 // Mauve is free software; you can redistribute it and/or modify
       
     9 // it under the terms of the GNU General Public License as published by
       
    10 // the Free Software Foundation; either version 2, or (at your option)
       
    11 // any later version.
       
    12 
       
    13 // Mauve is distributed in the hope that it will be useful,
       
    14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16 // GNU General Public License for more details.
       
    17 
       
    18 // You should have received a copy of the GNU General Public License
       
    19 // along with Mauve; see the file COPYING.  If not, write to
       
    20 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    21 // Boston, MA 02111-1307, USA.
       
    22 
       
    23 
       
    24 package gnu.testlet.javax.xml.parsers.DocumentBuilder;
       
    25 
       
    26 import gnu.testlet.TestHarness;
       
    27 import gnu.testlet.Testlet;
       
    28 
       
    29 /**
       
    30  * A simple XML parsing test.
       
    31  * @author Audrius Meskauskas (AudriusA@Bluewin.ch)
       
    32  */
       
    33 public class parseSimpleXML
       
    34   extends Verifyer
       
    35   implements Testlet
       
    36 {
       
    37   public void test(TestHarness a_harness)
       
    38   {
       
    39     harness = a_harness;
       
    40 
       
    41     String head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
       
    42     verify(head +
       
    43            "<xa ap1=\"apv1\" ap2=\"apv2\"><b/><c><a ap1=\"n\"></a></c></xa>",
       
    44            "#document xa ap1='apv1'ap2='apv2' b c a ap1='n'", "simple xml"
       
    45           );
       
    46 
       
    47     verify(head + "<xa ap1=\"apv1\" ap2=\"apv2\">t0<b/>t1<c><a ap1=\"n\">" +
       
    48            "</a></c>te</xa>",
       
    49            "#document xa ap1='apv1'ap2='apv2' #text  = 't0' b #text  = 't1' c" +
       
    50            " a ap1='n' #text  = 'te'", "simple xml with text nodes"
       
    51           );
       
    52 
       
    53     verify(head + "<a><!--explain--></a>", "#document a #comment  = 'explain'",
       
    54            "comment"
       
    55           );
       
    56 
       
    57     verify(head + "<a><!--e1--><!--e2--></a>",
       
    58            "#document a #comment  = 'e1' #comment  = 'e2'",
       
    59            "subsequent comments"
       
    60           );
       
    61 
       
    62     verify(head + "<a xmlns:ans=\"www.lithuania.lt\"><ans:b></ans:b></a>",
       
    63            "#document a xmlns:ans='www.lithuania.lt' www.lithuania.lt:ans:b",
       
    64            "explicit namespace"
       
    65           );
       
    66 
       
    67     verify(head + "<a xmlns=\"www.lithuania.lt\"><b></b></a>",
       
    68            "#document www.lithuania.lt:a xmlns='www.lithuania.lt' www.lithuania.lt:b",
       
    69            "default namespace"
       
    70           );
       
    71 
       
    72     verify(head +
       
    73            "<a xmlns=\"www.lithuania.lt\" xmlns:ans=\"www.gnu.org\"><b><ans:c>" +
       
    74            "</ans:c></b></a>",
       
    75            "#document www.lithuania.lt:a " +
       
    76            "xmlns='www.lithuania.lt'xmlns:ans='www.gnu.org' " +
       
    77            "www.lithuania.lt:b www.gnu.org:ans:c", "mixed namespaces"
       
    78           );
       
    79 
       
    80     verify("<xa ap1=\"apv1\" ap2=\"apv2\"><b/><c><a ap1=\"n\"></a></c></xa>",
       
    81            "#document xa ap1='apv1'ap2='apv2' b c a ap1='n'",
       
    82            "missing xml header"
       
    83           );
       
    84   }
       
    85 }