001: package org.apache.anakia;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import java.io.File;
023:
024: import junit.framework.Test;
025: import junit.framework.TestCase;
026: import junit.framework.TestSuite;
027:
028: import org.apache.anakia.test.Log;
029: import org.apache.anakia.test.TestUtil;
030:
031: /**
032: * This is a test case for Anakia. Right now, it simply will compare
033: * two index.html files together. These are produced as a result of
034: * first running Anakia and then running this test.
035: *
036: * @version $Id: AnakiaTestCase.java 525405 2007-04-04 05:16:37Z wglass $
037: */
038: public class AnakiaTestCase extends TestCase {
039: public static final String TEST_DIR_KEY = "test.compare.dir";
040: public static final String RESULTS_DIR_KEY = "test.results.dir";
041:
042: private String resultsDir;
043: private String compareDir;
044:
045: /**
046: * Creates a new instance.
047: *
048: */
049: public AnakiaTestCase(String name) {
050: super (name);
051: }
052:
053: public static Test suite() {
054: return new TestSuite(AnakiaTestCase.class);
055: }
056:
057: /**
058: * Find the directories.
059: */
060: public void setUp() {
061: resultsDir = System.getProperty(RESULTS_DIR_KEY, "bin/test")
062: + "/anakia";
063: compareDir = System.getProperty(TEST_DIR_KEY, "test")
064: + "/anakia/compare";
065: }
066:
067: /**
068: * Runs the test. This is empty on purpose because the
069: * code to do the Anakia output is in the .xml file that runs
070: * this test.
071: */
072: public void testAnakiaResults() throws Exception {
073: TestUtil.assureResultsDirectoryExists(resultsDir);
074:
075: // compare standard run
076: if (!TestUtil.compareFiles(new File(compareDir, "index.html")
077: .toString(), new File(resultsDir, "index.html")
078: .toString())) {
079: fail("Anakia results are incorrect");
080: } else {
081: Log.log("Passed (standard)!");
082: }
083: }
084:
085: /**
086: * Runs the test. This is empty on purpose because the
087: * code to do the Anakia output is in the .xml file that runs
088: * this test.
089: */
090: public void testAnakiaCustomContextResults() throws Exception {
091: TestUtil.assureResultsDirectoryExists(resultsDir);
092:
093: // compare with custom context
094: if (!TestUtil.compareFiles(new File(compareDir,
095: "index.context.html").toString(), new File(resultsDir,
096: "index.context.html").toString())) {
097: fail("Anakia results are incorrect");
098: } else {
099: Log.log("Passed (custom context)!");
100: }
101: }
102:
103: }
|