EMMA Coverage Report (generated Sun Apr 20 22:38:01 CEST 2008)
[all classes][net.sf.jomic.comic]

COVERAGE SUMMARY FOR SOURCE FILE [ExtractComicTaskTest.java]

nameclass, %method, %block, %line, %
ExtractComicTaskTest.java100% (1/1)100% (8/8)68%  (144/211)77%  (34.1/44)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExtractComicTaskTest100% (1/1)100% (8/8)68%  (144/211)77%  (34.1/44)
testExtractInternalError (): void 100% (1/1)21%  (16/76)30%  (4.2/14)
testExtract (File): void 100% (1/1)90%  (64/71)99%  (11.9/12)
ExtractComicTaskTest (): void 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (34/34)100% (8/8)
tearDown (): void 100% (1/1)100% (6/6)100% (3/3)
testExtractCbr (): void 100% (1/1)100% (7/7)100% (2/2)
testExtractCbz (): void 100% (1/1)100% (7/7)100% (2/2)
testExtractPdf (): void 100% (1/1)100% (7/7)100% (2/2)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2008 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/>.
16package net.sf.jomic.comic;
17 
18import java.io.File;
19import java.util.zip.ZipException;
20 
21import net.sf.jomic.tools.FileTools;
22import net.sf.jomic.tools.ProgressFrame;
23import net.sf.jomic.tools.StringTools;
24import net.sf.jomic.tools.Task;
25import net.sf.jomic.tools.TestTools;
26import net.sf.wraplog.Logger;
27 
28import junit.framework.TestCase;
29 
30/**
31 *  TestCase for ExtractZipTask.
32 *
33 * @author    Thomas Aglassinger
34 */
35public class ExtractComicTaskTest extends TestCase
36{
37    private FileTools fileTools;
38    private Logger logger;
39    private ProgressFrame progressFrame;
40    private StringTools stringTools;
41    private TestTools testTools;
42 
43    protected void setUp()
44        throws Exception {
45        super.setUp();
46        logger = Logger.getLogger(ExtractComicTaskTest.class);
47        testTools = TestTools.instance();
48        fileTools = FileTools.instance();
49        stringTools = StringTools.instance();
50        progressFrame = new ProgressFrame();
51        progressFrame.setTitle(getClass().getName());
52    }
53 
54    public void testExtractCbr()
55        throws Exception {
56        testExtract(testTools.getTestFile(TestTools.TEST_COMIC_CBR));
57    }
58 
59    public void testExtractCbz()
60        throws Exception {
61        testExtract(testTools.getTestFile(TestTools.TEST_COMIC_CBZ));
62    }
63 
64    public void testExtractInternalError()
65        throws Exception {
66        String method = "testExtractInternalError";
67        File zipFile = testTools.getTestFile(TestTools.TEST_COMIC_INTERNAL_ERROR);
68        File targetFolder = testTools.getTestOutputFile(getClass().getName() + "." + method);
69 
70        progressFrame.setVisible(true);
71        progressFrame.setNote(method);
72 
73        Task extractZipTask = new ExtractComicTask(zipFile, targetFolder);
74 
75        try {
76            extractZipTask.start();
77            fail("broken archive must cause error: " + zipFile);
78        } catch (ZipException error) {
79            if (logger.isDebugEnabled()) {
80                logger.debug("ignoring expected error", error);
81            }
82        } finally {
83            progressFrame.setVisible(false);
84        }
85    }
86 
87    public void testExtractPdf()
88        throws Exception {
89        testExtract(testTools.getTestFile(TestTools.TEST_COMIC_PDF));
90    }
91 
92    protected void tearDown()
93        throws Exception {
94        progressFrame.dispose();
95        super.tearDown();
96    }
97 
98    private void testExtract(File comicFile)
99        throws Exception {
100        String comicSuffix = fileTools.getSuffix(comicFile);
101        String method = "testExtract" + stringTools.titled(comicSuffix);
102        File targetFolder = testTools.getTestOutputFile(getClass().getName() + "." + method);
103 
104        progressFrame.setVisible(true);
105        progressFrame.setNote(method);
106 
107        Task extractZipTask = new ExtractComicTask(comicFile, targetFolder);
108 
109        fileTools.attemptToDeleteAll(targetFolder, logger);
110        try {
111            extractZipTask.start();
112            assertTrue(targetFolder.exists());
113        } finally {
114            progressFrame.setVisible(false);
115        }
116    }
117}

[all classes][net.sf.jomic.comic]
EMMA 2.0.4217 (C) Vladimir Roubtsov