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 223167
Collapse All | Expand All

(-)masterfs/test/unit/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FileObjTest.java (+48 lines)
Lines 46-51 Link Here
46
import java.io.File;
46
import java.io.File;
47
import java.io.IOException;
47
import java.io.IOException;
48
import java.io.OutputStream;
48
import java.io.OutputStream;
49
import java.util.Arrays;
50
import java.util.List;
49
import java.util.logging.Handler;
51
import java.util.logging.Handler;
50
import java.util.logging.Level;
52
import java.util.logging.Level;
51
import java.util.logging.LogRecord;
53
import java.util.logging.LogRecord;
Lines 57-62 Link Here
57
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileUtil;
60
import org.openide.filesystems.FileUtil;
59
import org.openide.util.Exceptions;
61
import org.openide.util.Exceptions;
62
import org.openide.util.Utilities;
60
63
61
/**
64
/**
62
 * 
65
 * 
Lines 174-177 Link Here
174
            f.setWritable(true);
177
            f.setWritable(true);
175
        }
178
        }
176
    }
179
    }
180
    
181
    public void testFileObjectForBrokenLinkWithGetChildren () throws Exception {
182
        if (!Utilities.isUnix()) {
183
            return;
184
        }
185
        doFileObjectForBrokenLink(true);
186
    }
187
    //    public void testFileObjectForBrokenLink() throws Exception {
188
    //        if (!Utilities.isUnix()) {
189
    //            return;
190
    //        }
191
    //        doFileObjectForBrokenLink(false);
192
    //    }
193
194
    private void doFileObjectForBrokenLink (boolean listFirst) throws Exception {
195
        clearWorkDir();
196
        File wd = new File(getWorkDir(), "wd");
197
        wd.mkdirs();
198
199
        File original = new File(wd, "original");
200
//            original.createNewFile();
201
        for (int i = 0; i < 2; ++i) {
202
            File lockFile = new File(wd, "wlock");
203
            lockFile.delete();
204
            FileUtil.toFileObject(wd).refresh();
205
            ProcessBuilder pb = new ProcessBuilder().directory(wd).command(
206
                    new String[]{"ln", "-s", original.getName(), lockFile.getName()});
207
            pb.start().waitFor();
208
            final List<String> names = Arrays.asList(lockFile.getParentFile().list());
209
            assertEquals("One file", 1, names.size());
210
            // file exists, or at least dir.listFiles lists the file
211
            assertTrue(names.contains(lockFile.getName()));
212
            // java.io.File.exists returns false
213
            assertFalse(lockFile.exists());
214
            if (listFirst) {
215
                FileObject root = FileUtil.toFileObject(wd);
216
                List<FileObject> arr = Arrays.asList(root.getChildren());
217
                assertEquals("One files: " + arr, 1, arr.size());
218
                assertEquals("Has the right name", lockFile.getName(), arr.get(0).getName());
219
            }
220
221
            // and no FileObject is reated for such a file
222
            assertNotNull(FileUtil.toFileObject(lockFile));
223
        }
224
    }
177
}
225
}
(-)masterfs/test/unit/src/org/netbeans/modules/masterfs/providers/ProvidedExtensionsTest.java (+33 lines)
Lines 338-344 Link Here
338
        fo.refresh();
338
        fo.refresh();
339
        assertEquals(1, iListener.implsCreatedExternallyCalls);
339
        assertEquals(1, iListener.implsCreatedExternallyCalls);
340
    }
340
    }
341
    
342
    public void testCreatedDeleteBrokenLinkExternally () throws Exception {
343
        FileObject fo = FileUtil.toFileObject(getWorkDir());
344
        FileObject[] children = fo.getChildren(); // scan folder
341
345
346
        FileObject folder = fo.createFolder("folder");
347
        iListener.clear();
348
        assertEquals(0, iListener.implsCreatedExternallyCalls);
349
        File f = new File(FileUtil.toFile(fo), "wlock");
350
        ProcessBuilder pb = new ProcessBuilder().directory(f.getParentFile()).command(new String[] { "ln", "-s", "doesnotexist", f.getName() });
351
        pb.start().waitFor();
352
        assertEquals(0, iListener.implsCreatedExternallyCalls);
353
        fo.refresh();
354
        assertEquals(1, iListener.implsCreatedExternallyCalls);
355
        iListener.clear();
356
        f.delete();
357
        assertEquals(0, iListener.implsDeletedExternallyCalls);
358
        fo.refresh();
359
        assertEquals(1, iListener.implsDeletedExternallyCalls);
360
        
361
        // let's try once more, now it starts failing
362
        pb = new ProcessBuilder().directory(f.getParentFile()).command(new String[] { "ln", "-s", "doesnotexist", f.getName() });
363
        pb.start().waitFor();
364
        iListener.clear();
365
        assertEquals(0, iListener.implsCreatedExternallyCalls);
366
        fo.refresh();
367
        assertEquals(1, iListener.implsCreatedExternallyCalls);
368
        iListener.clear();
369
        f.delete();
370
        assertEquals(0, iListener.implsDeletedExternallyCalls);
371
        fo.refresh();
372
        assertEquals(1, iListener.implsDeletedExternallyCalls);
373
    }
374
342
    public void testDeletedExternally() throws IOException {
375
    public void testDeletedExternally() throws IOException {
343
        FileObject fo = FileUtil.toFileObject(getWorkDir());
376
        FileObject fo = FileUtil.toFileObject(getWorkDir());
344
        FileObject file = fo.createData("file");
377
        FileObject file = fo.createData("file");

Return to bug 223167