little refa

This commit is contained in:
coderfengyun 2014-01-14 09:26:42 +08:00
parent 4b9ebcb250
commit c7220e919e
2 changed files with 364 additions and 151 deletions

View File

@ -1,17 +1,230 @@
<html>
<head>
<title>Bench4Q Test Case</title>
<link href="style/bootstrap-cerulean.css" />
<link href="style/bootstrap-classic.css" />
<link href="style/bootstrap-cerulean.css" />
</head>
<body>
<img src="images/1.jpg" alt="No this one" />
<img src="images/2.jpg" alt="No this one" />
<img src="images/3.jpg" alt="No this one" />
<script src="script/agentTable.js" type="text/javascript"></script>
<script src="script/base.js" type="text/javascript"></script>
</body>
<html>
<head>
<meta charset="utf-8">
<title>Bench4Q</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
content="Bench4Q, a new method for QOS benchmarking.">
<meta name="author" content="Kai Ren">
<!-- The styles -->
<link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/charisma-app.css" rel="stylesheet">
<link href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet">
<link href='css/colorbox.css' rel='stylesheet'>
<link href='css/noty_theme_default.css' rel='stylesheet'>
<link href='css/opa-icons.css' rel='stylesheet'>
<link rel="shortcut icon" href="img/bench4q.png">
<link href="bench4q-css/bench4q.css" rel="stylesheet">
</head>
<body>
<div class="navbar">
<div class="navbar-inner" id="nav-primary">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse"
data-target=".top-nav.nav-collapse,.sidebar-nav.nav-collapse">
<span class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span>
</a> <a class="brand" href="index.jsp"> <img alt="Charisma Logo"
src="img/bench4q.png" /> <span>Bench4Q</span></a>
<!-- theme selector starts -->
<div class="btn-group pull-right theme-container">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="icon-tint"></i><span class="hidden-phone"> 更换主题 / 皮肤</span> <span class="caret"></span>
</a>
<ul class="dropdown-menu" id="themes">
<li><a data-value="classic" href="#"><i
class="icon-blank"></i> 经典样式</a></li>
<li><a data-value="cerulean" href="#"><i
class="icon-blank"></i> 天蓝色</a></li>
<li><a data-value="cyborg" href="#"><i class="icon-blank"></i>
电子</a></li>
<li><a data-value="redy" href="#"><i class="icon-blank"></i>
Redy</a></li>
<li><a data-value="journal" href="#"><i
class="icon-blank"></i> 日志</a></li>
<li><a data-value="simplex" href="#"><i
class="icon-blank"></i> Simplex</a></li>
<li><a data-value="slate" href="#"><i class="icon-blank"></i>
Slate</a></li>
<li><a data-value="spacelab" href="#"><i
class="icon-blank"></i> Spacelab</a></li>
<li><a data-value="united" href="#"><i class="icon-blank"></i>
United</a></li>
</ul>
</div>
<!-- theme selector ends -->
<!-- user dropdown starts -->
<div class="btn-group pull-right">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="icon-user"></i><span class="hidden-phone"> admin</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">形象</a></li>
<li class="divider"></li>
<li><a href="login.html">注销</a></li>
</ul>
</div>
<!-- user dropdown ends -->
<div class="top-nav nav-collapse">
<ul class="nav">
<li><a href="#">访问站点</a></li>
<li>
<form class="navbar-search pull-left">
<input placeholder="Search" class="search-query sp an2"
name="query" type="text">
</form>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<!-- topbar ends -->
<div class="container-fluid">
<div class="row-fluid">
<div id="content" class="span10 center ">
<!-- content starts -->
<div class="sortable row-fluid ui-sortable">
<a data-rel="tooltip" class="well span3 top-block" href="test.jsp"
data-original-title=新建测试计划> <span
class="icon32 icon-red icon-plus"></span>
<div>
新建测试计划
</div>
</a> <a data-rel="tooltip" class="well span3 top-block"
href="script.jsp"
data-original-title=???scriptmanagerment???>
<span class="icon32 icon-color icon-edit"></span>
<div>
脚本管理
</div>
</a> <a data-rel="tooltip" class="well span3 top-block"
href="testPlanTask.jsp"
data-original-title=测试任务> <span
class="icon32 icon-green icon-envelope-closed"></span>
<div>
测试任务
</div>
</a> </a> <a data-rel="tooltip" class="well span3 top-block"
href="testplans.jsp"
data-original-title=测试历史记录> <span
class="icon32 icon-blue icon-star-on"></span>
<div>
测试历史记录
</div>
</a>
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header well" data-original-title>
<h2>Scripts</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i
class="icon-cog"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a> <a href="#"
class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-condensed" id="scriptTab">
<thead>
<tr>
<th>脚本名称</th>
<th>ID</th>
<th>创建日期</th>
<th>操作</th>
</tr>
</thead>
</table>
</div>
</div>
<!-- content ends -->
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header well" data-original-title>
<h2>Latest Tests</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i
class="icon-cog"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a> <a href="#"
class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<table class="table table-condensed " id="testPlanTab">
<thead>
<tr>
<th>测试计划运行ID</th>
<th>ID</th>
<th>创建日期</th>
<th>status</th>
<th>操作</th>
</tr>
</thead>
</table>
</div>
</div>
<!-- content ends -->
</div>
<!--/#content.span10-->
</div>
<!--/fluid-row-->
</div>
<hr>
<footer>
<p class="pull-left">&copy; Bench4Q 2013</p>
<p class="pull-right">
技术支持
: Bench4Q
</p>
</footer>
</div>
<!-- external javascript ========== -->
<script src="js/jquery-1.8.2.min.js"></script>
<script src="js/jquery-ui-1.8.21.custom.min.js"></script>
<script src='js/jquery.dataTables.min.js'></script>
<script src="js/jquery.i18n.properties-1.0.9.js"></script>
<script src="js/bootstrap-dropdown.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="js/theme.js"></script>
<script src="script/base.js"></script>
<script src="script/scriptTable.js"></script>
<script src="script/bench4q.table.js"></script>
<script src="script/loadTestPlans.js"></script>
<script src="script/home.js"></script>
</body>
</html

View File

@ -1,135 +1,135 @@
package org.bench4q.master.scriptrecord.httpcapture;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.Header;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.impl.io.DefaultHttpRequestParser;
import org.apache.http.impl.io.HttpTransportMetricsImpl;
import org.apache.http.impl.io.SessionInputBufferImpl;
import org.apache.log4j.Logger;
import org.bench4q.master.exception.ExceptionLog;
public class HttpRequestHeader {
private static final Logger log = Logger.getLogger(HttpRequestHeader.class);
public String charset = new String();
public String method = new String();
public String url = new String();
/**
* to support http 1.1
*/
public String host = new String();
public String version = new String();
public String userAgent = new String();
public String referer = new String();
public String ifModifiedSince = new String();
public String accept = new String();
public String authorization = new String();
public String contentType = new String();
public int contentLength = -1;
public int oldContentLength = -1;
public String unrecognized = new String();
public boolean pragmaNoCache = false;
static final String CR = "\r\n";
private HttpRequest httpRequest;
private HttpRequest getHttpRequest() {
return httpRequest;
}
private void setHttpRequest(HttpRequest httpRequest) {
this.httpRequest = httpRequest;
}
public HttpRequestHeader(InputStream in) throws IOException {
SessionInputBufferImpl inputBuffer = new SessionInputBufferImpl(
new HttpTransportMetricsImpl(), 1024);
inputBuffer.bind(in);
try {
this.setHttpRequest(new DefaultHttpRequestParser(inputBuffer)
.parse());
this.url = this.httpRequest.getRequestLine().getUri();
this.method = this.httpRequest.getRequestLine().getMethod();
this.version = this.httpRequest.getRequestLine()
.getProtocolVersion().toString();
this.accept = this.getHeaderValue(HeaderValue.REQUEST_ACCEPT);
this.referer = this.getHeaderValue(HeaderValue.REQUEST_REFERER);
this.userAgent = this
.getHeaderValue(HeaderValue.REQUEST_USER_AGENT);
this.ifModifiedSince = this.getHeaderValue("if-modified-since");
this.authorization = this
.getHeaderValue(HeaderValue.REQUEST_AUTHORIZATION);
this.contentType = this
.getHeaderValue(HeaderValue.ENTITY_CONTENT_TYPE);
this.pragmaNoCache = this
.getHeaderValue(HeaderValue.GENERAL_PRAGMA)
.equalsIgnoreCase("NO-CACHE");
this.host = this.getHeaderValue(HeaderValue.REQUEST_HOST);
if (this.getHttpRequest().containsHeader(
HeaderValue.ENTITY_CONTENT_LENGHT)) {
this.contentLength = Integer.parseInt(this.httpRequest
.getFirstHeader(HeaderValue.ENTITY_CONTENT_LENGHT)
.getValue());
} else {
this.contentLength = 0;
}
} catch (IOException e) {
throw e;
} catch (HttpException e) {
log.error(ExceptionLog.getStackTrace(e));
} catch (NumberFormatException e) {
log.error(ExceptionLog.getStackTrace(e));
}
}
public boolean containsHeader(String name) {
return this.getHttpRequest().containsHeader(name);
}
/**
*
* @param name
* @return if contains this header return the header's value; if not return
* ""
*/
public String getHeaderValue(String name) {
if (!this.containsHeader(name)) {
return "";
}
return this.getHttpRequest().getFirstHeader(name).getValue();
}
public String toString() {
return toStringWithLib();
}
public String toStringWithLib() {
String result = this.getHttpRequest().getRequestLine().toString();
for (Header header : this.getHttpRequest().getAllHeaders()) {
result += CR + header.getName() + ": " + header.getValue();
}
result += CR + CR;
return result;
}
}
package org.bench4q.master.scriptrecord.httpcapture;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.Header;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.impl.io.DefaultHttpRequestParser;
import org.apache.http.impl.io.HttpTransportMetricsImpl;
import org.apache.http.impl.io.SessionInputBufferImpl;
import org.apache.log4j.Logger;
import org.bench4q.master.exception.ExceptionLog;
public class HttpRequestHeader {
private static final Logger log = Logger.getLogger(HttpRequestHeader.class);
public String charset = new String();
public String method = new String();
public String url = new String();
/**
* to support http 1.1
*/
public String host = new String();
public String version = new String();
public String userAgent = new String();
public String referer = new String();
public String ifModifiedSince = new String();
public String accept = new String();
public String authorization = new String();
public String contentType = new String();
public int contentLength = -1;
public int oldContentLength = -1;
public String unrecognized = new String();
public boolean pragmaNoCache = false;
static final String CR = "\r\n";
private HttpRequest httpRequest;
private HttpRequest getHttpRequest() {
return httpRequest;
}
private void setHttpRequest(HttpRequest httpRequest) {
this.httpRequest = httpRequest;
}
public HttpRequestHeader(InputStream in) throws IOException {
SessionInputBufferImpl inputBuffer = new SessionInputBufferImpl(
new HttpTransportMetricsImpl(), 1024);
inputBuffer.bind(in);
try {
this.setHttpRequest(new DefaultHttpRequestParser(inputBuffer)
.parse());
this.url = this.httpRequest.getRequestLine().getUri();
this.method = this.httpRequest.getRequestLine().getMethod();
this.version = this.httpRequest.getRequestLine()
.getProtocolVersion().toString();
this.accept = this.getHeaderValue(HeaderValue.REQUEST_ACCEPT);
this.referer = this.getHeaderValue(HeaderValue.REQUEST_REFERER);
this.userAgent = this
.getHeaderValue(HeaderValue.REQUEST_USER_AGENT);
this.ifModifiedSince = this.getHeaderValue("if-modified-since");
this.authorization = this
.getHeaderValue(HeaderValue.REQUEST_AUTHORIZATION);
this.contentType = this
.getHeaderValue(HeaderValue.ENTITY_CONTENT_TYPE);
this.pragmaNoCache = this
.getHeaderValue(HeaderValue.GENERAL_PRAGMA)
.equalsIgnoreCase("NO-CACHE");
this.host = this.getHeaderValue(HeaderValue.REQUEST_HOST);
if (this.getHttpRequest().containsHeader(
HeaderValue.ENTITY_CONTENT_LENGHT)) {
this.contentLength = Integer.parseInt(this.httpRequest
.getFirstHeader(HeaderValue.ENTITY_CONTENT_LENGHT)
.getValue());
} else {
this.contentLength = 0;
}
} catch (IOException e) {
throw e;
} catch (HttpException e) {
log.error(ExceptionLog.getStackTrace(e));
} catch (NumberFormatException e) {
log.error(ExceptionLog.getStackTrace(e));
}
}
public boolean containsHeader(String name) {
return this.getHttpRequest().containsHeader(name);
}
/**
*
* @param name
* @return if contains this header return the header's value; if not return
* ""
*/
public String getHeaderValue(String name) {
if (!this.containsHeader(name)) {
return "";
}
return this.getHttpRequest().getFirstHeader(name).getValue();
}
public String toString() {
return toStringWithLib();
}
public String toStringWithLib() {
String result = this.getHttpRequest().getRequestLine().toString();
for (Header header : this.getHttpRequest().getAllHeaders()) {
result += CR + header.getName() + ": " + header.getValue();
}
result += CR + CR;
return result;
}
}