1 /*
2 * Copyright 2001-2004 (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.6 2004/06/25 08:03:47 maartenc Exp $
8 */
9
10 package org.dom4j;
11
12 import junit.framework.Test;
13 import junit.framework.TestSuite;
14 import junit.textui.TestRunner;
15
16 /*** A test harness to test the parent relationship and use of the
17 * {@link Node#asXPathResult} method.
18 *
19 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a>
20 * @version $Revision: 1.6 $
21 */
22 public class TestIsTextOnly extends AbstractTestCase {
23
24 public static void main( String[] args ) {
25 TestRunner.run( suite() );
26 }
27
28 public static Test suite() {
29 return new TestSuite( TestIsTextOnly.class );
30 }
31
32 public TestIsTextOnly(String name) {
33 super(name);
34 }
35
36 // Test case(s)
37 //-------------------------------------------------------------------------
38 public void testDocument() throws Exception {
39 DocumentFactory factory = new DocumentFactory();
40 Element root = factory.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://www.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-2004 (C) MetaStuff, Ltd. All Rights Reserved.
96 *
97 * $Id: TestIsTextOnly.java,v 1.6 2004/06/25 08:03:47 maartenc Exp $
98 */