KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > loaders > FolderListTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.openide.loaders;
22
23 import java.util.logging.Level JavaDoc;
24 import junit.framework.*;
25 import java.beans.PropertyChangeListener JavaDoc;
26 import java.beans.PropertyChangeSupport JavaDoc;
27 import java.lang.ref.SoftReference JavaDoc;
28 import java.lang.ref.WeakReference JavaDoc;
29 import java.lang.ref.Reference JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.util.*;
32 import org.netbeans.junit.NbTestCase;
33 import org.openide.ErrorManager;
34 import org.openide.util.datatransfer.*;
35 import org.openide.filesystems.*;
36 import org.openide.util.*;
37
38 /** Tests for internals of FolderList as there seems to be some
39  * inherent problems.
40  *
41  * @author Jaroslav Tulach
42  */

43 public class FolderListTest extends NbTestCase {
44     private FileObject folder;
45     private FolderList list;
46     
47     
48     public FolderListTest(String JavaDoc testName) {
49         super(testName);
50     }
51     
52     protected Level JavaDoc logLevel() {
53         return Level.FINE;
54     }
55
56     protected void setUp() throws Exception JavaDoc {
57         clearWorkDir();
58         
59         LocalFileSystem lfs = new LocalFileSystem();
60         lfs.setRootDirectory(getWorkDir());
61         
62         folder = FileUtil.createFolder(lfs.getRoot(), "folder");
63
64         FileUtil.createData(folder, "A.txt");
65         FileUtil.createData(folder, "B.txt");
66         FileUtil.createData(folder, "C.txt");
67         
68         list = FolderList.find(folder, true);
69     }
70
71     protected void tearDown() throws Exception JavaDoc {
72     }
73
74     public void testComputeChildrenList() throws Exception JavaDoc {
75         class L implements FolderListListener {
76             private int cnt;
77             private boolean finished;
78             
79             public void process(DataObject obj, List arr) {
80                 cnt++;
81             }
82
83             public void finished(List arr) {
84                 assertTrue(arr.isEmpty());
85                 finished = true;
86             }
87         }
88         
89         L listener = new L();
90         RequestProcessor.Task t = list.computeChildrenList(listener);
91         t.waitFinished();
92         
93         assertEquals("Three files", 3, listener.cnt);
94         assertTrue("finished", listener.finished);
95     }
96     
97 }
98
Popular Tags