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

(-)a/masterfs/test/unit/src/org/netbeans/modules/masterfs/watcher/CyclicSymlinkTest.java (-48 / +26 lines)
Lines 39-68 Link Here
39
 *
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
41
 */
42
package org.netbeans.modules.masterfs.watcher;
42
package org.netbeans.modules.masterfs;
43
43
44
import java.io.File;
44
import java.io.File;
45
import java.io.IOException;
45
import java.io.IOException;
46
import java.io.InputStream;
46
import java.io.InputStream;
47
import java.util.Arrays;
47
import java.util.Arrays;
48
import java.util.Enumeration;
48
import org.netbeans.junit.NbTestCase;
49
import org.netbeans.junit.NbTestCase;
49
import org.openide.filesystems.*;
50
import org.openide.filesystems.*;
50
import org.openide.util.Exceptions;
51
import org.openide.util.Exceptions;
51
import org.openide.util.Utilities;
52
import org.openide.util.Utilities;
52
53
53
/** Check behavior of symlinks.
54
/** Check behavior of symlinks & getChildren(true).
54
 *
55
 *
55
 * @author Jaroslav Tulach <jtulach@netbeans.org>
56
 * @author Jaroslav Tulach <jtulach@netbeans.org>
56
 */
57
 */
57
public class CyclicSymlinkTest extends NbTestCase implements FileChangeListener {
58
public class CyclicSymlinkGetChildrenTest extends NbTestCase {
58
    private int cnt;
59
    private int cnt;
59
    private File lnk;
60
    private File lnk;
60
61
61
    public CyclicSymlinkTest(String name) {
62
    public CyclicSymlinkGetChildrenTest(String name) {
62
        super(name);
63
        super(name);
63
    }
64
    }
64
65
65
    @Override
66
    @Override
67
    protected int timeOut() {
68
        return 33333;
69
    }
70
71
    @Override
66
    protected void tearDown() throws Exception {
72
    protected void tearDown() throws Exception {
67
        if (lnk != null) {
73
        if (lnk != null) {
68
            lnk.delete();
74
            lnk.delete();
Lines 143-177 Link Here
143
        doAcyclicTesting(wd);
149
        doAcyclicTesting(wd);
144
    }
150
    }
145
151
146
    @Override
147
    public void fileFolderCreated(FileEvent fe) {
148
        throw new UnsupportedOperationException("Not supported yet.");
149
    }
150
151
    @Override
152
    public void fileDataCreated(FileEvent fe) {
153
        cnt++;
154
    }
155
156
    @Override
157
    public void fileChanged(FileEvent fe) {
158
        throw new UnsupportedOperationException("Not supported yet.");
159
    }
160
161
    @Override
162
    public void fileDeleted(FileEvent fe) {
163
    }
164
165
    @Override
166
    public void fileRenamed(FileRenameEvent fe) {
167
        throw new UnsupportedOperationException("Not supported yet.");
168
    }
169
170
    @Override
171
    public void fileAttributeChanged(FileAttributeEvent fe) {
172
        throw new UnsupportedOperationException("Not supported yet.");
173
    }
174
175
    private void assertCyclic(final File root) throws Exception {
152
    private void assertCyclic(final File root) throws Exception {
176
        File one = new File(root, "one");
153
        File one = new File(root, "one");
177
        File two = new File(one, "two");
154
        File two = new File(one, "two");
Lines 182-195 Link Here
182
        assertExec("Created OK", makeSymlink(up.toString(), three));
159
        assertExec("Created OK", makeSymlink(up.toString(), three));
183
        assertTrue("It is directory", lnk.isDirectory());
160
        assertTrue("It is directory", lnk.isDirectory());
184
        
161
        
185
        FileUtil.addRecursiveListener(this, one);
162
        FileObject rtf = FileUtil.toFileObject(root);
186
        
163
        Enumeration<? extends FileObject> en = rtf.getChildren(true);
187
        File newTxt = new File(two, "new.txt");
164
        int chldrn = 0;
188
        newTxt.createNewFile();
165
        while (en.hasMoreElements()) {
189
166
            FileObject n = en.nextElement();
190
        FileUtil.toFileObject(two).getFileSystem().refresh(true);
167
            chldrn++;
191
168
        }
192
        assertEquals("One data created event", 1, cnt);
169
        assertEquals("Five elements", 5, chldrn);
193
    }
170
    }
194
171
195
    private void assertAcyclic(final File root) throws Exception {
172
    private void assertAcyclic(final File root) throws Exception {
Lines 204-216 Link Here
204
        assertExec("Symlink is OK", makeSymlink( independent, three));
181
        assertExec("Symlink is OK", makeSymlink( independent, three));
205
        assertTrue("It is directory", lnk.isDirectory());
182
        assertTrue("It is directory", lnk.isDirectory());
206
        
183
        
207
        FileUtil.addRecursiveListener(this, one);
184
        FileObject rtf = FileUtil.toFileObject(one);
208
        File newTxt = new File(independent, "new.txt");
185
        Enumeration<? extends FileObject> en = rtf.getChildren(true);
209
        newTxt.createNewFile();
186
        int chldrn = 0;
210
187
        while (en.hasMoreElements()) {
211
        FileUtil.toFileObject(two).getFileSystem().refresh(true);
188
            FileObject n = en.nextElement();
212
189
            chldrn++;
213
        assertEquals("One data created event", 1, cnt);
190
        }
191
        assertEquals("Three elements left as children", 3, chldrn);
214
    }
192
    }
215
193
216
    private Process makeSymlink(File orig, File where) throws IOException {
194
    private Process makeSymlink(File orig, File where) throws IOException {

Return to bug 218795