1 19 20 package org.netbeans.core.output2; 21 22 import java.awt.EventQueue ; 23 import java.io.UnsupportedEncodingException ; 24 import java.util.Arrays ; 25 import javax.swing.SwingUtilities ; 26 import javax.swing.event.DocumentEvent ; 27 import javax.swing.event.DocumentListener ; 28 import javax.swing.text.BadLocationException ; 29 import javax.swing.text.DefaultStyledDocument ; 30 import javax.swing.text.Document ; 31 import javax.swing.text.Element ; 32 import javax.swing.text.Position ; 33 import javax.swing.text.SimpleAttributeSet ; 34 import junit.framework.TestCase; 35 import org.netbeans.junit.NbTestCase; 36 37 40 public class OutputDocumentTest extends NbTestCase { 41 42 public OutputDocumentTest(String testName) { 43 super(testName); 44 } 45 46 public void testAddDocumentListener() throws Exception { 47 System.out.println("testAddDocumentListener"); 48 49 OutWriter ow = new OutWriter (); 50 OutputDocument doc = new OutputDocument (ow); 51 final ODListener od = new ODListener(); 52 doc.addDocumentListener(od); 53 String first = "This is the first string"; 54 String second = "This is the second string, ain't it?"; 55 String third = "This is the third string"; 56 57 ow.println(first); 58 ow.println (second); 59 ow.println (third); 60 ow.flush(); 61 od.assertChanged(); 69 70 } 71 72 public void testDocumentEvents() throws Exception { 73 System.out.println("testDocumentEvents"); 74 75 OutWriter ow = new OutWriter (); 76 OutputDocument doc = new OutputDocument (ow); 77 ODListener od = new ODListener(); 78 doc.addDocumentListener(od); 79 80 for (int i=0; i < 100; i++) { 81 ow.println("This is string " + i); 82 } 83 84 Thread.currentThread().sleep(1500); 90 91 DocumentEvent de = od.getEvent(); 92 assertTrue ("Event should have been fired", de != null); 93 94 int elCount = doc.getElementCount(); 95 96 assertTrue ("Element count should be 100 after printing 100 lines, " + 97 "not " + elCount, 98 elCount == 100); 99 100 DocumentEvent.ElementChange ec = de.getChange(doc); 101 102 Element [] added = ec.getChildrenAdded(); 103 assertNotNull("Children added should not be null", added); 104 } 107 108 public void testCreatePosition() { 109 System.out.println("testCreatePosition"); 110 111 OutWriter ow = new OutWriter (); 112 OutputDocument doc = new OutputDocument (ow); 113 String first = "This is the first string"; 114 String second = "This is the second string, ain't it?"; 115 String third = "This is the third string"; 116 ow.println(first); 117 ow.println (second); 118 ow.println (third); 119 ow.flush(); 120 Position pos = null; 121 try { 122 pos = doc.createPosition (15); 123 } catch (BadLocationException ble) { 124 ble.printStackTrace(); 125 fail ("Unexpected BadLocationException: " + ble.getMessage()); 126 } 127 assertNotNull (pos); 128 129 assertTrue (pos.getOffset() == 15); 130 131 BadLocationException ble = null; 132 try { 133 pos = doc.createPosition (65543); 134 } catch (BadLocationException e) { 135 ble = e; 136 } 137 assertNotNull("Exception should have been thrown when creating a bogus location", ble); 138 139 try { 140 pos = doc.createPosition (-2); 141 } catch (BadLocationException e) { 142 ble = e; 143 } 144 assertNotNull("Exception should have been thrown when creating a bogus negative location", ble); 145 } 146 147 public void testStillGrowing() { 148 System.out.println("testStillGrowing"); 149 150 OutWriter ow = new OutWriter (); 151 OutputDocument doc = new OutputDocument (ow); 152 String first = "This is the first string"; 153 String second = "This is the second string, ain't it?"; 154 String third = "This is the third string"; 155 ow.println(first); 156 ow.println (second); 157 ow.println (third); 158 assertTrue ("After a few writes, document should not think its output stream is closed, it isn't.", doc.getLines().isGrowing()); 159 ow.flush(); 160 assertTrue ("After a flush, document should not think its output stream is closed, it isn't.", doc.getLines().isGrowing()); 161 ow.close(); 162 assertFalse ("After closing the writer, the document should not expect itself to grow", doc.getLines().isGrowing()); 163 } 164 165 private static String STATE = "(STATE NOT SET!)"; 166 public void testWordWrap() { 167 System.out.println("testWordWrap - line data caching ON"); 168 STATE = "(CACHED MODE)"; 169 AbstractLines.unitTestUseCache(Boolean.TRUE); 170 doTestWordWrap(); 171 172 System.out.println("testWordWrap - line data caching OFF"); 173 STATE = "(DYNAMIC MODE)"; 174 AbstractLines.unitTestUseCache(Boolean.FALSE); 175 177 AbstractLines.unitTestUseCache(null); 178 STATE = "(STATE NOT SET!)"; 179 } 180 181 private void doTestWordWrap() { 182 OutWriter ow = new OutWriter (); 183 OutputDocument doc = new OutputDocument (ow); 184 185 char[] c120 = new char[120]; 186 Arrays.fill(c120, 'A'); 187 String s120 = new String (c120); 188 char[] c80 = new char[80]; 189 Arrays.fill(c80, 'B'); 190 String s80 = new String (c80); 191 char[] c20 = new char[20]; 192 Arrays.fill (c20, 'C'); 193 String s20 = new String (c20); 194 195 ow.println (c80); 196 ow.println (c80); 197 ow.println (c80); 198 199 int val = doc.getLines().getLogicalLineCountAbove(2, 90); 200 assertTrue (STATE + "With three 80 character lines of data, wrapped at 90 characters, there should be 2 lines above line 2, not " + val, val == 2); 201 202 val = doc.getLines().getLogicalLineCountIfWrappedAt(90); 203 assertTrue (STATE + "With three 80 character lines of data, wrapped at 90 characters, the line count should be 3, not " + val, val == 3); 204 assertTrue (val == ow.getLines().getLineCount()); 205 206 val = doc.getLines().getLogicalLineCountIfWrappedAt(50); 207 assertTrue (STATE + "With three 80 character lines of data, wrapped at 50 characters, the line count should be 6, not " + val, val == 6); 208 209 val = doc.getLines().getLogicalLineCountAbove(2, 50); 210 assertTrue (STATE + "With three 80 character lines of data, wrapped at 50 characters, there should be 4 logical lines above 2, not " + val, val == 4); 211 212 int[] wrapData = new int[] {5, 0, 0}; 213 doc.getLines().toLogicalLineIndex(wrapData, 50); 214 assertTrue("The logical line index of the 5th phys line with three 80 char lines wrapped at 50 chars should be 2 in the document, not " + wrapData[0], wrapData[0] == 2); 215 assertTrue("An 80 char line should wrap twice, not " + wrapData[2], wrapData[2] == 2); 216 assertTrue("On the 5th physical line with three 80 char lines wrapped at 50 chars should be the 1st line of actual line 3, not " + wrapData[1], wrapData[1] == 1); 217 218 wrapData[0] = 6; 219 doc.getLines().toLogicalLineIndex(wrapData, 50); 220 assertTrue("On the 5th physical line with three 80 char lines wrapped at 50 chars should be the 2nd line of actual line 3, not " + wrapData[1], wrapData[1] == 2); 221 222 ow.println(c20); 223 ow.println(c80); 224 225 val = doc.getLines().getLogicalLineCountAbove(3, 50); 226 assertTrue ("There should be 6 logical lines above a 20 char line following three 80 char lines when wrapped at 50 chars", val == 6); 227 228 wrapData[0] = 6; 229 doc.getLines().toLogicalLineIndex(wrapData, 50); 230 assertTrue ("20 char line should not be wrapped, but shows " + wrapData[2] + " wraps", wrapData[2] == 1); 231 } 232 233 public void testGetDefaultRootElement() { 234 System.out.println("testGetDefaultRootElement"); 235 236 OutWriter ow = new OutWriter (); 237 OutputDocument doc = new OutputDocument (ow); 238 String first = "This is the first string"; 239 String second = "This is the second string, ain't it?"; 240 String third = "This is the third string"; 241 ow.println(first); 242 ow.println (second); 243 ow.println (third); 244 ow.flush(); 245 246 Element el = doc.getDefaultRootElement(); 247 assertNotNull ("Root element should not be null", el); 248 249 assertTrue ("Root offset should be 0", el.getStartOffset() == 0); 250 assertTrue ("Root ending char should be count of written chars", el.getEndOffset() == ow.getLines().getCharCount()); 251 assertTrue ("Wrong document object from default root element's getDocument method", el.getDocument() == doc); 252 assertTrue ("Element count of the root element should be the line count", el.getElementCount() == ow.getLines().getLineCount()); 253 254 255 } 256 257 public void testGetEndPosition() { 258 System.out.println("testGetEndPosition"); 259 260 OutWriter ow = new OutWriter (); 261 OutputDocument doc = new OutputDocument (ow); 262 String first = "This is the first string"; 263 String second = "This is the second string, ain't it?"; 264 String third = "This is the third string"; 265 ow.println(first); 266 ow.println (second); 267 ow.flush(); 268 269 Position pos = doc.getEndPosition(); 270 271 int offset = pos.getOffset(); 272 273 assertTrue ("End offset should match number of characters written", offset == ow.getLines().getCharCount()); 274 275 ow.println (third); 276 ow.flush(); 277 278 assertTrue ("Document end offset should change after writing more data", offset != pos.getOffset()); 279 assertTrue ("End offset should match number of characters written", pos.getOffset() == ow.getLines().getCharCount()); 280 281 } 282 283 public void testGetLength() throws UnsupportedEncodingException { 284 System.out.println("testGetLength"); 285 286 OutWriter ow = new OutWriter (); 287 OutputDocument doc = new OutputDocument (ow); 288 String first = "This is the first string"; 289 String second = "This is the second string, ain't it?"; 290 String third = "This is the third string"; 291 ow.println(first); 292 ow.println (second); 293 ow.println (third); 294 ow.flush(); 295 296 String lineSeparator = new String (OutWriter.lineSepBytes, "UTF-16"); 297 298 int expectedLength = first.length() + second.length() + third.length() + (3 * lineSeparator.length()) ; 299 int receivedLength = doc.getLength(); 300 301 assertTrue ("Number of characters counting carriage returns should be " 302 + expectedLength + " but was " + receivedLength, expectedLength == receivedLength); 303 304 } 305 306 public void testGetRootElements() { 307 System.out.println("testGetRootElements"); 308 309 OutWriter ow = new OutWriter (); 310 OutputDocument doc = new OutputDocument (ow); 311 String first = "This is the first string"; 312 String second = "This is the second string, ain't it?"; 313 String third = "This is the third string"; 314 ow.println(first); 315 ow.println (second); 316 ow.println (third); 317 ow.flush(); 318 319 Element [] el = doc.getRootElements(); 320 assertTrue ("Should be only one root element", el.length == 1); 321 assertTrue ("Root element should be the document", el[0] == doc); 322 323 } 324 325 public void testGetStartPosition() { 326 System.out.println("testGetStartPosition"); 327 OutWriter ow = new OutWriter (); 328 OutputDocument doc = new OutputDocument (ow); 329 String first = "This is the first string"; 330 String second = "This is the second string, ain't it?"; 331 String third = "This is the third string"; 332 ow.println(first); 333 ow.println (second); 334 ow.println (third); 335 ow.flush(); 336 337 Position p = doc.getStartPosition(); 338 339 assertTrue ("Start position should be start offset", p.getOffset() == doc.getStartOffset()); 340 assertTrue ("Start offset should be 0", p.getOffset() == 0); 341 342 } 343 344 public void testGetText() throws UnsupportedEncodingException { 345 System.out.println("testGetText"); 346 OutWriter ow = new OutWriter (); 347 OutputDocument doc = new OutputDocument (ow); 348 String first = "This is the first string"; 349 ow.println(first); 350 ow.flush(); 351 String received = null; 352 353 try { 354 received = doc.getText(3, 7); 355 } catch (BadLocationException ble) { 356 ble.printStackTrace(); 357 fail ("Unexpected BadLocationException: " + ble.getMessage()); 358 } 359 String expected = first.substring (3, 10); 360 361 assertEquals ("getText() returned \"" + received + "\" but should have returned \"" + expected + "\"", expected, received); 362 363 try { 364 received = doc.getText (0, first.length()); 365 } catch (BadLocationException e) { 366 e.printStackTrace(); 367 fail ("Unexpected BadLocationException thrown: " + e.getMessage()); 368 } 369 assertEquals ("getText for the full first string printed should return \"" + first + "\" but got \"" + received + "\"", first, received); 370 371 String second = "Lets try a different string this time"; 372 ow.println(second); 373 ow.flush(); 374 try { 375 received = doc.getText (0, doc.getLength()); 376 } catch (BadLocationException ble) { 377 ble.printStackTrace(); 378 fail ("Unexpected BadLocationException: " + ble.getMessage()); 379 } 380 String lineSeparator = new String (OutWriter.lineSepBytes, "UTF-16"); 381 expected = first + lineSeparator + second + lineSeparator; 382 383 assertEquals ("getText for first two strings should be \"" + expected + "\" but was \"" + received + "\"", expected, received); 384 } 385 386 public void testInsertString() { 387 System.out.println("testInsertString"); 388 OutWriter ow = new OutWriter (); 389 OutputDocument doc = new OutputDocument (ow); 390 String first = "This is the first string"; 391 ow.println(first); 392 ow.flush(); 393 394 UnsupportedOperationException uoe = null; 395 try { 396 doc.insertString(5, "Foo", null); 397 } catch (UnsupportedOperationException e) { 398 uoe = e; 399 } catch (BadLocationException e) { 400 fail ("Bad location exception thrown - should have been UnsupportedOperationException"); 401 } 402 assertNotNull ("insertString should throw an unsupportedOperationException ", uoe); 403 404 } 405 406 407 public void testRender() { 408 System.out.println("testRender"); 409 410 OutWriter ow = new OutWriter (); 411 OutputDocument doc = new OutputDocument (ow); 412 String first = "This is the first string"; 413 ow.println(first); 414 ow.flush(); 415 416 RunIt r = new RunIt(); 417 doc.render (r); 418 r.assertWasRun(); 419 420 } 421 422 private static class RunIt implements Runnable { 423 private boolean hasBeenRun = false; 424 425 public void assertWasRun() { 426 assertTrue (hasBeenRun); 427 } 428 429 public void run() { 430 hasBeenRun = true; 431 } 432 } 433 434 public void testGetDocument() { 435 System.out.println("testGetDocument"); 436 437 OutWriter ow = new OutWriter (); 438 OutputDocument doc = new OutputDocument (ow); 439 String first = "This is the first string"; 440 ow.println(first); 441 ow.flush(); 442 443 444 assertTrue(doc.getDocument() == doc); 445 446 } 447 448 public void testGetElement() throws UnsupportedEncodingException { 449 System.out.println("testGetElement"); 450 451 OutWriter ow = new OutWriter (); 452 OutputDocument doc = new OutputDocument (ow); 453 String first = "This is the first string"; 454 String second = "This is the second string, ain't it?"; 455 String third = "This is the third string"; 456 ow.println(first); 457 ow.println (second); 458 ow.println (third); 459 ow.flush(); 460 String lineSeparator = new String (OutWriter.lineSepBytes, "UTF-16"); 461 462 Element el = doc.getElement(0); 463 assertTrue (el.getStartOffset() == 0); 464 assertTrue ("End offset should be length of string + separator length (" 465 + (first.length() + lineSeparator.length()) + " but was " + el.getEndOffset(), 466 el.getEndOffset() == first.length() + lineSeparator.length()); 467 468 el = doc.getElement(1); 469 } 470 471 public void testGetElementCount() { 472 System.out.println("testGetElementCount"); 473 OutWriter ow = new OutWriter (); 474 OutputDocument doc = new OutputDocument (ow); 475 String first = "This is the first string"; 476 String second = "This is the second string, ain't it?"; 477 String third = "This is the third string"; 478 ow.println(first); 479 ow.println (second); 480 ow.println (third); 481 ow.flush(); 482 assertTrue ("Element count for document should match line count", doc.getElementCount() == ow.getLines().getLineCount()); 483 } 484 485 public void testGetElementIndex() { 486 System.out.println("testGetElementIndex"); 487 488 OutWriter ow = new OutWriter (); 489 OutputDocument doc = new OutputDocument (ow); 490 String first = "This is the first string"; 491 String second = "This is the second string, ain't it?"; 492 String third = "This is the third string"; 493 ow.println(first); 494 ow.println (second); 495 ow.println (third); 496 ow.flush(); 497 498 int idx = doc.getElementIndex(5); 499 assertTrue ("Element index five characters into the first string should be element 0, not " + idx, idx == 0); 500 501 idx = doc.getElementIndex (first.length() + 1 + 5); 502 assertTrue ("Element index five characters into the second string should be 1, not " + idx, idx == 1); 503 504 505 idx = doc.getElementIndex(first.length() + 1 + second.length() + 1 + (third.length() / 2)); 506 assertTrue ("Element index halfway through the third string should be 2, not " + idx, 507 idx == 2); 508 } 509 510 public void testGetEndOffset() { 511 System.out.println("testGetEndOffset"); 512 513 OutWriter ow = new OutWriter (); 514 OutputDocument doc = new OutputDocument (ow); 515 String first = "This is the first string"; 516 String second = "This is the second string, ain't it?"; 517 String third = "This is the third string"; 518 ow.println(first); 519 ow.println (second); 520 ow.println (third); 521 ow.flush(); 522 523 assertTrue ("End offset should be chars printed", doc.getEndOffset() == ow.getLines().getCharCount()); 524 } 525 526 public void testGetParentElement() { 527 System.out.println("testGetParentElement"); 528 529 OutWriter ow = new OutWriter (); 530 OutputDocument doc = new OutputDocument (ow); 531 String first = "This is the first string"; 532 String second = "This is the second string, ain't it?"; 533 String third = "This is the third string"; 534 ow.println(first); 535 ow.println (second); 536 ow.println (third); 537 ow.flush(); 538 539 assertNull ("Document parent element should be null ", doc.getParentElement()); 540 541 Element el = doc.getElement(1); 542 assertSame ("Parent element of line element should be the document", el.getParentElement(), doc); 543 544 } 545 546 public void testGetStartOffset() { 547 System.out.println("testGetStartOffset"); 548 } 550 551 public void testIsLeaf() { 552 System.out.println("testIsLeaf"); 553 554 OutWriter ow = new OutWriter (); 555 OutputDocument doc = new OutputDocument (ow); 556 557 558 assertTrue ("Document should be leaf if no text has been written", doc.isLeaf()); 559 560 String first = "This is the first string"; 561 String second = "This is the second string, ain't it?"; 562 String third = "This is the third string"; 563 ow.println(first); 564 ow.println (second); 565 ow.println (third); 566 ow.flush(); 567 568 assertFalse("Document should not be leaf if text has been written", doc.isLeaf()); 569 } 570 571 572 public void testDocumentEventSimilarity() throws Exception { 573 System.out.println("testDocumentEventSimilarity"); 574 DefaultStyledDocument styled = new DefaultStyledDocument (); 575 OutWriter ow = new OutWriter (); 576 OutputDocument doc = new OutputDocument (ow); 577 578 ODListener docListener = new ODListener(doc); 579 ODListener styListener = new ODListener(styled); 580 581 String lineSeparator = new String (OutWriter.lineSepBytes, "UTF-16"); 582 583 584 585 String s = "This is a string I will append"; 586 587 styled.insertString(styled.getLength(), s + lineSeparator, SimpleAttributeSet.EMPTY); 588 ow.println (s); 589 ow.flush(); 590 docListener.assertChanged(); 591 styListener.assertChanged(); 592 593 styled.insertString(styled.getLength(), s + lineSeparator, SimpleAttributeSet.EMPTY); 594 ow.println (s); 595 ow.flush(); 596 597 605 int styLen = styled.getLength(); 606 int docLen = doc.getLength(); 607 608 assertTrue ("Length should be same, but OutputDocument length is " + 609 docLen + " and similar StyledDocument length is " + styLen, 610 doc.getLength() == styled.getLength()); 611 612 DocumentEvent docEvent = docListener.getEvent(); 613 DocumentEvent styEvent = styListener.getEvent(); 614 615 assertNotNull("StyledDocument should have fired an event", styEvent); 616 assertNotNull("OutputDocument should have fired an event", docEvent); 617 618 assertEventsIdentical (styled, doc, styEvent, docEvent); 619 620 for (int i = 0; i < 10; i++) { 622 for (int j=0; j < STRINGS.length; j++) { 623 styled.insertString(styled.getLength(), s + lineSeparator, SimpleAttributeSet.EMPTY); 624 ow.println (s); 625 ow.flush(); 626 627 640 styLen = styled.getLength(); 641 docLen = doc.getLength(); 642 643 assertTrue ("Length should be same, but OutputDocument length is " + 644 docLen + " and similar StyledDocument length is " + styLen, 645 doc.getLength() == styled.getLength()); 646 647 docEvent = docListener.getEvent(); 648 styEvent = styListener.getEvent(); 649 650 assertEventsIdentical (styled, doc, styEvent, docEvent); 651 652 } 653 } 654 655 } 656 657 private void assertEventsIdentical (Document styled, OutputDocument doc, DocumentEvent styEvent, DocumentEvent docEvent) throws Exception { 658 int docOffset = docEvent.getOffset(); 659 int styOffset = styEvent.getOffset(); 660 661 int docLength = docEvent.getLength(); 662 int styLength = styEvent.getLength(); 663 664 assertTrue ("OutputDocument event offset is " + docOffset + " but " + 665 "offset of identical change to a StyledDocument is " + styOffset, 666 docOffset == styOffset); 667 668 assertTrue ("OutputDocument event length is " + docLength + " but " + 669 "length from identical change to a StyledDocument is " + 670 styLength, styLength == docLength); 671 672 DocumentEvent.ElementChange docEc = docEvent.getChange(doc); 673 DocumentEvent.ElementChange styEc = styEvent.getChange(styled.getDefaultRootElement()); 674 675 int docIndex = docEc.getIndex(); 676 int styIndex = styEc.getIndex(); 677 678 Element [] docAdded = docEc.getChildrenAdded(); 679 Element [] styAdded = styEc.getChildrenAdded(); 680 681 assertTrue ("Index of change in OutputDocument was " + docIndex + " but" + 682 " an identical change on a StyledDocument returns " + styIndex, 683 styIndex == docIndex); 684 685 assertTrue ("OutputDocument returned an array of " + docAdded.length + 686 " affected elements, but an identical change on a StyledDocument " + 687 "produces an array of " + styAdded.length, styAdded.length == 688 docAdded.length); 689 690 for (int i=0; i < docAdded.length; i++) { 691 int docStartOffset = docAdded[i].getStartOffset(); 692 int styStartOffset = styAdded[i].getStartOffset(); 693 assertTrue ("Start offset of element " + i + " from " + 694 "OutputDocument.ODDEvent.EC is " + docStartOffset + " but " + 695 "offset from identical change in a StyledDocument is " + 696 styStartOffset, styStartOffset == docStartOffset); 697 698 int docEndOffset = docAdded[i].getEndOffset(); 699 int styEndOffset = styAdded[i].getEndOffset(); 700 assertTrue ("End offset of element " + i + " from " + 701 "OutputDocument.ODDEvent.EC is " + docStartOffset + " but " + 702 "offset from identical change in a StyledDocument is " + 703 styEndOffset, styEndOffset == docEndOffset); 704 705 String styTxt = styled.getText(styAdded[i].getStartOffset(), styAdded[i].getEndOffset() - styAdded[i].getStartOffset()); 706 String docTxt = styled.getText(styAdded[i].getStartOffset(), styAdded[i].getEndOffset() - styAdded[i].getStartOffset()); 707 assertEquals("Element " + i + " text from styled document is " + 708 styTxt + " but OutputDocument return " + docTxt + " for the " + 709 "same indices", styTxt, docTxt); 710 } 711 } 712 713 private String [] STRINGS = new String [] { 714 "Okay, we need some content for this test. I wonder what it should " + 715 "be? We should probably have some seriously long strings in here, " + 716 "just to make sure everythings okay. After all, we wouldn't want to" + 717 "lose a byte or two of output one day, that would be bad. But if " + 718 "everything works out, this thing might just be pretty cool, and " + 719 "efficient, and nifty, and all that stuff. Wouldn't that be nice?" + 720 " Of course it would be silly! Good heavens, I need a vacation.", 721 "This is a short, non-editorializing string", 722 "Should you get a chance to read it, David McCullough's biography of " + 723 "John Adams is quite good.", 724 "Short string", 725 "Okay, let's just go ahead and write another long string - after all, " + 726 "what else was I going to do with my time anyway? Did you ever consider" + 727 "what it would be like to *be* an output window? I mean really, whatever" + 728 "any body prints, you just display it on the front of you. Never " + 729 "complain, never get to be creative, never get to, say, write some " + 730 "POETRY, or turn that exception message into a nice haiku. I mean, " + 731 "once in a while it would be nice to let your hair down, after all - " + 732 "all this build failed stuff is just a collossal bore. C'mon, gimme some" + 733 "GOOD output for once", 734 "I'm sure there's an explanation for all of this. I just don't know" + 735 "what it is" 736 }; 737 738 protected boolean runInEQ() { 739 return true; 740 } 741 742 850 851 852 final class ODListener implements DocumentListener { 853 DocumentEvent evt = null; 854 855 public ODListener(){} 856 857 public ODListener (Document d) { 858 d.addDocumentListener(this); 859 } 860 861 public void assertChanged() { 862 DocumentEvent e = evt; 863 evt = null; 864 assertNotNull("No event received", e); 865 e.getLength(); 867 } 868 869 public void assertNoChange() { 870 DocumentEvent e = evt; 871 evt = null; 872 assertNull("Unexpected event was received " + e, e); 873 } 874 875 public DocumentEvent getEvent() { 876 return evt; 877 } 878 879 880 public void changedUpdate(DocumentEvent documentEvent) { 881 evt = documentEvent; 882 } 883 884 public void insertUpdate(DocumentEvent documentEvent) { 885 evt = documentEvent; 886 } 887 888 public void removeUpdate(DocumentEvent documentEvent) { 889 evt = documentEvent; 890 } 891 892 } 893 894 } 895 | Popular Tags |