1 19 20 21 package org.openide.text; 22 23 24 import java.io.ByteArrayOutputStream ; 25 import java.io.File ; 26 import java.io.IOException ; 27 import javax.swing.text.*; 28 import javax.swing.text.BadLocationException ; 29 import javax.swing.text.Document ; 30 import javax.swing.text.Position ; 31 import javax.swing.text.StyledDocument ; 32 33 import junit.textui.TestRunner; 34 35 import org.netbeans.junit.NbTestCase; 36 import org.netbeans.junit.NbTestSuite; 37 38 import org.openide.text.CloneableEditorSupport; 39 import org.openide.text.FilterDocument; 40 import org.openide.text.NbDocument; 41 import org.openide.util.RequestProcessor; 42 43 49 public class Deadlock47515Test extends NbTestCase implements CloneableEditorSupport.Env { 50 private Object myPrivateLock = new Object (); 51 52 53 private CES support; 54 private String content = "Hello"; 56 private boolean valid = true; 57 private boolean modified = false; 58 59 private java.util.Date date = new java.util.Date (); 60 private java.util.List propL = new java.util.ArrayList (); 61 private java.beans.VetoableChangeListener vetoL; 62 63 64 public Deadlock47515Test(String s) { 65 super(s); 66 } 67 68 public static void main(String [] args) { 69 TestRunner.run(new NbTestSuite(Deadlock47515Test.class)); 70 } 71 72 protected void setUp () { 73 support = new CES (this, org.openide.util.Lookup.EMPTY); 74 } 75 76 public void testDeadlock47515() throws Exception { 77 synchronized(myPrivateLock) { 78 try { 79 support.openDocument(); 80 } catch (IOException ioe) { 81 } 83 } 84 } 85 86 87 91 public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener l) { 92 propL.add (l); 93 } 94 public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener l) { 95 propL.remove (l); 96 } 97 98 public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener l) { 99 assertNull ("This is the first veto listener", vetoL); 100 vetoL = l; 101 } 102 public void removeVetoableChangeListener(java.beans.VetoableChangeListener l) { 103 assertEquals ("Removing the right veto one", vetoL, l); 104 vetoL = null; 105 } 106 107 public org.openide.windows.CloneableOpenSupport findCloneableOpenSupport() { 108 return support; 109 } 110 111 public String getMimeType() { 112 return "text/plain"; 113 } 114 115 public java.util.Date getTime() { 116 return date; 117 } 118 119 public java.io.InputStream inputStream() throws java.io.IOException { 120 throw new IOException ("Can't load"); 121 } 122 public java.io.OutputStream outputStream() throws java.io.IOException { 123 return new ByteArrayOutputStream (); 124 } 125 126 public boolean isValid() { 127 return valid; 128 } 129 130 public boolean isModified() { 131 return modified; 132 } 133 134 public void markModified() throws java.io.IOException { 135 modified = true; 136 } 137 138 public void unmarkModified() { 139 modified = false; 140 } 141 142 143 private final class CES extends CloneableEditorSupport { 144 145 public CES (Env env, org.openide.util.Lookup l) { 146 super (env, l); 147 } 148 149 protected String messageName() { 150 synchronized(myPrivateLock) { 151 return "Name"; 152 } 153 } 154 155 protected String messageOpened() { 156 return "Opened"; 157 } 158 159 protected String messageOpening() { 160 return "Opening"; 161 } 162 163 protected String messageSave() { 164 return "Save"; 165 } 166 167 protected String messageToolTip() { 168 return "ToolTip"; 169 } 170 171 172 } } 174 | Popular Tags |