1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.internal.xml

File DOMXMLWriterTest.java

 

Code metrics

0
15
1
1
63
29
1
0.07
15
1
1

Classes

Class Line # Actions
DOMXMLWriterTest 35 15 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software 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 GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.internal.xml;
21   
22    import java.io.IOException;
23   
24    import org.dom4j.Document;
25    import org.dom4j.dom.DOMDocument;
26    import org.dom4j.dom.DOMElement;
27    import org.junit.Assert;
28    import org.junit.Test;
29   
30    /**
31    * Tests for {@link DOMXMLWriter}.
32    *
33    * @version $Id: ad4904ef87d76841131635ea03bb77a5b3f7304f $
34    */
 
35    public class DOMXMLWriterTest
36    {
37    /**
38    * Before 3.0M2 there was a bug where write and writeOpen were reversed.
39    *
40    * @throws IOException
41    * @see "XWIKI-5937"
42    */
 
43  1 toggle @Test
44    public void writeVersusWriteOpen() throws IOException
45    {
46  1 Document doc = new DOMDocument();
47  1 DOMXMLWriter writer = new DOMXMLWriter(doc);
48  1 DOMElement e = new DOMElement("a");
49  1 writer.writeOpen(e);
50  1 writer.write(new DOMElement("b"));
51  1 writer.writeClose(e);
52  1 writer.close();
53  1 Assert.assertNotNull(doc.getRootElement().element("b"));
54   
55  1 doc = new DOMDocument();
56  1 writer = new DOMXMLWriter(doc);
57  1 e = new DOMElement("c");
58  1 writer.write(e);
59  1 writer.write(new DOMElement("d"));
60  1 writer.close();
61  1 Assert.assertNull(doc.getRootElement().element("d"));
62    }
63    }