KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > dom4j > rule > TestStylesheet2


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: TestStylesheet2.java,v 1.1 2003/07/07 10:30:30 per_nyfelt Exp $
8  */

9
10 package test.dom4j.rule;
11
12 import junit.framework.Test;
13 import junit.framework.TestSuite;
14 import junit.textui.TestRunner;
15 import org.dom4j.Node;
16 import org.dom4j.io.SAXReader;
17 import org.dom4j.rule.Action;
18 import org.dom4j.rule.Stylesheet;
19
20 /** A test harness to test the use of the Stylesheet and the
21   * XSLT rule engine.
22   *
23   * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan</a>
24   * @version $Revision: 1.1 $
25   */

26 public class TestStylesheet2 extends TestStylesheet {
27
28     protected String JavaDoc[] templates = {
29         "/",
30         "title",
31         "para",
32         "*",
33     };
34
35     // JUnit stuff
36
//-------------------------------------------------------------------------
37
public static void main( String JavaDoc[] args ) {
38         TestRunner.run( suite() );
39     }
40
41     public static Test suite() {
42         return new TestSuite( TestStylesheet2.class );
43     }
44
45     public TestStylesheet2(String JavaDoc name) {
46         super(name);
47     }
48
49     // Test case(s)
50
//-------------------------------------------------------------------------
51
public void testRules() throws Exception JavaDoc {
52         for ( int i = 0, size = templates.length; i < size; i++ ) {
53             addTemplate( templates[i] );
54         }
55
56         log( "" );
57         log( "........................................" );
58         log( "" );
59         log( "Running stylesheet" );
60
61         stylesheet.run( document );
62
63         log( "Finished" );
64     }
65
66
67     // Implementation methods
68
//-------------------------------------------------------------------------
69
public void setUp() throws Exception JavaDoc {
70         SAXReader reader = new SAXReader();
71         document = reader.read( "xml/test/littledoc.xml" );
72
73         stylesheet = new Stylesheet();
74         stylesheet.setValueOfAction(
75             new Action() {
76                 public void run(Node node) {
77                     log( "Default ValueOf action on node: " + node );
78                     log( "........................................" );
79                 }
80             }
81         );
82     }
83 }
84
85
86
87
88 /*
89  * Redistribution and use of this software and associated documentation
90  * ("Software"), with or without modification, are permitted provided
91  * that the following conditions are met:
92  *
93  * 1. Redistributions of source code must retain copyright
94  * statements and notices. Redistributions must also contain a
95  * copy of this document.
96  *
97  * 2. Redistributions in binary form must reproduce the
98  * above copyright notice, this list of conditions and the
99  * following disclaimer in the documentation and/or other
100  * materials provided with the distribution.
101  *
102  * 3. The name "DOM4J" must not be used to endorse or promote
103  * products derived from this Software without prior written
104  * permission of MetaStuff, Ltd. For written permission,
105  * please contact dom4j-info@metastuff.com.
106  *
107  * 4. Products derived from this Software may not be called "DOM4J"
108  * nor may "DOM4J" appear in their names without prior written
109  * permission of MetaStuff, Ltd. DOM4J is a registered
110  * trademark of MetaStuff, Ltd.
111  *
112  * 5. Due credit should be given to the DOM4J Project
113  * (http://dom4j.org/).
114  *
115  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
116  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
117  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
118  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
119  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
120  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
121  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
122  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
123  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
124  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
125  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
126  * OF THE POSSIBILITY OF SUCH DAMAGE.
127  *
128  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
129  *
130  * $Id: TestStylesheet2.java,v 1.1 2003/07/07 10:30:30 per_nyfelt Exp $
131  */

132
Popular Tags