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