KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > transformation > XIncludeTransformerTestCase


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.transformation;
18
19 import junit.framework.Test;
20 import junit.framework.TestSuite;
21 import junit.textui.TestRunner;
22
23 import org.apache.avalon.framework.component.WrapperComponentManager;
24 import org.apache.avalon.framework.parameters.Parameters;
25 import org.apache.cocoon.Processor;
26 import org.apache.cocoon.SitemapComponentTestCase;
27 import org.apache.cocoon.components.CocoonComponentManager;
28 import org.apache.cocoon.environment.mock.MockEnvironment;
29
30 /**
31  * A simple testcase for FilterTransformer.
32  *
33  * @author <a HREF="mailto:stephan@apache.org">Stephan Michels </a>
34  * @version CVS $Id: XIncludeTransformerTestCase.java 55454 2004-10-24 18:02:39Z cziegeler $
35  */

36 public class XIncludeTransformerTestCase extends SitemapComponentTestCase {
37     
38     /**
39      * Run this test suite from commandline
40      *
41      * @param args commandline arguments (ignored)
42      */

43     public static void main( String JavaDoc[] args ) {
44         TestRunner.run(suite());
45     }
46     
47     /** Create a test suite.
48      * This test suite contains all test cases of this class.
49      * @return the Test object containing all test cases.
50      */

51     public static Test suite() {
52         TestSuite suite = new TestSuite(XIncludeTransformerTestCase.class);
53         return suite;
54     }
55     
56     /** Testcase for xinclude simple include
57      *
58      * @throws Exception iff ComponentManager enterEnvironment fails
59      */

60     public void testXInclude1() throws Exception JavaDoc {
61         getLogger().debug("testXInclude1");
62         
63         Parameters parameters = new Parameters();
64         
65         String JavaDoc input = "resource://org/apache/cocoon/transformation/xinclude-input-1.xml";
66         String JavaDoc result = "resource://org/apache/cocoon/transformation/xinclude-result-1.xml";
67         String JavaDoc src = null;
68         
69         // enter & leave environment, as a manager is looked up using
70
// the processing context stack
71
MockEnvironment env = new
72         MockEnvironment(null);
73         Processor processor = (Processor)this.lookup(Processor.ROLE);
74         
75         CocoonComponentManager.enterEnvironment(
76         env, new WrapperComponentManager(this.getManager()), processor);
77         
78         assertEqual( load(result),
79         transform("xinclude", src, parameters, load(input)));
80         
81         CocoonComponentManager.leaveEnvironment();
82     }
83     /** Testcase for xinclude simple text include
84      *
85      * @throws Exception iff ComponentManager enterEnvironment fails
86      */

87     public void testXInclude2() throws Exception JavaDoc {
88         getLogger().debug("testXInclude2");
89         
90         Parameters parameters = new Parameters();
91         
92         String JavaDoc input = "resource://org/apache/cocoon/transformation/xinclude-input-2.xml";
93         String JavaDoc result = "resource://org/apache/cocoon/transformation/xinclude-result-2.xml";
94         String JavaDoc src = null;
95         
96         // enter & leave environment, as a manager is looked up using
97
// the processing context stack
98
MockEnvironment env = new
99         MockEnvironment(null);
100         Processor processor = (Processor)this.lookup(Processor.ROLE);
101         
102         CocoonComponentManager.enterEnvironment(
103         env, new WrapperComponentManager(this.getManager()), processor);
104         
105         assertEqual( load(result),
106         transform("xinclude", src, parameters, load(input)));
107         
108         CocoonComponentManager.leaveEnvironment();
109     }
110     
111 }
112
Popular Tags