KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > methodhead > shim > ViewPageActionTest


1 /*
2  * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
3  *
4  * This file is part of TransferCM.
5  *
6  * TransferCM is free software; you can redistribute it and/or modify it under the
7  * terms of the GNU General Public License as published by the Free Software
8  * Foundation; either version 2 of the License, or (at your option) any later
9  * version.
10  *
11  * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18  * Fifth Floor, Boston, MA 02110-1301 USA
19  */

20
21 package com.methodhead.shim;
22
23 import java.io.*;
24 import java.util.*;
25 import java.sql.*;
26 import junit.framework.*;
27 import org.apache.log4j.*;
28 import com.methodhead.persistable.*;
29 import com.methodhead.aikp.*;
30 import com.methodhead.test.*;
31 import com.methodhead.auth.*;
32 import com.methodhead.sitecontext.*;
33 import servletunit.struts.*;
34 import org.apache.cactus.*;
35 import org.apache.struts.util.*;
36
37 public class ViewPageActionTest extends CactusStrutsTestCase {
38
39   private Page page = null;
40   private Panel panel = null;
41   private TextModule textModule = null;
42   private Link link = null;
43
44   static {
45     TestUtils.initLogger();
46     TestUtils.initDb();
47   }
48
49   public ViewPageActionTest( String JavaDoc name ) {
50     super( name );
51   }
52
53   public void setUp()
54   throws
55     Exception JavaDoc {
56
57     //setLogLevel( Level.DEBUG );
58
try {
59       super.setUp();
60       ConnectionSingleton.runBatchUpdate( new FileReader( "webapp/WEB-INF/db/transfer-reset.sql" ) );
61
62       panel = new Panel();
63       panel.setName( "body" );
64       panel.setModuleClass( "com.methodhead.shim.MockModule" );
65
66       page = new Page();
67       page.setString( "template", "template.jsp" );
68       page.setString( "aliasname", "page1" );
69       page.addPanel( panel );
70       page.setSiteContext( SiteContext.getDefaultContext() );
71       page.saveNew();
72
73       //
74
// this may have been set by previous tests
75
//
76
session.getServletContext().removeAttribute( ShimGlobals.SITEMAPMAP_KEY );
77     }
78     catch ( Exception JavaDoc e ) {
79       fail( e.getMessage() );
80     }
81   }
82
83   public void tearDown()
84   throws
85     Exception JavaDoc {
86
87     super.tearDown();
88   }
89
90   public void testDoEmptySite() {
91     try {
92
93       setRequestPathInfo( "/emptySite" );
94       actionPerform();
95
96       verifyForward( "form" );
97     }
98     catch ( Exception JavaDoc e ) {
99       e.printStackTrace();
100       fail();
101     }
102   }
103
104   public void testDoPageNotFound() {
105     try {
106
107       setRequestPathInfo( "/pageNotFound" );
108       actionPerform();
109
110       verifyForward( "form" );
111     }
112     catch ( Exception JavaDoc e ) {
113       e.printStackTrace();
114       fail();
115     }
116   }
117 }
118
Popular Tags