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: I18NTransformerTestCase.java 433543 2006-08-22 06:22:54Z crossley $
036: */
037: public class I18NTransformerTestCase extends SitemapComponentTestCase {
038:
039: /**
040: * Run this test suite from commandline
041: *
042: * @param args commandline arguments (ignored)
043: */
044: public static void main(String[] args) {
045: TestRunner.run(suite());
046: }
047:
048: /** Create a test suite.
049: * This test suite contains all test cases of this class.
050: * @return the Test object containing all test cases.
051: */
052: public static Test suite() {
053: TestSuite suite = new TestSuite(I18NTransformerTestCase.class);
054: return suite;
055: }
056:
057: /** Testcase for i18n
058: *
059: * @throws Exception iff ComponentManager enterEnvironment fails
060: */
061: public void testI18n1() throws Exception {
062: getLogger().debug("testI18n1");
063:
064: Parameters parameters = new Parameters();
065: parameters.setParameter("support-caching", "false");
066:
067: String input = "resource://org/apache/cocoon/transformation/i18n-input-1.xml";
068: String result = "resource://org/apache/cocoon/transformation/i18n-result-1.xml";
069: String src = null;
070:
071: // enter & leave environment, as a manager is looked up using
072: // the processing context stack
073: MockEnvironment env = new MockEnvironment(null);
074: Processor processor = (Processor) this .lookup(Processor.ROLE);
075:
076: CocoonComponentManager.enterEnvironment(env,
077: new WrapperComponentManager(this .getManager()),
078: processor);
079:
080: assertEqual(load(result), transform("i18n", src, parameters,
081: load(input)));
082:
083: CocoonComponentManager.leaveEnvironment();
084: }
085:
086: /** Testcase for i18n
087: *
088: * @throws Exception iff ComponentManager enterEnvironment fails
089: */
090: public void testI18n2() throws Exception {
091: getLogger().debug("testI18n2");
092:
093: Parameters parameters = new Parameters();
094: parameters.setParameter("support-caching", "false");
095:
096: String input = "resource://org/apache/cocoon/transformation/i18n-input-2.xml";
097: String result = "resource://org/apache/cocoon/transformation/i18n-result-2.xml";
098: String src = null;
099:
100: // enter & leave environment, as a manager is looked up using
101: // the processing context stack
102: MockEnvironment env = new MockEnvironment(null);
103: Processor processor = (Processor) this .lookup(Processor.ROLE);
104:
105: CocoonComponentManager.enterEnvironment(env,
106: new WrapperComponentManager(this .getManager()),
107: processor);
108:
109: assertEqual(load(result), transform("i18n", src, parameters,
110: load(input)));
111:
112: CocoonComponentManager.leaveEnvironment();
113: }
114: }
|