Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
65   151   5   13
0   112   0.08   5
5     1  
1    
 
  StringOutputTest       Line # 26 65 5 100% 1.0
 
  (3)
 
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   
16    package org.qedeq.base.io;
17   
18    import org.qedeq.base.test.QedeqTestCase;
19    import org.qedeq.base.utility.StringUtility;
20   
21    /**
22    * Test {@link StringOutput}.
23    *
24    * @author Michael Meyling
25    */
 
26    public class StringOutputTest extends QedeqTestCase {
27   
28    private static final String XML_DATA =
29    /* 1 */ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
30    /* 2 */ + "<QEDEQ \n"
31    /* 3 */ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
32    /* 4 */ + " xsi:noNamespaceSchemaLocation=\"http://www.qedeq.org/0_01_06/xml/qedeq.xsd\">\n"
33    /* 5 */ + " <HEADER email=\"mime@qedeq.org\">\n"
34    /* 6 */ + " <SPEC name=\"qedeq_sample1\" ruleVersion=\"1.00.00\">\n"
35    /* 7 */ + " <LOCATIONS>\n"
36    /* 8 */ + " \t\r <LOCATION value=\"http://qedeq.org/0.01.06/sample1\"/>\n"
37    /* 9 */ + " </LOCATIONS>\n"
38    /* 10 */ + " </SPEC>\n"
39    /* 11 */ + " <TITLE>\n"
40    /* 12 */ + " <LATEX language=\"en\">\n"
41    /* 13 */ + " Example1\n"
42    /* 14 */ + " </LATEX>\n"
43    /* 15 */ + " </TITLE>\n"
44    /* 16 */ + " <ABSTRACT>\n"
45    /* 17 */ + " <LATEX language=\"en\">\n"
46    /* 18 */ + " 1789.01239In this very first qedeq module the XML specification is demonstrated.\n"
47    /* 19 */ + " </LATEX>\n"
48    /* 20 */ + " </ABSTRACT>\n"
49    /* 21 */ + " <AUTHORS>\n"
50    /* 22 */ + " <AUTHOR email=\"michael@meyling.com\">\n"
51    /* 23 */ + " <LATEX language=\"de\">\n"
52    /* 24 */ + " <![CDATA[Michael Meyling]]>\n"
53    /* 25 */ + " </LATEX>\n"
54    /* 26 */ + " </AUTHOR>\n"
55    /* 27 */ + " </AUTHORS>\n"
56    /* 28 */ + " </HEADER>\n"
57    /* 29 */ + "</QEDEQ>\n";
58   
 
59  3 toggle protected void setUp() throws Exception {
60  3 super.setUp();
61    }
62   
 
63  3 toggle protected void tearDown() throws Exception {
64  3 super.tearDown();
65    }
66   
67    /**
68    * Test various print methods.
69    *
70    * @throws Exception Test failed.
71    */
 
72  1 toggle public void testComplete() throws Exception {
73  1 final AbstractOutput out = new StringOutput();
74  1 out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
75  1 out.println("<QEDEQ ");
76  1 out.pushLevel();
77  1 out.pushLevel();
78  1 out.print("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
79  1 out.println();
80  1 out.println("xsi:noNamespaceSchemaLocation=\"http://www.qedeq.org/0_01_06/xml/qedeq.xsd\">");
81  1 out.popLevel();
82  1 out.println("<HEADER email=\"mime@qedeq.org\">");
83  1 out.pushLevel();
84  1 out.print("<SPEC name=\"qedeq_sample1\" ruleVersion=\"1.00.00\">");
85  1 out.print("\n");
86  1 out.pushLevel();
87  1 out.println("<LOCATIONS>");
88  1 out.print((Object) ("\t\r <LOCATION value=\"http://qedeq.org/0.01.06/sample1\"/>"
89    + "\n"));
90  1 out.println("</LOCATIONS>");
91  1 out.popLevel();
92  1 out.println("</SPEC>");
93  1 out.println("<TITLE>");
94  1 out.pushLevel();
95  1 out.println("<LATEX language=\"en\">");
96  1 out.println(" Example1");
97  1 out.println("</LATEX>");
98  1 out.popLevel();
99  1 out.println("</TITLE>");
100  1 out.println("<ABSTRACT>");
101  1 out.pushLevel();
102  1 out.println("<LATEX language=\"en\">");
103  1 out.pushLevel();
104  1 out.println(" 1789.01239In this very first qedeq module the XML specification is demonstrated.");
105  1 out.popLevel();
106  1 out.println("</LATEX>");
107  1 out.popLevel();
108  1 out.println("</ABSTRACT>");
109  1 out.println("<AUTHORS>");
110  1 out.pushLevel();
111  1 out.println("<AUTHOR email=\"michael@meyling.com\">");
112  1 out.pushLevel();
113  1 out.println("<LATEX language=\"de\">");
114  1 out.pushLevel();
115  1 out.println(" <![CDATA[Michael Meyling]]>");
116  1 out.popLevel();
117  1 out.println("</LATEX>");
118  1 out.popLevel();
119  1 out.println("</AUTHOR>");
120  1 out.popLevel();
121  1 out.println("</AUTHORS>");
122  1 out.println((Object) " </HEADER>");
123  1 out.pushLevel();
124  1 out.clearLevel();
125  1 out.println("</QEDEQ>");
126   
127  1 assertEquals(StringUtility.string2Hex(XML_DATA),
128    StringUtility.byte2Hex(out.toString().getBytes()));
129   
130  1 assertEquals(XML_DATA, out.toString());
131   
132    // System.out.println(to.toString());
133    }
134   
 
135  1 toggle public void testGetPosition() {
136  1 final AbstractOutput out = new StringOutput();
137  1 out.pushLevel();
138  1 out.print("James Bond");
139  1 assertEquals(" James Bond".length(), out.getPosition());
140    }
141   
 
142  1 toggle public void testPushPop() throws Exception {
143  1 final AbstractOutput out = new StringOutput();
144  1 out.popLevel();
145  1 out.popLevel();
146  1 out.print("James Bond");
147  1 assertEquals("James Bond", out.toString());
148    }
149   
150    }
151