1 24 package org.objectweb.speedo.j2eedo; 25 26 import javax.jdo.JDOException; 27 import javax.jdo.JDOFatalException; 28 29 import org.objectweb.speedo.j2eedo.common.HTTPTools; 30 import org.objectweb.speedo.j2eedo.web.ApplicationServlet; 31 import org.objectweb.util.monolog.api.BasicLevel; 32 33 42 public class TestJ2eedoJ2ee extends TestJ2eedoApplication { 43 protected final String TESTJ2EE = getLoggerName() + ".j2ee"; 44 protected final String URL = getLoggerName() + ".url"; 45 protected final String HTTPPARAMS = getLoggerName() + ".httpParams"; 46 47 protected String url = null; 48 protected String httpParams = null; 49 50 57 public TestJ2eedoJ2ee(String s) { 58 super(s); 59 this.url = 60 System.getProperty(this.URL, "http://localhost:9000/j2eedo/"); 61 this.httpParams = 62 System.getProperty( 63 this.HTTPPARAMS, 64 ApplicationServlet.WITH_GETPM_PARAMETER + "=true"); 65 } 66 67 protected void setUp() { 68 super.setUp(); 69 if (null == this.url) 70 return; 71 try { 72 logger.log(BasicLevel.INFO, HTTPTools.getURL( 73 this.url + "evictall.do", 74 this.httpParams 75 + "&" 76 + ApplicationServlet.PARAMETER_ACTION 77 + "=evictall", 78 "GET", 79 logger)); 80 } catch (Exception e) { 81 logger.log(BasicLevel.ERROR, ""); 82 } 83 84 } 85 protected void displayTestParameters() { 86 if (!logger.isLoggable(BasicLevel.INFO)) 87 return; 88 super.displayTestParameters(); 89 90 logger.log( 91 BasicLevel.INFO, 92 "\n\tJ2EE application URL: " 93 + this.url 94 + "\n\tHTTP default parameters : " 95 + this.httpParams); 96 } 97 98 110 protected String performMethod(String action) 111 throws Exception , JDOException, JDOFatalException { 112 String str = ""; 113 try { 114 return HTTPTools.getURL( 115 this.url + action + ".do", 116 this.httpParams 117 + "&" 118 + ApplicationServlet.PARAMETER_ACTION 119 + "=" 120 + action, 121 "GET", 122 logger); 123 } catch (Exception e) { 124 logger.log( 125 BasicLevel.ERROR, 126 "HTTP:The call \"" 127 + this.url 128 + action 129 + ".do?" 130 + this.httpParams 131 + "&" 132 + ApplicationServlet.PARAMETER_ACTION 133 + "=" 134 + action 135 + "\" throws Exception ", 136 e); 137 assertTrue( 138 "HTTP:The call \"" 139 + this.url 140 + action 141 + ".do?" 142 + this.httpParams 143 + "&" 144 + ApplicationServlet.PARAMETER_ACTION 145 + "=" 146 + action 147 + "\" throws Exception :\n" 148 + e.toString(), 149 false); 150 throw e; 151 } 152 } 153 154 160 public void testHTTPCallSessionContainer() { 161 if (this.simpleTestOnly) 162 return; 163 if (null == this.url) 164 return; 165 this.httpParams = 166 ApplicationServlet.WITH_TRANSACTION_PARAMETER 167 + "=false&" 168 + ApplicationServlet.TYPE_CONTAINER_PARAMETER 169 + "=true&" 170 + ApplicationServlet.WITH_GETPM_PARAMETER 171 + "=false"; 172 this.perform(); 173 } 174 175 182 public void testHTTPCallSessionContainerWithPM() { 183 if (this.simpleTestOnly) 184 return; 185 if (null == this.url) 186 return; 187 this.httpParams = 188 ApplicationServlet.WITH_TRANSACTION_PARAMETER 189 + "=false&" 190 + ApplicationServlet.TYPE_CONTAINER_PARAMETER 191 + "=true&" 192 + ApplicationServlet.WITH_GETPM_PARAMETER 193 + "=true"; 194 this.perform(); 195 } 196 197 204 public void testHTTPWithTransWithGetPM() { 205 if (this.simpleTestOnly) 206 return; 207 if (null == this.url) 208 return; 209 this.httpParams = 210 ApplicationServlet.WITH_TRANSACTION_PARAMETER 211 + "=true&" 212 + ApplicationServlet.WITH_GETPM_PARAMETER 213 + "=true"; 214 this.perform(); 215 } 216 } | Popular Tags |