|
1 |
| package photospace.vfs; |
|
2 |
| |
|
3 |
| import java.io.*; |
|
4 |
| import org.apache.commons.io.*; |
|
5 |
| import org.apache.commons.logging.*; |
|
6 |
| import junit.framework.*; |
|
7 |
| import photospace.meta.*; |
|
8 |
| |
|
9 |
| public class BrowserTest |
|
10 |
| extends TestCase |
|
11 |
| { |
|
12 |
| private static final Log log = LogFactory.getLog(BrowserTest.class); |
|
13 |
| |
|
14 |
| FileSystem filesystem; |
|
15 |
| FileSystemBrowser browser; |
|
16 |
| |
|
17 |
3
| public void setUp() throws Exception
|
|
18 |
| { |
|
19 |
3
| File root = new File(System.getProperty("java.io.tmpdir"), "BrowserTest");
|
|
20 |
3
| File subdir = new File(root, "subdir");
|
|
21 |
3
| subdir.mkdirs();
|
|
22 |
3
| File photo = new File(System.getProperty("project.root"), "build/test/exif-nordf.jpg");
|
|
23 |
3
| FileUtils.copyFileToDirectory(photo, root);
|
|
24 |
3
| FileUtils.copyFileToDirectory(photo, subdir);
|
|
25 |
| |
|
26 |
3
| filesystem = new FileSystemImpl();
|
|
27 |
3
| filesystem.setRoot(root);
|
|
28 |
| |
|
29 |
3
| PersisterImpl persister = new PersisterImpl();
|
|
30 |
3
| persister.setFilesystem(filesystem);
|
|
31 |
3
| persister.setTranslator(new Translator());
|
|
32 |
| |
|
33 |
3
| browser = new FileSystemBrowser();
|
|
34 |
3
| browser.setFilesystem(filesystem);
|
|
35 |
3
| browser.setPersister(persister);
|
|
36 |
| } |
|
37 |
| |
|
38 |
3
| public void tearDown() throws Exception
|
|
39 |
| { |
|
40 |
3
| FileUtils.deleteDirectory(filesystem.getRoot());
|
|
41 |
| } |
|
42 |
| |
|
43 |
1
| public void testBrowse() throws Exception
|
|
44 |
| { |
|
45 |
1
| FolderMeta dir = browser.browse("/", 1);
|
|
46 |
1
| assertFalse(dir.getFiles().length == 0);
|
|
47 |
1
| assertFalse(dir.getPhotos().length == 0);
|
|
48 |
1
| assertFalse(dir.getFolders().length == 0);
|
|
49 |
| } |
|
50 |
| |
|
51 |
1
| public void testBrowseShallow() throws Exception
|
|
52 |
| { |
|
53 |
1
| FolderMeta dir = browser.browse("/", 0);
|
|
54 |
1
| assertTrue(dir.getFiles().length == 0);
|
|
55 |
| } |
|
56 |
| |
|
57 |
1
| public void testBrowseDeep() throws Exception
|
|
58 |
| { |
|
59 |
1
| FolderMeta dir = browser.browse("/", -1);
|
|
60 |
1
| assertFalse(dir.getFiles().length == 0);
|
|
61 |
| } |
|
62 |
| |
|
63 |
| |
|
64 |
| } |