1 | // Jomic - a viewer for comic book archives. |
2 | // Copyright (C) 2004-2011 Thomas Aglassinger |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | package net.sf.jomic.tests; |
17 | |
18 | import java.io.File; |
19 | import java.io.IOException; |
20 | |
21 | import junit.framework.TestCase; |
22 | import net.sf.jomic.Jomic; |
23 | import net.sf.jomic.comic.ComicModel; |
24 | import net.sf.jomic.common.JomicJSAP; |
25 | import net.sf.jomic.common.PropertyConstants; |
26 | import net.sf.jomic.common.Settings; |
27 | import net.sf.jomic.tools.TestTools; |
28 | |
29 | /** |
30 | * TestCase for command line option "--clear-cache". |
31 | * |
32 | * @author Thomas Aglassinger |
33 | */ |
34 | public class JomicCliClearCacheTest extends TestCase |
35 | { |
36 | private TestTools testTools; |
37 | |
38 | protected void setUp() |
39 | throws Exception { |
40 | super.setUp(); |
41 | testTools = TestTools.instance(); |
42 | } |
43 | |
44 | public void testClearCache() |
45 | throws IOException, InterruptedException { |
46 | testTools.setupCache(); |
47 | |
48 | File cacheDir = Settings.instance().getCacheDir(); |
49 | String cacheDirPath = cacheDir.getAbsolutePath(); |
50 | |
51 | ComicModel comicModel = new ComicModel(testTools.getTestComicFile()); |
52 | |
53 | comicModel.dispose(); |
54 | assertTrue(cacheDir.exists()); |
55 | |
56 | testTools.setupTestSettings(JomicCliClearCacheTest.class, "testClearCache", |
57 | new String[]{PropertyConstants.CACHE_DIR, cacheDirPath}); |
58 | System.setProperty(PropertyConstants.TEST_IGNORE_EXIT, Boolean.TRUE.toString()); |
59 | |
60 | Jomic.main(new String[]{"--" + JomicJSAP.ARG_CLEAR_CACHE}); |
61 | |
62 | assertFalse(cacheDir.exists()); |
63 | } |
64 | |
65 | protected void tearDown() |
66 | throws Exception { |
67 | testTools = null; |
68 | super.tearDown(); |
69 | } |
70 | } |