PR target/27599
[official-gcc.git] / libjava / classpath / testsuite / javax.swing.text.html.parser / test / gnu / javax / swing / text / html / parser / Element_Test.java
blob039be4ab7ece5b36f21470d08f84e9e523aa5c8b
1 /* Element_Test.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package test.gnu.javax.swing.text.html.parser;
41 import javax.swing.text.html.parser.AttributeList;
42 import javax.swing.text.html.parser.DTD;
43 import javax.swing.text.html.parser.DTDConstants;
44 import javax.swing.text.html.parser.Element;
46 /**
47 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
49 public class Element_Test
50 extends TestCase
52 private Element element = null;
54 public void testAttributeGetter()
55 throws Exception
57 // Create a chain of 24 attributes:
58 AttributeList list = new AttributeList("heading");
59 AttributeList head = list;
60 list.value = null;
61 for (int i = 0; i < 24; i++)
63 AttributeList a = new AttributeList("a" + i);
64 a.value = "v" + i;
65 list.next = a;
66 list = a;
69 Element e = DTD.getDTD("test").getElement("e");
70 e.atts = head;
72 for (int i = 0; i < 24; i++)
74 // Check if the name is found.
75 assertEquals(e.getAttribute("a" + i).toString(), "a" + i);
77 // Check if the attribute value is correct.
78 assertEquals(e.getAttribute("a" + i).value, "v" + i);
80 // Check if the attribute can be found by value.
81 assertEquals(e.getAttributeByValue("v" + i).name, "a" + i);
84 // Check is the null value is searched correctly.
85 assertEquals(e.getAttributeByValue(null).toString(), "heading");
87 // Check for unknown attribute
88 assertEquals(e.getAttribute("audrius"), null);
90 // Check for unknown value
91 assertEquals(e.getAttributeByValue("audrius"), null);
94 public void testName2type()
96 assertEquals(Element.name2type("CDATA"), DTDConstants.CDATA);
97 assertEquals(Element.name2type("RCDATA"), DTDConstants.RCDATA);
98 assertEquals(Element.name2type("EMPTY"), DTDConstants.EMPTY);
99 assertEquals(Element.name2type("ANY"), DTDConstants.ANY);
101 assertEquals(Element.name2type("audrius"), 0);
102 assertEquals(Element.name2type("rcdata"), 0);
105 protected void setUp()
106 throws Exception
108 super.setUp();
111 protected void tearDown()
112 throws Exception
114 element = null;
115 super.tearDown();