KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > dom4j > TestIsTextOnly


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: TestIsTextOnly.java,v 1.2 2003/11/02 18:31:28 per_nyfelt 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.dom4j.Element;
16
17 /** A test harness to test the parent relationship and use of the
18   * {@link org.dom4j.Node#asXPathResult} method.
19   *
20   * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan</a>
21   * @version $Revision: 1.2 $
22   */

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

99
Popular Tags