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

COVERAGE SUMMARY FOR SOURCE FILE [JomicJSAPTest.java]

nameclass, %method, %block, %line, %
JomicJSAPTest.java100% (1/1)100% (9/9)92%  (119/130)97%  (34.8/36)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JomicJSAPTest100% (1/1)100% (9/9)92%  (119/130)97%  (34.8/36)
testPrintLicense (): void 100% (1/1)81%  (47/58)90%  (10.8/12)
JomicJSAPTest (): void 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (11/11)100% (4/4)
tearDown (): void 100% (1/1)100% (9/9)100% (4/4)
testErrorMutexOptions (): void 100% (1/1)100% (9/9)100% (3/3)
testNoOptions (): void 100% (1/1)100% (18/18)100% (5/5)
testOpenFile (): void 100% (1/1)100% (12/12)100% (3/3)
testPrintHelp (): void 100% (1/1)100% (5/5)100% (2/2)
testPrintVersion (): void 100% (1/1)100% (5/5)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.common;
17 
18import java.io.ByteArrayOutputStream;
19import java.io.IOException;
20import java.io.PrintStream;
21import java.util.Calendar;
22import java.util.GregorianCalendar;
23 
24import net.sf.jomic.tools.TestTools;
25 
26import com.martiansoftware.jsap.JSAPResult;
27 
28import junit.framework.TestCase;
29 
30/**
31 * @author    Thomas Aglassinger
32 */
33public class JomicJSAPTest extends TestCase
34{
35 
36    private JomicJSAP jsap;
37    private TestTools testTools;
38 
39    /*
40     *  @see TestCase#setUp()
41     */
42    protected void setUp()
43        throws Exception {
44        super.setUp();
45        testTools = TestTools.instance();
46        jsap = new JomicJSAP();
47    }
48 
49    public void testErrorMutexOptions() {
50        JSAPResult options = jsap.parse("--help test.cbz");
51 
52        assertFalse(options.success());
53    }
54 
55    public void testNoOptions() {
56        JSAPResult options = jsap.parse("");
57 
58        assertTrue(options.success());
59        options = jsap.parse(new String[]{});
60        assertTrue(options.success());
61    }
62 
63    public void testOpenFile() {
64        JSAPResult options = jsap.parse(testTools.getTestComicFile().getAbsolutePath());
65 
66        assertTrue(options.success());
67    }
68 
69    public void testPrintHelp() {
70        jsap.printHelp(System.out);
71    }
72 
73    public void testPrintLicense()
74        throws IOException {
75        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
76 
77        try {
78            PrintStream printStream = new PrintStream(byteStream);
79 
80            try {
81                jsap.printLicense(printStream);
82 
83                String licenseText = byteStream.toString();
84                int currentYear = new GregorianCalendar().get(Calendar.YEAR);
85                int currentYearIndexInLicense = licenseText.indexOf(Integer.toString(currentYear));
86 
87                assertTrue("license must contain current year: " + currentYear, currentYearIndexInLicense >= 0);
88            } finally {
89                printStream.close();
90            }
91        } finally {
92            byteStream.close();
93        }
94    }
95 
96    public void testPrintVersion() {
97        jsap.printVersion(System.out);
98    }
99 
100    /*
101     *  @see TestCase#tearDown()
102     */
103    protected void tearDown()
104        throws Exception {
105        jsap = null;
106        testTools = null;
107        super.tearDown();
108    }
109 
110}

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