KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > dom4j > TestNormalize


1 /*
2  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
3  *
4  * This software is open source.
5  * See the bottom of this file for the licence.
6  *
7  * $Id: TestNormalize.java,v 1.3 2003/04/07 22:24:33 jstrachan Exp $
8  */

9
10 package test.dom4j;
11
12 import junit.framework.Test;
13 import junit.framework.TestSuite;
14 import junit.textui.TestRunner;
15 import org.ozoneDB.xml.dom4j.O3DocumentHelper;
16
17 /** A test harness for the normalize() method
18   *
19   * @author <a HREF="mailto:jstrachan@apache.org">James Strachan</a>
20   * @version $Revision: 1.3 $
21   */

22 public class TestNormalize extends AbstractTestCase {
23
24     public static void main( String JavaDoc[] args ) {
25         TestRunner.run( suite() );
26     }
27
28     public static Test suite() {
29         return new TestSuite( TestNormalize.class );
30     }
31
32     public TestNormalize(String JavaDoc name) {
33         super(name);
34     }
35
36     // Test case(s)
37
//-------------------------------------------------------------------------
38
public void testNormalize() throws Exception JavaDoc {
39         String JavaDoc text = document.asXML();
40
41         document.normalize();
42
43         String JavaDoc normalizedText = document.asXML();
44
45         log( "Initial: " + text );
46         log( "Normalized: " + normalizedText );
47
48         String JavaDoc value = document.valueOf( "/dummy/full" );
49         assertEquals( "Should not trim text", " node ", value );
50     }
51
52
53     // Implementation methods
54
//-------------------------------------------------------------------------
55
protected void setUp() throws Exception JavaDoc {
56         document = O3DocumentHelper.parseText(
57             "<dummy> <full> node </full> with text <and>another node</and> </dummy>"
58         );
59     }
60 }
61
62
63
64
65 /*
66  * Redistribution and use of this software and associated documentation
67  * ("Software"), with or without modification, are permitted provided
68  * that the following conditions are met:
69  *
70  * 1. Redistributions of source code must retain copyright
71  * statements and notices. Redistributions must also contain a
72  * copy of this document.
73  *
74  * 2. Redistributions in binary form must reproduce the
75  * above copyright notice, this list of conditions and the
76  * following disclaimer in the documentation and/or other
77  * materials provided with the distribution.
78  *
79  * 3. The name "DOM4J" must not be used to endorse or promote
80  * products derived from this Software without prior written
81  * permission of MetaStuff, Ltd. For written permission,
82  * please contact dom4j-info@metastuff.com.
83  *
84  * 4. Products derived from this Software may not be called "DOM4J"
85  * nor may "DOM4J" appear in their names without prior written
86  * permission of MetaStuff, Ltd. DOM4J is a registered
87  * trademark of MetaStuff, Ltd.
88  *
89  * 5. Due credit should be given to the DOM4J Project
90  * (http://dom4j.org/).
91  *
92  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
93  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
94  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
95  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
96  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
97  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
98  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
99  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103  * OF THE POSSIBILITY OF SUCH DAMAGE.
104  *
105  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
106  *
107  * $Id: TestNormalize.java,v 1.3 2003/04/07 22:24:33 jstrachan Exp $
108  */

109
Popular Tags