Merge branch 'master' of https://github.com/lostcharlie/Bench4Q.git
Conflicts: Bench4Q-Web/src/main/webapp/script/RecordScript/RecordScriptServer.js
This commit is contained in:
commit
9dfe8caab6
File diff suppressed because one or more lines are too long
|
@ -6,24 +6,13 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.ProtocolException;
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
|
|
||||||
import org.apache.commons.httpclient.ChunkedOutputStream;
|
import org.apache.commons.httpclient.ChunkedOutputStream;
|
||||||
import org.apache.commons.httpclient.HttpMethod;
|
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.bench4q.recorder.httpcapture.Utils.SilentException;
|
import org.bench4q.recorder.httpcapture.Utils.SilentException;
|
||||||
|
|
||||||
|
@ -96,17 +85,17 @@ public class RequestHandler implements Runnable {
|
||||||
serverConnection.addRequestProperty("host", host);
|
serverConnection.addRequestProperty("host", host);
|
||||||
serverConnection.addRequestProperty("port", Integer.toString(port));
|
serverConnection.addRequestProperty("port", Integer.toString(port));
|
||||||
}
|
}
|
||||||
|
//
|
||||||
private String stripProxyInfoFromRequestHeader()
|
// private String stripProxyInfoFromRequestHeader()
|
||||||
throws MalformedURLException {
|
// throws MalformedURLException {
|
||||||
String res = "";
|
// String res = "";
|
||||||
String origUrl = this.header.url;
|
// String origUrl = this.header.url;
|
||||||
URL url = new URL("https://" + origUrl);
|
// URL url = new URL("https://" + origUrl);
|
||||||
this.header.url = url.getFile();
|
// this.header.url = url.getFile();
|
||||||
res = this.header.toString();
|
// res = this.header.toString();
|
||||||
this.header.url = origUrl;
|
// this.header.url = origUrl;
|
||||||
return res;
|
// return res;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.bench4q.recorder.httpcapture.generator;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
import java.util.zip.GZIPOutputStream;
|
|
||||||
|
|
||||||
public class GzipDecoder extends ContentDecoder {
|
public class GzipDecoder extends ContentDecoder {
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,7 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.httpclient.ChunkedInputStream;
|
|
||||||
import org.apache.commons.httpclient.ChunkedOutputStream;
|
|
||||||
import org.apache.commons.io.output.ByteArrayOutputStream;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.bench4q.recorder.httpcapture.ResponseModel;
|
import org.bench4q.recorder.httpcapture.ResponseModel;
|
||||||
|
|
||||||
|
|
|
@ -16,21 +16,27 @@ import org.bench4q.share.models.agent.RunScenarioModel;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Test_RequestHandler {
|
public class Test_RequestHandler {
|
||||||
private static final int PORT = 8910;
|
// private static final int PORT = 8910;
|
||||||
|
// private static ScriptCapturer scriptCapturer;
|
||||||
// @Test
|
// @Test
|
||||||
// public void test() {
|
// public void test() {
|
||||||
// try {
|
// scriptCapturer = new ScriptCapturer();
|
||||||
// ProxyServer proxyServer = new ProxyServer(PORT);
|
// scriptCapturer.startRecordServer(PORT, "test_hemeimei", "hemeimei");
|
||||||
// Bench4qCodeGenerator observer = new Bench4qCodeGenerator(
|
// scriptCapturer.startRecording(PORT);
|
||||||
// new Bench4qTestScriptAdapter(new RunScenarioModel()));
|
//
|
||||||
// proxyServer.addObserver(observer);
|
//// ProxyServer proxyServer = new ProxyServer(PORT);
|
||||||
// RequestHandler requestHandler = new RequestHandler(proxyServer,
|
//// Bench4qCodeGenerator observer = new Bench4qCodeGenerator(
|
||||||
// proxyServer.getServerSocket().accept());
|
//// new Bench4qTestScriptAdapter(new RunScenarioModel()));
|
||||||
// requestHandler.run();
|
//// proxyServer.addObserver(observer);
|
||||||
// } catch (IOException e) {
|
//// RequestHandler requestHandler = new RequestHandler(proxyServer,
|
||||||
// e.printStackTrace();
|
//// proxyServer.getServerSocket().accept());
|
||||||
|
//// requestHandler.run();
|
||||||
|
//// proxyServer.
|
||||||
// }
|
// }
|
||||||
|
// @Test
|
||||||
|
// public void testStop(){
|
||||||
|
// scriptCapturer.stopRecording(PORT);
|
||||||
|
// scriptCapturer.stopProxyServer(PORT);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Test
|
// @Test
|
||||||
|
|
|
@ -39,7 +39,6 @@ agentManage_jsp_addAgent=Add Agent
|
||||||
portManage_jsp_addPort=Add Port
|
portManage_jsp_addPort=Add Port
|
||||||
configuredmessage=Here settings can be configured
|
configuredmessage=Here settings can be configured
|
||||||
startserver=Start Server
|
startserver=Start Server
|
||||||
stoprecording=Stop Recording
|
|
||||||
savefile=Save File
|
savefile=Save File
|
||||||
editscript=Edit Script
|
editscript=Edit Script
|
||||||
savechanges=Save
|
savechanges=Save
|
||||||
|
@ -200,9 +199,7 @@ edit=Edit
|
||||||
script-submitScript=Submit Script
|
script-submitScript=Submit Script
|
||||||
test-editScript=Edit Script
|
test-editScript=Edit Script
|
||||||
test-iptip=Please input right ip address
|
test-iptip=Please input right ip address
|
||||||
filterStatic=Filter Static Resources
|
|
||||||
filterTime=Filter Think Time
|
filterTime=Filter Think Time
|
||||||
staticTip=The static resources contains:js,css,jpeg,gif,png files.
|
|
||||||
timeTipe=The Think time refers the time between tow behaviors.
|
timeTipe=The Think time refers the time between tow behaviors.
|
||||||
startServer=start server to generate a script or upload a script to server
|
startServer=start server to generate a script or upload a script to server
|
||||||
testExecuteTime=Execute Time
|
testExecuteTime=Execute Time
|
||||||
|
@ -211,4 +208,4 @@ stopTestPlan=Stop Test
|
||||||
stop=Stop
|
stop=Stop
|
||||||
testProxySettings=testProxySettings
|
testProxySettings=testProxySettings
|
||||||
startRecording=startRecording
|
startRecording=startRecording
|
||||||
startrecording=start recording to generate a script or upload a script to server
|
stopRecording=Stop Recording
|
|
@ -39,7 +39,6 @@ agentManage_jsp_addAgent=\u6DFB\u52A0\u4EE3\u7406
|
||||||
portManage_jsp_addPort=\u6DFB\u52A0\u7AEF\u53E3
|
portManage_jsp_addPort=\u6DFB\u52A0\u7AEF\u53E3
|
||||||
configuredmessage=\u5728\u8FD9\u91CC\u53EF\u4EE5\u914D\u7F6E
|
configuredmessage=\u5728\u8FD9\u91CC\u53EF\u4EE5\u914D\u7F6E
|
||||||
startserver=\u542F\u52A8\u670D\u52A1\u5668
|
startserver=\u542F\u52A8\u670D\u52A1\u5668
|
||||||
stoprecording=\u505C\u6B62\u5f55\u5236
|
|
||||||
savefile=\u4FDD\u5B58\u6587\u4EF6
|
savefile=\u4FDD\u5B58\u6587\u4EF6
|
||||||
editscript=\u7F16\u8F91\u811A\u672C
|
editscript=\u7F16\u8F91\u811A\u672C
|
||||||
savechanges=\u4FDD\u5B58
|
savechanges=\u4FDD\u5B58
|
||||||
|
@ -202,9 +201,7 @@ edit=\u7F16\u8F91
|
||||||
script-submitScript=\u4FDD\u5B58\u811A\u672C
|
script-submitScript=\u4FDD\u5B58\u811A\u672C
|
||||||
test-editScript=\u7F16\u8F91\u811A\u672C
|
test-editScript=\u7F16\u8F91\u811A\u672C
|
||||||
test-iptip=\u8BF7\u8F93\u5165\u6B63\u786E\u7684IP\u5730\u5740
|
test-iptip=\u8BF7\u8F93\u5165\u6B63\u786E\u7684IP\u5730\u5740
|
||||||
filterStatic=\u8FC7\u6EE4\u9759\u6001\u8D44\u6E90
|
|
||||||
filterTime=\u8FC7\u6EE4\u601D\u8003\u65F6\u95F4
|
filterTime=\u8FC7\u6EE4\u601D\u8003\u65F6\u95F4
|
||||||
staticTip=\u9759\u6001\u8D44\u6E90\u4E3B\u8981\u662F\u6307:js,css,jpeg,gif,png\u6587\u4EF6\u3002
|
|
||||||
timeTip=\u601D\u8003\u65F6\u95F4\u6307\u7684\u662F\u7528\u6237\u4E24\u4E2A\u8FDE\u7EED\u884C\u4E3A\u4E4B\u95F4\u7684\u95F4\u9694\u65F6\u95F4
|
timeTip=\u601D\u8003\u65F6\u95F4\u6307\u7684\u662F\u7528\u6237\u4E24\u4E2A\u8FDE\u7EED\u884C\u4E3A\u4E4B\u95F4\u7684\u95F4\u9694\u65F6\u95F4
|
||||||
startServer=\u70B9\u51FB\u542F\u52A8\u670D\u52A1\u5F55\u5236\u811A\u672C\u6216\u8005\u4E0A\u4F20\u811A\u672C\u6587\u4EF6
|
startServer=\u70B9\u51FB\u542F\u52A8\u670D\u52A1\u5F55\u5236\u811A\u672C\u6216\u8005\u4E0A\u4F20\u811A\u672C\u6587\u4EF6
|
||||||
testExecuteTime=\u6267\u884C\u65F6\u95F4
|
testExecuteTime=\u6267\u884C\u65F6\u95F4
|
||||||
|
@ -212,4 +209,4 @@ stopTestPlan=\u505C\u6B62\u6D4B\u8BD5
|
||||||
stop=\u505C\u6B62
|
stop=\u505C\u6B62
|
||||||
testProxySettings=\u6d4b\u8bd5Proxy\u8bbe\u7f6e
|
testProxySettings=\u6d4b\u8bd5Proxy\u8bbe\u7f6e
|
||||||
startRecording=\u5f00\u59cb\u5f55\u5236
|
startRecording=\u5f00\u59cb\u5f55\u5236
|
||||||
startrecording=\u70b9\u51fb\u5f00\u59cb\u5f55\u5236\u5f55\u5236\u811a\u672c
|
stopRecording=\u505C\u6B62\u5f55\u5236
|
|
@ -46,5 +46,5 @@ saveScriptSuccess=Save successfully.
|
||||||
saveScriptFail=Fail to save script.
|
saveScriptFail=Fail to save script.
|
||||||
plugin_jsp_addPage=Add Page
|
plugin_jsp_addPage=Add Page
|
||||||
stopTestPlan_fail=Stop running test plan fail
|
stopTestPlan_fail=Stop running test plan fail
|
||||||
RecordingScript=Recording Script
|
startRecordingMessage=Please click start recording
|
||||||
stoprecord=click stop script recording to stop recording script
|
stopRecordingMessage=Please click stop recording
|
|
@ -42,5 +42,5 @@ saveScriptSuccess=\u4FDD\u5B58\u6210\u529F\u3002
|
||||||
saveScriptFail=\u4FDD\u5B58\u811A\u672C\u5931\u8D25
|
saveScriptFail=\u4FDD\u5B58\u811A\u672C\u5931\u8D25
|
||||||
plugin_jsp_addPage=\u52A0\u9875
|
plugin_jsp_addPage=\u52A0\u9875
|
||||||
stopTestPlan_fail=\u505C\u6B62\u8FD0\u884C\u6D4B\u8BD5\u8BA1\u5212\u5931\u8D25
|
stopTestPlan_fail=\u505C\u6B62\u8FD0\u884C\u6D4B\u8BD5\u8BA1\u5212\u5931\u8D25
|
||||||
RecordingScript=\u6b63\u5728\u5f55\u5236\u811a\u672c
|
startRecordingMessage=\u8bf7\u70b9\u51fb\u5f00\u59cb\u5f55\u5236
|
||||||
stoprecord=\u70b9\u51fb\u505c\u6b62\u5f55\u5236\u505c\u6b62\u5f55\u5236\u811a\u672c
|
stopRecordingMessage=\u8bf7\u70b9\u51fb\u505c\u6b62\u5f55\u5236
|
|
@ -204,8 +204,8 @@ body {
|
||||||
<fmt:message key="startRecording" />
|
<fmt:message key="startRecording" />
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-primary"
|
<button type="button" class="btn btn-primary"
|
||||||
onClick="stopServer()" id="stopServer">
|
onClick="stopRecording()" id=stopRecording>
|
||||||
<fmt:message key="stopserver" />
|
<fmt:message key="stopRecording" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="fileName" class="modal-footer none-div">
|
<div id="fileName" class="modal-footer none-div">
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
var server = null;
|
var server = null;
|
||||||
var table = $("#scriptTab").DataTable();
|
var table = $("#scriptTab").DataTable();
|
||||||
|
var startRecordingSuccess = false;
|
||||||
|
var startServerSuccess = false;
|
||||||
|
var stopServerSuccess = false;
|
||||||
|
|
||||||
function startServer() {
|
function startServer() {
|
||||||
$.post("startRecordServer", {}, function(data) {
|
$.post("startRecordServer", {}, function(data) {
|
||||||
|
@ -13,7 +16,11 @@ function startServer() {
|
||||||
$.i18n.prop("setProxy")+
|
$.i18n.prop("setProxy")+
|
||||||
" IP:133.133.2.100"
|
" IP:133.133.2.100"
|
||||||
+ " ,port: " + server.port
|
+ " ,port: " + server.port
|
||||||
+ $.i18n.prop("recordScript"));
|
+ $.i18n.prop("recordScript"))
|
||||||
|
$('#stopRecording').attr('disabled', false);
|
||||||
|
$('#startRecording').attr('disabled', false);
|
||||||
|
startServerSuccess = true;
|
||||||
|
stopServerSuccess = false;
|
||||||
} else {
|
} else {
|
||||||
$('#scriptInfo').html(
|
$('#scriptInfo').html(
|
||||||
$.i18n.prop("startServerFail") + data.failedMessage);
|
$.i18n.prop("startServerFail") + data.failedMessage);
|
||||||
|
@ -30,15 +37,17 @@ function startRecording() {
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
$('#scriptInfo3').text(
|
$('#scriptInfo3').text(
|
||||||
"start recording error:" + data.failedMessage);
|
"start recording error:" + data.failedMessage);
|
||||||
$('#stopServer').attr('disabled', false);
|
$('#stopRecording').attr('disabled', false);
|
||||||
$('#startRecording').attr('disabled', true);
|
$('#startRecording').attr('disabled', true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#scriptInfo3').text($.i18n.prop("stopRecord"));
|
$('#scriptInfo3').text($.i18n.prop("stopRecordingMessage"));
|
||||||
var url = $('#target-url2').val();
|
var url = $('#target-url2').val();
|
||||||
window.open(url);
|
window.open(url);
|
||||||
$('#stopServer').attr('disabled', false);
|
$('#stopRecording').attr('disabled', false);
|
||||||
$('#startRecording').attr('disabled', true);
|
$('#startRecording').attr('disabled', true);
|
||||||
|
startRecordingSuccess = true;
|
||||||
|
stopServerSuccess = false;
|
||||||
}
|
}
|
||||||
}, "json");
|
}, "json");
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,16 +64,18 @@ function stopRecording() {
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
$('#scriptInfo3').text(
|
$('#scriptInfo3').text(
|
||||||
"stop record server error:" + data.failedMessage);
|
"stop record server error:" + data.failedMessage);
|
||||||
$('#stopServer').attr('disabled', true);
|
|
||||||
$('#startServer').attr('disabled', false);
|
|
||||||
|
|
||||||
|
$('#stopRecording').attr('disabled', true);
|
||||||
|
$('#startRecording').attr('disabled', false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#stopServer').attr('disabled', true);
|
|
||||||
$('#scriptInfo3').text(
|
$('#scriptInfo3').text($.i18n.prop("stopRecord"));
|
||||||
$.i18n.prop("stoprecord")
|
$('#stopRecording').attr('disabled', true);
|
||||||
);
|
$('#fileName').show();
|
||||||
stopServer();
|
stopServer();
|
||||||
|
stopServerSuccess = true;
|
||||||
|
startRecordingSuccess = false;
|
||||||
}
|
}
|
||||||
}, "json");
|
}, "json");
|
||||||
} else {
|
} else {
|
||||||
|
@ -81,11 +92,12 @@ function stopServer() {
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
$('#scriptInfo3').text(
|
$('#scriptInfo3').text(
|
||||||
"stop record server error:" + data.failedMessage);
|
"stop record server error:" + data.failedMessage);
|
||||||
$('#stopServer').attr('disabled', true);
|
$('#stopRecording').attr('disabled', true);
|
||||||
$('#startServer').attr('disabled', false);
|
$('#startRecording').attr('disabled', false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#fileName').show();
|
stopServerSuccess = true;
|
||||||
|
startServerSuccess = false;
|
||||||
}
|
}
|
||||||
}, "json");
|
}, "json");
|
||||||
} else {
|
} else {
|
||||||
|
@ -99,7 +111,7 @@ function testRecordProxy() {
|
||||||
$('#mySecondModal').modal('hide');
|
$('#mySecondModal').modal('hide');
|
||||||
$('#myThirdModal').modal('show');
|
$('#myThirdModal').modal('show');
|
||||||
$('#scriptInfo3').text(
|
$('#scriptInfo3').text(
|
||||||
$.i18n.prop("RecordingScript"));
|
$.i18n.prop("startRecordingMessage"));
|
||||||
} else {
|
} else {
|
||||||
$("#ProxySettingMessage").attr("class","show");
|
$("#ProxySettingMessage").attr("class","show");
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,11 @@ $('.btn-setting').click(function(e) {
|
||||||
|
|
||||||
function dismiss(container){
|
function dismiss(container){
|
||||||
$(container).modal('hide');
|
$(container).modal('hide');
|
||||||
|
if(startRecordingSuccess && !stopServerSuccess){
|
||||||
|
stopRecording();
|
||||||
|
$('#fileName').hide();
|
||||||
|
}
|
||||||
|
if(startServerSuccess && !stopServerSuccess)
|
||||||
stopServer();
|
stopServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +46,7 @@ $('#uploadScript')
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
addEvent(table);
|
addEvent(table);
|
||||||
loadScript(table);
|
loadScript(table);
|
||||||
$('#stopServer').attr('disabled', true);
|
$('#stopRecording').attr('disabled', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
|
|
Loading…
Reference in New Issue