This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 38218
Collapse All | Expand All

(-)CloneableEditorSupportTest.java (+39 lines)
Lines 166-171 Link Here
166
        assertGC ("Document can dissapear", ref);
166
        assertGC ("Document can dissapear", ref);
167
    }
167
    }
168
168
169
    public void testDocumentBeGarbageCollectedWhenNotModifiedButOpened () throws Exception {
170
        content = "Ahoj\nMyDoc";
171
        javax.swing.text.Document doc = support.openDocument ();
172
        assertNotNull (doc);
173
        
174
        java.lang.ref.WeakReference ref = new java.lang.ref.WeakReference (doc);
175
        doc = null;
176
        
177
        assertGC ("Document can dissapear", ref);
178
179
        assertFalse ("Document is not loaded", support.isDocumentLoaded ());
180
        assertTrue ("Can be closed without problems", support.close ());
181
    }
182
183
    public void testDocumentIsNotGCedIfModified () throws Exception {
184
        content = "Ahoj\nMyDoc";
185
        javax.swing.text.Document doc = support.openDocument ();
186
        assertNotNull (doc);
187
        doc.insertString (0, "Zmena", null);
188
        
189
        assertTrue ("Is modified", support.isModified ());
190
        
191
        java.lang.ref.WeakReference ref = new java.lang.ref.WeakReference (doc);
192
        doc = null;
193
194
        boolean ok;
195
        try {
196
            assertGC ("Should fail", ref);
197
            ok = false;
198
        } catch (AssertionFailedError expected) {
199
            ok = true;
200
        }
201
        if (!ok) {
202
            fail ("Document should not disappear, as it is modified");
203
        }
204
        
205
        assertTrue ("Document remains loaded", support.isDocumentLoaded ());
206
        
207
    }
169
    
208
    
170
    private void compareStreamWithString(InputStream is, String s) throws Exception{
209
    private void compareStreamWithString(InputStream is, String s) throws Exception{
171
        int i;
210
        int i;

Return to bug 38218