harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r479418 [27/43] - in /harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common: javax/swing/ javax/swing/border/ javax/swing/colorchooser/ javax/swing/event/ javax/swing/filechooser/ javax/swing/plaf/ javax/swing/plaf/basic/ j...
Date Sun, 26 Nov 2006 20:15:55 GMT
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_Specs2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_Specs2Test.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_Specs2Test.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_Specs2Test.java Sun Nov 26 12:15:43 2006
@@ -22,13 +22,11 @@
 
 import java.util.List;
 import java.util.Vector;
-
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.text.AbstractDocument.DefaultDocumentEvent;
 import javax.swing.text.DefaultStyledDocument.ElementBuffer;
 import javax.swing.text.DefaultStyledDocument.ElementSpec;
-
 import junit.framework.TestCase;
 
 /**
@@ -78,31 +76,39 @@
  * <p>Each test-case region currently contains four tests.
  *
  */
-public class DefaultStyledDocument_ElementBuffer_Specs2Test extends TestCase
-    implements DocumentListener {
+public class DefaultStyledDocument_ElementBuffer_Specs2Test extends TestCase implements
+        DocumentListener {
+    private DefaultStyledDocument doc;
+
+    private Element root;
+
+    private ElementBuffer buf;
+
+    private ElementSpec[] specs;
+
+    private Element modified;
 
-    private DefaultStyledDocument     doc;
-    private Element                   root;
-    private ElementBuffer             buf;
-    private ElementSpec[]             specs;
-
-    private Element                   modified;
-    private static final int          modifiedIndex = 1;
-    private int                       insertOffset;
+    private static final int modifiedIndex = 1;
 
-    private DefaultDocumentEvent      insertEvent;
+    private int insertOffset;
+
+    private DefaultDocumentEvent insertEvent;
 
     private static final AttributeSet bold = DefStyledDoc_Helpers.bold;
+
     private static final AttributeSet italic = DefStyledDoc_Helpers.italic;
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
         root = doc.getDefaultRootElement();
-        buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc,
-                                                                root) {
+        buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             public void insert(int offset, int length, ElementSpec[] spec,
-                               DefaultDocumentEvent event) {
+                    DefaultDocumentEvent event) {
                 super.insert(offset, length, specs = spec, event);
             }
         };
@@ -119,10 +125,8 @@
     public void testInsertString01() throws Exception {
         doc.insertString(insertOffset, "one", null);
         assertEquals(1, getEdits(insertEvent).size());
-
         assertEquals(1, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 3);
     }
 
     /**
@@ -130,18 +134,14 @@
      */
     public void testInsertString02() throws Exception {
         doc.insertString(insertOffset, "one\n", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(3, edits.size());
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 1);
         assertChange(edits.get(2), root, 0, 1);
-
         assertEquals(3, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
     }
 
     /**
@@ -149,22 +149,17 @@
      */
     public void testInsertString03() throws Exception {
         doc.insertString(insertOffset, "\none", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 1);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 1, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 1);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.JoinNextDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 1);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.JoinNextDirection, 0, 3);
     }
 
     /**
@@ -172,25 +167,19 @@
      */
     public void testInsertString04() throws Exception {
         doc.insertString(insertOffset, "one\ntwo", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 1);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 1, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.JoinNextDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.JoinNextDirection, 0, 3);
     }
 
-//---------------------------------------------------------------------------
-
+    //---------------------------------------------------------------------------
     /**
      * Bold attribute on paragraph, text 'one' with no attributes, doc is empty.
      */
@@ -198,13 +187,10 @@
         doc.setParagraphAttributes(insertOffset, 1, bold, false);
         doc.insertString(insertOffset, "one", null);
         assertEquals(1, getEdits(insertEvent).size());
-
         assertSame(modified, root.getElement(modifiedIndex));
         assertTrue(modified.getAttributes().containsAttributes(bold));
-
         assertEquals(1, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 3);
     }
 
     /**
@@ -214,23 +200,16 @@
     public void testInsertString12() throws Exception {
         doc.setParagraphAttributes(insertOffset, 1, bold, false);
         doc.insertString(insertOffset, "one\n", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(3, edits.size());
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 1);
         assertChange(edits.get(2), root, 0, 1);
-
-        assertTrue(root.getElement(modifiedIndex).getAttributes()
-                   .containsAttributes(bold));
-        assertTrue(root.getElement(modifiedIndex + 1).getAttributes()
-                   .containsAttributes(bold));
-
+        assertTrue(root.getElement(modifiedIndex).getAttributes().containsAttributes(bold));
+        assertTrue(root.getElement(modifiedIndex + 1).getAttributes().containsAttributes(bold));
         assertEquals(3, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
     }
 
     /**
@@ -240,26 +219,18 @@
     public void testInsertString13() throws Exception {
         doc.setParagraphAttributes(insertOffset, 1, bold, false);
         doc.insertString(insertOffset, "\none", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 1);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 1, 1);
         assertChange(edits.get(3), root, 0, 1);
-
-        assertTrue(root.getElement(modifiedIndex).getAttributes()
-                   .containsAttributes(bold));
-        assertTrue(root.getElement(modifiedIndex + 1).getAttributes()
-                   .containsAttributes(bold));
-
+        assertTrue(root.getElement(modifiedIndex).getAttributes().containsAttributes(bold));
+        assertTrue(root.getElement(modifiedIndex + 1).getAttributes().containsAttributes(bold));
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 1);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.JoinNextDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 1);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.JoinNextDirection, 0, 3);
     }
 
     /**
@@ -269,58 +240,41 @@
     public void testInsertString14() throws Exception {
         doc.setParagraphAttributes(insertOffset, 1, bold, false);
         doc.insertString(insertOffset, "one\ntwo", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 1);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 1, 1);
         assertChange(edits.get(3), root, 0, 1);
-
-        assertTrue(root.getElement(modifiedIndex).getAttributes()
-                   .containsAttributes(bold));
-        assertTrue(root.getElement(modifiedIndex + 1).getAttributes()
-                   .containsAttributes(bold));
-
-        assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.JoinNextDirection, 0, 3);
+        assertTrue(root.getElement(modifiedIndex).getAttributes().containsAttributes(bold));
+        assertTrue(root.getElement(modifiedIndex + 1).getAttributes().containsAttributes(bold));
+        assertEquals(4, specs.length);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.JoinNextDirection, 0, 3);
     }
 
-//---------------------------------------------------------------------------
-
+    //---------------------------------------------------------------------------
     /**
      * Bold attribute on character, text 'one' with no attributes, doc is empty.
      */
     public void testInsertString21() throws Exception {
-        doc.setCharacterAttributes(modified.getStartOffset(),
-                                   modified.getEndOffset()
-                                   - modified.getStartOffset(), bold, false);
+        doc.setCharacterAttributes(modified.getStartOffset(), modified.getEndOffset()
+                - modified.getStartOffset(), bold, false);
         doc.insertString(insertOffset, "one", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(2, edits.size());
-
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 3);
-
         assertEquals(3, modified.getElementCount());
-
         Element charElem = modified.getElement(0);
         assertTrue(charElem.getAttributes().isEqual(bold));
-
         charElem = modified.getElement(1);
         assertEquals(0, charElem.getAttributes().getAttributeCount());
-
         charElem = modified.getElement(2);
         assertTrue(charElem.getAttributes().isEqual(bold));
-
         assertEquals(1, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
@@ -328,43 +282,34 @@
      * empty.
      */
     public void testInsertString22() throws Exception {
-        doc.setCharacterAttributes(modified.getStartOffset(),
-                                   modified.getEndOffset()
-                                   - modified.getStartOffset(), bold, false);
+        doc.setCharacterAttributes(modified.getStartOffset(), modified.getEndOffset()
+                - modified.getStartOffset(), bold, false);
         doc.insertString(insertOffset, "one\n", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(3, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root, 0, 1);
-
         final Element mutated = root.getElement(modifiedIndex);
         assertEquals(2, mutated.getElementCount());
         Element charElem = mutated.getElement(0);
         assertTrue(charElem.getAttributes().isEqual(bold));
         assertEquals(insertOffset - 2, charElem.getStartOffset());
         assertEquals(insertOffset, charElem.getEndOffset());
-
         charElem = mutated.getElement(1);
         assertEquals(0, charElem.getAttributes().getAttributeCount());
         assertEquals(insertOffset, charElem.getStartOffset());
         assertEquals(insertOffset + 4, charElem.getEndOffset());
-
         final Element next = root.getElement(modifiedIndex + 1);
         assertEquals(1, next.getElementCount());
-
         charElem = next.getElement(0);
         assertTrue(charElem.getAttributes().isEqual(bold));
         assertEquals(insertOffset + 4, charElem.getStartOffset());
         assertEquals(insertOffset + 4 + 5, charElem.getEndOffset());
-
         assertEquals(3, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
     }
 
     /**
@@ -372,38 +317,29 @@
      * empty.
      */
     public void testInsertString23() throws Exception {
-        doc.setCharacterAttributes(modified.getStartOffset(),
-                                   modified.getEndOffset()
-                                   - modified.getStartOffset(), bold, false);
+        doc.setCharacterAttributes(modified.getStartOffset(), modified.getEndOffset()
+                - modified.getStartOffset(), bold, false);
         doc.insertString(insertOffset, "\none", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(2, modified.getElementCount());
         assertTrue(modified.getElement(0).getAttributes().isEqual(bold));
         final Element charElem = modified.getElement(1);
         assertEquals(0, charElem.getAttributes().getAttributeCount());
         assertEquals(1, charElem.getEndOffset() - charElem.getStartOffset());
-
         final Element newPar = root.getElement(modifiedIndex + 1);
         assertEquals(2, newPar.getElementCount());
-        assertEquals(0,
-                     newPar.getElement(0).getAttributes().getAttributeCount());
+        assertEquals(0, newPar.getElement(0).getAttributes().getAttributeCount());
         assertTrue(newPar.getElement(1).getAttributes().isEqual(bold));
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 1);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 1);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
@@ -411,53 +347,41 @@
      * empty.
      */
     public void testInsertString24() throws Exception {
-        doc.setCharacterAttributes(modified.getStartOffset(),
-                                   modified.getEndOffset()
-                                   - modified.getStartOffset(), bold, false);
+        doc.setCharacterAttributes(modified.getStartOffset(), modified.getEndOffset()
+                - modified.getStartOffset(), bold, false);
         doc.insertString(insertOffset, "one\ntwo", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(2, modified.getElementCount());
         assertEquals(2, root.getElement(modifiedIndex + 1).getElementCount());
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
-//===========================================================================
-
+    //===========================================================================
     /**
      * No attributes, text 'one' with italic, doc is empty.
      */
     public void testInsertString31() throws Exception {
         doc.insertString(insertOffset, "one", italic);
-
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(2, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 3);
-
         assertEquals(3, modified.getElementCount());
         final Element e = modified;
         assertEquals(0, e.getElement(0).getAttributes().getAttributeCount());
         assertTrue(e.getElement(1).getAttributes().isEqual(italic));
         assertEquals(0, e.getElement(2).getAttributes().getAttributeCount());
-
         assertEquals(1, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
@@ -465,39 +389,31 @@
      */
     public void testInsertString32() throws Exception {
         doc.insertString(insertOffset, "one\n", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(3, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root, 0, 1);
-
         final Element mutated = root.getElement(modifiedIndex);
         assertEquals(2, mutated.getElementCount());
         Element charElem = mutated.getElement(0);
         assertEquals(0, charElem.getAttributes().getAttributeCount());
         assertEquals(insertOffset - 2, charElem.getStartOffset());
         assertEquals(insertOffset, charElem.getEndOffset());
-
         charElem = mutated.getElement(1);
         assertTrue(charElem.getAttributes().isEqual(italic));
         assertEquals(insertOffset, charElem.getStartOffset());
         assertEquals(insertOffset + 4, charElem.getEndOffset());
-
         final Element next = root.getElement(modifiedIndex + 1);
         assertEquals(1, next.getElementCount());
-
         charElem = next.getElement(0);
         assertEquals(0, charElem.getAttributes().getAttributeCount());
         assertEquals(insertOffset + 4, charElem.getStartOffset());
         assertEquals(insertOffset + 4 + 5, charElem.getEndOffset());
-
         assertEquals(3, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
     }
 
     /**
@@ -505,35 +421,26 @@
      */
     public void testInsertString33() throws Exception {
         doc.insertString(insertOffset, "\none", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(2, modified.getElementCount());
-        assertEquals(0, modified.getElement(0).getAttributes()
-                        .getAttributeCount());
+        assertEquals(0, modified.getElement(0).getAttributes().getAttributeCount());
         final Element charElem = modified.getElement(1);
         assertTrue(charElem.getAttributes().isEqual(italic));
         assertEquals(1, charElem.getEndOffset() - charElem.getStartOffset());
-
         final Element newPar = root.getElement(modifiedIndex + 1);
         assertEquals(2, newPar.getElementCount());
         assertTrue(newPar.getElement(0).getAttributes().isEqual(italic));
-        assertEquals(0, newPar.getElement(1).getAttributes()
-                        .getAttributeCount());
-
+        assertEquals(0, newPar.getElement(1).getAttributes().getAttributeCount());
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 1);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 1);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
@@ -541,53 +448,39 @@
      */
     public void testInsertString34() throws Exception {
         doc.insertString(insertOffset, "one\ntwo", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(2, modified.getElementCount());
         assertEquals(2, root.getElement(modifiedIndex + 1).getElementCount());
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
-//---------------------------------------------------------------------------
-
+    //---------------------------------------------------------------------------
     /**
      * Bold attribute on paragraph, text 'one' with italic, doc is empty.
      */
     public void testInsertString41() throws Exception {
         doc.setParagraphAttributes(insertOffset, 1, bold, false);
         doc.insertString(insertOffset, "one", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(2, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 3);
-
-        assertTrue(root.getElement(modifiedIndex).getAttributes()
-                   .containsAttributes(bold));
+        assertTrue(root.getElement(modifiedIndex).getAttributes().containsAttributes(bold));
         assertEquals(3, modified.getElementCount());
-
-        assertEquals(0, modified.getElement(0).getAttributes()
-                        .getAttributeCount());
+        assertEquals(0, modified.getElement(0).getAttributes().getAttributeCount());
         assertTrue(modified.getElement(1).getAttributes().isEqual(italic));
-        assertEquals(0, modified.getElement(2).getAttributes()
-                        .getAttributeCount());
-
+        assertEquals(0, modified.getElement(2).getAttributes().getAttributeCount());
         assertEquals(1, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
@@ -596,27 +489,19 @@
     public void testInsertString42() throws Exception {
         doc.setParagraphAttributes(insertOffset, 1, bold, false);
         doc.insertString(insertOffset, "one\n", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(3, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root, 0, 1);
-
-        assertTrue(root.getElement(modifiedIndex).getAttributes()
-                   .containsAttributes(bold));
-        assertTrue(root.getElement(modifiedIndex + 1).getAttributes()
-                   .containsAttributes(bold));
-
+        assertTrue(root.getElement(modifiedIndex).getAttributes().containsAttributes(bold));
+        assertTrue(root.getElement(modifiedIndex + 1).getAttributes().containsAttributes(bold));
         assertEquals(2, root.getElement(modifiedIndex).getElementCount());
         assertEquals(1, root.getElement(modifiedIndex + 1).getElementCount());
-
         assertEquals(3, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
     }
 
     /**
@@ -625,34 +510,23 @@
     public void testInsertString43() throws Exception {
         doc.setParagraphAttributes(insertOffset, 1, bold, false);
         doc.insertString(insertOffset, "\none", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
-        assertTrue(root.getElement(modifiedIndex).getAttributes()
-                   .containsAttributes(bold));
-        assertTrue(root.getElement(modifiedIndex + 1).getAttributes()
-                   .containsAttributes(bold));
-
+        assertTrue(root.getElement(modifiedIndex).getAttributes().containsAttributes(bold));
+        assertTrue(root.getElement(modifiedIndex + 1).getAttributes().containsAttributes(bold));
         assertEquals(2, modified.getElementCount());
-        assertEquals(0, modified.getElement(0).getAttributes()
-                        .getAttributeCount());
+        assertEquals(0, modified.getElement(0).getAttributes().getAttributeCount());
         assertTrue(modified.getElement(1).getAttributes().isEqual(italic));
-
         assertEquals(2, root.getElement(modifiedIndex + 1).getElementCount());
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 1);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 1);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
@@ -661,87 +535,65 @@
     public void testInsertString44() throws Exception {
         doc.setParagraphAttributes(insertOffset, 1, bold, false);
         doc.insertString(insertOffset, "one\ntwo", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertSame(modified, root.getElement(modifiedIndex));
         assertEquals(4, edits.size());
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
-        assertTrue(root.getElement(modifiedIndex).getAttributes()
-                   .containsAttributes(bold));
-        assertTrue(root.getElement(modifiedIndex + 1).getAttributes()
-                   .containsAttributes(bold));
-
+        assertTrue(root.getElement(modifiedIndex).getAttributes().containsAttributes(bold));
+        assertTrue(root.getElement(modifiedIndex + 1).getAttributes().containsAttributes(bold));
         assertEquals(2, modified.getElementCount());
         assertEquals(2, root.getElement(modifiedIndex + 1).getElementCount());
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
-//---------------------------------------------------------------------------
-
+    //---------------------------------------------------------------------------
     /**
      * Bold attribute on character, text 'one' with italic, doc is empty.
      */
     public void testInsertString51() throws Exception {
-        doc.setCharacterAttributes(modified.getStartOffset(),
-                                   modified.getEndOffset()
-                                   - modified.getStartOffset(), bold, false);
+        doc.setCharacterAttributes(modified.getStartOffset(), modified.getEndOffset()
+                - modified.getStartOffset(), bold, false);
         doc.insertString(insertOffset, "one", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(2, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 3);
-
         assertEquals(3, modified.getElementCount());
         assertTrue(modified.getElement(0).getAttributes().isEqual(bold));
         assertTrue(modified.getElement(1).getAttributes().isEqual(italic));
         assertTrue(modified.getElement(2).getAttributes().isEqual(bold));
-
         assertEquals(1, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
      * Bold attribute on character, text 'one\n' with italic, doc is empty.
      */
     public void testInsertString52() throws Exception {
-        doc.setCharacterAttributes(modified.getStartOffset(),
-                                   modified.getEndOffset()
-                                   - modified.getStartOffset(), bold, false);
+        doc.setCharacterAttributes(modified.getStartOffset(), modified.getEndOffset()
+                - modified.getStartOffset(), bold, false);
         doc.insertString(insertOffset, "one\n", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(3, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root, 0, 1);
-
         assertEquals(2, modified.getElementCount());
         assertTrue(modified.getElement(0).getAttributes().isEqual(bold));
         assertTrue(modified.getElement(1).getAttributes().isEqual(italic));
-
         final Element newPar = root.getElement(modifiedIndex + 1);
         assertEquals(1, newPar.getElementCount());
         assertTrue(newPar.getElement(0).getAttributes().isEqual(bold));
-
         assertEquals(3, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
         /*
          * While copying elements with fracture, it will copy leaf attributes:
          *
@@ -754,96 +606,76 @@
      * Bold attribute on character, text '\none' with italic, doc is empty.
      */
     public void testInsertString53() throws Exception {
-        doc.setCharacterAttributes(modified.getStartOffset(),
-                                   modified.getEndOffset()
-                                   - modified.getStartOffset(), bold, false);
+        doc.setCharacterAttributes(modified.getStartOffset(), modified.getEndOffset()
+                - modified.getStartOffset(), bold, false);
         doc.insertString(insertOffset, "\none", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(2, modified.getElementCount());
         assertTrue(modified.getElement(0).getAttributes().isEqual(bold));
         assertTrue(modified.getElement(1).getAttributes().isEqual(italic));
-
         assertEquals(2, root.getElement(modifiedIndex + 1).getElementCount());
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 1);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 1);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
      * Bold attribute on character, text 'one\ntwo' with italic, doc is empty.
      */
     public void testInsertString54() throws Exception {
-        doc.setCharacterAttributes(modified.getStartOffset(),
-                                   modified.getEndOffset()
-                                   - modified.getStartOffset(), bold, false);
+        doc.setCharacterAttributes(modified.getStartOffset(), modified.getEndOffset()
+                - modified.getStartOffset(), bold, false);
         doc.insertString(insertOffset, "one\ntwo", italic);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertSame(modified, root.getElement(modifiedIndex));
         assertChange(edits.get(1), root.getElement(modifiedIndex), 1, 2);
         assertChange(edits.get(2), root.getElement(modifiedIndex + 1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(2, modified.getElementCount());
         Element charElem = modified.getElement(0);
         assertTrue(charElem.getAttributes().isEqual(bold));
         assertEquals(insertOffset - 2, charElem.getStartOffset());
         assertEquals(insertOffset, charElem.getEndOffset());
-
         charElem = modified.getElement(1);
         assertTrue(charElem.getAttributes().isEqual(italic));
         assertEquals(insertOffset, charElem.getStartOffset());
         assertEquals(insertOffset + 4, charElem.getEndOffset());
-
         final Element newPar = root.getElement(modifiedIndex + 1);
         assertEquals(2, newPar.getElementCount());
-
         charElem = newPar.getElement(0);
         assertTrue(charElem.getAttributes().isEqual(italic));
         assertEquals(insertOffset + 4, charElem.getStartOffset());
         assertEquals(insertOffset + 4 + 3, charElem.getEndOffset());
-
         charElem = newPar.getElement(1);
         assertTrue(charElem.getAttributes().isEqual(bold));
         assertEquals(insertOffset + 4 + 3, charElem.getStartOffset());
         assertEquals(insertOffset + 4 + 3 + 5, charElem.getEndOffset());
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     private static void assertChange(final Object object, final Element element,
-                                     final int removed, int added) {
+            final int removed, int added) {
         DefStyledDoc_Helpers.assertChange(object, element, removed, added);
     }
 
     private static void assertSpec(final ElementSpec spec, final short type,
-                                   final short direction, final int offset,
-                                   final int length) {
+            final short direction, final int offset, final int length) {
         DefStyledDoc_Helpers.assertSpec(spec, type, direction, offset, length);
     }
 
-    private static Vector getEdits(final DefaultDocumentEvent event) {
+    private static Vector<?> getEdits(final DefaultDocumentEvent event) {
         return DefStyledDoc_Helpers.getEdits(event);
     }
 
@@ -851,7 +683,7 @@
     }
 
     public void insertUpdate(DocumentEvent e) {
-        insertEvent = (DefaultDocumentEvent)e;
+        insertEvent = (DefaultDocumentEvent) e;
     }
 
     public void removeUpdate(DocumentEvent e) {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_Specs3Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_Specs3Test.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_Specs3Test.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_Specs3Test.java Sun Nov 26 12:15:43 2006
@@ -22,14 +22,12 @@
 
 import java.util.List;
 import java.util.Vector;
-
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.event.DocumentEvent.ElementChange;
 import javax.swing.text.AbstractDocument.DefaultDocumentEvent;
 import javax.swing.text.DefaultStyledDocument.ElementBuffer;
 import javax.swing.text.DefaultStyledDocument.ElementSpec;
-
 import junit.framework.TestCase;
 
 /**
@@ -78,27 +76,35 @@
  * <p>Each test-case region currently contains four tests.
  *
  */
-public class DefaultStyledDocument_ElementBuffer_Specs3Test extends TestCase
-    implements DocumentListener {
+public class DefaultStyledDocument_ElementBuffer_Specs3Test extends TestCase implements
+        DocumentListener {
+    private DefaultStyledDocument doc;
+
+    private Element root;
+
+    private ElementBuffer buf;
+
+    private ElementSpec[] specs;
+
+    private Element paragraph;
+
+    private Element leaf;
 
-    private DefaultStyledDocument     doc;
-    private Element                   root;
-    private ElementBuffer             buf;
-    private ElementSpec[]             specs;
-
-    private Element                   paragraph;
-    private Element                   leaf;
-    private static final int          leafIndex = 1;
-    private int                       insertOffset;
+    private static final int leafIndex = 1;
 
-    private DefaultDocumentEvent      insertEvent;
+    private int insertOffset;
+
+    private DefaultDocumentEvent insertEvent;
 
     private static final AttributeSet bold = DefStyledDoc_Helpers.bold;
+
     private static final AttributeSet italic = DefStyledDoc_Helpers.italic;
 
     private static final class ElementAssert {
         private final AttributeSet attrs;
+
         private final int start;
+
         private final int end;
 
         public ElementAssert(AttributeSet attrs, int start, int end) {
@@ -109,34 +115,33 @@
 
         public void check(final Element element) {
             if (attrs == null) {
-                assertEquals("Attibute count",
-                             0, element.getAttributes().getAttributeCount());
+                assertEquals("Attibute count", 0, element.getAttributes().getAttributeCount());
             } else {
-                assertTrue("Attributes",
-                           attrs.isEqual(element.getAttributes()));
+                assertTrue("Attributes", attrs.isEqual(element.getAttributes()));
             }
             assertEquals("Start offset", start, element.getStartOffset());
             assertEquals("End offset", end, element.getEndOffset());
         }
     }
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
         root = doc.getDefaultRootElement();
-        buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc,
-                                                                root) {
+        buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             public void insert(int offset, int length, ElementSpec[] spec,
-                               DefaultDocumentEvent event) {
+                    DefaultDocumentEvent event) {
                 super.insert(offset, length, specs = spec, event);
             }
         };
         doc.buffer = buf;
-
-        doc.insertString(doc.getLength(), "plain", null);    // 5 chars
-        doc.insertString(doc.getLength(), "bold", bold);     // 4 chars
+        doc.insertString(doc.getLength(), "plain", null); // 5 chars
+        doc.insertString(doc.getLength(), "bold", bold); // 4 chars
         doc.insertString(doc.getLength(), "italic", italic); // 6 chars
-
         paragraph = root.getElement(0);
         leaf = paragraph.getElement(leafIndex);
         insertOffset = leaf.getStartOffset() + 2;
@@ -149,31 +154,24 @@
     public void testInsertString01() throws Exception {
         doc.insertString(insertOffset, "^^^", null);
         assertEquals(2, getEdits(insertEvent).size());
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertChange(edits.get(1), paragraph, 1, 3);
-        ElementChange change = (ElementChange)edits.get(1);
+        ElementChange change = (ElementChange) edits.get(1);
         assertSame(leaf, change.getChildrenRemoved()[0]);
         final Element[] added = change.getChildrenAdded();
         for (int i = 0; i < added.length; i++) {
             assertSame("@" + i, paragraph.getElement(i + leafIndex), added[i]);
         }
-
-        ElementAssert[] expected = {
-            new ElementAssert(null, 0, 5),
-            new ElementAssert(bold, 5, 7),
-            new ElementAssert(null, 7, 10),
-            new ElementAssert(bold, 10, 12),
-            new ElementAssert(italic, 12, 18),
-            new ElementAssert(null, 18, 19)
-        };
+        ElementAssert[] expected = { new ElementAssert(null, 0, 5),
+                new ElementAssert(bold, 5, 7), new ElementAssert(null, 7, 10),
+                new ElementAssert(bold, 10, 12), new ElementAssert(italic, 12, 18),
+                new ElementAssert(null, 18, 19) };
         assertEquals(expected.length, paragraph.getElementCount());
         for (int i = 0; i < expected.length; i++) {
             expected[i].check(paragraph.getElement(i));
         }
-
         assertEquals(1, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
     }
 
     /**
@@ -181,20 +179,16 @@
      */
     public void testInsertString02() throws Exception {
         doc.insertString(insertOffset, "^^^", bold);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(1, edits.size());
-
         assertEquals(5, leaf.getStartOffset());
         assertEquals(5 + 4 + 3, leaf.getEndOffset());
-
         assertEquals(1, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 3);
-
-// These actions are performed:
-//      createLeaf(paragraph[0, 19], bold=true , 5, 7)
-//      createLeaf(paragraph[0, 19], , 7, 10)
-//      createLeaf(paragraph[0, 19], bold=true , 10, 12)
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 3);
+        // These actions are performed:
+        //      createLeaf(paragraph[0, 19], bold=true , 5, 7)
+        //      createLeaf(paragraph[0, 19], , 7, 10)
+        //      createLeaf(paragraph[0, 19], bold=true , 10, 12)
     }
 
     /**
@@ -202,49 +196,36 @@
      */
     public void testInsertString03() throws Exception {
         doc.insertString(insertOffset, "\n", null);
-        final List edits = getEdits(insertEvent);
+        final List<?> edits = getEdits(insertEvent);
         assertEquals(3, edits.size());
         assertSame(paragraph, root.getElement(0));
         assertChange(edits.get(1), root.getElement(0), 3, 2);
-//        assertChange(edits.get(2), root.getElement(1), 1, 1);
+        //        assertChange(edits.get(2), root.getElement(1), 1, 1);
         assertChange(edits.get(2), root, 0, 1);
-
-        final ElementAssert[] par1Expected = {
-            new ElementAssert(null, 0, 5),
-            new ElementAssert(bold, 5, 7),
-            new ElementAssert(null, 7, 8)
-        };
+        final ElementAssert[] par1Expected = { new ElementAssert(null, 0, 5),
+                new ElementAssert(bold, 5, 7), new ElementAssert(null, 7, 8) };
         assertEquals(par1Expected.length, paragraph.getElementCount());
         for (int i = 0; i < par1Expected.length; i++) {
             par1Expected[i].check(paragraph.getElement(i));
         }
-
-        final ElementAssert[] par2Expected = {
-            new ElementAssert(bold, 8, 10),
-            new ElementAssert(italic, 10, 16),
-            new ElementAssert(null, 16, 17)
-        };
+        final ElementAssert[] par2Expected = { new ElementAssert(bold, 8, 10),
+                new ElementAssert(italic, 10, 16), new ElementAssert(null, 16, 17) };
         final Element par2 = root.getElement(1);
         assertEquals(par2Expected.length, par2.getElementCount());
         for (int i = 0; i < par2Expected.length; i++) {
             par2Expected[i].check(par2.getElement(i));
         }
-
         assertEquals(3, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 1);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-
-// These actions are performed:
-//      createLeaf(paragraph[0, 17], bold=true , 5, 7)
-//      createLeaf(paragraph[0, 17], , 7, 8)
-//      createBranch(section[0, 17], resolver=**AttributeSet** )
-//      createLeaf(paragraph[N/A], bold=true , 8, 10)
-//      createLeaf(paragraph[N/A], italic=true , 10, 16)
-//      createLeaf(paragraph[N/A], , 16, 17)
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 1);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        // These actions are performed:
+        //      createLeaf(paragraph[0, 17], bold=true , 5, 7)
+        //      createLeaf(paragraph[0, 17], , 7, 8)
+        //      createBranch(section[0, 17], resolver=**AttributeSet** )
+        //      createLeaf(paragraph[N/A], bold=true , 8, 10)
+        //      createLeaf(paragraph[N/A], italic=true , 10, 16)
+        //      createLeaf(paragraph[N/A], , 16, 17)
     }
 
     /**
@@ -252,30 +233,24 @@
      */
     public void testInsertString04() throws Exception {
         doc.insertString(insertOffset, "one\ntwo", null);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertChange(edits.get(1), root.getElement(0), 3, 2);
         assertChange(edits.get(2), root.getElement(1), 0, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.OriginateDirection, 0, 3);
-
-// These actions are performed:
-//      createLeaf(paragraph[0, 23], bold=true , 5, 7)
-//      createLeaf(paragraph[0, 23], , 7, 11)
-//      createBranch(section[0, 23], resolver=**AttributeSet** )
-//      createLeaf(paragraph[N/A], bold=true , 14, 16)
-//      createLeaf(paragraph[N/A], italic=true , 16, 22)
-//      createLeaf(paragraph[N/A], , 22, 23)
-//      createLeaf(paragraph[14, 23], , 11, 14)
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
+        // These actions are performed:
+        //      createLeaf(paragraph[0, 23], bold=true , 5, 7)
+        //      createLeaf(paragraph[0, 23], , 7, 11)
+        //      createBranch(section[0, 23], resolver=**AttributeSet** )
+        //      createLeaf(paragraph[N/A], bold=true , 14, 16)
+        //      createLeaf(paragraph[N/A], italic=true , 16, 22)
+        //      createLeaf(paragraph[N/A], , 22, 23)
+        //      createLeaf(paragraph[14, 23], , 11, 14)
     }
 
     /**
@@ -284,43 +259,36 @@
      */
     public void testInsertString05() throws Exception {
         doc.insertString(insertOffset, "one\ntwo", bold);
-        List edits = getEdits(insertEvent);
+        List<?> edits = getEdits(insertEvent);
         assertEquals(4, edits.size());
         assertChange(edits.get(1), root.getElement(0), 3, 1);
         assertChange(edits.get(2), root.getElement(1), 1, 1);
         assertChange(edits.get(3), root, 0, 1);
-
         assertEquals(4, specs.length);
-        assertSpec(specs[0], ElementSpec.ContentType,
-                   ElementSpec.JoinPreviousDirection, 0, 4);
-        assertSpec(specs[1], ElementSpec.EndTagType,
-                   ElementSpec.OriginateDirection, 0, 0);
-        assertSpec(specs[2], ElementSpec.StartTagType,
-                   ElementSpec.JoinFractureDirection, 0, 0);
-        assertSpec(specs[3], ElementSpec.ContentType,
-                   ElementSpec.JoinNextDirection, 0, 3);
-
-// These actions are performed:
-//      createLeaf(paragraph[0, 23], bold=true , 5, 11)
-//      createBranch(section[0, 23], resolver=**AttributeSet** )
-//      createLeaf(paragraph[N/A], bold=true , 14, 16)
-//      createLeaf(paragraph[N/A], italic=true , 16, 22)
-//      createLeaf(paragraph[N/A], , 22, 23)
-//      createLeaf(paragraph[14, 23], bold=true , 11, 16)
+        assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.JoinPreviousDirection, 0, 4);
+        assertSpec(specs[1], ElementSpec.EndTagType, ElementSpec.OriginateDirection, 0, 0);
+        assertSpec(specs[2], ElementSpec.StartTagType, ElementSpec.JoinFractureDirection, 0, 0);
+        assertSpec(specs[3], ElementSpec.ContentType, ElementSpec.JoinNextDirection, 0, 3);
+        // These actions are performed:
+        //      createLeaf(paragraph[0, 23], bold=true , 5, 11)
+        //      createBranch(section[0, 23], resolver=**AttributeSet** )
+        //      createLeaf(paragraph[N/A], bold=true , 14, 16)
+        //      createLeaf(paragraph[N/A], italic=true , 16, 22)
+        //      createLeaf(paragraph[N/A], , 22, 23)
+        //      createLeaf(paragraph[14, 23], bold=true , 11, 16)
     }
 
     private static void assertChange(final Object object, final Element element,
-                                     final int removed, final int added) {
+            final int removed, final int added) {
         DefStyledDoc_Helpers.assertChange(object, element, removed, added);
     }
 
     private static void assertSpec(final ElementSpec spec, final short type,
-                                   final short direction, final int offset,
-                                   final int length) {
+            final short direction, final int offset, final int length) {
         DefStyledDoc_Helpers.assertSpec(spec, type, direction, offset, length);
     }
 
-    private static Vector getEdits(final DefaultDocumentEvent event) {
+    private static Vector<?> getEdits(final DefaultDocumentEvent event) {
         return DefStyledDoc_Helpers.getEdits(event);
     }
 
@@ -328,7 +296,7 @@
     }
 
     public void insertUpdate(DocumentEvent e) {
-        insertEvent = (DefaultDocumentEvent)e;
+        insertEvent = (DefaultDocumentEvent) e;
     }
 
     public void removeUpdate(DocumentEvent e) {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_UpdateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_UpdateTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_UpdateTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementBuffer_UpdateTest.java Sun Nov 26 12:15:43 2006
@@ -21,7 +21,6 @@
 package javax.swing.text;
 
 import java.util.List;
-
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.event.DocumentEvent.EventType;
@@ -29,7 +28,6 @@
 import javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit;
 import javax.swing.text.DefaultStyledDocument.ElementBuffer;
 import javax.swing.text.DefaultStyledDocument.ElementSpec;
-
 import junit.framework.TestCase;
 
 /**
@@ -43,10 +41,14 @@
  */
 public class DefaultStyledDocument_ElementBuffer_UpdateTest extends TestCase {
     private DefaultStyledDocument doc;
+
     private Element root;
+
     private ElementBuffer buf;
+
     private DefaultDocumentEvent event;
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         doc = new DefaultStyledDocument();
@@ -62,18 +64,21 @@
      */
     public void testChangeUpdateChar() {
         buf = doc.new ElementBuffer(root) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             protected void changeUpdate() {
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertEquals(0, edits.size());
                 super.changeUpdate();
                 assertEquals(0, edits.size());
                 assertTrue(event.isInProgress());
             }
 
-            public void change(int offset, int length,
-                               DefaultDocumentEvent e) {
+            @Override
+            public void change(int offset, int length, DefaultDocumentEvent e) {
                 event = e;
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertSame(EventType.CHANGE, event.getType());
                 assertEquals(0, edits.size());
                 super.change(offset, length, event);
@@ -81,22 +86,18 @@
             }
         };
         doc.buffer = buf;
-
         MutableAttributeSet attrs = new SimpleAttributeSet();
         StyleConstants.setBold(attrs, true);
         doc.setCharacterAttributes(2, 2, attrs, false);
-
-        List edits = getEdits(event);
+        List<?> edits = getEdits(event);
         assertEquals(2, edits.size());
-
-        assertChange(edits.get(0), root.getElement(0), 0,
-                     new int[] {0, 2, 2, 4, 4, 6}, new int[] {0, 6});
-        AttributeUndoableEdit attrEdit = (AttributeUndoableEdit)edits.get(1);
+        assertChange(edits.get(0), root.getElement(0), 0, new int[] { 0, 2, 2, 4, 4, 6 },
+                new int[] { 0, 6 });
+        AttributeUndoableEdit attrEdit = (AttributeUndoableEdit) edits.get(1);
         assertFalse(attrEdit.isReplacing);
         assertEquals(SimpleAttributeSet.EMPTY, attrEdit.copy);
         assertEquals(attrs, attrEdit.newAttributes);
         assertSame(root.getElement(0).getElement(1), attrEdit.element);
-
         final Element leaf = root.getElement(0).getElement(1);
         assertEquals(attrs, leaf.getAttributes());
         doc.writeLock();
@@ -116,18 +117,21 @@
      */
     public void testChangeUpdateCharDirect() {
         buf = doc.new ElementBuffer(root) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             protected void changeUpdate() {
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertEquals(0, edits.size());
                 super.changeUpdate();
                 assertEquals(0, edits.size());
                 assertTrue(event.isInProgress());
             }
 
-            public void change(int offset, int length,
-                               DefaultDocumentEvent e) {
+            @Override
+            public void change(int offset, int length, DefaultDocumentEvent e) {
                 event = e;
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertSame(EventType.CHANGE, event.getType());
                 assertEquals(0, edits.size());
                 super.change(offset, length, event);
@@ -135,30 +139,24 @@
             }
         };
         doc.buffer = buf;
-
         MutableAttributeSet attrs = new SimpleAttributeSet();
         StyleConstants.setBold(attrs, true);
         event = doc.new DefaultDocumentEvent(2, 2, EventType.CHANGE);
-
         doc.writeLock();
         try {
             buf.change(2, 2, event);
         } finally {
             doc.writeUnlock();
         }
-
         // The call to buf.change is almost like a call
         // doc.setCharacterAttributes(2, 2, SimpleAttributeSet.EMPTY, false);
         // but the latter will also safe attribute changes into
         // AttributeUndoableEdit despite there actually were no changes
         // in attributes.
-
-        List edits = getEdits(event);
+        List<?> edits = getEdits(event);
         assertEquals(1, edits.size());
-
-        assertChange(edits.get(0), root.getElement(0), 0,
-                     new int[] {0, 2, 2, 4, 4, 6}, new int[] {0, 6});
-
+        assertChange(edits.get(0), root.getElement(0), 0, new int[] { 0, 2, 2, 4, 4, 6 },
+                new int[] { 0, 6 });
         final Element leaf = root.getElement(0).getElement(1);
         assertEquals(SimpleAttributeSet.EMPTY, leaf.getAttributes());
     }
@@ -171,36 +169,38 @@
      */
     public void testChangeUpdatePar() {
         buf = doc.new ElementBuffer(root) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             protected void changeUpdate() {
                 fail("ElementBuffer.changeUpdate is not expected");
             }
 
-            public void change(int offset, int length,
-                               DefaultDocumentEvent e) {
+            @Override
+            public void change(int offset, int length, DefaultDocumentEvent e) {
                 fail("ElementBuffer.change is not expected");
             }
         };
         doc.buffer = buf;
-
         MutableAttributeSet attrs = new SimpleAttributeSet();
         StyleConstants.setBold(attrs, true);
         doc.addDocumentListener(new DocumentListener() {
             public void changedUpdate(DocumentEvent e) {
-                event = (DefaultDocumentEvent)e;
+                event = (DefaultDocumentEvent) e;
             }
+
             public void insertUpdate(DocumentEvent e) {
                 fail("DocumentListener.insertUpdate is not expected");
             }
+
             public void removeUpdate(DocumentEvent e) {
                 fail("DocumentListener.removeUpdate is not expected");
             }
         });
         doc.setParagraphAttributes(2, 2, attrs, false);
-
-        List edits = getEdits(event);
+        List<?> edits = getEdits(event);
         assertEquals(1, edits.size());
-
-        AttributeUndoableEdit attrEdit = (AttributeUndoableEdit)edits.get(0);
+        AttributeUndoableEdit attrEdit = (AttributeUndoableEdit) edits.get(0);
         assertFalse(attrEdit.isReplacing);
         assertEquals(1, attrEdit.copy.getAttributeCount());
         assertTrue(attrEdit.copy.isDefined(AttributeSet.ResolveAttribute));
@@ -213,100 +213,91 @@
      */
     public void testInsertUpdate() throws BadLocationException {
         buf = doc.new ElementBuffer(root) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             protected void insertUpdate(ElementSpec[] spec) {
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertEquals(0, edits.size());
                 super.insertUpdate(spec);
                 assertEquals(0, edits.size());
                 assertTrue(event.isInProgress());
             }
 
+            @Override
             public void insert(int offset, int length, ElementSpec[] spec,
-                               DefaultDocumentEvent event) {
-                final List edits = getEdits(event);
+                    DefaultDocumentEvent event) {
+                final List<?> edits = getEdits(event);
                 assertEquals(0, edits.size());
                 super.insert(offset, length, spec, event);
                 assertEquals(3, edits.size());
             }
         };
         doc.buffer = buf;
-
-//        The specs are:
-//        Content:JoinPrevious:1,
-//        EndTag:Originate:0,
-//        StartTag:Fracture:0,
-//        Content:JoinNext:4
-
-//        It is the same as:
-//        doc.insertString(doc.getLength(), "\nthird", null);
-//
-//        Document contains: "01234\nabcde\n"
-//        Offsets             012345 678901 2
-//                            0          1
-//        Paragraphs          000000 111111
-//        After the text is inserted:
-//                           "01234\nabcde\nthird\n"
-//        Offsets:            012345 678901 234567 8
-//                            0          1
-//        Paragraphs           000000 111111 222222
-//
-//        doc.dump(System.out);
-//<section>
-//  <paragraph
-//    resolver=NamedStyle:default {name=default,}
-//  >
-//    <content>
-//      [0,6][01234
-//]
-//  <paragraph
-//    resolver=NamedStyle:default {name=default,}
-//  >
-//    <content>
-//      [6,12][abcde
-//]
-//  <paragraph
-//    resolver=NamedStyle:default {name=default,}
-//  >
-//    <content>
-//      [12,18][third
-//]
-
+        //        The specs are:
+        //        Content:JoinPrevious:1,
+        //        EndTag:Originate:0,
+        //        StartTag:Fracture:0,
+        //        Content:JoinNext:4
+        //        It is the same as:
+        //        doc.insertString(doc.getLength(), "\nthird", null);
+        //
+        //        Document contains: "01234\nabcde\n"
+        //        Offsets             012345 678901 2
+        //                            0          1
+        //        Paragraphs          000000 111111
+        //        After the text is inserted:
+        //                           "01234\nabcde\nthird\n"
+        //        Offsets:            012345 678901 234567 8
+        //                            0          1
+        //        Paragraphs           000000 111111 222222
+        //
+        //        doc.dump(System.out);
+        //<section>
+        //  <paragraph
+        //    resolver=NamedStyle:default {name=default,}
+        //  >
+        //    <content>
+        //      [0,6][01234
+        //]
+        //  <paragraph
+        //    resolver=NamedStyle:default {name=default,}
+        //  >
+        //    <content>
+        //      [6,12][abcde
+        //]
+        //  <paragraph
+        //    resolver=NamedStyle:default {name=default,}
+        //  >
+        //    <content>
+        //      [12,18][third
+        //]
         ElementSpec[] specs = {
-            new ElementSpec(SimpleAttributeSet.EMPTY,
-                            ElementSpec.ContentType, 1),
-            new ElementSpec(null, ElementSpec.EndTagType, 0),
-            new ElementSpec(root.getElement(1).getAttributes(),
-                            ElementSpec.StartTagType, 0),
-            new ElementSpec(SimpleAttributeSet.EMPTY,
-                            ElementSpec.ContentType, 5)
-        };
+                new ElementSpec(SimpleAttributeSet.EMPTY, ElementSpec.ContentType, 1),
+                new ElementSpec(null, ElementSpec.EndTagType, 0),
+                new ElementSpec(root.getElement(1).getAttributes(), ElementSpec.StartTagType, 0),
+                new ElementSpec(SimpleAttributeSet.EMPTY, ElementSpec.ContentType, 5) };
         specs[0].setDirection(ElementSpec.JoinPreviousDirection);
         specs[2].setDirection(ElementSpec.JoinFractureDirection);
         specs[3].setDirection(ElementSpec.JoinNextDirection);
-
-        event = doc.new DefaultDocumentEvent(doc.getLength(), 6,
-                                             EventType.INSERT);
+        event = doc.new DefaultDocumentEvent(doc.getLength(), 6, EventType.INSERT);
         int off = doc.getLength();
         // Insert the text into the content, so that ElementBuffer
         // could use proper offsets (or BadLocationException may be thrown).
         doc.getContent().insertString(off, "\nthird");
-
         doc.writeLock();
         try {
             buf.insert(off, 6, specs, event);
         } finally {
             doc.writeUnlock();
         }
-
-        List edits = getEdits(event);
+        List<?> edits = getEdits(event);
         assertEquals(3, edits.size());
-
-        assertChange(edits.get(0), root.getElement(1), 0,
-                     new int[] {6, 12}, new int[] {6, 18});
-        assertChange(edits.get(1), root.getElement(2), 0,
-                     new int[] {12, 18}, new int[] {17, 18});
-        assertChange(edits.get(2), root, 2,
-                     new int[] {12, 18}, new int[] {});
+        assertChange(edits.get(0), root.getElement(1), 0, new int[] { 6, 12 }, new int[] { 6,
+                18 });
+        assertChange(edits.get(1), root.getElement(2), 0, new int[] { 12, 18 }, new int[] { 17,
+                18 });
+        assertChange(edits.get(2), root, 2, new int[] { 12, 18 }, new int[] {});
     }
 
     /*
@@ -316,18 +307,21 @@
      */
     public void testRemoveUpdateNoStrucChange() {
         buf = doc.new ElementBuffer(root) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             protected void removeUpdate() {
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertEquals(0, edits.size());
                 super.removeUpdate();
                 assertEquals(0, edits.size());
                 assertTrue(event.isInProgress());
             }
 
-            public void remove(int offset, int length,
-                               DefaultDocumentEvent e) {
+            @Override
+            public void remove(int offset, int length, DefaultDocumentEvent e) {
                 event = e;
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertSame(EventType.REMOVE, event.getType());
                 assertEquals(0, edits.size());
                 super.remove(offset, length, event);
@@ -335,7 +329,6 @@
             }
         };
         doc.buffer = buf;
-
         event = doc.new DefaultDocumentEvent(2, 2, EventType.REMOVE);
         doc.writeLock();
         try {
@@ -343,8 +336,7 @@
         } finally {
             doc.writeUnlock();
         }
-
-        List edits = getEdits(event);
+        List<?> edits = getEdits(event);
         assertEquals(0, edits.size());
     }
 
@@ -355,18 +347,21 @@
      */
     public void testRemoveUpdateStrucChange() {
         buf = doc.new ElementBuffer(root) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             protected void removeUpdate() {
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertEquals(0, edits.size());
                 super.removeUpdate();
                 assertEquals(0, edits.size());
                 assertTrue(event.isInProgress());
             }
 
-            public void remove(int offset, int length,
-                               DefaultDocumentEvent e) {
+            @Override
+            public void remove(int offset, int length, DefaultDocumentEvent e) {
                 event = e;
-                final List edits = getEdits(event);
+                final List<?> edits = getEdits(event);
                 assertSame(EventType.REMOVE, event.getType());
                 assertEquals(0, edits.size());
                 super.remove(offset, length, event);
@@ -374,7 +369,6 @@
             }
         };
         doc.buffer = buf;
-
         event = doc.new DefaultDocumentEvent(2, 2, EventType.REMOVE);
         doc.writeLock();
         try {
@@ -382,25 +376,17 @@
         } finally {
             doc.writeUnlock();
         }
-
-        List edits = getEdits(event);
+        List<?> edits = getEdits(event);
         assertEquals(1, edits.size());
-
-        assertChange(edits.get(0), root, 0,
-                     new int[] {0, 12}, new int[] {0, 6, 6, 12});
+        assertChange(edits.get(0), root, 0, new int[] { 0, 12 }, new int[] { 0, 6, 6, 12 });
     }
 
-    private static void assertChange(final Object change,
-                                     final Element element,
-                                     final int index,
-                                     final int[] addedOffsets,
-                                     final int[] removedOffsets) {
-        DefStyledDoc_Helpers.assertChange(change, element, index,
-                                          removedOffsets, addedOffsets);
+    private static void assertChange(final Object change, final Element element,
+            final int index, final int[] addedOffsets, final int[] removedOffsets) {
+        DefStyledDoc_Helpers.assertChange(change, element, index, removedOffsets, addedOffsets);
     }
 
-    private static List getEdits(final DefaultDocumentEvent event) {
+    private static List<?> getEdits(final DefaultDocumentEvent event) {
         return DefStyledDoc_Helpers.getEdits(event);
     }
-
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementSpecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementSpecTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementSpecTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/DefaultStyledDocument_ElementSpecTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -22,7 +21,6 @@
 package javax.swing.text;
 
 import javax.swing.text.DefaultStyledDocument.ElementSpec;
-
 import junit.framework.TestCase;
 
 public class DefaultStyledDocument_ElementSpecTest extends TestCase {
@@ -30,11 +28,13 @@
      * ElementSpec created with ElementSpec(AttributeSet, short) constructor.
      */
     private ElementSpec spec1;
+
     /**
      * ElementSpec created with ElementSpec(AttributeSet, short, int)
      * constructor.
      */
     private ElementSpec spec2;
+
     /**
      * ElementSpec created with
      * ElementSpec(AttributeSet, short, char[], int, int) constructor.
@@ -42,34 +42,32 @@
     private ElementSpec spec3;
 
     private static final AttributeSet attrs1;
+
     private static final AttributeSet attrs2;
+
     private static final AttributeSet attrs3;
 
     private char[] text;
-
     static {
         MutableAttributeSet mas;
-
         mas = new SimpleAttributeSet();
         StyleConstants.setBold(mas, true);
         attrs1 = mas.copyAttributes();
-
         mas = new SimpleAttributeSet();
         StyleConstants.setItalic(mas, true);
         attrs2 = mas.copyAttributes();
-
         mas = new SimpleAttributeSet(attrs1);
         mas.addAttributes(attrs2);
         attrs3 = mas.copyAttributes();
     }
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
-
         spec1 = new ElementSpec(attrs1, ElementSpec.StartTagType);
         spec2 = new ElementSpec(attrs2, ElementSpec.ContentType, 10);
-        spec3 = new ElementSpec(attrs3, ElementSpec.EndTagType,
-                                text = "sample text".toCharArray(), 2, 4);
+        spec3 = new ElementSpec(attrs3, ElementSpec.EndTagType, text = "sample text"
+                .toCharArray(), 2, 4);
     }
 
     /*
@@ -80,15 +78,14 @@
      * ElementSpec(AttributeSet, short, char[], int, int)
      * ElementSpec(AttributeSet, short, int)
      */
-/*
-    public void testElementSpecAttributeSetshort() {
-    }
-    public void testElementSpecAttributeSetshortcharArrayintint() {
-    }
-    public void testElementSpecAttributeSetshortint() {
-    }
-*/
-
+    /*
+     public void testElementSpecAttributeSetshort() {
+     }
+     public void testElementSpecAttributeSetshortcharArrayintint() {
+     }
+     public void testElementSpecAttributeSetshortint() {
+     }
+     */
     public void testGetArray() {
         assertNull(spec1.getArray());
         assertNull(spec2.getArray());
@@ -150,18 +147,11 @@
      * Checks how directions represented in string.
      */
     public void testToStringDirection() {
-        final short[] direction = new short[] {
-            ElementSpec.OriginateDirection,
-            ElementSpec.JoinFractureDirection,
-            ElementSpec.JoinNextDirection,
-            ElementSpec.JoinPreviousDirection
-        };
-        final String[] text = new String[] {
-            "Originate",
-            "Fracture",
-            "JoinNext",
-            "JoinPrevious"
-        };
+        final short[] direction = new short[] { ElementSpec.OriginateDirection,
+                ElementSpec.JoinFractureDirection, ElementSpec.JoinNextDirection,
+                ElementSpec.JoinPreviousDirection };
+        final String[] text = new String[] { "Originate", "Fracture", "JoinNext",
+                "JoinPrevious" };
         for (int i = 0; i < direction.length; i++) {
             spec1.setDirection(direction[i]);
             assertEquals("@ " + i, text[i], spec1.toString().split(":")[1]);
@@ -169,14 +159,14 @@
     }
 
     public void testToStringIvalidDirection() {
-        spec1.setDirection((short)25);
-        assertEquals((short)25, spec1.getDirection());
+        spec1.setDirection((short) 25);
+        assertEquals((short) 25, spec1.getDirection());
         assertEquals("StartTag:??:0", spec1.toString());
     }
 
     public void testToStringInvalidType() throws Exception {
-        spec1.setType((short)25);
-        assertEquals((short)25, spec1.getType());
+        spec1.setType((short) 25);
+        assertEquals((short) 25, spec1.getType());
         assertEquals("??:Originate:0", spec1.toString());
     }
 }



Mime
View raw message