Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
20   106   10   2.5
0   56   0.5   8
8     1.25  
1    
 
  QedeqParserTest       Line # 30 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-2013, 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.bo.test.DummyPlugin;
19    import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
20    import org.qedeq.kernel.xml.handler.common.SaxDefaultHandler;
21    import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
22    import org.qedeq.kernel.xml.handler.module.QedeqHandler;
23   
24    /**
25    * Tests the class {@link SaxParser}.
26    *
27    * @version $Revision: 1.1 $
28    * @author Michael Meyling
29    */
 
30    public class QedeqParserTest extends QedeqTestCase {
31   
32    /** Parser with default SAX document handler. */
33    private SaxParser parser1;
34   
35    /** Parser with application document handlers. */
36    private SaxParser parser2;
37   
 
38  2 toggle protected void setUp() throws Exception {
39  2 super.setUp();
40    {
41  2 SaxDefaultHandler handler = new SaxDefaultHandler(new DummyPlugin());
42  2 AbstractSimpleHandler simple = new AbstractSimpleHandler(handler, null) {
43   
 
44  105 toggle public void startElement(final String name, final SimpleAttributes attributes) {
45    // System.out.println("<" + name + " " + attributes + ">");
46    }
47   
 
48  105 toggle public void endElement(final String name) {
49    // System.out.println("</" + name + ">");
50    // mime 20050205: for testing: throw new NullPointerException("");
51    }
52   
 
53  33 toggle public void characters(final String name, final String value) {
54    // System.out.println(value);
55    }
56   
 
57  1 toggle public void init() {
58    // do nothing
59    }
60   
61    };
62  2 handler.setBasisDocumentHandler(simple);
63  2 parser1 = new SaxParser(DummyPlugin.getInstance(), handler);
64    }
65    {
66  2 SaxDefaultHandler handler = new SaxDefaultHandler(new DummyPlugin());
67  2 AbstractSimpleHandler simple = new QedeqHandler(handler);
68  2 handler.setBasisDocumentHandler(simple);
69  2 parser2 = new SaxParser(DummyPlugin.getInstance(), handler);
70    }
71    }
72   
 
73  2 toggle protected void tearDown() throws Exception {
74  2 parser1 = null;
75  2 parser2 = null;
76  2 super.tearDown();
77    }
78   
79    /**
80    * Test parsing with default SAX parser.
81    *
82    * @throws Exception Something bad happened.
83    */
 
84  1 toggle public void testParse1() throws Exception {
85  1 try {
86  1 parser1.parse(getFile("qedeq.xml"), getFile("qedeq.xml").toURL().toString());
87    } catch (Exception e) {
88  0 e.printStackTrace(System.out);
89  0 throw e;
90    }
91    }
92   
93    /**
94    * Test parsing with application parser.
95    *
96    * @throws Exception Something bad happened.
97    */
 
98  1 toggle public void testParse2() throws Exception {
99  1 try {
100  1 parser2.parse(getFile("qedeq.xml"), getFile("qedeq.xml").toURL().toString());
101    } catch (Exception e) {
102  0 e.printStackTrace(System.out);
103  0 throw e;
104    }
105    }
106    }