1 19 20 package org.openide.text; 21 22 import java.io.ByteArrayOutputStream ; 23 import java.io.IOException ; 24 import java.io.InputStream ; 25 import java.util.Arrays ; 26 import junit.framework.*; 27 28 import org.netbeans.junit.*; 29 30 import org.openide.util.Lookup; 31 import org.openide.util.RequestProcessor; 32 import org.openide.util.lookup.*; 33 34 35 39 public class NotifyModifiedOnNbEditorLikeKitTest extends NotifyModifiedTest { 40 private NbLikeEditorKit k; 41 42 public NotifyModifiedOnNbEditorLikeKitTest (String s) { 43 super (s); 44 } 45 46 50 protected javax.swing.text.EditorKit createEditorKit () { 51 NbLikeEditorKit k = new NbLikeEditorKit (); 52 return k; 53 } 54 55 protected void doesVetoedInsertFireBadLocationException (javax.swing.text.BadLocationException e) { 56 if (e == null) { 57 fail("Vetoed insert has to generate BadLocationException"); 58 } 59 } 60 61 private static RequestProcessor testRP = new RequestProcessor("Test"); 62 protected void checkThatDocumentLockIsNotHeld () { 63 class X implements Runnable { 64 private boolean second; 65 private boolean ok; 66 67 public void run () { 68 if (second) { 69 ok = true; 70 return; 71 } else { 72 second = true; 73 javax.swing.text.Document doc = support.getDocument (); 74 assertNotNull (doc); 75 doc.render (this); 77 78 if (ok) { 79 try { 80 doc.insertString (-1, "A", null); 82 ok = false; 83 } catch (javax.swing.text.BadLocationException ex) { 84 } 85 86 try { 87 doc.remove (-1, 1); 88 ok = false; 89 } catch (javax.swing.text.BadLocationException ex) { 90 } 91 } 92 93 return; 94 } 95 } 96 } 97 98 X x = new X (); 99 testRP.post (x).waitFinished (); 100 assertTrue ("No lock is held on document when running notifyModified", x.ok); 101 } 102 } 103 | Popular Tags |