001: package org.apache.turbine.modules.screens;
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 junit.framework.Test;
023: import junit.framework.TestSuite;
024:
025: import org.apache.cactus.ServletTestCase;
026: import org.apache.turbine.Turbine;
027: import org.apache.turbine.modules.ScreenLoader;
028: import org.apache.turbine.services.TurbineServices;
029: import org.apache.turbine.services.rundata.RunDataService;
030: import org.apache.turbine.util.RunData;
031:
032: /**
033: * ErrorTest
034: *
035: *@author <a href="epugh@upstate.com">Eric Pugh</a>
036: *@version $Id: ErrorTest.java 534527 2007-05-02 16:10:59Z tv $
037: */
038: public class ErrorTest extends ServletTestCase {
039: private RunData data = null;
040: private org.apache.turbine.modules.screens.Error errorScreen = null;
041: private Turbine turbine = null;
042:
043: /**
044: * Defines the testcase name for JUnit.
045: *
046: *@param name the testcase's name.
047: */
048: public ErrorTest(String name) {
049: super (name);
050: }
051:
052: /**
053: * Start the tests.
054: *
055: *@param args the arguments. Not used
056: */
057: public static void main(String args[]) {
058: junit.awtui.TestRunner.main(new String[] { ErrorTest.class
059: .getName() });
060: }
061:
062: /**
063: * Creates the test suite.
064: *
065: *@return a test suite (<code>TestSuite</code>) that includes all methods
066: * starting with "test"
067: */
068: public static Test suite() {
069: // All methods starting with "test" will be executed in the test suite.
070: return new TestSuite(ErrorTest.class);
071: }
072:
073: protected void setUp() throws Exception {
074: super .setUp();
075:
076: }
077:
078: /**
079: * After each testXXX test runs, shut down the Turbine servlet.
080: */
081: protected void tearDown() throws Exception {
082: turbine.destroy();
083: super .tearDown();
084: }
085:
086: /**
087: * Tests if we can call the doBuild method
088: *
089: *@todo Move the turbine setup stuff into the setUp() method.
090: */
091: public void testDobuild() throws Exception {
092:
093: config.setInitParameter("properties",
094: "/WEB-INF/conf/TurbineCacheTest.properties");
095: turbine = new Turbine();
096: turbine.init(config);
097:
098: data = ((RunDataService) TurbineServices.getInstance()
099: .getService(RunDataService.SERVICE_NAME)).getRunData(
100: request, response, config);
101:
102: errorScreen = (org.apache.turbine.modules.screens.Error) ScreenLoader
103: .getInstance().getInstance("Error");
104: data.getParameters().setString("param", "param1Value");
105: errorScreen.doBuild(data);
106:
107: assertTrue("Make sure we have our error parameter.", data
108: .getPage().toString().indexOf("param1Value") > -1);
109:
110: }
111:
112: }
|