1 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 name ) { 50 super( name ); 51 } 52 53 public void setUp() 54 throws 55 Exception { 56 57 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 session.getServletContext().removeAttribute( ShimGlobals.SITEMAPMAP_KEY ); 77 } 78 catch ( Exception e ) { 79 fail( e.getMessage() ); 80 } 81 } 82 83 public void tearDown() 84 throws 85 Exception { 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 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 e ) { 113 e.printStackTrace(); 114 fail(); 115 } 116 } 117 } 118 | Popular Tags |