001: /*
002: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
003: *
004: * This file is part of TransferCM.
005: *
006: * TransferCM is free software; you can redistribute it and/or modify it under the
007: * terms of the GNU General Public License as published by the Free Software
008: * Foundation; either version 2 of the License, or (at your option) any later
009: * version.
010: *
011: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
014: * details.
015: *
016: * You should have received a copy of the GNU General Public License along with
017: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018: * Fifth Floor, Boston, MA 02110-1301 USA
019: */
020:
021: package com.methodhead.shim;
022:
023: import java.io.*;
024: import java.util.*;
025: import java.sql.*;
026: import junit.framework.*;
027: import org.apache.log4j.*;
028: import com.methodhead.persistable.*;
029: import com.methodhead.aikp.*;
030: import com.methodhead.test.*;
031: import com.methodhead.auth.*;
032: import com.methodhead.sitecontext.*;
033: import servletunit.struts.*;
034: import org.apache.cactus.*;
035: import org.apache.struts.util.*;
036:
037: public class ViewPageActionTest extends CactusStrutsTestCase {
038:
039: private Page page = null;
040: private Panel panel = null;
041: private TextModule textModule = null;
042: private Link link = null;
043:
044: static {
045: TestUtils.initLogger();
046: TestUtils.initDb();
047: }
048:
049: public ViewPageActionTest(String name) {
050: super (name);
051: }
052:
053: public void setUp() throws Exception {
054:
055: //setLogLevel( Level.DEBUG );
056: try {
057: super .setUp();
058: ConnectionSingleton.runBatchUpdate(new FileReader(
059: "webapp/WEB-INF/db/transfer-reset.sql"));
060:
061: panel = new Panel();
062: panel.setName("body");
063: panel.setModuleClass("com.methodhead.shim.MockModule");
064:
065: page = new Page();
066: page.setString("template", "template.jsp");
067: page.setString("aliasname", "page1");
068: page.addPanel(panel);
069: page.setSiteContext(SiteContext.getDefaultContext());
070: page.saveNew();
071:
072: //
073: // this may have been set by previous tests
074: //
075: session.getServletContext().removeAttribute(
076: ShimGlobals.SITEMAPMAP_KEY);
077: } catch (Exception e) {
078: fail(e.getMessage());
079: }
080: }
081:
082: public void tearDown() throws Exception {
083:
084: super .tearDown();
085: }
086:
087: public void testDoEmptySite() {
088: try {
089:
090: setRequestPathInfo("/emptySite");
091: actionPerform();
092:
093: verifyForward("form");
094: } catch (Exception e) {
095: e.printStackTrace();
096: fail();
097: }
098: }
099:
100: public void testDoPageNotFound() {
101: try {
102:
103: setRequestPathInfo("/pageNotFound");
104: actionPerform();
105:
106: verifyForward("form");
107: } catch (Exception e) {
108: e.printStackTrace();
109: fail();
110: }
111: }
112: }
|