diff --git a/masterfs/test/unit/src/org/netbeans/modules/masterfs/watcher/CyclicSymlinkTest.java b/masterfs/test/unit/src/org/netbeans/modules/masterfs/CyclicSymlinkGetChildrenTest.java copy from masterfs/test/unit/src/org/netbeans/modules/masterfs/watcher/CyclicSymlinkTest.java copy to masterfs/test/unit/src/org/netbeans/modules/masterfs/CyclicSymlinkGetChildrenTest.java --- a/masterfs/test/unit/src/org/netbeans/modules/masterfs/watcher/CyclicSymlinkTest.java +++ b/masterfs/test/unit/src/org/netbeans/modules/masterfs/CyclicSymlinkGetChildrenTest.java @@ -39,30 +39,36 @@ * * Portions Copyrighted 2012 Sun Microsystems, Inc. */ -package org.netbeans.modules.masterfs.watcher; +package org.netbeans.modules.masterfs; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; +import java.util.Enumeration; import org.netbeans.junit.NbTestCase; import org.openide.filesystems.*; import org.openide.util.Exceptions; import org.openide.util.Utilities; -/** Check behavior of symlinks. +/** Check behavior of symlinks & getChildren(true). * * @author Jaroslav Tulach */ -public class CyclicSymlinkTest extends NbTestCase implements FileChangeListener { +public class CyclicSymlinkGetChildrenTest extends NbTestCase { private int cnt; private File lnk; - public CyclicSymlinkTest(String name) { + public CyclicSymlinkGetChildrenTest(String name) { super(name); } @Override + protected int timeOut() { + return 33333; + } + + @Override protected void tearDown() throws Exception { if (lnk != null) { lnk.delete(); @@ -143,35 +149,6 @@ doAcyclicTesting(wd); } - @Override - public void fileFolderCreated(FileEvent fe) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void fileDataCreated(FileEvent fe) { - cnt++; - } - - @Override - public void fileChanged(FileEvent fe) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void fileDeleted(FileEvent fe) { - } - - @Override - public void fileRenamed(FileRenameEvent fe) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void fileAttributeChanged(FileAttributeEvent fe) { - throw new UnsupportedOperationException("Not supported yet."); - } - private void assertCyclic(final File root) throws Exception { File one = new File(root, "one"); File two = new File(one, "two"); @@ -182,14 +159,14 @@ assertExec("Created OK", makeSymlink(up.toString(), three)); assertTrue("It is directory", lnk.isDirectory()); - FileUtil.addRecursiveListener(this, one); - - File newTxt = new File(two, "new.txt"); - newTxt.createNewFile(); - - FileUtil.toFileObject(two).getFileSystem().refresh(true); - - assertEquals("One data created event", 1, cnt); + FileObject rtf = FileUtil.toFileObject(root); + Enumeration en = rtf.getChildren(true); + int chldrn = 0; + while (en.hasMoreElements()) { + FileObject n = en.nextElement(); + chldrn++; + } + assertEquals("Five elements", 5, chldrn); } private void assertAcyclic(final File root) throws Exception { @@ -204,13 +181,14 @@ assertExec("Symlink is OK", makeSymlink( independent, three)); assertTrue("It is directory", lnk.isDirectory()); - FileUtil.addRecursiveListener(this, one); - File newTxt = new File(independent, "new.txt"); - newTxt.createNewFile(); - - FileUtil.toFileObject(two).getFileSystem().refresh(true); - - assertEquals("One data created event", 1, cnt); + FileObject rtf = FileUtil.toFileObject(one); + Enumeration en = rtf.getChildren(true); + int chldrn = 0; + while (en.hasMoreElements()) { + FileObject n = en.nextElement(); + chldrn++; + } + assertEquals("Three elements left as children", 3, chldrn); } private Process makeSymlink(File orig, File where) throws IOException {