refactor master messenger test

This commit is contained in:
fanfuxiaoran 2014-05-14 11:39:06 +08:00
parent f40befc151
commit bf8f1693ee
16 changed files with 626 additions and 842 deletions

View File

@ -11,7 +11,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.JAXBException;
import javax.xml.transform.Source;
@ -39,7 +38,6 @@ import org.bench4q.web.service.BaseService;
import org.bench4q.web.service.CommunicateWithMaster;
import org.bench4q.web.service.ScriptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;

View File

@ -14,7 +14,7 @@ button {
color: #212121;
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
margin-bottom: 20px;
}
.containerBox .header {
@ -39,12 +39,12 @@ button {
height: 36;
}
.deviceSize {
.separator {
width: 80%;
border: 1px solid #d5d5d5;
border-top: 3px solid #212121;
color: #212121;
margin-top: 10px;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
height: 50px;
@ -53,14 +53,14 @@ button {
text-align: center;
}
.deviceSize label {
.separator label {
margin-right: 10px;
font-weight: bold;
font-size: 25px;
font-weight: bold;
}
.deviceSize input {
.separator input {
width: 100px;
height: 25px;
font-weight: bold;
@ -95,7 +95,7 @@ button {
width: 80%;
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
margin-bottom: 20px;
}
tr,thead {

View File

@ -1 +1,157 @@
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('!7($){"X W";9 h=7(3,a){2.$3=$(3)2.a=$.V({},$.q.4.K,a)8(2.a.g){2.$g=$(2.a.g)}2.a.f&&2.f()}h.Y={Z:h,5:7(){9 B=2.$3.w(\'A\')b B?\'A\':\'10\'},m:7(){9 5,p,c,i 8(2.j)b 5=2.5()p=$.U([\'p\',5].13(\'-\'))c=2.$g&&2.$g.M(\'> .O-N > .v\')8(c&&c.P){i=c.6(\'4\')8(i&&i.j)b c.4(\'l\')i||c.6(\'4\',E)}2.$3[5](0)2.k(\'H\',$.D(\'m\'),\'R\')2.$3[5](2.$3[0][p])},l:7(){9 5 8(2.j)b 5=2.5()2.y(2.$3[5]())2.k(\'x\',$.D(\'l\'),\'14\')2.$3[5](0)},y:7(z){9 5=2.5()2.$3.x(\'4\')[5](z||\'1f\')[0].1e 2.$3[z!==E?\'H\':\'x\'](\'4\')b 2},k:7(C,n,I){9 o=2,u=7(){8(n.1h==\'m\')o.y()o.j=0 o.$3.F(I)}2.$3.F(n)8(n.19())b 2.j=1 2.$3[C](\'v\')$.G.k&&2.$3.w(\'4\')?2.$3.1a($.G.k.1b,u):u()},f:7(){2[2.$3.w(\'v\')?\'l\':\'m\']()}}$.q.4=7(d){b 2.15(7(){9 $2=$(2),6=$2.6(\'4\'),a=J d==\'17\'&&d 8(!6)$2.6(\'4\',(6=1d h(2,a)))8(J d==\'1i\')6[d]()})}$.q.4.K={f:Q}$.q.4.S=h $(7(){$(\'12\').16(\'11.4.6-1j\',\'[6-f=4]\',7(e){9 $2=$(2),r,t=$2.L(\'6-t\')||e.18()||(r=$2.L(\'r\'))&&r.1g(/.*(?=#[^\\s]+$)/,\'\'),d=$(t).6(\'4\')?\'f\':$2.6()$(t).4(d)})})}(T.1c);',62,82,'||this|element|collapse|dimension|data|function|if|var|options|return|actives|option||toggle|parent|Collapse|hasData|transitioning|transition|hide|show|startEvent|that|scroll|fn|href||target|complete|in|hasClass|removeClass|reset|size|width|hasWidth|method|Event|null|trigger|support|addClass|completeEvent|typeof|defaults|attr|find|group|accordion|length|true|shown|Constructor|window|camelCase|extend|strict|use|prototype|constructor|height|click|body|join|hidden|each|on|object|preventDefault|isDefaultPrevented|one|end|jQuery|new|offsetWidth|auto|replace|type|string|api'.split('|'),0,{}))
/* =============================================================
* bootstrap-collapse.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#collapse
* =============================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============================================================ */
!function ($) {
"use strict"; // jshint ;_;
/* COLLAPSE PUBLIC CLASS DEFINITION
* ================================ */
var Collapse = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, $.fn.collapse.defaults, options)
if (this.options.parent) {
this.$parent = $(this.options.parent)
}
this.options.toggle && this.toggle()
}
Collapse.prototype = {
constructor: Collapse
, dimension: function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
, show: function () {
var dimension
, scroll
, actives
, hasData
if (this.transitioning) return
dimension = this.dimension()
scroll = $.camelCase(['scroll', dimension].join('-'))
actives = this.$parent && this.$parent.find('> .accordion-group > .in')
if (actives && actives.length) {
hasData = actives.data('collapse')
if (hasData && hasData.transitioning) return
actives.collapse('hide')
hasData || actives.data('collapse', null)
}
this.$element[dimension](0)
this.transition('addClass', $.Event('show'), 'shown')
this.$element[dimension](this.$element[0][scroll])
}
, hide: function () {
var dimension
if (this.transitioning) return
dimension = this.dimension()
this.reset(this.$element[dimension]())
this.transition('removeClass', $.Event('hide'), 'hidden')
this.$element[dimension](0)
}
, reset: function (size) {
var dimension = this.dimension()
this.$element
.removeClass('collapse')
[dimension](size || 'auto')
[0].offsetWidth
this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
return this
}
, transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function () {
if (startEvent.type == 'show') that.reset()
that.transitioning = 0
that.$element.trigger(completeEvent)
}
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
this.transitioning = 1
this.$element[method]('in')
$.support.transition && this.$element.hasClass('collapse') ?
this.$element.one($.support.transition.end, complete) :
complete()
}
, toggle: function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
}
/* COLLAPSIBLE PLUGIN DEFINITION
* ============================== */
$.fn.collapse = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('collapse')
, options = typeof option == 'object' && option
if (!data) $this.data('collapse', (data = new Collapse(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.collapse.defaults = {
toggle: true
}
$.fn.collapse.Constructor = Collapse
/* COLLAPSIBLE DATA-API
* ==================== */
$(function () {
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
var $this = $(this), href
, target = $this.attr('data-target')
|| e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
, option = $(target).data('collapse') ? 'toggle' : $this.data()
$(target).collapse(option)
})
})
}(window.jQuery);

View File

@ -1,165 +1,165 @@
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<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.">
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
rel="stylesheet">
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link rel="shortcut icon" href="image/bench4q.png">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href='lib/chrisma/css/opa-icons.css' rel='stylesheet'>
<link href='lib/jsoneditor/css/jsoneditor.css' rel='stylesheet'>
<link href='css/editor.css' rel='stylesheet'>
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- The fav icon -->
</head>
<body>
<fmt:bundle basename="i18n">
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
<div class="container-fluid">
<div class="row-fluid">
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<div class="tab span10">
<ul style="cursor: pointer" class="nav nav-tabs">
<li id="tow1" class="on" onclick='refresh();setTab("tow",1,3);'><a
href="#">View</a></li>
<li id="tow2" onclick='setTab("tow",2,3);'><a href="#">EditBehaviors</a></li>
<li id="tow3" onclick='setTab("tow",3,3);'><a href="#">EditPlugins</a></li>
</ul>
</div>
<div class="span10">
<div id="cont_tow_1" class="one block">
<div id="contents" class="span8">
<div id="codeEditor" class="view"></div>
</div>
<jsp:include page="publiccontrol/scriptEditRightMenuBar.jsp"></jsp:include>
</div>
<div id="cont_tow_2" class="one" style="display: none">
<div class="all-plugins btn-group span12">
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
<span class="hidden-phone"> All plug-ins </span> <span
class="caret"></span>
</a>
<ul class="dropdown-menu" id="allPlugins">
<li><a onclick="choosePlugin(this);">All</a></li>
<li class="divider"></li>
</ul>
</div>
<div class="row-fluid">
<div id="behaviors" class="all-behaviors span4">
<ul id="behaviorUl">
</ul>
</div>
<div class="span8">
<div id="showPluginMethodForm"></div>
<div id="action" style="display: none">
<button type="button" class="btn btn-primary" id="submit"
title="save edit">
<fmt:message key="script_edit_jsp_save"></fmt:message>
</button>
<button type="button" class="btn btn-primary" id="cancel"
title="cancel edit">
<fmt:message key="script_edit_jsp_cancel" />
</button>
<button type="button" class="btn btn-primary" id="validate"
title="validate edit">
<fmt:message key="script_edit_jsp_validate"></fmt:message>
</button>
</div>
</div>
</div>
</div>
<div id="cont_tow_3" class="one" style="display: none">
<div class="all-plugins btn-group span12">
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
<span class="hidden-phone"> All plug-ins </span> <span
class="caret"></span>
</a>
<ul class="dropdown-menu" id="allPlugins">
<li><a onclick="choosePlugin(this);">All</a></li>
<li class="divider"></li>
</ul>
</div>
<div class="row-fluid">
<div id="usePlugins" class="all-behaviors span4">
<ul id="usePlugin">
</ul>
</div>
<div class="span8">
<div id="pluginParamArea"></div>
</div>
</div>
<div id="usePluginAction" style="float: right">
<button type="button" class="btn btn-primary" id="submitPlugin"
title="save edit">
<fmt:message key="script_edit_jsp_save"></fmt:message>
</button>
<button type="button" class="btn btn-primary" id="cancel"
title="cancel edit">
<fmt:message key="script_edit_jsp_cancel" />
</button>
<button type="button" class="btn btn-primary" id="validate"
title="validate edit">
<fmt:message key="script_edit_jsp_validate"></fmt:message>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- </div> -->
<hr>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.1/bootstrap.min.js"></script>
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="lib/chrisma/js/theme.js"></script>
<script src="lib/jsonvalidate/script-edit-uri.js"></script>
<script src="lib/jsonvalidate/script-edit-jsv.js"></script>
<script src="lib/jsonvalidate/script-edit-json-schema-draft.js"></script>
<script src="lib/jsoneditor/js/jsoneditor.js"></script>
<script src="lib/ace/js/ace.js"></script>
<script src="lib/ace/js/mode-json.js"></script>
<script src="lib/ace/js/ext-searchbox.js"></script>
<script src="lib/ace/js/theme-textmate.js"></script>
<script src="lib/ace/js/theme-jsoneditor.js"></script>
<script src="script/base.js"></script>
<script src="script/ScriptEditor/uiCommon.js"></script>
<script src="script/jsonEditorApp.js"></script>
<script src="script/ScriptEditor/paramInfosForm.js"></script>
<script src="script/ScriptEditor/pluginModel.js"></script>
<script src="script/editScript.js"></script>
</fmt:bundle>
</body>
</html>
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<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.">
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
rel="stylesheet">
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link rel="shortcut icon" href="image/bench4q.png">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href='lib/chrisma/css/opa-icons.css' rel='stylesheet'>
<link href='lib/jsoneditor/css/jsoneditor.css' rel='stylesheet'>
<link href='css/editor.css' rel='stylesheet'>
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- The fav icon -->
</head>
<body>
<fmt:bundle basename="i18n">
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
<div class="container-fluid">
<div class="row-fluid">
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<div class="tab span10">
<ul style="cursor: pointer" class="nav nav-tabs">
<li id="tow1" class="on" onclick='refresh();setTab("tow",1,3);'><a
href="#">View</a></li>
<li id="tow2" onclick='setTab("tow",2,3);'><a href="#">EditBehaviors</a></li>
<li id="tow3" onclick='setTab("tow",3,3);'><a href="#">EditPlugins</a></li>
</ul>
</div>
<div class="span10">
<div id="cont_tow_1" class="one block">
<div id="contents" class="span8">
<div id="codeEditor" class="view"></div>
</div>
<jsp:include page="publiccontrol/scriptEditRightMenuBar.jsp"></jsp:include>
</div>
<div id="cont_tow_2" class="one" style="display: none">
<div class="all-plugins btn-group span12">
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
<span class="hidden-phone"> All plug-ins </span> <span
class="caret"></span>
</a>
<ul class="dropdown-menu" id="allPlugins">
<li><a onclick="choosePlugin(this);">All</a></li>
<li class="divider"></li>
</ul>
</div>
<div class="row-fluid">
<div id="behaviors" class="all-behaviors span4">
<ul id="behaviorUl">
</ul>
</div>
<div class="span8">
<div id="showPluginMethodForm"></div>
<div id="action" style="display: none">
<button type="button" class="btn btn-primary" id="submit"
title="save edit">
<fmt:message key="script_edit_jsp_save"></fmt:message>
</button>
<button type="button" class="btn btn-primary" id="cancel"
title="cancel edit">
<fmt:message key="script_edit_jsp_cancel" />
</button>
<button type="button" class="btn btn-primary" id="validate"
title="validate edit">
<fmt:message key="script_edit_jsp_validate"></fmt:message>
</button>
</div>
</div>
</div>
</div>
<div id="cont_tow_3" class="one" style="display: none">
<div class="all-plugins btn-group span12">
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
<span class="hidden-phone"> All plug-ins </span> <span
class="caret"></span>
</a>
<ul class="dropdown-menu" id="allPlugins">
<li><a onclick="choosePlugin(this);">All</a></li>
<li class="divider"></li>
</ul>
</div>
<div class="row-fluid">
<div id="usePlugins" class="all-behaviors span4">
<ul id="usePlugin">
</ul>
</div>
<div class="span8">
<div id="pluginParamArea"></div>
</div>
</div>
<div id="usePluginAction" style="float:right">
<button type="button" class="btn btn-primary" id="submitPlugin"
title="save edit">
<fmt:message key="script_edit_jsp_save"></fmt:message>
</button>
<button type="button" class="btn btn-primary" id="cancel"
title="cancel edit">
<fmt:message key="script_edit_jsp_cancel" />
</button>
<button type="button" class="btn btn-primary" id="validate"
title="validate edit">
<fmt:message key="script_edit_jsp_validate"></fmt:message>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- </div> -->
<hr>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
<script
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.1/bootstrap.min.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="lib/chrisma/js/theme.js"></script>
<script src="lib/jsonvalidate/script-edit-uri.js"></script>
<script src="lib/jsonvalidate/script-edit-jsv.js"></script>
<script src="lib/jsonvalidate/script-edit-json-schema-draft.js"></script>
<script src="lib/jsoneditor/js/jsoneditor.js"></script>
<script src="lib/ace/js/ace.js"></script>
<script src="lib/ace/js/mode-json.js"></script>
<script src="lib/ace/js/theme-textmate.js"></script>
<script src="lib/ace/js/theme-jsoneditor.js"></script>
<script src="lib/bootstrap/js/bootstrap-collapse.js"></script>
<script src="script/base.js"></script>
<script src="script/ScriptEditor/pluginCommon.js"></script>
<script src="script/ScriptEditor/jsonEditorApp.js"></script>
<script src="script/ScriptEditor/paramInfosForm.js"></script>
<script src="script/ScriptEditor/pluginModel.js"></script>
<script src="script/ScriptEditor/editScript.js"></script>
</fmt:bundle>
</body>
</html>

View File

@ -1,196 +1,199 @@
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<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.">
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css" rel="stylesheet">
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href="css/bench4q.css" rel="stylesheet">
<link rel="shortcut icon" href="images/bench4q.png">
<style type="text/css">
body {
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
</head>
<body>
<fmt:bundle basename="i18n">
<!-- topbar starts -->
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
<!-- topbar ends -->
<div class="container-fluid">
<div class="row-fluid">
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<noscript>
<div class="alert alert-block span10">
<h4 class="alert-heading">
<fmt:message key="warning" />
!
</h4>
<p>
<fmt:message key="warningcontent1" />
<a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
<fmt:message key="warningcontent2" />
.
</p>
</div>
</noscript>
<div id="content" class="span10">
<!-- content starts -->
<div>
<ul class="breadcrumb">
<li><a href="homepage.jsp"><fmt:message key="home" /></a> <span
class="divider">/</span></li>
<li><a href="script.jsp"><fmt:message
key="scriptmanagement" /></a></li>
</ul>
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header well" data-original-title>
<h2>
<i></i>
<fmt:message key="script" />
</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i
class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i
class="icon-list"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a>
</div>
</div>
<div class="box-content">
<table id="scriptTab"
class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th><fmt:message key="scriptname" /></th>
<th>ID</th>
<th><fmt:message key="datecreated" /></th>
<th><fmt:message key="actions" /></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<!--/span-->
</div>
<!--/row-->
<!-- 添加脚本 -->
<div>
<table>
<tr>
<td>
<button id="createNewScript"
class="btn btn-primary btn-setting" onclick="" type="submit">
<fmt:message key="script_jsp_recordScript" />
</button>
<button id="createScript" class="btn btn-primary" onclick="#"
type="submit">
<fmt:message key="script_jsp_makeScript" />
</button>
<button id="refreshPage" class="btn btn-primary "
onclick="refresh()" type="submit">
<fmt:message key="script_jsp_refresh" />
</button>
</td>
</tr>
</table>
</div>
<!-- /addScript -->
<!-- content ends -->
</div>
<!--/#content.span10-->
</div>
<hr>
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button>
<h3>
<fmt:message key="settings" />
</h3>
</div>
<div class="modal-body">
<p id="scriptInfo">start server to generate a script or upload
a script to server</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary"
onClick="startServer()" id="startServer">
<fmt:message key="startserver" />
</button>
<button type="button" class="btn btn-primary"
onClick="stopServer()" id="stopServer">
<fmt:message key="stopserver" />
</button>
<button type="button" id="uploadScript" class="btn btn-primary">
<fmt:message key="uploadScript" />
</button>
</div>
<div id="fileName" style="display: none" class="modal-footer">
<input class="input-mini" name="scriptname"></input>
<button type="button" class="btn btn-primary"
onClick="saveScript()">
<fmt:message key="savefile" />
</button>
</div>
</div>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
</div>
<!--/.fluid-container-->
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="lib/bootstrap/js/bootstrap-modal.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.1/bootstrap.min.js"></script>
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script
src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.js'></script>
<script src="lib/chrisma/js/theme.js"></script>
<script src="script/base.js"></script>
<script src="script/scriptTable.js"></script>
<script src="script/script.js"></script>
</fmt:bundle>
</body>
</html>
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<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.">
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
rel="stylesheet">
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href="css/bench4q.css" rel="stylesheet">
<link rel="shortcut icon" href="images/bench4q.png">
<style type="text/css">
body {
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
</head>
<body>
<fmt:bundle basename="i18n">
<!-- topbar starts -->
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
<!-- topbar ends -->
<div class="container-fluid">
<div class="row-fluid">
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<noscript>
<div class="alert alert-block span10">
<h4 class="alert-heading">
<fmt:message key="warning" />
!
</h4>
<p>
<fmt:message key="warningcontent1" />
<a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
<fmt:message key="warningcontent2" />
.
</p>
</div>
</noscript>
<div id="content" class="span10">
<!-- content starts -->
<div>
<ul class="breadcrumb">
<li><a href="homepage.jsp"><fmt:message key="home" /></a> <span
class="divider">/</span></li>
<li><a href="script.jsp"><fmt:message
key="scriptmanagement" /></a></li>
</ul>
</div>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header well" data-original-title>
<h2>
<i></i>
<fmt:message key="script" />
</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i
class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i
class="icon-list"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a>
</div>
</div>
<div class="box-content">
<table id="scriptTab"
class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th><fmt:message key="scriptname" /></th>
<th>ID</th>
<th><fmt:message key="datecreated" /></th>
<th><fmt:message key="actions" /></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<!--/span-->
</div>
<!--/row-->
<!-- 添加脚本 -->
<div>
<table>
<tr>
<td>
<button id="createNewScript"
class="btn btn-primary btn-setting" onclick="" type="submit">
<fmt:message key="script_jsp_recordScript" />
</button>
<button id="createScript" class="btn btn-primary" onclick="#"
type="submit">
<fmt:message key="script_jsp_makeScript" />
</button>
<button id="refreshPage" class="btn btn-primary "
onclick="refresh()" type="submit">
<fmt:message key="script_jsp_refresh" />
</button>
</td>
</tr>
</table>
</div>
<!-- /addScript -->
<!-- content ends -->
</div>
<!--/#content.span10-->
</div>
<hr>
<div class="modal hide fade" id="myModal">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button>
<h3>
<fmt:message key="settings" />
</h3>
</div>
<div class="modal-body">
<p id="scriptInfo">start server to generate a script or upload
a script to server</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary"
onClick="startServer()" id="startServer">
<fmt:message key="startserver" />
</button>
<button type="button" class="btn btn-primary"
onClick="stopServer()" id="stopServer">
<fmt:message key="stopserver" />
</button>
<button type="button" id="uploadScript" class="btn btn-primary">
<fmt:message key="uploadScript" />
</button>
</div>
<div id="fileName" style="display: none" class="modal-footer">
<input class="input-mini" name="scriptname"></input>
<button type="button" class="btn btn-primary"
onClick="saveScript()">
<fmt:message key="savefile" />
</button>
</div>
</div>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
</div>
<!--/.fluid-container-->
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="lib/bootstrap/js/bootstrap-modal.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.1/bootstrap.min.js"></script>
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script
src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.js'></script>
<script src="lib/chrisma/js/theme.js"></script>
<script src="script/base.js"></script>
<script src="script/scriptTable.js"></script>
<script src="script/script.js"></script>
</fmt:bundle>
</body>
</html>

View File

@ -0,0 +1,30 @@
function getvars() {
var vars = [], hash;
var hashes = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
$(function() {
var jsonData = getvars()['jsonData'];
if(jsonData!=null){
showScriptByJsonData(jsonData);
}
});

View File

@ -98,41 +98,28 @@ var BehaviorData = function(name, usePlugin, type, parameters) {
this.use = usePlugin;
this.parameters = parameters;
};
function getBehaviorSizeMap(pluginSizeMap) {
function getBehaviorNames(usePlugins) {
var behaviorNames = new Array();
var behaviorName = "Send";
for ( var i = 0; i < usePlugins.length; i++) {
behaviorNames.push(usePlugins[i].id + "_" + behaviorName);
var map = new HashMap();
var behaviorName = "send";
var plugins = $("#devices")
.children(" [containerType=device]");
var deviceSizes = $("#devices").children("[titletype=device]");
for ( var i = 0; i < plugins.length; i++) {
var behaviorId = $(plugins[i]).attr("id") +"-"+ behaviorName;
var size = $(deviceSizes[i]).children("input").val();
if (size <= 0) {
alert("device size is error");
return
}
map.put(behaviorId, size);
}
return map
return behaviorNames;
}
};
function getBehaviorDatas(behaviorSizeMap) {
function getBehaviorDatas(behaviorNames) {
var behaviors = new Array();
var behaviorEditor = $("#behaviors").children(".containerBox");
var type = "USERBEHAVIOR";
var keys = behaviorSizeMap.getKeys();
for ( var i = 0; i < keys.length;i++) {
var behaviorEditor = $("#"+keys[i]);
for(var j=0;j<behaviorSizeMap.get(keys[i]);j++){
behaviors.push(getBehaviorData(behaviorEditor,keys[i] , type));
}
for ( var i = 0; i < behaviorNames.length; i++) {
behaviors.push(getBehaviorData(behaviorEditor, behaviorNames[i], type));
}
return behaviors;
function getBehaviorData(editor, behaviorName, type) {
var paramEditors = editor.find(".editor");
var names = behaviorName.split("-");
var names = behaviorName.split("_");
var usePlugin = names[0];
var behavior = names[1];
var dataCollector = new DataCollector();
@ -140,6 +127,7 @@ function getBehaviorDatas(behaviorSizeMap) {
var behavior = new BehaviorData(behavior, usePlugin, type, params);
return behavior;
}
;
};
var PluginData = function(id, name, params) {
@ -150,10 +138,9 @@ var PluginData = function(id, name, params) {
}
function getPluginDatas() {
var pluginContainers = $("#devices").children(
" [containerType=device]");
var separators = $("#devices").children("[titletype=device]");
var plugins = new Array;
var pluginContainers = $("#devices").children(".containerBox");
var separators = $("#devices").children(".separator");
var plugins = new Array();
var pluginCount = -1;
var pluginName = "hbase";
for ( var i = 0; i < pluginContainers.length; i++) {
@ -163,10 +150,15 @@ function getPluginDatas() {
return [];
}
var dataCollector = new DataCollector();
var params = dataCollector.getUnitParams($(pluginContainers[i]).find(
".editor"));
plugins.push(new PluginData(i, pluginName, params));
var params = dataCollector.getUnitParams($(pluginContainers[i]).find(".editor"));
for ( var j = 1; j <= deviceSize; j++) {
pluginCount++;
var id=pluginName+pluginCount;
plugins.push(new PluginData(id, pluginName,params));
}
}
return plugins;
}

View File

@ -2,28 +2,24 @@ var DeviceFactory = function(deviceEditorInfo, container, behaviorEditorInfo) {
this.deviceEditorInfo = deviceEditorInfo;
this.container = container;
this.behaviorEditorInfo = behaviorEditorInfo;
};
DeviceFactory.prototype.createDevice = function(header, id) {
var deviceSizeConfig = this.createDeviceSizeConfig();
$(deviceSizeConfig).attr("titleType", "device");
var containerFactory = new ContainerFactory();
var deviceContainer = containerFactory.createEditorContainer(header, id,
this.deviceEditorInfo);
$(deviceContainer).attr("containerType", "device");
var behaviorFactory = new BehaviorFactory(this.container);
var behaviorName="send";
var behaviorId = id +"-"+ behaviorName;
behaviorFactory.createBehavior("Device Data Sender", behaviorId,
behaviorFactory.createBehavior("Device Data Sender", "behavior",
this.behaviorEditorInfo);
this.container.prepend(deviceContainer);
this.container.prepend(deviceSizeConfig);
};
DeviceFactory.prototype.createDeviceSizeConfig = function() {
var deviceSizeConfig = document.createElement("div");
$(deviceSizeConfig).addClass("deviceSize");
$(deviceSizeConfig).addClass("separator");
var label = document.createElement("label");
$(label).html("Device Size:");
var input = document.createElement("input");
@ -42,13 +38,13 @@ BehaviorFactory.prototype.createBehavior = function(header, id, editorInfo) {
var containerFactory = new ContainerFactory();
var editorContainer = containerFactory.createEditorContainer(header, id,
editorInfo);
$(editorContainer).attr("containerType", "behavior");
this.container.prepend(editorContainer)
this.container.prepend(title);
this.container.prepend(title);
};
BehaviorFactory.prototype.createTitle = function() {
var title = document.createElement("div");
$(title).attr("titleType", "behavior")
$(title).addClass("separator");
$(title).attr("style", "color:#4183c4")
$(title).html("Configure Device Data Sender")
return title;

View File

@ -61,7 +61,7 @@ function initDevice(){
});
var deviceFactory=new DeviceFactory(pluginData,$("#devices"),behaviorData);
deviceFactory.createDevice("device config",
"device0");
"device");
return deviceFactory;
@ -74,37 +74,30 @@ $(function() {
$("#behaviorPanel").hide();
var deviceFactory=initDevice();
var deviceCount=0;
$("#add-device").click(
{
deviceFactory : deviceFactory,
deviceCount:deviceCount
},
function(event) {
event.preventDefault();
event.data.deviceCount++;
event.data.deviceFactory.createDevice("device config",
"device"+event.data.devcieCount);
"device");
});
$("#remove-device").click({deviceCount:deviceCount},function(event) {
$("#remove-device").click(function(event) {
event.preventDefault();
if ($("#devices").children(".containerBox").length <= 1) {
return;
}
event.data.deviceCount--;
$("#devices").children(".containerBox [containerType=device]").last().remove();
$("#devices").children("[titleType=device]").last().remove();
$("#devices").children(".containerBox [containerType=behavior]").last().remove();
$("#devices").children("[titleType=behavior]").last().remove();
$("#devices").children(".containerBox").last().remove();
$("#devices").children(".separator").last().remove();
});
$("#to-behavior").click(function(event){
$("#start").click(function(event){
var plugins=getPluginDatas();
var behaviorSizeMap=getBehaviorSizeMap(plugins);
var behaviors=getBehaviorDatas(behaviorSizeMap);
var behaviorNames=getBehaviorNames(plugins);
var behaviors=getBehaviorDatas(behaviorNames);
$.ajax({
type: "POST",
url: 'deviceScript',

View File

@ -1,99 +0,0 @@
package org.bench4q.web.test.masterMessager;
import static org.junit.Assert.*;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.AgentModel;
import org.bench4q.share.models.master.AgentResponseModel;
import org.bench4q.web.masterMessager.AgentManagerMessager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
public class AgentMessagerTest extends MessagerTestBase {
private String accessToken;
private AgentManagerMessager agentManagerMessager;
public AgentManagerMessager getAgentManagerMessager() {
return agentManagerMessager;
}
@Autowired
public void setAgentManagerMessager(
AgentManagerMessager agentManagerMessager) {
this.agentManagerMessager = agentManagerMessager;
}
@Before
public void setUp() {
this.accessToken = this.login();
}
@Test
public void test_addAndDeleteAgent() throws JAXBException {
AgentModel agentModel = createAgentModel();
AgentResponseModel agentResponseModel = this.addAgent(agentModel);
assertNotNull(agentResponseModel);
assertTrue(agentResponseModel.isSuccess());
agentResponseModel = this.deleteAgent(agentModel);
assertNotNull(agentResponseModel);
assertTrue(agentResponseModel.isSuccess());
}
@Test
public void test_loadAgents() throws JAXBException {
int countBeforeInsert = this.getAgentManagerMessager()
.loadAgents(this.accessToken).getAgents().size();
AgentModel agentModel = this.createAgentModel();
assertTrue(this.addAgent(agentModel).isSuccess());
int countAfterInsert = this.getAgentManagerMessager()
.loadAgents(this.accessToken).getAgents().size();
assertEquals(countBeforeInsert + 1, countAfterInsert);
assertTrue(this.deleteAgent(agentModel).isSuccess());
}
private AgentResponseModel addAgent(AgentModel agentModel)
throws JAXBException {
String agentModelContent = MarshalHelper.marshal(AgentModel.class,
agentModel);
AgentResponseModel agentResponseModel = this.getAgentManagerMessager()
.addAgent(this.accessToken, agentModelContent);
return agentResponseModel;
}
private AgentResponseModel deleteAgent(AgentModel agentModel) {
return this.getAgentManagerMessager().deleteAgent(this.accessToken,
this.getAgentId(agentModel.getHostName()),
agentModel.getHostName());
}
private AgentModel createAgentModel() {
AgentModel agentModel = new AgentModel();
agentModel.setHostName("133.133.1.1");
agentModel.setPort(5555);
agentModel.setMaxLoad(500);
return agentModel;
}
private String getAgentId(String hostName) {
List<AgentModel> agentModels = this.getAgentManagerMessager()
.loadAgents(this.accessToken).getAgents();
for (AgentModel agentModel : agentModels) {
if (agentModel.getHostName().equals(hostName)) {
return new Integer(agentModel.getId()).toString();
}
}
return null;
}
}

View File

@ -1,30 +1,29 @@
package org.bench4q.web.test.masterMessager;
import org.bench4q.share.models.master.AuthorizeResponseModel;
import org.bench4q.web.masterMessager.UserMessager;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
public abstract class MessagerTestBase {
private UserMessager userMessager;
private final String userName = "admin";
private final String password = "admin";
private WireMockServer wireMockServer;
protected WireMock wireMock;
private final int port = 7979;
private UserMessager getUserMessager() {
return userMessager;
protected void mockServer() {
WireMockConfiguration wmc = new WireMockConfiguration();
wmc.bindAddress("localhost");
wmc.port(port);
wireMockServer = new WireMockServer(wmc);
wireMockServer.start();
wireMock = new WireMock("localhost", port);
}
@Autowired
private void setUserMessager(UserMessager userMessager) {
this.userMessager = userMessager;
protected void stopServer() {
wireMockServer.stop();
}
public String login() {
AuthorizeResponseModel authorizeResponseModel = this.getUserMessager()
.adminLogin(userName, password);
if (authorizeResponseModel != null)
return authorizeResponseModel.getAccessToken();
else
return null;
public WireMock getWireMock() {
return wireMock;
}
}

View File

@ -1,109 +0,0 @@
package org.bench4q.web.test.masterMessager;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.bench4q.share.models.master.plugin.PluginResponseModel;
import org.bench4q.web.masterMessager.PluginMessager;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
public class PluginMessagerTest extends MessagerTestBase {
private PluginMessager pluginMessager;
private String accessToken;
private String pluginName = "Http";
public PluginMessager getPluginMessager() {
return pluginMessager;
}
@Autowired
public void setPluginMessager(PluginMessager pluginMessager) {
this.pluginMessager = pluginMessager;
}
@Before
public void setUp() {
this.accessToken = this.login();
}
@Test
public void test_addAndDeletePlugin() throws IOException {
this.getPluginMessager().deletePlugin(accessToken, pluginName);
PluginResponseModel pluginResponseModel = this.addPlugin();
assertTrue(pluginResponseModel.isSuccess());
pluginResponseModel = this.getPluginMessager().deletePlugin(
accessToken, pluginName);
}
@Test
public void test_loadPluginNames() throws IOException {
this.getPluginMessager().deletePlugin(accessToken, pluginName);
int countBeforInsert = this.getPluginMessager()
.loadPluginNameList(this.accessToken).getPluginList().size();
assertTrue(this.addPlugin().isSuccess());
PluginResponseModel pluginResponseModel = this.getPluginMessager()
.loadPluginNameList(accessToken);
assertTrue(pluginResponseModel.isSuccess());
assertNotNull(pluginResponseModel.getPluginList());
assertEquals(countBeforInsert + 1, pluginResponseModel.getPluginList()
.size());
this.getPluginMessager().deletePlugin(accessToken, pluginName);
}
@Test
public void test_loadPluginUIs() throws IOException {
this.getPluginMessager().deletePlugin(accessToken, pluginName);
int countBeforInsert = this.getPluginMessager()
.loadPluginUIModels(accessToken).getPluginUIModels().size();
this.addPlugin();
PluginResponseModel pluginResponseModel = this.getPluginMessager()
.loadPluginUIModels(accessToken);
assertTrue(pluginResponseModel.isSuccess());
assertNotNull(pluginResponseModel.getPluginUIModels());
assertEquals(countBeforInsert + 1, pluginResponseModel
.getPluginUIModels().size());
this.getPluginMessager().deletePlugin(accessToken, pluginName);
}
@Test
public void test_loadBehaviors() throws IOException {
this.addPlugin();
PluginResponseModel pluginResponseModel = this.getPluginMessager()
.loadBehaviors(accessToken, pluginName);
assertTrue(pluginResponseModel.isSuccess());
assertNotNull(pluginResponseModel.getBehaviorInfoModels());
assertTrue(pluginResponseModel.getBehaviorInfoModels().size() > 0);
this.getPluginMessager().deletePlugin(accessToken, pluginName);
}
@After
public void clearUp() {
}
private PluginResponseModel addPlugin() throws IOException {
String fileSeparator = System.getProperty("file.separator");
String filePath = System.getProperty("user.dir") + fileSeparator
+ "target" + fileSeparator + "test-classes" + fileSeparator
+ "http.xml";
File file = new File(filePath);
String pluginContent = FileUtils.readFileToString(file);
return this.getPluginMessager().addPlugin(this.accessToken,
pluginContent);
}
}

View File

@ -3,12 +3,9 @@ package org.bench4q.web.test.masterMessager;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.OrganizeRecordPortResponseModel;
import org.bench4q.share.models.master.PortModel;
import org.bench4q.web.masterMessager.RecordPortMessager;
import org.junit.After;
import org.junit.Before;
@ -17,18 +14,12 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
public class PortMessageTest extends MessagerTestBase {
static private int portNumber = 5;
private final int port = 7979;
private RecordPortMessager recordPortMessager;
private WireMockServer wireMockServer;
private WireMock wireMock;
public RecordPortMessager getRecordPortMessager() {
return recordPortMessager;
@ -41,86 +32,62 @@ public class PortMessageTest extends MessagerTestBase {
@Before
public void setUp() {
WireMockConfiguration wmc = new WireMockConfiguration();
wmc.bindAddress("localhost");
wmc.port(port);
wireMockServer = new WireMockServer(wmc);
wireMockServer.start();
wireMock = new WireMock("localhost", port);
this.mockServer();
}
@After
public void shutDowm() {
wireMockServer.stop();
this.stopServer();
}
@Test
public void test_addPort() throws IOException, JAXBException {
String resultWithoutPortList = PortMessageTest.loadWithoutPortList();
wireMock.register(post(urlEqualTo("/RecordPort/addPortToPortPool"))
.withRequestBody(containing("port")).willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(resultWithoutPortList)));
.withBody(this.createResponse())));
OrganizeRecordPortResponseModel responseModel = recordPortMessager
.addPort(null, "8090");
assertNotNull(responseModel);
assertTrue(responseModel.isSuccess());
}
@Test
public void test_deletePort() throws JAXBException {
String resultWithoutPortList = PortMessageTest.loadWithoutPortList();
wireMock.register(post(urlEqualTo("/RecordPort/removePortFromPool"))
.withRequestBody(containing("port")).willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(resultWithoutPortList)));
.withBody(this.createResponse())));
OrganizeRecordPortResponseModel responseModel = recordPortMessager
.deletePort(null, "8090");
assertNotNull(responseModel);
assertTrue(responseModel.isSuccess());
}
@Test
public void test_loadPorts() throws JAXBException {
String resultWithPortList = PortMessageTest.loadWithPortList();
wireMock.register(post(urlEqualTo("/RecordPort/loadPortList"))
.willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(resultWithPortList)));
.withBody(this.createResponse())));
OrganizeRecordPortResponseModel responseModel = recordPortMessager
.loadPorts(null);
assertNotNull(responseModel);
assertTrue(responseModel.isSuccess());
}
static public String loadWithPortList() throws JAXBException {
List<PortModel> list = new ArrayList<PortModel>();
for (int i = 1; i <= portNumber; i++) {
PortModel portModel = new PortModel();
portModel.setId(i);
list.add(portModel);
}
private String createResponse() throws JAXBException {
OrganizeRecordPortResponseModel organizeRecordPortResponseModel = new OrganizeRecordPortResponseModel();
organizeRecordPortResponseModel.setSuccess(true);
organizeRecordPortResponseModel.setFailCauseString("");
organizeRecordPortResponseModel.setPortModels(list);
String resultWithPortList = MarshalHelper.marshal(
String response = MarshalHelper.marshal(
OrganizeRecordPortResponseModel.class,
organizeRecordPortResponseModel);
return resultWithPortList;
}
static public String loadWithoutPortList() throws JAXBException {
OrganizeRecordPortResponseModel organizeRecordPortResponseModel = new OrganizeRecordPortResponseModel();
organizeRecordPortResponseModel.setSuccess(true);
organizeRecordPortResponseModel.setFailCauseString("");
organizeRecordPortResponseModel
.setPortModels(new ArrayList<PortModel>());
String resultWithoutPortList = MarshalHelper.marshal(
OrganizeRecordPortResponseModel.class,
organizeRecordPortResponseModel);
return resultWithoutPortList;
return response;
}
}

View File

@ -1,142 +0,0 @@
package org.bench4q.web.test.masterMessager;
import static org.junit.Assert.*;
import javax.xml.bind.JAXBException;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
import org.bench4q.share.models.master.ScriptModel;
import org.bench4q.web.masterMessager.RecordPortMessager;
import org.bench4q.web.masterMessager.ScriptMessager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
public class ScriptMessageTest extends MessagerTestBase {
private ScriptMessager scriptMessager;
private String accessToken;
private RecordPortMessager recordPortMessager;
private String scriptName = "testScript";
@Autowired
public void setRecordPortMessager(RecordPortMessager recordPortMessager) {
this.recordPortMessager = recordPortMessager;
}
public RecordPortMessager getRecordPortMessager() {
return this.recordPortMessager;
}
@Autowired
public void setScriptMessager(ScriptMessager scriptMessager) {
this.scriptMessager = scriptMessager;
}
public ScriptMessager getScriptMessager() {
return this.scriptMessager;
}
@Before
public void SetUp() {
this.accessToken = this.login();
}
@Test
public void test_startScriptRecordServer() throws JAXBException {
this.scriptMessager.stopScriptRecordServer(accessToken, "8090", "");
OperateScriptServerResponseModel operateScriptServerResponseModel = this.scriptMessager
.startScriptRecordServer(accessToken);
String xml = MarshalHelper.marshal(
OperateScriptServerResponseModel.class,
operateScriptServerResponseModel);
System.out.println(xml);
assertTrue(operateScriptServerResponseModel.isSuccess());
}
@Test
public void test_stopScriptRecordServer() {
OperateScriptServerResponseModel stopOperateScriptServerResponseModel = this.scriptMessager
.stopScriptRecordServer(accessToken, "8090", "");
assertTrue(stopOperateScriptServerResponseModel.isSuccess());
}
@Test
public void test_loadScript() {
OperateScriptServerResponseModel beforeSave_operateScriptServerResponseModel = this.scriptMessager
.loadScript(accessToken);
assertTrue(beforeSave_operateScriptServerResponseModel.isSuccess());
}
@Test
public void test_saveAndDeleteScript() {
int countBeforeSave = this.scriptMessager.loadScript(accessToken)
.getScriptModels().size();
this.scriptMessager.stopScriptRecordServer(accessToken, "8090", "");
OperateScriptServerResponseModel startOperateScriptServerResponseModel = this.scriptMessager
.startScriptRecordServer(accessToken);
String port = Integer.toString(startOperateScriptServerResponseModel
.getPort());
String fileNameUUID = startOperateScriptServerResponseModel
.getFileName();
assertTrue(this.scriptMessager.saveScriptRecorded(accessToken,
scriptName, port, fileNameUUID).isSuccess());
int countAfterSave = this.scriptMessager.loadScript(accessToken)
.getScriptModels().size();
assertEquals(countBeforeSave + 1, countAfterSave);
assertTrue(this.scriptMessager.queryScriptByName(accessToken,
scriptName).isSuccess());
ScriptModel scriptModel = this.scriptMessager
.queryScriptByName(accessToken, scriptName).getScriptModels()
.get(0);
String id = Integer.toString(scriptModel.getId());
assertTrue(this.scriptMessager.deleteScript(accessToken, id)
.isSuccess());
int countAfterDelete = this.scriptMessager.loadScript(accessToken)
.getScriptModels().size();
assertEquals(countBeforeSave, countAfterDelete);
}
@Test
public void test_updateScript() {
this.scriptMessager.stopScriptRecordServer(accessToken, "8090", "");
OperateScriptServerResponseModel startOperateScriptServerResponseModel = this.scriptMessager
.startScriptRecordServer(accessToken);
String port = Integer.toString(startOperateScriptServerResponseModel
.getPort());
String fileNameUUID = startOperateScriptServerResponseModel
.getFileName();
this.scriptMessager.saveScriptRecorded(accessToken, scriptName, port,
fileNameUUID);
String id = Integer.toString(this.scriptMessager
.queryScriptByName(accessToken, scriptName).getScriptModels()
.get(0).getId());
String scriptContent = "testScriptContent";
assertTrue(this.scriptMessager.updateScript(accessToken, id,
scriptContent).isSuccess());
this.scriptMessager.deleteScript(accessToken, id);
}
@Test
public void test_queryScriptById() {
this.scriptMessager.stopScriptRecordServer(accessToken, "8090", "");
OperateScriptServerResponseModel startOperateScriptServerResponseModel = this.scriptMessager
.startScriptRecordServer(accessToken);
String port = Integer.toString(startOperateScriptServerResponseModel
.getPort());
String fileNameUUID = startOperateScriptServerResponseModel
.getFileName();
this.scriptMessager.saveScriptRecorded(accessToken, scriptName, port,
fileNameUUID);
String id = Integer.toString(this.scriptMessager
.queryScriptByName(accessToken, scriptName).getScriptModels()
.get(0).getId());
assertTrue(this.scriptMessager.queryScriptById(accessToken, id)
.isSuccess());
this.scriptMessager.deleteScript(accessToken, id);
}
}