KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > dom4j > TestGetQNames


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: TestGetQNames.java,v 1.3 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.Document;
16 import org.dom4j.Element;
17 import org.dom4j.QName;
18 import org.dom4j.io.SAXReader;
19 import org.ozoneDB.xml.dom4j.O3DocumentHelper;
20 import org.ozoneDB.xml.dom4j.OzoneDocumentFactory;
21
22 import java.util.List JavaDoc;
23
24 /** A test harness to test the DocumentFactory.getQNames() method
25   *
26   * @author <a HREF="mailto:jstrachan@apache.org">James Strachan</a>
27   * @version $Revision: 1.3 $
28   */

29 public class TestGetQNames extends AbstractTestCase {
30
31     public static void main( String JavaDoc[] args ) {
32         TestRunner.run( suite() );
33     }
34
35     public static Test suite() {
36         return new TestSuite( TestGetQNames.class );
37     }
38
39     public TestGetQNames(String JavaDoc name) {
40         super(name);
41     }
42
43     // Test case(s)
44
//-------------------------------------------------------------------------
45
public void testQNames() throws Exception JavaDoc {
46         List JavaDoc qnames = ((OzoneDocumentFactory)nodeFactory).getQNames();
47
48         assertTrue( "Found 15 QNames", qnames.size() == 15 );
49     }
50
51     /** Test the element rename functionality which was lacking as spotted by
52      * Rob Lebowitz
53      */

54     public void testRename() throws Exception JavaDoc {
55         Document doc = O3DocumentHelper.createDocument();
56         Element root = doc.addElement( "foo" );
57
58         assertEquals( "named correctly", "foo", root.getName() );
59
60         root.setName( "bar" );
61
62         assertEquals( "named correctly", "bar", root.getName() );
63
64         QName xyz = root.getQName( "xyz" );
65
66         root.setQName( xyz );
67
68         assertEquals( "QNamed correctly", xyz, root.getQName() );
69     }
70
71     // Implementation methods
72
//-------------------------------------------------------------------------
73
protected void setUp() throws Exception JavaDoc {
74         SAXReader reader = new SAXReader();
75         reader.setNodeFactory( nodeFactory );
76         document = reader.read( "xml/test/soap2.xml" );
77     }
78 }
79
80
81
82
83 /*
84  * Redistribution and use of this software and associated documentation
85  * ("Software"), with or without modification, are permitted provided
86  * that the following conditions are met:
87  *
88  * 1. Redistributions of source code must retain copyright
89  * statements and notices. Redistributions must also contain a
90  * copy of this document.
91  *
92  * 2. Redistributions in binary form must reproduce the
93  * above copyright notice, this list of conditions and the
94  * following disclaimer in the documentation and/or other
95  * materials provided with the distribution.
96  *
97  * 3. The name "DOM4J" must not be used to endorse or promote
98  * products derived from this Software without prior written
99  * permission of MetaStuff, Ltd. For written permission,
100  * please contact dom4j-info@metastuff.com.
101  *
102  * 4. Products derived from this Software may not be called "DOM4J"
103  * nor may "DOM4J" appear in their names without prior written
104  * permission of MetaStuff, Ltd. DOM4J is a registered
105  * trademark of MetaStuff, Ltd.
106  *
107  * 5. Due credit should be given to the DOM4J Project
108  * (http://dom4j.org/).
109  *
110  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
111  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
112  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
113  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
114  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
115  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
116  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
117  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
118  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
119  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
120  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
121  * OF THE POSSIBILITY OF SUCH DAMAGE.
122  *
123  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
124  *
125  * $Id: TestGetQNames.java,v 1.3 2003/11/02 18:31:28 per_nyfelt Exp $
126  */

127
Popular Tags