From 90f076ed4e7df3b7f7acad64197236e801483938 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Mon, 22 Jul 2013 17:48:13 +0800 Subject: [PATCH] debug the httpcapture --- .../master/api/RecordScriptController.java | 8 +- .../bench4q/master/entity/ScriptCapturer.java | 63 +- .../master/entity/httpcapture/Config.java | 5 +- .../entity/httpcapture/HttpTestCase.java | 30 +- .../entity/httpcapture/ProxyServer.java | 1 + .../entity/httpcapture/RequestHandler.java | 5 +- .../master/entity/httpcapture/Validator.java | 37 +- .../generator/AbstractCodeGenerator.java | 1086 ++++++++--------- .../master/service/PortPoolService.java | 2 +- .../config/httpCaptureConfig/maxq.properties | 54 + 10 files changed, 662 insertions(+), 629 deletions(-) create mode 100644 src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties diff --git a/src/main/java/org/bench4q/master/api/RecordScriptController.java b/src/main/java/org/bench4q/master/api/RecordScriptController.java index cdcfffa3..2e16ee06 100644 --- a/src/main/java/org/bench4q/master/api/RecordScriptController.java +++ b/src/main/java/org/bench4q/master/api/RecordScriptController.java @@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.ResponseBody; @RequestMapping("/RecordScript") public class RecordScriptController extends BaseController { private int portForRecord; - private ScriptCapturer scriptCapturer; + private ScriptCapturer scriptCapturer = null; private ScriptService scriptService; private static final Object PORT_LOCK = new Object(); private PortPoolService portPoolService = new PortPoolService(); @@ -72,7 +72,6 @@ public class RecordScriptController extends BaseController { } this.setPortForRecord(port.getPort()); } - // String pathString = this.getClass().getResource("/").getPath(); // scriptCapturer = new ScriptCapturer(portForRecord, "C:\\Script\\", // this.getPrincipal().getUserName()); @@ -96,15 +95,16 @@ public class RecordScriptController extends BaseController { * if (!checkScope(Constant.NORAML_AUTHENTICATION)) { return * returnResponseModel(false, "has no power for this!!!"); } */ - if (this.getScriptCapturer().equals(null)) { + if (this.getScriptCapturer() == null) { return returnResponseModel(false, "there is no RecordingServer to stop"); } this.getScriptCapturer().stopCurrentRecord(); this.getScriptCapturer().shutHttpCaptureProxyServer(); - + this.getPortPoolService().backThePortToPool(this.getPortForRecord()); + return returnResponseModel(true, "RecordServer stop"); } diff --git a/src/main/java/org/bench4q/master/entity/ScriptCapturer.java b/src/main/java/org/bench4q/master/entity/ScriptCapturer.java index 83b478f4..74d52589 100644 --- a/src/main/java/org/bench4q/master/entity/ScriptCapturer.java +++ b/src/main/java/org/bench4q/master/entity/ScriptCapturer.java @@ -8,10 +8,11 @@ import javax.swing.JTextArea; import org.bench4q.master.entity.httpcapture.HttpCapture; import org.bench4q.master.entity.httpcapture.Utils.UserException; import org.springframework.stereotype.Component; + @Component public class ScriptCapturer { - - //private HttpCapture httpCapture = null; + + // private HttpCapture httpCapture = null; private int portForRecord; private String scriptPath; private boolean isRecording; @@ -20,17 +21,18 @@ public class ScriptCapturer { private HttpCapture httpCapture; private String scriptContentString; private static final String HTTPCATUREGENERATOR_STRING = "org.bench4q.master.entity.httpcapture.generator.IsacCodeGenerator"; - - public ScriptCapturer(){} - - public ScriptCapturer(int portForRecord, String scriptParentPath, String userName) - { + + public ScriptCapturer() { + } + + public ScriptCapturer(int portForRecord, String scriptParentPath, + String userName) { this.setPortForRecord(portForRecord); this.setScriptPath(scriptParentPath + userName); - //TODO get the machine's ipAdress + // TODO get the machine's ipAdress this.setIpHttpCaptureServerAdress(Constant.TESTIPADRESS); } - + public boolean isRecording() { return isRecording; } @@ -38,7 +40,7 @@ public class ScriptCapturer { public void setRecording(boolean isRecording) { this.isRecording = isRecording; } - + public String getScriptPath() { return scriptPath; } @@ -46,7 +48,7 @@ public class ScriptCapturer { public void setScriptPath(String scriptPath) { this.scriptPath = scriptPath; } - + public boolean isProxyServerRunning() { return isProxyServerRunning; } @@ -54,7 +56,7 @@ public class ScriptCapturer { public void setProxyServerRunning(boolean isProxyServerRunning) { this.isProxyServerRunning = isProxyServerRunning; } - + public String getIpHttpCaptureServerAdress() { return ipHttpCaptureServerAdress; } @@ -62,7 +64,7 @@ public class ScriptCapturer { public void setIpHttpCaptureServerAdress(String ipHttpCaptureServerAdress) { this.ipHttpCaptureServerAdress = ipHttpCaptureServerAdress; } - + public int getPortForRecord() { return portForRecord; } @@ -70,14 +72,16 @@ public class ScriptCapturer { public void setPortForRecord(int portForRecord) { this.portForRecord = portForRecord; } - + private void startHttpCaptureProxyServer() { try { - httpCapture = new HttpCapture( this.getScriptPath(), this.getPortForRecord(), - HTTPCATUREGENERATOR_STRING, new JTextArea()); + httpCapture = new HttpCapture(this.getScriptPath(), + this.getPortForRecord(), HTTPCATUREGENERATOR_STRING, + new JTextArea()); httpCapture.startProxyServer(); this.setProxyServerRunning(true); - System.out.println("INFO: Proxy Server Started at Port: " + this.getPortForRecord()); + System.out.println("INFO: Proxy Server Started at Port: " + + this.getPortForRecord()); } catch (IOException e1) { System.out.println("Error When build the proxy server!"); e1.printStackTrace(); @@ -86,16 +90,17 @@ public class ScriptCapturer { e1.printStackTrace(); } } - - public void shutHttpCaptureProxyServer(){ + + public void shutHttpCaptureProxyServer() { try { if (!isProxyServerRunning()) { return; } - if(this.isRecording()){ + if (this.isRecording()) { httpCapture.stopRecording(); } httpCapture.shutProxyServer(); + this.setProxyServerRunning(false); } catch (IOException e1) { System.out.println("Error When shut the httpCapture proxy server!"); e1.printStackTrace(); @@ -104,12 +109,10 @@ public class ScriptCapturer { e1.printStackTrace(); } } - - public void startCurrentRecord() - { + + public void startCurrentRecord() { try { - if(!this.isProxyServerRunning()) - { + if (!this.isProxyServerRunning()) { this.startHttpCaptureProxyServer(); } httpCapture.startRecording(); @@ -122,23 +125,23 @@ public class ScriptCapturer { e1.printStackTrace(); } } - + public void stopCurrentRecord() { try { - if(!this.isRecording()) - { + if (!this.isRecording()) { return; } httpCapture.stopRecording(); this.setRecording(false); - this.setScriptContentString(this.httpCapture.getScriptContentString()); + this.setScriptContentString(this.httpCapture + .getScriptContentString()); } catch (IOException e1) { System.out.println("Error When stop recording!"); e1.printStackTrace(); } catch (UserException e1) { System.out.println("Error When stop recording!"); e1.printStackTrace(); - } + } } public String getScriptContentString() { diff --git a/src/main/java/org/bench4q/master/entity/httpcapture/Config.java b/src/main/java/org/bench4q/master/entity/httpcapture/Config.java index 8007353d..67d1885a 100644 --- a/src/main/java/org/bench4q/master/entity/httpcapture/Config.java +++ b/src/main/java/org/bench4q/master/entity/httpcapture/Config.java @@ -55,8 +55,9 @@ public class Config { String maxqDir = System.getProperty("maxq.dir"); String pathSep = System.getProperty("file.separator"); - String propertiesFileName = System.getProperty("properties.file", - "maxq.properties"); + String propertiesFileName = System.getProperty("user.dir") + + "\\src\\main\\resources\\org\\bench4q\\master\\config\\httpCaptureConfig\\maxq.properties"; + InputStream propertiesStream = Config.class.getClassLoader() .getResourceAsStream(propertiesFileName); props = new Properties(); diff --git a/src/main/java/org/bench4q/master/entity/httpcapture/HttpTestCase.java b/src/main/java/org/bench4q/master/entity/httpcapture/HttpTestCase.java index b82b4a1e..47f17034 100644 --- a/src/main/java/org/bench4q/master/entity/httpcapture/HttpTestCase.java +++ b/src/main/java/org/bench4q/master/entity/httpcapture/HttpTestCase.java @@ -5,8 +5,6 @@ import java.io.IOException; import javax.swing.JOptionPane; -import junit.framework.TestCase; - import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.HttpClient; @@ -14,17 +12,14 @@ import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.URIException; import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.MultipartPostMethod; import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.multipart.StringPart; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.python.core.PyDictionary; import org.python.core.PyString; import org.python.core.PyTuple; -@SuppressWarnings("deprecation") -public class HttpTestCase extends TestCase { +public class HttpTestCase { private static final Log log = LogFactory.getLog(HttpTestCase.class); private Config config = Config.getConfig(); protected HttpMethod method = null; @@ -70,7 +65,6 @@ public class HttpTestCase extends TestCase { } public HttpTestCase(String name) { - super(name); Config.ProxySettings proxy = this.config.getProxySettings(); if (proxy != null) { HostConfiguration hc = this.client.getHostConfiguration(); @@ -79,9 +73,6 @@ public class HttpTestCase extends TestCase { } public void Run() throws Throwable { - setUp(); - runTest(); - tearDown(); } public HttpMethod getMethod() { @@ -91,7 +82,7 @@ public class HttpTestCase extends TestCase { private void cleanupMethod() { if (this.method != null) { this.method.releaseConnection(); - this.method.recycle(); + // this.method.recycle(); this.method = null; } } @@ -148,13 +139,14 @@ public class HttpTestCase extends TestCase { cleanupMethod(); url = replaceURL(url); - MultipartPostMethod multipartPost = new MultipartPostMethod(url); - multipartPost.addPart(new StringPart("data", data)); + PostMethod multipartPostMethod = new PostMethod(url); + + multipartPostMethod.addParameter("data", data); if (args != null) { - multipartPost.setQueryString(paramsToNV(args)); + multipartPostMethod.setQueryString(paramsToNV(args)); } - this.method = multipartPost; + this.method = multipartPostMethod; this.method.setFollowRedirects(this.followRedirects); this.client.executeMethod(this.method); } @@ -179,6 +171,7 @@ public class HttpTestCase extends TestCase { } public static String staticUrlDecode(String s) { + String sUrl = ""; ByteArrayOutputStream out = new ByteArrayOutputStream(s.length()); for (int count = 0; count < s.length(); ++count) if (s.charAt(count) == '%') { @@ -197,17 +190,14 @@ public class HttpTestCase extends TestCase { } else if (s.charAt(count) == '+') { out.write(32); } else { + sUrl += s.charAt(count); out.write(s.charAt(count)); } - + System.out.println(sUrl); return out.toString(); } protected void responseOK() throws URIException { - int status = getResponseCode(); - assertTrue("Invalid HTTP response: " + this.method + " for URI: " - + this.method.getURI(), (status == 200) || (status == 302) - || (status == 304)); } protected boolean responseContainsURI(String uri) throws URIException { diff --git a/src/main/java/org/bench4q/master/entity/httpcapture/ProxyServer.java b/src/main/java/org/bench4q/master/entity/httpcapture/ProxyServer.java index 7413b804..65e718da 100644 --- a/src/main/java/org/bench4q/master/entity/httpcapture/ProxyServer.java +++ b/src/main/java/org/bench4q/master/entity/httpcapture/ProxyServer.java @@ -54,6 +54,7 @@ public class ProxyServer extends Thread { public void run() { + System.out.println(" in run"); while (!Thread.interrupted()) if (!this.srvSock.isClosed()) try { diff --git a/src/main/java/org/bench4q/master/entity/httpcapture/RequestHandler.java b/src/main/java/org/bench4q/master/entity/httpcapture/RequestHandler.java index a7eb4c4e..afe19c29 100644 --- a/src/main/java/org/bench4q/master/entity/httpcapture/RequestHandler.java +++ b/src/main/java/org/bench4q/master/entity/httpcapture/RequestHandler.java @@ -43,7 +43,8 @@ public class RequestHandler implements Runnable { try { this.header = new HttpRequestHeader(this.clientIn); } catch (IOException e) { - log.info("truncated request from browser: " + e.getMessage()); + log.info("truncated request from browser: " + e.getMessage() + + this.header.url); throw new Utils.SilentException(); } if (!this.header.url.startsWith("http")) @@ -161,7 +162,7 @@ public class RequestHandler implements Runnable { this.clientOut.write(buf, 0, len); } catch (SocketException e) { log.info("browser stopped listening: " - + e.getMessage()); + + e.getMessage() + this.buffer.toString()); throw new Utils.SilentException(); } this.buffer.write(buf, 0, len); diff --git a/src/main/java/org/bench4q/master/entity/httpcapture/Validator.java b/src/main/java/org/bench4q/master/entity/httpcapture/Validator.java index 62bf0d4b..5be6deee 100644 --- a/src/main/java/org/bench4q/master/entity/httpcapture/Validator.java +++ b/src/main/java/org/bench4q/master/entity/httpcapture/Validator.java @@ -1,38 +1,25 @@ package org.bench4q.master.entity.httpcapture; import java.io.IOException; -import java.util.regex.Pattern; - import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class Validator { private static final Log log = LogFactory.getLog(Validator.class); - private static String[] stdRspErrTags = new String[0]; - private static String[] stdRspErrPats = new String[0]; - public static void validateResponse(HttpTestCase test, HttpMethod httpMethod, String url, Object[] params) throws IOException - { - log.debug("------Validator.validateResponse: method: " + httpMethod.getName() + " url: " + url + " params: " + params); + public static void validateResponse(HttpTestCase test, + HttpMethod httpMethod, String url, Object[] params) + throws IOException { + log.debug("------Validator.validateResponse: method: " + + httpMethod.getName() + " url: " + url + " params: " + params); - String response = httpMethod.getResponseBodyAsString(); + httpMethod.getResponseBodyAsString(); + } - for (int i = 0; i < stdRspErrTags.length; ++i) { - HttpTestCase.assertEquals("Standard invariant tag found in response: " + - stdRspErrTags[i], -1, response.indexOf(stdRspErrTags[i])); - } - - for (int i = 0; i < stdRspErrPats.length; ++i) { - Pattern re = Pattern.compile(stdRspErrPats[i], 32); - HttpTestCase.assertFalse("Standard invariant pattern found in response: " + - stdRspErrPats[i], re.matcher(response).find()); - } - } - - public static void validateRequest(HttpTestCase test, HttpMethod httpMethod, String method, String url, Object[] params) - { - log.debug("------Validator.validateRequest: method: " + method + - " url: " + url + " params: " + params); - } + public static void validateRequest(HttpTestCase test, + HttpMethod httpMethod, String method, String url, Object[] params) { + log.debug("------Validator.validateRequest: method: " + method + + " url: " + url + " params: " + params); + } } diff --git a/src/main/java/org/bench4q/master/entity/httpcapture/generator/AbstractCodeGenerator.java b/src/main/java/org/bench4q/master/entity/httpcapture/generator/AbstractCodeGenerator.java index 4aa0552b..58aac74f 100644 --- a/src/main/java/org/bench4q/master/entity/httpcapture/generator/AbstractCodeGenerator.java +++ b/src/main/java/org/bench4q/master/entity/httpcapture/generator/AbstractCodeGenerator.java @@ -22,549 +22,545 @@ import org.bench4q.master.entity.httpcapture.Param; import org.bench4q.master.entity.httpcapture.ProxyServer; import org.bench4q.master.entity.httpcapture.Utils; -public abstract class AbstractCodeGenerator -implements IScriptGenerator, ProxyServer.Observer, Runnable -{ - private Config config = Config.getConfig(); - private static final Log log; - private static String cpRspTo; - private static boolean cpRspToStdout; - private static boolean cpRspToFile; - private static final String[] MIME_DEFAULTS; - private static HashMap mimeTypes; - protected static final String END_STATEMENT; - protected static String jtidyConfigFile; - protected long assertNumber = 0L; - protected boolean headersExist = false; - private IScriptAdapter scriptAdapter; - private String testName; - private String defaultTestName; - private String testPath; - private boolean ignoreNextResponse; - private Pattern[] namePatterns; - private LinkedList outstandingInserts; - private Thread insertThread; - private String charset; - private final Pattern insertMarkerRE = Pattern.compile("(^[ \\t]*" + EOL + ")?" + ".*\\^\\^\\^ Insert new recording.*", 8); - private long timeElapsedSinceLastestRequest = 0L; - private Date latestRequestDate = new Date(); - private boolean isFirstRequest = true; - static final boolean $assertionsDisabled = !(AbstractCodeGenerator.class.desiredAssertionStatus()); - - public static boolean isCpRspToStdout() - { - return cpRspToStdout; - } - - public static boolean isCpRspToFile() - { - return cpRspToFile; - } - - public AbstractCodeGenerator(IScriptAdapter adapter, String[] nameRegExps) - { - this.scriptAdapter = adapter; - - this.namePatterns = new Pattern[nameRegExps.length]; - for (int i = 0; i < nameRegExps.length; ++i) - this.namePatterns[i] = Pattern.compile(nameRegExps[i], 8); - - this.testName = this.config.getProperty("test.default_testname", "MaxQTest"); - this.defaultTestName = this.testName; - - this.insertThread = new Thread(this); - this.insertThread.start(); - } - - public String getDefaultTestName() - { - return this.defaultTestName; - } - - public void setDefaultTestName(String defaultTestName) - { - this.defaultTestName = defaultTestName; - } - - public IScriptAdapter getScriptAdapter() - { - return this.scriptAdapter; - } - - public String getTestName() - { - return this.testName; - } - - public void setTestName(String testName) - { - this.testName = testName; - } - - public String getTestPath() - { - return this.testPath; - } - - public void setTestPath(String testPath) - { - this.testPath = testPath; - } - - public long getTimeElapsedSinceLastestRequest() - { - return this.timeElapsedSinceLastestRequest; - } - - public boolean isFirstRequest() { - return this.isFirstRequest; - } - - public String parseTestName() - { - Matcher m = this.namePatterns[0].matcher(getScript()); - if (!(m.find())) - throw new IllegalArgumentException("You have fiddled with the formatting of the name of the test embedded in this file. I can no longer understand it."); - - return m.group(1); - } - - public void doSave(String path, String fileName) - { - String name = fileName; - int dotPos = fileName.indexOf("."); - if (dotPos > -1) - name = fileName.substring(0, dotPos); - setTestName(name); - setTestPath(path); - - for (int i = 0; i < this.namePatterns.length; ++i) { - Matcher m = this.namePatterns[i].matcher(getScript()); - if (!(m.find())) - throw new IllegalArgumentException("Regular expression (\"" + this.namePatterns[i].pattern() + "\") provided to constructor cannot match the contents of the script"); - this.scriptAdapter.replace(name, m.start(1), m.end(1)); - } - } - - public void doLoad() - { - setTestName(parseTestName()); - } - - public void close() - { - this.insertThread.interrupt(); - } - - public void processRequest(HttpRequestHeader header, byte[] requestBody) - throws Exception - { - Param[] params; - int i; - String name; - String value; - Date d = new Date(); - this.timeElapsedSinceLastestRequest = (d.getTime() - this.latestRequestDate.getTime()); - this.latestRequestDate = d; - - if ((header.method.toLowerCase().equals("get")) && (urlIgnored(header.url))) { - log.debug("Ignoring GET request: \"" + header.url + "\""); - this.ignoreNextResponse = true; - return; - } - - boolean isMultiPartRequest = header.contentType.startsWith("multipart/form-data"); - boolean isFormRequest = header.contentType.startsWith("application/x-www-form-urlencoded"); - Action action = new Action(); - - String newCharset = null; - Matcher charsetParser = Pattern.compile("charset=([a-z0-9_\\-]+)", 2).matcher(header.contentType); - if (charsetParser.matches()) { - newCharset = charsetParser.group(); - if (!(newCharset.equals(this.charset))) { - doSetCharset(newCharset); - } - else if (this.charset != null) { - doSetCharset(null); - } - - } - - doHeaders(createHeaders(header)); - - String url = header.url; - log.debug(" recording url: " + url); - - String method = header.method.toLowerCase(); - - int pos = url.indexOf("?"); - if ((pos != -1) && (url.length() > pos + 1)) { - setQueryStringParams(action, url.substring(pos + 1)); - action.setUrl(HttpTestCase.replaceURL(url.substring(0, pos))); - } else { - action.setUrl(HttpTestCase.replaceURL(url)); - } - if (requestBody.length > 0) { - if (isMultiPartRequest) - { - setMultiPartData(action, header, requestBody); - } else if (!(isFormRequest)) { - if (newCharset != null) - doSetData(new String(requestBody, newCharset)); - else - doSetData(new String(requestBody)); - - } - else if (newCharset != null) - setBodyParams(action, new String(requestBody, newCharset)); - else { - setBodyParams(action, new String(requestBody)); - } - - } - - if (action.getParamsCount() > 0) { - params = action.getParams(); - - for (i = 0; i < params.length; ++i) { - name = params[i].name; - value = params[i].value; - if ((name.indexOf("+") != -1) || (name.indexOf("%") != -1)) - params[i].name = HttpTestCase.staticUrlDecode(name); - if ((value.indexOf("+") != -1) || (value.indexOf("%") != -1)) - params[i].value = HttpTestCase.staticUrlDecode(value); - } - doParameterList(params); - } - - if (action.getQueryStringParamCount() > 0) { - params = action.getQueryStringParams(); - - for (i = 0; i < params.length; ++i) { - name = params[i].name; - value = params[i].value; - if ((name.indexOf("+") != -1) || (name.indexOf("%") != -1)) - params[i].name = HttpTestCase.staticUrlDecode(name); - if ((value.indexOf("+") != -1) || (value.indexOf("%") != -1)) - params[i].value = HttpTestCase.staticUrlDecode(value); - } - doQueryStringParameterList(params); - } - - if (action.getBodyParamCount() > 0) { - params = action.getBodyParams(); - - for (i = 0; i < params.length; ++i) { - name = params[i].name; - value = params[i].value; - if ((name.indexOf("+") != -1) || (name.indexOf("%") != -1)) - params[i].name = HttpTestCase.staticUrlDecode(name); - if ((value.indexOf("+") != -1) || (value.indexOf("%") != -1)) - params[i].value = HttpTestCase.staticUrlDecode(value); - } - doBodyParameterList(params); - } - - String url_str = header.url; - if (requestBody.length > 0) { - url_str = url_str + '?' + new String(requestBody); - } - - if (!(isMultiPartRequest)) { - doTestUrlMessage(HttpTestCase.staticUrlDecode(url_str).trim()); - } - - String data_str = ""; - String cont_len_str = ""; - - if (isMultiPartRequest) { - method = method + "MultiPart"; - data_str = ", data"; - cont_len_str = ", " + header.contentLength; - - doSetData(action.getMultiPartData()); - } - - doCallUrl(action.getUrl(), method, data_str, cont_len_str); - } - - private HeaderValue[] createHeaders(HttpRequestHeader header) - { - Vector v = new Vector(); - if (header.contentType.length() > 0) - v.add(new HeaderValue("Content-Type", header.contentType)); - if (header.accept.length() > 0) - v.add(new HeaderValue("Accept", header.accept)); - if (header.referer.length() > 0) - v.add(new HeaderValue("Referer", header.referer)); - if (header.pragmaNoCache) - v.add(new HeaderValue("Cache-Control", "no-cache")); - HeaderValue[] hv = new HeaderValue[v.size()]; - return ((HeaderValue[])(HeaderValue[])v.toArray(hv)); - } - - public void processResponse(HttpRequestHeader header, byte[] response) - throws Exception - { - if (this.ignoreNextResponse) { - log.debug("Ignoring response"); - this.ignoreNextResponse = false; - return; - } - - String respStr = new String(response).toLowerCase(); - - String respCode = parseResponseCode(respStr); - String contentType = parseContentType(respStr); - - doAssertResponse(respCode); - - if ((contentType != null) && (mimeTypes.get(contentType) != null) && (respCode != null)) { - if (respCode.startsWith("200")) { - if (respStr.indexOf("org.apache.struts.taglib.html.token") > 0) - setStruts(true); - else - setStruts(false); - - if (contentType.toLowerCase().compareTo("text/html") == 0) { - doTidyCode(HttpTestCase.staticUrlDecode(header.url)); - if (cpRspToStdout) - doResponseForStdOut(HttpTestCase.staticUrlDecode(header.url).trim()); - else if (cpRspToFile) - doResponseForFile(); - } - } - - doEndTransaction(); - } else { - log.debug("Ignoring response because content type is not known: " + contentType); - } - - if (isFirstRequest()) - this.isFirstRequest = false; - } - - public void run() - { - this.outstandingInserts = new LinkedList(); - try { - if (!(Thread.interrupted())) - try - { - synchronized (this.outstandingInserts) - { - this.outstandingInserts.wait(); - StringBuffer sb = new StringBuffer(); - while (this.outstandingInserts.size() > 0) { - sb.append((String)this.outstandingInserts.removeFirst()); - } - - Matcher m = this.insertMarkerRE.matcher(getScriptAdapter().getText()); - if (!(m.find())) - throw new Utils.UserException("You have altered your script and it no longer includes the lines that you were told not to alter."); - getScriptAdapter().insert(sb.toString(), m.start(0)); - } - } catch (Utils.UserException e) { - e.printStackTrace(); - } - } - catch (InterruptedException e) { - log.trace("Thread dead"); - } - } - - public abstract void doAssertResponse(String paramString) - throws Utils.UserException; - - public abstract void doCallUrl(String paramString1, String paramString2, String paramString3, String paramString4) - throws Utils.UserException; - - public abstract void doEndTransaction() - throws Utils.UserException; - - public abstract void setStruts(boolean paramBoolean); - - public abstract void doSetCharset(String paramString) - throws Utils.UserException; - - public abstract void doParameterList(Param[] paramArrayOfParam) - throws Utils.UserException; - - public abstract void doQueryStringParameterList(Param[] paramArrayOfParam) - throws Utils.UserException; - - public abstract void doBodyParameterList(Param[] paramArrayOfParam) - throws Utils.UserException; - - public abstract void doResponseForFile() - throws Utils.UserException; - - public abstract void doResponseForStdOut(String paramString) - throws Utils.UserException; - - public abstract void doSetData(String paramString) - throws Utils.UserException; - - public abstract void doTestUrlMessage(String paramString) - throws Utils.UserException; - - public abstract void doTidyCode(String paramString) - throws Utils.UserException; - - public abstract void doHeaders(HeaderValue[] paramArrayOfHeaderValue); - - protected String getScript() - { - return this.scriptAdapter.getText(); - } - - protected void insert(String s) - throws Utils.UserException - { - synchronized (this.outstandingInserts) - { - this.outstandingInserts.add(s); - this.outstandingInserts.notifyAll(); - } - } - - private String parseContentType(String response) - { - String contentType = null; - - int pos = response.indexOf("content-type:"); - if (pos > -1) { - pos += 14; - int end = response.indexOf("\r\n", pos); - int end2 = response.indexOf(";", pos); - if ((end2 > -1) && (end2 < end)) end = end2; - if (end > -1) - contentType = response.substring(pos, end).trim(); - - log.debug(" Content-Type: " + contentType); - } else { - log.debug(" No content-type header! First few lines:"); - StringTokenizer st = new StringTokenizer(response, "\n"); - int i = 0; - while ((st.hasMoreTokens()) && (i < 5)) { - log.debug(st.nextToken()); - ++i; - } - } - return contentType; - } - - private String parseResponseCode(String response) - { - String respCode = null; - int pos = response.indexOf(" "); - if (pos != -1) { - int end = response.indexOf(" ", pos + 1); - - int end2 = response.indexOf("\n", pos + 1); - if ((end2 != -1) && (end2 < end)) end = end2; - if (end != -1) respCode = response.substring(pos + 1, end).trim(); - } - - log.debug("HTTP response code: " + respCode); - return respCode; - } - - private void setMultiPartData(Action action, HttpRequestHeader header, byte[] strarray) - { - String str = new String(strarray); - int begin = header.contentType.indexOf("boundary="); - int end = header.contentType.indexOf("; ", begin); - if (end == -1) - end = header.contentType.length(); - String boundary = header.contentType.substring(begin + 9, end); - - String[] parts = str.split("--" + boundary); - if ((!($assertionsDisabled)) && (!(parts[0].equals("")))) throw new AssertionError(); - - Pattern re = Pattern.compile("\r\nContent-Disposition: form-data; name=\"([^\"]+)\"[^\r\n]*\r\n\r\n(.*)\r\n", 32); - for (int i = 1; i < parts.length - 1; ++i) { - Matcher m = re.matcher(parts[i]); - boolean ok = m.matches(); - if ((!($assertionsDisabled)) && (!(ok))) throw new AssertionError(); - Param p = new Param(); - p.name = m.group(1); - p.value = m.group(2); - action.addBodyParam(p); - } - - if ((!($assertionsDisabled)) && (!(parts[(parts.length - 1)].equals("--\r\n")))) throw new AssertionError(); - } - - private void setQueryStringParams(Action action, String str) - { - List params = Utils.getParams(str); - Iterator iter = params.iterator(); - while (iter.hasNext()) - action.addQueryStringParam((Param)iter.next()); - } - - private void setBodyParams(Action action, String str) - { - List params = Utils.getParams(str); - Iterator iter = params.iterator(); - while (iter.hasNext()) - action.addBodyParam((Param)iter.next()); - } - - private boolean urlIgnored(String str) - { - boolean ignore = false; - - List incPats = this.config.getIncludePatterns(); - List excPats = this.config.getExcludePatterns(); - if ((!(ignore)) && (incPats.size() != 0)) { - log.debug("urlIgnored: checking for include matches"); - ignore = checkMatch(incPats.iterator(), str, false, true); - } - if ((!(ignore)) && (excPats.size() != 0)) { - log.debug("urlIgnored: checking for exclude matches"); - ignore = checkMatch(excPats.iterator(), str, true, ignore); - } - return ignore; - } - - private boolean checkMatch(Iterator iter, String str, boolean res, boolean def) - { - while (iter.hasNext()) { - Matcher m = ((Pattern)iter.next()).matcher(str); - log.debug("checkMatch: for \"" + str + "\" with pattern: \"" + m.pattern().pattern() + "\""); - if (m.find()) { - log.debug("checkMatch: Found match, returning: " + res); - return res; - } - } - log.debug("checkMatch: Didn't find match, returning: " + def); - return def; - } - - static - { - log = LogFactory.getLog(AbstractCodeGenerator.class); - - cpRspTo = System.getProperty("http.cpRspTo"); - - cpRspToFile = false; - MIME_DEFAULTS = new String[] { "text/plain", "text/html", "text/comma-separated-values" }; - - END_STATEMENT = ";" + EOL; - - jtidyConfigFile = System.getProperty("jtidy.config"); - - if (cpRspTo != null) - if (cpRspTo.toLowerCase().compareTo("stdout") == 0) - cpRspToStdout = true; - else if (cpRspTo.toLowerCase().compareTo("file") == 0) - cpRspToFile = true; - - - mimeTypes = new HashMap(); - for (int i = 0; i < MIME_DEFAULTS.length; ++i) - mimeTypes.put(MIME_DEFAULTS[i], MIME_DEFAULTS[i]); - } +public abstract class AbstractCodeGenerator implements IScriptGenerator, + ProxyServer.Observer, Runnable { + private Config config = Config.getConfig(); + private static final Log log; + private static String cpRspTo; + private static boolean cpRspToStdout; + private static boolean cpRspToFile; + private static final String[] MIME_DEFAULTS; + private static HashMap mimeTypes; + protected static final String END_STATEMENT; + protected static String jtidyConfigFile; + protected long assertNumber = 0L; + protected boolean headersExist = false; + private IScriptAdapter scriptAdapter; + private String testName; + private String defaultTestName; + private String testPath; + private boolean ignoreNextResponse; + private Pattern[] namePatterns; + private LinkedList outstandingInserts; + private Thread insertThread; + private String charset; + private final Pattern insertMarkerRE = Pattern.compile("(^[ \\t]*" + EOL + + ")?" + ".*\\^\\^\\^ Insert new recording.*", 8); + private long timeElapsedSinceLastestRequest = 0L; + private Date latestRequestDate = new Date(); + private boolean isFirstRequest = true; + static final boolean $assertionsDisabled = !(AbstractCodeGenerator.class + .desiredAssertionStatus()); + + public static boolean isCpRspToStdout() { + return cpRspToStdout; + } + + public static boolean isCpRspToFile() { + return cpRspToFile; + } + + public AbstractCodeGenerator(IScriptAdapter adapter, String[] nameRegExps) { + this.scriptAdapter = adapter; + + this.namePatterns = new Pattern[nameRegExps.length]; + for (int i = 0; i < nameRegExps.length; ++i) + this.namePatterns[i] = Pattern.compile(nameRegExps[i], 8); + + this.testName = this.config.getProperty("test.default_testname", + "MaxQTest"); + this.defaultTestName = this.testName; + + this.insertThread = new Thread(this); + this.insertThread.start(); + } + + public String getDefaultTestName() { + return this.defaultTestName; + } + + public void setDefaultTestName(String defaultTestName) { + this.defaultTestName = defaultTestName; + } + + public IScriptAdapter getScriptAdapter() { + return this.scriptAdapter; + } + + public String getTestName() { + return this.testName; + } + + public void setTestName(String testName) { + this.testName = testName; + } + + public String getTestPath() { + return this.testPath; + } + + public void setTestPath(String testPath) { + this.testPath = testPath; + } + + public long getTimeElapsedSinceLastestRequest() { + return this.timeElapsedSinceLastestRequest; + } + + public boolean isFirstRequest() { + return this.isFirstRequest; + } + + public String parseTestName() { + Matcher m = this.namePatterns[0].matcher(getScript()); + if (!(m.find())) + throw new IllegalArgumentException( + "You have fiddled with the formatting of the name of the test embedded in this file. I can no longer understand it."); + + return m.group(1); + } + + public void doSave(String path, String fileName) { + String name = fileName; + int dotPos = fileName.indexOf("."); + if (dotPos > -1) + name = fileName.substring(0, dotPos); + setTestName(name); + setTestPath(path); + + for (int i = 0; i < this.namePatterns.length; ++i) { + Matcher m = this.namePatterns[i].matcher(getScript()); + if (!(m.find())) + throw new IllegalArgumentException( + "Regular expression (\"" + + this.namePatterns[i].pattern() + + "\") provided to constructor cannot match the contents of the script"); + this.scriptAdapter.replace(name, m.start(1), m.end(1)); + } + } + + public void doLoad() { + setTestName(parseTestName()); + } + + public void close() { + this.insertThread.interrupt(); + } + + public void processRequest(HttpRequestHeader header, byte[] requestBody) + throws Exception { + Param[] params; + int i; + String name; + String value; + Date d = new Date(); + this.timeElapsedSinceLastestRequest = (d.getTime() - this.latestRequestDate + .getTime()); + this.latestRequestDate = d; + + if ((header.method.toLowerCase().equals("get")) + && (urlIgnored(header.url))) { + log.debug("Ignoring GET request: \"" + header.url + "\""); + this.ignoreNextResponse = true; + return; + } + + boolean isMultiPartRequest = header.contentType + .startsWith("multipart/form-data"); + boolean isFormRequest = header.contentType + .startsWith("application/x-www-form-urlencoded"); + Action action = new Action(); + + String newCharset = null; + Matcher charsetParser = Pattern.compile("charset=([a-z0-9_\\-]+)", 2) + .matcher(header.contentType); + if (charsetParser.matches()) { + newCharset = charsetParser.group(); + if (!(newCharset.equals(this.charset))) { + doSetCharset(newCharset); + } else if (this.charset != null) { + doSetCharset(null); + } + + } + + doHeaders(createHeaders(header)); + + String url = header.url; + log.debug(" recording url: " + url); + + String method = header.method.toLowerCase(); + + int pos = url.indexOf("?"); + if ((pos != -1) && (url.length() > pos + 1)) { + setQueryStringParams(action, url.substring(pos + 1)); + action.setUrl(HttpTestCase.replaceURL(url.substring(0, pos))); + } else { + // action.setUrl(HttpTestCase.replaceURL(url)); + action.setUrl(url); + } + if (requestBody.length > 0) { + if (isMultiPartRequest) { + setMultiPartData(action, header, requestBody); + } else if (!(isFormRequest)) { + if (newCharset != null) + doSetData(new String(requestBody, newCharset)); + else + doSetData(new String(requestBody)); + + } else if (newCharset != null) + setBodyParams(action, new String(requestBody, newCharset)); + else { + setBodyParams(action, new String(requestBody)); + } + + } + + if (action.getParamsCount() > 0) { + params = action.getParams(); + + for (i = 0; i < params.length; ++i) { + name = params[i].name; + value = params[i].value; + if ((name.indexOf("+") != -1) || (name.indexOf("%") != -1)) + params[i].name = HttpTestCase.staticUrlDecode(name); + if ((value.indexOf("+") != -1) || (value.indexOf("%") != -1)) + params[i].value = HttpTestCase.staticUrlDecode(value); + } + doParameterList(params); + } + + if (action.getQueryStringParamCount() > 0) { + params = action.getQueryStringParams(); + + for (i = 0; i < params.length; ++i) { + name = params[i].name; + value = params[i].value; + if ((name.indexOf("+") != -1) || (name.indexOf("%") != -1)) + params[i].name = HttpTestCase.staticUrlDecode(name); + if ((value.indexOf("+") != -1) || (value.indexOf("%") != -1)) + params[i].value = HttpTestCase.staticUrlDecode(value); + } + doQueryStringParameterList(params); + } + + if (action.getBodyParamCount() > 0) { + params = action.getBodyParams(); + + for (i = 0; i < params.length; ++i) { + name = params[i].name; + value = params[i].value; + if ((name.indexOf("+") != -1) || (name.indexOf("%") != -1)) + params[i].name = HttpTestCase.staticUrlDecode(name); + if ((value.indexOf("+") != -1) || (value.indexOf("%") != -1)) + params[i].value = HttpTestCase.staticUrlDecode(value); + } + doBodyParameterList(params); + } + + String url_str = header.url; + if (requestBody.length > 0) { + url_str = url_str + '?' + new String(requestBody); + } + + if (!(isMultiPartRequest)) { + doTestUrlMessage(HttpTestCase.staticUrlDecode(url_str).trim()); + } + + String data_str = ""; + String cont_len_str = ""; + + if (isMultiPartRequest) { + method = method + "MultiPart"; + data_str = ", data"; + cont_len_str = ", " + header.contentLength; + + doSetData(action.getMultiPartData()); + } + + doCallUrl(action.getUrl(), method, data_str, cont_len_str); + } + + private HeaderValue[] createHeaders(HttpRequestHeader header) { + Vector v = new Vector(); + if (header.contentType.length() > 0) + v.add(new HeaderValue("Content-Type", header.contentType)); + if (header.accept.length() > 0) + v.add(new HeaderValue("Accept", header.accept)); + if (header.referer.length() > 0) + v.add(new HeaderValue("Referer", header.referer)); + if (header.pragmaNoCache) + v.add(new HeaderValue("Cache-Control", "no-cache")); + HeaderValue[] hv = new HeaderValue[v.size()]; + return ((HeaderValue[]) (HeaderValue[]) v.toArray(hv)); + } + + public void processResponse(HttpRequestHeader header, byte[] response) + throws Exception { + if (this.ignoreNextResponse) { + log.debug("Ignoring response"); + this.ignoreNextResponse = false; + return; + } + + String respStr = new String(response).toLowerCase(); + + String respCode = parseResponseCode(respStr); + String contentType = parseContentType(respStr); + + doAssertResponse(respCode); + + if ((contentType != null) && (mimeTypes.get(contentType) != null) + && (respCode != null)) { + if (respCode.startsWith("200")) { + if (respStr.indexOf("org.apache.struts.taglib.html.token") > 0) + setStruts(true); + else + setStruts(false); + + if (contentType.toLowerCase().compareTo("text/html") == 0) { + doTidyCode(HttpTestCase.staticUrlDecode(header.url)); + if (cpRspToStdout) + doResponseForStdOut(HttpTestCase.staticUrlDecode( + header.url).trim()); + else if (cpRspToFile) + doResponseForFile(); + } + } + + doEndTransaction(); + } else { + log.debug("Ignoring response because content type is not known: " + + contentType); + } + + if (isFirstRequest()) + this.isFirstRequest = false; + } + + public void run() { + this.outstandingInserts = new LinkedList(); + try { + while (!(Thread.interrupted())) { + try { + synchronized (this.outstandingInserts) { + this.outstandingInserts.wait(); + StringBuffer sb = new StringBuffer(); + while (this.outstandingInserts.size() > 0) { + sb.append((String) this.outstandingInserts + .removeFirst()); + } + + Matcher m = this.insertMarkerRE + .matcher(getScriptAdapter().getText()); + if (!(m.find())) + throw new Utils.UserException( + "You have altered your script and it no longer includes the lines that you were told not to alter."); + System.out.println(sb.toString()); + getScriptAdapter().insert(sb.toString(), m.start(0)); + } + } catch (Utils.UserException e) { + e.printStackTrace(); + } + } + + } catch (InterruptedException e) { + log.trace("Thread dead"); + } + } + + public abstract void doAssertResponse(String paramString) + throws Utils.UserException; + + public abstract void doCallUrl(String paramString1, String paramString2, + String paramString3, String paramString4) + throws Utils.UserException; + + public abstract void doEndTransaction() throws Utils.UserException; + + public abstract void setStruts(boolean paramBoolean); + + public abstract void doSetCharset(String paramString) + throws Utils.UserException; + + public abstract void doParameterList(Param[] paramArrayOfParam) + throws Utils.UserException; + + public abstract void doQueryStringParameterList(Param[] paramArrayOfParam) + throws Utils.UserException; + + public abstract void doBodyParameterList(Param[] paramArrayOfParam) + throws Utils.UserException; + + public abstract void doResponseForFile() throws Utils.UserException; + + public abstract void doResponseForStdOut(String paramString) + throws Utils.UserException; + + public abstract void doSetData(String paramString) + throws Utils.UserException; + + public abstract void doTestUrlMessage(String paramString) + throws Utils.UserException; + + public abstract void doTidyCode(String paramString) + throws Utils.UserException; + + public abstract void doHeaders(HeaderValue[] paramArrayOfHeaderValue); + + protected String getScript() { + return this.scriptAdapter.getText(); + } + + protected void insert(String s) throws Utils.UserException { + synchronized (this.outstandingInserts) { + this.outstandingInserts.add(s); + this.outstandingInserts.notifyAll(); + } + } + + private String parseContentType(String response) { + String contentType = null; + + int pos = response.indexOf("content-type:"); + if (pos > -1) { + pos += 14; + int end = response.indexOf("\r\n", pos); + int end2 = response.indexOf(";", pos); + if ((end2 > -1) && (end2 < end)) + end = end2; + if (end > -1) + contentType = response.substring(pos, end).trim(); + + log.debug(" Content-Type: " + contentType); + } else { + log.debug(" No content-type header! First few lines:"); + StringTokenizer st = new StringTokenizer(response, "\n"); + int i = 0; + while ((st.hasMoreTokens()) && (i < 5)) { + log.debug(st.nextToken()); + ++i; + } + } + return contentType; + } + + private String parseResponseCode(String response) { + String respCode = null; + int pos = response.indexOf(" "); + if (pos != -1) { + int end = response.indexOf(" ", pos + 1); + + int end2 = response.indexOf("\n", pos + 1); + if ((end2 != -1) && (end2 < end)) + end = end2; + if (end != -1) + respCode = response.substring(pos + 1, end).trim(); + } + + log.debug("HTTP response code: " + respCode); + return respCode; + } + + private void setMultiPartData(Action action, HttpRequestHeader header, + byte[] strarray) { + String str = new String(strarray); + int begin = header.contentType.indexOf("boundary="); + int end = header.contentType.indexOf("; ", begin); + if (end == -1) + end = header.contentType.length(); + String boundary = header.contentType.substring(begin + 9, end); + + String[] parts = str.split("--" + boundary); + if ((!($assertionsDisabled)) && (!(parts[0].equals("")))) + throw new AssertionError(); + + Pattern re = Pattern + .compile( + "\r\nContent-Disposition: form-data; name=\"([^\"]+)\"[^\r\n]*\r\n\r\n(.*)\r\n", + 32); + for (int i = 1; i < parts.length - 1; ++i) { + Matcher m = re.matcher(parts[i]); + boolean ok = m.matches(); + if ((!($assertionsDisabled)) && (!(ok))) + throw new AssertionError(); + Param p = new Param(); + p.name = m.group(1); + p.value = m.group(2); + action.addBodyParam(p); + } + + if ((!($assertionsDisabled)) + && (!(parts[(parts.length - 1)].equals("--\r\n")))) + throw new AssertionError(); + } + + private void setQueryStringParams(Action action, String str) { + List params = Utils.getParams(str); + Iterator iter = params.iterator(); + while (iter.hasNext()) + action.addQueryStringParam((Param) iter.next()); + } + + private void setBodyParams(Action action, String str) { + List params = Utils.getParams(str); + Iterator iter = params.iterator(); + while (iter.hasNext()) + action.addBodyParam((Param) iter.next()); + } + + private boolean urlIgnored(String str) { + boolean ignore = false; + + List incPats = this.config.getIncludePatterns(); + List excPats = this.config.getExcludePatterns(); + if ((!(ignore)) && (incPats.size() != 0)) { + log.debug("urlIgnored: checking for include matches"); + ignore = checkMatch(incPats.iterator(), str, false, true); + } + if ((!(ignore)) && (excPats.size() != 0)) { + log.debug("urlIgnored: checking for exclude matches"); + ignore = checkMatch(excPats.iterator(), str, true, ignore); + } + return ignore; + } + + private boolean checkMatch(Iterator iter, String str, boolean res, + boolean def) { + while (iter.hasNext()) { + Matcher m = ((Pattern) iter.next()).matcher(str); + log.debug("checkMatch: for \"" + str + "\" with pattern: \"" + + m.pattern().pattern() + "\""); + if (m.find()) { + log.debug("checkMatch: Found match, returning: " + res); + return res; + } + } + log.debug("checkMatch: Didn't find match, returning: " + def); + return def; + } + + static { + log = LogFactory.getLog(AbstractCodeGenerator.class); + + cpRspTo = System.getProperty("http.cpRspTo"); + + cpRspToFile = false; + MIME_DEFAULTS = new String[] { "text/plain", "text/html", + "text/comma-separated-values" }; + + END_STATEMENT = ";" + EOL; + + jtidyConfigFile = System.getProperty("jtidy.config"); + + if (cpRspTo != null) + if (cpRspTo.toLowerCase().compareTo("stdout") == 0) + cpRspToStdout = true; + else if (cpRspTo.toLowerCase().compareTo("file") == 0) + cpRspToFile = true; + + mimeTypes = new HashMap(); + for (int i = 0; i < MIME_DEFAULTS.length; ++i) + mimeTypes.put(MIME_DEFAULTS[i], MIME_DEFAULTS[i]); + } } diff --git a/src/main/java/org/bench4q/master/service/PortPoolService.java b/src/main/java/org/bench4q/master/service/PortPoolService.java index 5a0219ba..cfc9bb85 100644 --- a/src/main/java/org/bench4q/master/service/PortPoolService.java +++ b/src/main/java/org/bench4q/master/service/PortPoolService.java @@ -102,7 +102,7 @@ public class PortPoolService { .createCriteria(Port.class) .add(Restrictions.eq("inUse", false)).list(); - if (portList == null) { + if (portList.isEmpty()) { return null; } diff --git a/src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties b/src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties new file mode 100644 index 00000000..8b23e25a --- /dev/null +++ b/src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties @@ -0,0 +1,54 @@ +# This file specifies configuration for maxq. + +# Names of generator classes to make available in the GUI. We do not +# include the Java generator here by default because MaxQ cannot run +# these scripts, only generate them. We do not include SampleGenerator +# because it is only of interest to people writing new generators and +# might confuse regular MaxQ users. +# +# Class names are separated by colons. +generator.classnames=com.bitmechanic.maxq.generator.IsacCodeGenerator + +# What port MaxQ should listen on for requests from the browser. Default is +# port 8090. +local.proxy.port=8090 + +# HTTP proxy settings for MaxQ's own requests; MaxQ can operate behind a +# firewall. +#remote.proxy.host=myproxy +#remote.proxy.port=3128 + + +########################################## +# properties used in TemplateCodeGenerator +########################################## +template.theme=HttpUnit + +########################################## +# properties used in IsacCodeGenerator +########################################## +#for constant think times +generator.isac.timer=ConstantTimer + +#not to capture think times +#generator.isac.timer=null + +#for randomized think times +#generator.isac.timer=Random + +#extra properties for a uniform distribution +#generator.isac.timer.random.dist=uniform +#generator.isac.timer.random.delta=1000 + +#extra properties for a gaussian distribution +#generator.isac.timer.random.dist=gaussian +#generator.isac.timer.random.delta=1000 +#generator.isac.timer.random.deviation=10 + +#extra properties for a Poisson law distribution +#generator.isac.timer.random.dist=poisson +#generator.isac.timer.random.unit=1 + +#extra properties for a negative exponential law distribution +#generator.isac.timer.random.dist=negexpo +#generator.isac.timer.random.delta=10 \ No newline at end of file