EMMA Coverage Report (generated Sat Oct 08 11:41:37 CEST 2011)
[all classes][net.sf.jomic.comic]

COVERAGE SUMMARY FOR SOURCE FILE [ExtractComicTaskTest.java]

nameclass, %method, %block, %line, %
ExtractComicTaskTest.java100% (1/1)100% (8/8)66%  (139/211)75%  (33.1/44)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExtractComicTaskTest100% (1/1)100% (8/8)66%  (139/211)75%  (33.1/44)
testExtractInternalError (): void 100% (1/1)14%  (11/76)23%  (3.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-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/>.
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 org.apache.commons.logging.Log;
27import org.apache.commons.logging.LogFactory;
28 
29import junit.framework.TestCase;
30 
31/**
32 *  TestCase for ExtractZipTask.
33 *
34 * @author    Thomas Aglassinger
35 */
36public class ExtractComicTaskTest extends TestCase
37{
38    private FileTools fileTools;
39    private Log logger;
40    private ProgressFrame progressFrame;
41    private StringTools stringTools;
42    private TestTools testTools;
43 
44    protected void setUp()
45        throws Exception {
46        super.setUp();
47        logger = LogFactory.getLog(ExtractComicTaskTest.class);
48        testTools = TestTools.instance();
49        fileTools = FileTools.instance();
50        stringTools = StringTools.instance();
51        progressFrame = new ProgressFrame();
52        progressFrame.setTitle(getClass().getName());
53    }
54 
55    public void testExtractCbr()
56        throws Exception {
57        testExtract(testTools.getTestFile(TestTools.TEST_COMIC_CBR));
58    }
59 
60    public void testExtractCbz()
61        throws Exception {
62        testExtract(testTools.getTestFile(TestTools.TEST_COMIC_CBZ));
63    }
64 
65    public void testExtractInternalError()
66        throws Exception {
67        String method = "testExtractInternalError";
68        File zipFile = testTools.getTestFile(TestTools.TEST_COMIC_INTERNAL_ERROR);
69        File targetFolder = testTools.getTestOutputFile(getClass().getName() + "." + method);
70 
71        progressFrame.setVisible(true);
72        progressFrame.setNote(method);
73 
74        Task extractZipTask = new ExtractComicTask(zipFile, targetFolder);
75 
76        try {
77            extractZipTask.start();
78            fail("broken archive must cause error: " + zipFile);
79        } catch (ZipException error) {
80            if (logger.isDebugEnabled()) {
81                logger.debug("ignoring expected error", error);
82            }
83        } finally {
84            progressFrame.setVisible(false);
85        }
86    }
87 
88    public void testExtractPdf()
89        throws Exception {
90        testExtract(testTools.getTestFile(TestTools.TEST_COMIC_PDF));
91    }
92 
93    protected void tearDown()
94        throws Exception {
95        progressFrame.dispose();
96        super.tearDown();
97    }
98 
99    private void testExtract(File comicFile)
100        throws Exception {
101        String comicSuffix = fileTools.getSuffix(comicFile);
102        String method = "testExtract" + stringTools.titled(comicSuffix);
103        File targetFolder = testTools.getTestOutputFile(getClass().getName() + "." + method);
104 
105        progressFrame.setVisible(true);
106        progressFrame.setNote(method);
107 
108        Task extractZipTask = new ExtractComicTask(comicFile, targetFolder);
109 
110        fileTools.attemptToDeleteAll(targetFolder, logger);
111        try {
112            extractZipTask.start();
113            assertTrue(targetFolder.exists());
114        } finally {
115            progressFrame.setVisible(false);
116        }
117    }
118}

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