1 16 17 package org.apache.jetspeed.test; 18 19 import org.apache.turbine.modules.actions.sessionvalidator.SessionValidator; 21 import org.apache.turbine.modules.ActionLoader; 22 import org.apache.turbine.modules.PageLoader; 23 import org.apache.turbine.services.resources.TurbineResources; 24 import org.apache.turbine.services.template.TurbineTemplate; 25 import org.apache.turbine.util.RunData; 26 27 44 public abstract class TurbineTestUtilities 45 { 46 55 public static void setupRunData(RunData rundata) throws Exception 56 { 57 if (rundata == null) 58 throw new NullPointerException ("rundata is null"); 59 60 SessionValidator sessionValidator = (SessionValidator)ActionLoader 62 .getInstance().getInstance(TurbineResources.getString( 63 "action.sessionvalidator")); 64 if (sessionValidator == null) 65 throw new NullPointerException ("Failed to get a SessonValidator"); 66 67 rundata.setScreen( rundata.getParameters().getString("screen") ); 69 rundata.setAction( rundata.getParameters().getString("action") ); 70 71 if ( rundata.hasAction() 73 && rundata.getAction().equalsIgnoreCase(TurbineResources 74 .getString("action.login")) 75 || rundata.getAction().equalsIgnoreCase(TurbineResources 76 .getString("action.logout"))) 77 { 78 if (rundata.getAction().equalsIgnoreCase(TurbineResources 79 .getString("action.login"))) 80 { 81 String [] names = rundata.getSession().getValueNames(); 82 if (names != null) 83 { 84 for (int i=0; i< names.length; i++) 85 { 86 rundata.getSession().removeValue(names[i]); 87 } 88 } 89 } 90 ActionLoader.getInstance().exec( rundata, rundata.getAction() ); 91 rundata.setAction(null); 92 } 93 94 ActionLoader.getInstance().exec( 96 rundata,TurbineResources.getString("action.sessionvalidator") ); 97 98 ActionLoader.getInstance().exec( 100 rundata,TurbineResources.getString("action.accesscontroller")); 101 102 } 103 104 109 public static void generatePage(RunData rundata) throws Exception 110 { 111 if (rundata == null) 112 throw new NullPointerException ("rundata is null"); 113 114 String defaultPage = TurbineTemplate.getDefaultPageName(rundata); 115 PageLoader.getInstance().exec(rundata, defaultPage); 116 } 117 118 126 public static void outputPage(RunData rundata) throws Exception 127 { 128 if (rundata == null) 129 throw new NullPointerException ("rundata is null"); 130 131 rundata.getResponse().setLocale( rundata.getLocale() ); 132 rundata.getResponse().setContentType( rundata.getContentType() ); 133 rundata.getResponse().setStatus( rundata.getStatusCode() ); 134 rundata.getPage().output(rundata.getOut()); 135 136 try 137 { 138 rundata.getOut().close(); 139 } 140 catch (Exception e) 141 { 142 } 144 } 145 146 } | Popular Tags |