KickJava   Java API By Example, From Geeks To Geeks.

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


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: CIncludeTransformerTestCase.java 55454 2004-10-24 18:02:39Z cziegeler $
35  */

36 public class CIncludeTransformerTestCase 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(CIncludeTransformerTestCase.class);
53         return suite;
54     }
55     
56     /** Testcase for cinclude simple include
57      *
58      * @throws Exception iff ComponentManager enterEnvironment fails
59      */

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

90     public void testCInclude2() throws Exception JavaDoc {
91         getLogger().debug("testCInclude2");
92         
93         Parameters parameters = new Parameters();
94         parameters.setParameter( "support-caching", "false" );
95         
96         String JavaDoc input = "resource://org/apache/cocoon/transformation/cinclude-input-2.xml";
97         String JavaDoc result = "resource://org/apache/cocoon/transformation/cinclude-result-2.xml";
98         String JavaDoc src = null;
99         
100         // enter & leave environment, as a manager is looked up using
101
// the processing context stack
102
MockEnvironment env = new
103         MockEnvironment(null);
104         Processor processor = (Processor)this.lookup(Processor.ROLE);
105         
106         CocoonComponentManager.enterEnvironment(
107         env, new WrapperComponentManager(this.getManager()), processor);
108         
109         assertEqual( load(result),
110         transform("cinclude", src, parameters, load(input)));
111         
112         CocoonComponentManager.leaveEnvironment();
113     }
114     
115     /**
116      * Testcase for cinclude specifying select attribute, selection elements from the included document
117      *
118      * @throws Exception iff ComponentManager enterEnvironment fails
119      */

120     public void testCInclude3() throws Exception JavaDoc {
121         getLogger().debug("testCInclude3");
122         
123         Parameters parameters = new Parameters();
124         parameters.setParameter( "support-caching", "false" );
125         
126         String JavaDoc input = "resource://org/apache/cocoon/transformation/cinclude-input-3.xml";
127         String JavaDoc result = "resource://org/apache/cocoon/transformation/cinclude-result-3.xml";
128         String JavaDoc src = null;
129         
130         // enter & leave environment, as a manager is looked up using
131
// the processing context stack
132
MockEnvironment env = new
133         MockEnvironment(null);
134         Processor processor = (Processor)this.lookup(Processor.ROLE);
135         
136         CocoonComponentManager.enterEnvironment(
137         env, new WrapperComponentManager(this.getManager()), processor);
138         
139         assertEqual( load(result),
140         transform("cinclude", src, parameters, load(input)));
141         
142         CocoonComponentManager.leaveEnvironment();
143     }
144 }
145
Popular Tags