Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
20   104   10   2,5
0   52   0,5   8
8     1,25  
1    
 
  QedeqParserTest       Line # 28 20 10 85,7% 0.85714287
 
  (2)
 
1    /* $Id: QedeqParserTest.java,v 1.1 2008/07/26 08:01:08 m31 Exp $
2    *
3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
4    *
5    * Copyright 2000-2008, Michael Meyling <mime@qedeq.org>.
6    *
7    * "Hilbert II" is free software; you can redistribute
8    * it and/or modify it under the terms of the GNU General Public
9    * License as published by the Free Software Foundation; either
10    * version 2 of the License, or (at your option) any later version.
11    *
12    * This program is distributed in the hope that it will be useful,
13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15    * GNU General Public License for more details.
16    */
17    package org.qedeq.kernel.xml.parser;
18   
19    import org.qedeq.base.test.QedeqTestCase;
20    import org.qedeq.kernel.xml.handler.module.QedeqHandler;
21   
22    /**
23    * Tests the class {@link SaxParser}.
24    *
25    * @version $Revision: 1.1 $
26    * @author Michael Meyling
27    */
 
28    public class QedeqParserTest extends QedeqTestCase {
29   
30    /** Parser with default SAX document handler. */
31    private SaxParser parser1;
32   
33    /** Parser with application document handlers. */
34    private SaxParser parser2;
35   
 
36  2 toggle protected void setUp() throws Exception {
37  2 super.setUp();
38    {
39  2 SaxDefaultHandler handler = new SaxDefaultHandler();
40  2 AbstractSimpleHandler simple = new AbstractSimpleHandler(handler, null) {
41   
 
42  104 toggle public void startElement(final String name, final SimpleAttributes attributes) {
43    // System.out.println("<" + name + " " + attributes + ">");
44    }
45   
 
46  104 toggle public void endElement(final String name) {
47    // System.out.println("</" + name + ">");
48    // mime 20050205: for testing: throw new NullPointerException("");
49    }
50   
 
51  33 toggle public void characters(final String name, final String value) {
52    // System.out.println(value);
53    }
54   
 
55  1 toggle public void init() {
56    // do nothing
57    }
58   
59    };
60  2 handler.setBasisDocumentHandler(simple);
61  2 parser1 = new SaxParser(handler);
62    }
63    {
64  2 SaxDefaultHandler handler = new SaxDefaultHandler();
65  2 AbstractSimpleHandler simple = new QedeqHandler(handler);
66  2 handler.setBasisDocumentHandler(simple);
67  2 parser2 = new SaxParser(handler);
68    }
69    }
70   
 
71  2 toggle protected void tearDown() throws Exception {
72  2 parser1 = null;
73  2 parser2 = null;
74  2 super.tearDown();
75    }
76   
77    /**
78    * Test parsing with default SAX parser.
79    *
80    * @throws Exception Something bad happened.
81    */
 
82  1 toggle public void testParse1() throws Exception {
83  1 try {
84  1 parser1.parse(getFile("qedeq.xml"), getFile("qedeq.xml").toURL());
85    } catch (Exception e) {
86  0 System.err.println(e.getMessage());
87  0 throw e;
88    }
89    }
90   
91    /**
92    * Test parsing with application parser.
93    *
94    * @throws Exception Something bad happened.
95    */
 
96  1 toggle public void testParse2() throws Exception {
97  1 try {
98  1 parser2.parse(getFile("qedeq.xml"), getFile("qedeq.xml").toURL());
99    } catch (Exception e) {
100  0 System.err.println(e.getMessage());
101  0 throw e;
102    }
103    }
104    }