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: import org.apache.avalon.framework.parameters.Parameters;
024: import org.apache.cocoon.SitemapComponentTestCase;
025:
026: /**
027: * A simple testcase for FilterTransformer.
028: *
029: * @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
030: * @version CVS $Id: FilterTransformerTestCase.java 433543 2006-08-22 06:22:54Z crossley $
031: */
032: public class FilterTransformerTestCase extends SitemapComponentTestCase {
033:
034: /**
035: * Run this test suite from commandline
036: *
037: * @param args commandline arguments (ignored)
038: */
039: public static void main(String[] args) {
040: TestRunner.run(suite());
041: }
042:
043: /** Create a test suite.
044: * This test suite contains all test cases of this class.
045: * @return the Test object containing all test cases.
046: */
047: public static Test suite() {
048: TestSuite suite = new TestSuite(FilterTransformerTestCase.class);
049: return suite;
050: }
051:
052: /**
053: * Testcase for count=1, blocknr=1
054: */
055: public void testFilter_1_1() throws Exception {
056: getLogger().debug("testFilter_1_1");
057:
058: Parameters parameters = new Parameters();
059: parameters.setParameter("element-name", "leaf");
060: parameters.setParameter("count", "1");
061: parameters.setParameter("blocknr", "1");
062:
063: String input = "resource://org/apache/cocoon/transformation/filter-input.xml";
064: String result = "resource://org/apache/cocoon/transformation/filter-result-1-1.xml";
065: String src = null;
066:
067: assertEqual(load(result), transform("filter", src, parameters,
068: load(input)));
069: }
070:
071: /**
072: * Testcase for count=3, blocknr=1
073: */
074: public void testFilter_3_1() throws Exception {
075: getLogger().debug("testFilter_3_1");
076:
077: Parameters parameters = new Parameters();
078: parameters.setParameter("element-name", "leaf");
079: parameters.setParameter("count", "3");
080: parameters.setParameter("blocknr", "1");
081:
082: String input = "resource://org/apache/cocoon/transformation/filter-input.xml";
083: String result = "resource://org/apache/cocoon/transformation/filter-result-3-1.xml";
084: String src = null;
085:
086: assertEqual(load(result), transform("filter", src, parameters,
087: load(input)));
088: }
089:
090: /**
091: * Testcase for count=1, blocknr=3
092: */
093: public void testFilter_1_3() throws Exception {
094: getLogger().debug("testFilter_1_3");
095:
096: Parameters parameters = new Parameters();
097: parameters.setParameter("element-name", "leaf");
098: parameters.setParameter("count", "1");
099: parameters.setParameter("blocknr", "3");
100:
101: String input = "resource://org/apache/cocoon/transformation/filter-input.xml";
102: String result = "resource://org/apache/cocoon/transformation/filter-result-1-3.xml";
103: String src = null;
104:
105: assertEqual(load(result), transform("filter", src, parameters,
106: load(input)));
107: }
108: }
|