01: package org.apache.dvsl;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import java.io.StringReader;
23: import java.io.StringWriter;
24: import java.io.FileReader;
25:
26: import junit.framework.TestCase;
27:
28: import org.dom4j.Document;
29: import org.dom4j.io.SAXReader;
30:
31: /**
32: * Simple testcase to ensure things are basically working.
33: * This tests both a serialized document as well as a 'live'
34: * dom4j one.
35: *
36: * @author <a href="mailto:geirm@apache.org>Geir Magnusson Jr.</a>
37: */
38: public class GrinderTest extends TestCase {
39: /*
40: * use simple in-memory style and input strings
41: */
42:
43: private String dvslstyle = "src/test/site.dvsl";
44: private String input = "src/test/user-guide.xml";
45:
46: public GrinderTest(String name) {
47: super (name);
48: }
49:
50: public void testSelection() {
51: try {
52: doit();
53: } catch (Exception e) {
54: fail(e.getMessage());
55: }
56: }
57:
58: public void doit() throws Exception {
59: /*
60: * make a dvsl
61: */
62:
63: DVSL dvsl = new DVSL();
64:
65: /*
66: * register the stylesheet
67: */
68:
69: dvsl.setStylesheet(new FileReader(dvslstyle));
70:
71: /*
72: * render the document as a Reader
73: */
74:
75: StringWriter sw = new StringWriter();
76: SAXReader sr = new SAXReader();
77: Document document = sr.read(new FileReader(input));
78: sw = new StringWriter();
79:
80: while (true) {
81: dvsl.transform(document, sw);
82: }
83: }
84: }
|