harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r427121 [20/29] - in /incubator/harmony/enhanced/classlib/trunk/modules/swing: make/ src/main/java/common/javax/swing/ src/main/java/common/javax/swing/text/ src/main/java/common/javax/swing/text/html/ src/main/java/common/javax/swing/text/...
Date Mon, 31 Jul 2006 14:08:55 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLWriterTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLWriterTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLWriterTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,464 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+
+/**
+ * @author Vadim L. Bogdanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import javax.swing.SwingTestCase;
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.Element;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledEditorKit;
+
+public class HTMLWriterTest extends SwingTestCase {
+    private static final String HTML_TEXT = "normal <b>bold</b>";
+
+    private static class TestHTMLDocument extends HTMLDocument {
+        public void callWriteLock() {
+            writeLock();
+        }
+        public void callWriteUnlock() {
+            writeUnlock();
+        }
+    }
+
+    private static class TestHTMLWriter extends HTMLWriter {
+        public TestHTMLWriter(final Writer w, final HTMLDocument doc) {
+            super(w, doc);
+        }
+
+        public TestHTMLWriter(final Writer w, final HTMLDocument doc,
+                              final int pos, final int len) {
+            super(w, doc, pos, len);
+        }
+
+        protected void incrIndent() {
+            super.incrIndent();
+        }
+
+        protected int getIndentLevel() {
+            return super.getIndentLevel();
+        }
+        protected void setLineLength(final int len) {
+            super.setLineLength(len);
+        }
+        protected boolean getCanWrapLines() {
+            return super.getCanWrapLines();
+        }
+        protected int getLineLength() {
+            return super.getLineLength();
+        }
+    }
+
+    private TestHTMLDocument doc;
+    private Element root;
+    private Element body;
+    private StringWriter out;
+    private TestHTMLWriter writer;
+
+    public HTMLWriterTest(final String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        setIgnoreNotImplemented(true);
+
+        createDocument(HTML_TEXT);
+        out = new StringWriter();
+        writer = new TestHTMLWriter(out, doc);
+        writer.setLineSeparator("~");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testWrite() throws Exception {
+        final String content = "<html>\n"
+                             + "  <head>\n"
+                             + "    \n"
+                             + "  </head>\n"
+                             + "  <body>\n"
+                             + "    <p>\n"
+                             + "      Body text. <i>Italic text</i>\n"
+                             + "    </p>\n"
+                             + "    Text outside paragraphs.\n"
+                             + "  </body>\n"
+                             + "</html>\n"
+                             + "<!-- mycomment1 -->\n"
+                             + "<!-- mycomment2 -->\n";
+        createDocument(content);
+        writer = new TestHTMLWriter(out, doc);
+        writer.write();
+        assertEquals(content, out.toString());
+    }
+
+    public void testWriteLineSeparator() throws Exception {
+        doc.putProperty(StyledEditorKit.EndOfLineStringProperty, "`");
+        writer = new TestHTMLWriter(out, doc);
+        writer.writeLineSeparator();
+        assertEquals("`", out.toString());
+
+        writer.setLineSeparator("~");
+        writer.writeLineSeparator();
+        assertEquals("`~", out.toString());
+    }
+
+    public void testOutput() throws Exception {
+        String content = "abc<def";
+        writer.output(content.toCharArray(), 0, content.length());
+        assertEquals(content, out.toString());
+
+        content = "abc&lt;&gt;def";
+        out = new StringWriter();
+        createDocument(content);
+        createWriter();
+        writer.text(body);
+        assertEquals(content, out.toString());
+    }
+
+    public void testHTMLWriterWriterHTMLDocument() {
+        assertEquals(80, writer.getLineLength());
+    }
+
+    public void testHTMLWriterWriterHTMLDocumentIntInt() {
+        assertEquals(80, writer.getLineLength());
+    }
+
+    public void testComment() throws Exception {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        attrs.addAttribute(HTML.Tag.I, HTML.Tag.I);
+        attrs.addAttribute(HTML.Attribute.COMMENT, "comment body");
+
+        doc.callWriteLock();
+        Element elem = doc.createBranchElement(body, attrs);
+        setTag(elem, HTML.Tag.COMMENT);
+        doc.callWriteUnlock();
+
+        writer.incrIndent();
+        writer.writeEmbeddedTags(attrs);
+        writer.comment(elem);
+        assertEquals("<i><!--comment body-->~", out.toString());
+    }
+
+    public void testEmptyTag() throws Exception {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        attrs.addAttribute(HTML.Tag.I, HTML.Tag.I);
+
+        writer.incrIndent();
+        writer.writeEmbeddedTags(attrs);
+        setTag(body, HTML.Tag.CONTENT);
+        writer.emptyTag(body);
+        writer.emptyTag(body);
+        assertEquals("<i>  </i>normal boldnormal bold", out.toString());
+
+        out = new StringWriter();
+        writer = new TestHTMLWriter(out, doc);
+        writer.setLineSeparator("~");
+        writer.incrIndent();
+        writer.writeEmbeddedTags(attrs);
+        setTag(body, HTML.Tag.COMMENT);
+        writer.emptyTag(body);
+        assertEquals("<i>  </i><!---->~", out.toString());
+
+        setTag(body, HTML.Tag.P);
+        out = new StringWriter();
+        writer = new TestHTMLWriter(out, doc);
+        writer.setLineSeparator("~");
+        writer.incrIndent();
+        writer.writeEmbeddedTags(attrs);
+        writer.emptyTag(body);
+        assertEquals("<i>  </i><p>~", out.toString());
+    }
+
+    public void testIsBlockTag() {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        assertFalse(writer.isBlockTag(attrs));
+
+        attrs.addAttribute(StyleConstants.NameAttribute, HTML.Tag.BODY);
+        assertTrue(writer.isBlockTag(attrs));
+
+        attrs.addAttribute(StyleConstants.NameAttribute, HTML.Tag.I);
+        assertFalse(writer.isBlockTag(attrs));
+    }
+
+    public void testMatchNameAttribute() {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        assertFalse(writer.matchNameAttribute(attrs, null));
+        assertFalse(writer.matchNameAttribute(attrs, HTML.Tag.BODY));
+
+        attrs.addAttribute(StyleConstants.NameAttribute, HTML.Tag.I);
+        assertTrue(writer.matchNameAttribute(attrs, HTML.Tag.I));
+        assertFalse(writer.matchNameAttribute(attrs, HTML.Tag.BODY));
+        assertFalse(writer.matchNameAttribute(attrs, null));
+    }
+
+    public void testStartTag() throws Exception {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        attrs.addAttribute(HTML.Tag.I, HTML.Tag.I);
+        writer.writeEmbeddedTags(attrs);
+        setTag(body, HTML.Tag.P);
+        writer.incrIndent();
+        writer.startTag(body);
+        assertEquals("<i></i>  <p>~", out.toString());
+
+        out = new StringWriter();
+        writer = new TestHTMLWriter(out, doc);
+        writer.setLineSeparator("~");
+        writer.writeEmbeddedTags(attrs);
+        setTag(body, HTML.Tag.IMPLIED);
+        writer.incrIndent();
+        writer.startTag(body);
+        assertEquals("<i>", out.toString());
+
+        out = new StringWriter();
+        writer = new TestHTMLWriter(out, doc);
+        writer.setLineSeparator("~");
+        writer.writeEmbeddedTags(attrs);
+        setTag(body, HTML.Tag.BODY);
+        writer.incrIndent();
+        writer.setLineLength(5);
+        writer.startTag(body);
+        assertEquals("<i></i>  <head>~~  </head>~  <body>~", out.toString());
+    }
+
+    public void testEndTag() throws Exception {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        attrs.addAttribute(HTML.Tag.I, HTML.Tag.I);
+        writer.writeEmbeddedTags(attrs);
+        writer.incrIndent();
+        writer.endTag(body);
+        assertEquals("<i></i>  </body>~", out.toString());
+
+        out = new StringWriter();
+        writer = new TestHTMLWriter(out, doc);
+        writer.setLineSeparator("~");
+        writer.writeEmbeddedTags(attrs);
+        setTag(body, HTML.Tag.IMPLIED);
+        writer.incrIndent();
+        writer.endTag(body);
+        assertEquals("<i>", out.toString());
+    }
+
+    public void testSynthesizedElement() {
+        assertFalse(writer.synthesizedElement(root));
+
+        setTag(root, HTML.Tag.BODY);
+        assertFalse(writer.synthesizedElement(root));
+
+        setTag(root, HTML.Tag.IMPLIED);
+        assertTrue(writer.synthesizedElement(root));
+    }
+
+    public void testText() throws Exception {
+        String content = "abc&lt;&gt; def";
+        createDocument(content);
+        createWriter();
+        writer.setLineLength(7);
+        writer.incrIndent();
+        writer.text(body);
+        assertEquals("abc&lt;&gt; ~  def", out.toString());
+
+        out = new StringWriter();
+        createWriter();
+
+        writer.setLineLength(7);
+        writer.incrIndent();
+        setTag(body, HTML.Tag.PRE);
+        writer.startTag(body);
+        writer.text(body);
+        assertEquals("  <pre>abc&lt;&gt; def", out.toString());
+    }
+
+    public void testSelectContent() throws Exception {
+        String content = "<select>\n  <option selected>Component1</option>\n"
+                + "  <option>Component2</option>\n</select>";
+        createDocument(content);
+        createWriter();
+        Element elem = doc.getElement(body, StyleConstants.NameAttribute,
+                                      HTML.Tag.SELECT);
+        writer.selectContent(elem.getAttributes());
+        assertEquals("  <option selected>Component1~  <option>Component2~",
+                     out.toString());
+
+        content = "<select multiple>\n  <option selected>Component1</option>\n"
+                + "  <option>Component2</option>\n</select>";
+        createDocument(content);
+        out = new StringWriter();
+        createWriter();
+        elem = doc.getElement(body, StyleConstants.NameAttribute,
+                              HTML.Tag.SELECT);
+        writer.selectContent(elem.getAttributes());
+        assertEquals("  <option selected>Component1~  <option>Component2~",
+                     out.toString());
+
+        if (isHarmony()) {
+            content = "<select>\n  <optgroup label=optgr>\n"
+                    + "    <option selected>Comp1</option>\n"
+                    + "    <option>Comp2</option>\n  </optgroup>\n</select>";
+            createDocument(content);
+            out = new StringWriter();
+            createWriter();
+            elem = doc.getElement(body, StyleConstants.NameAttribute,
+                                  HTML.Tag.SELECT);
+            writer.selectContent(elem.getAttributes());
+            assertEquals("  <optgroup label=\"optgr\">~"
+                         + "    <option selected>Comp1~    <option>Comp2~"
+                         + "  </optgroup>",
+                         out.toString());
+        }
+    }
+
+    public void testTextAreaContent() throws Exception {
+        String content = "<textarea>\n   First line&lt;.\n"
+                + "   Second line.\n   </textarea>";
+        createDocument(content);
+        createWriter();
+
+        Element elem = doc.getElement(body, StyleConstants.NameAttribute,
+                                      HTML.Tag.TEXTAREA);
+        writer.textAreaContent(elem.getAttributes());
+        assertEquals("     First line&lt;.~     Second line.~     ~",
+                     out.toString());
+    }
+
+    public void testWriteAttributes() throws IOException {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        attrs.addAttribute(HTML.Tag.H1, HTML.Tag.H2);
+        attrs.addAttribute(StyleConstants.Bold, StyleConstants.Bold);
+        attrs.addAttribute(HTML.Attribute.ENDTAG, HTML.Attribute.ENDTAG);
+        attrs.addAttribute(HTML.Attribute.COLOR, "red");
+        attrs.addAttribute(CSS.Attribute.MARGIN, new Integer(10));
+
+        writer.writeAttributes(attrs);
+        assertEquals(" style=\"margin: 10\" color=\"red\"", out.toString());
+    }
+
+    public void testWriteEmbeddedTags() throws IOException {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        attrs.addAttribute(HTML.Tag.I, HTML.Tag.B);
+        attrs.addAttribute(HTML.Tag.H1, HTML.Tag.H2);
+
+        writer.writeEmbeddedTags(attrs);
+        writer.writeEmbeddedTags(attrs);
+        assertTrue("<i><h1>".equals(out.toString())
+                   || "<h1><i>".equals(out.toString()));
+    }
+
+    public void testCloseOutUnwantedEmbeddedTags() throws IOException {
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        attrs.addAttribute(HTML.Tag.I, HTML.Tag.B);
+        attrs.addAttribute(HTML.Tag.H1, HTML.Tag.H2);
+        writer.writeEmbeddedTags(attrs);
+
+        SimpleAttributeSet attrs2 = new SimpleAttributeSet();
+        attrs2.addAttribute(HTML.Tag.I, HTML.Tag.B);
+        writer.closeOutUnwantedEmbeddedTags(attrs2);
+        assertTrue("<i><h1></h1>".equals(out.toString())
+                   || "<h1><i></i></h1>".equals(out.toString()));
+
+        out = new StringWriter();
+        createWriter();
+        writer.writeEmbeddedTags(attrs);
+        attrs2.addAttribute(HTML.Tag.H1, HTML.Tag.H2);
+        writer.closeOutUnwantedEmbeddedTags(attrs2);
+        assertTrue("<i><h1>".equals(out.toString())
+                   || "<h1><i>".equals(out.toString()));
+    }
+
+    public void testWriteOption() throws IOException {
+        writer.incrIndent();
+        SimpleAttributeSet attrs = new SimpleAttributeSet();
+        Option option = new Option(attrs);
+        writer.writeOption(option);
+        assertEquals("  <option>~", out.toString());
+
+        out = new StringWriter();
+        createWriter();
+        writer.incrIndent();
+        attrs.addAttribute(HTML.Attribute.SELECTED, Boolean.valueOf(true));
+        option = new Option(attrs);
+        writer.writeOption(option);
+        assertEquals("  <option selected>~", out.toString());
+
+        out = new StringWriter();
+        createWriter();
+        writer.incrIndent();
+        attrs.addAttribute(HTML.Attribute.VALUE, "option_value");
+        option = new Option(attrs);
+        writer.writeOption(option);
+        assertEquals("  <option value=option_value selected>~", out.toString());
+
+        out = new StringWriter();
+        createWriter();
+        attrs.addAttribute(HTML.Attribute.VALUE, "");
+        option = new Option(attrs);
+        option.setLabel("option_label");
+        writer.incrIndent();
+        writer.writeOption(option);
+        assertEquals("  <option value= selected>option_label~",
+                     out.toString());
+    }
+
+    public void testWriteDocumentBase() throws Exception {
+        if (!isHarmony()) {
+            return;
+        }
+
+        String content = "<html><head><base href=\"http://my.site.com/index.html\""
+            + "</head></html>";
+        createDocument(content);
+        createWriter();
+
+        writer.write();
+
+        assertEquals("<html>~  <head>~    <base href=\"http://my.site.com/index.html\">    ~"
+                     + "  </head>~</html>~",
+                     out.toString());
+    }
+
+    private void createDocument(final String content) throws Exception {
+        doc = new TestHTMLDocument();
+        doc.setAsynchronousLoadPriority(-1);  // synchronous loading
+
+        new HTMLEditorKit().read(new StringReader(content), doc, 0);
+
+        root = doc.getDefaultRootElement();
+        body = doc.getElement(root, StyleConstants.NameAttribute, HTML.Tag.BODY);
+    }
+
+    private void createWriter() {
+        writer = new TestHTMLWriter(out, doc);
+        writer.setLineSeparator("~");
+    }
+
+    private void setTag(final Element elem, final HTML.Tag tag) {
+        doc.callWriteLock();
+        ((AbstractDocument.AbstractElement)elem).addAttribute(
+                StyleConstants.NameAttribute, tag);
+        doc.callWriteUnlock();
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_AttributeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_AttributeTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_AttributeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_AttributeTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,428 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import javax.swing.text.html.HTML.Attribute;
+
+import junit.framework.TestCase;
+
+public class HTML_AttributeTest extends TestCase {
+    private Attribute attr;
+
+    public void testACTION() {
+        attr = HTML.Attribute.ACTION;
+        assertEquals("action", attr.toString());
+    }
+
+    public void testALIGN() {
+        attr = HTML.Attribute.ALIGN;
+        assertEquals("align", attr.toString());
+    }
+
+    public void testALINK() {
+        attr = HTML.Attribute.ALINK;
+        assertEquals("alink", attr.toString());
+    }
+
+    public void testALT() {
+        attr = HTML.Attribute.ALT;
+        assertEquals("alt", attr.toString());
+    }
+
+    public void testARCHIVE() {
+        attr = HTML.Attribute.ARCHIVE;
+        assertEquals("archive", attr.toString());
+    }
+
+    public void testBACKGROUND() {
+        attr = HTML.Attribute.BACKGROUND;
+        assertEquals("background", attr.toString());
+    }
+
+    public void testBGCOLOR() {
+        attr = HTML.Attribute.BGCOLOR;
+        assertEquals("bgcolor", attr.toString());
+    }
+
+    public void testBORDER() {
+        attr = HTML.Attribute.BORDER;
+        assertEquals("border", attr.toString());
+    }
+
+    public void testCELLPADDING() {
+        attr = HTML.Attribute.CELLPADDING;
+        assertEquals("cellpadding", attr.toString());
+    }
+
+    public void testCELLSPACING() {
+        attr = HTML.Attribute.CELLSPACING;
+        assertEquals("cellspacing", attr.toString());
+    }
+
+    public void testCHECKED() {
+        attr = HTML.Attribute.CHECKED;
+        assertEquals("checked", attr.toString());
+    }
+
+    public void testCLASS() {
+        attr = HTML.Attribute.CLASS;
+        assertEquals("class", attr.toString());
+    }
+
+    public void testCLASSID() {
+        attr = HTML.Attribute.CLASSID;
+        assertEquals("classid", attr.toString());
+    }
+
+    public void testCLEAR() {
+        attr = HTML.Attribute.CLEAR;
+        assertEquals("clear", attr.toString());
+    }
+
+    public void testCODE() {
+        attr = HTML.Attribute.CODE;
+        assertEquals("code", attr.toString());
+    }
+
+    public void testCODEBASE() {
+        attr = HTML.Attribute.CODEBASE;
+        assertEquals("codebase", attr.toString());
+    }
+
+    public void testCODETYPE() {
+        attr = HTML.Attribute.CODETYPE;
+        assertEquals("codetype", attr.toString());
+    }
+
+    public void testCOLOR() {
+        attr = HTML.Attribute.COLOR;
+        assertEquals("color", attr.toString());
+    }
+
+    public void testCOLS() {
+        attr = HTML.Attribute.COLS;
+        assertEquals("cols", attr.toString());
+    }
+
+    public void testCOLSPAN() {
+        attr = HTML.Attribute.COLSPAN;
+        assertEquals("colspan", attr.toString());
+    }
+
+    public void testCOMMENT() {
+        attr = HTML.Attribute.COMMENT;
+        assertEquals("comment", attr.toString());
+    }
+
+    public void testCOMPACT() {
+        attr = HTML.Attribute.COMPACT;
+        assertEquals("compact", attr.toString());
+    }
+
+    public void testCONTENT() {
+        attr = HTML.Attribute.CONTENT;
+        assertEquals("content", attr.toString());
+    }
+
+    public void testCOORDS() {
+        attr = HTML.Attribute.COORDS;
+        assertEquals("coords", attr.toString());
+    }
+
+    public void testDATA() {
+        attr = HTML.Attribute.DATA;
+        assertEquals("data", attr.toString());
+    }
+
+    public void testDECLARE() {
+        attr = HTML.Attribute.DECLARE;
+        assertEquals("declare", attr.toString());
+    }
+
+    public void testDIR() {
+        attr = HTML.Attribute.DIR;
+        assertEquals("dir", attr.toString());
+    }
+
+    public void testDUMMY() {
+        attr = HTML.Attribute.DUMMY;
+        assertEquals("dummy", attr.toString());
+    }
+
+    public void testENCTYPE() {
+        attr = HTML.Attribute.ENCTYPE;
+        assertEquals("enctype", attr.toString());
+    }
+
+    public void testENDTAG() {
+        attr = HTML.Attribute.ENDTAG;
+        assertEquals("endtag", attr.toString());
+    }
+
+    public void testFACE() {
+        attr = HTML.Attribute.FACE;
+        assertEquals("face", attr.toString());
+    }
+
+    public void testFRAMEBORDER() {
+        attr = HTML.Attribute.FRAMEBORDER;
+        assertEquals("frameborder", attr.toString());
+    }
+
+    public void testHALIGN() {
+        attr = HTML.Attribute.HALIGN;
+        assertEquals("halign", attr.toString());
+    }
+
+    public void testHEIGHT() {
+        attr = HTML.Attribute.HEIGHT;
+        assertEquals("height", attr.toString());
+    }
+
+    public void testHREF() {
+        attr = HTML.Attribute.HREF;
+        assertEquals("href", attr.toString());
+    }
+
+    public void testHSPACE() {
+        attr = HTML.Attribute.HSPACE;
+        assertEquals("hspace", attr.toString());
+    }
+
+    public void testHTTPEQUIV() {
+        attr = HTML.Attribute.HTTPEQUIV;
+        assertEquals("http-equiv", attr.toString());
+    }
+
+    public void testID() {
+        attr = HTML.Attribute.ID;
+        assertEquals("id", attr.toString());
+    }
+
+    public void testISMAP() {
+        attr = HTML.Attribute.ISMAP;
+        assertEquals("ismap", attr.toString());
+    }
+
+    public void testLANG() {
+        attr = HTML.Attribute.LANG;
+        assertEquals("lang", attr.toString());
+    }
+
+    public void testLANGUAGE() {
+        attr = HTML.Attribute.LANGUAGE;
+        assertEquals("language", attr.toString());
+    }
+
+    public void testLINK() {
+        attr = HTML.Attribute.LINK;
+        assertEquals("link", attr.toString());
+    }
+
+    public void testLOWSRC() {
+        attr = HTML.Attribute.LOWSRC;
+        assertEquals("lowsrc", attr.toString());
+    }
+
+    public void testMARGINHEIGHT() {
+        attr = HTML.Attribute.MARGINHEIGHT;
+        assertEquals("marginheight", attr.toString());
+    }
+
+    public void testMARGINWIDTH() {
+        attr = HTML.Attribute.MARGINWIDTH;
+        assertEquals("marginwidth", attr.toString());
+    }
+
+    public void testMAXLENGTH() {
+        attr = HTML.Attribute.MAXLENGTH;
+        assertEquals("maxlength", attr.toString());
+    }
+
+    public void testMETHOD() {
+        attr = HTML.Attribute.METHOD;
+        assertEquals("method", attr.toString());
+    }
+
+    public void testMULTIPLE() {
+        attr = HTML.Attribute.MULTIPLE;
+        assertEquals("multiple", attr.toString());
+    }
+
+    public void testN() {
+        attr = HTML.Attribute.N;
+        assertEquals("n", attr.toString());
+    }
+
+    public void testNAME() {
+        attr = HTML.Attribute.NAME;
+        assertEquals("name", attr.toString());
+    }
+
+    public void testNOHREF() {
+        attr = HTML.Attribute.NOHREF;
+        assertEquals("nohref", attr.toString());
+    }
+
+    public void testNORESIZE() {
+        attr = HTML.Attribute.NORESIZE;
+        assertEquals("noresize", attr.toString());
+    }
+
+    public void testNOSHADE() {
+        attr = HTML.Attribute.NOSHADE;
+        assertEquals("noshade", attr.toString());
+    }
+
+    public void testNOWRAP() {
+        attr = HTML.Attribute.NOWRAP;
+        assertEquals("nowrap", attr.toString());
+    }
+
+    public void testPROMPT() {
+        attr = HTML.Attribute.PROMPT;
+        assertEquals("prompt", attr.toString());
+    }
+
+    public void testREL() {
+        attr = HTML.Attribute.REL;
+        assertEquals("rel", attr.toString());
+    }
+
+    public void testREV() {
+        attr = HTML.Attribute.REV;
+        assertEquals("rev", attr.toString());
+    }
+
+    public void testROWS() {
+        attr = HTML.Attribute.ROWS;
+        assertEquals("rows", attr.toString());
+    }
+
+    public void testROWSPAN() {
+        attr = HTML.Attribute.ROWSPAN;
+        assertEquals("rowspan", attr.toString());
+    }
+
+    public void testSCROLLING() {
+        attr = HTML.Attribute.SCROLLING;
+        assertEquals("scrolling", attr.toString());
+    }
+
+    public void testSELECTED() {
+        attr = HTML.Attribute.SELECTED;
+        assertEquals("selected", attr.toString());
+    }
+
+    public void testSHAPE() {
+        attr = HTML.Attribute.SHAPE;
+        assertEquals("shape", attr.toString());
+    }
+
+    public void testSHAPES() {
+        attr = HTML.Attribute.SHAPES;
+        assertEquals("shapes", attr.toString());
+    }
+
+    public void testSIZE() {
+        attr = HTML.Attribute.SIZE;
+        assertEquals("size", attr.toString());
+    }
+
+    public void testSRC() {
+        attr = HTML.Attribute.SRC;
+        assertEquals("src", attr.toString());
+    }
+
+    public void testSTANDBY() {
+        attr = HTML.Attribute.STANDBY;
+        assertEquals("standby", attr.toString());
+    }
+
+    public void testSTART() {
+        attr = HTML.Attribute.START;
+        assertEquals("start", attr.toString());
+    }
+
+    public void testSTYLE() {
+        attr = HTML.Attribute.STYLE;
+        assertEquals("style", attr.toString());
+    }
+
+    public void testTARGET() {
+        attr = HTML.Attribute.TARGET;
+        assertEquals("target", attr.toString());
+    }
+
+    public void testTEXT() {
+        attr = HTML.Attribute.TEXT;
+        assertEquals("text", attr.toString());
+    }
+
+    public void testTITLE() {
+        attr = HTML.Attribute.TITLE;
+        assertEquals("title", attr.toString());
+    }
+
+    public void testTYPE() {
+        attr = HTML.Attribute.TYPE;
+        assertEquals("type", attr.toString());
+    }
+
+    public void testUSEMAP() {
+        attr = HTML.Attribute.USEMAP;
+        assertEquals("usemap", attr.toString());
+    }
+
+    public void testVALIGN() {
+        attr = HTML.Attribute.VALIGN;
+        assertEquals("valign", attr.toString());
+    }
+
+    public void testVALUE() {
+        attr = HTML.Attribute.VALUE;
+        assertEquals("value", attr.toString());
+    }
+
+    public void testVALUETYPE() {
+        attr = HTML.Attribute.VALUETYPE;
+        assertEquals("valuetype", attr.toString());
+    }
+
+    public void testVERSION() {
+        attr = HTML.Attribute.VERSION;
+        assertEquals("version", attr.toString());
+    }
+
+    public void testVLINK() {
+        attr = HTML.Attribute.VLINK;
+        assertEquals("vlink", attr.toString());
+    }
+
+    public void testVSPACE() {
+        attr = HTML.Attribute.VSPACE;
+        assertEquals("vspace", attr.toString());
+    }
+
+    public void testWIDTH() {
+        attr = HTML.Attribute.WIDTH;
+        assertEquals("width", attr.toString());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_TagTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_TagTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_TagTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_TagTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,891 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.text.html.HTML.Tag;
+
+import junit.framework.TestCase;
+
+public class HTML_TagTest extends TestCase {
+    private Tag tag;
+
+    public void testTag() {
+        tag = new Tag();
+        assertNull(tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testTagString() {
+        final String tagName = "newTag";
+        tag = new Tag(tagName);
+        assertEquals("newTag", tag.toString());
+        assertSame(tagName, tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testTagStringboolbool() {
+        tag = new Tag("tag1", true, false);
+        assertSame("tag1", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+
+        tag = new Tag("tag2", false, true);
+        assertSame("tag2", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testIsPreformatted() throws Exception {
+        tag = new Tag("pre", false, false);
+        assertNotSame(Tag.PRE, tag);
+        assertEquals(Tag.PRE.toString(), tag.toString());
+        assertFalse("isPre", tag.isPreformatted());
+
+        tag = new Tag("textarea", false, false);
+        assertNotSame(Tag.TEXTAREA, tag);
+        assertEquals(Tag.TEXTAREA.toString(), tag.toString());
+        assertFalse("isPre", tag.isPreformatted());
+
+        tag = new Tag("verb", true, false) {
+            public boolean isPreformatted() {
+                return true;
+            }
+        };
+        assertEquals("verb", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertTrue("isPre", tag.isPreformatted());
+    }
+
+    public void testA() {
+        tag = HTML.Tag.A;
+        assertEquals("a", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testADDRESS() {
+        tag = HTML.Tag.ADDRESS;
+        assertEquals("address", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testAPPLET() {
+        tag = HTML.Tag.APPLET;
+        assertEquals("applet", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testAREA() {
+        tag = HTML.Tag.AREA;
+        assertEquals("area", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testB() {
+        tag = HTML.Tag.B;
+        assertEquals("b", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testBASE() {
+        tag = HTML.Tag.BASE;
+        assertEquals("base", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testBASEFONT() {
+        tag = HTML.Tag.BASEFONT;
+        assertEquals("basefont", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testBIG() {
+        tag = HTML.Tag.BIG;
+        assertEquals("big", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testBLOCKQUOTE() {
+        tag = HTML.Tag.BLOCKQUOTE;
+        assertEquals("blockquote", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testBODY() {
+        tag = HTML.Tag.BODY;
+        assertEquals("body", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testBR() {
+        tag = HTML.Tag.BR;
+        assertEquals("br", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testCAPTION() {
+        tag = HTML.Tag.CAPTION;
+        assertEquals("caption", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testCENTER() {
+        tag = HTML.Tag.CENTER;
+        assertEquals("center", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testCITE() {
+        tag = HTML.Tag.CITE;
+        assertEquals("cite", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testCODE() {
+        tag = HTML.Tag.CODE;
+        assertEquals("code", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testCOMMENT() {
+        tag = HTML.Tag.COMMENT;
+        assertEquals("comment", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testCONTENT() {
+        tag = HTML.Tag.CONTENT;
+        assertEquals("content", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testDD() {
+        tag = HTML.Tag.DD;
+        assertEquals("dd", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testDFN() {
+        tag = HTML.Tag.DFN;
+        assertEquals("dfn", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testDIR() {
+        tag = HTML.Tag.DIR;
+        assertEquals("dir", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testDIV() {
+        tag = HTML.Tag.DIV;
+        assertEquals("div", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testDL() {
+        tag = HTML.Tag.DL;
+        assertEquals("dl", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testDT() {
+        tag = HTML.Tag.DT;
+        assertEquals("dt", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testEM() {
+        tag = HTML.Tag.EM;
+        assertEquals("em", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testFONT() {
+        tag = HTML.Tag.FONT;
+        assertEquals("font", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testFORM() {
+        tag = HTML.Tag.FORM;
+        assertEquals("form", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testFRAME() {
+        tag = HTML.Tag.FRAME;
+        assertEquals("frame", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testFRAMESET() {
+        tag = HTML.Tag.FRAMESET;
+        assertEquals("frameset", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testH1() {
+        tag = HTML.Tag.H1;
+        assertEquals("h1", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testH2() {
+        tag = HTML.Tag.H2;
+        assertEquals("h2", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testH3() {
+        tag = HTML.Tag.H3;
+        assertEquals("h3", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testH4() {
+        tag = HTML.Tag.H4;
+        assertEquals("h4", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testH5() {
+        tag = HTML.Tag.H5;
+        assertEquals("h5", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testH6() {
+        tag = HTML.Tag.H6;
+        assertEquals("h6", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testHEAD() {
+        tag = HTML.Tag.HEAD;
+        assertEquals("head", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testHR() {
+        tag = HTML.Tag.HR;
+        assertEquals("hr", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testHTML() {
+        tag = HTML.Tag.HTML;
+        assertEquals("html", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testI() {
+        tag = HTML.Tag.I;
+        assertEquals("i", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testIMG() {
+        tag = HTML.Tag.IMG;
+        assertEquals("img", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testIMPLIED() {
+        tag = HTML.Tag.IMPLIED;
+        assertEquals("p-implied", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testINPUT() {
+        tag = HTML.Tag.INPUT;
+        assertEquals("input", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testISINDEX() {
+        tag = HTML.Tag.ISINDEX;
+        assertEquals("isindex", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testKBD() {
+        tag = HTML.Tag.KBD;
+        assertEquals("kbd", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testLI() {
+        tag = HTML.Tag.LI;
+        assertEquals("li", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testLINK() {
+        tag = HTML.Tag.LINK;
+        assertEquals("link", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testMAP() {
+        tag = HTML.Tag.MAP;
+        assertEquals("map", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testMENU() {
+        tag = HTML.Tag.MENU;
+        assertEquals("menu", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testMETA() {
+        tag = HTML.Tag.META;
+        assertEquals("meta", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testNOFRAMES() {
+        tag = HTML.Tag.NOFRAMES;
+        assertEquals("noframes", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testOBJECT() {
+        tag = HTML.Tag.OBJECT;
+        assertEquals("object", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testOL() {
+        tag = HTML.Tag.OL;
+        assertEquals("ol", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testOPTION() {
+        tag = HTML.Tag.OPTION;
+        assertEquals("option", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testP() {
+        tag = HTML.Tag.P;
+        assertEquals("p", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testPARAM() {
+        tag = HTML.Tag.PARAM;
+        assertEquals("param", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testPRE() {
+        tag = HTML.Tag.PRE;
+        assertEquals("pre", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertTrue("isPre", tag.isPreformatted());
+    }
+
+    public void testS() {
+        tag = HTML.Tag.S;
+        assertEquals("s", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSAMP() {
+        tag = HTML.Tag.SAMP;
+        assertEquals("samp", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSCRIPT() {
+        tag = HTML.Tag.SCRIPT;
+        assertEquals("script", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSELECT() {
+        tag = HTML.Tag.SELECT;
+        assertEquals("select", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSMALL() {
+        tag = HTML.Tag.SMALL;
+        assertEquals("small", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSPAN() {
+        tag = HTML.Tag.SPAN;
+        assertEquals("span", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSTRIKE() {
+        tag = HTML.Tag.STRIKE;
+        assertEquals("strike", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSTRONG() {
+        tag = HTML.Tag.STRONG;
+        assertEquals("strong", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSTYLE() {
+        tag = HTML.Tag.STYLE;
+        assertEquals("style", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSUB() {
+        tag = HTML.Tag.SUB;
+        assertEquals("sub", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testSUP() {
+        tag = HTML.Tag.SUP;
+        assertEquals("sup", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testTABLE() {
+        tag = HTML.Tag.TABLE;
+        assertEquals("table", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testTD() {
+        tag = HTML.Tag.TD;
+        assertEquals("td", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testTEXTAREA() {
+        tag = HTML.Tag.TEXTAREA;
+        assertEquals("textarea", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertTrue("isPre", tag.isPreformatted());
+    }
+
+    public void testTH() {
+        tag = HTML.Tag.TH;
+        assertEquals("th", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testTITLE() {
+        tag = HTML.Tag.TITLE;
+        assertEquals("title", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testTR() {
+        tag = HTML.Tag.TR;
+        assertEquals("tr", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testTT() {
+        tag = HTML.Tag.TT;
+        assertEquals("tt", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testU() {
+        tag = HTML.Tag.U;
+        assertEquals("u", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testUL() {
+        tag = HTML.Tag.UL;
+        assertEquals("ul", tag.toString());
+        assertTrue("breaks Flow", tag.breaksFlow());
+        assertTrue("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testVAR() {
+        tag = HTML.Tag.VAR;
+        assertEquals("var", tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    // Tags for HTML 4.0
+
+    public void testABBR() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.ABBR;
+        assertEquals("abbr", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testACRONYM() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.ACRONYM;
+        assertEquals("acronym", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testBDO() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.BDO;
+        assertEquals("bdo", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testBUTTON() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.BUTTON;
+        assertEquals("button", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testCOL() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.COL;
+        assertEquals("col", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testCOLGROUP() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.COLGROUP;
+        assertEquals("colgroup", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testDEL() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.DEL;
+        assertEquals("del", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testFIELDSET() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.FIELDSET;
+        assertEquals("fieldset", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testIFRAME() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.IFRAME;
+        assertEquals("iframe", tag.toString());
+        assertTrue(tag.breaksFlow());
+        assertTrue(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testINS() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.INS;
+        assertEquals("ins", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testLABEL() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.LABEL;
+        assertEquals("label", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testLEGEND() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.LEGEND;
+        assertEquals("legend", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testNOSCRIPT() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.NOSCRIPT;
+        assertEquals("noscript", tag.toString());
+        assertTrue(tag.breaksFlow());
+        assertTrue(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testOPTGROUP() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.OPTGROUP;
+        assertEquals("optgroup", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testQ() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.Q;
+        assertEquals("q", tag.toString());
+        assertFalse(tag.breaksFlow());
+        assertFalse(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testTBODY() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.TBODY;
+        assertEquals("tbody", tag.toString());
+        assertTrue(tag.breaksFlow());
+        assertTrue(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testTFOOT() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.TFOOT;
+        assertEquals("tfoot", tag.toString());
+        assertTrue(tag.breaksFlow());
+        assertTrue(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+
+    public void testTHEAD() {
+        if (!BasicSwingTestCase.isHarmony()) {
+            return;
+        }
+        tag = HTML.Tag.THEAD;
+        assertEquals("thead", tag.toString());
+        assertTrue(tag.breaksFlow());
+        assertTrue(tag.isBlock());
+        assertFalse(tag.isPreformatted());
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_UnknownTagTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_UnknownTagTest.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_UnknownTagTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTML_UnknownTagTest.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,95 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+/**
+ * @author Alexey A. Ivanov
+ * @version $Revision$
+ */
+package javax.swing.text.html;
+
+import javax.swing.BasicSwingTestCase;
+import javax.swing.text.html.HTML.Tag;
+import javax.swing.text.html.HTML.UnknownTag;
+
+public class HTML_UnknownTagTest extends BasicSwingTestCase {
+    private static final String tagName = "verb";
+    private Tag tag;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        tag = new UnknownTag(tagName);
+    }
+
+    public void testUnknownTag() {
+        assertSame(tagName, tag.toString());
+        assertFalse("breaks Flow", tag.breaksFlow());
+        assertFalse("isBlock", tag.isBlock());
+        assertFalse("isPre", tag.isPreformatted());
+    }
+
+    public void testEqualsObject() {
+        Tag other = new UnknownTag(new String(tagName));
+        assertNotSame(tag.toString(), other.toString());
+        assertEquals(tag.toString(), other.toString());
+        assertTrue(other.equals(tag));
+        assertFalse(other.equals(tagName));
+        assertFalse(other.equals(Tag.A));
+        assertFalse(tag.equals(Tag.A));
+
+        other = new UnknownTag(Tag.A.toString());
+        assertSame(Tag.A.toString(), other.toString());
+        assertFalse(other.equals(Tag.A));
+
+        other = new UnknownTag("author");
+        assertFalse(tag.equals(other));
+    }
+
+    public void testHashCode() {
+        Tag other = new UnknownTag(new String(tagName));
+        assertNotSame(tag.toString(), other.toString());
+        assertEquals(tag.toString(), other.toString());
+        assertEquals(tagName.hashCode(), tag.hashCode());
+        assertEquals(other.hashCode(), tag.hashCode());
+
+        other = new UnknownTag("author");
+        assertFalse(other.hashCode() == tag.hashCode());
+    }
+
+    public void testNull() {
+        tag = new UnknownTag(null);
+        assertNull(tag.toString());
+
+        Tag other = new UnknownTag(null);
+        try {
+            assertTrue(tag.equals(other));
+            fail("NPE expected");
+        } catch (NullPointerException e) { }
+
+        try {
+            assertEquals(0, tag.hashCode());
+            fail("NPE expected");
+        } catch (NullPointerException e) { }
+    }
+
+    public void testSerializable() throws Exception {
+        Tag readTag = (Tag)serializeObject(tag);
+        assertTrue(readTag instanceof UnknownTag);
+        assertEquals(tagName, readTag.toString());
+        assertTrue(tag.equals(readTag));
+        assertFalse(readTag.breaksFlow());
+        assertFalse(readTag.isBlock());
+        assertFalse(readTag.isPreformatted());
+    }
+}



Mime
View raw message