Conflicts:
	Bench4Q-Web/src/main/webapp/script/RecordScript/RecordScriptServer.js
This commit is contained in:
hmm 2014-09-04 08:40:55 +08:00
commit 9dfe8caab6
13 changed files with 160 additions and 90 deletions

File diff suppressed because one or more lines are too long

View File

@ -6,24 +6,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.Socket;
import java.net.SocketException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
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.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.log4j.Logger;
import org.bench4q.recorder.httpcapture.Utils.SilentException;
@ -96,17 +85,17 @@ public class RequestHandler implements Runnable {
serverConnection.addRequestProperty("host", host);
serverConnection.addRequestProperty("port", Integer.toString(port));
}
private String stripProxyInfoFromRequestHeader()
throws MalformedURLException {
String res = "";
String origUrl = this.header.url;
URL url = new URL("https://" + origUrl);
this.header.url = url.getFile();
res = this.header.toString();
this.header.url = origUrl;
return res;
}
//
// private String stripProxyInfoFromRequestHeader()
// throws MalformedURLException {
// String res = "";
// String origUrl = this.header.url;
// URL url = new URL("https://" + origUrl);
// this.header.url = url.getFile();
// res = this.header.toString();
// this.header.url = origUrl;
// return res;
// }
public void run() {
try {

View File

@ -2,7 +2,6 @@ package org.bench4q.recorder.httpcapture.generator;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

View File

@ -6,7 +6,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class GzipDecoder extends ContentDecoder {

View File

@ -4,12 +4,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
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.bench4q.recorder.httpcapture.ResponseModel;

View File

@ -16,21 +16,27 @@ import org.bench4q.share.models.agent.RunScenarioModel;
import org.junit.Test;
public class Test_RequestHandler {
private static final int PORT = 8910;
// private static final int PORT = 8910;
// private static ScriptCapturer scriptCapturer;
// @Test
// public void test() {
// try {
// ProxyServer proxyServer = new ProxyServer(PORT);
// Bench4qCodeGenerator observer = new Bench4qCodeGenerator(
// new Bench4qTestScriptAdapter(new RunScenarioModel()));
// proxyServer.addObserver(observer);
// RequestHandler requestHandler = new RequestHandler(proxyServer,
// proxyServer.getServerSocket().accept());
// requestHandler.run();
// } catch (IOException e) {
// e.printStackTrace();
// scriptCapturer = new ScriptCapturer();
// scriptCapturer.startRecordServer(PORT, "test_hemeimei", "hemeimei");
// scriptCapturer.startRecording(PORT);
//
//// ProxyServer proxyServer = new ProxyServer(PORT);
//// Bench4qCodeGenerator observer = new Bench4qCodeGenerator(
//// new Bench4qTestScriptAdapter(new RunScenarioModel()));
//// proxyServer.addObserver(observer);
//// RequestHandler requestHandler = new RequestHandler(proxyServer,
//// proxyServer.getServerSocket().accept());
//// requestHandler.run();
//// proxyServer.
// }
// @Test
// public void testStop(){
// scriptCapturer.stopRecording(PORT);
// scriptCapturer.stopProxyServer(PORT);
// }
//
// @Test

View File

@ -39,7 +39,6 @@ agentManage_jsp_addAgent=Add Agent
portManage_jsp_addPort=Add Port
configuredmessage=Here settings can be configured
startserver=Start Server
stoprecording=Stop Recording
savefile=Save File
editscript=Edit Script
savechanges=Save
@ -200,9 +199,7 @@ edit=Edit
script-submitScript=Submit Script
test-editScript=Edit Script
test-iptip=Please input right ip address
filterStatic=Filter Static Resources
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.
startServer=start server to generate a script or upload a script to server
testExecuteTime=Execute Time
@ -211,4 +208,4 @@ stopTestPlan=Stop Test
stop=Stop
testProxySettings=testProxySettings
startRecording=startRecording
startrecording=start recording to generate a script or upload a script to server
stopRecording=Stop Recording

View File

@ -39,7 +39,6 @@ agentManage_jsp_addAgent=\u6DFB\u52A0\u4EE3\u7406
portManage_jsp_addPort=\u6DFB\u52A0\u7AEF\u53E3
configuredmessage=\u5728\u8FD9\u91CC\u53EF\u4EE5\u914D\u7F6E
startserver=\u542F\u52A8\u670D\u52A1\u5668
stoprecording=\u505C\u6B62\u5f55\u5236
savefile=\u4FDD\u5B58\u6587\u4EF6
editscript=\u7F16\u8F91\u811A\u672C
savechanges=\u4FDD\u5B58
@ -202,9 +201,7 @@ edit=\u7F16\u8F91
script-submitScript=\u4FDD\u5B58\u811A\u672C
test-editScript=\u7F16\u8F91\u811A\u672C
test-iptip=\u8BF7\u8F93\u5165\u6B63\u786E\u7684IP\u5730\u5740
filterStatic=\u8FC7\u6EE4\u9759\u6001\u8D44\u6E90
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
startServer=\u70B9\u51FB\u542F\u52A8\u670D\u52A1\u5F55\u5236\u811A\u672C\u6216\u8005\u4E0A\u4F20\u811A\u672C\u6587\u4EF6
testExecuteTime=\u6267\u884C\u65F6\u95F4
@ -212,4 +209,4 @@ stopTestPlan=\u505C\u6B62\u6D4B\u8BD5
stop=\u505C\u6B62
testProxySettings=\u6d4b\u8bd5Proxy\u8bbe\u7f6e
startRecording=\u5f00\u59cb\u5f55\u5236
startrecording=\u70b9\u51fb\u5f00\u59cb\u5f55\u5236\u5f55\u5236\u811a\u672c
stopRecording=\u505C\u6B62\u5f55\u5236

View File

@ -46,5 +46,5 @@ saveScriptSuccess=Save successfully.
saveScriptFail=Fail to save script.
plugin_jsp_addPage=Add Page
stopTestPlan_fail=Stop running test plan fail
RecordingScript=Recording Script
stoprecord=click stop script recording to stop recording script
startRecordingMessage=Please click start recording
stopRecordingMessage=Please click stop recording

View File

@ -42,5 +42,5 @@ saveScriptSuccess=\u4FDD\u5B58\u6210\u529F\u3002
saveScriptFail=\u4FDD\u5B58\u811A\u672C\u5931\u8D25
plugin_jsp_addPage=\u52A0\u9875
stopTestPlan_fail=\u505C\u6B62\u8FD0\u884C\u6D4B\u8BD5\u8BA1\u5212\u5931\u8D25
RecordingScript=\u6b63\u5728\u5f55\u5236\u811a\u672c
stoprecord=\u70b9\u51fb\u505c\u6b62\u5f55\u5236\u505c\u6b62\u5f55\u5236\u811a\u672c
startRecordingMessage=\u8bf7\u70b9\u51fb\u5f00\u59cb\u5f55\u5236
stopRecordingMessage=\u8bf7\u70b9\u51fb\u505c\u6b62\u5f55\u5236

View File

@ -204,8 +204,8 @@ body {
<fmt:message key="startRecording" />
</button>
<button type="button" class="btn btn-primary"
onClick="stopServer()" id="stopServer">
<fmt:message key="stopserver" />
onClick="stopRecording()" id=stopRecording>
<fmt:message key="stopRecording" />
</button>
</div>
<div id="fileName" class="modal-footer none-div">

View File

@ -1,5 +1,8 @@
var server = null;
var table = $("#scriptTab").DataTable();
var startRecordingSuccess = false;
var startServerSuccess = false;
var stopServerSuccess = false;
function startServer() {
$.post("startRecordServer", {}, function(data) {
@ -13,7 +16,11 @@ function startServer() {
$.i18n.prop("setProxy")+
" IP:133.133.2.100"
+ " ,port: " + server.port
+ $.i18n.prop("recordScript"));
+ $.i18n.prop("recordScript"))
$('#stopRecording').attr('disabled', false);
$('#startRecording').attr('disabled', false);
startServerSuccess = true;
stopServerSuccess = false;
} else {
$('#scriptInfo').html(
$.i18n.prop("startServerFail") + data.failedMessage);
@ -30,15 +37,17 @@ function startRecording() {
if (!data.success) {
$('#scriptInfo3').text(
"start recording error:" + data.failedMessage);
$('#stopServer').attr('disabled', false);
$('#stopRecording').attr('disabled', false);
$('#startRecording').attr('disabled', true);
}
else {
$('#scriptInfo3').text($.i18n.prop("stopRecord"));
$('#scriptInfo3').text($.i18n.prop("stopRecordingMessage"));
var url = $('#target-url2').val();
window.open(url);
$('#stopServer').attr('disabled', false);
$('#stopRecording').attr('disabled', false);
$('#startRecording').attr('disabled', true);
startRecordingSuccess = true;
stopServerSuccess = false;
}
}, "json");
} else {
@ -55,16 +64,18 @@ function stopRecording() {
if (!data.success) {
$('#scriptInfo3').text(
"stop record server error:" + data.failedMessage);
$('#stopServer').attr('disabled', true);
$('#startServer').attr('disabled', false);
$('#stopRecording').attr('disabled', true);
$('#startRecording').attr('disabled', false);
}
else {
$('#stopServer').attr('disabled', true);
$('#scriptInfo3').text(
$.i18n.prop("stoprecord")
);
$('#scriptInfo3').text($.i18n.prop("stopRecord"));
$('#stopRecording').attr('disabled', true);
$('#fileName').show();
stopServer();
stopServerSuccess = true;
startRecordingSuccess = false;
}
}, "json");
} else {
@ -81,11 +92,12 @@ function stopServer() {
if (!data.success) {
$('#scriptInfo3').text(
"stop record server error:" + data.failedMessage);
$('#stopServer').attr('disabled', true);
$('#startServer').attr('disabled', false);
$('#stopRecording').attr('disabled', true);
$('#startRecording').attr('disabled', false);
}
else {
$('#fileName').show();
stopServerSuccess = true;
startServerSuccess = false;
}
}, "json");
} else {
@ -99,7 +111,7 @@ function testRecordProxy() {
$('#mySecondModal').modal('hide');
$('#myThirdModal').modal('show');
$('#scriptInfo3').text(
$.i18n.prop("RecordingScript"));
$.i18n.prop("startRecordingMessage"));
} else {
$("#ProxySettingMessage").attr("class","show");
}

View File

@ -5,6 +5,11 @@ $('.btn-setting').click(function(e) {
function dismiss(container){
$(container).modal('hide');
if(startRecordingSuccess && !stopServerSuccess){
stopRecording();
$('#fileName').hide();
}
if(startServerSuccess && !stopServerSuccess)
stopServer();
}
@ -41,7 +46,7 @@ $('#uploadScript')
$(document).ready(function() {
addEvent(table);
loadScript(table);
$('#stopServer').attr('disabled', true);
$('#stopRecording').attr('disabled', true);
});
function refresh() {