|
1 |
| package photospace.graphics; |
|
2 |
| |
|
3 |
| import java.io.*; |
|
4 |
| import org.apache.commons.io.*; |
|
5 |
| import org.apache.commons.logging.*; |
|
6 |
| import junit.framework.*; |
|
7 |
| import photospace.vfs.*; |
|
8 |
| |
|
9 |
| public class ImageCacheTest |
|
10 |
| extends TestCase |
|
11 |
| { |
|
12 |
| private static final Log log = LogFactory.getLog(ImageCacheTest.class); |
|
13 |
| |
|
14 |
| File cacheRoot; |
|
15 |
| File fileRoot; |
|
16 |
| |
|
17 |
1
| public void setUp() throws Exception
|
|
18 |
| { |
|
19 |
1
| fileRoot = new File(System.getProperty("project.root"), "build/test/");
|
|
20 |
1
| cacheRoot = new File(System.getProperty("java.io.tmpdir"), "ImageCacheTest");
|
|
21 |
1
| cacheRoot.mkdirs();
|
|
22 |
| } |
|
23 |
| |
|
24 |
1
| public void tearDown() throws Exception
|
|
25 |
| { |
|
26 |
1
| FileUtils.forceDelete(cacheRoot);
|
|
27 |
| } |
|
28 |
| |
|
29 |
1
| public void testSync() throws Exception
|
|
30 |
| { |
|
31 |
1
| FileSystem filesystem = new FileSystemImpl();
|
|
32 |
1
| filesystem.setRoot(fileRoot);
|
|
33 |
| |
|
34 |
1
| ImageCache cache = new ImageCache();
|
|
35 |
1
| cache.setRoot(cacheRoot);
|
|
36 |
1
| cache.setFilesystem(filesystem);
|
|
37 |
| |
|
38 |
1
| File photo1 = filesystem.getAsset("/exif-nordf.jpg");
|
|
39 |
1
| File photo2 = filesystem.getAsset("/exif-rdf.jpg");
|
|
40 |
| |
|
41 |
1
| int count = cache.sync(new File[] { photo1, photo2 });
|
|
42 |
1
| assertEquals(2, count);
|
|
43 |
| |
|
44 |
1
| count = cache.sync(new File[] { photo1, photo2 });
|
|
45 |
1
| assertEquals(0, count);
|
|
46 |
| } |
|
47 |
| |
|
48 |
| } |