001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.cocoon.transformation;
019:
020: import junit.framework.Test;
021: import junit.framework.TestSuite;
022: import junit.textui.TestRunner;
023:
024: import org.apache.avalon.framework.component.WrapperComponentManager;
025: import org.apache.avalon.framework.parameters.Parameters;
026: import org.apache.cocoon.Processor;
027: import org.apache.cocoon.SitemapComponentTestCase;
028: import org.apache.cocoon.components.CocoonComponentManager;
029: import org.apache.cocoon.environment.mock.MockEnvironment;
030:
031: /**
032: * A simple testcase for FilterTransformer.
033: *
034: * @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
035: * @version CVS $Id: CIncludeTransformerTestCase.java 433543 2006-08-22 06:22:54Z crossley $
036: */
037: public class CIncludeTransformerTestCase extends
038: SitemapComponentTestCase {
039:
040: /**
041: * Run this test suite from commandline
042: *
043: * @param args commandline arguments (ignored)
044: */
045: public static void main(String[] args) {
046: TestRunner.run(suite());
047: }
048:
049: /** Create a test suite.
050: * This test suite contains all test cases of this class.
051: * @return the Test object containing all test cases.
052: */
053: public static Test suite() {
054: TestSuite suite = new TestSuite(
055: CIncludeTransformerTestCase.class);
056: return suite;
057: }
058:
059: /** Testcase for cinclude simple include
060: *
061: * @throws Exception iff ComponentManager enterEnvironment fails
062: */
063: public void testCInclude1() throws Exception {
064: getLogger().debug("testCInclude1");
065:
066: Parameters parameters = new Parameters();
067: parameters.setParameter("support-caching", "false");
068:
069: String input = "resource://org/apache/cocoon/transformation/cinclude-input-1.xml";
070: String result = "resource://org/apache/cocoon/transformation/cinclude-result-1.xml";
071: String src = null;
072:
073: // enter & leave environment, as a manager is looked up using
074: // the processing context stack
075: MockEnvironment env = new MockEnvironment(null);
076: Processor processor = (Processor) this .lookup(Processor.ROLE);
077:
078: CocoonComponentManager.enterEnvironment(env,
079: new WrapperComponentManager(this .getManager()),
080: processor);
081:
082: assertEqual(load(result), transform("cinclude", src,
083: parameters, load(input)));
084:
085: CocoonComponentManager.leaveEnvironment();
086: }
087:
088: /**
089: * Testcase for cinclude specifying element for wrapping included content
090: *
091: * @throws Exception iff ComponentManager enterEnvironment fails
092: */
093: public void testCInclude2() throws Exception {
094: getLogger().debug("testCInclude2");
095:
096: Parameters parameters = new Parameters();
097: parameters.setParameter("support-caching", "false");
098:
099: String input = "resource://org/apache/cocoon/transformation/cinclude-input-2.xml";
100: String result = "resource://org/apache/cocoon/transformation/cinclude-result-2.xml";
101: String src = null;
102:
103: // enter & leave environment, as a manager is looked up using
104: // the processing context stack
105: MockEnvironment env = new MockEnvironment(null);
106: Processor processor = (Processor) this .lookup(Processor.ROLE);
107:
108: CocoonComponentManager.enterEnvironment(env,
109: new WrapperComponentManager(this .getManager()),
110: processor);
111:
112: assertEqual(load(result), transform("cinclude", src,
113: parameters, load(input)));
114:
115: CocoonComponentManager.leaveEnvironment();
116: }
117:
118: /**
119: * Testcase for cinclude specifying select attribute, selection elements from the included document
120: *
121: * @throws Exception iff ComponentManager enterEnvironment fails
122: */
123: public void testCInclude3() throws Exception {
124: getLogger().debug("testCInclude3");
125:
126: Parameters parameters = new Parameters();
127: parameters.setParameter("support-caching", "false");
128:
129: String input = "resource://org/apache/cocoon/transformation/cinclude-input-3.xml";
130: String result = "resource://org/apache/cocoon/transformation/cinclude-result-3.xml";
131: String src = null;
132:
133: // enter & leave environment, as a manager is looked up using
134: // the processing context stack
135: MockEnvironment env = new MockEnvironment(null);
136: Processor processor = (Processor) this .lookup(Processor.ROLE);
137:
138: CocoonComponentManager.enterEnvironment(env,
139: new WrapperComponentManager(this .getManager()),
140: processor);
141:
142: assertEqual(load(result), transform("cinclude", src,
143: parameters, load(input)));
144:
145: CocoonComponentManager.leaveEnvironment();
146: }
147: }
|