From b4df36bfeda00c321fe2577185a9e84dc33ebe59 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Thu, 20 Mar 2014 11:21:05 +0800 Subject: [PATCH] Merge Bench4Q-Master --- .../Bench4QTestCase/frame1.html | 14 +- .../Bench4QTestCase/frameTestCase.html | 30 +- .../Bench4QTestCase/images/1.jpg | Bin .../Bench4QTestCase/images/2.jpg | Bin .../Bench4QTestCase/images/3.jpg | Bin .../Bench4QTestCase/images/4.jpg | Bin .../Bench4QTestCase/images/5.jpg | Bin .../Bench4QTestCase/images/6.jpg | Bin .../Bench4QTestCase/script/agentTable.js | 188 +++--- .../Bench4QTestCase/script/base.js | 286 ++++----- .../style/bootstrap-cerulean.css | 0 .../style/bootstrap-classic.css | 0 .../Bench4QTestCase/testcase.html | 34 +- .../RecordScriptTestCase}/baidu.html | 0 .../gzip/gzipBaiduIRBlankBody.html | 30 +- .../gzip/gzipBaiduIRNotHtmlResponse.html | 30 +- .../gzip/gzipBaiduIRNullResponseBody.html | 0 .../gzip/gzipBaiduIRRequest.txt | 30 +- .../gzip/gzipBaiduIRResponse.txt | Bin .../gzip/gzipBaiduIRResponseBody.txt | Bin .../gzipBaiduRequestHeader.txt | 20 +- .../gzipBaiduResponse.txt | Bin .../gzipBaiduResponseBody.txt | Bin .../gzipChunkedGoogleResponse.txt | Bin .../gzipChunkedGoogleResponseBody.txt | Bin .../responsBodyAfterDeal.txt | 0 .../scriptBriefResultModel.xml | 30 +- .../RecordScriptTestCase}/simpleResponse.txt | 52 +- .../ScriptParameterization}/79/param1.txt | 0 .../ScriptParameterization}/79/param2.txt | 0 .../descriptor.xml | 48 +- pom.xml => Bench4Q-Master/pom.xml | 332 +++++------ .../relative Docs}/bench4q year final.pptx | Bin .../main/java/org/bench4q/master/Main.java | 114 ++-- .../java/org/bench4q/master/MasterServer.java | 150 ++--- .../org/bench4q/master/TestPlunginHelper.java | 124 ++-- .../bench4q/master/api/AgentController.java | 0 .../bench4q/master/api/BaseController.java | 0 .../bench4q/master/api/HomeController.java | 0 .../bench4q/master/api/MonitorController.java | 0 .../bench4q/master/api/PluginController.java | 256 ++++----- .../master/api/RecordPortController.java | 0 .../bench4q/master/api/ScriptController.java | 0 .../master/api/TestPlanController.java | 0 .../master/api/TestPlanResulController.java | 0 .../bench4q/master/api/UserController.java | 0 .../org/bench4q/master/domain/IAggregate.java | 0 .../master/domain/RunningAgentInterface.java | 0 .../master/domain/RunningScriptInterface.java | 0 .../bench4q/master/domain/entity/Agent.java | 0 .../master/domain/entity/EntityBase.java | 0 .../bench4q/master/domain/entity/Monitor.java | 0 .../master/domain/entity/MonitorResult.java | 0 .../master/domain/entity/PlanedConfig.java | 0 .../bench4q/master/domain/entity/Port.java | 0 .../master/domain/entity/RunningAgentDB.java | 0 .../bench4q/master/domain/entity/Script.java | 0 .../master/domain/entity/TestPlan.java | 0 .../master/domain/entity/TestPlanScript.java | 0 .../domain/entity/TestPlanScriptResult.java | 0 .../bench4q/master/domain/entity/User.java | 0 .../master/domain/entity/plugin/Method.java | 0 .../domain/entity/plugin/MethodParam.java | 0 .../entity/plugin/MethodParamProperty.java | 120 ++-- .../domain/entity/plugin/ParamType.java | 82 +-- .../master/domain/entity/plugin/Plugin.java | 0 .../factory/BusinessModelMapFactory.java | 0 .../master/domain/factory/PluginFactory.java | 274 ++++----- .../domain/factory/TestPlanFactory.java | 0 .../master/domain/factory/UserFactory.java | 0 .../domain/repository/AbstractRepositoty.java | 0 .../domain/repository/AgentRepository.java | 0 .../domain/repository/MonitorRepository.java | 28 +- .../domain/repository/PluginRepository.java | 0 .../domain/repository/ScriptRepositoty.java | 0 .../domain/repository/TestPlanRepository.java | 0 .../domain/repository/UserRepository.java | 0 .../master/domain/service/AgentService.java | 0 .../domain/service/MonitorResultService.java | 0 .../master/domain/service/PluginService.java | 258 ++++----- .../domain/service/PortPoolService.java | 0 .../master/domain/service/ScriptService.java | 0 .../master/domain/service/TestPlanEngine.java | 0 .../service/TestPlanScriptResultService.java | 0 .../domain/service/TestPlanScriptService.java | 0 .../domain/service/TestPlanService.java | 0 .../master/domain/service/UserService.java | 0 .../domain/service/auth/AccessToken.java | 0 .../service/auth/AuthenticationManager.java | 0 .../domain/service/auth/CryptoManager.java | 0 .../domain/testplan/LoadDistribute.java | 0 .../domain/testplan/RunningScriptSampler.java | 0 .../domain/testplan/TestMoniorResultSave.java | 252 ++++---- .../domain/testplan/TestMonitorSampler.java | 50 +- .../domain/testplan/TestScriptResultSave.java | 0 .../master/exception/Bench4QException.java | 94 +-- .../exception/Bench4QExceptionSweeper.java | 38 +- .../master/exception/ExceptionLog.java | 26 +- .../master/exception/ExceptionUtils.java | 0 .../helper/ApplicationContextHelper.java | 52 +- .../master/helper/CollectionHelper.java | 0 .../org/bench4q/master/helper/HashHelper.java | 66 +-- .../bench4q/master/helper/SessionHelper.java | 0 .../bench4q/master/helper/StringHelper.java | 76 +-- .../communication/AgentMessenger.java | 0 .../communication/MonitorMessenger.java | 0 .../master/scriptrecord/ScriptCapturer.java | 182 +++--- .../scriptrecord/httpcapture/Action.java | 294 +++++----- .../httpcapture/Bench4qTestScriptAdapter.java | 0 .../scriptrecord/httpcapture/Config.java | 544 +++++++++--------- .../scriptrecord/httpcapture/HeaderValue.java | 156 ++--- .../scriptrecord/httpcapture/HttpCapture.java | 256 ++++----- .../httpcapture/HttpRequestHeader.java | 0 .../httpcapture/HttpTestCase.java | 482 ++++++++-------- .../httpcapture/IScriptAdapter.java | 66 +-- .../scriptrecord/httpcapture/Param.java | 0 .../scriptrecord/httpcapture/ProxyServer.java | 174 +++--- .../httpcapture/RequestHandler.java | 0 .../master/scriptrecord/httpcapture/Test.java | 224 ++++---- .../scriptrecord/httpcapture/Utils.java | 230 ++++---- .../generator/AbstractCodeGenerator.java | 0 .../generator/Bench4qCodeGenerator.java | 0 .../httpcapture/generator/ChildrenUrl.java | 58 +- .../httpcapture/generator/ContentDecoder.java | 0 .../generator/GeneratorFactory.java | 138 ++--- .../httpcapture/generator/GzipDecoder.java | 56 +- .../generator/HtmlDocumentParser.java | 108 ++-- .../generator/IScriptGenerator.java | 46 +- .../httpcapture/generator/ResponseHeader.java | 0 .../httpcapture/generator/ResponseParser.java | 0 .../BehaviorsBriefStatistics.java | 244 ++++---- .../datastatistics/DataStatistics.java | 38 +- .../datastatistics/PageBriefStatistics.java | 146 ++--- .../datastatistics/PagesBriefStatistics.java | 122 ++-- .../datastatistics/ScriptBriefStatistics.java | 0 .../datastatistics/ScriptStatistics.java | 26 +- .../highavailable/AgentRunBlotter.java | 0 .../highavailable/CurrentLoadObserver.java | 10 +- .../highavailable/CurrentLoadSubject.java | 34 +- .../highavailable/HighAvailablePool.java | 0 .../faultolerence/BriefAgentFault.java | 0 .../faultolerence/FaultTolerance.java | 10 +- .../faultolerence/FaultTolerenceFactory.java | 0 .../faultolerence/RunAgentFault.java | 0 .../faultolerence/StopAgentFault.java | 0 .../schedulscript/ExecutionOverTask.java | 0 .../schedulscript/TaskCompleteCallback.java | 14 +- .../schedulscript/WarmUpOverTask.java | 0 .../transaction/TestPlanLoadCommand.java | 0 .../master/transaction/Transaction.java | 0 .../transaction/agent/AgentRunException.java | 0 .../transaction/agent/AgentTransaction.java | 0 .../transaction/script/ScriptLoadBase.java | 0 .../transaction/script/ScriptLoadCommand.java | 0 .../script/ScriptLoadDistributeException.java | 0 .../script/ScriptLoadSubstitute.java | 0 .../src}/main/resources/log4j.properties | 0 .../master/config/ServerPort.properties | 0 .../master/config/application-context.xml | 26 +- .../bench4q/master/config/hibernate.cfg.xml | 0 .../config/httpCaptureConfig/maxq.properties | 106 ++-- .../org/bench4q/master/config/key.pfx | Bin .../java/ModelTest/BehaviorBaseModelTest.java | 88 +-- .../src}/test/java/ModelTest/IpTest.java | 70 +-- .../test/java/ModelTest/MarshallerTest.java | 60 +- .../ModelTest/Test_StatisticsResultModel.java | 84 +-- .../MonitorModelTest/MonitorModelTest.java | 136 ++--- .../java/TestHelper/Test_PlunginHelper.java | 122 ++-- .../master/test/FileSeperatorTest.java | 14 +- .../bench4q/master/test/HttpRequestTest.java | 0 .../bench4q/master/test/PolymorphismTest.java | 56 +- .../master/test/TestBase_MakeUpTestPlan.java | 0 .../bench4q/master/test/TestRecordBase.java | 0 .../org/bench4q/master/test/byteTest.java | 48 +- .../communication/Test_AgentMessenger.java | 0 .../communication/Test_MonitorMessenger.java | 80 +-- .../controller/AgentPoolControllerTest.java | 150 ++--- .../test/controller/PluginControllerTest.java | 150 ++--- .../controller/RecordPortControllerTest.java | 86 +-- .../RecordScriptControllerTest.java | 0 .../test/controller/ScriptControllerTest.java | 84 +-- .../master/test/controller/TestBase.java | 0 .../controller/TestPlanControllerTest.java | 0 .../TestPlanScriptResultControllerTest.java | 0 .../controller/Test_MonitorController.java | 78 +-- .../test/controller/UserControllerTest.java | 76 +-- .../BehaviorsBriefStatisticsTest.java | 20 +- .../ScriptBriefStatisticsTest.java | 0 .../test/datastatistics/TestPageBrief.java | 218 +++---- .../test/datastatistics/Test_PagesBrief.java | 190 +++--- .../test/domain/Test_HighAvailable.java | 0 .../master/test/domain/Test_Monitor.java | 68 +-- .../domain/Test_RunningScriptSampler.java | 0 .../domain/Test_TestMonitorResultSave.java | 198 +++---- .../test/domain/Test_TestMonitorSampler.java | 106 ++-- .../master/test/domain/Test_TestPlan.java | 0 .../domain/Test_TestScriptResultSave.java | 142 ++--- .../test/recordscript/ContentDecoderTest.java | 80 +-- .../TestBench4qTestScriptAdapter.java | 0 .../test/recordscript/TestDomGenerator.java | 0 .../recordscript/TestHttpRequestHeader.java | 0 .../test/recordscript/TestParentRequest.java | 0 .../test/recordscript/TestResponseParser.java | 0 .../Test_Bench4QCodeGenerator.java | 0 .../test/recordscript/Test_ParamParser.java | 0 .../master/test/recordscript/testcase.html | 34 +- .../test/repository/Test_AgentRepository.java | 0 .../repository/Test_PluginRepository.java | 188 +++--- .../repository/Test_TestPlanRepository.java | 0 .../test/repository/Test_UserRepository.java | 0 .../test/service/Test_AgentService.java | 0 .../test/service/Test_MonitorMessenger.java | 0 .../service/Test_MonitorResultService.java | 0 .../test/service/Test_PluginService.java | 0 .../test/service/Test_ReportService.java | 0 .../test/service/Test_ScriptService.java | 0 .../test/service/Test_TestPlanEngine.java | 0 .../Test_TestPlanScriptResultService.java | 0 .../service/Test_TestPlanScriptService.java | 0 .../test/service/Test_TestPlanService.java | 0 .../master/test/service/Test_UserService.java | 0 .../auth/Test_AuthenticationManager.java | 0 .../master/test/testplan/TestPlanTester.java | 0 .../test/testplan/TestTestPlanResult.java | 66 +-- .../test/testplan/Test_LoadDistribute.java | 0 .../transaction/Test_ScriptLoadCommand.java | 0 .../mater/test/entity/Test_Monitor.java | 88 +-- .../mater/test/entity/Test_TestPlan.java | 156 ++--- .../resources/repository-test-context.xml | 0 .../test/resources/service-test-context.xml | 0 license.txt | 339 ----------- .../master/report/MonitorReportService.java | 246 -------- .../bench4q/master/report/ReportService.java | 175 ------ .../master/report/ScriptReportService.java | 140 ----- .../master/test/report/ReportFontTest.java | 54 -- 235 files changed, 4955 insertions(+), 5909 deletions(-) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/frame1.html (88%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/frameTestCase.html (95%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/images/1.jpg (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/images/2.jpg (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/images/3.jpg (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/images/4.jpg (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/images/5.jpg (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/images/6.jpg (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/script/agentTable.js (95%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/script/base.js (97%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/style/bootstrap-cerulean.css (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/style/bootstrap-classic.css (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/Bench4QTestCase/testcase.html (96%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/baidu.html (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzip/gzipBaiduIRBlankBody.html (91%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzip/gzipBaiduIRNotHtmlResponse.html (95%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzip/gzipBaiduIRNullResponseBody.html (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzip/gzipBaiduIRRequest.txt (97%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzip/gzipBaiduIRResponse.txt (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzip/gzipBaiduIRResponseBody.txt (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzipBaiduRequestHeader.txt (98%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzipBaiduResponse.txt (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzipBaiduResponseBody.txt (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzipChunkedGoogleResponse.txt (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/gzipChunkedGoogleResponseBody.txt (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/responsBodyAfterDeal.txt (100%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/scriptBriefResultModel.xml (94%) rename {RecordScriptTestCase => Bench4Q-Master/RecordScriptTestCase}/simpleResponse.txt (96%) rename {ScriptParameterization => Bench4Q-Master/ScriptParameterization}/79/param1.txt (100%) rename {ScriptParameterization => Bench4Q-Master/ScriptParameterization}/79/param2.txt (100%) rename descriptor.xml => Bench4Q-Master/descriptor.xml (95%) rename pom.xml => Bench4Q-Master/pom.xml (96%) rename {relative Docs => Bench4Q-Master/relative Docs}/bench4q year final.pptx (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/Main.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/MasterServer.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/TestPlunginHelper.java (97%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/AgentController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/BaseController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/HomeController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/MonitorController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/PluginController.java (97%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/RecordPortController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/ScriptController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/TestPlanController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/TestPlanResulController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/api/UserController.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/IAggregate.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/RunningAgentInterface.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/RunningScriptInterface.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/Agent.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/EntityBase.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/Monitor.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/MonitorResult.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/PlanedConfig.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/Port.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/Script.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/TestPlan.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/TestPlanScript.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/TestPlanScriptResult.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/User.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/plugin/Method.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/plugin/MethodParam.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/plugin/MethodParamProperty.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/plugin/ParamType.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/entity/plugin/Plugin.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/factory/BusinessModelMapFactory.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/factory/PluginFactory.java (97%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/factory/UserFactory.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/repository/AbstractRepositoty.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/repository/AgentRepository.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/repository/MonitorRepository.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/repository/PluginRepository.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/repository/ScriptRepositoty.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/repository/TestPlanRepository.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/repository/UserRepository.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/AgentService.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/MonitorResultService.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/PluginService.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/PortPoolService.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/ScriptService.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/TestPlanEngine.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/TestPlanScriptResultService.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/TestPlanScriptService.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/TestPlanService.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/UserService.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/auth/AccessToken.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/auth/AuthenticationManager.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/service/auth/CryptoManager.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/testplan/LoadDistribute.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/testplan/RunningScriptSampler.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/testplan/TestMoniorResultSave.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/testplan/TestMonitorSampler.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/domain/testplan/TestScriptResultSave.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/exception/Bench4QException.java (94%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/exception/Bench4QExceptionSweeper.java (97%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/exception/ExceptionLog.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/exception/ExceptionUtils.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/helper/ApplicationContextHelper.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/helper/CollectionHelper.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/helper/HashHelper.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/helper/SessionHelper.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/helper/StringHelper.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/infrastructure/communication/MonitorMessenger.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/ScriptCapturer.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/Action.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/Bench4qTestScriptAdapter.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/Config.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/HeaderValue.java (97%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpCapture.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpRequestHeader.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpTestCase.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/IScriptAdapter.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/Param.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/ProxyServer.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/RequestHandler.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/Test.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/Utils.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/AbstractCodeGenerator.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/Bench4qCodeGenerator.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ChildrenUrl.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ContentDecoder.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GeneratorFactory.java (97%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GzipDecoder.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/HtmlDocumentParser.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/IScriptGenerator.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseHeader.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseParser.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/datastatistics/BehaviorsBriefStatistics.java (97%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/datastatistics/DataStatistics.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/datastatistics/PageBriefStatistics.java (97%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/datastatistics/PagesBriefStatistics.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/datastatistics/ScriptBriefStatistics.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/datastatistics/ScriptStatistics.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/AgentRunBlotter.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadObserver.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadSubject.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerance.java (96%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerenceFactory.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/faultolerence/RunAgentFault.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/highavailable/faultolerence/StopAgentFault.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/schedulscript/ExecutionOverTask.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/schedulscript/TaskCompleteCallback.java (95%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/testplan/schedulscript/WarmUpOverTask.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/transaction/TestPlanLoadCommand.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/transaction/Transaction.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/transaction/agent/AgentRunException.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/transaction/agent/AgentTransaction.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/transaction/script/ScriptLoadBase.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/transaction/script/ScriptLoadCommand.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/transaction/script/ScriptLoadDistributeException.java (100%) rename {src => Bench4Q-Master/src}/main/java/org/bench4q/master/transaction/script/ScriptLoadSubstitute.java (100%) rename {src => Bench4Q-Master/src}/main/resources/log4j.properties (100%) rename {src => Bench4Q-Master/src}/main/resources/org/bench4q/master/config/ServerPort.properties (100%) rename {src => Bench4Q-Master/src}/main/resources/org/bench4q/master/config/application-context.xml (98%) rename {src => Bench4Q-Master/src}/main/resources/org/bench4q/master/config/hibernate.cfg.xml (100%) rename {src => Bench4Q-Master/src}/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties (95%) rename {src => Bench4Q-Master/src}/main/resources/org/bench4q/master/config/key.pfx (100%) rename {src => Bench4Q-Master/src}/test/java/ModelTest/BehaviorBaseModelTest.java (97%) rename {src => Bench4Q-Master/src}/test/java/ModelTest/IpTest.java (96%) rename {src => Bench4Q-Master/src}/test/java/ModelTest/MarshallerTest.java (97%) rename {src => Bench4Q-Master/src}/test/java/ModelTest/Test_StatisticsResultModel.java (97%) rename {src => Bench4Q-Master/src}/test/java/MonitorModelTest/MonitorModelTest.java (96%) rename {src => Bench4Q-Master/src}/test/java/TestHelper/Test_PlunginHelper.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/FileSeperatorTest.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/HttpRequestTest.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/PolymorphismTest.java (95%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/TestBase_MakeUpTestPlan.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/TestRecordBase.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/byteTest.java (95%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/communication/Test_AgentMessenger.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/communication/Test_MonitorMessenger.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/AgentPoolControllerTest.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/PluginControllerTest.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/RecordPortControllerTest.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/RecordScriptControllerTest.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/ScriptControllerTest.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/TestBase.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/TestPlanControllerTest.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/TestPlanScriptResultControllerTest.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/Test_MonitorController.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/controller/UserControllerTest.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/datastatistics/BehaviorsBriefStatisticsTest.java (94%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/datastatistics/ScriptBriefStatisticsTest.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/datastatistics/TestPageBrief.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/datastatistics/Test_PagesBrief.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/domain/Test_HighAvailable.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/domain/Test_Monitor.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/domain/Test_RunningScriptSampler.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/domain/Test_TestMonitorResultSave.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/domain/Test_TestMonitorSampler.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/domain/Test_TestPlan.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/domain/Test_TestScriptResultSave.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/ContentDecoderTest.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/TestBench4qTestScriptAdapter.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/TestDomGenerator.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/TestHttpRequestHeader.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/TestParentRequest.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/TestResponseParser.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/Test_Bench4QCodeGenerator.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/Test_ParamParser.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/recordscript/testcase.html (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/repository/Test_AgentRepository.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/repository/Test_PluginRepository.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/repository/Test_TestPlanRepository.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/repository/Test_UserRepository.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_AgentService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_MonitorMessenger.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_MonitorResultService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_PluginService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_ReportService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_ScriptService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_TestPlanScriptResultService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_TestPlanScriptService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_TestPlanService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/Test_UserService.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/service/auth/Test_AuthenticationManager.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/testplan/TestPlanTester.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/testplan/TestTestPlanResult.java (97%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/testplan/Test_LoadDistribute.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/master/test/transaction/Test_ScriptLoadCommand.java (100%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/mater/test/entity/Test_Monitor.java (96%) rename {src => Bench4Q-Master/src}/test/java/org/bench4q/mater/test/entity/Test_TestPlan.java (96%) rename {src => Bench4Q-Master/src}/test/resources/repository-test-context.xml (100%) rename {src => Bench4Q-Master/src}/test/resources/service-test-context.xml (100%) delete mode 100644 license.txt delete mode 100644 src/main/java/org/bench4q/master/report/MonitorReportService.java delete mode 100644 src/main/java/org/bench4q/master/report/ReportService.java delete mode 100644 src/main/java/org/bench4q/master/report/ScriptReportService.java delete mode 100644 src/test/java/org/bench4q/master/test/report/ReportFontTest.java diff --git a/RecordScriptTestCase/Bench4QTestCase/frame1.html b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/frame1.html similarity index 88% rename from RecordScriptTestCase/Bench4QTestCase/frame1.html rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/frame1.html index f6027a42..a513d1fa 100644 --- a/RecordScriptTestCase/Bench4QTestCase/frame1.html +++ b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/frame1.html @@ -1,8 +1,8 @@ - - -frame1 - - - No this picture - + + +frame1 + + + No this picture + \ No newline at end of file diff --git a/RecordScriptTestCase/Bench4QTestCase/frameTestCase.html b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/frameTestCase.html similarity index 95% rename from RecordScriptTestCase/Bench4QTestCase/frameTestCase.html rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/frameTestCase.html index b60b1f4e..64bf46f7 100644 --- a/RecordScriptTestCase/Bench4QTestCase/frameTestCase.html +++ b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/frameTestCase.html @@ -1,16 +1,16 @@ - - -Bench4Q Test Case - - - - - - - No this one - No this one - No this one - - - + + +Bench4Q Test Case + + + + + + + No this one + No this one + No this one + + + \ No newline at end of file diff --git a/RecordScriptTestCase/Bench4QTestCase/images/1.jpg b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/1.jpg similarity index 100% rename from RecordScriptTestCase/Bench4QTestCase/images/1.jpg rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/1.jpg diff --git a/RecordScriptTestCase/Bench4QTestCase/images/2.jpg b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/2.jpg similarity index 100% rename from RecordScriptTestCase/Bench4QTestCase/images/2.jpg rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/2.jpg diff --git a/RecordScriptTestCase/Bench4QTestCase/images/3.jpg b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/3.jpg similarity index 100% rename from RecordScriptTestCase/Bench4QTestCase/images/3.jpg rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/3.jpg diff --git a/RecordScriptTestCase/Bench4QTestCase/images/4.jpg b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/4.jpg similarity index 100% rename from RecordScriptTestCase/Bench4QTestCase/images/4.jpg rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/4.jpg diff --git a/RecordScriptTestCase/Bench4QTestCase/images/5.jpg b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/5.jpg similarity index 100% rename from RecordScriptTestCase/Bench4QTestCase/images/5.jpg rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/5.jpg diff --git a/RecordScriptTestCase/Bench4QTestCase/images/6.jpg b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/6.jpg similarity index 100% rename from RecordScriptTestCase/Bench4QTestCase/images/6.jpg rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/images/6.jpg diff --git a/RecordScriptTestCase/Bench4QTestCase/script/agentTable.js b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/script/agentTable.js similarity index 95% rename from RecordScriptTestCase/Bench4QTestCase/script/agentTable.js rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/script/agentTable.js index 812ef142..8ebdd8ca 100644 --- a/RecordScriptTestCase/Bench4QTestCase/script/agentTable.js +++ b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/script/agentTable.js @@ -1,94 +1,94 @@ -var table= $('#agents'); -$('.datatable').dataTable({ - "sDom": "<'row-fluid'<'span6'l><'span6'f>>t<'row-fluid'<'span12 center'p>>", - "sPaginationType": "bootstrap", - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" - } -} ); - - -$('.btn-setting').click(function(e){ -e.preventDefault(); -$("#agentParam").modal('show'); -}); -$(document).ready(function() { - loadAgents(table); - -}); -function cancel(){ - $("#agentParam").modal('hide'); -} -function loadAgents() { - table.dataTable().fnClearTable(); - $.post("loadAgents", {}, function(data) { - if (data!=null) { - for (var i = 0; i<'span6'f>>t<'row-fluid'<'span12 center'p>>", + "sPaginationType": "bootstrap", + "oLanguage": { + "sLengthMenu": "_MENU_ records per page" + } +} ); + + +$('.btn-setting').click(function(e){ +e.preventDefault(); +$("#agentParam").modal('show'); +}); +$(document).ready(function() { + loadAgents(table); + +}); +function cancel(){ + $("#agentParam").modal('hide'); +} +function loadAgents() { + table.dataTable().fnClearTable(); + $.post("loadAgents", {}, function(data) { + if (data!=null) { + for (var i = 0; i'+ - ''+ - ''+ - '' - ); - var els = $('a', nPaging); - $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); - $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler ); - }, - - "fnUpdate": function ( oSettings, fnDraw ) { - var iListLength = 5; - var oPaging = oSettings.oInstance.fnPagingInfo(); - var an = oSettings.aanFeatures.p; - var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); - - if ( oPaging.iTotalPages < iListLength) { - iStart = 1; - iEnd = oPaging.iTotalPages; - } - else if ( oPaging.iPage <= iHalf ) { - iStart = 1; - iEnd = iListLength; - } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { - iStart = oPaging.iTotalPages - iListLength + 1; - iEnd = oPaging.iTotalPages; - } else { - iStart = oPaging.iPage - iHalf + 1; - iEnd = iStart + iListLength - 1; - } - - for ( i=0, iLen=an.length ; i'+j+'') - .insertBefore( $('li:last', an[i])[0] ) - .bind('click', function (e) { - e.preventDefault(); - oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; - fnDraw( oSettings ); - } ); - } - - // add / remove disabled classes from the static elements - if ( oPaging.iPage === 0 ) { - $('li:first', an[i]).addClass('disabled'); - } else { - $('li:first', an[i]).removeClass('disabled'); - } - - if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { - $('li:last', an[i]).addClass('disabled'); - } else { - $('li:last', an[i]).removeClass('disabled'); - } - } - } - } -}); -function loadProperties(){ - jQuery.i18n.properties({// 加载资浏览器语言对应的资源文件 - name:'i18n', // 资源文件名称 - path:'i18n/', // 资源文件路径 - mode:'map', // 用 Map 的方式使用资源文件中的值 - } ); - } + +/*var viewButton = "View"+" "; +var editButton = "Edit"+" "; +var deleteButton = "Delete";*/ + +$(document).ready(function(){ + //highlight current / active link + $('ul.main-menu li a').each(function(){ + if($($(this))[0].href==String(window.location)) + $(this).parent().addClass('active'); + }); + //animating menus on hover + $('ul.main-menu li:not(.nav-header)').hover(function(){ + $(this).animate({'margin-left':'+=5'},300); + }, + function(){ + $(this).animate({'margin-left':'-=5'},300); + }); + docReady(); + loadProperties(); +}); + + +function docReady(){ + //makes elements soratble, elements that sort need to have id attribute to save the result + $('.sortable').sortable({ + revert:true, + cancel:'.btn,.box-content,.nav-header', + update:function(event,ui){ + //line below gives the ids of elements, you can make ajax call here to save it to the database + //console.log($(this).sortable('toArray')); + } + }); + $('.btn-close').click(function(e){ + e.preventDefault(); + $(this).parent().parent().parent().fadeOut(); + }); + $('.btn-minimize').click(function(e){ + e.preventDefault(); + var $target = $(this).parent().parent().next('.box-content'); + if($target.is(':visible')) $('i',$(this)).removeClass('icon-chevron-up').addClass('icon-chevron-down'); + else $('i',$(this)).removeClass('icon-chevron-down').addClass('icon-chevron-up'); + $target.slideToggle(); + }); + /*$('.btn-setting').click(function(e){ + e.preventDefault(); + $('#myModal').modal('show'); + });*/ +} +$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) +{ + return { + "iStart": oSettings._iDisplayStart, + "iEnd": oSettings.fnDisplayEnd(), + "iLength": oSettings._iDisplayLength, + "iTotal": oSettings.fnRecordsTotal(), + "iFilteredTotal": oSettings.fnRecordsDisplay(), + "iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), + "iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) + }; +}; +$.extend( $.fn.dataTableExt.oPagination, { + "bootstrap": { + "fnInit": function( oSettings, nPaging, fnDraw ) { + var oLang = oSettings.oLanguage.oPaginate; + var fnClickHandler = function ( e ) { + e.preventDefault(); + if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { + fnDraw( oSettings ); + } + }; + + $(nPaging).addClass('pagination').append( + '' + ); + var els = $('a', nPaging); + $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); + $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler ); + }, + + "fnUpdate": function ( oSettings, fnDraw ) { + var iListLength = 5; + var oPaging = oSettings.oInstance.fnPagingInfo(); + var an = oSettings.aanFeatures.p; + var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); + + if ( oPaging.iTotalPages < iListLength) { + iStart = 1; + iEnd = oPaging.iTotalPages; + } + else if ( oPaging.iPage <= iHalf ) { + iStart = 1; + iEnd = iListLength; + } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { + iStart = oPaging.iTotalPages - iListLength + 1; + iEnd = oPaging.iTotalPages; + } else { + iStart = oPaging.iPage - iHalf + 1; + iEnd = iStart + iListLength - 1; + } + + for ( i=0, iLen=an.length ; i'+j+'') + .insertBefore( $('li:last', an[i])[0] ) + .bind('click', function (e) { + e.preventDefault(); + oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; + fnDraw( oSettings ); + } ); + } + + // add / remove disabled classes from the static elements + if ( oPaging.iPage === 0 ) { + $('li:first', an[i]).addClass('disabled'); + } else { + $('li:first', an[i]).removeClass('disabled'); + } + + if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { + $('li:last', an[i]).addClass('disabled'); + } else { + $('li:last', an[i]).removeClass('disabled'); + } + } + } + } +}); +function loadProperties(){ + jQuery.i18n.properties({// 加载资浏览器语言对应的资源文件 + name:'i18n', // 资源文件名称 + path:'i18n/', // 资源文件路径 + mode:'map', // 用 Map 的方式使用资源文件中的值 + } ); + } diff --git a/RecordScriptTestCase/Bench4QTestCase/style/bootstrap-cerulean.css b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/style/bootstrap-cerulean.css similarity index 100% rename from RecordScriptTestCase/Bench4QTestCase/style/bootstrap-cerulean.css rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/style/bootstrap-cerulean.css diff --git a/RecordScriptTestCase/Bench4QTestCase/style/bootstrap-classic.css b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/style/bootstrap-classic.css similarity index 100% rename from RecordScriptTestCase/Bench4QTestCase/style/bootstrap-classic.css rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/style/bootstrap-classic.css diff --git a/RecordScriptTestCase/Bench4QTestCase/testcase.html b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/testcase.html similarity index 96% rename from RecordScriptTestCase/Bench4QTestCase/testcase.html rename to Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/testcase.html index 2592d42a..62334744 100644 --- a/RecordScriptTestCase/Bench4QTestCase/testcase.html +++ b/Bench4Q-Master/RecordScriptTestCase/Bench4QTestCase/testcase.html @@ -1,17 +1,17 @@ - - - Bench4Q Test Case - - - - - - No this one - No this one - No this one - - - - - - + + + Bench4Q Test Case + + + + + + No this one + No this one + No this one + + + + + + diff --git a/RecordScriptTestCase/baidu.html b/Bench4Q-Master/RecordScriptTestCase/baidu.html similarity index 100% rename from RecordScriptTestCase/baidu.html rename to Bench4Q-Master/RecordScriptTestCase/baidu.html diff --git a/RecordScriptTestCase/gzip/gzipBaiduIRBlankBody.html b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRBlankBody.html similarity index 91% rename from RecordScriptTestCase/gzip/gzipBaiduIRBlankBody.html rename to Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRBlankBody.html index a477239f..cdf32e0f 100644 --- a/RecordScriptTestCase/gzip/gzipBaiduIRBlankBody.html +++ b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRBlankBody.html @@ -1,16 +1,16 @@ -HTTP/1.1 200 OK -Content-Type: text/html; charset=utf-8 -Server: Microsoft-IIS/7.0 -CachedXSLT: true -X-AspNet-Version: 2.0.50727 -X-Powered-By: ASP.NET -Vary: Accept-Encoding -Cache-Control: private, max-age=31 -Date: Tue, 10 Dec 2013 08:40:29 GMT -Content-Length: 26 -Connection: keep-alive -Set-Cookie: agentscape-tag-devtype=desktop; Path=/ -Set-Cookie: agentscape-proc=noop; Path=/ -x-agentscape-info: c=1.0-r9869; v=3; fp=f844b0e65e9b5458; ts=1333395837 - +HTTP/1.1 200 OK +Content-Type: text/html; charset=utf-8 +Server: Microsoft-IIS/7.0 +CachedXSLT: true +X-AspNet-Version: 2.0.50727 +X-Powered-By: ASP.NET +Vary: Accept-Encoding +Cache-Control: private, max-age=31 +Date: Tue, 10 Dec 2013 08:40:29 GMT +Content-Length: 26 +Connection: keep-alive +Set-Cookie: agentscape-tag-devtype=desktop; Path=/ +Set-Cookie: agentscape-proc=noop; Path=/ +x-agentscape-info: c=1.0-r9869; v=3; fp=f844b0e65e9b5458; ts=1333395837 + \ No newline at end of file diff --git a/RecordScriptTestCase/gzip/gzipBaiduIRNotHtmlResponse.html b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRNotHtmlResponse.html similarity index 95% rename from RecordScriptTestCase/gzip/gzipBaiduIRNotHtmlResponse.html rename to Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRNotHtmlResponse.html index bf17233a..47d8fc0d 100644 --- a/RecordScriptTestCase/gzip/gzipBaiduIRNotHtmlResponse.html +++ b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRNotHtmlResponse.html @@ -1,16 +1,16 @@ -HTTP/1.1 200 OK -Content-Type: text/plain; charset=utf-8 -Server: Microsoft-IIS/7.0 -CachedXSLT: true -X-AspNet-Version: 2.0.50727 -X-Powered-By: ASP.NET -Vary: Accept-Encoding -Cache-Control: private, max-age=31 -Date: Tue, 10 Dec 2013 08:40:29 GMT -Content-Length: 6 -Connection: keep-alive -Set-Cookie: agentscape-tag-devtype=desktop; Path=/ -Set-Cookie: agentscape-proc=noop; Path=/ -x-agentscape-info: c=1.0-r9869; v=3; fp=f844b0e65e9b5458; ts=1333395837 - +HTTP/1.1 200 OK +Content-Type: text/plain; charset=utf-8 +Server: Microsoft-IIS/7.0 +CachedXSLT: true +X-AspNet-Version: 2.0.50727 +X-Powered-By: ASP.NET +Vary: Accept-Encoding +Cache-Control: private, max-age=31 +Date: Tue, 10 Dec 2013 08:40:29 GMT +Content-Length: 6 +Connection: keep-alive +Set-Cookie: agentscape-tag-devtype=desktop; Path=/ +Set-Cookie: agentscape-proc=noop; Path=/ +x-agentscape-info: c=1.0-r9869; v=3; fp=f844b0e65e9b5458; ts=1333395837 + adnddm \ No newline at end of file diff --git a/RecordScriptTestCase/gzip/gzipBaiduIRNullResponseBody.html b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRNullResponseBody.html similarity index 100% rename from RecordScriptTestCase/gzip/gzipBaiduIRNullResponseBody.html rename to Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRNullResponseBody.html diff --git a/RecordScriptTestCase/gzip/gzipBaiduIRRequest.txt b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRRequest.txt similarity index 97% rename from RecordScriptTestCase/gzip/gzipBaiduIRRequest.txt rename to Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRRequest.txt index 4721fc68..3b2fea2d 100644 --- a/RecordScriptTestCase/gzip/gzipBaiduIRRequest.txt +++ b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRRequest.txt @@ -1,15 +1,15 @@ -GET /phoenix.zhtml?c=188488&p=irol-homeprofile HTTP/1.1 -Host: ir.baidu.com -Connection: keep-alive -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 -User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 -Referer: http://www.baidu.com/ -Accept-Encoding: gzip,deflate,sdch -IF-MODIFIED-SINCE: Mon, 22 Mar 2010 14:14:40 GMT; old-content-length=200 -AUTHORIZATION: bearer -Accept-Language: zh-CN,zh;q=0.8 -Content-Type: multipart -Content-Length: 100 -Pragma: No-Cache -Cookie: BAIDUID=993724E1CAB01EE3D0C0AFAA99796E6A:FG=1; H_PS_PSSID=4381_1463_4212_4264_4451 - +GET /phoenix.zhtml?c=188488&p=irol-homeprofile HTTP/1.1 +Host: ir.baidu.com +Connection: keep-alive +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 +Referer: http://www.baidu.com/ +Accept-Encoding: gzip,deflate,sdch +IF-MODIFIED-SINCE: Mon, 22 Mar 2010 14:14:40 GMT; old-content-length=200 +AUTHORIZATION: bearer +Accept-Language: zh-CN,zh;q=0.8 +Content-Type: multipart +Content-Length: 100 +Pragma: No-Cache +Cookie: BAIDUID=993724E1CAB01EE3D0C0AFAA99796E6A:FG=1; H_PS_PSSID=4381_1463_4212_4264_4451 + diff --git a/RecordScriptTestCase/gzip/gzipBaiduIRResponse.txt b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRResponse.txt similarity index 100% rename from RecordScriptTestCase/gzip/gzipBaiduIRResponse.txt rename to Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRResponse.txt diff --git a/RecordScriptTestCase/gzip/gzipBaiduIRResponseBody.txt b/Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRResponseBody.txt similarity index 100% rename from RecordScriptTestCase/gzip/gzipBaiduIRResponseBody.txt rename to Bench4Q-Master/RecordScriptTestCase/gzip/gzipBaiduIRResponseBody.txt diff --git a/RecordScriptTestCase/gzipBaiduRequestHeader.txt b/Bench4Q-Master/RecordScriptTestCase/gzipBaiduRequestHeader.txt similarity index 98% rename from RecordScriptTestCase/gzipBaiduRequestHeader.txt rename to Bench4Q-Master/RecordScriptTestCase/gzipBaiduRequestHeader.txt index d1949e05..91e99ea6 100644 --- a/RecordScriptTestCase/gzipBaiduRequestHeader.txt +++ b/Bench4Q-Master/RecordScriptTestCase/gzipBaiduRequestHeader.txt @@ -1,10 +1,10 @@ -GET / HTTP/1.1 -Host: www.baidu.com -Connection: keep-alive -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 -User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 -DNT: 1 -Accept-Encoding: gzip,deflate,sdch -Accept-Language: en,zh-CN;q=0.8,zh;q=0.6 -Cookie: BAIDUID=1D43A956BCED0A81B8340058134CD2F6:FG=1; BDUSS=EJMRWZ2eklMaERoQ344em5RZ2EyTVh0UjRDcWpiRmhnMjRlLTZnR3NZajBOS0JTQVFBQUFBJCQAAAAAAAAAAAEAAAA2JuwxZmVuZ3l1bjIwMTIzOQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPSneFL0p3hSN; Hm_lvt_9f14aaa038bbba8b12ec2a4a3e51d254=1384429678; H_PS_PSSID=3784_4199_1432_4421_4414_4211_4264_4450_4503; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0 - +GET / HTTP/1.1 +Host: www.baidu.com +Connection: keep-alive +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 +DNT: 1 +Accept-Encoding: gzip,deflate,sdch +Accept-Language: en,zh-CN;q=0.8,zh;q=0.6 +Cookie: BAIDUID=1D43A956BCED0A81B8340058134CD2F6:FG=1; BDUSS=EJMRWZ2eklMaERoQ344em5RZ2EyTVh0UjRDcWpiRmhnMjRlLTZnR3NZajBOS0JTQVFBQUFBJCQAAAAAAAAAAAEAAAA2JuwxZmVuZ3l1bjIwMTIzOQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPSneFL0p3hSN; Hm_lvt_9f14aaa038bbba8b12ec2a4a3e51d254=1384429678; H_PS_PSSID=3784_4199_1432_4421_4414_4211_4264_4450_4503; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0 + diff --git a/RecordScriptTestCase/gzipBaiduResponse.txt b/Bench4Q-Master/RecordScriptTestCase/gzipBaiduResponse.txt similarity index 100% rename from RecordScriptTestCase/gzipBaiduResponse.txt rename to Bench4Q-Master/RecordScriptTestCase/gzipBaiduResponse.txt diff --git a/RecordScriptTestCase/gzipBaiduResponseBody.txt b/Bench4Q-Master/RecordScriptTestCase/gzipBaiduResponseBody.txt similarity index 100% rename from RecordScriptTestCase/gzipBaiduResponseBody.txt rename to Bench4Q-Master/RecordScriptTestCase/gzipBaiduResponseBody.txt diff --git a/RecordScriptTestCase/gzipChunkedGoogleResponse.txt b/Bench4Q-Master/RecordScriptTestCase/gzipChunkedGoogleResponse.txt similarity index 100% rename from RecordScriptTestCase/gzipChunkedGoogleResponse.txt rename to Bench4Q-Master/RecordScriptTestCase/gzipChunkedGoogleResponse.txt diff --git a/RecordScriptTestCase/gzipChunkedGoogleResponseBody.txt b/Bench4Q-Master/RecordScriptTestCase/gzipChunkedGoogleResponseBody.txt similarity index 100% rename from RecordScriptTestCase/gzipChunkedGoogleResponseBody.txt rename to Bench4Q-Master/RecordScriptTestCase/gzipChunkedGoogleResponseBody.txt diff --git a/RecordScriptTestCase/responsBodyAfterDeal.txt b/Bench4Q-Master/RecordScriptTestCase/responsBodyAfterDeal.txt similarity index 100% rename from RecordScriptTestCase/responsBodyAfterDeal.txt rename to Bench4Q-Master/RecordScriptTestCase/responsBodyAfterDeal.txt diff --git a/RecordScriptTestCase/scriptBriefResultModel.xml b/Bench4Q-Master/RecordScriptTestCase/scriptBriefResultModel.xml similarity index 94% rename from RecordScriptTestCase/scriptBriefResultModel.xml rename to Bench4Q-Master/RecordScriptTestCase/scriptBriefResultModel.xml index 10945118..b0a4679a 100644 --- a/RecordScriptTestCase/scriptBriefResultModel.xml +++ b/Bench4Q-Master/RecordScriptTestCase/scriptBriefResultModel.xml @@ -1,16 +1,16 @@ - - - 0 - 0 - 0 - 1203 - 0 - 28205 - 1774 - 559 - 3172 - 22154 - 5245392 - - 40 + + + 0 + 0 + 0 + 1203 + 0 + 28205 + 1774 + 559 + 3172 + 22154 + 5245392 + + 40 \ No newline at end of file diff --git a/RecordScriptTestCase/simpleResponse.txt b/Bench4Q-Master/RecordScriptTestCase/simpleResponse.txt similarity index 96% rename from RecordScriptTestCase/simpleResponse.txt rename to Bench4Q-Master/RecordScriptTestCase/simpleResponse.txt index 73f76515..67501f04 100644 --- a/RecordScriptTestCase/simpleResponse.txt +++ b/Bench4Q-Master/RecordScriptTestCase/simpleResponse.txt @@ -1,26 +1,26 @@ -HTTP/1.1 200 OK -Server: Apache-Coyote/1.1 -Accept-Ranges: bytes -ETag: W/"532-1386125334307" -Last-Modified: Wed, 04 Dec 2013 02:48:54 GMT -Content-Type: text/html -Content-Length: 532 -Date: Mon, 09 Dec 2013 07:03:15 GMT - - - - Bench4Q Test Case - - - - - - No this one - No this one - No this one - - - - - - +HTTP/1.1 200 OK +Server: Apache-Coyote/1.1 +Accept-Ranges: bytes +ETag: W/"532-1386125334307" +Last-Modified: Wed, 04 Dec 2013 02:48:54 GMT +Content-Type: text/html +Content-Length: 532 +Date: Mon, 09 Dec 2013 07:03:15 GMT + + + + Bench4Q Test Case + + + + + + No this one + No this one + No this one + + + + + + diff --git a/ScriptParameterization/79/param1.txt b/Bench4Q-Master/ScriptParameterization/79/param1.txt similarity index 100% rename from ScriptParameterization/79/param1.txt rename to Bench4Q-Master/ScriptParameterization/79/param1.txt diff --git a/ScriptParameterization/79/param2.txt b/Bench4Q-Master/ScriptParameterization/79/param2.txt similarity index 100% rename from ScriptParameterization/79/param2.txt rename to Bench4Q-Master/ScriptParameterization/79/param2.txt diff --git a/descriptor.xml b/Bench4Q-Master/descriptor.xml similarity index 95% rename from descriptor.xml rename to Bench4Q-Master/descriptor.xml index 4e8dc6e7..4454ef3a 100644 --- a/descriptor.xml +++ b/Bench4Q-Master/descriptor.xml @@ -1,25 +1,25 @@ - - - publish - - tar.gz - - false - - - lib - false - false - runtime - - - - - target/bench4q-master.jar - / - - + + + publish + + tar.gz + + false + + + lib + false + false + runtime + + + + + target/bench4q-master.jar + / + + \ No newline at end of file diff --git a/pom.xml b/Bench4Q-Master/pom.xml similarity index 96% rename from pom.xml rename to Bench4Q-Master/pom.xml index 23bb82ea..042d212d 100644 --- a/pom.xml +++ b/Bench4Q-Master/pom.xml @@ -1,167 +1,167 @@ - - 4.0.0 - org.bench4q - bench4q-master - jar - 0.0.1-SNAPSHOT - Bench4Q Master - Bench4Q Master - - TCSE, ISCAS - - - - junit - junit - 4.11 - test - - - org.springframework - spring-webmvc - 3.2.5.RELEASE - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.12 - - - org.hibernate - hibernate-core - 4.3.0.Beta3 - - - org.hibernate.javax.persistence - hibernate-jpa-2.1-api - 1.0.0.Draft-16 - - - mysql - mysql-connector-java - 5.1.25 - - - log4j - log4j - 1.2.17 - - - commons-httpclient - commons-httpclient - 3.1 - - - org.python - jython - 2.7-b1 - - - org.springframework - spring-test - 3.2.5.RELEASE - - - org.quartz-scheduler - quartz - 1.8.5 - - - org.springframework - spring-core - 3.2.5.RELEASE - - - org.slf4j - slf4j-simple - 1.7.5 - - - - jfree - jfreechart - 1.0.13 - - - - org.eclipse.birt.runtime.3_7_1 - com.lowagie.text - 2.1.7 - - - org.apache.portals.jetspeed-2 - jetspeed-fileutils-maven-plugin - 2.2.2 - maven-plugin - - - org.bench4q - bench4q-share - 0.0.1-SNAPSHOT - - - org.eclipse.jetty - jetty-servlet - 9.1.0.RC2 - - - org.eclipse.jetty - jetty-server - 9.1.0.RC2 - - - - org.jsoup - jsoup - 1.7.3 - - - - org.apache.httpcomponents - httpcore-nio - 4.3 - - - - - - maven-jar-plugin - - - - org.bench4q.master.Main - true - lib/ - - - - - - maven-assembly-plugin - - - make-zip - package - - single - - - - descriptor.xml - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - bench4q-master - + + 4.0.0 + org.bench4q + bench4q-master + jar + 0.0.1-SNAPSHOT + Bench4Q Master + Bench4Q Master + + TCSE, ISCAS + + + + junit + junit + 4.11 + test + + + org.springframework + spring-webmvc + 3.2.5.RELEASE + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.12 + + + org.hibernate + hibernate-core + 4.3.0.Beta3 + + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + 1.0.0.Draft-16 + + + mysql + mysql-connector-java + 5.1.25 + + + log4j + log4j + 1.2.17 + + + commons-httpclient + commons-httpclient + 3.1 + + + org.python + jython + 2.7-b1 + + + org.springframework + spring-test + 3.2.5.RELEASE + + + org.quartz-scheduler + quartz + 1.8.5 + + + org.springframework + spring-core + 3.2.5.RELEASE + + + org.slf4j + slf4j-simple + 1.7.5 + + + + jfree + jfreechart + 1.0.13 + + + + org.eclipse.birt.runtime.3_7_1 + com.lowagie.text + 2.1.7 + + + org.apache.portals.jetspeed-2 + jetspeed-fileutils-maven-plugin + 2.2.2 + maven-plugin + + + org.bench4q + bench4q-share + 0.0.1-SNAPSHOT + + + org.eclipse.jetty + jetty-servlet + 9.1.0.RC2 + + + org.eclipse.jetty + jetty-server + 9.1.0.RC2 + + + + org.jsoup + jsoup + 1.7.3 + + + + org.apache.httpcomponents + httpcore-nio + 4.3 + + + + + + maven-jar-plugin + + + + org.bench4q.master.Main + true + lib/ + + + + + + maven-assembly-plugin + + + make-zip + package + + single + + + + descriptor.xml + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + bench4q-master + \ No newline at end of file diff --git a/relative Docs/bench4q year final.pptx b/Bench4Q-Master/relative Docs/bench4q year final.pptx similarity index 100% rename from relative Docs/bench4q year final.pptx rename to Bench4Q-Master/relative Docs/bench4q year final.pptx diff --git a/src/main/java/org/bench4q/master/Main.java b/Bench4Q-Master/src/main/java/org/bench4q/master/Main.java similarity index 96% rename from src/main/java/org/bench4q/master/Main.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/Main.java index 6901197d..7e22673a 100644 --- a/src/main/java/org/bench4q/master/Main.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/Main.java @@ -1,57 +1,57 @@ -package org.bench4q.master; - -import java.io.InputStream; -import java.util.Properties; -import org.apache.log4j.Logger; - -/** - * - * @author coderfengyun - * - */ -public class Main { - private static Logger logger = Logger.getLogger(Main.class); - public static int Min_Sample_Cycle_InSecond = 10; - public static int MAX_FAIL_TIMES = 10; - public static int MIN_EXECUTE_INTERVAL_IN_SECONDS = 600; - public static int PICK_CYCLE_IN_SECONDS = 60; - - public static void main(String[] args) { - try { - MasterServer masterServer = new MasterServer(getPortToServe()); - masterServer.start(); - } catch (Exception e) { - e.printStackTrace(); - return; - } - } - - public static int getPortToServe() { - int portToUse = 0; - Properties prop = new Properties(); - String configFile = ""; - try { - InputStream inputStream = Main.class.getClassLoader() - .getResourceAsStream( - "org/bench4q/master/config/ServerPort.properties"); - prop.load(inputStream); - portToUse = Integer.parseInt(prop.getProperty("portToServe")); - MAX_FAIL_TIMES = Integer.parseInt(prop.getProperty("maxFailTime")); - MIN_EXECUTE_INTERVAL_IN_SECONDS = Integer.parseInt(prop - .getProperty("minExcuteIntervalInSeconds")); - PICK_CYCLE_IN_SECONDS = Integer.parseInt(prop - .getProperty("pickTestPlanCycleInSeconds")); - Min_Sample_Cycle_InSecond = Integer.parseInt(prop - .getProperty("minSampleCycleInSeconds")); - } catch (Exception e) { - portToUse = 8080; - MAX_FAIL_TIMES = 10; - MIN_EXECUTE_INTERVAL_IN_SECONDS = 600; - PICK_CYCLE_IN_SECONDS = 60; - Min_Sample_Cycle_InSecond = 10; - logger.error("There is no config file for port to serve! where path is " - + configFile); - } - return portToUse; - } -} +package org.bench4q.master; + +import java.io.InputStream; +import java.util.Properties; +import org.apache.log4j.Logger; + +/** + * + * @author coderfengyun + * + */ +public class Main { + private static Logger logger = Logger.getLogger(Main.class); + public static int Min_Sample_Cycle_InSecond = 10; + public static int MAX_FAIL_TIMES = 10; + public static int MIN_EXECUTE_INTERVAL_IN_SECONDS = 600; + public static int PICK_CYCLE_IN_SECONDS = 60; + + public static void main(String[] args) { + try { + MasterServer masterServer = new MasterServer(getPortToServe()); + masterServer.start(); + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + public static int getPortToServe() { + int portToUse = 0; + Properties prop = new Properties(); + String configFile = ""; + try { + InputStream inputStream = Main.class.getClassLoader() + .getResourceAsStream( + "org/bench4q/master/config/ServerPort.properties"); + prop.load(inputStream); + portToUse = Integer.parseInt(prop.getProperty("portToServe")); + MAX_FAIL_TIMES = Integer.parseInt(prop.getProperty("maxFailTime")); + MIN_EXECUTE_INTERVAL_IN_SECONDS = Integer.parseInt(prop + .getProperty("minExcuteIntervalInSeconds")); + PICK_CYCLE_IN_SECONDS = Integer.parseInt(prop + .getProperty("pickTestPlanCycleInSeconds")); + Min_Sample_Cycle_InSecond = Integer.parseInt(prop + .getProperty("minSampleCycleInSeconds")); + } catch (Exception e) { + portToUse = 8080; + MAX_FAIL_TIMES = 10; + MIN_EXECUTE_INTERVAL_IN_SECONDS = 600; + PICK_CYCLE_IN_SECONDS = 60; + Min_Sample_Cycle_InSecond = 10; + logger.error("There is no config file for port to serve! where path is " + + configFile); + } + return portToUse; + } +} diff --git a/src/main/java/org/bench4q/master/MasterServer.java b/Bench4Q-Master/src/main/java/org/bench4q/master/MasterServer.java similarity index 95% rename from src/main/java/org/bench4q/master/MasterServer.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/MasterServer.java index 7c5c1234..cd054cb0 100644 --- a/src/main/java/org/bench4q/master/MasterServer.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/MasterServer.java @@ -1,75 +1,75 @@ -package org.bench4q.master; - -import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.springframework.web.servlet.DispatcherServlet; - -/** - * - * @author coderfengyun - * - */ -public class MasterServer { - private Server server; - private int port; - - private Server getServer() { - return server; - } - - private void setServer(Server server) { - this.server = server; - } - - private int getPort() { - return port; - } - - private void setPort(int port) { - this.port = port; - } - - public MasterServer(int port) { - this.setPort(port); - } - - public boolean start() { - try { - this.setServer(new Server(this.getPort())); - ServletContextHandler servletContextHandler = new ServletContextHandler(); - ServletHolder servletHolder = servletContextHandler.addServlet( - DispatcherServlet.class, "/"); - servletHolder - .setInitParameter("contextConfigLocation", - "classpath*:/org/bench4q/master/config/application-context.xml"); - servletHolder.setInitOrder(1); - this.getServer().setHandler(servletContextHandler); - this.getServer().start(); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean stop() { - try { - if (this.getServer() != null) { - for (Connector connector : this.getServer().getConnectors()) { - if (connector != null) { - connector.shutdown(); - } - } - this.getServer().stop(); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } finally { - this.setServer(null); - } - } -} +package org.bench4q.master; + +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.springframework.web.servlet.DispatcherServlet; + +/** + * + * @author coderfengyun + * + */ +public class MasterServer { + private Server server; + private int port; + + private Server getServer() { + return server; + } + + private void setServer(Server server) { + this.server = server; + } + + private int getPort() { + return port; + } + + private void setPort(int port) { + this.port = port; + } + + public MasterServer(int port) { + this.setPort(port); + } + + public boolean start() { + try { + this.setServer(new Server(this.getPort())); + ServletContextHandler servletContextHandler = new ServletContextHandler(); + ServletHolder servletHolder = servletContextHandler.addServlet( + DispatcherServlet.class, "/"); + servletHolder + .setInitParameter("contextConfigLocation", + "classpath*:/org/bench4q/master/config/application-context.xml"); + servletHolder.setInitOrder(1); + this.getServer().setHandler(servletContextHandler); + this.getServer().start(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public boolean stop() { + try { + if (this.getServer() != null) { + for (Connector connector : this.getServer().getConnectors()) { + if (connector != null) { + connector.shutdown(); + } + } + this.getServer().stop(); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + this.setServer(null); + } + } +} diff --git a/src/main/java/org/bench4q/master/TestPlunginHelper.java b/Bench4Q-Master/src/main/java/org/bench4q/master/TestPlunginHelper.java similarity index 97% rename from src/main/java/org/bench4q/master/TestPlunginHelper.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/TestPlunginHelper.java index 408a2184..cbd75b48 100644 --- a/src/main/java/org/bench4q/master/TestPlunginHelper.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/TestPlunginHelper.java @@ -1,62 +1,62 @@ -package org.bench4q.master; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -import org.bench4q.share.models.master.plugin.MethodModel; -import org.bench4q.share.models.master.plugin.MethodParamModel; -import org.bench4q.share.models.master.plugin.ParamTypeEnum; -import org.bench4q.share.models.master.plugin.PluginModel; -import org.bench4q.share.models.master.plugin.MethodParamPropertyModel; - -; - -public class TestPlunginHelper { - - public static PluginModel createOnePlugin() { - PluginModel plugin = new PluginModel(); - MethodModel method = new MethodModel(); - MethodParamModel methodParamModelUrl = new MethodParamModel(); - methodParamModelUrl.setLable("input url"); - methodParamModelUrl.setName("url"); - methodParamModelUrl.setMethodParamProperties(generatePropertyForField()); - methodParamModelUrl.setParamType(ParamTypeEnum.Field); - - MethodParamModel methodParamsParamModel = new MethodParamModel(); - methodParamsParamModel.setName("queryparams"); - methodParamsParamModel.setLable("key=value"); - methodParamsParamModel.setMethodParamProperties(generatePropertyForMulti()); - methodParamsParamModel.setParamType(ParamTypeEnum.MultiField); - Set methodParams = new HashSet(); - methodParams.add(methodParamModelUrl); - methodParams.add(methodParamsParamModel); - method.setName("get"); - method.setMethodParams(methodParams); - - Set methods = new HashSet(); - methods.add(method); - plugin.setMethods(methods); - plugin.setName("http" + UUID.randomUUID()); - return plugin; - - } - private static Set generatePropertyForField() { - Set metList = new HashSet(); - MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); - methodParamPropertyModel.setKey("size"); - methodParamPropertyModel.setValue("20"); - metList.add(methodParamPropertyModel); - return metList; - - } - private static Set generatePropertyForMulti() { - Set metList = new HashSet(); - MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); - methodParamPropertyModel.setKey("size"); - methodParamPropertyModel.setValue("20"); - metList.add(methodParamPropertyModel); - return metList; - - } -} +package org.bench4q.master; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import org.bench4q.share.models.master.plugin.MethodModel; +import org.bench4q.share.models.master.plugin.MethodParamModel; +import org.bench4q.share.models.master.plugin.ParamTypeEnum; +import org.bench4q.share.models.master.plugin.PluginModel; +import org.bench4q.share.models.master.plugin.MethodParamPropertyModel; + +; + +public class TestPlunginHelper { + + public static PluginModel createOnePlugin() { + PluginModel plugin = new PluginModel(); + MethodModel method = new MethodModel(); + MethodParamModel methodParamModelUrl = new MethodParamModel(); + methodParamModelUrl.setLable("input url"); + methodParamModelUrl.setName("url"); + methodParamModelUrl.setMethodParamProperties(generatePropertyForField()); + methodParamModelUrl.setParamType(ParamTypeEnum.Field); + + MethodParamModel methodParamsParamModel = new MethodParamModel(); + methodParamsParamModel.setName("queryparams"); + methodParamsParamModel.setLable("key=value"); + methodParamsParamModel.setMethodParamProperties(generatePropertyForMulti()); + methodParamsParamModel.setParamType(ParamTypeEnum.MultiField); + Set methodParams = new HashSet(); + methodParams.add(methodParamModelUrl); + methodParams.add(methodParamsParamModel); + method.setName("get"); + method.setMethodParams(methodParams); + + Set methods = new HashSet(); + methods.add(method); + plugin.setMethods(methods); + plugin.setName("http" + UUID.randomUUID()); + return plugin; + + } + private static Set generatePropertyForField() { + Set metList = new HashSet(); + MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); + methodParamPropertyModel.setKey("size"); + methodParamPropertyModel.setValue("20"); + metList.add(methodParamPropertyModel); + return metList; + + } + private static Set generatePropertyForMulti() { + Set metList = new HashSet(); + MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); + methodParamPropertyModel.setKey("size"); + methodParamPropertyModel.setValue("20"); + metList.add(methodParamPropertyModel); + return metList; + + } +} diff --git a/src/main/java/org/bench4q/master/api/AgentController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/AgentController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/AgentController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/AgentController.java diff --git a/src/main/java/org/bench4q/master/api/BaseController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/BaseController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/BaseController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/BaseController.java diff --git a/src/main/java/org/bench4q/master/api/HomeController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/HomeController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/HomeController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/HomeController.java diff --git a/src/main/java/org/bench4q/master/api/MonitorController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/MonitorController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/MonitorController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/MonitorController.java diff --git a/src/main/java/org/bench4q/master/api/PluginController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/PluginController.java similarity index 97% rename from src/main/java/org/bench4q/master/api/PluginController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/PluginController.java index 0b5b3aa5..dbfe0df9 100644 --- a/src/main/java/org/bench4q/master/api/PluginController.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/api/PluginController.java @@ -1,128 +1,128 @@ -package org.bench4q.master.api; - -import org.apache.log4j.Logger; -import org.bench4q.master.TestPlunginHelper; -import org.bench4q.master.domain.service.PluginService; -import org.bench4q.master.domain.service.UserService; -import org.bench4q.master.exception.Bench4QException; -import org.bench4q.master.exception.ExceptionLog; -import org.bench4q.share.models.master.plugin.PluginGUI; -import org.bench4q.share.models.master.plugin.PluginModel; -import org.bench4q.share.models.master.plugin.PluginResponseModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/plugin") -public class PluginController extends BaseController { - private Logger logger = Logger.getLogger(PluginController.class); - private PluginService pluginService; - - public PluginService getPluginService() { - return pluginService; - } - - @Autowired - public void setPluginService(PluginService pluginService) { - this.pluginService = pluginService; - } - - @RequestMapping("/add") - @ResponseBody - public void addPluginToDataBase() throws Bench4QException{ - PluginModel pluginModel=TestPlunginHelper.createOnePlugin(); - this.getPluginService().addPlugin(pluginModel); - } - @RequestMapping("/loadPluginList") - @ResponseBody - public PluginResponseModel loadPluginList() throws Bench4QException { - if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { - throw new Bench4QException(400 + "", "not permitted", - "/loadPluginList"); - } - PluginResponseModel pluginResponseModel = new PluginResponseModel(); - pluginResponseModel.setPluginList(this.getPluginService() - .getPluginNameList()); - - pluginResponseModel.setSuccess(true); - return pluginResponseModel; - } - - @RequestMapping(value = "loadMethodList/{pluginName}", method = { - RequestMethod.GET, RequestMethod.POST }) - @ResponseBody - public PluginResponseModel getMethodList( - @PathVariable("pluginName") String pluginName) - throws Bench4QException { - if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { - throw new Bench4QException(400 + "", "not permitted", - "/loadMethodList/{pluginName}"); - } - try { - PluginResponseModel pluginResponseModel = new PluginResponseModel(); - pluginResponseModel.setMethodList(this.getPluginService() - .getMethodNameInPlugin(pluginName)); - pluginResponseModel.setSuccess(true); - return pluginResponseModel; - } catch (Exception e) { - logger.error(ExceptionLog.getStackTrace(e)); - return null; - } - } - - @RequestMapping(value = "loadMethodParams/{pluginName}/{methodName}", method = { - RequestMethod.GET, RequestMethod.POST }) - @ResponseBody - public PluginResponseModel getMethodParams( - @PathVariable("pluginName") String pluginName, - @PathVariable("methodName") String methodName) - throws Bench4QException { - if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) { - throw new Bench4QException(400 + "", "not permitted", - "loadMethodParams/{pluginName}/{methodName}"); - } - PluginResponseModel pluginResponseModel = new PluginResponseModel(); - pluginResponseModel.setMethosMethodParamModels(this.getPluginService() - .getMethodParamModelsInPlugin(pluginName, methodName)); - pluginResponseModel.setSuccess(true); - return pluginResponseModel; - } - - @RequestMapping(value = "/addPlugin", method = { RequestMethod.PUT }) - @ResponseBody - public PluginResponseModel addPlugin(@RequestBody PluginGUI pluginGUI) - throws Bench4QException { - if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) { - throw new Bench4QException(400 + "", "not permitted", - "loadMethodParams/{pluginName}/{methodName}"); - } - PluginResponseModel pluginResponseModel = new PluginResponseModel(); - pluginResponseModel.setSuccess(this.getPluginService().addPlugin( - pluginGUI.getPlugin())); - return pluginResponseModel; - - } - - @RequestMapping(value = "/deletePlugin/{pluginName}", method = { - RequestMethod.GET, RequestMethod.POST }) - @ResponseBody - public PluginResponseModel deletePlugin( - @PathVariable("pluginName") String pluginName) - throws Bench4QException { - if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) { - throw new Bench4QException(400 + "", "not permitted", - "loadMethodParams/{pluginName}/{methodName}"); - } - PluginResponseModel pluginResponseModel = new PluginResponseModel(); - pluginResponseModel.setSuccess(this.getPluginService().deletePlugin( - pluginName)); - return pluginResponseModel; - - } - -} +package org.bench4q.master.api; + +import org.apache.log4j.Logger; +import org.bench4q.master.TestPlunginHelper; +import org.bench4q.master.domain.service.PluginService; +import org.bench4q.master.domain.service.UserService; +import org.bench4q.master.exception.Bench4QException; +import org.bench4q.master.exception.ExceptionLog; +import org.bench4q.share.models.master.plugin.PluginGUI; +import org.bench4q.share.models.master.plugin.PluginModel; +import org.bench4q.share.models.master.plugin.PluginResponseModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/plugin") +public class PluginController extends BaseController { + private Logger logger = Logger.getLogger(PluginController.class); + private PluginService pluginService; + + public PluginService getPluginService() { + return pluginService; + } + + @Autowired + public void setPluginService(PluginService pluginService) { + this.pluginService = pluginService; + } + + @RequestMapping("/add") + @ResponseBody + public void addPluginToDataBase() throws Bench4QException{ + PluginModel pluginModel=TestPlunginHelper.createOnePlugin(); + this.getPluginService().addPlugin(pluginModel); + } + @RequestMapping("/loadPluginList") + @ResponseBody + public PluginResponseModel loadPluginList() throws Bench4QException { + if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { + throw new Bench4QException(400 + "", "not permitted", + "/loadPluginList"); + } + PluginResponseModel pluginResponseModel = new PluginResponseModel(); + pluginResponseModel.setPluginList(this.getPluginService() + .getPluginNameList()); + + pluginResponseModel.setSuccess(true); + return pluginResponseModel; + } + + @RequestMapping(value = "loadMethodList/{pluginName}", method = { + RequestMethod.GET, RequestMethod.POST }) + @ResponseBody + public PluginResponseModel getMethodList( + @PathVariable("pluginName") String pluginName) + throws Bench4QException { + if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { + throw new Bench4QException(400 + "", "not permitted", + "/loadMethodList/{pluginName}"); + } + try { + PluginResponseModel pluginResponseModel = new PluginResponseModel(); + pluginResponseModel.setMethodList(this.getPluginService() + .getMethodNameInPlugin(pluginName)); + pluginResponseModel.setSuccess(true); + return pluginResponseModel; + } catch (Exception e) { + logger.error(ExceptionLog.getStackTrace(e)); + return null; + } + } + + @RequestMapping(value = "loadMethodParams/{pluginName}/{methodName}", method = { + RequestMethod.GET, RequestMethod.POST }) + @ResponseBody + public PluginResponseModel getMethodParams( + @PathVariable("pluginName") String pluginName, + @PathVariable("methodName") String methodName) + throws Bench4QException { + if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) { + throw new Bench4QException(400 + "", "not permitted", + "loadMethodParams/{pluginName}/{methodName}"); + } + PluginResponseModel pluginResponseModel = new PluginResponseModel(); + pluginResponseModel.setMethosMethodParamModels(this.getPluginService() + .getMethodParamModelsInPlugin(pluginName, methodName)); + pluginResponseModel.setSuccess(true); + return pluginResponseModel; + } + + @RequestMapping(value = "/addPlugin", method = { RequestMethod.PUT }) + @ResponseBody + public PluginResponseModel addPlugin(@RequestBody PluginGUI pluginGUI) + throws Bench4QException { + if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) { + throw new Bench4QException(400 + "", "not permitted", + "loadMethodParams/{pluginName}/{methodName}"); + } + PluginResponseModel pluginResponseModel = new PluginResponseModel(); + pluginResponseModel.setSuccess(this.getPluginService().addPlugin( + pluginGUI.getPlugin())); + return pluginResponseModel; + + } + + @RequestMapping(value = "/deletePlugin/{pluginName}", method = { + RequestMethod.GET, RequestMethod.POST }) + @ResponseBody + public PluginResponseModel deletePlugin( + @PathVariable("pluginName") String pluginName) + throws Bench4QException { + if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) { + throw new Bench4QException(400 + "", "not permitted", + "loadMethodParams/{pluginName}/{methodName}"); + } + PluginResponseModel pluginResponseModel = new PluginResponseModel(); + pluginResponseModel.setSuccess(this.getPluginService().deletePlugin( + pluginName)); + return pluginResponseModel; + + } + +} diff --git a/src/main/java/org/bench4q/master/api/RecordPortController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/RecordPortController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/RecordPortController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/RecordPortController.java diff --git a/src/main/java/org/bench4q/master/api/ScriptController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/ScriptController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java diff --git a/src/main/java/org/bench4q/master/api/TestPlanController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/TestPlanController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/TestPlanController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/TestPlanController.java diff --git a/src/main/java/org/bench4q/master/api/TestPlanResulController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/TestPlanResulController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/TestPlanResulController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/TestPlanResulController.java diff --git a/src/main/java/org/bench4q/master/api/UserController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/UserController.java similarity index 100% rename from src/main/java/org/bench4q/master/api/UserController.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/api/UserController.java diff --git a/src/main/java/org/bench4q/master/domain/IAggregate.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/IAggregate.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/IAggregate.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/IAggregate.java diff --git a/src/main/java/org/bench4q/master/domain/RunningAgentInterface.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/RunningAgentInterface.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/RunningAgentInterface.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/RunningAgentInterface.java diff --git a/src/main/java/org/bench4q/master/domain/RunningScriptInterface.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/RunningScriptInterface.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/RunningScriptInterface.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/RunningScriptInterface.java diff --git a/src/main/java/org/bench4q/master/domain/entity/Agent.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Agent.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/Agent.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Agent.java diff --git a/src/main/java/org/bench4q/master/domain/entity/EntityBase.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/EntityBase.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/EntityBase.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/EntityBase.java diff --git a/src/main/java/org/bench4q/master/domain/entity/Monitor.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/Monitor.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java diff --git a/src/main/java/org/bench4q/master/domain/entity/MonitorResult.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/MonitorResult.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/MonitorResult.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/MonitorResult.java diff --git a/src/main/java/org/bench4q/master/domain/entity/PlanedConfig.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/PlanedConfig.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/PlanedConfig.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/PlanedConfig.java diff --git a/src/main/java/org/bench4q/master/domain/entity/Port.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Port.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/Port.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Port.java diff --git a/src/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java diff --git a/src/main/java/org/bench4q/master/domain/entity/Script.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Script.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/Script.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Script.java diff --git a/src/main/java/org/bench4q/master/domain/entity/TestPlan.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlan.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/TestPlan.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlan.java diff --git a/src/main/java/org/bench4q/master/domain/entity/TestPlanScript.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlanScript.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/TestPlanScript.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlanScript.java diff --git a/src/main/java/org/bench4q/master/domain/entity/TestPlanScriptResult.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlanScriptResult.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/TestPlanScriptResult.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/TestPlanScriptResult.java diff --git a/src/main/java/org/bench4q/master/domain/entity/User.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/User.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/User.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/User.java diff --git a/src/main/java/org/bench4q/master/domain/entity/plugin/Method.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/Method.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/plugin/Method.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/Method.java diff --git a/src/main/java/org/bench4q/master/domain/entity/plugin/MethodParam.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/MethodParam.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/plugin/MethodParam.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/MethodParam.java diff --git a/src/main/java/org/bench4q/master/domain/entity/plugin/MethodParamProperty.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/MethodParamProperty.java similarity index 95% rename from src/main/java/org/bench4q/master/domain/entity/plugin/MethodParamProperty.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/MethodParamProperty.java index d500e342..88084978 100644 --- a/src/main/java/org/bench4q/master/domain/entity/plugin/MethodParamProperty.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/MethodParamProperty.java @@ -1,60 +1,60 @@ -package org.bench4q.master.domain.entity.plugin; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - -@Entity -@Table(name = "methodParamProperty") -public class MethodParamProperty { - - private int id; - private String key; - private String value; - private MethodParam methodParam; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Column(name = "key") - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - @Column(name = "value") - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @ManyToOne - @JoinColumn(name = "methodParamId") - public MethodParam getMethodParam() { - return methodParam; - } - - public void setMethodParam(MethodParam methodParam) { - this.methodParam = methodParam; - } - -} +package org.bench4q.master.domain.entity.plugin; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "methodParamProperty") +public class MethodParamProperty { + + private int id; + private String key; + private String value; + private MethodParam methodParam; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Column(name = "key") + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + @Column(name = "value") + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @ManyToOne + @JoinColumn(name = "methodParamId") + public MethodParam getMethodParam() { + return methodParam; + } + + public void setMethodParam(MethodParam methodParam) { + this.methodParam = methodParam; + } + +} diff --git a/src/main/java/org/bench4q/master/domain/entity/plugin/ParamType.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/ParamType.java similarity index 95% rename from src/main/java/org/bench4q/master/domain/entity/plugin/ParamType.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/ParamType.java index 04c8b41f..7ea1f204 100644 --- a/src/main/java/org/bench4q/master/domain/entity/plugin/ParamType.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/ParamType.java @@ -1,41 +1,41 @@ -package org.bench4q.master.domain.entity.plugin; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -import org.bench4q.share.models.master.plugin.ParamTypeEnum; - -@Entity -@Table(name = "paramType") -public class ParamType { - private int id; - private ParamTypeEnum type; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Enumerated(EnumType.STRING) - @Column(columnDefinition = "ENUM('Field', 'MultiField', 'Table','CheckBox')") - public ParamTypeEnum getType() { - return type; - } - - public void setType(ParamTypeEnum type) { - this.type = type; - } - -} +package org.bench4q.master.domain.entity.plugin; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.bench4q.share.models.master.plugin.ParamTypeEnum; + +@Entity +@Table(name = "paramType") +public class ParamType { + private int id; + private ParamTypeEnum type; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Enumerated(EnumType.STRING) + @Column(columnDefinition = "ENUM('Field', 'MultiField', 'Table','CheckBox')") + public ParamTypeEnum getType() { + return type; + } + + public void setType(ParamTypeEnum type) { + this.type = type; + } + +} diff --git a/src/main/java/org/bench4q/master/domain/entity/plugin/Plugin.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/Plugin.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/entity/plugin/Plugin.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/Plugin.java diff --git a/src/main/java/org/bench4q/master/domain/factory/BusinessModelMapFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/BusinessModelMapFactory.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/factory/BusinessModelMapFactory.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/BusinessModelMapFactory.java diff --git a/src/main/java/org/bench4q/master/domain/factory/PluginFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginFactory.java similarity index 97% rename from src/main/java/org/bench4q/master/domain/factory/PluginFactory.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginFactory.java index 5ebc3f78..ef760d1a 100644 --- a/src/main/java/org/bench4q/master/domain/factory/PluginFactory.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginFactory.java @@ -1,137 +1,137 @@ -package org.bench4q.master.domain.factory; - -import java.util.HashSet; - -import org.bench4q.master.domain.entity.plugin.Method; -import org.bench4q.master.domain.entity.plugin.MethodParam; -import org.bench4q.master.domain.entity.plugin.MethodParamProperty; -import org.bench4q.master.domain.entity.plugin.ParamType; -import org.bench4q.master.domain.entity.plugin.Plugin; -import org.bench4q.master.domain.repository.PluginRepository; -import org.bench4q.share.models.master.plugin.MethodModel; -import org.bench4q.share.models.master.plugin.MethodParamModel; -import org.bench4q.share.models.master.plugin.MethodParamPropertyModel; -import org.bench4q.share.models.master.plugin.ParamTypeEnum; -import org.bench4q.share.models.master.plugin.PluginModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -@Component -public class PluginFactory { - - private PluginRepository pluginRepository; - - public PluginRepository getPluginRepository() { - return pluginRepository; - } - - @Autowired - public void setPluginRepository(PluginRepository pluginRepository) { - this.pluginRepository = pluginRepository; - } - - public Plugin createPluginEntity(PluginModel pluginModel) { - Plugin plugin = new Plugin(); - plugin.setPluginMethods(new HashSet()); - if (pluginModel.getMethods() != null) { - for (MethodModel methodModel : pluginModel.getMethods()) { - plugin.getPluginMethods().add( - createMethodEntity(methodModel, plugin)); - } - } - - plugin.setName(pluginModel.getName()); - return plugin; - - } - - private Method createMethodEntity(MethodModel methodModel, Plugin plugin) { - Method method = new Method(); - method.setMethodParams(new HashSet()); - method.setName(methodModel.getName()); - if (methodModel.getMethodParams() != null) { - for (MethodParamModel methodParamModel : methodModel - .getMethodParams()) { - method.getMethodParams().add( - createMethodParamEntity(methodParamModel, method)); - } - } - method.setPlugin(plugin); - - return method; - } - - private MethodParam createMethodParamEntity( - MethodParamModel methodParamModel, Method method) { - MethodParam methodParam = new MethodParam(); - methodParam.setLable(methodParamModel.getLable()); - methodParam.setName(methodParamModel.getName()); - methodParam.setMethod(method); - methodParam.setParamType(createPraParamTypeWithOutId(methodParamModel - .getParamType())); - if (methodParamModel.getMethodParamProperties() != null) { - methodParam - .setMethodParamProperties(new HashSet()); - for (MethodParamPropertyModel methodParamPropertyModel : methodParamModel - .getMethodParamProperties()) { - methodParam.getMethodParamProperties().add( - createMethodParamPropertyWithOutId( - methodParamPropertyModel, methodParam)); - } - } - return methodParam; - } - - private ParamType createPraParamTypeWithOutId(ParamTypeEnum paramTypeEnum) { - return this.getPluginRepository().getParamTypeByType(paramTypeEnum); - } - - private MethodParamProperty createMethodParamPropertyWithOutId( - MethodParamPropertyModel methodParamPropertyModel, - MethodParam methodParam) { - MethodParamProperty methodParamProperty = new MethodParamProperty(); - methodParamProperty.setKey(methodParamPropertyModel.getKey()); - methodParamProperty.setValue(methodParamPropertyModel.getValue()); - methodParamProperty.setMethodParam(methodParam); - return methodParamProperty; - } - - public static MethodModel extractMethodModel(Method method) { - MethodModel methodModel = new MethodModel(); - methodModel.setName(method.getName()); - if (method.getMethodParams() != null) { - methodModel.setMethodParams(new HashSet()); - for (MethodParam methodParam : method.getMethodParams()) { - methodModel.getMethodParams().add( - extractMethodParamModel(methodParam)); - } - } - return methodModel; - } - - private static MethodParamModel extractMethodParamModel( - MethodParam methodParam) { - MethodParamModel methodParamModel = new MethodParamModel(); - methodParamModel.setLable(methodParam.getLable()); - methodParamModel.setName(methodParam.getName()); - methodParamModel.setParamType(methodParam.getParamType().getType()); - if (methodParam.getMethodParamProperties() != null) { - methodParamModel - .setMethodParamProperties(new HashSet()); - for (MethodParamProperty methodParamProperty : methodParam - .getMethodParamProperties()) { - methodParamModel.getMethodParamProperties().add( - extractMethodParamPropertyModel(methodParamProperty)); - } - } - return methodParamModel; - } - - private static MethodParamPropertyModel extractMethodParamPropertyModel( - MethodParamProperty methodParamProperty) { - MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); - methodParamPropertyModel.setKey(methodParamProperty.getKey()); - methodParamPropertyModel.setValue(methodParamProperty.getValue()); - return methodParamPropertyModel; - } - -} +package org.bench4q.master.domain.factory; + +import java.util.HashSet; + +import org.bench4q.master.domain.entity.plugin.Method; +import org.bench4q.master.domain.entity.plugin.MethodParam; +import org.bench4q.master.domain.entity.plugin.MethodParamProperty; +import org.bench4q.master.domain.entity.plugin.ParamType; +import org.bench4q.master.domain.entity.plugin.Plugin; +import org.bench4q.master.domain.repository.PluginRepository; +import org.bench4q.share.models.master.plugin.MethodModel; +import org.bench4q.share.models.master.plugin.MethodParamModel; +import org.bench4q.share.models.master.plugin.MethodParamPropertyModel; +import org.bench4q.share.models.master.plugin.ParamTypeEnum; +import org.bench4q.share.models.master.plugin.PluginModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +@Component +public class PluginFactory { + + private PluginRepository pluginRepository; + + public PluginRepository getPluginRepository() { + return pluginRepository; + } + + @Autowired + public void setPluginRepository(PluginRepository pluginRepository) { + this.pluginRepository = pluginRepository; + } + + public Plugin createPluginEntity(PluginModel pluginModel) { + Plugin plugin = new Plugin(); + plugin.setPluginMethods(new HashSet()); + if (pluginModel.getMethods() != null) { + for (MethodModel methodModel : pluginModel.getMethods()) { + plugin.getPluginMethods().add( + createMethodEntity(methodModel, plugin)); + } + } + + plugin.setName(pluginModel.getName()); + return plugin; + + } + + private Method createMethodEntity(MethodModel methodModel, Plugin plugin) { + Method method = new Method(); + method.setMethodParams(new HashSet()); + method.setName(methodModel.getName()); + if (methodModel.getMethodParams() != null) { + for (MethodParamModel methodParamModel : methodModel + .getMethodParams()) { + method.getMethodParams().add( + createMethodParamEntity(methodParamModel, method)); + } + } + method.setPlugin(plugin); + + return method; + } + + private MethodParam createMethodParamEntity( + MethodParamModel methodParamModel, Method method) { + MethodParam methodParam = new MethodParam(); + methodParam.setLable(methodParamModel.getLable()); + methodParam.setName(methodParamModel.getName()); + methodParam.setMethod(method); + methodParam.setParamType(createPraParamTypeWithOutId(methodParamModel + .getParamType())); + if (methodParamModel.getMethodParamProperties() != null) { + methodParam + .setMethodParamProperties(new HashSet()); + for (MethodParamPropertyModel methodParamPropertyModel : methodParamModel + .getMethodParamProperties()) { + methodParam.getMethodParamProperties().add( + createMethodParamPropertyWithOutId( + methodParamPropertyModel, methodParam)); + } + } + return methodParam; + } + + private ParamType createPraParamTypeWithOutId(ParamTypeEnum paramTypeEnum) { + return this.getPluginRepository().getParamTypeByType(paramTypeEnum); + } + + private MethodParamProperty createMethodParamPropertyWithOutId( + MethodParamPropertyModel methodParamPropertyModel, + MethodParam methodParam) { + MethodParamProperty methodParamProperty = new MethodParamProperty(); + methodParamProperty.setKey(methodParamPropertyModel.getKey()); + methodParamProperty.setValue(methodParamPropertyModel.getValue()); + methodParamProperty.setMethodParam(methodParam); + return methodParamProperty; + } + + public static MethodModel extractMethodModel(Method method) { + MethodModel methodModel = new MethodModel(); + methodModel.setName(method.getName()); + if (method.getMethodParams() != null) { + methodModel.setMethodParams(new HashSet()); + for (MethodParam methodParam : method.getMethodParams()) { + methodModel.getMethodParams().add( + extractMethodParamModel(methodParam)); + } + } + return methodModel; + } + + private static MethodParamModel extractMethodParamModel( + MethodParam methodParam) { + MethodParamModel methodParamModel = new MethodParamModel(); + methodParamModel.setLable(methodParam.getLable()); + methodParamModel.setName(methodParam.getName()); + methodParamModel.setParamType(methodParam.getParamType().getType()); + if (methodParam.getMethodParamProperties() != null) { + methodParamModel + .setMethodParamProperties(new HashSet()); + for (MethodParamProperty methodParamProperty : methodParam + .getMethodParamProperties()) { + methodParamModel.getMethodParamProperties().add( + extractMethodParamPropertyModel(methodParamProperty)); + } + } + return methodParamModel; + } + + private static MethodParamPropertyModel extractMethodParamPropertyModel( + MethodParamProperty methodParamProperty) { + MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); + methodParamPropertyModel.setKey(methodParamProperty.getKey()); + methodParamPropertyModel.setValue(methodParamProperty.getValue()); + return methodParamPropertyModel; + } + +} diff --git a/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java diff --git a/src/main/java/org/bench4q/master/domain/factory/UserFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/UserFactory.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/factory/UserFactory.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/UserFactory.java diff --git a/src/main/java/org/bench4q/master/domain/repository/AbstractRepositoty.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/AbstractRepositoty.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/repository/AbstractRepositoty.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/AbstractRepositoty.java diff --git a/src/main/java/org/bench4q/master/domain/repository/AgentRepository.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/AgentRepository.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/repository/AgentRepository.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/AgentRepository.java diff --git a/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java similarity index 96% rename from src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java index 99642bab..8175646e 100644 --- a/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java @@ -1,14 +1,14 @@ -package org.bench4q.master.domain.repository; - -import org.bench4q.master.exception.ExceptionUtils.EntityUniqueAlReadyExistException; - -public class MonitorRepository extends AbstractRepositoty { - - @Override - protected void guardOtherUniqueConditionForEntity( - String uniquePropertyName, String value) - throws EntityUniqueAlReadyExistException { - // TODO Auto-generated method stub - - } -} +package org.bench4q.master.domain.repository; + +import org.bench4q.master.exception.ExceptionUtils.EntityUniqueAlReadyExistException; + +public class MonitorRepository extends AbstractRepositoty { + + @Override + protected void guardOtherUniqueConditionForEntity( + String uniquePropertyName, String value) + throws EntityUniqueAlReadyExistException { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/org/bench4q/master/domain/repository/PluginRepository.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/PluginRepository.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/repository/PluginRepository.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/PluginRepository.java diff --git a/src/main/java/org/bench4q/master/domain/repository/ScriptRepositoty.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/ScriptRepositoty.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/repository/ScriptRepositoty.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/ScriptRepositoty.java diff --git a/src/main/java/org/bench4q/master/domain/repository/TestPlanRepository.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/TestPlanRepository.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/repository/TestPlanRepository.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/TestPlanRepository.java diff --git a/src/main/java/org/bench4q/master/domain/repository/UserRepository.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/UserRepository.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/repository/UserRepository.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/UserRepository.java diff --git a/src/main/java/org/bench4q/master/domain/service/AgentService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/AgentService.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/AgentService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/AgentService.java diff --git a/src/main/java/org/bench4q/master/domain/service/MonitorResultService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/MonitorResultService.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/MonitorResultService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/MonitorResultService.java diff --git a/src/main/java/org/bench4q/master/domain/service/PluginService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/PluginService.java similarity index 96% rename from src/main/java/org/bench4q/master/domain/service/PluginService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/PluginService.java index 9a52aba9..a6d53a1d 100644 --- a/src/main/java/org/bench4q/master/domain/service/PluginService.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/PluginService.java @@ -1,129 +1,129 @@ -package org.bench4q.master.domain.service; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.bench4q.master.domain.entity.plugin.MethodParam; -import org.bench4q.master.domain.entity.plugin.Plugin; -import org.bench4q.master.domain.repository.PluginRepository; -import org.bench4q.master.exception.Bench4QException; -import org.bench4q.master.domain.entity.plugin.Method; -import org.bench4q.master.domain.factory.PluginFactory; -import org.bench4q.share.models.master.plugin.MethodParamModel; -import org.bench4q.share.models.master.plugin.PluginModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class PluginService { - private Set plugins; - private List pluginNameList; - private PluginRepository pluginRepository; - private PluginFactory pluginFactory; - private Logger logger = Logger.getLogger(PluginService.class); - - public PluginRepository getPluginRepository() { - return pluginRepository; - } - - @Autowired - public void setPluginRepository(PluginRepository pluginRepository) { - this.pluginRepository = pluginRepository; - } - - public PluginFactory getPluginFactory() { - return pluginFactory; - } - - @Autowired - public void setPluginFactory(PluginFactory pluginFactory) { - this.pluginFactory = pluginFactory; - } - - private Set getPlugins() throws Bench4QException { - List loadPluginList = this.getPluginRepository().loadPlugins(); - if (loadPluginList != null) { - this.plugins = new HashSet(); - for (Plugin plugin : loadPluginList) { - this.plugins.add(plugin); - } - } - - return this.plugins; - } - - public boolean addPlugin(PluginModel pluginModel) throws Bench4QException { - return this.getPluginRepository().attatch( - this.getPluginFactory().createPluginEntity(pluginModel)); - } - - public boolean deletePlugin(String pluginName) throws Bench4QException { - return this.getPluginRepository().detach(pluginName); - } - - private Plugin getPluginByName(String pluginName) { - return this.getPluginRepository().getPlugin(pluginName); - } - - public List getPluginNameList() throws Bench4QException { - this.pluginNameList = new ArrayList(); - this.getPlugins(); - if (this.plugins != null) { - for (Plugin plugin : this.plugins) { - this.pluginNameList.add(plugin.getName()); - } - } - return this.pluginNameList; - } - - public List getMethodNameInPlugin(String pluginName) { - List methodNameList = new ArrayList(); - Set methods = this.getPluginByName(pluginName) - .getPluginMethods(); - - if (methods != null) { - for (Method method : methods) { - methodNameList.add(method.getName()); - } - } - return methodNameList; - } - - private Method getMethodInPlugin(String pluginName, String methodName) - throws Bench4QException { - Set methods = this.getMethodInPlugin(pluginName); - if (methods != null) { - for (Method method : methods) { - if (method.getName().equals(methodName)) - return method; - } - } - logger.info("method is empty"); - - throw new Bench4QException("", "no such method:" + methodName - + "in plugin:" + pluginName, ""); - - } - - public Set getMethodParamModelsInPlugin( - String pluginName, String methodName) throws Bench4QException { - return PluginFactory.extractMethodModel( - this.getMethodInPlugin(pluginName, methodName)) - .getMethodParams(); - } - - private Set getMethodInPlugin(String pluginName) { - - return this.getPluginByName(pluginName).getPluginMethods(); - } - - public Set getMethodParams(String pluginName, String methodName) - throws Bench4QException { - Method method = this.getMethodInPlugin(pluginName, methodName); - return method.getMethodParams(); - } - -} +package org.bench4q.master.domain.service; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.log4j.Logger; +import org.bench4q.master.domain.entity.plugin.MethodParam; +import org.bench4q.master.domain.entity.plugin.Plugin; +import org.bench4q.master.domain.repository.PluginRepository; +import org.bench4q.master.exception.Bench4QException; +import org.bench4q.master.domain.entity.plugin.Method; +import org.bench4q.master.domain.factory.PluginFactory; +import org.bench4q.share.models.master.plugin.MethodParamModel; +import org.bench4q.share.models.master.plugin.PluginModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class PluginService { + private Set plugins; + private List pluginNameList; + private PluginRepository pluginRepository; + private PluginFactory pluginFactory; + private Logger logger = Logger.getLogger(PluginService.class); + + public PluginRepository getPluginRepository() { + return pluginRepository; + } + + @Autowired + public void setPluginRepository(PluginRepository pluginRepository) { + this.pluginRepository = pluginRepository; + } + + public PluginFactory getPluginFactory() { + return pluginFactory; + } + + @Autowired + public void setPluginFactory(PluginFactory pluginFactory) { + this.pluginFactory = pluginFactory; + } + + private Set getPlugins() throws Bench4QException { + List loadPluginList = this.getPluginRepository().loadPlugins(); + if (loadPluginList != null) { + this.plugins = new HashSet(); + for (Plugin plugin : loadPluginList) { + this.plugins.add(plugin); + } + } + + return this.plugins; + } + + public boolean addPlugin(PluginModel pluginModel) throws Bench4QException { + return this.getPluginRepository().attatch( + this.getPluginFactory().createPluginEntity(pluginModel)); + } + + public boolean deletePlugin(String pluginName) throws Bench4QException { + return this.getPluginRepository().detach(pluginName); + } + + private Plugin getPluginByName(String pluginName) { + return this.getPluginRepository().getPlugin(pluginName); + } + + public List getPluginNameList() throws Bench4QException { + this.pluginNameList = new ArrayList(); + this.getPlugins(); + if (this.plugins != null) { + for (Plugin plugin : this.plugins) { + this.pluginNameList.add(plugin.getName()); + } + } + return this.pluginNameList; + } + + public List getMethodNameInPlugin(String pluginName) { + List methodNameList = new ArrayList(); + Set methods = this.getPluginByName(pluginName) + .getPluginMethods(); + + if (methods != null) { + for (Method method : methods) { + methodNameList.add(method.getName()); + } + } + return methodNameList; + } + + private Method getMethodInPlugin(String pluginName, String methodName) + throws Bench4QException { + Set methods = this.getMethodInPlugin(pluginName); + if (methods != null) { + for (Method method : methods) { + if (method.getName().equals(methodName)) + return method; + } + } + logger.info("method is empty"); + + throw new Bench4QException("", "no such method:" + methodName + + "in plugin:" + pluginName, ""); + + } + + public Set getMethodParamModelsInPlugin( + String pluginName, String methodName) throws Bench4QException { + return PluginFactory.extractMethodModel( + this.getMethodInPlugin(pluginName, methodName)) + .getMethodParams(); + } + + private Set getMethodInPlugin(String pluginName) { + + return this.getPluginByName(pluginName).getPluginMethods(); + } + + public Set getMethodParams(String pluginName, String methodName) + throws Bench4QException { + Method method = this.getMethodInPlugin(pluginName, methodName); + return method.getMethodParams(); + } + +} diff --git a/src/main/java/org/bench4q/master/domain/service/PortPoolService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/PortPoolService.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/PortPoolService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/PortPoolService.java diff --git a/src/main/java/org/bench4q/master/domain/service/ScriptService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/ScriptService.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/ScriptService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/ScriptService.java diff --git a/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java diff --git a/src/main/java/org/bench4q/master/domain/service/TestPlanScriptResultService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanScriptResultService.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/TestPlanScriptResultService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanScriptResultService.java diff --git a/src/main/java/org/bench4q/master/domain/service/TestPlanScriptService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanScriptService.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/TestPlanScriptService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanScriptService.java diff --git a/src/main/java/org/bench4q/master/domain/service/TestPlanService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanService.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/TestPlanService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanService.java diff --git a/src/main/java/org/bench4q/master/domain/service/UserService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/UserService.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/UserService.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/UserService.java diff --git a/src/main/java/org/bench4q/master/domain/service/auth/AccessToken.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/auth/AccessToken.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/auth/AccessToken.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/auth/AccessToken.java diff --git a/src/main/java/org/bench4q/master/domain/service/auth/AuthenticationManager.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/auth/AuthenticationManager.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/auth/AuthenticationManager.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/auth/AuthenticationManager.java diff --git a/src/main/java/org/bench4q/master/domain/service/auth/CryptoManager.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/auth/CryptoManager.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/service/auth/CryptoManager.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/auth/CryptoManager.java diff --git a/src/main/java/org/bench4q/master/domain/testplan/LoadDistribute.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/LoadDistribute.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/testplan/LoadDistribute.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/LoadDistribute.java diff --git a/src/main/java/org/bench4q/master/domain/testplan/RunningScriptSampler.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/RunningScriptSampler.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/testplan/RunningScriptSampler.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/RunningScriptSampler.java diff --git a/src/main/java/org/bench4q/master/domain/testplan/TestMoniorResultSave.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/TestMoniorResultSave.java similarity index 96% rename from src/main/java/org/bench4q/master/domain/testplan/TestMoniorResultSave.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/TestMoniorResultSave.java index eaa4c8d7..34da6116 100644 --- a/src/main/java/org/bench4q/master/domain/testplan/TestMoniorResultSave.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/TestMoniorResultSave.java @@ -1,126 +1,126 @@ -package org.bench4q.master.domain.testplan; - -import java.lang.reflect.Field; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Observable; -import java.util.Observer; -import java.util.Set; -import java.util.UUID; - -import javax.xml.bind.JAXBException; - -import org.apache.log4j.Logger; -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.domain.entity.MonitorResult; -import org.bench4q.master.domain.entity.TestPlan; -import org.bench4q.master.domain.repository.TestPlanRepository; -import org.bench4q.master.helper.SessionHelper; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.statistics.SampleModel; -import org.bench4q.share.models.monitor.MonitorMain; -import org.hibernate.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class TestMoniorResultSave implements Observer { - private Logger logger = Logger.getLogger(TestMoniorResultSave.class); - private SessionHelper sessionHelper; - private TestPlanRepository testPlanRepository; - - public SessionHelper getSessionHelper() { - return sessionHelper; - } - - @Autowired - public void setSessionHelper(SessionHelper sessionHelper) { - this.sessionHelper = sessionHelper; - } - - private TestPlanRepository getTestPlanRepository() { - return testPlanRepository; - } - - @Autowired - private void setTestPlanRepository(TestPlanRepository testPlanRepository) { - this.testPlanRepository = testPlanRepository; - } - - public void update(Observable o, Object arg) { - // TODO Auto-generated method stub - - Monitor monitor = (Monitor) o; - logger.info("enter monitor update:" + monitor.getHostName()); - this.saveMonitorResult( - UUID.fromString(monitor.getTestPlan().getTestPlanRunId()), - (MonitorMain) arg, ((SampleModel) arg).getSamplingTime(), - monitor); - } - - public boolean saveMonitorResult(UUID testPlanRunId, MonitorMain mainModel, - Date createDatetime, Monitor monitor) { - Session session = this.getSessionHelper().openSession(); - try { - TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy( - session, testPlanRunId); - if (testPlan == null) { - return false; - } - monitor = testPlan.extractSpecifiedMonitor(monitor.getHostName()); - Set monitorResultToAdd = monitor.getResults(); - List monitorResults = this - .extractMonitorResultFromMonitorModel(mainModel, testPlan, - monitor, createDatetime); - if (monitorResults == null) - return false; - if (monitorResults.size() == 0) { - System.out.println("size is 0 "); - return false; - } - - for (MonitorResult monitorResult : monitorResults) { - if (session == null) - return false; - monitorResultToAdd.add(monitorResult); - } - logger.info("monitor ressult size:" + monitorResultToAdd.size()); - return this.getTestPlanRepository().doUpdateEntity(session, - testPlan); - } catch (Exception e) { - e.printStackTrace(); - return false; - } finally { - if (session.isConnected()) { - session.close(); - } - } - - } - - private List extractMonitorResultFromMonitorModel( - MonitorMain monitorMain, TestPlan testPlan, Monitor monitor, - Date createDatetime) throws IllegalArgumentException, - IllegalAccessException, JAXBException { - - List monitorResults = new LinkedList(); - - Field[] fields = monitorMain.getClass().getDeclaredFields(); - - for (int i = 0; i < fields.length; i++) { - MonitorResult monitorResult = new MonitorResult(); - monitorResult.setTestPlanDB(testPlan); - monitorResult.setMonitor(monitor); - monitorResult.setCreateDatetime(createDatetime); - monitorResult.setHostNameUnderMonitor(monitor.getHostName()); - fields[i].setAccessible(true); - monitorResult.setType(fields[i].getName()); - monitorResult.setContent(MarshalHelper.marshal(fields[i].getType(), - fields[i].get(monitorMain))); - monitorResults.add(monitorResult); - } - return monitorResults; - - } -} +package org.bench4q.master.domain.testplan; + +import java.lang.reflect.Field; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Observable; +import java.util.Observer; +import java.util.Set; +import java.util.UUID; + +import javax.xml.bind.JAXBException; + +import org.apache.log4j.Logger; +import org.bench4q.master.domain.entity.Monitor; +import org.bench4q.master.domain.entity.MonitorResult; +import org.bench4q.master.domain.entity.TestPlan; +import org.bench4q.master.domain.repository.TestPlanRepository; +import org.bench4q.master.helper.SessionHelper; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.statistics.SampleModel; +import org.bench4q.share.models.monitor.MonitorMain; +import org.hibernate.Session; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class TestMoniorResultSave implements Observer { + private Logger logger = Logger.getLogger(TestMoniorResultSave.class); + private SessionHelper sessionHelper; + private TestPlanRepository testPlanRepository; + + public SessionHelper getSessionHelper() { + return sessionHelper; + } + + @Autowired + public void setSessionHelper(SessionHelper sessionHelper) { + this.sessionHelper = sessionHelper; + } + + private TestPlanRepository getTestPlanRepository() { + return testPlanRepository; + } + + @Autowired + private void setTestPlanRepository(TestPlanRepository testPlanRepository) { + this.testPlanRepository = testPlanRepository; + } + + public void update(Observable o, Object arg) { + // TODO Auto-generated method stub + + Monitor monitor = (Monitor) o; + logger.info("enter monitor update:" + monitor.getHostName()); + this.saveMonitorResult( + UUID.fromString(monitor.getTestPlan().getTestPlanRunId()), + (MonitorMain) arg, ((SampleModel) arg).getSamplingTime(), + monitor); + } + + public boolean saveMonitorResult(UUID testPlanRunId, MonitorMain mainModel, + Date createDatetime, Monitor monitor) { + Session session = this.getSessionHelper().openSession(); + try { + TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy( + session, testPlanRunId); + if (testPlan == null) { + return false; + } + monitor = testPlan.extractSpecifiedMonitor(monitor.getHostName()); + Set monitorResultToAdd = monitor.getResults(); + List monitorResults = this + .extractMonitorResultFromMonitorModel(mainModel, testPlan, + monitor, createDatetime); + if (monitorResults == null) + return false; + if (monitorResults.size() == 0) { + System.out.println("size is 0 "); + return false; + } + + for (MonitorResult monitorResult : monitorResults) { + if (session == null) + return false; + monitorResultToAdd.add(monitorResult); + } + logger.info("monitor ressult size:" + monitorResultToAdd.size()); + return this.getTestPlanRepository().doUpdateEntity(session, + testPlan); + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + if (session.isConnected()) { + session.close(); + } + } + + } + + private List extractMonitorResultFromMonitorModel( + MonitorMain monitorMain, TestPlan testPlan, Monitor monitor, + Date createDatetime) throws IllegalArgumentException, + IllegalAccessException, JAXBException { + + List monitorResults = new LinkedList(); + + Field[] fields = monitorMain.getClass().getDeclaredFields(); + + for (int i = 0; i < fields.length; i++) { + MonitorResult monitorResult = new MonitorResult(); + monitorResult.setTestPlanDB(testPlan); + monitorResult.setMonitor(monitor); + monitorResult.setCreateDatetime(createDatetime); + monitorResult.setHostNameUnderMonitor(monitor.getHostName()); + fields[i].setAccessible(true); + monitorResult.setType(fields[i].getName()); + monitorResult.setContent(MarshalHelper.marshal(fields[i].getType(), + fields[i].get(monitorMain))); + monitorResults.add(monitorResult); + } + return monitorResults; + + } +} diff --git a/src/main/java/org/bench4q/master/domain/testplan/TestMonitorSampler.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/TestMonitorSampler.java similarity index 96% rename from src/main/java/org/bench4q/master/domain/testplan/TestMonitorSampler.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/TestMonitorSampler.java index b79204cc..cca1d6ce 100644 --- a/src/main/java/org/bench4q/master/domain/testplan/TestMonitorSampler.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/TestMonitorSampler.java @@ -1,25 +1,25 @@ -package org.bench4q.master.domain.testplan; - - -import org.bench4q.master.infrastructure.communication.MonitorMessenger; -import org.bench4q.share.models.monitor.MonitorMain; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class TestMonitorSampler { - - private MonitorMessenger monitorMessenger; - - @Autowired - private void setMonitorMessenger(MonitorMessenger monitorMessenger) { - this.monitorMessenger = monitorMessenger; - } - - public MonitorMain getMonitorResult( String hostName, - int port) { - return this.monitorMessenger - .monitorModel(hostName, port); - } - -} +package org.bench4q.master.domain.testplan; + + +import org.bench4q.master.infrastructure.communication.MonitorMessenger; +import org.bench4q.share.models.monitor.MonitorMain; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class TestMonitorSampler { + + private MonitorMessenger monitorMessenger; + + @Autowired + private void setMonitorMessenger(MonitorMessenger monitorMessenger) { + this.monitorMessenger = monitorMessenger; + } + + public MonitorMain getMonitorResult( String hostName, + int port) { + return this.monitorMessenger + .monitorModel(hostName, port); + } + +} diff --git a/src/main/java/org/bench4q/master/domain/testplan/TestScriptResultSave.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/TestScriptResultSave.java similarity index 100% rename from src/main/java/org/bench4q/master/domain/testplan/TestScriptResultSave.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/domain/testplan/TestScriptResultSave.java diff --git a/src/main/java/org/bench4q/master/exception/Bench4QException.java b/Bench4Q-Master/src/main/java/org/bench4q/master/exception/Bench4QException.java similarity index 94% rename from src/main/java/org/bench4q/master/exception/Bench4QException.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/exception/Bench4QException.java index 3502dbbc..5b5af3cc 100644 --- a/src/main/java/org/bench4q/master/exception/Bench4QException.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/exception/Bench4QException.java @@ -1,47 +1,47 @@ -package org.bench4q.master.exception; - -/** - * To deal with the response of each function of TestPlanController - * - * @author coderfengyun - * - */ -public class Bench4QException extends Exception { - /** - * - */ - private static final long serialVersionUID = 7450550491330737876L; - private String code; - private String message; - private String resource; - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getResource() { - return resource; - } - - public void setResource(String resource) { - this.resource = resource; - } - - public Bench4QException(String code, String message, String resource) { - this.setCode(code); - this.setMessage(message); - this.setResource(resource); - } -} +package org.bench4q.master.exception; + +/** + * To deal with the response of each function of TestPlanController + * + * @author coderfengyun + * + */ +public class Bench4QException extends Exception { + /** + * + */ + private static final long serialVersionUID = 7450550491330737876L; + private String code; + private String message; + private String resource; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Bench4QException(String code, String message, String resource) { + this.setCode(code); + this.setMessage(message); + this.setResource(resource); + } +} diff --git a/src/main/java/org/bench4q/master/exception/Bench4QExceptionSweeper.java b/Bench4Q-Master/src/main/java/org/bench4q/master/exception/Bench4QExceptionSweeper.java similarity index 97% rename from src/main/java/org/bench4q/master/exception/Bench4QExceptionSweeper.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/exception/Bench4QExceptionSweeper.java index b51026bb..7793a9c7 100644 --- a/src/main/java/org/bench4q/master/exception/Bench4QExceptionSweeper.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/exception/Bench4QExceptionSweeper.java @@ -1,19 +1,19 @@ -package org.bench4q.master.exception; - -import org.bench4q.share.models.ErrorResponseModel; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -@Component -public class Bench4QExceptionSweeper { - @ExceptionHandler(Bench4QException.class) - @ResponseStatus(value = HttpStatus.BAD_REQUEST) - @ResponseBody - public ErrorResponseModel handleException(Bench4QException e) { - return ErrorResponseModel.buildErrorResponse(e.getCode(), - e.getMessage(), e.getResource()); - } -} +package org.bench4q.master.exception; + +import org.bench4q.share.models.ErrorResponseModel; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +@Component +public class Bench4QExceptionSweeper { + @ExceptionHandler(Bench4QException.class) + @ResponseStatus(value = HttpStatus.BAD_REQUEST) + @ResponseBody + public ErrorResponseModel handleException(Bench4QException e) { + return ErrorResponseModel.buildErrorResponse(e.getCode(), + e.getMessage(), e.getResource()); + } +} diff --git a/src/main/java/org/bench4q/master/exception/ExceptionLog.java b/Bench4Q-Master/src/main/java/org/bench4q/master/exception/ExceptionLog.java similarity index 96% rename from src/main/java/org/bench4q/master/exception/ExceptionLog.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/exception/ExceptionLog.java index 608bfaae..ab07bb7c 100644 --- a/src/main/java/org/bench4q/master/exception/ExceptionLog.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/exception/ExceptionLog.java @@ -1,13 +1,13 @@ -package org.bench4q.master.exception; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -public class ExceptionLog { - public static ByteArrayOutputStream getStackTrace(Throwable e) { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - PrintStream printStream = new PrintStream(outputStream); - e.printStackTrace(printStream); - return outputStream; - } -} +package org.bench4q.master.exception; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +public class ExceptionLog { + public static ByteArrayOutputStream getStackTrace(Throwable e) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + PrintStream printStream = new PrintStream(outputStream); + e.printStackTrace(printStream); + return outputStream; + } +} diff --git a/src/main/java/org/bench4q/master/exception/ExceptionUtils.java b/Bench4Q-Master/src/main/java/org/bench4q/master/exception/ExceptionUtils.java similarity index 100% rename from src/main/java/org/bench4q/master/exception/ExceptionUtils.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/exception/ExceptionUtils.java diff --git a/src/main/java/org/bench4q/master/helper/ApplicationContextHelper.java b/Bench4Q-Master/src/main/java/org/bench4q/master/helper/ApplicationContextHelper.java similarity index 96% rename from src/main/java/org/bench4q/master/helper/ApplicationContextHelper.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/helper/ApplicationContextHelper.java index fb232241..ebea4283 100644 --- a/src/main/java/org/bench4q/master/helper/ApplicationContextHelper.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/helper/ApplicationContextHelper.java @@ -1,26 +1,26 @@ -package org.bench4q.master.helper; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -@Component -public class ApplicationContextHelper implements ApplicationContextAware { - - private static ApplicationContext context; - - public static ApplicationContext getContext() { - return context; - } - - private void setContext(ApplicationContext context) { - ApplicationContextHelper.context = context; - } - - public void setApplicationContext(ApplicationContext applicationContext) - throws BeansException { - this.setContext(applicationContext); - } - -} +package org.bench4q.master.helper; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +@Component +public class ApplicationContextHelper implements ApplicationContextAware { + + private static ApplicationContext context; + + public static ApplicationContext getContext() { + return context; + } + + private void setContext(ApplicationContext context) { + ApplicationContextHelper.context = context; + } + + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + this.setContext(applicationContext); + } + +} diff --git a/src/main/java/org/bench4q/master/helper/CollectionHelper.java b/Bench4Q-Master/src/main/java/org/bench4q/master/helper/CollectionHelper.java similarity index 100% rename from src/main/java/org/bench4q/master/helper/CollectionHelper.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/helper/CollectionHelper.java diff --git a/src/main/java/org/bench4q/master/helper/HashHelper.java b/Bench4Q-Master/src/main/java/org/bench4q/master/helper/HashHelper.java similarity index 95% rename from src/main/java/org/bench4q/master/helper/HashHelper.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/helper/HashHelper.java index 0d267e2e..39e36486 100644 --- a/src/main/java/org/bench4q/master/helper/HashHelper.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/helper/HashHelper.java @@ -1,33 +1,33 @@ -package org.bench4q.master.helper; - -import java.security.MessageDigest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class HashHelper { - private StringHelper stringHelper; - - private StringHelper getStringHelper() { - return stringHelper; - } - - @Autowired - private void setStringHelper(StringHelper stringHelper) { - this.stringHelper = stringHelper; - } - - public String sha1Hash(String source) { - try { - String ret = new String(source); - MessageDigest md = MessageDigest.getInstance("SHA-1"); - ret = this.getStringHelper().convertToHexString( - md.digest(ret.getBytes())); - return ret; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} +package org.bench4q.master.helper; + +import java.security.MessageDigest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class HashHelper { + private StringHelper stringHelper; + + private StringHelper getStringHelper() { + return stringHelper; + } + + @Autowired + private void setStringHelper(StringHelper stringHelper) { + this.stringHelper = stringHelper; + } + + public String sha1Hash(String source) { + try { + String ret = new String(source); + MessageDigest md = MessageDigest.getInstance("SHA-1"); + ret = this.getStringHelper().convertToHexString( + md.digest(ret.getBytes())); + return ret; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/java/org/bench4q/master/helper/SessionHelper.java b/Bench4Q-Master/src/main/java/org/bench4q/master/helper/SessionHelper.java similarity index 100% rename from src/main/java/org/bench4q/master/helper/SessionHelper.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/helper/SessionHelper.java diff --git a/src/main/java/org/bench4q/master/helper/StringHelper.java b/Bench4Q-Master/src/main/java/org/bench4q/master/helper/StringHelper.java similarity index 96% rename from src/main/java/org/bench4q/master/helper/StringHelper.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/helper/StringHelper.java index 0b894c5d..0da00088 100644 --- a/src/main/java/org/bench4q/master/helper/StringHelper.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/helper/StringHelper.java @@ -1,38 +1,38 @@ -package org.bench4q.master.helper; - -import org.springframework.stereotype.Component; - -@Component -public final class StringHelper { - - public String convertToHexString(byte[] b) { - String ret = ""; - for (int i = 0; i < b.length; i++) { - String hex = Integer.toHexString(b[i] & 0xFF); - if (hex.length() == 1) { - hex = '0' + hex; - } - ret += hex; - } - return ret; - } - - private byte uniteBytes(byte src0, byte src1) { - byte _b0 = Byte.decode("0x" + new String(new byte[] { src0 })) - .byteValue(); - _b0 = (byte) (_b0 << 4); - byte _b1 = Byte.decode("0x" + new String(new byte[] { src1 })) - .byteValue(); - byte ret = (byte) (_b0 ^ _b1); - return ret; - } - - public byte[] convertToBytes(String src) { - byte[] ret = new byte[src.getBytes().length / 2]; - byte[] tmp = src.getBytes(); - for (int i = 0; i < ret.length; i++) { - ret[i] = this.uniteBytes(tmp[i * 2], tmp[i * 2 + 1]); - } - return ret; - } -} +package org.bench4q.master.helper; + +import org.springframework.stereotype.Component; + +@Component +public final class StringHelper { + + public String convertToHexString(byte[] b) { + String ret = ""; + for (int i = 0; i < b.length; i++) { + String hex = Integer.toHexString(b[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + ret += hex; + } + return ret; + } + + private byte uniteBytes(byte src0, byte src1) { + byte _b0 = Byte.decode("0x" + new String(new byte[] { src0 })) + .byteValue(); + _b0 = (byte) (_b0 << 4); + byte _b1 = Byte.decode("0x" + new String(new byte[] { src1 })) + .byteValue(); + byte ret = (byte) (_b0 ^ _b1); + return ret; + } + + public byte[] convertToBytes(String src) { + byte[] ret = new byte[src.getBytes().length / 2]; + byte[] tmp = src.getBytes(); + for (int i = 0; i < ret.length; i++) { + ret[i] = this.uniteBytes(tmp[i * 2], tmp[i * 2 + 1]); + } + return ret; + } +} diff --git a/src/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java similarity index 100% rename from src/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java diff --git a/src/main/java/org/bench4q/master/infrastructure/communication/MonitorMessenger.java b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/MonitorMessenger.java similarity index 100% rename from src/main/java/org/bench4q/master/infrastructure/communication/MonitorMessenger.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/MonitorMessenger.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/ScriptCapturer.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/ScriptCapturer.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/ScriptCapturer.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/ScriptCapturer.java index f4b6eb40..dd042201 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/ScriptCapturer.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/ScriptCapturer.java @@ -1,91 +1,91 @@ -package org.bench4q.master.scriptrecord; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.HashMap; -import java.util.Map; - -import javax.swing.JTextArea; - -import org.bench4q.master.scriptrecord.httpcapture.HttpCapture; -import org.bench4q.master.scriptrecord.httpcapture.Utils.UserException; -import org.springframework.stereotype.Component; - -@Component -public class ScriptCapturer { - private String ipHttpCaptureServerAdress; - private static final String HTTPCATUREGENERATOR_STRING = "org.bench4q.master.scriptrecord.httpcapture.generator.Bench4qCodeGenerator"; - private Map httpCaptureMap; - - public String getIpHttpCaptureServerAdress() { - return ipHttpCaptureServerAdress; - } - - public void setIpHttpCaptureServerAdress(String ipHttpCaptureServerAdress) { - this.ipHttpCaptureServerAdress = ipHttpCaptureServerAdress; - } - - public Map getHttpCaptureMap() { - return httpCaptureMap; - } - - public void setHttpCaptureMap(Map httpCaptureMap) { - this.httpCaptureMap = httpCaptureMap; - } - - public ScriptCapturer() { - this.setIpHttpCaptureServerAdress(this.getLocalHostIp()); - this.setHttpCaptureMap(new HashMap()); - } - - private String getLocalHostIp() { - InetAddress addr; - try { - addr = InetAddress.getLocalHost(); - return addr.getHostAddress().toString(); - } catch (UnknownHostException e) { - e.printStackTrace(); - return null; - } - - } - - public void startRecord(int port, String fileDir, String fileName) { - try { - HttpCapture httpCapture = buildACapture(port, fileDir, fileName); - httpCapture.startProxyServer(); - httpCapture.startRecording(); - } catch (IOException e1) { - System.out.println("Error When start recording!"); - e1.printStackTrace(); - } catch (UserException e1) { - System.out.println("Error When start recording!"); - e1.printStackTrace(); - } - } - - private HttpCapture buildACapture(int port, String filePath, String fileName) { - HttpCapture httpCapture = new HttpCapture(filePath, fileName, port, - HTTPCATUREGENERATOR_STRING, new JTextArea()); - this.getHttpCaptureMap().put(new Integer(port), httpCapture); - return httpCapture; - } - - public void stopCurrentRecord(int port) { - try { - HttpCapture httpCapture = this.getHttpCaptureMap().get( - new Integer(port)); - if (httpCapture == null) { - return; - } - assert (httpCapture.isRecording()); - httpCapture.stopRecording(); - httpCapture.shutProxyServer(); - this.getHttpCaptureMap().remove(new Integer(port)); - } catch (Exception e1) { - System.out.println("Error When stop recording!"); - e1.printStackTrace(); - } - } -} +package org.bench4q.master.scriptrecord; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTextArea; + +import org.bench4q.master.scriptrecord.httpcapture.HttpCapture; +import org.bench4q.master.scriptrecord.httpcapture.Utils.UserException; +import org.springframework.stereotype.Component; + +@Component +public class ScriptCapturer { + private String ipHttpCaptureServerAdress; + private static final String HTTPCATUREGENERATOR_STRING = "org.bench4q.master.scriptrecord.httpcapture.generator.Bench4qCodeGenerator"; + private Map httpCaptureMap; + + public String getIpHttpCaptureServerAdress() { + return ipHttpCaptureServerAdress; + } + + public void setIpHttpCaptureServerAdress(String ipHttpCaptureServerAdress) { + this.ipHttpCaptureServerAdress = ipHttpCaptureServerAdress; + } + + public Map getHttpCaptureMap() { + return httpCaptureMap; + } + + public void setHttpCaptureMap(Map httpCaptureMap) { + this.httpCaptureMap = httpCaptureMap; + } + + public ScriptCapturer() { + this.setIpHttpCaptureServerAdress(this.getLocalHostIp()); + this.setHttpCaptureMap(new HashMap()); + } + + private String getLocalHostIp() { + InetAddress addr; + try { + addr = InetAddress.getLocalHost(); + return addr.getHostAddress().toString(); + } catch (UnknownHostException e) { + e.printStackTrace(); + return null; + } + + } + + public void startRecord(int port, String fileDir, String fileName) { + try { + HttpCapture httpCapture = buildACapture(port, fileDir, fileName); + httpCapture.startProxyServer(); + httpCapture.startRecording(); + } catch (IOException e1) { + System.out.println("Error When start recording!"); + e1.printStackTrace(); + } catch (UserException e1) { + System.out.println("Error When start recording!"); + e1.printStackTrace(); + } + } + + private HttpCapture buildACapture(int port, String filePath, String fileName) { + HttpCapture httpCapture = new HttpCapture(filePath, fileName, port, + HTTPCATUREGENERATOR_STRING, new JTextArea()); + this.getHttpCaptureMap().put(new Integer(port), httpCapture); + return httpCapture; + } + + public void stopCurrentRecord(int port) { + try { + HttpCapture httpCapture = this.getHttpCaptureMap().get( + new Integer(port)); + if (httpCapture == null) { + return; + } + assert (httpCapture.isRecording()); + httpCapture.stopRecording(); + httpCapture.shutProxyServer(); + this.getHttpCaptureMap().remove(new Integer(port)); + } catch (Exception e1) { + System.out.println("Error When stop recording!"); + e1.printStackTrace(); + } + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Action.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Action.java similarity index 95% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/Action.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Action.java index aee35a7e..95cffb05 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Action.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Action.java @@ -1,147 +1,147 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -import java.util.Vector; - -public class Action { - private String url; - private String method; - private String expected_result; - private int delayTime; - private int expected_size; - private int timeout; - private Vector headers; - private Vector queryStringParams; - private Vector bodyParams; - private String multiPartData; - - public Action() { - this.headers = new Vector(); - this.queryStringParams = new Vector(); - this.bodyParams = new Vector(); - this.expected_result = ""; - this.multiPartData = ""; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getUrl() { - return this.url; - } - - public void setMethod(String method) { - this.method = method; - } - - public String getMethod() { - return this.method; - } - - public void setExpectedResult(String str) { - this.expected_result = str; - } - - public String getExpectedResult() { - return this.expected_result; - } - - public void setDelayTime(int seconds) { - this.delayTime = seconds; - } - - public int getDelayTime() { - return this.delayTime; - } - - public void setExpectedSize(int bytes) { - this.expected_size = bytes; - } - - public int getExpectedSize() { - return this.expected_size; - } - - public void setTimeout(int seconds) { - this.timeout = seconds; - } - - public int getTimeout() { - return this.timeout; - } - - public int getHeaderCount() { - return this.headers.size(); - } - - public HeaderValue[] getHeaders() { - HeaderValue[] list = new HeaderValue[this.headers.size()]; - this.headers.copyInto(list); - return list; - } - - public void addHeader(HeaderValue p) { - this.headers.addElement(p); - } - - public void removeHeader(HeaderValue p) { - this.headers.removeElement(p); - } - - public int getParamsCount() { - return getParams().length; - } - - public int getQueryStringParamCount() { - return this.queryStringParams.size(); - } - - public int getBodyParamCount() { - return this.bodyParams.size(); - } - - public Param[] getQueryStringParams() { - Param[] list = new Param[this.queryStringParams.size()]; - this.queryStringParams.copyInto(list); - return list; - } - - public Param[] getBodyParams() { - Param[] list = new Param[this.bodyParams.size()]; - this.bodyParams.copyInto(list); - return list; - } - - public Param[] getParams() { - @SuppressWarnings("unchecked") - Vector v = (Vector) this.queryStringParams.clone(); - v.addAll(this.bodyParams); - Param[] list = new Param[v.size()]; - v.copyInto(list); - return list; - } - - public void addQueryStringParam(Param p) { - this.queryStringParams.addElement(p); - } - - public void addBodyParam(Param p) { - this.bodyParams.addElement(p); - } - - public void removeQueryStringParam(Param p) { - this.queryStringParams.removeElement(p); - } - - public void removeBodyParam(Param p) { - this.bodyParams.removeElement(p); - } - - public void setMultiPartData(String multiPartData) { - this.multiPartData = multiPartData; - } - - public String getMultiPartData() { - return this.multiPartData; - } -} +package org.bench4q.master.scriptrecord.httpcapture; + +import java.util.Vector; + +public class Action { + private String url; + private String method; + private String expected_result; + private int delayTime; + private int expected_size; + private int timeout; + private Vector headers; + private Vector queryStringParams; + private Vector bodyParams; + private String multiPartData; + + public Action() { + this.headers = new Vector(); + this.queryStringParams = new Vector(); + this.bodyParams = new Vector(); + this.expected_result = ""; + this.multiPartData = ""; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUrl() { + return this.url; + } + + public void setMethod(String method) { + this.method = method; + } + + public String getMethod() { + return this.method; + } + + public void setExpectedResult(String str) { + this.expected_result = str; + } + + public String getExpectedResult() { + return this.expected_result; + } + + public void setDelayTime(int seconds) { + this.delayTime = seconds; + } + + public int getDelayTime() { + return this.delayTime; + } + + public void setExpectedSize(int bytes) { + this.expected_size = bytes; + } + + public int getExpectedSize() { + return this.expected_size; + } + + public void setTimeout(int seconds) { + this.timeout = seconds; + } + + public int getTimeout() { + return this.timeout; + } + + public int getHeaderCount() { + return this.headers.size(); + } + + public HeaderValue[] getHeaders() { + HeaderValue[] list = new HeaderValue[this.headers.size()]; + this.headers.copyInto(list); + return list; + } + + public void addHeader(HeaderValue p) { + this.headers.addElement(p); + } + + public void removeHeader(HeaderValue p) { + this.headers.removeElement(p); + } + + public int getParamsCount() { + return getParams().length; + } + + public int getQueryStringParamCount() { + return this.queryStringParams.size(); + } + + public int getBodyParamCount() { + return this.bodyParams.size(); + } + + public Param[] getQueryStringParams() { + Param[] list = new Param[this.queryStringParams.size()]; + this.queryStringParams.copyInto(list); + return list; + } + + public Param[] getBodyParams() { + Param[] list = new Param[this.bodyParams.size()]; + this.bodyParams.copyInto(list); + return list; + } + + public Param[] getParams() { + @SuppressWarnings("unchecked") + Vector v = (Vector) this.queryStringParams.clone(); + v.addAll(this.bodyParams); + Param[] list = new Param[v.size()]; + v.copyInto(list); + return list; + } + + public void addQueryStringParam(Param p) { + this.queryStringParams.addElement(p); + } + + public void addBodyParam(Param p) { + this.bodyParams.addElement(p); + } + + public void removeQueryStringParam(Param p) { + this.queryStringParams.removeElement(p); + } + + public void removeBodyParam(Param p) { + this.bodyParams.removeElement(p); + } + + public void setMultiPartData(String multiPartData) { + this.multiPartData = multiPartData; + } + + public String getMultiPartData() { + return this.multiPartData; + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Bench4qTestScriptAdapter.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Bench4qTestScriptAdapter.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/Bench4qTestScriptAdapter.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Bench4qTestScriptAdapter.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Config.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Config.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/Config.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Config.java index aeed4efe..c0c73c9c 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Config.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Config.java @@ -1,272 +1,272 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.Layout; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.python.util.PythonInterpreter; - -public class Config { - private static Config config = null; - private static final Log log = LogFactory.getLog(Config.class); - private static Properties props; - private String pythonPath; - private int port = 8090; - private boolean debug; - private boolean quiet; - private String exist; - private String replace; - private List includeList; - private List excludeList; - private List includePatterns = new ArrayList(); - private List excludePatterns = new ArrayList(); - private String scriptArg; - private ProxySettings proxySettings; - private static String defDriverPkgName = "com.bitmechanic.maxq"; - private static String defValidatorPkgName = "com.bitmechanic.maxq"; - - static { - Layout layout = new PatternLayout("%d [%t] %-5p %c - %m%n"); - Logger.getRootLogger().addAppender( - new ConsoleAppender(layout, "System.err")); - } - - public static Config getConfig() { - if (config == null) - initConfig(); - return config; - } - - public static void initConfig() { - config = new Config(); - String maxqDir = System.getProperty("maxq.dir"); - String pathSep = System.getProperty("file.separator"); - // "\\src\\main\\resources\\org\\bench4q\\master\\config\\httpCaptureConfig\\maxq.properties"; - String propertiesFileName = System.getProperty("user.dir") + "src" - + pathSep + "main" + pathSep + "resources" + pathSep + "org" - + pathSep + "bench4q" + pathSep + "master" + pathSep + "config" - + pathSep + "httpCaptureConfig" + pathSep + "maxq.properties"; - - InputStream propertiesStream = Config.class.getClassLoader() - .getResourceAsStream(propertiesFileName); - props = new Properties(); - if (propertiesStream != null) { - try { - props.load(propertiesStream); - log.debug("Generator: " - + props.getProperty("generator.classnames")); - } catch (IOException e) { - throw new ExceptionInInitializerError(e); - } - - } - - config.addPythonPath(maxqDir + pathSep + "jython"); - - String path = config.getProperty("python.path"); - if (path != null) { - config.addPythonPath(path); - } - - String portStr = props.getProperty("local.proxy.port"); - if (portStr != null) - config.port = Integer.parseInt(portStr); - } - - public void completeInit() throws Utils.UserException { - Level level = this.quiet ? Level.WARN : this.debug ? Level.ALL - : Level.INFO; - Logger.getRootLogger().setLevel(level); - - System.setProperty("org.apache.commons.logging.simplelog.defaultlog", - "warn"); - - Properties ppref = new Properties(); - if (getPythonPath() != null) - ppref.put("python.path", getPythonPath()); - PythonInterpreter.initialize(System.getProperties(), ppref, - new String[0]); - - String host = getProperty("remote.proxy.host"); - Integer port = getPropertyInt("remote.proxy.port"); - if ((host == null ? 1 : 0) != (port == null ? 1 : 0)) - throw new Utils.UserException( - "Not using proxy server. You must set both remote.proxy.host and remote.proxy.port."); - if ((host != null) && (port != null)) { - this.proxySettings = new ProxySettings(); - this.proxySettings.host = host; - this.proxySettings.port = port.intValue(); - log.info("Proxying requests via " + this.proxySettings.host + ":" - + Integer.toString(this.proxySettings.port)); - } - } - - public String getProperty(String prop) { - return (String) props.get(prop); - } - - public String getProperty(String prop, String def) { - String val = getProperty(prop); - return (val == null) || (val.equals("")) ? def : val; - } - - public void setProperty(String property, String value) { - props.setProperty(property, value); - } - - public Integer getPropertyInt(String prop) throws Utils.UserException { - String s = getProperty(prop); - if (s == null) - return null; - try { - return new Integer(s); - } catch (NumberFormatException e) { - } - throw new Utils.UserException(prop + " property must be an integer"); - } - - public void addPythonPath(String path) { - if (this.pythonPath == null) - this.pythonPath = path; - else - this.pythonPath = (this.pythonPath - + System.getProperty("path.separator") + path); - } - - public String getPythonPath() { - return this.pythonPath; - } - - public void setPort(int pt) { - this.port = pt; - } - - public int getPort() { - return this.port; - } - - public void setDebug(boolean d) { - this.debug = d; - } - - public boolean isDebug() { - return this.debug; - } - - public void setQuiet(boolean q) { - this.quiet = q; - } - - public boolean isQuiet() { - return this.quiet; - } - - public void setExist(String e) { - this.exist = e; - } - - public String getExist() { - return this.exist; - } - - public void setReplace(String e) { - this.replace = e; - } - - public String getReplace() { - return this.replace; - } - - public void setIncludePatterns(String[] pats) { - this.includeList = Arrays.asList(pats); - createPatterns(this.includeList, this.includePatterns); - } - - public void setExcludePatterns(String[] pats) { - this.excludeList = Arrays.asList(pats); - createPatterns(this.excludeList, this.excludePatterns); - } - - public List getIncludePatterns() { - return this.includePatterns; - } - - public List getExcludePatterns() { - return this.excludePatterns; - } - - public void setScriptArg(String arg) { - this.scriptArg = arg; - } - - public String getScriptArg() { - return this.scriptArg; - } - - public static String getDriverPkgName() { - return System.getProperty("maxq.driverpkgname", defDriverPkgName); - } - - public static String getValidatorPkgName() { - return System.getProperty("maxq.validatorpkgname", defValidatorPkgName); - } - - public static Log getTestLogger() { - return LogFactory.getLog("com.bitmechanic.maxq.testrun"); - } - - public ProxySettings getProxySettings() { - return this.proxySettings; - } - - public void setProxySettings(ProxySettings proxySettings) { - this.proxySettings = proxySettings; - } - - private void createPatterns(List list, - List excludePatterns2) { - Iterator iter = list.iterator(); - excludePatterns2.clear(); - while (iter.hasNext()) - try { - Pattern p = Pattern.compile(iter.next().toString()); - excludePatterns2.add(p); - } catch (PatternSyntaxException e) { - log.error(e); - } - } - - public static class ProxySettings { - String host; - int port; - - public String getHost() { - return this.host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return this.port; - } - - public void setPort(int port) { - this.port = port; - } - } -} +package org.bench4q.master.scriptrecord.httpcapture; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.Layout; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; +import org.python.util.PythonInterpreter; + +public class Config { + private static Config config = null; + private static final Log log = LogFactory.getLog(Config.class); + private static Properties props; + private String pythonPath; + private int port = 8090; + private boolean debug; + private boolean quiet; + private String exist; + private String replace; + private List includeList; + private List excludeList; + private List includePatterns = new ArrayList(); + private List excludePatterns = new ArrayList(); + private String scriptArg; + private ProxySettings proxySettings; + private static String defDriverPkgName = "com.bitmechanic.maxq"; + private static String defValidatorPkgName = "com.bitmechanic.maxq"; + + static { + Layout layout = new PatternLayout("%d [%t] %-5p %c - %m%n"); + Logger.getRootLogger().addAppender( + new ConsoleAppender(layout, "System.err")); + } + + public static Config getConfig() { + if (config == null) + initConfig(); + return config; + } + + public static void initConfig() { + config = new Config(); + String maxqDir = System.getProperty("maxq.dir"); + String pathSep = System.getProperty("file.separator"); + // "\\src\\main\\resources\\org\\bench4q\\master\\config\\httpCaptureConfig\\maxq.properties"; + String propertiesFileName = System.getProperty("user.dir") + "src" + + pathSep + "main" + pathSep + "resources" + pathSep + "org" + + pathSep + "bench4q" + pathSep + "master" + pathSep + "config" + + pathSep + "httpCaptureConfig" + pathSep + "maxq.properties"; + + InputStream propertiesStream = Config.class.getClassLoader() + .getResourceAsStream(propertiesFileName); + props = new Properties(); + if (propertiesStream != null) { + try { + props.load(propertiesStream); + log.debug("Generator: " + + props.getProperty("generator.classnames")); + } catch (IOException e) { + throw new ExceptionInInitializerError(e); + } + + } + + config.addPythonPath(maxqDir + pathSep + "jython"); + + String path = config.getProperty("python.path"); + if (path != null) { + config.addPythonPath(path); + } + + String portStr = props.getProperty("local.proxy.port"); + if (portStr != null) + config.port = Integer.parseInt(portStr); + } + + public void completeInit() throws Utils.UserException { + Level level = this.quiet ? Level.WARN : this.debug ? Level.ALL + : Level.INFO; + Logger.getRootLogger().setLevel(level); + + System.setProperty("org.apache.commons.logging.simplelog.defaultlog", + "warn"); + + Properties ppref = new Properties(); + if (getPythonPath() != null) + ppref.put("python.path", getPythonPath()); + PythonInterpreter.initialize(System.getProperties(), ppref, + new String[0]); + + String host = getProperty("remote.proxy.host"); + Integer port = getPropertyInt("remote.proxy.port"); + if ((host == null ? 1 : 0) != (port == null ? 1 : 0)) + throw new Utils.UserException( + "Not using proxy server. You must set both remote.proxy.host and remote.proxy.port."); + if ((host != null) && (port != null)) { + this.proxySettings = new ProxySettings(); + this.proxySettings.host = host; + this.proxySettings.port = port.intValue(); + log.info("Proxying requests via " + this.proxySettings.host + ":" + + Integer.toString(this.proxySettings.port)); + } + } + + public String getProperty(String prop) { + return (String) props.get(prop); + } + + public String getProperty(String prop, String def) { + String val = getProperty(prop); + return (val == null) || (val.equals("")) ? def : val; + } + + public void setProperty(String property, String value) { + props.setProperty(property, value); + } + + public Integer getPropertyInt(String prop) throws Utils.UserException { + String s = getProperty(prop); + if (s == null) + return null; + try { + return new Integer(s); + } catch (NumberFormatException e) { + } + throw new Utils.UserException(prop + " property must be an integer"); + } + + public void addPythonPath(String path) { + if (this.pythonPath == null) + this.pythonPath = path; + else + this.pythonPath = (this.pythonPath + + System.getProperty("path.separator") + path); + } + + public String getPythonPath() { + return this.pythonPath; + } + + public void setPort(int pt) { + this.port = pt; + } + + public int getPort() { + return this.port; + } + + public void setDebug(boolean d) { + this.debug = d; + } + + public boolean isDebug() { + return this.debug; + } + + public void setQuiet(boolean q) { + this.quiet = q; + } + + public boolean isQuiet() { + return this.quiet; + } + + public void setExist(String e) { + this.exist = e; + } + + public String getExist() { + return this.exist; + } + + public void setReplace(String e) { + this.replace = e; + } + + public String getReplace() { + return this.replace; + } + + public void setIncludePatterns(String[] pats) { + this.includeList = Arrays.asList(pats); + createPatterns(this.includeList, this.includePatterns); + } + + public void setExcludePatterns(String[] pats) { + this.excludeList = Arrays.asList(pats); + createPatterns(this.excludeList, this.excludePatterns); + } + + public List getIncludePatterns() { + return this.includePatterns; + } + + public List getExcludePatterns() { + return this.excludePatterns; + } + + public void setScriptArg(String arg) { + this.scriptArg = arg; + } + + public String getScriptArg() { + return this.scriptArg; + } + + public static String getDriverPkgName() { + return System.getProperty("maxq.driverpkgname", defDriverPkgName); + } + + public static String getValidatorPkgName() { + return System.getProperty("maxq.validatorpkgname", defValidatorPkgName); + } + + public static Log getTestLogger() { + return LogFactory.getLog("com.bitmechanic.maxq.testrun"); + } + + public ProxySettings getProxySettings() { + return this.proxySettings; + } + + public void setProxySettings(ProxySettings proxySettings) { + this.proxySettings = proxySettings; + } + + private void createPatterns(List list, + List excludePatterns2) { + Iterator iter = list.iterator(); + excludePatterns2.clear(); + while (iter.hasNext()) + try { + Pattern p = Pattern.compile(iter.next().toString()); + excludePatterns2.add(p); + } catch (PatternSyntaxException e) { + log.error(e); + } + } + + public static class ProxySettings { + String host; + int port; + + public String getHost() { + return this.host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return this.port; + } + + public void setPort(int port) { + this.port = port; + } + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HeaderValue.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HeaderValue.java similarity index 97% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/HeaderValue.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HeaderValue.java index 5432367c..3b57ad26 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HeaderValue.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HeaderValue.java @@ -1,78 +1,78 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -public class HeaderValue { - public static final String GENERAL_CACHE_CONTROL = "Cache-Control"; - public static final String GENERAL_CONNECTION = "Connection"; - public static final String GENERAL_DATE = "Date"; - public static final String GENERAL_PRAGMA = "Pragma"; - public static final String GENERAL_TRAILER = "Trailer"; - public static final String GENERAL_TRANSFER_ENC = "Transfer-Encoding"; - public static final String GENERAL_UPGRADE = "Upgrade"; - public static final String GENERAL_VIA = "Via"; - public static final String GENERAL_WARNING = "Warning"; - public static final String REQUEST_ACCEPT = "Accept"; - public static final String REQUEST_ACCEPT_CHARSET = "Accept-Charset"; - public static final String REQUEST_ACCEPT_ENCODING = "Accept-Encoding"; - public static final String REQUEST_ACCEPT_LANGUAGE = "Accept-Language"; - public static final String REQUEST_AUTHORIZATION = "Authorization"; - public static final String REQUEST_EXPECT = "Expect"; - public static final String REQUEST_FROM = "From"; - public static final String REQUEST_HOST = "Host"; - public static final String REQUEST_IF_MATCH = "If-Match"; - public static final String REQUEST_IF_MODIFIED_SINCE = "If-Modified-Since"; - public static final String REQUEST_IF_NONE_MATCH = "If-None-Match"; - public static final String REQUEST_IF_RANGE = "If-Range"; - public static final String REQUEST_IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; - public static final String REQUEST_MAX_FORWARDS = "Max-Forwards"; - public static final String REQUEST_PROXY_AUTHORIZATION = "Proxy-Authorization"; - public static final String REQUEST_RANGE = "Range"; - public static final String REQUEST_REFERER = "Referer"; - public static final String REQUEST_TE = "TE"; - public static final String REQUEST_USER_AGENT = "User-Agent"; - public static final String RESPONSE_AGE = "Age"; - public static final String RESPONSE_ETAG = "ETag"; - public static final String RESPONSE_LOCATION = "Location"; - public static final String RESPONSE_PROXY_AUTHENTICATE = "Proxy-Authenticate"; - public static final String RESPONSE_RETRY_AFTER = "Retry-After"; - public static final String RESPONSE_SERVER = "Server"; - public static final String RESPONSE_VARY = "Vary"; - public static final String RESPONSE_WWW_AUTHENTICATE = "WWW-Authenticate"; - public static final String ENTITY_ALLOW = "Allow"; - public static final String ENTITY_CONTENT_ENCODING = "Content-Encoding"; - public static final String ENTITY_CONTENT_LANGUAGE = "Content-Language"; - public static final String ENTITY_CONTENT_LENGHT = "Content-Length"; - public static final String ENTITY_CONTENT_LOCATION = "Content-Location"; - public static final String ENTITY_CONTENT_MD5 = "Content-MD5"; - public static final String ENTITY_CONTENT_RANGE = "Content-Range"; - public static final String ENTITY_CONTENT_TYPE = "Content-Type"; - public static final String ENTITY_EXPIRES = "Expires"; - public static final String ENTITY_LAST_MODIFIED = "Last-Modified"; - private String header; - private String value; - - public HeaderValue(String header, String value) - { - this.header = header; - this.value = value; - } - - public String getHeader() - { - return this.header; - } - - public void setHeader(String header) - { - this.header = header; - } - - public String getValue() - { - return this.value; - } - - public void setValue(String value) - { - this.value = value; - } -} +package org.bench4q.master.scriptrecord.httpcapture; + +public class HeaderValue { + public static final String GENERAL_CACHE_CONTROL = "Cache-Control"; + public static final String GENERAL_CONNECTION = "Connection"; + public static final String GENERAL_DATE = "Date"; + public static final String GENERAL_PRAGMA = "Pragma"; + public static final String GENERAL_TRAILER = "Trailer"; + public static final String GENERAL_TRANSFER_ENC = "Transfer-Encoding"; + public static final String GENERAL_UPGRADE = "Upgrade"; + public static final String GENERAL_VIA = "Via"; + public static final String GENERAL_WARNING = "Warning"; + public static final String REQUEST_ACCEPT = "Accept"; + public static final String REQUEST_ACCEPT_CHARSET = "Accept-Charset"; + public static final String REQUEST_ACCEPT_ENCODING = "Accept-Encoding"; + public static final String REQUEST_ACCEPT_LANGUAGE = "Accept-Language"; + public static final String REQUEST_AUTHORIZATION = "Authorization"; + public static final String REQUEST_EXPECT = "Expect"; + public static final String REQUEST_FROM = "From"; + public static final String REQUEST_HOST = "Host"; + public static final String REQUEST_IF_MATCH = "If-Match"; + public static final String REQUEST_IF_MODIFIED_SINCE = "If-Modified-Since"; + public static final String REQUEST_IF_NONE_MATCH = "If-None-Match"; + public static final String REQUEST_IF_RANGE = "If-Range"; + public static final String REQUEST_IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; + public static final String REQUEST_MAX_FORWARDS = "Max-Forwards"; + public static final String REQUEST_PROXY_AUTHORIZATION = "Proxy-Authorization"; + public static final String REQUEST_RANGE = "Range"; + public static final String REQUEST_REFERER = "Referer"; + public static final String REQUEST_TE = "TE"; + public static final String REQUEST_USER_AGENT = "User-Agent"; + public static final String RESPONSE_AGE = "Age"; + public static final String RESPONSE_ETAG = "ETag"; + public static final String RESPONSE_LOCATION = "Location"; + public static final String RESPONSE_PROXY_AUTHENTICATE = "Proxy-Authenticate"; + public static final String RESPONSE_RETRY_AFTER = "Retry-After"; + public static final String RESPONSE_SERVER = "Server"; + public static final String RESPONSE_VARY = "Vary"; + public static final String RESPONSE_WWW_AUTHENTICATE = "WWW-Authenticate"; + public static final String ENTITY_ALLOW = "Allow"; + public static final String ENTITY_CONTENT_ENCODING = "Content-Encoding"; + public static final String ENTITY_CONTENT_LANGUAGE = "Content-Language"; + public static final String ENTITY_CONTENT_LENGHT = "Content-Length"; + public static final String ENTITY_CONTENT_LOCATION = "Content-Location"; + public static final String ENTITY_CONTENT_MD5 = "Content-MD5"; + public static final String ENTITY_CONTENT_RANGE = "Content-Range"; + public static final String ENTITY_CONTENT_TYPE = "Content-Type"; + public static final String ENTITY_EXPIRES = "Expires"; + public static final String ENTITY_LAST_MODIFIED = "Last-Modified"; + private String header; + private String value; + + public HeaderValue(String header, String value) + { + this.header = header; + this.value = value; + } + + public String getHeader() + { + return this.header; + } + + public void setHeader(String header) + { + this.header = header; + } + + public String getValue() + { + return this.value; + } + + public void setValue(String value) + { + this.value = value; + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpCapture.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpCapture.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpCapture.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpCapture.java index 7fbec5b1..7dd48637 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpCapture.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpCapture.java @@ -1,128 +1,128 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -import java.io.File; -import java.io.IOException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import javax.swing.JTextArea; - -import org.apache.log4j.Logger; -import org.bench4q.share.models.agent.RunScenarioModel; - -public class HttpCapture { - private int localport; - private Config config; - private Test currentTest; - private ProxyServer proxy; - private File resultFile; - private ExecutorService executorService; - private String scriptContent; - private static Logger logger = Logger.getLogger(HttpCapture.class); - - public int getLocalport() { - return localport; - } - - public void setLocalport(int localport) { - this.localport = localport; - } - - public Config getConfig() { - return config; - } - - public void setConfig(Config config) { - this.config = config; - } - - public Test getCurrentTest() { - return currentTest; - } - - public void setCurrentTest(Test currentTest) { - this.currentTest = currentTest; - } - - public ProxyServer getProxy() { - return proxy; - } - - public void setProxy(ProxyServer proxy) { - this.proxy = proxy; - } - - public File getResultFile() { - return resultFile; - } - - public void setResultFile(File resultFile) { - this.resultFile = resultFile; - } - - public String getScriptContent() { - return scriptContent; - } - - private void setScriptContent(String scriptContent) { - this.scriptContent = scriptContent; - } - - public boolean isRecording() { - return this.getCurrentTest().isRecording(); - } - - public HttpCapture(String dirPath, String fileName, int localport, - String generator, JTextArea textArea) { - this.localport = localport; - System.out.println(dirPath + System.getProperty("file.separator") - + fileName + ".xml"); - - File file = new File(dirPath); - if (!file.exists()) { - file.mkdirs(); - } - - this.resultFile = new File(dirPath - + System.getProperty("file.separator") + fileName + ".xml"); - this.config = Config.getConfig(); - try { - this.config.completeInit(); - this.proxy = new ProxyServer(this.localport); - } catch (Exception e) { - e.printStackTrace(); - } - this.currentTest = new Test(this.proxy, new Bench4qTestScriptAdapter( - new RunScenarioModel()), generator); - } - - public void startProxyServer() throws IOException, Utils.UserException { - logger.info("enter startProxyServer!"); - this.executorService = Executors.newCachedThreadPool(); - this.executorService.execute(this.proxy); - } - - public void startRecording() throws IOException, Utils.UserException { - this.currentTest.startRecording(); - this.resultFile.createNewFile(); - this.currentTest.setTestFile(this.resultFile); - } - - public void stopRecording() throws IOException, Utils.UserException { - this.currentTest.stopRecording(); - this.currentTest.save(); - } - - public void shutProxyServer() throws IOException, Utils.UserException { - if (this.proxy.getServerSocket() != null) { - this.proxy.getServerSocket().close(); - } - this.executorService.shutdownNow(); - this.currentTest.close(); - this.retrieveScriptContent(); - } - - private void retrieveScriptContent() { - this.setScriptContent(this.currentTest.getScriptContent()); - } -} +package org.bench4q.master.scriptrecord.httpcapture; + +import java.io.File; +import java.io.IOException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.swing.JTextArea; + +import org.apache.log4j.Logger; +import org.bench4q.share.models.agent.RunScenarioModel; + +public class HttpCapture { + private int localport; + private Config config; + private Test currentTest; + private ProxyServer proxy; + private File resultFile; + private ExecutorService executorService; + private String scriptContent; + private static Logger logger = Logger.getLogger(HttpCapture.class); + + public int getLocalport() { + return localport; + } + + public void setLocalport(int localport) { + this.localport = localport; + } + + public Config getConfig() { + return config; + } + + public void setConfig(Config config) { + this.config = config; + } + + public Test getCurrentTest() { + return currentTest; + } + + public void setCurrentTest(Test currentTest) { + this.currentTest = currentTest; + } + + public ProxyServer getProxy() { + return proxy; + } + + public void setProxy(ProxyServer proxy) { + this.proxy = proxy; + } + + public File getResultFile() { + return resultFile; + } + + public void setResultFile(File resultFile) { + this.resultFile = resultFile; + } + + public String getScriptContent() { + return scriptContent; + } + + private void setScriptContent(String scriptContent) { + this.scriptContent = scriptContent; + } + + public boolean isRecording() { + return this.getCurrentTest().isRecording(); + } + + public HttpCapture(String dirPath, String fileName, int localport, + String generator, JTextArea textArea) { + this.localport = localport; + System.out.println(dirPath + System.getProperty("file.separator") + + fileName + ".xml"); + + File file = new File(dirPath); + if (!file.exists()) { + file.mkdirs(); + } + + this.resultFile = new File(dirPath + + System.getProperty("file.separator") + fileName + ".xml"); + this.config = Config.getConfig(); + try { + this.config.completeInit(); + this.proxy = new ProxyServer(this.localport); + } catch (Exception e) { + e.printStackTrace(); + } + this.currentTest = new Test(this.proxy, new Bench4qTestScriptAdapter( + new RunScenarioModel()), generator); + } + + public void startProxyServer() throws IOException, Utils.UserException { + logger.info("enter startProxyServer!"); + this.executorService = Executors.newCachedThreadPool(); + this.executorService.execute(this.proxy); + } + + public void startRecording() throws IOException, Utils.UserException { + this.currentTest.startRecording(); + this.resultFile.createNewFile(); + this.currentTest.setTestFile(this.resultFile); + } + + public void stopRecording() throws IOException, Utils.UserException { + this.currentTest.stopRecording(); + this.currentTest.save(); + } + + public void shutProxyServer() throws IOException, Utils.UserException { + if (this.proxy.getServerSocket() != null) { + this.proxy.getServerSocket().close(); + } + this.executorService.shutdownNow(); + this.currentTest.close(); + this.retrieveScriptContent(); + } + + private void retrieveScriptContent() { + this.setScriptContent(this.currentTest.getScriptContent()); + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpRequestHeader.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpRequestHeader.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpRequestHeader.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpRequestHeader.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpTestCase.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpTestCase.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpTestCase.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpTestCase.java index d620356a..dbd0bbdf 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpTestCase.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/HttpTestCase.java @@ -1,241 +1,241 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import javax.swing.JOptionPane; - -import org.apache.commons.httpclient.Header; -import org.apache.commons.httpclient.HostConfiguration; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.NameValuePair; -import org.apache.commons.httpclient.URIException; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.python.core.PyDictionary; -import org.python.core.PyString; -import org.python.core.PyTuple; - -public class HttpTestCase { - private Config config = Config.getConfig(); - protected HttpMethod method = null; - protected HttpClient client = new HttpClient(); - protected String data; - private boolean followRedirects = false; - private String charset; - - public void setCharset(String cs) { - this.charset = cs; - } - - public HttpTestCase(String name) { - Config.ProxySettings proxy = this.config.getProxySettings(); - if (proxy != null) { - HostConfiguration hc = this.client.getHostConfiguration(); - hc.setProxy(proxy.host, proxy.port); - } - } - - public void Run() throws Throwable { - } - - public HttpMethod getMethod() { - return this.method; - } - - private void cleanupMethod() { - if (this.method != null) { - this.method.releaseConnection(); - this.method = null; - } - } - - public void get(String url) throws IOException { - get(url, null); - } - - public void get(String url, Object[] args) throws IOException { - cleanupMethod(); - - this.method = new GetMethod(url); - - if (args != null) { - this.method.setQueryString(paramsToNV(args)); - } - - this.method.setFollowRedirects(this.followRedirects); - this.client.executeMethod(this.method); - } - - public void post(String url) throws IOException { - post(url, null); - } - - public void post(String url, Object[] args) throws IOException { - cleanupMethod(); - PostMethod post = new PostMethod(url); - - if (this.charset != null) { - post.setRequestHeader("Content-Type", - "application/x-www-form-urlencoded; charset=" - + this.charset); - } - - if (args != null) { - post.setRequestBody(paramsToNV(args)); - } - - this.method = post; - this.method.setFollowRedirects(this.followRedirects); - this.client.executeMethod(this.method); - } - - public void postMultiPart(String url, String data, int contLen) - throws IOException { - postMultiPart(url, data, contLen, null); - } - - public void postMultiPart(String url, String data, int contLen, - Object[] args) throws IOException { - cleanupMethod(); - - PostMethod multipartPostMethod = new PostMethod(url); - - multipartPostMethod.addParameter("data", data); - if (args != null) { - multipartPostMethod.setQueryString(paramsToNV(args)); - } - - this.method = multipartPostMethod; - this.method.setFollowRedirects(this.followRedirects); - this.client.executeMethod(this.method); - } - - public NameValuePair[] paramsToNV(Object[] params) { - NameValuePair[] res = new NameValuePair[params.length]; - for (int i = 0; i < params.length; ++i) { - Object param = params[i]; - if (param instanceof PyTuple) { - PyTuple pyParam = (PyTuple) param; - res[i] = new NameValuePair(pyParam.__getitem__(0).toString(), - pyParam.__getitem__(1).toString()); - } else if (param instanceof NameValuePair) { - res[i] = ((NameValuePair) param); - } - } - return res; - } - - public String urlDecode(String s) { - return staticUrlDecode(s); - } - - public static String staticUrlDecode(String s) { - String sUrl = ""; - ByteArrayOutputStream out = new ByteArrayOutputStream(s.length()); - for (int count = 0; count < s.length(); ++count) - if (s.charAt(count) == '%') { - ++count; - if (count < s.length()) { - int a = Character.digit(s.charAt(count++), 16); - a <<= 4; - int b = Character.digit(s.charAt(count), 16); - - if ((a + b == 39) || (a + b == 132)) - out.write(92); - out.write(a + b); - } else { - out.write(37); - } - } else if (s.charAt(count) == '+') { - out.write(32); - } else { - sUrl += s.charAt(count); - out.write(s.charAt(count)); - } - System.out.println(sUrl); - return out.toString(); - } - - protected void responseOK() throws URIException { - } - - protected boolean responseContainsURI(String uri) throws URIException { - return ((this.method != null) && (this.method.getURI().getPath() - .indexOf(uri) != -1)); - } - - protected boolean responseContains(String text) { - try { - if ((this.method == null) - || (this.method.getResponseBody() == null)) - return false; - - this.data = this.method.getResponseBodyAsString(); - } catch (IOException e) { - e.printStackTrace(); - } - - return (this.data.indexOf(text) != -1); - } - - protected void printResponse() { - try { - System.err.println(new String(this.method.getResponseBody())); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public String getResponse() throws IOException { - return this.method.getResponseBodyAsString(); - } - - public byte[] getResponseAsBytes() throws IOException { - return this.method.getResponseBody(); - } - - public int getResponseCode() { - return getMethod().getStatusCode(); - } - - public PyDictionary getResponseHeader() { - PyDictionary dict = new PyDictionary(); - Header[] headers = this.method.getResponseHeaders(); - - for (int i = 0; i < headers.length; ++i) - dict.__setitem__(new PyString(headers[i].getName()), new PyString( - headers[i].getValue())); - return dict; - } - - public String getScriptArg() { - return this.config.getScriptArg(); - } - - public boolean userConfirm(String msg) { - int rc = JOptionPane.showConfirmDialog(null, msg, "HttpCapture", 2); - return (rc == 0); - } - - public String userInput(String msg) { - return JOptionPane.showInputDialog(null, msg, "HttpCapture", 3); - } - - public String getStrutsToken() throws IOException { - String responseString = new String( - this.method.getResponseBodyAsString()); - - String strutsToken = null; - - int tokenIDIndex = responseString.toLowerCase().indexOf( - "org.apache.struts.taglib.html.TOKEN".toLowerCase()); - int nextValue = responseString.toLowerCase().indexOf( - "value=\"".toLowerCase(), tokenIDIndex); - - strutsToken = responseString.substring(nextValue + "value=\"".length(), - nextValue + "value=\"".length() + 32); - return strutsToken; - } -} +package org.bench4q.master.scriptrecord.httpcapture; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import javax.swing.JOptionPane; + +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HostConfiguration; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.NameValuePair; +import org.apache.commons.httpclient.URIException; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; +import org.python.core.PyDictionary; +import org.python.core.PyString; +import org.python.core.PyTuple; + +public class HttpTestCase { + private Config config = Config.getConfig(); + protected HttpMethod method = null; + protected HttpClient client = new HttpClient(); + protected String data; + private boolean followRedirects = false; + private String charset; + + public void setCharset(String cs) { + this.charset = cs; + } + + public HttpTestCase(String name) { + Config.ProxySettings proxy = this.config.getProxySettings(); + if (proxy != null) { + HostConfiguration hc = this.client.getHostConfiguration(); + hc.setProxy(proxy.host, proxy.port); + } + } + + public void Run() throws Throwable { + } + + public HttpMethod getMethod() { + return this.method; + } + + private void cleanupMethod() { + if (this.method != null) { + this.method.releaseConnection(); + this.method = null; + } + } + + public void get(String url) throws IOException { + get(url, null); + } + + public void get(String url, Object[] args) throws IOException { + cleanupMethod(); + + this.method = new GetMethod(url); + + if (args != null) { + this.method.setQueryString(paramsToNV(args)); + } + + this.method.setFollowRedirects(this.followRedirects); + this.client.executeMethod(this.method); + } + + public void post(String url) throws IOException { + post(url, null); + } + + public void post(String url, Object[] args) throws IOException { + cleanupMethod(); + PostMethod post = new PostMethod(url); + + if (this.charset != null) { + post.setRequestHeader("Content-Type", + "application/x-www-form-urlencoded; charset=" + + this.charset); + } + + if (args != null) { + post.setRequestBody(paramsToNV(args)); + } + + this.method = post; + this.method.setFollowRedirects(this.followRedirects); + this.client.executeMethod(this.method); + } + + public void postMultiPart(String url, String data, int contLen) + throws IOException { + postMultiPart(url, data, contLen, null); + } + + public void postMultiPart(String url, String data, int contLen, + Object[] args) throws IOException { + cleanupMethod(); + + PostMethod multipartPostMethod = new PostMethod(url); + + multipartPostMethod.addParameter("data", data); + if (args != null) { + multipartPostMethod.setQueryString(paramsToNV(args)); + } + + this.method = multipartPostMethod; + this.method.setFollowRedirects(this.followRedirects); + this.client.executeMethod(this.method); + } + + public NameValuePair[] paramsToNV(Object[] params) { + NameValuePair[] res = new NameValuePair[params.length]; + for (int i = 0; i < params.length; ++i) { + Object param = params[i]; + if (param instanceof PyTuple) { + PyTuple pyParam = (PyTuple) param; + res[i] = new NameValuePair(pyParam.__getitem__(0).toString(), + pyParam.__getitem__(1).toString()); + } else if (param instanceof NameValuePair) { + res[i] = ((NameValuePair) param); + } + } + return res; + } + + public String urlDecode(String s) { + return staticUrlDecode(s); + } + + public static String staticUrlDecode(String s) { + String sUrl = ""; + ByteArrayOutputStream out = new ByteArrayOutputStream(s.length()); + for (int count = 0; count < s.length(); ++count) + if (s.charAt(count) == '%') { + ++count; + if (count < s.length()) { + int a = Character.digit(s.charAt(count++), 16); + a <<= 4; + int b = Character.digit(s.charAt(count), 16); + + if ((a + b == 39) || (a + b == 132)) + out.write(92); + out.write(a + b); + } else { + out.write(37); + } + } else if (s.charAt(count) == '+') { + out.write(32); + } else { + sUrl += s.charAt(count); + out.write(s.charAt(count)); + } + System.out.println(sUrl); + return out.toString(); + } + + protected void responseOK() throws URIException { + } + + protected boolean responseContainsURI(String uri) throws URIException { + return ((this.method != null) && (this.method.getURI().getPath() + .indexOf(uri) != -1)); + } + + protected boolean responseContains(String text) { + try { + if ((this.method == null) + || (this.method.getResponseBody() == null)) + return false; + + this.data = this.method.getResponseBodyAsString(); + } catch (IOException e) { + e.printStackTrace(); + } + + return (this.data.indexOf(text) != -1); + } + + protected void printResponse() { + try { + System.err.println(new String(this.method.getResponseBody())); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public String getResponse() throws IOException { + return this.method.getResponseBodyAsString(); + } + + public byte[] getResponseAsBytes() throws IOException { + return this.method.getResponseBody(); + } + + public int getResponseCode() { + return getMethod().getStatusCode(); + } + + public PyDictionary getResponseHeader() { + PyDictionary dict = new PyDictionary(); + Header[] headers = this.method.getResponseHeaders(); + + for (int i = 0; i < headers.length; ++i) + dict.__setitem__(new PyString(headers[i].getName()), new PyString( + headers[i].getValue())); + return dict; + } + + public String getScriptArg() { + return this.config.getScriptArg(); + } + + public boolean userConfirm(String msg) { + int rc = JOptionPane.showConfirmDialog(null, msg, "HttpCapture", 2); + return (rc == 0); + } + + public String userInput(String msg) { + return JOptionPane.showInputDialog(null, msg, "HttpCapture", 3); + } + + public String getStrutsToken() throws IOException { + String responseString = new String( + this.method.getResponseBodyAsString()); + + String strutsToken = null; + + int tokenIDIndex = responseString.toLowerCase().indexOf( + "org.apache.struts.taglib.html.TOKEN".toLowerCase()); + int nextValue = responseString.toLowerCase().indexOf( + "value=\"".toLowerCase(), tokenIDIndex); + + strutsToken = responseString.substring(nextValue + "value=\"".length(), + nextValue + "value=\"".length() + 32); + return strutsToken; + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/IScriptAdapter.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/IScriptAdapter.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/IScriptAdapter.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/IScriptAdapter.java index a2d865b3..f82d21df 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/IScriptAdapter.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/IScriptAdapter.java @@ -1,33 +1,33 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -import java.util.List; - -import org.bench4q.master.scriptrecord.httpcapture.generator.ChildrenUrl; -import org.bench4q.share.models.agent.RunScenarioModel; -import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; -import org.bench4q.share.models.agent.scriptrecord.UsePluginModel; - -public interface IScriptAdapter { - - public abstract RunScenarioModel getRunScenarioModel(); - - public abstract void addPage(); - - public abstract void appendUsePluginsToScenario( - List usePluginModels); - - public abstract void insertUserBehaviorsToScenario(BehaviorModel model); - - public abstract String getText(); - - public abstract void setText(String paramString); - - // TODO:move this function to more fit place - public abstract List getChildrenUrls(); - - public abstract int getParentBatchIdWithParentUrl(String url); - - public abstract boolean isInChildrenUrl(String url); - - public abstract void resetChildrenUrls(); -} +package org.bench4q.master.scriptrecord.httpcapture; + +import java.util.List; + +import org.bench4q.master.scriptrecord.httpcapture.generator.ChildrenUrl; +import org.bench4q.share.models.agent.RunScenarioModel; +import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; +import org.bench4q.share.models.agent.scriptrecord.UsePluginModel; + +public interface IScriptAdapter { + + public abstract RunScenarioModel getRunScenarioModel(); + + public abstract void addPage(); + + public abstract void appendUsePluginsToScenario( + List usePluginModels); + + public abstract void insertUserBehaviorsToScenario(BehaviorModel model); + + public abstract String getText(); + + public abstract void setText(String paramString); + + // TODO:move this function to more fit place + public abstract List getChildrenUrls(); + + public abstract int getParentBatchIdWithParentUrl(String url); + + public abstract boolean isInChildrenUrl(String url); + + public abstract void resetChildrenUrls(); +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Param.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Param.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/Param.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Param.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/ProxyServer.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/ProxyServer.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/ProxyServer.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/ProxyServer.java index f67de511..bac0e378 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/ProxyServer.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/ProxyServer.java @@ -1,87 +1,87 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -import java.io.IOException; -import java.net.ServerSocket; -import java.util.Enumeration; -import java.util.Vector; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class ProxyServer implements Runnable { - private Vector listeners; - private ServerSocket srvSock; - private int count; - private static final Log log = LogFactory.getLog(ProxyServer.class); - - public ProxyServer() throws IOException { - this(0); - } - - public ProxyServer(int port) throws IOException { - this.srvSock = new ServerSocket(port); - this.listeners = new Vector(); - } - - public void addObserver(Observer proxy) { - this.listeners.addElement(proxy); - } - - public void removeObserver(Observer proxy) { - this.listeners.removeElement(proxy); - } - - public void processRequest(HttpRequestHeader header, byte[] requestBody) - throws Exception { - for (Enumeration e = this.listeners.elements(); e - .hasMoreElements();) { - Observer pl = (Observer) e.nextElement(); - pl.processRequest(header, requestBody); - } - } - - public void processResponse(HttpRequestHeader header, byte[] requestBody, - byte[] response) throws Exception { - for (Enumeration e = this.listeners.elements(); e - .hasMoreElements();) { - Observer pl = (Observer) e.nextElement(); - pl.processResponse(header, requestBody, response); - } - } - - public void run() { - if (this.getServerSocket().isClosed()) { - return; - } - try { - while (true) { - RequestHandler handler = new RequestHandler(this, this - .getServerSocket().accept()); - log.trace("New connection. Creating new RequestHandler thread."); - Thread t = new Thread(handler, "Bench4QRequestHandler #" - + this.getLocalPort() + "#" + this.count); - t.start(); - this.count += 1; - } - } catch (Exception e) { - return; - } - } - - int getLocalPort() { - return this.srvSock.getLocalPort(); - } - - public ServerSocket getServerSocket() { - return this.srvSock; - } - - public static abstract interface Observer { - public abstract void processRequest( - HttpRequestHeader paramHttpRequestHeader, - byte[] paramArrayOfByte) throws Exception; - - public abstract void processResponse( - HttpRequestHeader paramHttpRequestHeader, byte[] requestBody, - byte[] paramArrayOfByte) throws Exception; - } -} +package org.bench4q.master.scriptrecord.httpcapture; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.Enumeration; +import java.util.Vector; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class ProxyServer implements Runnable { + private Vector listeners; + private ServerSocket srvSock; + private int count; + private static final Log log = LogFactory.getLog(ProxyServer.class); + + public ProxyServer() throws IOException { + this(0); + } + + public ProxyServer(int port) throws IOException { + this.srvSock = new ServerSocket(port); + this.listeners = new Vector(); + } + + public void addObserver(Observer proxy) { + this.listeners.addElement(proxy); + } + + public void removeObserver(Observer proxy) { + this.listeners.removeElement(proxy); + } + + public void processRequest(HttpRequestHeader header, byte[] requestBody) + throws Exception { + for (Enumeration e = this.listeners.elements(); e + .hasMoreElements();) { + Observer pl = (Observer) e.nextElement(); + pl.processRequest(header, requestBody); + } + } + + public void processResponse(HttpRequestHeader header, byte[] requestBody, + byte[] response) throws Exception { + for (Enumeration e = this.listeners.elements(); e + .hasMoreElements();) { + Observer pl = (Observer) e.nextElement(); + pl.processResponse(header, requestBody, response); + } + } + + public void run() { + if (this.getServerSocket().isClosed()) { + return; + } + try { + while (true) { + RequestHandler handler = new RequestHandler(this, this + .getServerSocket().accept()); + log.trace("New connection. Creating new RequestHandler thread."); + Thread t = new Thread(handler, "Bench4QRequestHandler #" + + this.getLocalPort() + "#" + this.count); + t.start(); + this.count += 1; + } + } catch (Exception e) { + return; + } + } + + int getLocalPort() { + return this.srvSock.getLocalPort(); + } + + public ServerSocket getServerSocket() { + return this.srvSock; + } + + public static abstract interface Observer { + public abstract void processRequest( + HttpRequestHeader paramHttpRequestHeader, + byte[] paramArrayOfByte) throws Exception; + + public abstract void processResponse( + HttpRequestHeader paramHttpRequestHeader, byte[] requestBody, + byte[] paramArrayOfByte) throws Exception; + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/RequestHandler.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/RequestHandler.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/RequestHandler.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/RequestHandler.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Test.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Test.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/Test.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Test.java index faf628bc..e0e35af6 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Test.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Test.java @@ -1,112 +1,112 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; - -import org.bench4q.master.scriptrecord.httpcapture.generator.GeneratorFactory; -import org.bench4q.master.scriptrecord.httpcapture.generator.IScriptGenerator; - -public class Test { - private IScriptGenerator generator; - private IScriptAdapter scriptAdapter; - private boolean isRecording; - private File testFile; - ProxyServer proxyServer; - - public Test(ProxyServer proxy, IScriptAdapter adapter, String generatorClass) { - this.proxyServer = proxy; - adapter.setText(""); - this.generator = GeneratorFactory.newGenerator(generatorClass, adapter); - this.generator.doNew(); - this.scriptAdapter = adapter; - } - - public Test(ProxyServer proxy, IScriptAdapter adapter, File file) - throws IOException, Utils.UserException { - this.proxyServer = proxy; - this.testFile = file; - - StringBuffer buffer = new StringBuffer(); - BufferedReader r = new BufferedReader(new FileReader(this.testFile)); - String line = r.readLine(); - while (line != null) { - buffer.append(line); - buffer.append(IScriptGenerator.EOL); - line = r.readLine(); - } - r.close(); - String script = buffer.toString(); - - String generatorClass = null; - String[] classes = GeneratorFactory.getClasses(); - - for (int i = 0; i < classes.length; i++) { - if (script.indexOf(classes[i]) != -1) { - generatorClass = classes[i]; - break; - } - } - if (generatorClass == null) { - throw new Utils.UserException( - "Your file does not appear to have been generated by MaxQ.\n\n(MaxQ expects to find the class name of the generator somewhere in the script.\nPerhaps you have mistakenly deleted it?)"); - } - - adapter.setText(script); - this.generator = GeneratorFactory.newGenerator(generatorClass, adapter); - this.generator.doLoad(); - this.generator.parseTestName(); - } - - public File getTestFile() { - return this.testFile; - } - - public void setTestFile(File file) { - this.testFile = file; - } - - public boolean isRecording() { - return this.isRecording; - } - - public void stopRecording() { - this.proxyServer.removeObserver(this.generator); - assert (this.isRecording); - this.generator.doStopRecording(); - this.isRecording = false; - } - - public void startRecording() { - assert (!this.isRecording); - this.proxyServer.addObserver(this.generator); - this.isRecording = true; - this.generator.doStartRecording(); - } - - public boolean save() throws IOException { - return this.generator.doSave( - stripFileName(this.testFile.getAbsolutePath()), - this.testFile.getName()); - } - - private String stripFileName(String absolutePath) { - int index = absolutePath.lastIndexOf(System - .getProperty("file.separator")); - if (index == -1) { - return absolutePath; - } - return absolutePath.substring(0, index); - } - - public void close() { - if (this.isRecording) - this.proxyServer.removeObserver(this.generator); - this.generator.close(); - } - - public String getScriptContent() { - return this.scriptAdapter.getText(); - } -} +package org.bench4q.master.scriptrecord.httpcapture; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import org.bench4q.master.scriptrecord.httpcapture.generator.GeneratorFactory; +import org.bench4q.master.scriptrecord.httpcapture.generator.IScriptGenerator; + +public class Test { + private IScriptGenerator generator; + private IScriptAdapter scriptAdapter; + private boolean isRecording; + private File testFile; + ProxyServer proxyServer; + + public Test(ProxyServer proxy, IScriptAdapter adapter, String generatorClass) { + this.proxyServer = proxy; + adapter.setText(""); + this.generator = GeneratorFactory.newGenerator(generatorClass, adapter); + this.generator.doNew(); + this.scriptAdapter = adapter; + } + + public Test(ProxyServer proxy, IScriptAdapter adapter, File file) + throws IOException, Utils.UserException { + this.proxyServer = proxy; + this.testFile = file; + + StringBuffer buffer = new StringBuffer(); + BufferedReader r = new BufferedReader(new FileReader(this.testFile)); + String line = r.readLine(); + while (line != null) { + buffer.append(line); + buffer.append(IScriptGenerator.EOL); + line = r.readLine(); + } + r.close(); + String script = buffer.toString(); + + String generatorClass = null; + String[] classes = GeneratorFactory.getClasses(); + + for (int i = 0; i < classes.length; i++) { + if (script.indexOf(classes[i]) != -1) { + generatorClass = classes[i]; + break; + } + } + if (generatorClass == null) { + throw new Utils.UserException( + "Your file does not appear to have been generated by MaxQ.\n\n(MaxQ expects to find the class name of the generator somewhere in the script.\nPerhaps you have mistakenly deleted it?)"); + } + + adapter.setText(script); + this.generator = GeneratorFactory.newGenerator(generatorClass, adapter); + this.generator.doLoad(); + this.generator.parseTestName(); + } + + public File getTestFile() { + return this.testFile; + } + + public void setTestFile(File file) { + this.testFile = file; + } + + public boolean isRecording() { + return this.isRecording; + } + + public void stopRecording() { + this.proxyServer.removeObserver(this.generator); + assert (this.isRecording); + this.generator.doStopRecording(); + this.isRecording = false; + } + + public void startRecording() { + assert (!this.isRecording); + this.proxyServer.addObserver(this.generator); + this.isRecording = true; + this.generator.doStartRecording(); + } + + public boolean save() throws IOException { + return this.generator.doSave( + stripFileName(this.testFile.getAbsolutePath()), + this.testFile.getName()); + } + + private String stripFileName(String absolutePath) { + int index = absolutePath.lastIndexOf(System + .getProperty("file.separator")); + if (index == -1) { + return absolutePath; + } + return absolutePath.substring(0, index); + } + + public void close() { + if (this.isRecording) + this.proxyServer.removeObserver(this.generator); + this.generator.close(); + } + + public String getScriptContent() { + return this.scriptAdapter.getText(); + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Utils.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Utils.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/Utils.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Utils.java index a030f2a4..63e197c7 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Utils.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/Utils.java @@ -1,115 +1,115 @@ -package org.bench4q.master.scriptrecord.httpcapture; - -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; -import org.bench4q.master.scriptrecord.httpcapture.Param; - -public class Utils { - public static final String SPACE = " "; - private static final Logger log = Logger.getLogger(Utils.class); - - public static File saveHTML(String htmlFileName, String str, String dir_str) { - if (str == null) { - log.error("Argument is null: EditorPane.saveHTML()"); - return null; - } - File dir, htmlFile; - if (dir_str == null) { - dir = new File("Tempfiles"); - } else { - dir = new File(dir_str); - } - dir.mkdir(); - try { - htmlFile = new File(dir, htmlFileName); - if (htmlFile.exists()) { - htmlFile.delete(); - log.warn("deleting duplicated file: " + htmlFileName); - } - htmlFile.createNewFile(); - PrintWriter writer = new PrintWriter(new FileWriter(htmlFile)); - writer.print(str); - writer.close(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - - return htmlFile; - } - - public static String[] splitString(String str, String delim) { - StringTokenizer st = new StringTokenizer(str, delim); - String[] res = new String[st.countTokens()]; - int i = 0; - while (st.hasMoreTokens()) { - res[i] = st.nextToken(); - i++; - } - return res; - } - - public static String replace(String str, String search, String replace) { - int pos = str.indexOf(search); - if (pos == -1) - return str; - StringBuffer buff = new StringBuffer(str.length() + 32); - int start = 0; - while ((pos != -1) && (start < str.length())) { - buff.append(str.substring(start, pos)); - buff.append(replace); - - start = pos + search.length(); - if (start < str.length()) - pos = str.indexOf(search, start); - } - if (start < str.length()) - buff.append(str.substring(start)); - - return buff.toString(); - } - - public static List getParams(String query) { - List paramList = new ArrayList(); - if (query != null) { - query = query.trim(); - log.debug(" parsing: " + query); - String[] items = splitString(query, "&"); - for (int i = 0; i < items.length; i++) { - int pos = items[i].indexOf("="); - if (pos != -1) { - Param p = new Param(); - paramList.add(p); - p.name = items[i].substring(0, pos); - if (pos < items[i].length() - 1) - p.value = items[i].substring(pos + 1); - else - p.value = ""; - } - } - } - return paramList; - } - - public static class SilentException extends Exception { - private static final long serialVersionUID = 3172942039967787899L; - - public SilentException() { - super(); - } - } - - public static class UserException extends Exception { - private static final long serialVersionUID = -7337004995296463936L; - - public UserException(String s) { - super(); - } - } -} +package org.bench4q.master.scriptrecord.httpcapture; + +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.log4j.Logger; +import org.bench4q.master.scriptrecord.httpcapture.Param; + +public class Utils { + public static final String SPACE = " "; + private static final Logger log = Logger.getLogger(Utils.class); + + public static File saveHTML(String htmlFileName, String str, String dir_str) { + if (str == null) { + log.error("Argument is null: EditorPane.saveHTML()"); + return null; + } + File dir, htmlFile; + if (dir_str == null) { + dir = new File("Tempfiles"); + } else { + dir = new File(dir_str); + } + dir.mkdir(); + try { + htmlFile = new File(dir, htmlFileName); + if (htmlFile.exists()) { + htmlFile.delete(); + log.warn("deleting duplicated file: " + htmlFileName); + } + htmlFile.createNewFile(); + PrintWriter writer = new PrintWriter(new FileWriter(htmlFile)); + writer.print(str); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + + return htmlFile; + } + + public static String[] splitString(String str, String delim) { + StringTokenizer st = new StringTokenizer(str, delim); + String[] res = new String[st.countTokens()]; + int i = 0; + while (st.hasMoreTokens()) { + res[i] = st.nextToken(); + i++; + } + return res; + } + + public static String replace(String str, String search, String replace) { + int pos = str.indexOf(search); + if (pos == -1) + return str; + StringBuffer buff = new StringBuffer(str.length() + 32); + int start = 0; + while ((pos != -1) && (start < str.length())) { + buff.append(str.substring(start, pos)); + buff.append(replace); + + start = pos + search.length(); + if (start < str.length()) + pos = str.indexOf(search, start); + } + if (start < str.length()) + buff.append(str.substring(start)); + + return buff.toString(); + } + + public static List getParams(String query) { + List paramList = new ArrayList(); + if (query != null) { + query = query.trim(); + log.debug(" parsing: " + query); + String[] items = splitString(query, "&"); + for (int i = 0; i < items.length; i++) { + int pos = items[i].indexOf("="); + if (pos != -1) { + Param p = new Param(); + paramList.add(p); + p.name = items[i].substring(0, pos); + if (pos < items[i].length() - 1) + p.value = items[i].substring(pos + 1); + else + p.value = ""; + } + } + } + return paramList; + } + + public static class SilentException extends Exception { + private static final long serialVersionUID = 3172942039967787899L; + + public SilentException() { + super(); + } + } + + public static class UserException extends Exception { + private static final long serialVersionUID = -7337004995296463936L; + + public UserException(String s) { + super(); + } + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/AbstractCodeGenerator.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/AbstractCodeGenerator.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/AbstractCodeGenerator.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/AbstractCodeGenerator.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/Bench4qCodeGenerator.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/Bench4qCodeGenerator.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/Bench4qCodeGenerator.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/Bench4qCodeGenerator.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ChildrenUrl.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ChildrenUrl.java similarity index 95% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ChildrenUrl.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ChildrenUrl.java index bfa18b19..8a2def60 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ChildrenUrl.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ChildrenUrl.java @@ -1,29 +1,29 @@ -package org.bench4q.master.scriptrecord.httpcapture.generator; - -public class ChildrenUrl { - private String url; - private int parentBatchId; - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public int getParentBatchId() { - return parentBatchId; - } - - public void setParentBatchId(int parentBatchId) { - this.parentBatchId = parentBatchId; - } - - public static ChildrenUrl createChilldUrl(String url, int parentBatchId) { - ChildrenUrl ret = new ChildrenUrl(); - ret.setParentBatchId(parentBatchId); - ret.setUrl(url); - return ret; - } -} +package org.bench4q.master.scriptrecord.httpcapture.generator; + +public class ChildrenUrl { + private String url; + private int parentBatchId; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public int getParentBatchId() { + return parentBatchId; + } + + public void setParentBatchId(int parentBatchId) { + this.parentBatchId = parentBatchId; + } + + public static ChildrenUrl createChilldUrl(String url, int parentBatchId) { + ChildrenUrl ret = new ChildrenUrl(); + ret.setParentBatchId(parentBatchId); + ret.setUrl(url); + return ret; + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ContentDecoder.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ContentDecoder.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ContentDecoder.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ContentDecoder.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GeneratorFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GeneratorFactory.java similarity index 97% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GeneratorFactory.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GeneratorFactory.java index f7262fc0..83da2182 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GeneratorFactory.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GeneratorFactory.java @@ -1,69 +1,69 @@ -package org.bench4q.master.scriptrecord.httpcapture.generator; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.bench4q.master.scriptrecord.httpcapture.Config; -import org.bench4q.master.scriptrecord.httpcapture.IScriptAdapter; -import org.bench4q.master.scriptrecord.httpcapture.Utils; - -public class GeneratorFactory { - private static Config config = Config.getConfig(); - public static final String GENERATOR_CLASSNAMES_PROPERTY = "generator.classnames"; - public static final String JYTHON_CLASSNAME = "com.bitmechanic.maxq.generator.JythonCodeGenerator"; - - public static String[] getClasses() - { - String names = config.getProperty("generator.classnames", - "com.bitmechanic.maxq.generator.JythonCodeGenerator"); - return Utils.splitString(names, ":"); - } - - public static String getClassDescription(String className) - throws ClassNotFoundException, IllegalAccessException, InvocationTargetException - { - Method getGenDesc; - Class gen = Class.forName(className); - try - { - getGenDesc = gen.getMethod("getGeneratorDescription", gen); - } - catch (NoSuchMethodException e) - { - return className; - } - - return (String)getGenDesc.invoke((Object)null, (Object)null); - } - - public static IScriptGenerator newGenerator(String className, IScriptAdapter adapter) - { - Class clazz = null; - try { - clazz = GeneratorFactory.class.getClassLoader().loadClass(className); - } catch (ClassNotFoundException e) { - throw new IllegalStateException("Invalid test script class specified . Class not found:" + className); - } - - if (IScriptGenerator.class.isAssignableFrom(clazz)) { - try { - Class[] generatorConstructorParameterClasses = { IScriptAdapter.class }; - Object[] generatorConstructorParameters = { adapter }; - Constructor constructor = clazz.getDeclaredConstructor(generatorConstructorParameterClasses); - return (IScriptGenerator)constructor.newInstance(generatorConstructorParameters); - } - catch (NoSuchMethodException e) { - throw new IllegalStateException("Invalid test script class specified. Must have a constructor that takes in properties: " + className); - } catch (InstantiationException e) { - throw new IllegalStateException("Invalid test script class specified. Could not construct: " + className); - } catch (InvocationTargetException e) { - e.printStackTrace(); - throw new IllegalStateException("Invalid test script class specified. Exception thrown in constructor: " + className); - } catch (IllegalAccessException e) { - throw new IllegalStateException("Invalid test script class specified. IllegalAccessException: " + className); - } - } - throw new IllegalStateException("Invalid test script class specified. Does not implement IScriptGenerator: " + className); - } -} +package org.bench4q.master.scriptrecord.httpcapture.generator; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.bench4q.master.scriptrecord.httpcapture.Config; +import org.bench4q.master.scriptrecord.httpcapture.IScriptAdapter; +import org.bench4q.master.scriptrecord.httpcapture.Utils; + +public class GeneratorFactory { + private static Config config = Config.getConfig(); + public static final String GENERATOR_CLASSNAMES_PROPERTY = "generator.classnames"; + public static final String JYTHON_CLASSNAME = "com.bitmechanic.maxq.generator.JythonCodeGenerator"; + + public static String[] getClasses() + { + String names = config.getProperty("generator.classnames", + "com.bitmechanic.maxq.generator.JythonCodeGenerator"); + return Utils.splitString(names, ":"); + } + + public static String getClassDescription(String className) + throws ClassNotFoundException, IllegalAccessException, InvocationTargetException + { + Method getGenDesc; + Class gen = Class.forName(className); + try + { + getGenDesc = gen.getMethod("getGeneratorDescription", gen); + } + catch (NoSuchMethodException e) + { + return className; + } + + return (String)getGenDesc.invoke((Object)null, (Object)null); + } + + public static IScriptGenerator newGenerator(String className, IScriptAdapter adapter) + { + Class clazz = null; + try { + clazz = GeneratorFactory.class.getClassLoader().loadClass(className); + } catch (ClassNotFoundException e) { + throw new IllegalStateException("Invalid test script class specified . Class not found:" + className); + } + + if (IScriptGenerator.class.isAssignableFrom(clazz)) { + try { + Class[] generatorConstructorParameterClasses = { IScriptAdapter.class }; + Object[] generatorConstructorParameters = { adapter }; + Constructor constructor = clazz.getDeclaredConstructor(generatorConstructorParameterClasses); + return (IScriptGenerator)constructor.newInstance(generatorConstructorParameters); + } + catch (NoSuchMethodException e) { + throw new IllegalStateException("Invalid test script class specified. Must have a constructor that takes in properties: " + className); + } catch (InstantiationException e) { + throw new IllegalStateException("Invalid test script class specified. Could not construct: " + className); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("Invalid test script class specified. Exception thrown in constructor: " + className); + } catch (IllegalAccessException e) { + throw new IllegalStateException("Invalid test script class specified. IllegalAccessException: " + className); + } + } + throw new IllegalStateException("Invalid test script class specified. Does not implement IScriptGenerator: " + className); + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GzipDecoder.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GzipDecoder.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GzipDecoder.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GzipDecoder.java index 7f2695c8..9c4478f4 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GzipDecoder.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/GzipDecoder.java @@ -1,28 +1,28 @@ -package org.bench4q.master.scriptrecord.httpcapture.generator; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.GZIPInputStream; - -import org.bench4q.master.exception.ExceptionLog; - -public class GzipDecoder extends ContentDecoder { - - public byte[] decodeContent(InputStream inputStream) { - try { - GZIPInputStream gzipInputStream = new GZIPInputStream(inputStream); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - - byte[] buf = new byte[1024]; - int len; - while ((len = gzipInputStream.read(buf)) > 0) { - outputStream.write(buf, 0, len); - } - return outputStream.toByteArray(); - } catch (IOException e) { - logger.error(ExceptionLog.getStackTrace(e)); - return null; - } - } -} +package org.bench4q.master.scriptrecord.httpcapture.generator; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPInputStream; + +import org.bench4q.master.exception.ExceptionLog; + +public class GzipDecoder extends ContentDecoder { + + public byte[] decodeContent(InputStream inputStream) { + try { + GZIPInputStream gzipInputStream = new GZIPInputStream(inputStream); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + byte[] buf = new byte[1024]; + int len; + while ((len = gzipInputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + return outputStream.toByteArray(); + } catch (IOException e) { + logger.error(ExceptionLog.getStackTrace(e)); + return null; + } + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/HtmlDocumentParser.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/HtmlDocumentParser.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/HtmlDocumentParser.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/HtmlDocumentParser.java index 0aecd56b..afbeaeb9 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/HtmlDocumentParser.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/HtmlDocumentParser.java @@ -1,54 +1,54 @@ -package org.bench4q.master.scriptrecord.httpcapture.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -public class HtmlDocumentParser { - private Document document; - private static Logger logger = Logger.getLogger(HtmlDocumentParser.class); - - private Document getDocument() { - return document; - } - - private void setDocument(Document document) { - this.document = document; - } - - public HtmlDocumentParser(String htmlContent, String baseUrl) { - this.setDocument(Jsoup.parse(htmlContent, baseUrl)); - } - - public void beginParse() { - - } - - public List buildParentChildrenRelationship(int parentBatchId) { - List result = new ArrayList(); - if (parentBatchId == -1) { - return result; - } - - Elements allChildrenLinks = new Elements(); - allChildrenLinks.addAll(this.getDocument().select("[src]")); - allChildrenLinks.addAll(this.getDocument().select("link[href]")); - - logger.info("Following url shuold in children urls: \n"); - for (Element element : allChildrenLinks) { - String childAbsoluteUrl = element.absUrl("src"); - if (childAbsoluteUrl.isEmpty()) { - childAbsoluteUrl = element.absUrl("href"); - } - logger.info(childAbsoluteUrl); - result.add(ChildrenUrl.createChilldUrl(childAbsoluteUrl, - parentBatchId)); - } - return result; - } -} +package org.bench4q.master.scriptrecord.httpcapture.generator; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +public class HtmlDocumentParser { + private Document document; + private static Logger logger = Logger.getLogger(HtmlDocumentParser.class); + + private Document getDocument() { + return document; + } + + private void setDocument(Document document) { + this.document = document; + } + + public HtmlDocumentParser(String htmlContent, String baseUrl) { + this.setDocument(Jsoup.parse(htmlContent, baseUrl)); + } + + public void beginParse() { + + } + + public List buildParentChildrenRelationship(int parentBatchId) { + List result = new ArrayList(); + if (parentBatchId == -1) { + return result; + } + + Elements allChildrenLinks = new Elements(); + allChildrenLinks.addAll(this.getDocument().select("[src]")); + allChildrenLinks.addAll(this.getDocument().select("link[href]")); + + logger.info("Following url shuold in children urls: \n"); + for (Element element : allChildrenLinks) { + String childAbsoluteUrl = element.absUrl("src"); + if (childAbsoluteUrl.isEmpty()) { + childAbsoluteUrl = element.absUrl("href"); + } + logger.info(childAbsoluteUrl); + result.add(ChildrenUrl.createChilldUrl(childAbsoluteUrl, + parentBatchId)); + } + return result; + } +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/IScriptGenerator.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/IScriptGenerator.java similarity index 96% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/IScriptGenerator.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/IScriptGenerator.java index e0612f70..5b8dadcc 100644 --- a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/IScriptGenerator.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/IScriptGenerator.java @@ -1,23 +1,23 @@ -package org.bench4q.master.scriptrecord.httpcapture.generator; - -import org.bench4q.master.scriptrecord.httpcapture.ProxyServer; - -public interface IScriptGenerator extends ProxyServer.Observer { - public static final String EOL = System.getProperty("line.separator"); - - public abstract String[] getValidFileExtensions(); - - public abstract String parseTestName(); - - public abstract void doStartRecording(); - - public abstract void doStopRecording(); - - public abstract void doNew(); - - public abstract boolean doSave(String paramString1, String paramString2); - - public abstract void doLoad(); - - public abstract void close(); -} +package org.bench4q.master.scriptrecord.httpcapture.generator; + +import org.bench4q.master.scriptrecord.httpcapture.ProxyServer; + +public interface IScriptGenerator extends ProxyServer.Observer { + public static final String EOL = System.getProperty("line.separator"); + + public abstract String[] getValidFileExtensions(); + + public abstract String parseTestName(); + + public abstract void doStartRecording(); + + public abstract void doStopRecording(); + + public abstract void doNew(); + + public abstract boolean doSave(String paramString1, String paramString2); + + public abstract void doLoad(); + + public abstract void close(); +} diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseHeader.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseHeader.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseHeader.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseHeader.java diff --git a/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseParser.java b/Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseParser.java similarity index 100% rename from src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseParser.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/scriptrecord/httpcapture/generator/ResponseParser.java diff --git a/src/main/java/org/bench4q/master/testplan/datastatistics/BehaviorsBriefStatistics.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/BehaviorsBriefStatistics.java similarity index 97% rename from src/main/java/org/bench4q/master/testplan/datastatistics/BehaviorsBriefStatistics.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/BehaviorsBriefStatistics.java index ce53bc28..b5498412 100644 --- a/src/main/java/org/bench4q/master/testplan/datastatistics/BehaviorsBriefStatistics.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/BehaviorsBriefStatistics.java @@ -1,122 +1,122 @@ -package org.bench4q.master.testplan.datastatistics; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bench4q.share.models.agent.BehaviorBriefModel; -import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel; -import org.bench4q.share.models.agent.statistics.DataStatisticsModel; -import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel; -import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel; - -public class BehaviorsBriefStatistics extends ScriptStatistics { - private Map> map; - private Map idUrlMap; - - private Map> getMap() { - return map; - } - - private void setMap( - Map> map) { - this.map = map; - } - - public Map getIdUrlMap() { - return idUrlMap; - } - - public void setIdUrlMap(Map idUrlMap) { - this.idUrlMap = idUrlMap; - } - - public BehaviorsBriefStatistics() { - this.setMap(new HashMap>()); - this.setIdUrlMap(new HashMap()); - } - - public ScriptBehaviorsBriefModel getStatistics() { - ScriptBehaviorsBriefModel result = new ScriptBehaviorsBriefModel(); - AgentBehaviorsBriefModel agentBehaviorsBriefModel = new AgentBehaviorsBriefModel(); - List list = new ArrayList(); - for (int behaviorId : this.getMap().keySet()) { - BehaviorBriefModel behaviorBriefModel = new BehaviorBriefModel(); - behaviorBriefModel.setBehaviorId(behaviorId); - behaviorBriefModel.setBehaviorUrl(this.getIdUrlMap() - .get(behaviorId)); - List statusList = new ArrayList(); - for (int statusCode : this.getMap().get(behaviorId).keySet()) { - statusList.add(getCopy(behaviorId, statusCode)); - } - behaviorBriefModel.setDetailStatusCodeResultModels(statusList); - list.add(behaviorBriefModel); - } - agentBehaviorsBriefModel.setBehaviorBriefModels(list); - result.setTestBehaviorsBriefModel(agentBehaviorsBriefModel); - makeUpResultModelWithSamplingTime(result); - return result; - } - - private BehaviorStatusCodeResultModel getCopy(int behaviorId, int statusCode) { - BehaviorStatusCodeResultModel statusInMap = this.getMap() - .get(behaviorId).get(statusCode); - BehaviorStatusCodeResultModel ret = new BehaviorStatusCodeResultModel(); - ret.setStatusCode(statusCode); - ret.setContentLength(statusInMap.getContentLength()); - ret.setContentType(statusInMap.getContentType()); - ret.setCount(statusInMap.getCount()); - ret.setMaxResponseTime(statusInMap.getMaxResponseTime()); - ret.setMinResponseTime(statusInMap.getMinResponseTime()); - ret.setTotalResponseTimeThisTime(statusInMap - .getTotalResponseTimeThisTime()); - return ret; - } - - public void add(DataStatisticsModel dataUnit) { - if (!(dataUnit instanceof AgentBehaviorsBriefModel)) { - return; - } - AgentBehaviorsBriefModel input = (AgentBehaviorsBriefModel) dataUnit; - for (BehaviorBriefModel behaviorBriefModel : input - .getBehaviorBriefModels()) { - guardAllMapsKeyExists(behaviorBriefModel); - Map behaviorStatusMap = this - .getMap().get(behaviorBriefModel.getBehaviorId()); - for (BehaviorStatusCodeResultModel newOne : behaviorBriefModel - .getDetailStatusCodeResultModels()) { - if (!behaviorStatusMap.containsKey(newOne.getStatusCode())) { - behaviorStatusMap.put(newOne.getStatusCode(), newOne); - continue; - } - BehaviorStatusCodeResultModel origin = behaviorStatusMap - .get(newOne.getStatusCode()); - origin.setContentLength(origin.getContentLength() - + newOne.getContentLength()); - origin.setCount(origin.getCount() + newOne.getCount()); - origin.setTotalResponseTimeThisTime(origin - .getTotalResponseTimeThisTime() - + newOne.getTotalResponseTimeThisTime()); - if (newOne.getMaxResponseTime() > origin.getMaxResponseTime()) { - origin.setMaxResponseTime(newOne.getMaxResponseTime()); - } - if (newOne.getMinResponseTime() < origin.getMinResponseTime()) { - origin.setMinResponseTime(newOne.getMinResponseTime()); - } - } - } - } - - private synchronized void guardAllMapsKeyExists( - BehaviorBriefModel behaviorBriefModel) { - if (!this.getMap().containsKey(behaviorBriefModel.getBehaviorId())) { - this.getMap().put(behaviorBriefModel.getBehaviorId(), - new HashMap()); - } - if (!this.getIdUrlMap().containsKey(behaviorBriefModel.getBehaviorId())) { - this.getIdUrlMap().put(behaviorBriefModel.getBehaviorId(), - behaviorBriefModel.getBehaviorUrl()); - } - } -} +package org.bench4q.master.testplan.datastatistics; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bench4q.share.models.agent.BehaviorBriefModel; +import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel; +import org.bench4q.share.models.agent.statistics.DataStatisticsModel; +import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel; +import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel; + +public class BehaviorsBriefStatistics extends ScriptStatistics { + private Map> map; + private Map idUrlMap; + + private Map> getMap() { + return map; + } + + private void setMap( + Map> map) { + this.map = map; + } + + public Map getIdUrlMap() { + return idUrlMap; + } + + public void setIdUrlMap(Map idUrlMap) { + this.idUrlMap = idUrlMap; + } + + public BehaviorsBriefStatistics() { + this.setMap(new HashMap>()); + this.setIdUrlMap(new HashMap()); + } + + public ScriptBehaviorsBriefModel getStatistics() { + ScriptBehaviorsBriefModel result = new ScriptBehaviorsBriefModel(); + AgentBehaviorsBriefModel agentBehaviorsBriefModel = new AgentBehaviorsBriefModel(); + List list = new ArrayList(); + for (int behaviorId : this.getMap().keySet()) { + BehaviorBriefModel behaviorBriefModel = new BehaviorBriefModel(); + behaviorBriefModel.setBehaviorId(behaviorId); + behaviorBriefModel.setBehaviorUrl(this.getIdUrlMap() + .get(behaviorId)); + List statusList = new ArrayList(); + for (int statusCode : this.getMap().get(behaviorId).keySet()) { + statusList.add(getCopy(behaviorId, statusCode)); + } + behaviorBriefModel.setDetailStatusCodeResultModels(statusList); + list.add(behaviorBriefModel); + } + agentBehaviorsBriefModel.setBehaviorBriefModels(list); + result.setTestBehaviorsBriefModel(agentBehaviorsBriefModel); + makeUpResultModelWithSamplingTime(result); + return result; + } + + private BehaviorStatusCodeResultModel getCopy(int behaviorId, int statusCode) { + BehaviorStatusCodeResultModel statusInMap = this.getMap() + .get(behaviorId).get(statusCode); + BehaviorStatusCodeResultModel ret = new BehaviorStatusCodeResultModel(); + ret.setStatusCode(statusCode); + ret.setContentLength(statusInMap.getContentLength()); + ret.setContentType(statusInMap.getContentType()); + ret.setCount(statusInMap.getCount()); + ret.setMaxResponseTime(statusInMap.getMaxResponseTime()); + ret.setMinResponseTime(statusInMap.getMinResponseTime()); + ret.setTotalResponseTimeThisTime(statusInMap + .getTotalResponseTimeThisTime()); + return ret; + } + + public void add(DataStatisticsModel dataUnit) { + if (!(dataUnit instanceof AgentBehaviorsBriefModel)) { + return; + } + AgentBehaviorsBriefModel input = (AgentBehaviorsBriefModel) dataUnit; + for (BehaviorBriefModel behaviorBriefModel : input + .getBehaviorBriefModels()) { + guardAllMapsKeyExists(behaviorBriefModel); + Map behaviorStatusMap = this + .getMap().get(behaviorBriefModel.getBehaviorId()); + for (BehaviorStatusCodeResultModel newOne : behaviorBriefModel + .getDetailStatusCodeResultModels()) { + if (!behaviorStatusMap.containsKey(newOne.getStatusCode())) { + behaviorStatusMap.put(newOne.getStatusCode(), newOne); + continue; + } + BehaviorStatusCodeResultModel origin = behaviorStatusMap + .get(newOne.getStatusCode()); + origin.setContentLength(origin.getContentLength() + + newOne.getContentLength()); + origin.setCount(origin.getCount() + newOne.getCount()); + origin.setTotalResponseTimeThisTime(origin + .getTotalResponseTimeThisTime() + + newOne.getTotalResponseTimeThisTime()); + if (newOne.getMaxResponseTime() > origin.getMaxResponseTime()) { + origin.setMaxResponseTime(newOne.getMaxResponseTime()); + } + if (newOne.getMinResponseTime() < origin.getMinResponseTime()) { + origin.setMinResponseTime(newOne.getMinResponseTime()); + } + } + } + } + + private synchronized void guardAllMapsKeyExists( + BehaviorBriefModel behaviorBriefModel) { + if (!this.getMap().containsKey(behaviorBriefModel.getBehaviorId())) { + this.getMap().put(behaviorBriefModel.getBehaviorId(), + new HashMap()); + } + if (!this.getIdUrlMap().containsKey(behaviorBriefModel.getBehaviorId())) { + this.getIdUrlMap().put(behaviorBriefModel.getBehaviorId(), + behaviorBriefModel.getBehaviorUrl()); + } + } +} diff --git a/src/main/java/org/bench4q/master/testplan/datastatistics/DataStatistics.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/DataStatistics.java similarity index 95% rename from src/main/java/org/bench4q/master/testplan/datastatistics/DataStatistics.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/DataStatistics.java index dfb304ea..fde602c1 100644 --- a/src/main/java/org/bench4q/master/testplan/datastatistics/DataStatistics.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/DataStatistics.java @@ -1,19 +1,19 @@ -package org.bench4q.master.testplan.datastatistics; - -import org.bench4q.share.models.agent.statistics.DataStatisticsModel; - -public interface DataStatistics { - public void add(DataStatisticsModel dataUnit); - - public Object getStatistics(); - - public class DefaultStatistics implements DataStatistics { - public void add(DataStatisticsModel dataUnit) { - } - - public Object getStatistics() { - return null; - } - - } -} +package org.bench4q.master.testplan.datastatistics; + +import org.bench4q.share.models.agent.statistics.DataStatisticsModel; + +public interface DataStatistics { + public void add(DataStatisticsModel dataUnit); + + public Object getStatistics(); + + public class DefaultStatistics implements DataStatistics { + public void add(DataStatisticsModel dataUnit) { + } + + public Object getStatistics() { + return null; + } + + } +} diff --git a/src/main/java/org/bench4q/master/testplan/datastatistics/PageBriefStatistics.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/PageBriefStatistics.java similarity index 97% rename from src/main/java/org/bench4q/master/testplan/datastatistics/PageBriefStatistics.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/PageBriefStatistics.java index 7dd082e1..9cb1c9bd 100644 --- a/src/main/java/org/bench4q/master/testplan/datastatistics/PageBriefStatistics.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/PageBriefStatistics.java @@ -1,73 +1,73 @@ -package org.bench4q.master.testplan.datastatistics; - -import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; -import org.bench4q.share.models.agent.statistics.DataStatisticsModel; -import org.bench4q.share.models.master.statistics.ScriptPageBriefModel; - -/** - * - * @author coderfengyun :This class is only statistics for One page, should - * construct it once each page; - * @Tip countFromBegin : Because of the statistics means that just accumulate - * the "countFromBegin" field of AgentPageBriefModel, so I can just take it - * as a temperary field for this class - */ -public class PageBriefStatistics extends ScriptStatistics { - private long countFromBegin; - private long maxResponseTimeFromBegin; - private long minResponseTimeFromBegin; - private long totalResponseTimeThisTime; - private long countThisTime; - private long latestResponseTime; - - public PageBriefStatistics() { - resetTemperaryFields(); - this.maxResponseTimeFromBegin = Long.MIN_VALUE; - this.minResponseTimeFromBegin = Long.MAX_VALUE; - } - - private void resetTemperaryFields() { - this.totalResponseTimeThisTime = 0; - this.countThisTime = 0; - this.countFromBegin = 0; - } - - public void add(DataStatisticsModel dataUnit) { - if (!(dataUnit instanceof AgentPageBriefModel)) { - return; - } - add((AgentPageBriefModel) dataUnit); - } - - private void add(AgentPageBriefModel pageBriefModel) { - this.countFromBegin += pageBriefModel.getCountFromBegin(); - this.countThisTime += pageBriefModel.getCountThisTime(); - this.totalResponseTimeThisTime += pageBriefModel - .getTotalResponseTimeThisTime(); - this.latestResponseTime = pageBriefModel.getLatestResponseTime(); - if (pageBriefModel.getMaxResponseTimeFromBegin() > this.maxResponseTimeFromBegin) { - this.maxResponseTimeFromBegin = pageBriefModel - .getMaxResponseTimeFromBegin(); - } - if (pageBriefModel.getMinResponseTimeFromBegin() < this.minResponseTimeFromBegin) { - this.minResponseTimeFromBegin = pageBriefModel - .getMinResponseTimeFromBegin(); - } - } - - public Object getStatistics() { - ScriptPageBriefModel result = new ScriptPageBriefModel(); - result.setCountFromBegin(this.countFromBegin); - result.setLatestResponseTime(this.latestResponseTime); - result.setMaxResponseTimeFromBegin(this.maxResponseTimeFromBegin); - result.setMinResponseTimeFromBegin(this.minResponseTimeFromBegin); - if (this.countThisTime > 0) { - result.setAverageResponseTimeThisTime(this.totalResponseTimeThisTime - / this.countThisTime); - } - resetTemperaryFields(); - makeUpResultModelWithSamplingTime(result); - return result; - } - -} +package org.bench4q.master.testplan.datastatistics; + +import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; +import org.bench4q.share.models.agent.statistics.DataStatisticsModel; +import org.bench4q.share.models.master.statistics.ScriptPageBriefModel; + +/** + * + * @author coderfengyun :This class is only statistics for One page, should + * construct it once each page; + * @Tip countFromBegin : Because of the statistics means that just accumulate + * the "countFromBegin" field of AgentPageBriefModel, so I can just take it + * as a temperary field for this class + */ +public class PageBriefStatistics extends ScriptStatistics { + private long countFromBegin; + private long maxResponseTimeFromBegin; + private long minResponseTimeFromBegin; + private long totalResponseTimeThisTime; + private long countThisTime; + private long latestResponseTime; + + public PageBriefStatistics() { + resetTemperaryFields(); + this.maxResponseTimeFromBegin = Long.MIN_VALUE; + this.minResponseTimeFromBegin = Long.MAX_VALUE; + } + + private void resetTemperaryFields() { + this.totalResponseTimeThisTime = 0; + this.countThisTime = 0; + this.countFromBegin = 0; + } + + public void add(DataStatisticsModel dataUnit) { + if (!(dataUnit instanceof AgentPageBriefModel)) { + return; + } + add((AgentPageBriefModel) dataUnit); + } + + private void add(AgentPageBriefModel pageBriefModel) { + this.countFromBegin += pageBriefModel.getCountFromBegin(); + this.countThisTime += pageBriefModel.getCountThisTime(); + this.totalResponseTimeThisTime += pageBriefModel + .getTotalResponseTimeThisTime(); + this.latestResponseTime = pageBriefModel.getLatestResponseTime(); + if (pageBriefModel.getMaxResponseTimeFromBegin() > this.maxResponseTimeFromBegin) { + this.maxResponseTimeFromBegin = pageBriefModel + .getMaxResponseTimeFromBegin(); + } + if (pageBriefModel.getMinResponseTimeFromBegin() < this.minResponseTimeFromBegin) { + this.minResponseTimeFromBegin = pageBriefModel + .getMinResponseTimeFromBegin(); + } + } + + public Object getStatistics() { + ScriptPageBriefModel result = new ScriptPageBriefModel(); + result.setCountFromBegin(this.countFromBegin); + result.setLatestResponseTime(this.latestResponseTime); + result.setMaxResponseTimeFromBegin(this.maxResponseTimeFromBegin); + result.setMinResponseTimeFromBegin(this.minResponseTimeFromBegin); + if (this.countThisTime > 0) { + result.setAverageResponseTimeThisTime(this.totalResponseTimeThisTime + / this.countThisTime); + } + resetTemperaryFields(); + makeUpResultModelWithSamplingTime(result); + return result; + } + +} diff --git a/src/main/java/org/bench4q/master/testplan/datastatistics/PagesBriefStatistics.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/PagesBriefStatistics.java similarity index 96% rename from src/main/java/org/bench4q/master/testplan/datastatistics/PagesBriefStatistics.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/PagesBriefStatistics.java index e2005385..13a04e54 100644 --- a/src/main/java/org/bench4q/master/testplan/datastatistics/PagesBriefStatistics.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/PagesBriefStatistics.java @@ -1,61 +1,61 @@ -package org.bench4q.master.testplan.datastatistics; - -import java.util.HashMap; -import java.util.Map; - -import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; -import org.bench4q.share.models.agent.statistics.AgentPagesBriefModel; -import org.bench4q.share.models.agent.statistics.DataStatisticsModel; -import org.bench4q.share.models.master.statistics.ScriptPageBriefModel; -import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel; - -public class PagesBriefStatistics extends ScriptStatistics { - private Map map; - - private Map getMap() { - return map; - } - - private void setMap(Map map) { - this.map = map; - } - - public PagesBriefStatistics() { - this.setMap(new HashMap()); - } - - public void add(DataStatisticsModel dataUnit) { - if (dataUnit instanceof AgentPagesBriefModel) { - add((AgentPagesBriefModel) dataUnit); - } - } - - private void add(AgentPagesBriefModel agentPagesBriefModel) { - for (AgentPageBriefModel unit : agentPagesBriefModel - .getPageBriefModels()) { - this.getValueFromMap(unit.getPageId()).add(unit); - } - } - - private PageBriefStatistics getValueFromMap(int key) { - guardMapKeyExists(key); - return this.getMap().get(key); - } - - private synchronized void guardMapKeyExists(int key) { - if (!this.getMap().containsKey(key)) { - this.getMap().put(key, new PageBriefStatistics()); - } - } - - public Object getStatistics() { - ScriptPagesBriefModel scriptPagesBriefModel = new ScriptPagesBriefModel(); - for (Integer key : this.getMap().keySet()) { - scriptPagesBriefModel.getScriptPageBriefModels().add( - (ScriptPageBriefModel) this.getValueFromMap(key) - .getStatistics()); - } - return scriptPagesBriefModel; - } - -} +package org.bench4q.master.testplan.datastatistics; + +import java.util.HashMap; +import java.util.Map; + +import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; +import org.bench4q.share.models.agent.statistics.AgentPagesBriefModel; +import org.bench4q.share.models.agent.statistics.DataStatisticsModel; +import org.bench4q.share.models.master.statistics.ScriptPageBriefModel; +import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel; + +public class PagesBriefStatistics extends ScriptStatistics { + private Map map; + + private Map getMap() { + return map; + } + + private void setMap(Map map) { + this.map = map; + } + + public PagesBriefStatistics() { + this.setMap(new HashMap()); + } + + public void add(DataStatisticsModel dataUnit) { + if (dataUnit instanceof AgentPagesBriefModel) { + add((AgentPagesBriefModel) dataUnit); + } + } + + private void add(AgentPagesBriefModel agentPagesBriefModel) { + for (AgentPageBriefModel unit : agentPagesBriefModel + .getPageBriefModels()) { + this.getValueFromMap(unit.getPageId()).add(unit); + } + } + + private PageBriefStatistics getValueFromMap(int key) { + guardMapKeyExists(key); + return this.getMap().get(key); + } + + private synchronized void guardMapKeyExists(int key) { + if (!this.getMap().containsKey(key)) { + this.getMap().put(key, new PageBriefStatistics()); + } + } + + public Object getStatistics() { + ScriptPagesBriefModel scriptPagesBriefModel = new ScriptPagesBriefModel(); + for (Integer key : this.getMap().keySet()) { + scriptPagesBriefModel.getScriptPageBriefModels().add( + (ScriptPageBriefModel) this.getValueFromMap(key) + .getStatistics()); + } + return scriptPagesBriefModel; + } + +} diff --git a/src/main/java/org/bench4q/master/testplan/datastatistics/ScriptBriefStatistics.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/ScriptBriefStatistics.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/datastatistics/ScriptBriefStatistics.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/ScriptBriefStatistics.java diff --git a/src/main/java/org/bench4q/master/testplan/datastatistics/ScriptStatistics.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/ScriptStatistics.java similarity index 96% rename from src/main/java/org/bench4q/master/testplan/datastatistics/ScriptStatistics.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/ScriptStatistics.java index 1157494d..0e1cc83f 100644 --- a/src/main/java/org/bench4q/master/testplan/datastatistics/ScriptStatistics.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/datastatistics/ScriptStatistics.java @@ -1,13 +1,13 @@ -package org.bench4q.master.testplan.datastatistics; - -import java.util.Date; - -import org.bench4q.share.models.master.statistics.SampleModel; - -public abstract class ScriptStatistics implements DataStatistics { - protected void makeUpResultModelWithSamplingTime( - SampleModel resultModel) { - resultModel.setSamplingTime(new Date()); - } - -} +package org.bench4q.master.testplan.datastatistics; + +import java.util.Date; + +import org.bench4q.share.models.master.statistics.SampleModel; + +public abstract class ScriptStatistics implements DataStatistics { + protected void makeUpResultModelWithSamplingTime( + SampleModel resultModel) { + resultModel.setSamplingTime(new Date()); + } + +} diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/AgentRunBlotter.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/AgentRunBlotter.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/highavailable/AgentRunBlotter.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/AgentRunBlotter.java diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadObserver.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadObserver.java similarity index 96% rename from src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadObserver.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadObserver.java index 3c6f2d13..a3735fff 100644 --- a/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadObserver.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadObserver.java @@ -1,5 +1,5 @@ -package org.bench4q.master.testplan.highavailable; - -public interface CurrentLoadObserver { - public void executePendingTestPlan(); -} +package org.bench4q.master.testplan.highavailable; + +public interface CurrentLoadObserver { + public void executePendingTestPlan(); +} diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadSubject.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadSubject.java similarity index 95% rename from src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadSubject.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadSubject.java index 66c9fb27..29f6126c 100644 --- a/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadSubject.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/CurrentLoadSubject.java @@ -1,17 +1,17 @@ -package org.bench4q.master.testplan.highavailable; - -public class CurrentLoadSubject { - private CurrentLoadObserver observer; - - public CurrentLoadObserver getObserver() { - return observer; - } - - public void setObserver(CurrentLoadObserver observer) { - this.observer = observer; - } - - public void notifyOberser() { - this.getObserver().executePendingTestPlan(); - } -} +package org.bench4q.master.testplan.highavailable; + +public class CurrentLoadSubject { + private CurrentLoadObserver observer; + + public CurrentLoadObserver getObserver() { + return observer; + } + + public void setObserver(CurrentLoadObserver observer) { + this.observer = observer; + } + + public void notifyOberser() { + this.getObserver().executePendingTestPlan(); + } +} diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/HighAvailablePool.java diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/BriefAgentFault.java diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerance.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerance.java similarity index 96% rename from src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerance.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerance.java index eb4bdb1c..5bbd8710 100644 --- a/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerance.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerance.java @@ -1,5 +1,5 @@ -package org.bench4q.master.testplan.highavailable.faultolerence; - -public interface FaultTolerance { - public void doTolerance(); -} +package org.bench4q.master.testplan.highavailable.faultolerence; + +public interface FaultTolerance { + public void doTolerance(); +} diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerenceFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerenceFactory.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerenceFactory.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/FaultTolerenceFactory.java diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/RunAgentFault.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/RunAgentFault.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/RunAgentFault.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/RunAgentFault.java diff --git a/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/StopAgentFault.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/StopAgentFault.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/StopAgentFault.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/highavailable/faultolerence/StopAgentFault.java diff --git a/src/main/java/org/bench4q/master/testplan/schedulscript/ExecutionOverTask.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/schedulscript/ExecutionOverTask.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/schedulscript/ExecutionOverTask.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/schedulscript/ExecutionOverTask.java diff --git a/src/main/java/org/bench4q/master/testplan/schedulscript/TaskCompleteCallback.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/schedulscript/TaskCompleteCallback.java similarity index 95% rename from src/main/java/org/bench4q/master/testplan/schedulscript/TaskCompleteCallback.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/schedulscript/TaskCompleteCallback.java index b2adb885..2c653b45 100644 --- a/src/main/java/org/bench4q/master/testplan/schedulscript/TaskCompleteCallback.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/schedulscript/TaskCompleteCallback.java @@ -1,7 +1,7 @@ -package org.bench4q.master.testplan.schedulscript; - -import java.util.UUID; - -public interface TaskCompleteCallback { - void doTaskComplete(UUID testPlanID); -} +package org.bench4q.master.testplan.schedulscript; + +import java.util.UUID; + +public interface TaskCompleteCallback { + void doTaskComplete(UUID testPlanID); +} diff --git a/src/main/java/org/bench4q/master/testplan/schedulscript/WarmUpOverTask.java b/Bench4Q-Master/src/main/java/org/bench4q/master/testplan/schedulscript/WarmUpOverTask.java similarity index 100% rename from src/main/java/org/bench4q/master/testplan/schedulscript/WarmUpOverTask.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/testplan/schedulscript/WarmUpOverTask.java diff --git a/src/main/java/org/bench4q/master/transaction/TestPlanLoadCommand.java b/Bench4Q-Master/src/main/java/org/bench4q/master/transaction/TestPlanLoadCommand.java similarity index 100% rename from src/main/java/org/bench4q/master/transaction/TestPlanLoadCommand.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/transaction/TestPlanLoadCommand.java diff --git a/src/main/java/org/bench4q/master/transaction/Transaction.java b/Bench4Q-Master/src/main/java/org/bench4q/master/transaction/Transaction.java similarity index 100% rename from src/main/java/org/bench4q/master/transaction/Transaction.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/transaction/Transaction.java diff --git a/src/main/java/org/bench4q/master/transaction/agent/AgentRunException.java b/Bench4Q-Master/src/main/java/org/bench4q/master/transaction/agent/AgentRunException.java similarity index 100% rename from src/main/java/org/bench4q/master/transaction/agent/AgentRunException.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/transaction/agent/AgentRunException.java diff --git a/src/main/java/org/bench4q/master/transaction/agent/AgentTransaction.java b/Bench4Q-Master/src/main/java/org/bench4q/master/transaction/agent/AgentTransaction.java similarity index 100% rename from src/main/java/org/bench4q/master/transaction/agent/AgentTransaction.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/transaction/agent/AgentTransaction.java diff --git a/src/main/java/org/bench4q/master/transaction/script/ScriptLoadBase.java b/Bench4Q-Master/src/main/java/org/bench4q/master/transaction/script/ScriptLoadBase.java similarity index 100% rename from src/main/java/org/bench4q/master/transaction/script/ScriptLoadBase.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/transaction/script/ScriptLoadBase.java diff --git a/src/main/java/org/bench4q/master/transaction/script/ScriptLoadCommand.java b/Bench4Q-Master/src/main/java/org/bench4q/master/transaction/script/ScriptLoadCommand.java similarity index 100% rename from src/main/java/org/bench4q/master/transaction/script/ScriptLoadCommand.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/transaction/script/ScriptLoadCommand.java diff --git a/src/main/java/org/bench4q/master/transaction/script/ScriptLoadDistributeException.java b/Bench4Q-Master/src/main/java/org/bench4q/master/transaction/script/ScriptLoadDistributeException.java similarity index 100% rename from src/main/java/org/bench4q/master/transaction/script/ScriptLoadDistributeException.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/transaction/script/ScriptLoadDistributeException.java diff --git a/src/main/java/org/bench4q/master/transaction/script/ScriptLoadSubstitute.java b/Bench4Q-Master/src/main/java/org/bench4q/master/transaction/script/ScriptLoadSubstitute.java similarity index 100% rename from src/main/java/org/bench4q/master/transaction/script/ScriptLoadSubstitute.java rename to Bench4Q-Master/src/main/java/org/bench4q/master/transaction/script/ScriptLoadSubstitute.java diff --git a/src/main/resources/log4j.properties b/Bench4Q-Master/src/main/resources/log4j.properties similarity index 100% rename from src/main/resources/log4j.properties rename to Bench4Q-Master/src/main/resources/log4j.properties diff --git a/src/main/resources/org/bench4q/master/config/ServerPort.properties b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/ServerPort.properties similarity index 100% rename from src/main/resources/org/bench4q/master/config/ServerPort.properties rename to Bench4Q-Master/src/main/resources/org/bench4q/master/config/ServerPort.properties diff --git a/src/main/resources/org/bench4q/master/config/application-context.xml b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/application-context.xml similarity index 98% rename from src/main/resources/org/bench4q/master/config/application-context.xml rename to Bench4Q-Master/src/main/resources/org/bench4q/master/config/application-context.xml index 5aac14d6..006d76d9 100644 --- a/src/main/resources/org/bench4q/master/config/application-context.xml +++ b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/application-context.xml @@ -1,13 +1,13 @@ - - - - - - - + + + + + + + diff --git a/src/main/resources/org/bench4q/master/config/hibernate.cfg.xml b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/hibernate.cfg.xml similarity index 100% rename from src/main/resources/org/bench4q/master/config/hibernate.cfg.xml rename to Bench4Q-Master/src/main/resources/org/bench4q/master/config/hibernate.cfg.xml diff --git a/src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties similarity index 95% rename from src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties rename to Bench4Q-Master/src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties index 8b23e25a..b931c29b 100644 --- a/src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties +++ b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/httpCaptureConfig/maxq.properties @@ -1,54 +1,54 @@ -# This file specifies configuration for maxq. - -# Names of generator classes to make available in the GUI. We do not -# include the Java generator here by default because MaxQ cannot run -# these scripts, only generate them. We do not include SampleGenerator -# because it is only of interest to people writing new generators and -# might confuse regular MaxQ users. -# -# Class names are separated by colons. -generator.classnames=com.bitmechanic.maxq.generator.IsacCodeGenerator - -# What port MaxQ should listen on for requests from the browser. Default is -# port 8090. -local.proxy.port=8090 - -# HTTP proxy settings for MaxQ's own requests; MaxQ can operate behind a -# firewall. -#remote.proxy.host=myproxy -#remote.proxy.port=3128 - - -########################################## -# properties used in TemplateCodeGenerator -########################################## -template.theme=HttpUnit - -########################################## -# properties used in IsacCodeGenerator -########################################## -#for constant think times -generator.isac.timer=ConstantTimer - -#not to capture think times -#generator.isac.timer=null - -#for randomized think times -#generator.isac.timer=Random - -#extra properties for a uniform distribution -#generator.isac.timer.random.dist=uniform -#generator.isac.timer.random.delta=1000 - -#extra properties for a gaussian distribution -#generator.isac.timer.random.dist=gaussian -#generator.isac.timer.random.delta=1000 -#generator.isac.timer.random.deviation=10 - -#extra properties for a Poisson law distribution -#generator.isac.timer.random.dist=poisson -#generator.isac.timer.random.unit=1 - -#extra properties for a negative exponential law distribution -#generator.isac.timer.random.dist=negexpo +# This file specifies configuration for maxq. + +# Names of generator classes to make available in the GUI. We do not +# include the Java generator here by default because MaxQ cannot run +# these scripts, only generate them. We do not include SampleGenerator +# because it is only of interest to people writing new generators and +# might confuse regular MaxQ users. +# +# Class names are separated by colons. +generator.classnames=com.bitmechanic.maxq.generator.IsacCodeGenerator + +# What port MaxQ should listen on for requests from the browser. Default is +# port 8090. +local.proxy.port=8090 + +# HTTP proxy settings for MaxQ's own requests; MaxQ can operate behind a +# firewall. +#remote.proxy.host=myproxy +#remote.proxy.port=3128 + + +########################################## +# properties used in TemplateCodeGenerator +########################################## +template.theme=HttpUnit + +########################################## +# properties used in IsacCodeGenerator +########################################## +#for constant think times +generator.isac.timer=ConstantTimer + +#not to capture think times +#generator.isac.timer=null + +#for randomized think times +#generator.isac.timer=Random + +#extra properties for a uniform distribution +#generator.isac.timer.random.dist=uniform +#generator.isac.timer.random.delta=1000 + +#extra properties for a gaussian distribution +#generator.isac.timer.random.dist=gaussian +#generator.isac.timer.random.delta=1000 +#generator.isac.timer.random.deviation=10 + +#extra properties for a Poisson law distribution +#generator.isac.timer.random.dist=poisson +#generator.isac.timer.random.unit=1 + +#extra properties for a negative exponential law distribution +#generator.isac.timer.random.dist=negexpo #generator.isac.timer.random.delta=10 \ No newline at end of file diff --git a/src/main/resources/org/bench4q/master/config/key.pfx b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/key.pfx similarity index 100% rename from src/main/resources/org/bench4q/master/config/key.pfx rename to Bench4Q-Master/src/main/resources/org/bench4q/master/config/key.pfx diff --git a/src/test/java/ModelTest/BehaviorBaseModelTest.java b/Bench4Q-Master/src/test/java/ModelTest/BehaviorBaseModelTest.java similarity index 97% rename from src/test/java/ModelTest/BehaviorBaseModelTest.java rename to Bench4Q-Master/src/test/java/ModelTest/BehaviorBaseModelTest.java index 1bbd417f..10582838 100644 --- a/src/test/java/ModelTest/BehaviorBaseModelTest.java +++ b/Bench4Q-Master/src/test/java/ModelTest/BehaviorBaseModelTest.java @@ -1,44 +1,44 @@ -package ModelTest; - -import java.util.ArrayList; -import java.util.List; - -import org.bench4q.share.models.agent.ParameterModel; -import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class BehaviorBaseModelTest { - @Test - public void testUserBehavior() { - List parameterModels = new ArrayList(); - ParameterModel param = new ParameterModel(); - param.setKey("url"); - param.setValue("www.baidu.com"); - parameterModels.add(param); - BehaviorModel behaviorBaseModel = BehaviorModel - .UserBehaviorBuilder(20, "Put", "http", parameterModels); - assertEquals(20, behaviorBaseModel.getId()); - assertEquals("Put", behaviorBaseModel.getName()); - assertEquals("http", behaviorBaseModel.getUse()); - assertEquals("USERBEHAVIOR", behaviorBaseModel.getType()); - assertEquals(1, behaviorBaseModel.getParameters().size()); - } - - @Test - public void testTimerBehavior() { - List params = new ArrayList(); - ParameterModel param = new ParameterModel(); - param.setKey("Time"); - param.setValue("209"); - params.add(param); - BehaviorModel behaviorBaseModel = BehaviorModel - .TimerBehaviorBuilder(3, "Sleep", "ContantTimer", params); - assertEquals(3, behaviorBaseModel.getId()); - assertEquals("Sleep", behaviorBaseModel.getName()); - assertEquals("ContantTimer", behaviorBaseModel.getUse()); - assertEquals(1, behaviorBaseModel.getParameters().size()); - assertEquals("TIMERBEHAVIOR", behaviorBaseModel.getType()); - } -} +package ModelTest; + +import java.util.ArrayList; +import java.util.List; + +import org.bench4q.share.models.agent.ParameterModel; +import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class BehaviorBaseModelTest { + @Test + public void testUserBehavior() { + List parameterModels = new ArrayList(); + ParameterModel param = new ParameterModel(); + param.setKey("url"); + param.setValue("www.baidu.com"); + parameterModels.add(param); + BehaviorModel behaviorBaseModel = BehaviorModel + .UserBehaviorBuilder(20, "Put", "http", parameterModels); + assertEquals(20, behaviorBaseModel.getId()); + assertEquals("Put", behaviorBaseModel.getName()); + assertEquals("http", behaviorBaseModel.getUse()); + assertEquals("USERBEHAVIOR", behaviorBaseModel.getType()); + assertEquals(1, behaviorBaseModel.getParameters().size()); + } + + @Test + public void testTimerBehavior() { + List params = new ArrayList(); + ParameterModel param = new ParameterModel(); + param.setKey("Time"); + param.setValue("209"); + params.add(param); + BehaviorModel behaviorBaseModel = BehaviorModel + .TimerBehaviorBuilder(3, "Sleep", "ContantTimer", params); + assertEquals(3, behaviorBaseModel.getId()); + assertEquals("Sleep", behaviorBaseModel.getName()); + assertEquals("ContantTimer", behaviorBaseModel.getUse()); + assertEquals(1, behaviorBaseModel.getParameters().size()); + assertEquals("TIMERBEHAVIOR", behaviorBaseModel.getType()); + } +} diff --git a/src/test/java/ModelTest/IpTest.java b/Bench4Q-Master/src/test/java/ModelTest/IpTest.java similarity index 96% rename from src/test/java/ModelTest/IpTest.java rename to Bench4Q-Master/src/test/java/ModelTest/IpTest.java index 729ad729..99376d7b 100644 --- a/src/test/java/ModelTest/IpTest.java +++ b/Bench4Q-Master/src/test/java/ModelTest/IpTest.java @@ -1,35 +1,35 @@ -package ModelTest; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.bench4q.share.models.master.statistics.ScriptBriefResultModel; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class IpTest { - @Test - public void testIp() throws UnknownHostException { - InetAddress addr = InetAddress.getLocalHost(); - System.out.println(addr.getHostAddress().toString()); - System.out.println(new SimpleDateFormat("yyyyMMdd").format(new Date())); - } - - @Test - public void testClassName() throws ClassNotFoundException { - ScriptBriefResultModel model = new ScriptBriefResultModel(); - System.out.println(model.getClass().getName()); - assertTrue(Class.forName(model.getClass().getName()).equals( - model.getClass())); - } - - @Test - public void testForInheritance() throws ClassNotFoundException { - Object model = new ScriptBriefResultModel(); - assertEquals(ScriptBriefResultModel.class.getName(), model.getClass() - .getName()); - } -} +package ModelTest; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.bench4q.share.models.master.statistics.ScriptBriefResultModel; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class IpTest { + @Test + public void testIp() throws UnknownHostException { + InetAddress addr = InetAddress.getLocalHost(); + System.out.println(addr.getHostAddress().toString()); + System.out.println(new SimpleDateFormat("yyyyMMdd").format(new Date())); + } + + @Test + public void testClassName() throws ClassNotFoundException { + ScriptBriefResultModel model = new ScriptBriefResultModel(); + System.out.println(model.getClass().getName()); + assertTrue(Class.forName(model.getClass().getName()).equals( + model.getClass())); + } + + @Test + public void testForInheritance() throws ClassNotFoundException { + Object model = new ScriptBriefResultModel(); + assertEquals(ScriptBriefResultModel.class.getName(), model.getClass() + .getName()); + } +} diff --git a/src/test/java/ModelTest/MarshallerTest.java b/Bench4Q-Master/src/test/java/ModelTest/MarshallerTest.java similarity index 97% rename from src/test/java/ModelTest/MarshallerTest.java rename to Bench4Q-Master/src/test/java/ModelTest/MarshallerTest.java index 245fdc83..b430bff5 100644 --- a/src/test/java/ModelTest/MarshallerTest.java +++ b/Bench4Q-Master/src/test/java/ModelTest/MarshallerTest.java @@ -1,30 +1,30 @@ -package ModelTest; - -import javax.xml.bind.JAXBException; - -import static org.junit.Assert.*; - -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.RunningAgentModel; -import org.junit.Test; - -public class MarshallerTest { - @Test - public void testMarshal() throws ClassNotFoundException, JAXBException { - RunningAgentModel runningAgentModel = new RunningAgentModel(); - String contentString = MarshalHelper.marshal(RunningAgentModel.class, - runningAgentModel); - assertNotNull(contentString); - System.out.println(contentString); - } - - @Test - public void testUnmarshal() throws JAXBException { - RunningAgentModel input = new RunningAgentModel(); - String content = MarshalHelper.marshal(RunningAgentModel.class, input); - RunningAgentModel output = (RunningAgentModel) MarshalHelper.unmarshal( - RunningAgentModel.class, content); - System.out.println(input.getLoadInUse()); - assertTrue(input.getLoadInUse() == output.getLoadInUse()); - } -} +package ModelTest; + +import javax.xml.bind.JAXBException; + +import static org.junit.Assert.*; + +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.RunningAgentModel; +import org.junit.Test; + +public class MarshallerTest { + @Test + public void testMarshal() throws ClassNotFoundException, JAXBException { + RunningAgentModel runningAgentModel = new RunningAgentModel(); + String contentString = MarshalHelper.marshal(RunningAgentModel.class, + runningAgentModel); + assertNotNull(contentString); + System.out.println(contentString); + } + + @Test + public void testUnmarshal() throws JAXBException { + RunningAgentModel input = new RunningAgentModel(); + String content = MarshalHelper.marshal(RunningAgentModel.class, input); + RunningAgentModel output = (RunningAgentModel) MarshalHelper.unmarshal( + RunningAgentModel.class, content); + System.out.println(input.getLoadInUse()); + assertTrue(input.getLoadInUse() == output.getLoadInUse()); + } +} diff --git a/src/test/java/ModelTest/Test_StatisticsResultModel.java b/Bench4Q-Master/src/test/java/ModelTest/Test_StatisticsResultModel.java similarity index 97% rename from src/test/java/ModelTest/Test_StatisticsResultModel.java rename to Bench4Q-Master/src/test/java/ModelTest/Test_StatisticsResultModel.java index afb0735a..998f5027 100644 --- a/src/test/java/ModelTest/Test_StatisticsResultModel.java +++ b/Bench4Q-Master/src/test/java/ModelTest/Test_StatisticsResultModel.java @@ -1,42 +1,42 @@ -package ModelTest; - -import java.util.Date; - -import javax.xml.bind.JAXBException; - -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel; -import org.bench4q.share.models.master.statistics.ScriptBriefResultModel; -import org.bench4q.share.models.master.statistics.ScriptPageBriefModel; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class Test_StatisticsResultModel { - @Test - public void testScriptBrief() throws JAXBException { - ScriptBriefResultModel scriptBriefResultModel = new ScriptBriefResultModel(); - scriptBriefResultModel.setSamplingTime(new Date()); - System.out.println(MarshalHelper.marshal(ScriptBriefResultModel.class, - scriptBriefResultModel)); - assertNotNull(scriptBriefResultModel.getSamplingTime()); - } - - @Test - public void testBehaviorsBrief() throws JAXBException { - ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = new ScriptBehaviorsBriefModel(); - scriptBehaviorsBriefModel.setSamplingTime(new Date()); - System.out.println(MarshalHelper.marshal( - ScriptBehaviorsBriefModel.class, scriptBehaviorsBriefModel)); - assertNotNull(scriptBehaviorsBriefModel.getSamplingTime()); - } - - @Test - public void testPageBrief() throws JAXBException { - ScriptPageBriefModel pageBriefModel = new ScriptPageBriefModel(); - pageBriefModel.setSamplingTime(new Date()); - System.out.println(MarshalHelper.marshal(ScriptPageBriefModel.class, - pageBriefModel)); - assertNotNull(pageBriefModel.getSamplingTime()); - } -} +package ModelTest; + +import java.util.Date; + +import javax.xml.bind.JAXBException; + +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel; +import org.bench4q.share.models.master.statistics.ScriptBriefResultModel; +import org.bench4q.share.models.master.statistics.ScriptPageBriefModel; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class Test_StatisticsResultModel { + @Test + public void testScriptBrief() throws JAXBException { + ScriptBriefResultModel scriptBriefResultModel = new ScriptBriefResultModel(); + scriptBriefResultModel.setSamplingTime(new Date()); + System.out.println(MarshalHelper.marshal(ScriptBriefResultModel.class, + scriptBriefResultModel)); + assertNotNull(scriptBriefResultModel.getSamplingTime()); + } + + @Test + public void testBehaviorsBrief() throws JAXBException { + ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = new ScriptBehaviorsBriefModel(); + scriptBehaviorsBriefModel.setSamplingTime(new Date()); + System.out.println(MarshalHelper.marshal( + ScriptBehaviorsBriefModel.class, scriptBehaviorsBriefModel)); + assertNotNull(scriptBehaviorsBriefModel.getSamplingTime()); + } + + @Test + public void testPageBrief() throws JAXBException { + ScriptPageBriefModel pageBriefModel = new ScriptPageBriefModel(); + pageBriefModel.setSamplingTime(new Date()); + System.out.println(MarshalHelper.marshal(ScriptPageBriefModel.class, + pageBriefModel)); + assertNotNull(pageBriefModel.getSamplingTime()); + } +} diff --git a/src/test/java/MonitorModelTest/MonitorModelTest.java b/Bench4Q-Master/src/test/java/MonitorModelTest/MonitorModelTest.java similarity index 96% rename from src/test/java/MonitorModelTest/MonitorModelTest.java rename to Bench4Q-Master/src/test/java/MonitorModelTest/MonitorModelTest.java index ff776dbd..0853e712 100644 --- a/src/test/java/MonitorModelTest/MonitorModelTest.java +++ b/Bench4Q-Master/src/test/java/MonitorModelTest/MonitorModelTest.java @@ -1,68 +1,68 @@ -package MonitorModelTest; -import static org.junit.Assert.*; - -import org.bench4q.master.infrastructure.communication.MonitorMessenger; -import org.bench4q.share.models.master.MonitorModel; -import org.junit.Assert; -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 = { "classpath:service-test-context.xml" }) -public class MonitorModelTest { - private MonitorModel monitor; - private MonitorMessenger monitorMessenger; - - public MonitorMessenger getMonitorMessenger() { - return monitorMessenger; - } - - @Autowired - public void setMonitorMessenger(MonitorMessenger monitorMessenger) { - this.monitorMessenger = monitorMessenger; - } - - @Before - public void setUp() { - this.monitor = new MonitorModel(); - monitor.setHostName("127.0.0.1"); - monitor.setPort(5556); - } - - @Test - public void testMemeoryModel() { - assertTrue(this.monitor.getHostName().equals("127.0.0.1")); - assertTrue(this.monitor.getPort() == 5556); - Assert.assertNotNull(this.getMonitorMessenger().memory( - monitor.getHostName(), monitor.getPort())); - - } - @Test - public void testProcessorModel() { - Assert.assertNotNull(this.getMonitorMessenger().processor( - monitor.getHostName(), monitor.getPort())); - - } - @Test - public void testProcessModel() { - Assert.assertNotNull(this.getMonitorMessenger().process( - monitor.getHostName(), monitor.getPort())); - - } - @Test - public void testPhysicalDiskModel() { - Assert.assertNotNull(this.getMonitorMessenger().physicalDisk( - monitor.getHostName(), monitor.getPort())); - - } - @Test - public void testMonitorMain() { - Assert.assertNotNull(this.getMonitorMessenger().monitorModel( - monitor.getHostName(), monitor.getPort())); - - } -} +package MonitorModelTest; +import static org.junit.Assert.*; + +import org.bench4q.master.infrastructure.communication.MonitorMessenger; +import org.bench4q.share.models.master.MonitorModel; +import org.junit.Assert; +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 = { "classpath:service-test-context.xml" }) +public class MonitorModelTest { + private MonitorModel monitor; + private MonitorMessenger monitorMessenger; + + public MonitorMessenger getMonitorMessenger() { + return monitorMessenger; + } + + @Autowired + public void setMonitorMessenger(MonitorMessenger monitorMessenger) { + this.monitorMessenger = monitorMessenger; + } + + @Before + public void setUp() { + this.monitor = new MonitorModel(); + monitor.setHostName("127.0.0.1"); + monitor.setPort(5556); + } + + @Test + public void testMemeoryModel() { + assertTrue(this.monitor.getHostName().equals("127.0.0.1")); + assertTrue(this.monitor.getPort() == 5556); + Assert.assertNotNull(this.getMonitorMessenger().memory( + monitor.getHostName(), monitor.getPort())); + + } + @Test + public void testProcessorModel() { + Assert.assertNotNull(this.getMonitorMessenger().processor( + monitor.getHostName(), monitor.getPort())); + + } + @Test + public void testProcessModel() { + Assert.assertNotNull(this.getMonitorMessenger().process( + monitor.getHostName(), monitor.getPort())); + + } + @Test + public void testPhysicalDiskModel() { + Assert.assertNotNull(this.getMonitorMessenger().physicalDisk( + monitor.getHostName(), monitor.getPort())); + + } + @Test + public void testMonitorMain() { + Assert.assertNotNull(this.getMonitorMessenger().monitorModel( + monitor.getHostName(), monitor.getPort())); + + } +} diff --git a/src/test/java/TestHelper/Test_PlunginHelper.java b/Bench4Q-Master/src/test/java/TestHelper/Test_PlunginHelper.java similarity index 97% rename from src/test/java/TestHelper/Test_PlunginHelper.java rename to Bench4Q-Master/src/test/java/TestHelper/Test_PlunginHelper.java index 0fa620e7..79280968 100644 --- a/src/test/java/TestHelper/Test_PlunginHelper.java +++ b/Bench4Q-Master/src/test/java/TestHelper/Test_PlunginHelper.java @@ -1,61 +1,61 @@ -package TestHelper; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -import org.bench4q.share.models.master.plugin.MethodModel; -import org.bench4q.share.models.master.plugin.MethodParamModel; -import org.bench4q.share.models.master.plugin.ParamTypeEnum; -import org.bench4q.share.models.master.plugin.PluginModel; -import org.bench4q.share.models.master.plugin.MethodParamPropertyModel; - -; - -public class Test_PlunginHelper { - - public static PluginModel createOnePlugin() { - PluginModel plugin = new PluginModel(); - MethodModel method = new MethodModel(); - MethodParamModel methodParamModelUrl = new MethodParamModel(); - methodParamModelUrl.setLable("input url"); - methodParamModelUrl.setName("url"); - methodParamModelUrl.setMethodParamProperties(generatePropertyForField()); - methodParamModelUrl.setParamType(ParamTypeEnum.Field); - - MethodParamModel methodParamsParamModel = new MethodParamModel(); - methodParamsParamModel.setName("queryparams"); - methodParamsParamModel.setLable("key=value"); - methodParamsParamModel.setMethodParamProperties(generatePropertyForMulti()); - methodParamsParamModel.setParamType(ParamTypeEnum.MultiField); - Set methodParams = new HashSet(); - methodParams.add(methodParamModelUrl); - methodParams.add(methodParamsParamModel); - method.setName("get"); - method.setMethodParams(methodParams); - - Set methods = new HashSet(); - methods.add(method); - plugin.setMethods(methods); - plugin.setName("http" + UUID.randomUUID()); - return plugin; - - } - private static Set generatePropertyForField() { - Set metList = new HashSet(); - MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); - methodParamPropertyModel.setKey("size"); - methodParamPropertyModel.setValue("20"); - metList.add(methodParamPropertyModel); - return metList; - - } - private static Set generatePropertyForMulti() { - Set metList = new HashSet(); - MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); - methodParamPropertyModel.setKey("size"); - methodParamPropertyModel.setValue("20"); - metList.add(methodParamPropertyModel); - return metList; - - } -} +package TestHelper; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import org.bench4q.share.models.master.plugin.MethodModel; +import org.bench4q.share.models.master.plugin.MethodParamModel; +import org.bench4q.share.models.master.plugin.ParamTypeEnum; +import org.bench4q.share.models.master.plugin.PluginModel; +import org.bench4q.share.models.master.plugin.MethodParamPropertyModel; + +; + +public class Test_PlunginHelper { + + public static PluginModel createOnePlugin() { + PluginModel plugin = new PluginModel(); + MethodModel method = new MethodModel(); + MethodParamModel methodParamModelUrl = new MethodParamModel(); + methodParamModelUrl.setLable("input url"); + methodParamModelUrl.setName("url"); + methodParamModelUrl.setMethodParamProperties(generatePropertyForField()); + methodParamModelUrl.setParamType(ParamTypeEnum.Field); + + MethodParamModel methodParamsParamModel = new MethodParamModel(); + methodParamsParamModel.setName("queryparams"); + methodParamsParamModel.setLable("key=value"); + methodParamsParamModel.setMethodParamProperties(generatePropertyForMulti()); + methodParamsParamModel.setParamType(ParamTypeEnum.MultiField); + Set methodParams = new HashSet(); + methodParams.add(methodParamModelUrl); + methodParams.add(methodParamsParamModel); + method.setName("get"); + method.setMethodParams(methodParams); + + Set methods = new HashSet(); + methods.add(method); + plugin.setMethods(methods); + plugin.setName("http" + UUID.randomUUID()); + return plugin; + + } + private static Set generatePropertyForField() { + Set metList = new HashSet(); + MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); + methodParamPropertyModel.setKey("size"); + methodParamPropertyModel.setValue("20"); + metList.add(methodParamPropertyModel); + return metList; + + } + private static Set generatePropertyForMulti() { + Set metList = new HashSet(); + MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); + methodParamPropertyModel.setKey("size"); + methodParamPropertyModel.setValue("20"); + metList.add(methodParamPropertyModel); + return metList; + + } +} diff --git a/src/test/java/org/bench4q/master/test/FileSeperatorTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/FileSeperatorTest.java similarity index 96% rename from src/test/java/org/bench4q/master/test/FileSeperatorTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/FileSeperatorTest.java index c2c1ff1b..c0ef0304 100644 --- a/src/test/java/org/bench4q/master/test/FileSeperatorTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/FileSeperatorTest.java @@ -1,7 +1,7 @@ -package org.bench4q.master.test; - -public class FileSeperatorTest { - public static void main(String[] args) { - System.out.println("scripts" + System.getProperty("file.separator")); - } -} +package org.bench4q.master.test; + +public class FileSeperatorTest { + public static void main(String[] args) { + System.out.println("scripts" + System.getProperty("file.separator")); + } +} diff --git a/src/test/java/org/bench4q/master/test/HttpRequestTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/HttpRequestTest.java similarity index 100% rename from src/test/java/org/bench4q/master/test/HttpRequestTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/HttpRequestTest.java diff --git a/src/test/java/org/bench4q/master/test/PolymorphismTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/PolymorphismTest.java similarity index 95% rename from src/test/java/org/bench4q/master/test/PolymorphismTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/PolymorphismTest.java index 3abb6585..e3e914e4 100644 --- a/src/test/java/org/bench4q/master/test/PolymorphismTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/PolymorphismTest.java @@ -1,29 +1,29 @@ -package org.bench4q.master.test; - -public class PolymorphismTest { - public void shout() { - shoutTwice(); - } - - public void shoutTwice() { - System.out.println("aaaaaa"); - System.out.println("aaaaaa"); - } - - public static void main(String[] args) { - PolymorphismTest poly = new ChildTest(); - System.out.println("poly shout is "); - poly.shout(); - - ChildTest childTest = new ChildTest(); - System.out.println("child shout is "); - childTest.shout(); - } -} - -class ChildTest extends PolymorphismTest { - public void shoutTwice() { - System.out.println("bbbbbbb"); - System.out.println("bbbbbbb"); - } +package org.bench4q.master.test; + +public class PolymorphismTest { + public void shout() { + shoutTwice(); + } + + public void shoutTwice() { + System.out.println("aaaaaa"); + System.out.println("aaaaaa"); + } + + public static void main(String[] args) { + PolymorphismTest poly = new ChildTest(); + System.out.println("poly shout is "); + poly.shout(); + + ChildTest childTest = new ChildTest(); + System.out.println("child shout is "); + childTest.shout(); + } +} + +class ChildTest extends PolymorphismTest { + public void shoutTwice() { + System.out.println("bbbbbbb"); + System.out.println("bbbbbbb"); + } } \ No newline at end of file diff --git a/src/test/java/org/bench4q/master/test/TestBase_MakeUpTestPlan.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/TestBase_MakeUpTestPlan.java similarity index 100% rename from src/test/java/org/bench4q/master/test/TestBase_MakeUpTestPlan.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/TestBase_MakeUpTestPlan.java diff --git a/src/test/java/org/bench4q/master/test/TestRecordBase.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/TestRecordBase.java similarity index 100% rename from src/test/java/org/bench4q/master/test/TestRecordBase.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/TestRecordBase.java diff --git a/src/test/java/org/bench4q/master/test/byteTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/byteTest.java similarity index 95% rename from src/test/java/org/bench4q/master/test/byteTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/byteTest.java index b03e9ea3..2cae7592 100644 --- a/src/test/java/org/bench4q/master/test/byteTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/byteTest.java @@ -1,24 +1,24 @@ -package org.bench4q.master.test; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class byteTest { - @Test - public void testByteForNewLine() { - Byte byte1 = Byte.parseByte("10"); - assertTrue(byte1.byteValue() == 10); - char ch = (char) byte1.byteValue(); - assertEquals('\n', ch); - System.out.println(ch); - } - - @Test - public void testByteForReturn() { - Byte byte2 = Byte.parseByte("13"); - char ch = (char) byte2.byteValue(); - assertEquals('\r', ch); - System.out.println(ch); - } -} +package org.bench4q.master.test; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class byteTest { + @Test + public void testByteForNewLine() { + Byte byte1 = Byte.parseByte("10"); + assertTrue(byte1.byteValue() == 10); + char ch = (char) byte1.byteValue(); + assertEquals('\n', ch); + System.out.println(ch); + } + + @Test + public void testByteForReturn() { + Byte byte2 = Byte.parseByte("13"); + char ch = (char) byte2.byteValue(); + assertEquals('\r', ch); + System.out.println(ch); + } +} diff --git a/src/test/java/org/bench4q/master/test/communication/Test_AgentMessenger.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/communication/Test_AgentMessenger.java similarity index 100% rename from src/test/java/org/bench4q/master/test/communication/Test_AgentMessenger.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/communication/Test_AgentMessenger.java diff --git a/src/test/java/org/bench4q/master/test/communication/Test_MonitorMessenger.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/communication/Test_MonitorMessenger.java similarity index 96% rename from src/test/java/org/bench4q/master/test/communication/Test_MonitorMessenger.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/communication/Test_MonitorMessenger.java index a1a398cf..2d6013ed 100644 --- a/src/test/java/org/bench4q/master/test/communication/Test_MonitorMessenger.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/communication/Test_MonitorMessenger.java @@ -1,40 +1,40 @@ -package org.bench4q.master.test.communication; - -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.infrastructure.communication.MonitorMessenger; -import org.junit.Assert; -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 = { "classpath:service-test-context.xml" }) -public class Test_MonitorMessenger { - - private Monitor monitor = new Monitor(); - private MonitorMessenger monitorMessenger; - - @Before - public void setUp() { - this.monitor.setHostName("127.0.0.1"); - this.monitor.setPort(5556); - } - - public MonitorMessenger getMonitorMessenger() { - return monitorMessenger; - } - - @Autowired - public void setMonitorMessenger(MonitorMessenger monitorMessenger) { - this.monitorMessenger = monitorMessenger; - } - - @Test - public void test_getMonitorModel() { - Assert.assertNotNull(this.getMonitorMessenger().monitorModel( - monitor.getHostName(), monitor.getPort())); - } -} +package org.bench4q.master.test.communication; + +import org.bench4q.master.domain.entity.Monitor; +import org.bench4q.master.infrastructure.communication.MonitorMessenger; +import org.junit.Assert; +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 = { "classpath:service-test-context.xml" }) +public class Test_MonitorMessenger { + + private Monitor monitor = new Monitor(); + private MonitorMessenger monitorMessenger; + + @Before + public void setUp() { + this.monitor.setHostName("127.0.0.1"); + this.monitor.setPort(5556); + } + + public MonitorMessenger getMonitorMessenger() { + return monitorMessenger; + } + + @Autowired + public void setMonitorMessenger(MonitorMessenger monitorMessenger) { + this.monitorMessenger = monitorMessenger; + } + + @Test + public void test_getMonitorModel() { + Assert.assertNotNull(this.getMonitorMessenger().monitorModel( + monitor.getHostName(), monitor.getPort())); + } +} diff --git a/src/test/java/org/bench4q/master/test/controller/AgentPoolControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/AgentPoolControllerTest.java similarity index 97% rename from src/test/java/org/bench4q/master/test/controller/AgentPoolControllerTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/AgentPoolControllerTest.java index eb94b446..8b6dbf02 100644 --- a/src/test/java/org/bench4q/master/test/controller/AgentPoolControllerTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/AgentPoolControllerTest.java @@ -1,75 +1,75 @@ -package org.bench4q.master.test.controller; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBException; - -import org.bench4q.share.communication.HttpRequester.HttpResponse; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.AgentModel; -import org.bench4q.share.models.master.AgentResponseModel; -import org.junit.Test; - -public class AgentPoolControllerTest extends TestBase { - private final String URLSTRING = BASE_URL + "/agentManage"; - private final static String HOSTNAME1 = "127.0.0.1"; - private final static String HOSTNAME2 = "133.133.12.9"; - - @Test - public void testAdd() throws JAXBException, IOException { - this.setAccessTocken(this.login()); - this.addAgentToPool(HOSTNAME2); - // test.removeAgentToPool(); - this.loadAgentsFromPool(); - } - - public void addAgentToPool(String hostName) throws JAXBException, - IOException { - String urlString = this.URLSTRING + "/addAgentToPool"; - AgentResponseModel agentResponseModel = new AgentResponseModel(); - - AgentModel agent = new AgentModel(); - agent.setHostName(hostName); - agent.setMaxLoad(500); - agent.setRemainLoad(500); - agent.setPort(6565); - System.out.println(urlString); - System.out.println(MarshalHelper.marshal(AgentModel.class, agent)); - HttpResponse httpResponse = this.httpRequester.sendPostXml(urlString, - MarshalHelper.marshal(AgentModel.class, agent), - makeAccessTockenMap(this.getAccessTocken())); - - agentResponseModel = (AgentResponseModel) MarshalHelper.unmarshal( - AgentResponseModel.class, httpResponse.getContent()); - - System.out.println(httpResponse.getContent()); - System.out.println(agentResponseModel.isSuccess()); - } - - public void removeAgentToPool() throws IOException, JAXBException { - Map propertiesMap = new HashMap(); - propertiesMap.put(AUTH_HEADER_PROPERTY, this.ACCES_TOCKEN_STARTER - + this.accessTocken); - - String urlString = this.URLSTRING + "/removeAgentFromPool"; - Map map = new HashMap(); - map.put("hostName", HOSTNAME1); - HttpResponse httpResponse = this.httpRequester.sendGet(urlString, map, - propertiesMap); - System.out.println(httpResponse.getContent()); - } - - public void loadAgentsFromPool() throws IOException { - Map propertiesMap = new HashMap(); - propertiesMap.put(AUTH_HEADER_PROPERTY, this.ACCES_TOCKEN_STARTER - + this.accessTocken); - - String urlString = this.URLSTRING + "/queryAgentList"; - HttpResponse httpResponse = this.httpRequester.sendPost(urlString, - null, propertiesMap); - System.out.println(httpResponse.getContent()); - } - -} +package org.bench4q.master.test.controller; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBException; + +import org.bench4q.share.communication.HttpRequester.HttpResponse; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.AgentModel; +import org.bench4q.share.models.master.AgentResponseModel; +import org.junit.Test; + +public class AgentPoolControllerTest extends TestBase { + private final String URLSTRING = BASE_URL + "/agentManage"; + private final static String HOSTNAME1 = "127.0.0.1"; + private final static String HOSTNAME2 = "133.133.12.9"; + + @Test + public void testAdd() throws JAXBException, IOException { + this.setAccessTocken(this.login()); + this.addAgentToPool(HOSTNAME2); + // test.removeAgentToPool(); + this.loadAgentsFromPool(); + } + + public void addAgentToPool(String hostName) throws JAXBException, + IOException { + String urlString = this.URLSTRING + "/addAgentToPool"; + AgentResponseModel agentResponseModel = new AgentResponseModel(); + + AgentModel agent = new AgentModel(); + agent.setHostName(hostName); + agent.setMaxLoad(500); + agent.setRemainLoad(500); + agent.setPort(6565); + System.out.println(urlString); + System.out.println(MarshalHelper.marshal(AgentModel.class, agent)); + HttpResponse httpResponse = this.httpRequester.sendPostXml(urlString, + MarshalHelper.marshal(AgentModel.class, agent), + makeAccessTockenMap(this.getAccessTocken())); + + agentResponseModel = (AgentResponseModel) MarshalHelper.unmarshal( + AgentResponseModel.class, httpResponse.getContent()); + + System.out.println(httpResponse.getContent()); + System.out.println(agentResponseModel.isSuccess()); + } + + public void removeAgentToPool() throws IOException, JAXBException { + Map propertiesMap = new HashMap(); + propertiesMap.put(AUTH_HEADER_PROPERTY, this.ACCES_TOCKEN_STARTER + + this.accessTocken); + + String urlString = this.URLSTRING + "/removeAgentFromPool"; + Map map = new HashMap(); + map.put("hostName", HOSTNAME1); + HttpResponse httpResponse = this.httpRequester.sendGet(urlString, map, + propertiesMap); + System.out.println(httpResponse.getContent()); + } + + public void loadAgentsFromPool() throws IOException { + Map propertiesMap = new HashMap(); + propertiesMap.put(AUTH_HEADER_PROPERTY, this.ACCES_TOCKEN_STARTER + + this.accessTocken); + + String urlString = this.URLSTRING + "/queryAgentList"; + HttpResponse httpResponse = this.httpRequester.sendPost(urlString, + null, propertiesMap); + System.out.println(httpResponse.getContent()); + } + +} diff --git a/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java similarity index 97% rename from src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java index ce797f2f..c50bd8b2 100644 --- a/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java @@ -1,75 +1,75 @@ -package org.bench4q.master.test.controller; - -import static org.junit.Assert.*; - -import java.io.IOException; - -import javax.xml.bind.JAXBException; - -import org.bench4q.share.communication.HttpRequester.HttpResponse; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.plugin.PluginResponseModel; -import org.junit.Assert; -import org.junit.Test; - -public class PluginControllerTest extends TestBase { - private final String URLSTRING = BASE_URL + "/plugin"; - - public String getURLSTRING() { - return URLSTRING; - } - - @Test - public void testLoadPluginList() throws JAXBException, IOException { - this.setAccessTocken(this.login()); - String url = URLSTRING + "/loadPluginList"; - HttpResponse httpResponse = this.httpRequester.sendPost(url, null, - makeAccessTockenMap(this.getAccessTocken())); - System.out.println(httpResponse.getContent()); - PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper - .tryUnmarshal(PluginResponseModel.class, - httpResponse.getContent()); - Assert.assertTrue(pluginResponseModel.getPluginList().size() > 0); - } - - @Test - public void testLoadMethodNameList() throws IOException, JAXBException { - this.setAccessTocken(this.login()); - String url = URLSTRING + "/loadPluginList"; - HttpResponse httpResponse = this.httpRequester.sendPost(url, null, - makeAccessTockenMap(this.getAccessTocken())); - PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper - .tryUnmarshal(PluginResponseModel.class, - httpResponse.getContent()); - assertTrue(pluginResponseModel.getPluginList().size() > 0); - String pluginName = pluginResponseModel.getPluginList().get(0); - String urlForLoadMethod = URLSTRING + "/loadMethodList/" + pluginName; - httpResponse = this.httpRequester.sendPost(urlForLoadMethod, null, - makeAccessTockenMap(this.getAccessTocken())); - System.out.println(httpResponse.getContent()); - pluginResponseModel = (PluginResponseModel) MarshalHelper.unmarshal( - PluginResponseModel.class, httpResponse.getContent()); - assertNotNull(pluginResponseModel); - assertEquals(1, pluginResponseModel.getMethodList().size()); - } - - @Test - public void testDeletePlugin() throws IOException { - this.setAccessTocken(this.login()); - String url = URLSTRING + "/loadPluginList"; - HttpResponse httpResponse = this.httpRequester.sendPost(url, null, - makeAccessTockenMap(this.getAccessTocken())); - PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper - .tryUnmarshal(PluginResponseModel.class, - httpResponse.getContent()); - assertTrue(pluginResponseModel.getPluginList().size() > 0); - String pluginName = pluginResponseModel.getPluginList().get(0); - url = URLSTRING + "/deletePlugin" + "/" + pluginName; - httpResponse = this.httpRequester.sendPost(url, null, - makeAccessTockenMap(this.getAccessTocken())); - pluginResponseModel = (PluginResponseModel) MarshalHelper.tryUnmarshal( - PluginResponseModel.class, httpResponse.getContent()); - Assert.assertTrue(pluginResponseModel.isSuccess()); - } - -} +package org.bench4q.master.test.controller; + +import static org.junit.Assert.*; + +import java.io.IOException; + +import javax.xml.bind.JAXBException; + +import org.bench4q.share.communication.HttpRequester.HttpResponse; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.plugin.PluginResponseModel; +import org.junit.Assert; +import org.junit.Test; + +public class PluginControllerTest extends TestBase { + private final String URLSTRING = BASE_URL + "/plugin"; + + public String getURLSTRING() { + return URLSTRING; + } + + @Test + public void testLoadPluginList() throws JAXBException, IOException { + this.setAccessTocken(this.login()); + String url = URLSTRING + "/loadPluginList"; + HttpResponse httpResponse = this.httpRequester.sendPost(url, null, + makeAccessTockenMap(this.getAccessTocken())); + System.out.println(httpResponse.getContent()); + PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper + .tryUnmarshal(PluginResponseModel.class, + httpResponse.getContent()); + Assert.assertTrue(pluginResponseModel.getPluginList().size() > 0); + } + + @Test + public void testLoadMethodNameList() throws IOException, JAXBException { + this.setAccessTocken(this.login()); + String url = URLSTRING + "/loadPluginList"; + HttpResponse httpResponse = this.httpRequester.sendPost(url, null, + makeAccessTockenMap(this.getAccessTocken())); + PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper + .tryUnmarshal(PluginResponseModel.class, + httpResponse.getContent()); + assertTrue(pluginResponseModel.getPluginList().size() > 0); + String pluginName = pluginResponseModel.getPluginList().get(0); + String urlForLoadMethod = URLSTRING + "/loadMethodList/" + pluginName; + httpResponse = this.httpRequester.sendPost(urlForLoadMethod, null, + makeAccessTockenMap(this.getAccessTocken())); + System.out.println(httpResponse.getContent()); + pluginResponseModel = (PluginResponseModel) MarshalHelper.unmarshal( + PluginResponseModel.class, httpResponse.getContent()); + assertNotNull(pluginResponseModel); + assertEquals(1, pluginResponseModel.getMethodList().size()); + } + + @Test + public void testDeletePlugin() throws IOException { + this.setAccessTocken(this.login()); + String url = URLSTRING + "/loadPluginList"; + HttpResponse httpResponse = this.httpRequester.sendPost(url, null, + makeAccessTockenMap(this.getAccessTocken())); + PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper + .tryUnmarshal(PluginResponseModel.class, + httpResponse.getContent()); + assertTrue(pluginResponseModel.getPluginList().size() > 0); + String pluginName = pluginResponseModel.getPluginList().get(0); + url = URLSTRING + "/deletePlugin" + "/" + pluginName; + httpResponse = this.httpRequester.sendPost(url, null, + makeAccessTockenMap(this.getAccessTocken())); + pluginResponseModel = (PluginResponseModel) MarshalHelper.tryUnmarshal( + PluginResponseModel.class, httpResponse.getContent()); + Assert.assertTrue(pluginResponseModel.isSuccess()); + } + +} diff --git a/src/test/java/org/bench4q/master/test/controller/RecordPortControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/RecordPortControllerTest.java similarity index 97% rename from src/test/java/org/bench4q/master/test/controller/RecordPortControllerTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/RecordPortControllerTest.java index 2c877d1a..bec616ba 100644 --- a/src/test/java/org/bench4q/master/test/controller/RecordPortControllerTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/RecordPortControllerTest.java @@ -1,43 +1,43 @@ -package org.bench4q.master.test.controller; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBException; - -import org.bench4q.share.communication.HttpRequester.HttpResponse; - -public class RecordPortControllerTest extends TestBase { - private final String URLSTRING = BASE_URL + "/RecordPort"; - private final String PORT = "1100"; - private final String PARAM1 = "port"; - - public void AddPortToPool() throws IOException, JAXBException { - String accesTocken = this.login(); - Map params = new HashMap(); - params.put(PARAM1, PORT); - String urlString = URLSTRING + "/addPortToPortPool"; - - HttpResponse httpResponse = this.httpRequester.sendPost(urlString, - params, this.makeAccessTockenMap(accesTocken)); - - System.out.println(httpResponse.getContent()); - } - - public void RemovePortFromPool() throws IOException, JAXBException { - String accesTocken = this.login(); - Map params = new HashMap(); - params.put("portId", 3 + ""); - String urlString = URLSTRING + "/removePortFromPool"; - HttpResponse httpResponse = this.httpRequester.sendPost(urlString, - params, this.makeAccessTockenMap(accesTocken)); - System.out.println(httpResponse.getContent()); - } - - public static void main(String[] args) throws Throwable { - RecordPortControllerTest test = new RecordPortControllerTest(); - test.AddPortToPool(); - test.RemovePortFromPool(); - } -} +package org.bench4q.master.test.controller; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBException; + +import org.bench4q.share.communication.HttpRequester.HttpResponse; + +public class RecordPortControllerTest extends TestBase { + private final String URLSTRING = BASE_URL + "/RecordPort"; + private final String PORT = "1100"; + private final String PARAM1 = "port"; + + public void AddPortToPool() throws IOException, JAXBException { + String accesTocken = this.login(); + Map params = new HashMap(); + params.put(PARAM1, PORT); + String urlString = URLSTRING + "/addPortToPortPool"; + + HttpResponse httpResponse = this.httpRequester.sendPost(urlString, + params, this.makeAccessTockenMap(accesTocken)); + + System.out.println(httpResponse.getContent()); + } + + public void RemovePortFromPool() throws IOException, JAXBException { + String accesTocken = this.login(); + Map params = new HashMap(); + params.put("portId", 3 + ""); + String urlString = URLSTRING + "/removePortFromPool"; + HttpResponse httpResponse = this.httpRequester.sendPost(urlString, + params, this.makeAccessTockenMap(accesTocken)); + System.out.println(httpResponse.getContent()); + } + + public static void main(String[] args) throws Throwable { + RecordPortControllerTest test = new RecordPortControllerTest(); + test.AddPortToPool(); + test.RemovePortFromPool(); + } +} diff --git a/src/test/java/org/bench4q/master/test/controller/RecordScriptControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/RecordScriptControllerTest.java similarity index 100% rename from src/test/java/org/bench4q/master/test/controller/RecordScriptControllerTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/RecordScriptControllerTest.java diff --git a/src/test/java/org/bench4q/master/test/controller/ScriptControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/ScriptControllerTest.java similarity index 97% rename from src/test/java/org/bench4q/master/test/controller/ScriptControllerTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/ScriptControllerTest.java index 27723bf1..4f04fbd7 100644 --- a/src/test/java/org/bench4q/master/test/controller/ScriptControllerTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/ScriptControllerTest.java @@ -1,42 +1,42 @@ -package org.bench4q.master.test.controller; - -import static org.junit.Assert.*; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBException; - -import org.bench4q.share.communication.HttpRequester.HttpResponse; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.OperateScriptServerResponseModel; -import org.junit.Test; - -public class ScriptControllerTest extends TestBase { - - private String controllerUrl = BASE_URL + "/RecordScript"; - - @Test - public void loadScriptsTest() throws IOException, JAXBException { - String url = this.controllerUrl + "/loadScriptList"; - HttpResponse httpResponse = this.httpRequester.sendGet(url, null, - this.makeAccessTockenMap(this.login())); - OperateScriptServerResponseModel ret = (OperateScriptServerResponseModel) MarshalHelper - .unmarshal(OperateScriptServerResponseModel.class, - httpResponse.getContent()); - assertTrue(ret.getScriptModels().size() > 0); - } - - @Test - public void deleteScript(int scriptId) throws IOException { - Map params = new HashMap(); - params.put("scriptId", scriptId + ""); - Map properties = new HashMap(); - properties.put(this.AUTH_HEADER_PROPERTY, this.ACCES_TOCKEN_STARTER - + this.accessTocken); - HttpResponse httpResponse = this.httpRequester.sendPost( - this.controllerUrl + "/deleteScript", params, properties); - System.out.println(httpResponse.getContent()); - } -} +package org.bench4q.master.test.controller; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBException; + +import org.bench4q.share.communication.HttpRequester.HttpResponse; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.OperateScriptServerResponseModel; +import org.junit.Test; + +public class ScriptControllerTest extends TestBase { + + private String controllerUrl = BASE_URL + "/RecordScript"; + + @Test + public void loadScriptsTest() throws IOException, JAXBException { + String url = this.controllerUrl + "/loadScriptList"; + HttpResponse httpResponse = this.httpRequester.sendGet(url, null, + this.makeAccessTockenMap(this.login())); + OperateScriptServerResponseModel ret = (OperateScriptServerResponseModel) MarshalHelper + .unmarshal(OperateScriptServerResponseModel.class, + httpResponse.getContent()); + assertTrue(ret.getScriptModels().size() > 0); + } + + @Test + public void deleteScript(int scriptId) throws IOException { + Map params = new HashMap(); + params.put("scriptId", scriptId + ""); + Map properties = new HashMap(); + properties.put(this.AUTH_HEADER_PROPERTY, this.ACCES_TOCKEN_STARTER + + this.accessTocken); + HttpResponse httpResponse = this.httpRequester.sendPost( + this.controllerUrl + "/deleteScript", params, properties); + System.out.println(httpResponse.getContent()); + } +} diff --git a/src/test/java/org/bench4q/master/test/controller/TestBase.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/TestBase.java similarity index 100% rename from src/test/java/org/bench4q/master/test/controller/TestBase.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/TestBase.java diff --git a/src/test/java/org/bench4q/master/test/controller/TestPlanControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/TestPlanControllerTest.java similarity index 100% rename from src/test/java/org/bench4q/master/test/controller/TestPlanControllerTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/TestPlanControllerTest.java diff --git a/src/test/java/org/bench4q/master/test/controller/TestPlanScriptResultControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/TestPlanScriptResultControllerTest.java similarity index 100% rename from src/test/java/org/bench4q/master/test/controller/TestPlanScriptResultControllerTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/TestPlanScriptResultControllerTest.java diff --git a/src/test/java/org/bench4q/master/test/controller/Test_MonitorController.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/Test_MonitorController.java similarity index 97% rename from src/test/java/org/bench4q/master/test/controller/Test_MonitorController.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/Test_MonitorController.java index e0fbadb2..27b7195a 100644 --- a/src/test/java/org/bench4q/master/test/controller/Test_MonitorController.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/Test_MonitorController.java @@ -1,39 +1,39 @@ -package org.bench4q.master.test.controller; - -import static org.junit.Assert.*; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBException; - -import org.bench4q.master.test.TestBase_MakeUpTestPlan; -import org.bench4q.share.communication.HttpRequester; -import org.bench4q.share.communication.HttpRequester.HttpResponse; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.MonitorMemoryResponseModel; -import org.junit.Test; - -public class Test_MonitorController extends TestBase_MakeUpTestPlan { - - @Test - public void testMemoryInfo() throws IOException, JAXBException { - Map params = new HashMap(); - params.put("testPlanRunId", "90293f23-581a-40a2-93e3-f47035c06242"); - params.put("hostName", "127.0.0.1"); - params.put("port", "5556"); - params.put("duationBegin", "0"); - HttpResponse httpResponse = this.httpRequester.sendGet(BASE_URL - + "/monitorController/memorySUTInfo", params, - makeAccessTockenMap(this.getAccessTocken())); - System.out.println(httpResponse.getContent()); - if (HttpRequester.isInvalidResponse(httpResponse)) { - fail("not valid response!"); - } - MonitorMemoryResponseModel memoryResponseModel = (MonitorMemoryResponseModel) MarshalHelper - .unmarshal(MonitorMemoryResponseModel.class, - httpResponse.getContent()); - assertEquals(3, memoryResponseModel.getMemoryModels().size()); - } -} +package org.bench4q.master.test.controller; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBException; + +import org.bench4q.master.test.TestBase_MakeUpTestPlan; +import org.bench4q.share.communication.HttpRequester; +import org.bench4q.share.communication.HttpRequester.HttpResponse; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.MonitorMemoryResponseModel; +import org.junit.Test; + +public class Test_MonitorController extends TestBase_MakeUpTestPlan { + + @Test + public void testMemoryInfo() throws IOException, JAXBException { + Map params = new HashMap(); + params.put("testPlanRunId", "90293f23-581a-40a2-93e3-f47035c06242"); + params.put("hostName", "127.0.0.1"); + params.put("port", "5556"); + params.put("duationBegin", "0"); + HttpResponse httpResponse = this.httpRequester.sendGet(BASE_URL + + "/monitorController/memorySUTInfo", params, + makeAccessTockenMap(this.getAccessTocken())); + System.out.println(httpResponse.getContent()); + if (HttpRequester.isInvalidResponse(httpResponse)) { + fail("not valid response!"); + } + MonitorMemoryResponseModel memoryResponseModel = (MonitorMemoryResponseModel) MarshalHelper + .unmarshal(MonitorMemoryResponseModel.class, + httpResponse.getContent()); + assertEquals(3, memoryResponseModel.getMemoryModels().size()); + } +} diff --git a/src/test/java/org/bench4q/master/test/controller/UserControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/UserControllerTest.java similarity index 97% rename from src/test/java/org/bench4q/master/test/controller/UserControllerTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/UserControllerTest.java index 1d2c2bb0..d4d00607 100644 --- a/src/test/java/org/bench4q/master/test/controller/UserControllerTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/UserControllerTest.java @@ -1,38 +1,38 @@ -package org.bench4q.master.test.controller; - -import java.io.IOException; -import javax.xml.bind.JAXBException; - -import org.bench4q.share.communication.HttpRequester.HttpResponse; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.AuthorizeResponseModel; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class UserControllerTest extends TestBase { - - @Test - public void testNormalAuth() throws IOException, JAXBException { - String urlString = BASE_URL - + "/user/normalAuthorize?userName=chen&password=123"; - HttpResponse httpResponse = this.httpRequester.sendGet(urlString, null, - null); - AuthorizeResponseModel ret = (AuthorizeResponseModel) MarshalHelper - .unmarshal(AuthorizeResponseModel.class, - httpResponse.getContent()); - assertTrue(ret.isSuccess()); - } - - @Test - public void testAdminAuth() throws IOException, JAXBException { - String url = BASE_URL - + "/user/adminAuthorize?userName=chen&password=123"; - HttpResponse httpResponse = this.httpRequester.sendGet(url, null, null); - AuthorizeResponseModel ret = (AuthorizeResponseModel) MarshalHelper - .unmarshal(AuthorizeResponseModel.class, - httpResponse.getContent()); - assertTrue(ret.isSuccess()); - } - -} +package org.bench4q.master.test.controller; + +import java.io.IOException; +import javax.xml.bind.JAXBException; + +import org.bench4q.share.communication.HttpRequester.HttpResponse; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.AuthorizeResponseModel; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class UserControllerTest extends TestBase { + + @Test + public void testNormalAuth() throws IOException, JAXBException { + String urlString = BASE_URL + + "/user/normalAuthorize?userName=chen&password=123"; + HttpResponse httpResponse = this.httpRequester.sendGet(urlString, null, + null); + AuthorizeResponseModel ret = (AuthorizeResponseModel) MarshalHelper + .unmarshal(AuthorizeResponseModel.class, + httpResponse.getContent()); + assertTrue(ret.isSuccess()); + } + + @Test + public void testAdminAuth() throws IOException, JAXBException { + String url = BASE_URL + + "/user/adminAuthorize?userName=chen&password=123"; + HttpResponse httpResponse = this.httpRequester.sendGet(url, null, null); + AuthorizeResponseModel ret = (AuthorizeResponseModel) MarshalHelper + .unmarshal(AuthorizeResponseModel.class, + httpResponse.getContent()); + assertTrue(ret.isSuccess()); + } + +} diff --git a/src/test/java/org/bench4q/master/test/datastatistics/BehaviorsBriefStatisticsTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/BehaviorsBriefStatisticsTest.java similarity index 94% rename from src/test/java/org/bench4q/master/test/datastatistics/BehaviorsBriefStatisticsTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/BehaviorsBriefStatisticsTest.java index 1ec2449a..862ce98b 100644 --- a/src/test/java/org/bench4q/master/test/datastatistics/BehaviorsBriefStatisticsTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/BehaviorsBriefStatisticsTest.java @@ -1,10 +1,10 @@ -package org.bench4q.master.test.datastatistics; - -import org.junit.Test; - -public class BehaviorsBriefStatisticsTest { - @Test - public void testAddNull() { - - } -} +package org.bench4q.master.test.datastatistics; + +import org.junit.Test; + +public class BehaviorsBriefStatisticsTest { + @Test + public void testAddNull() { + + } +} diff --git a/src/test/java/org/bench4q/master/test/datastatistics/ScriptBriefStatisticsTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/ScriptBriefStatisticsTest.java similarity index 100% rename from src/test/java/org/bench4q/master/test/datastatistics/ScriptBriefStatisticsTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/ScriptBriefStatisticsTest.java diff --git a/src/test/java/org/bench4q/master/test/datastatistics/TestPageBrief.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/TestPageBrief.java similarity index 97% rename from src/test/java/org/bench4q/master/test/datastatistics/TestPageBrief.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/TestPageBrief.java index 18a3a655..40ab6a9e 100644 --- a/src/test/java/org/bench4q/master/test/datastatistics/TestPageBrief.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/TestPageBrief.java @@ -1,109 +1,109 @@ -package org.bench4q.master.test.datastatistics; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; - -import org.bench4q.master.testplan.datastatistics.PageBriefStatistics; -import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; -import org.bench4q.share.models.master.statistics.ScriptPageBriefModel; -import org.junit.Test; - -public class TestPageBrief { - private PageBriefStatistics statistics; - - private PageBriefStatistics getStatistics() { - return statistics; - } - - private void setStatistics(PageBriefStatistics statistics) { - this.statistics = statistics; - } - - public TestPageBrief() { - this.setStatistics(new PageBriefStatistics()); - } - - @Test - public void testNull() { - this.getStatistics().add(null); - ScriptPageBriefModel scriptPageBriefModel = (ScriptPageBriefModel) this - .getStatistics().getStatistics(); - assertTrue(scriptPageBriefModel != null); - assertEquals(0, scriptPageBriefModel.getCountFromBegin()); - assertEquals(Long.MIN_VALUE, - scriptPageBriefModel.getMaxResponseTimeFromBegin()); - assertEquals(Long.MAX_VALUE, - scriptPageBriefModel.getMinResponseTimeFromBegin()); - assertEquals(0, scriptPageBriefModel.getAverageResponseTimeThisTime()); - assertEquals(0, scriptPageBriefModel.getLatestResponseTime()); - } - - @Test - public void testOneWithZeroCountThisTimeForAverage() { - this.getStatistics().add( - buildAgentPageBriefModel(1, 1, 0, 200, 200, 200, 190, 0)); - ScriptPageBriefModel pageBriefModel = (ScriptPageBriefModel) this - .getStatistics().getStatistics(); - assertEquals(0, pageBriefModel.getAverageResponseTimeThisTime()); - assertEquals(1, pageBriefModel.getCountFromBegin()); - assertEquals(200, pageBriefModel.getLatestResponseTime()); - assertEquals(200, pageBriefModel.getMaxResponseTimeFromBegin()); - assertEquals(200, pageBriefModel.getMinResponseTimeFromBegin()); - assertEquals(0, pageBriefModel.getThroughputThisTime()); - } - - @Test - public void testTwoForCountFromBegin() { - this.testOneWithZeroCountThisTimeForAverage(); - this.getStatistics().add( - buildAgentPageBriefModel(1, 2, 0, 200, 200, 200, 190, 200)); - ScriptPageBriefModel pageBriefModel = (ScriptPageBriefModel) this - .getStatistics().getStatistics(); - assertEquals(0, pageBriefModel.getAverageResponseTimeThisTime()); - assertEquals(2, pageBriefModel.getCountFromBegin()); - } - - @Test - public void testThree() { - for (AgentPageBriefModel agentPageBriefModel : makePageBriefModels(3)) { - this.getStatistics().add(agentPageBriefModel); - } - ScriptPageBriefModel scriptPageBriefModel = (ScriptPageBriefModel) this - .getStatistics().getStatistics(); - assertEquals(9, scriptPageBriefModel.getCountFromBegin()); - assertEquals(220, scriptPageBriefModel.getLatestResponseTime()); - assertEquals(220, scriptPageBriefModel.getMaxResponseTimeFromBegin()); - assertEquals(180, scriptPageBriefModel.getMinResponseTimeFromBegin()); - assertEquals(0, scriptPageBriefModel.getThroughputThisTime()); - assertEquals(1230 / 6, - scriptPageBriefModel.getAverageResponseTimeThisTime()); - } - - private List makePageBriefModels(int count) { - List result = new ArrayList(); - for (int i = 0; i < count; i++) { - result.add(buildAgentPageBriefModel(2, i + 2, i + 1, 200 + 10 * i, - 200 + 10 * i, 200 - 10 * i, 200 + 20 * i, 400 + 10 * i)); - } - return result; - } - - private AgentPageBriefModel buildAgentPageBriefModel(int pageId, - long countFromBegin, long countThisTime, - long latestTimeResponseTime, long maxResponseTimeFromBegin, - long minResponseTimeFromBegin, long timeFrame, - long totalResponseTimeThisTime) { - AgentPageBriefModel result = new AgentPageBriefModel(); - result.setPageId(pageId); - result.setCountFromBegin(countFromBegin); - result.setCountThisTime(countThisTime); - result.setLatestResponseTime(latestTimeResponseTime); - result.setMaxResponseTimeFromBegin(maxResponseTimeFromBegin); - result.setMinResponseTimeFromBegin(minResponseTimeFromBegin); - result.setTimeFrame(timeFrame); - result.setTotalResponseTimeThisTime(totalResponseTimeThisTime); - return result; - } -} +package org.bench4q.master.test.datastatistics; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.bench4q.master.testplan.datastatistics.PageBriefStatistics; +import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; +import org.bench4q.share.models.master.statistics.ScriptPageBriefModel; +import org.junit.Test; + +public class TestPageBrief { + private PageBriefStatistics statistics; + + private PageBriefStatistics getStatistics() { + return statistics; + } + + private void setStatistics(PageBriefStatistics statistics) { + this.statistics = statistics; + } + + public TestPageBrief() { + this.setStatistics(new PageBriefStatistics()); + } + + @Test + public void testNull() { + this.getStatistics().add(null); + ScriptPageBriefModel scriptPageBriefModel = (ScriptPageBriefModel) this + .getStatistics().getStatistics(); + assertTrue(scriptPageBriefModel != null); + assertEquals(0, scriptPageBriefModel.getCountFromBegin()); + assertEquals(Long.MIN_VALUE, + scriptPageBriefModel.getMaxResponseTimeFromBegin()); + assertEquals(Long.MAX_VALUE, + scriptPageBriefModel.getMinResponseTimeFromBegin()); + assertEquals(0, scriptPageBriefModel.getAverageResponseTimeThisTime()); + assertEquals(0, scriptPageBriefModel.getLatestResponseTime()); + } + + @Test + public void testOneWithZeroCountThisTimeForAverage() { + this.getStatistics().add( + buildAgentPageBriefModel(1, 1, 0, 200, 200, 200, 190, 0)); + ScriptPageBriefModel pageBriefModel = (ScriptPageBriefModel) this + .getStatistics().getStatistics(); + assertEquals(0, pageBriefModel.getAverageResponseTimeThisTime()); + assertEquals(1, pageBriefModel.getCountFromBegin()); + assertEquals(200, pageBriefModel.getLatestResponseTime()); + assertEquals(200, pageBriefModel.getMaxResponseTimeFromBegin()); + assertEquals(200, pageBriefModel.getMinResponseTimeFromBegin()); + assertEquals(0, pageBriefModel.getThroughputThisTime()); + } + + @Test + public void testTwoForCountFromBegin() { + this.testOneWithZeroCountThisTimeForAverage(); + this.getStatistics().add( + buildAgentPageBriefModel(1, 2, 0, 200, 200, 200, 190, 200)); + ScriptPageBriefModel pageBriefModel = (ScriptPageBriefModel) this + .getStatistics().getStatistics(); + assertEquals(0, pageBriefModel.getAverageResponseTimeThisTime()); + assertEquals(2, pageBriefModel.getCountFromBegin()); + } + + @Test + public void testThree() { + for (AgentPageBriefModel agentPageBriefModel : makePageBriefModels(3)) { + this.getStatistics().add(agentPageBriefModel); + } + ScriptPageBriefModel scriptPageBriefModel = (ScriptPageBriefModel) this + .getStatistics().getStatistics(); + assertEquals(9, scriptPageBriefModel.getCountFromBegin()); + assertEquals(220, scriptPageBriefModel.getLatestResponseTime()); + assertEquals(220, scriptPageBriefModel.getMaxResponseTimeFromBegin()); + assertEquals(180, scriptPageBriefModel.getMinResponseTimeFromBegin()); + assertEquals(0, scriptPageBriefModel.getThroughputThisTime()); + assertEquals(1230 / 6, + scriptPageBriefModel.getAverageResponseTimeThisTime()); + } + + private List makePageBriefModels(int count) { + List result = new ArrayList(); + for (int i = 0; i < count; i++) { + result.add(buildAgentPageBriefModel(2, i + 2, i + 1, 200 + 10 * i, + 200 + 10 * i, 200 - 10 * i, 200 + 20 * i, 400 + 10 * i)); + } + return result; + } + + private AgentPageBriefModel buildAgentPageBriefModel(int pageId, + long countFromBegin, long countThisTime, + long latestTimeResponseTime, long maxResponseTimeFromBegin, + long minResponseTimeFromBegin, long timeFrame, + long totalResponseTimeThisTime) { + AgentPageBriefModel result = new AgentPageBriefModel(); + result.setPageId(pageId); + result.setCountFromBegin(countFromBegin); + result.setCountThisTime(countThisTime); + result.setLatestResponseTime(latestTimeResponseTime); + result.setMaxResponseTimeFromBegin(maxResponseTimeFromBegin); + result.setMinResponseTimeFromBegin(minResponseTimeFromBegin); + result.setTimeFrame(timeFrame); + result.setTotalResponseTimeThisTime(totalResponseTimeThisTime); + return result; + } +} diff --git a/src/test/java/org/bench4q/master/test/datastatistics/Test_PagesBrief.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/Test_PagesBrief.java similarity index 97% rename from src/test/java/org/bench4q/master/test/datastatistics/Test_PagesBrief.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/Test_PagesBrief.java index ca059ba0..0bdc4f0f 100644 --- a/src/test/java/org/bench4q/master/test/datastatistics/Test_PagesBrief.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/datastatistics/Test_PagesBrief.java @@ -1,95 +1,95 @@ -package org.bench4q.master.test.datastatistics; - -import java.util.ArrayList; -import java.util.List; - -import org.bench4q.master.testplan.datastatistics.PagesBriefStatistics; -import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; -import org.bench4q.share.models.agent.statistics.AgentPagesBriefModel; -import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel; -import org.junit.Test; -import static org.junit.Assert.*; - -public class Test_PagesBrief { - private PagesBriefStatistics pagesBriefStatistics = new PagesBriefStatistics(); - - @Test - public void testAddNull() { - pagesBriefStatistics.add(null); - ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) pagesBriefStatistics - .getStatistics(); - assertEquals(0, scriptPagesBriefModel.getScriptPageBriefModels().size()); - } - - @Test - public void testAddOneWithOnePage() { - pagesBriefStatistics.add(createAPagesBriefModel(1)); - ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) pagesBriefStatistics - .getStatistics(); - assertNotNull(scriptPagesBriefModel); - assertEquals(220, - scriptPagesBriefModel.getScriptPageBriefModels().get(0) - .getMaxResponseTimeFromBegin()); - } - - private AgentPagesBriefModel createAPagesBriefModel(int size) { - AgentPagesBriefModel agentPagesBriefModel = new AgentPagesBriefModel(); - List pageBriefModels = new ArrayList(); - for (int i = 0; i < size; i++) { - AgentPageBriefModel pageBriefModel = new AgentPageBriefModel(); - pageBriefModel.setCountFromBegin(100); - pageBriefModel.setCountThisTime(20); - pageBriefModel.setLatestResponseTime(200); - pageBriefModel.setMaxResponseTimeFromBegin(220); - pageBriefModel.setMinResponseTimeFromBegin(200); - pageBriefModel.setPageId(i); - pageBriefModel.setTimeFrame(100); - pageBriefModel.setTotalResponseTimeThisTime(20000); - pageBriefModels.add(pageBriefModel); - } - agentPagesBriefModel.setPageBriefModels(pageBriefModels); - return agentPagesBriefModel; - } - - @Test - public void testAddOneWithTwoPages() { - this.pagesBriefStatistics.add(createAPagesBriefModel(2)); - ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) this.pagesBriefStatistics - .getStatistics(); - assertEquals(2, scriptPagesBriefModel.getScriptPageBriefModels().size()); - assertNotNull(scriptPagesBriefModel.getScriptPageBriefModels().get(0)); - assertEquals(220, - scriptPagesBriefModel.getScriptPageBriefModels().get(0) - .getMaxResponseTimeFromBegin()); - assertNotNull(scriptPagesBriefModel.getScriptPageBriefModels().get(1)); - assertEquals(220, - scriptPagesBriefModel.getScriptPageBriefModels().get(1) - .getMaxResponseTimeFromBegin()); - } - - @Test - public void testAddTwoWithOnePage() { - this.pagesBriefStatistics.add(createAPagesBriefModel(1)); - this.pagesBriefStatistics.add(createAPagesBriefModel(1)); - ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) this.pagesBriefStatistics - .getStatistics(); - assertNotNull(scriptPagesBriefModel.getScriptPageBriefModels().get(0)); - assertEquals(220, - scriptPagesBriefModel.getScriptPageBriefModels().get(0) - .getMaxResponseTimeFromBegin()); - assertEquals(1, scriptPagesBriefModel.getScriptPageBriefModels().size()); - } - - @Test - public void testAddTwoWithTwoPages() { - this.pagesBriefStatistics.add(createAPagesBriefModel(2)); - this.pagesBriefStatistics.add(createAPagesBriefModel(2)); - ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) this.pagesBriefStatistics - .getStatistics(); - assertNotNull(scriptPagesBriefModel.getScriptPageBriefModels().get(0)); - assertEquals(220, - scriptPagesBriefModel.getScriptPageBriefModels().get(0) - .getMaxResponseTimeFromBegin()); - assertEquals(2, scriptPagesBriefModel.getScriptPageBriefModels().size()); - } -} +package org.bench4q.master.test.datastatistics; + +import java.util.ArrayList; +import java.util.List; + +import org.bench4q.master.testplan.datastatistics.PagesBriefStatistics; +import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; +import org.bench4q.share.models.agent.statistics.AgentPagesBriefModel; +import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel; +import org.junit.Test; +import static org.junit.Assert.*; + +public class Test_PagesBrief { + private PagesBriefStatistics pagesBriefStatistics = new PagesBriefStatistics(); + + @Test + public void testAddNull() { + pagesBriefStatistics.add(null); + ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) pagesBriefStatistics + .getStatistics(); + assertEquals(0, scriptPagesBriefModel.getScriptPageBriefModels().size()); + } + + @Test + public void testAddOneWithOnePage() { + pagesBriefStatistics.add(createAPagesBriefModel(1)); + ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) pagesBriefStatistics + .getStatistics(); + assertNotNull(scriptPagesBriefModel); + assertEquals(220, + scriptPagesBriefModel.getScriptPageBriefModels().get(0) + .getMaxResponseTimeFromBegin()); + } + + private AgentPagesBriefModel createAPagesBriefModel(int size) { + AgentPagesBriefModel agentPagesBriefModel = new AgentPagesBriefModel(); + List pageBriefModels = new ArrayList(); + for (int i = 0; i < size; i++) { + AgentPageBriefModel pageBriefModel = new AgentPageBriefModel(); + pageBriefModel.setCountFromBegin(100); + pageBriefModel.setCountThisTime(20); + pageBriefModel.setLatestResponseTime(200); + pageBriefModel.setMaxResponseTimeFromBegin(220); + pageBriefModel.setMinResponseTimeFromBegin(200); + pageBriefModel.setPageId(i); + pageBriefModel.setTimeFrame(100); + pageBriefModel.setTotalResponseTimeThisTime(20000); + pageBriefModels.add(pageBriefModel); + } + agentPagesBriefModel.setPageBriefModels(pageBriefModels); + return agentPagesBriefModel; + } + + @Test + public void testAddOneWithTwoPages() { + this.pagesBriefStatistics.add(createAPagesBriefModel(2)); + ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) this.pagesBriefStatistics + .getStatistics(); + assertEquals(2, scriptPagesBriefModel.getScriptPageBriefModels().size()); + assertNotNull(scriptPagesBriefModel.getScriptPageBriefModels().get(0)); + assertEquals(220, + scriptPagesBriefModel.getScriptPageBriefModels().get(0) + .getMaxResponseTimeFromBegin()); + assertNotNull(scriptPagesBriefModel.getScriptPageBriefModels().get(1)); + assertEquals(220, + scriptPagesBriefModel.getScriptPageBriefModels().get(1) + .getMaxResponseTimeFromBegin()); + } + + @Test + public void testAddTwoWithOnePage() { + this.pagesBriefStatistics.add(createAPagesBriefModel(1)); + this.pagesBriefStatistics.add(createAPagesBriefModel(1)); + ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) this.pagesBriefStatistics + .getStatistics(); + assertNotNull(scriptPagesBriefModel.getScriptPageBriefModels().get(0)); + assertEquals(220, + scriptPagesBriefModel.getScriptPageBriefModels().get(0) + .getMaxResponseTimeFromBegin()); + assertEquals(1, scriptPagesBriefModel.getScriptPageBriefModels().size()); + } + + @Test + public void testAddTwoWithTwoPages() { + this.pagesBriefStatistics.add(createAPagesBriefModel(2)); + this.pagesBriefStatistics.add(createAPagesBriefModel(2)); + ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) this.pagesBriefStatistics + .getStatistics(); + assertNotNull(scriptPagesBriefModel.getScriptPageBriefModels().get(0)); + assertEquals(220, + scriptPagesBriefModel.getScriptPageBriefModels().get(0) + .getMaxResponseTimeFromBegin()); + assertEquals(2, scriptPagesBriefModel.getScriptPageBriefModels().size()); + } +} diff --git a/src/test/java/org/bench4q/master/test/domain/Test_HighAvailable.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_HighAvailable.java similarity index 100% rename from src/test/java/org/bench4q/master/test/domain/Test_HighAvailable.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_HighAvailable.java diff --git a/src/test/java/org/bench4q/master/test/domain/Test_Monitor.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_Monitor.java similarity index 96% rename from src/test/java/org/bench4q/master/test/domain/Test_Monitor.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_Monitor.java index fcca43ef..03fc0772 100644 --- a/src/test/java/org/bench4q/master/test/domain/Test_Monitor.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_Monitor.java @@ -1,34 +1,34 @@ -package org.bench4q.master.test.domain; - -import static org.junit.Assert.*; - -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.domain.entity.TestPlan; -import org.bench4q.master.test.TestBase_MakeUpTestPlan; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:service-test-context.xml" }) -public class Test_Monitor extends TestBase_MakeUpTestPlan { - - @Before - public void prepare() { - prepareForTestPlanRunning(); - submitATestPlanWithOneScript(); - } - - @Test - public void testDoAfterRun() { - TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy( - getTestPlanRunIdUuid()); - assertEquals(1, testPlan.getMonitors().size()); - for (Monitor monitor : testPlan.getMonitors()) { - monitor.doAfterRun(); - } - } - -} +package org.bench4q.master.test.domain; + +import static org.junit.Assert.*; + +import org.bench4q.master.domain.entity.Monitor; +import org.bench4q.master.domain.entity.TestPlan; +import org.bench4q.master.test.TestBase_MakeUpTestPlan; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:service-test-context.xml" }) +public class Test_Monitor extends TestBase_MakeUpTestPlan { + + @Before + public void prepare() { + prepareForTestPlanRunning(); + submitATestPlanWithOneScript(); + } + + @Test + public void testDoAfterRun() { + TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy( + getTestPlanRunIdUuid()); + assertEquals(1, testPlan.getMonitors().size()); + for (Monitor monitor : testPlan.getMonitors()) { + monitor.doAfterRun(); + } + } + +} diff --git a/src/test/java/org/bench4q/master/test/domain/Test_RunningScriptSampler.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_RunningScriptSampler.java similarity index 100% rename from src/test/java/org/bench4q/master/test/domain/Test_RunningScriptSampler.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_RunningScriptSampler.java diff --git a/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorResultSave.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorResultSave.java similarity index 96% rename from src/test/java/org/bench4q/master/test/domain/Test_TestMonitorResultSave.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorResultSave.java index faff3104..c6848362 100644 --- a/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorResultSave.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorResultSave.java @@ -1,99 +1,99 @@ -package org.bench4q.master.test.domain; - -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.domain.entity.TestPlan; -import org.bench4q.master.domain.factory.TestPlanFactory; -import org.bench4q.master.domain.testplan.TestMoniorResultSave; -import org.bench4q.master.domain.testplan.TestMonitorSampler; -import org.bench4q.master.test.TestBase_MakeUpTestPlan; -import org.bench4q.share.models.monitor.MonitorMain; -import org.junit.After; -import org.junit.Assert; -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 = { "classpath:service-test-context.xml" }) -public class Test_TestMonitorResultSave extends TestBase_MakeUpTestPlan { - - private TestMoniorResultSave testMoniorResultSave; - private UUID testPlanRunId; - private TestMonitorSampler testMonitorSampler; - private TestPlanFactory testPlanFactory; - - public TestPlanFactory getTestPlanFactory() { - return testPlanFactory; - } - - @Autowired - public void setTestPlanFactory(TestPlanFactory testPlanFactory) { - this.testPlanFactory = testPlanFactory; - } - - public TestMoniorResultSave getTestMoniorResultSave() { - return testMoniorResultSave; - } - - @Autowired - public void setTestMoniorResultSave( - TestMoniorResultSave testMoniorResultSave) { - this.testMoniorResultSave = testMoniorResultSave; - } - - public TestMonitorSampler getTestMonitorSampler() { - return testMonitorSampler; - } - - @Autowired - public void setTestMonitorSampler(TestMonitorSampler testMonitorSampler) { - this.testMonitorSampler = testMonitorSampler; - } - - @Before - public void setUp() { - prepareForTestPlanRunning(); - this.submitATestPlanWithOneScript(); - TestPlan testPlan = fetchTestPlan(); - this.testPlanRunId = UUID.fromString(testPlan.getTestPlanRunId()); - testPlan.run(); - this.getTestPlanRepository().updateEntity(testPlan); - } - - @Test - public void testDoSaveResult() { - TestPlan testPlan = fetchTestPlan(); - Monitor monitor = testPlan.getMonitors().iterator().next(); - int beforeMonitorResultSize = monitor.getResults().size(); - MonitorMain monitorMain = monitor.getTestMonitorSampler() - .getMonitorResult(monitor.getHostName(), monitor.getPort()); - Assert.assertNotNull(monitorMain); - - assertTrue(this.getTestMoniorResultSave().saveMonitorResult( - this.testPlanRunId, monitorMain, monitorMain.getSamplingTime(), - monitor)); - testPlan = fetchTestPlan(); - monitor = testPlan.getMonitors().iterator().next(); - Assert.assertEquals(beforeMonitorResultSize + 5, monitor.getResults() - .size()); - - } - - @After - public void clean() { - cleanUpForTestPlanRunning(); - } - - private TestPlan fetchTestPlan() { - return this.getTestPlanRepository().getTestPlanBy( - getTestPlanRunIdUuid()); - } - -} +package org.bench4q.master.test.domain; + +import static org.junit.Assert.assertTrue; + +import java.util.UUID; + +import org.bench4q.master.domain.entity.Monitor; +import org.bench4q.master.domain.entity.TestPlan; +import org.bench4q.master.domain.factory.TestPlanFactory; +import org.bench4q.master.domain.testplan.TestMoniorResultSave; +import org.bench4q.master.domain.testplan.TestMonitorSampler; +import org.bench4q.master.test.TestBase_MakeUpTestPlan; +import org.bench4q.share.models.monitor.MonitorMain; +import org.junit.After; +import org.junit.Assert; +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 = { "classpath:service-test-context.xml" }) +public class Test_TestMonitorResultSave extends TestBase_MakeUpTestPlan { + + private TestMoniorResultSave testMoniorResultSave; + private UUID testPlanRunId; + private TestMonitorSampler testMonitorSampler; + private TestPlanFactory testPlanFactory; + + public TestPlanFactory getTestPlanFactory() { + return testPlanFactory; + } + + @Autowired + public void setTestPlanFactory(TestPlanFactory testPlanFactory) { + this.testPlanFactory = testPlanFactory; + } + + public TestMoniorResultSave getTestMoniorResultSave() { + return testMoniorResultSave; + } + + @Autowired + public void setTestMoniorResultSave( + TestMoniorResultSave testMoniorResultSave) { + this.testMoniorResultSave = testMoniorResultSave; + } + + public TestMonitorSampler getTestMonitorSampler() { + return testMonitorSampler; + } + + @Autowired + public void setTestMonitorSampler(TestMonitorSampler testMonitorSampler) { + this.testMonitorSampler = testMonitorSampler; + } + + @Before + public void setUp() { + prepareForTestPlanRunning(); + this.submitATestPlanWithOneScript(); + TestPlan testPlan = fetchTestPlan(); + this.testPlanRunId = UUID.fromString(testPlan.getTestPlanRunId()); + testPlan.run(); + this.getTestPlanRepository().updateEntity(testPlan); + } + + @Test + public void testDoSaveResult() { + TestPlan testPlan = fetchTestPlan(); + Monitor monitor = testPlan.getMonitors().iterator().next(); + int beforeMonitorResultSize = monitor.getResults().size(); + MonitorMain monitorMain = monitor.getTestMonitorSampler() + .getMonitorResult(monitor.getHostName(), monitor.getPort()); + Assert.assertNotNull(monitorMain); + + assertTrue(this.getTestMoniorResultSave().saveMonitorResult( + this.testPlanRunId, monitorMain, monitorMain.getSamplingTime(), + monitor)); + testPlan = fetchTestPlan(); + monitor = testPlan.getMonitors().iterator().next(); + Assert.assertEquals(beforeMonitorResultSize + 5, monitor.getResults() + .size()); + + } + + @After + public void clean() { + cleanUpForTestPlanRunning(); + } + + private TestPlan fetchTestPlan() { + return this.getTestPlanRepository().getTestPlanBy( + getTestPlanRunIdUuid()); + } + +} diff --git a/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorSampler.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorSampler.java similarity index 96% rename from src/test/java/org/bench4q/master/test/domain/Test_TestMonitorSampler.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorSampler.java index 0faf5851..3d045205 100644 --- a/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorSampler.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestMonitorSampler.java @@ -1,53 +1,53 @@ -package org.bench4q.master.test.domain; - -import static org.junit.Assert.assertTrue; -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.domain.testplan.TestMonitorSampler; -import org.bench4q.master.test.TestBase_MakeUpTestPlan; -import org.bench4q.share.models.monitor.MonitorMain; -import org.junit.After; -import org.junit.Assert; -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 = { "classpath:service-test-context.xml" }) -public class Test_TestMonitorSampler extends TestBase_MakeUpTestPlan { - - private TestMonitorSampler testMonitorSampler; - private Monitor monitor; - - public TestMonitorSampler getTestMonitorSampler() { - return testMonitorSampler; - } - - @Autowired - public void setTestMonitorSampler(TestMonitorSampler testMonitorSampler) { - this.testMonitorSampler = testMonitorSampler; - } - - @Before - public void setUp() { - this.monitor = new Monitor(); - monitor.setHostName("127.0.0.1"); - monitor.setPort(5556); - } - - @Test - public void testDoSaveResult() { - assertTrue(this.monitor.getHostName().equals("127.0.0.1")); - assertTrue(this.monitor.getPort() == 5556); - MonitorMain monitorMain = this.testMonitorSampler.getMonitorResult( - monitor.getHostName(), monitor.getPort()); - Assert.assertNotNull(monitorMain); - } - - @After - public void clean() { - } - -} +package org.bench4q.master.test.domain; + +import static org.junit.Assert.assertTrue; +import org.bench4q.master.domain.entity.Monitor; +import org.bench4q.master.domain.testplan.TestMonitorSampler; +import org.bench4q.master.test.TestBase_MakeUpTestPlan; +import org.bench4q.share.models.monitor.MonitorMain; +import org.junit.After; +import org.junit.Assert; +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 = { "classpath:service-test-context.xml" }) +public class Test_TestMonitorSampler extends TestBase_MakeUpTestPlan { + + private TestMonitorSampler testMonitorSampler; + private Monitor monitor; + + public TestMonitorSampler getTestMonitorSampler() { + return testMonitorSampler; + } + + @Autowired + public void setTestMonitorSampler(TestMonitorSampler testMonitorSampler) { + this.testMonitorSampler = testMonitorSampler; + } + + @Before + public void setUp() { + this.monitor = new Monitor(); + monitor.setHostName("127.0.0.1"); + monitor.setPort(5556); + } + + @Test + public void testDoSaveResult() { + assertTrue(this.monitor.getHostName().equals("127.0.0.1")); + assertTrue(this.monitor.getPort() == 5556); + MonitorMain monitorMain = this.testMonitorSampler.getMonitorResult( + monitor.getHostName(), monitor.getPort()); + Assert.assertNotNull(monitorMain); + } + + @After + public void clean() { + } + +} diff --git a/src/test/java/org/bench4q/master/test/domain/Test_TestPlan.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestPlan.java similarity index 100% rename from src/test/java/org/bench4q/master/test/domain/Test_TestPlan.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestPlan.java diff --git a/src/test/java/org/bench4q/master/test/domain/Test_TestScriptResultSave.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestScriptResultSave.java similarity index 96% rename from src/test/java/org/bench4q/master/test/domain/Test_TestScriptResultSave.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestScriptResultSave.java index e557ed67..8120d715 100644 --- a/src/test/java/org/bench4q/master/test/domain/Test_TestScriptResultSave.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/domain/Test_TestScriptResultSave.java @@ -1,71 +1,71 @@ -package org.bench4q.master.test.domain; - -import static org.junit.Assert.*; -import java.util.UUID; -import org.bench4q.master.domain.entity.TestPlan; -import org.bench4q.master.domain.entity.TestPlanScript; -import org.bench4q.master.domain.testplan.RunningScriptSampler; -import org.bench4q.master.domain.testplan.TestScriptResultSave; -import org.bench4q.master.test.TestBase_MakeUpTestPlan; -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 = { "classpath:service-test-context.xml" }) -public class Test_TestScriptResultSave extends TestBase_MakeUpTestPlan { - - private TestScriptResultSave testScriptResultSave; - private RunningScriptSampler runningScriptSampler; - private UUID testPlanRunId; - private int scriptId; - - public TestScriptResultSave getTestScriptResultSave() { - return testScriptResultSave; - } - - @Autowired - public void setTestScriptResultSave( - TestScriptResultSave testScriptResultSave) { - this.testScriptResultSave = testScriptResultSave; - } - - @Before - public void setUp() { - prepareForTestPlanRunning(); - this.submitATestPlanWithOneScript(); - TestPlan testPlan = fetchTestPlan(); - this.testPlanRunId = UUID.fromString(testPlan.getTestPlanRunId()); - testPlan.run(); - this.getTestPlanRepository().updateEntity(testPlan); - TestPlan testPlanInRunning = fetchTestPlan(); - TestPlanScript testPlanScript = testPlanInRunning - .extracSpecifiedScript(getScriptId()); - this.scriptId = getScriptId(); - this.runningScriptSampler = new RunningScriptSampler( - testPlanScript.getRunningAgentsDB()); - } - - @Test - public void testDoSaveResult() { - assertTrue(this.getTestScriptResultSave().doSaveResult( - this.testPlanRunId, this.scriptId, - this.runningScriptSampler.getScriptBrief(), - this.runningScriptSampler.getScriptBrief().getSamplingTime())); - } - - @After - public void clean() { - cleanUpForTestPlanRunning(); - } - - private TestPlan fetchTestPlan() { - return this.getTestPlanRepository().getTestPlanBy( - getTestPlanRunIdUuid()); - } - -} +package org.bench4q.master.test.domain; + +import static org.junit.Assert.*; +import java.util.UUID; +import org.bench4q.master.domain.entity.TestPlan; +import org.bench4q.master.domain.entity.TestPlanScript; +import org.bench4q.master.domain.testplan.RunningScriptSampler; +import org.bench4q.master.domain.testplan.TestScriptResultSave; +import org.bench4q.master.test.TestBase_MakeUpTestPlan; +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 = { "classpath:service-test-context.xml" }) +public class Test_TestScriptResultSave extends TestBase_MakeUpTestPlan { + + private TestScriptResultSave testScriptResultSave; + private RunningScriptSampler runningScriptSampler; + private UUID testPlanRunId; + private int scriptId; + + public TestScriptResultSave getTestScriptResultSave() { + return testScriptResultSave; + } + + @Autowired + public void setTestScriptResultSave( + TestScriptResultSave testScriptResultSave) { + this.testScriptResultSave = testScriptResultSave; + } + + @Before + public void setUp() { + prepareForTestPlanRunning(); + this.submitATestPlanWithOneScript(); + TestPlan testPlan = fetchTestPlan(); + this.testPlanRunId = UUID.fromString(testPlan.getTestPlanRunId()); + testPlan.run(); + this.getTestPlanRepository().updateEntity(testPlan); + TestPlan testPlanInRunning = fetchTestPlan(); + TestPlanScript testPlanScript = testPlanInRunning + .extracSpecifiedScript(getScriptId()); + this.scriptId = getScriptId(); + this.runningScriptSampler = new RunningScriptSampler( + testPlanScript.getRunningAgentsDB()); + } + + @Test + public void testDoSaveResult() { + assertTrue(this.getTestScriptResultSave().doSaveResult( + this.testPlanRunId, this.scriptId, + this.runningScriptSampler.getScriptBrief(), + this.runningScriptSampler.getScriptBrief().getSamplingTime())); + } + + @After + public void clean() { + cleanUpForTestPlanRunning(); + } + + private TestPlan fetchTestPlan() { + return this.getTestPlanRepository().getTestPlanBy( + getTestPlanRunIdUuid()); + } + +} diff --git a/src/test/java/org/bench4q/master/test/recordscript/ContentDecoderTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/ContentDecoderTest.java similarity index 96% rename from src/test/java/org/bench4q/master/test/recordscript/ContentDecoderTest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/ContentDecoderTest.java index 52eb508a..28cb1768 100644 --- a/src/test/java/org/bench4q/master/test/recordscript/ContentDecoderTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/ContentDecoderTest.java @@ -1,40 +1,40 @@ -package org.bench4q.master.test.recordscript; - -import static org.junit.Assert.*; - -import org.bench4q.master.scriptrecord.httpcapture.generator.ContentDecoder; -import org.bench4q.master.scriptrecord.httpcapture.generator.GzipDecoder; -import org.junit.Test; - -public class ContentDecoderTest { - - @Test - public void testWithNullEncoding() { - ContentDecoder contentDecoder = ContentDecoder.createDecoder(null); - assertTrue(contentDecoder instanceof ContentDecoder); - } - - @Test - public void testWithLowerCaseEncoding() { - ContentDecoder contentDecoder = ContentDecoder.createDecoder("gzip"); - assertTrue(contentDecoder instanceof GzipDecoder); - } - - @Test - public void testWithUpperCaseEncoding() { - ContentDecoder contentDecoder = ContentDecoder.createDecoder("GZIP"); - assertTrue(contentDecoder instanceof GzipDecoder); - } - - @Test - public void testWithMixCaseEncoding() { - ContentDecoder contentDecoder = ContentDecoder.createDecoder("Gzip"); - assertTrue(contentDecoder instanceof GzipDecoder); - } - - @Test - public void testWithNotSupportedEncoding() { - ContentDecoder contentDecoder = ContentDecoder.createDecoder("deflate"); - assertTrue(contentDecoder instanceof ContentDecoder); - } -} +package org.bench4q.master.test.recordscript; + +import static org.junit.Assert.*; + +import org.bench4q.master.scriptrecord.httpcapture.generator.ContentDecoder; +import org.bench4q.master.scriptrecord.httpcapture.generator.GzipDecoder; +import org.junit.Test; + +public class ContentDecoderTest { + + @Test + public void testWithNullEncoding() { + ContentDecoder contentDecoder = ContentDecoder.createDecoder(null); + assertTrue(contentDecoder instanceof ContentDecoder); + } + + @Test + public void testWithLowerCaseEncoding() { + ContentDecoder contentDecoder = ContentDecoder.createDecoder("gzip"); + assertTrue(contentDecoder instanceof GzipDecoder); + } + + @Test + public void testWithUpperCaseEncoding() { + ContentDecoder contentDecoder = ContentDecoder.createDecoder("GZIP"); + assertTrue(contentDecoder instanceof GzipDecoder); + } + + @Test + public void testWithMixCaseEncoding() { + ContentDecoder contentDecoder = ContentDecoder.createDecoder("Gzip"); + assertTrue(contentDecoder instanceof GzipDecoder); + } + + @Test + public void testWithNotSupportedEncoding() { + ContentDecoder contentDecoder = ContentDecoder.createDecoder("deflate"); + assertTrue(contentDecoder instanceof ContentDecoder); + } +} diff --git a/src/test/java/org/bench4q/master/test/recordscript/TestBench4qTestScriptAdapter.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestBench4qTestScriptAdapter.java similarity index 100% rename from src/test/java/org/bench4q/master/test/recordscript/TestBench4qTestScriptAdapter.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestBench4qTestScriptAdapter.java diff --git a/src/test/java/org/bench4q/master/test/recordscript/TestDomGenerator.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestDomGenerator.java similarity index 100% rename from src/test/java/org/bench4q/master/test/recordscript/TestDomGenerator.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestDomGenerator.java diff --git a/src/test/java/org/bench4q/master/test/recordscript/TestHttpRequestHeader.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestHttpRequestHeader.java similarity index 100% rename from src/test/java/org/bench4q/master/test/recordscript/TestHttpRequestHeader.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestHttpRequestHeader.java diff --git a/src/test/java/org/bench4q/master/test/recordscript/TestParentRequest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestParentRequest.java similarity index 100% rename from src/test/java/org/bench4q/master/test/recordscript/TestParentRequest.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestParentRequest.java diff --git a/src/test/java/org/bench4q/master/test/recordscript/TestResponseParser.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestResponseParser.java similarity index 100% rename from src/test/java/org/bench4q/master/test/recordscript/TestResponseParser.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/TestResponseParser.java diff --git a/src/test/java/org/bench4q/master/test/recordscript/Test_Bench4QCodeGenerator.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/Test_Bench4QCodeGenerator.java similarity index 100% rename from src/test/java/org/bench4q/master/test/recordscript/Test_Bench4QCodeGenerator.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/Test_Bench4QCodeGenerator.java diff --git a/src/test/java/org/bench4q/master/test/recordscript/Test_ParamParser.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/Test_ParamParser.java similarity index 100% rename from src/test/java/org/bench4q/master/test/recordscript/Test_ParamParser.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/Test_ParamParser.java diff --git a/src/test/java/org/bench4q/master/test/recordscript/testcase.html b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/testcase.html similarity index 96% rename from src/test/java/org/bench4q/master/test/recordscript/testcase.html rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/testcase.html index 2592d42a..62334744 100644 --- a/src/test/java/org/bench4q/master/test/recordscript/testcase.html +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/recordscript/testcase.html @@ -1,17 +1,17 @@ - - - Bench4Q Test Case - - - - - - No this one - No this one - No this one - - - - - - + + + Bench4Q Test Case + + + + + + No this one + No this one + No this one + + + + + + diff --git a/src/test/java/org/bench4q/master/test/repository/Test_AgentRepository.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_AgentRepository.java similarity index 100% rename from src/test/java/org/bench4q/master/test/repository/Test_AgentRepository.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_AgentRepository.java diff --git a/src/test/java/org/bench4q/master/test/repository/Test_PluginRepository.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_PluginRepository.java similarity index 96% rename from src/test/java/org/bench4q/master/test/repository/Test_PluginRepository.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_PluginRepository.java index a570258f..9d2dddc2 100644 --- a/src/test/java/org/bench4q/master/test/repository/Test_PluginRepository.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_PluginRepository.java @@ -1,94 +1,94 @@ -package org.bench4q.master.test.repository; - -import static org.junit.Assert.*; - -import org.bench4q.master.TestPlunginHelper; -import org.bench4q.master.domain.entity.plugin.MethodParam; -import org.bench4q.master.domain.entity.plugin.Plugin; -import org.bench4q.master.domain.factory.PluginFactory; -import org.bench4q.master.domain.repository.PluginRepository; -import org.bench4q.master.exception.Bench4QException; -import org.bench4q.share.models.master.plugin.PluginModel; -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 = { "classpath:service-test-context.xml" }) -public class Test_PluginRepository { - private PluginRepository pluginRepository; - private String pluginName; - private PluginFactory pluginFactory; - - public PluginRepository getPluginRepository() { - return pluginRepository; - } - - @Autowired - public void setPluginRepository(PluginRepository pluginRepository) { - this.pluginRepository = pluginRepository; - } - - public PluginFactory getPluginFactory() { - return pluginFactory; - } - - @Autowired - public void setPluginFactory(PluginFactory pluginFactory) { - this.pluginFactory = pluginFactory; - } - - @Before - public void setUp() throws Bench4QException { - pluginName = addPlugin(); - } - - @Test - public void testGetPlugin() { - assertNotNull(this.getPluginRepository().getPlugin(pluginName)); - } - - @Test - public void TestLoadMethodParam() { - Plugin plugin = this.getPluginRepository().getPlugin(pluginName); - MethodParam methodParam = plugin.getPluginMethods().iterator().next() - .getMethodParams().iterator().next(); - - System.out.println(methodParam.getParamType().getClass()); - } - - @Test - public void testGetMethodList() throws Bench4QException { - Plugin plugin = this.getPluginRepository().getPlugin(pluginName); - assertNotNull(plugin); - assertEquals(1, plugin.getPluginMethods().size()); - } - - @Test - public void testLoadPlugin() throws Bench4QException { - - int countBeforeInsert = this.getPluginRepository().loadPlugins().size(); - String insertPlugin = addPlugin(); - assertEquals(countBeforeInsert + 1, this.getPluginRepository() - .loadPlugins().size()); - this.getPluginRepository().detach(insertPlugin); - - } - - @After - public void clear() throws Bench4QException { - /* this.getPluginRepository().detach(pluginName); */ - } - - private String addPlugin() throws Bench4QException { - PluginModel pluginModel = TestPlunginHelper.createOnePlugin(); - this.getPluginRepository().attatch( - this.getPluginFactory().createPluginEntity(pluginModel)); - return pluginModel.getName(); - - } -} +package org.bench4q.master.test.repository; + +import static org.junit.Assert.*; + +import org.bench4q.master.TestPlunginHelper; +import org.bench4q.master.domain.entity.plugin.MethodParam; +import org.bench4q.master.domain.entity.plugin.Plugin; +import org.bench4q.master.domain.factory.PluginFactory; +import org.bench4q.master.domain.repository.PluginRepository; +import org.bench4q.master.exception.Bench4QException; +import org.bench4q.share.models.master.plugin.PluginModel; +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 = { "classpath:service-test-context.xml" }) +public class Test_PluginRepository { + private PluginRepository pluginRepository; + private String pluginName; + private PluginFactory pluginFactory; + + public PluginRepository getPluginRepository() { + return pluginRepository; + } + + @Autowired + public void setPluginRepository(PluginRepository pluginRepository) { + this.pluginRepository = pluginRepository; + } + + public PluginFactory getPluginFactory() { + return pluginFactory; + } + + @Autowired + public void setPluginFactory(PluginFactory pluginFactory) { + this.pluginFactory = pluginFactory; + } + + @Before + public void setUp() throws Bench4QException { + pluginName = addPlugin(); + } + + @Test + public void testGetPlugin() { + assertNotNull(this.getPluginRepository().getPlugin(pluginName)); + } + + @Test + public void TestLoadMethodParam() { + Plugin plugin = this.getPluginRepository().getPlugin(pluginName); + MethodParam methodParam = plugin.getPluginMethods().iterator().next() + .getMethodParams().iterator().next(); + + System.out.println(methodParam.getParamType().getClass()); + } + + @Test + public void testGetMethodList() throws Bench4QException { + Plugin plugin = this.getPluginRepository().getPlugin(pluginName); + assertNotNull(plugin); + assertEquals(1, plugin.getPluginMethods().size()); + } + + @Test + public void testLoadPlugin() throws Bench4QException { + + int countBeforeInsert = this.getPluginRepository().loadPlugins().size(); + String insertPlugin = addPlugin(); + assertEquals(countBeforeInsert + 1, this.getPluginRepository() + .loadPlugins().size()); + this.getPluginRepository().detach(insertPlugin); + + } + + @After + public void clear() throws Bench4QException { + /* this.getPluginRepository().detach(pluginName); */ + } + + private String addPlugin() throws Bench4QException { + PluginModel pluginModel = TestPlunginHelper.createOnePlugin(); + this.getPluginRepository().attatch( + this.getPluginFactory().createPluginEntity(pluginModel)); + return pluginModel.getName(); + + } +} diff --git a/src/test/java/org/bench4q/master/test/repository/Test_TestPlanRepository.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_TestPlanRepository.java similarity index 100% rename from src/test/java/org/bench4q/master/test/repository/Test_TestPlanRepository.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_TestPlanRepository.java diff --git a/src/test/java/org/bench4q/master/test/repository/Test_UserRepository.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_UserRepository.java similarity index 100% rename from src/test/java/org/bench4q/master/test/repository/Test_UserRepository.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/repository/Test_UserRepository.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_AgentService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_AgentService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_AgentService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_AgentService.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_MonitorMessenger.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_MonitorMessenger.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_MonitorMessenger.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_MonitorMessenger.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_MonitorResultService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_MonitorResultService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_MonitorResultService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_MonitorResultService.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_PluginService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_PluginService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_PluginService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_PluginService.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_ReportService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_ReportService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_ReportService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_ReportService.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_ScriptService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_ScriptService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_ScriptService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_ScriptService.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_TestPlanEngine.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_TestPlanScriptResultService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_TestPlanScriptResultService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_TestPlanScriptResultService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_TestPlanScriptResultService.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_TestPlanScriptService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_TestPlanScriptService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_TestPlanScriptService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_TestPlanScriptService.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_TestPlanService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_TestPlanService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_TestPlanService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_TestPlanService.java diff --git a/src/test/java/org/bench4q/master/test/service/Test_UserService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_UserService.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/Test_UserService.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_UserService.java diff --git a/src/test/java/org/bench4q/master/test/service/auth/Test_AuthenticationManager.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/auth/Test_AuthenticationManager.java similarity index 100% rename from src/test/java/org/bench4q/master/test/service/auth/Test_AuthenticationManager.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/service/auth/Test_AuthenticationManager.java diff --git a/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java similarity index 100% rename from src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java diff --git a/src/test/java/org/bench4q/master/test/testplan/TestTestPlanResult.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestTestPlanResult.java similarity index 97% rename from src/test/java/org/bench4q/master/test/testplan/TestTestPlanResult.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestTestPlanResult.java index dd6a54b3..584eb0ac 100644 --- a/src/test/java/org/bench4q/master/test/testplan/TestTestPlanResult.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestTestPlanResult.java @@ -1,33 +1,33 @@ -package org.bench4q.master.test.testplan; - -import static org.junit.Assert.*; - -import java.io.IOException; - -import javax.xml.bind.JAXBException; - -import org.bench4q.master.test.controller.TestBase; -import org.bench4q.share.communication.HttpRequester.HttpResponse; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.ResultLoadModel; -import org.junit.Test; - -public class TestTestPlanResult extends TestBase { - private static String URL = BASE_URL + "/TestPlanResult"; - private static String testPlanRunId = "0cdc3398-5b61-4bff-be48-8075e5d2fa64"; - - @Test - public void test() { - fail("Not yet implemented"); - } - - public void testScriptReuslts() throws IOException, JAXBException { - HttpResponse httpResponse = this.httpRequester.sendGet(URL + "/" - + testPlanRunId, null, - makeAccessTockenMap(this.getAccessTocken())); - assertTrue(httpResponse != null); - ResultLoadModel resultModel = (ResultLoadModel) MarshalHelper - .unmarshal(ResultLoadModel.class, httpResponse.getContent()); - assertTrue(resultModel.getValueTimeModels().size() > 0); - } -} +package org.bench4q.master.test.testplan; + +import static org.junit.Assert.*; + +import java.io.IOException; + +import javax.xml.bind.JAXBException; + +import org.bench4q.master.test.controller.TestBase; +import org.bench4q.share.communication.HttpRequester.HttpResponse; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.master.ResultLoadModel; +import org.junit.Test; + +public class TestTestPlanResult extends TestBase { + private static String URL = BASE_URL + "/TestPlanResult"; + private static String testPlanRunId = "0cdc3398-5b61-4bff-be48-8075e5d2fa64"; + + @Test + public void test() { + fail("Not yet implemented"); + } + + public void testScriptReuslts() throws IOException, JAXBException { + HttpResponse httpResponse = this.httpRequester.sendGet(URL + "/" + + testPlanRunId, null, + makeAccessTockenMap(this.getAccessTocken())); + assertTrue(httpResponse != null); + ResultLoadModel resultModel = (ResultLoadModel) MarshalHelper + .unmarshal(ResultLoadModel.class, httpResponse.getContent()); + assertTrue(resultModel.getValueTimeModels().size() > 0); + } +} diff --git a/src/test/java/org/bench4q/master/test/testplan/Test_LoadDistribute.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/Test_LoadDistribute.java similarity index 100% rename from src/test/java/org/bench4q/master/test/testplan/Test_LoadDistribute.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/Test_LoadDistribute.java diff --git a/src/test/java/org/bench4q/master/test/transaction/Test_ScriptLoadCommand.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/transaction/Test_ScriptLoadCommand.java similarity index 100% rename from src/test/java/org/bench4q/master/test/transaction/Test_ScriptLoadCommand.java rename to Bench4Q-Master/src/test/java/org/bench4q/master/test/transaction/Test_ScriptLoadCommand.java diff --git a/src/test/java/org/bench4q/mater/test/entity/Test_Monitor.java b/Bench4Q-Master/src/test/java/org/bench4q/mater/test/entity/Test_Monitor.java similarity index 96% rename from src/test/java/org/bench4q/mater/test/entity/Test_Monitor.java rename to Bench4Q-Master/src/test/java/org/bench4q/mater/test/entity/Test_Monitor.java index fd7aef2d..17a314f7 100644 --- a/src/test/java/org/bench4q/mater/test/entity/Test_Monitor.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/mater/test/entity/Test_Monitor.java @@ -1,44 +1,44 @@ -package org.bench4q.mater.test.entity; - -import static org.junit.Assert.*; - -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.domain.entity.TestPlan; -import org.bench4q.master.test.TestBase_MakeUpTestPlan; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:service-test-context.xml" }) -public class Test_Monitor extends TestBase_MakeUpTestPlan { - - @Before - public void prepare() { - prepareForTestPlanRunning(); - submitATestPlanWithOneScript(); - } - - @Test - public void testDoAfterRun() { - TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy( - getTestPlanRunIdUuid()); - assertEquals(1, testPlan.getMonitors().size()); - for (Monitor monitor : testPlan.getMonitors()) { - monitor.doAfterRun(); - } - for (Monitor monitor : getTestPlanRepository().getTestPlanBy( - getTestPlanRunIdUuid()).getMonitors()) { - assertEquals(5, monitor.getResults().size()); - } - } - - @After - public void clear() { - cleanUpForTestPlanRunning(); - } - -} +package org.bench4q.mater.test.entity; + +import static org.junit.Assert.*; + +import org.bench4q.master.domain.entity.Monitor; +import org.bench4q.master.domain.entity.TestPlan; +import org.bench4q.master.test.TestBase_MakeUpTestPlan; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:service-test-context.xml" }) +public class Test_Monitor extends TestBase_MakeUpTestPlan { + + @Before + public void prepare() { + prepareForTestPlanRunning(); + submitATestPlanWithOneScript(); + } + + @Test + public void testDoAfterRun() { + TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy( + getTestPlanRunIdUuid()); + assertEquals(1, testPlan.getMonitors().size()); + for (Monitor monitor : testPlan.getMonitors()) { + monitor.doAfterRun(); + } + for (Monitor monitor : getTestPlanRepository().getTestPlanBy( + getTestPlanRunIdUuid()).getMonitors()) { + assertEquals(5, monitor.getResults().size()); + } + } + + @After + public void clear() { + cleanUpForTestPlanRunning(); + } + +} diff --git a/src/test/java/org/bench4q/mater/test/entity/Test_TestPlan.java b/Bench4Q-Master/src/test/java/org/bench4q/mater/test/entity/Test_TestPlan.java similarity index 96% rename from src/test/java/org/bench4q/mater/test/entity/Test_TestPlan.java rename to Bench4Q-Master/src/test/java/org/bench4q/mater/test/entity/Test_TestPlan.java index 9a8ecb75..33325b89 100644 --- a/src/test/java/org/bench4q/mater/test/entity/Test_TestPlan.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/mater/test/entity/Test_TestPlan.java @@ -1,78 +1,78 @@ -package org.bench4q.mater.test.entity; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.domain.entity.TestPlan; -import org.bench4q.master.domain.factory.TestPlanFactory; -import org.bench4q.master.domain.service.TestPlanService; -import org.bench4q.master.test.TestBase_MakeUpTestPlan; -import org.bench4q.share.enums.master.TestPlanStatus; -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 = { "classpath:service-test-context.xml" }) -public class Test_TestPlan extends TestBase_MakeUpTestPlan { - - private TestPlanService testPlanService; - private TestPlanFactory testPlanFactory; - - public TestPlanService getTestPlanService() { - return testPlanService; - } - - @Autowired - public void setTestPlanService(TestPlanService testPlanService) { - this.testPlanService = testPlanService; - } - - public TestPlanFactory getTestPlanFactory() { - return testPlanFactory; - } - - @Autowired - public void setTestPlanFactory(TestPlanFactory testPlanFactory) { - this.testPlanFactory = testPlanFactory; - } - - @Before - public void prepare() { - this.getHaPool().timerTask(); - submitATestPlanWithOneScript(); - } - - @After - public void cleanUp() throws InterruptedException { - cleanUpForTestPlanRunning(); - } - - @Test - public void testDoAfterRun() throws InterruptedException { - assertNotNull(getTestPlanRunIdUuid()); - TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain( - this.getTestPlanRepository().getTestPlanBy( - getTestPlanRunIdUuid())); - assertEquals(TestPlanStatus.InRunning, - testPlanInDomain.run()); - Thread.sleep(4000); - for (Monitor monitor : getTestPlan().getMonitors()) { - assertTrue(monitor.getResults().size()>0); - } - } - - private TestPlan getTestPlan() { - TestPlan testPlanFromRepo = this.getTestPlanRepository().getTestPlanBy( - getTestPlanRunIdUuid()); - TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain( - testPlanFromRepo); - return testPlanInDomain; - } - -} +package org.bench4q.mater.test.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.bench4q.master.domain.entity.Monitor; +import org.bench4q.master.domain.entity.TestPlan; +import org.bench4q.master.domain.factory.TestPlanFactory; +import org.bench4q.master.domain.service.TestPlanService; +import org.bench4q.master.test.TestBase_MakeUpTestPlan; +import org.bench4q.share.enums.master.TestPlanStatus; +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 = { "classpath:service-test-context.xml" }) +public class Test_TestPlan extends TestBase_MakeUpTestPlan { + + private TestPlanService testPlanService; + private TestPlanFactory testPlanFactory; + + public TestPlanService getTestPlanService() { + return testPlanService; + } + + @Autowired + public void setTestPlanService(TestPlanService testPlanService) { + this.testPlanService = testPlanService; + } + + public TestPlanFactory getTestPlanFactory() { + return testPlanFactory; + } + + @Autowired + public void setTestPlanFactory(TestPlanFactory testPlanFactory) { + this.testPlanFactory = testPlanFactory; + } + + @Before + public void prepare() { + this.getHaPool().timerTask(); + submitATestPlanWithOneScript(); + } + + @After + public void cleanUp() throws InterruptedException { + cleanUpForTestPlanRunning(); + } + + @Test + public void testDoAfterRun() throws InterruptedException { + assertNotNull(getTestPlanRunIdUuid()); + TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain( + this.getTestPlanRepository().getTestPlanBy( + getTestPlanRunIdUuid())); + assertEquals(TestPlanStatus.InRunning, + testPlanInDomain.run()); + Thread.sleep(4000); + for (Monitor monitor : getTestPlan().getMonitors()) { + assertTrue(monitor.getResults().size()>0); + } + } + + private TestPlan getTestPlan() { + TestPlan testPlanFromRepo = this.getTestPlanRepository().getTestPlanBy( + getTestPlanRunIdUuid()); + TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain( + testPlanFromRepo); + return testPlanInDomain; + } + +} diff --git a/src/test/resources/repository-test-context.xml b/Bench4Q-Master/src/test/resources/repository-test-context.xml similarity index 100% rename from src/test/resources/repository-test-context.xml rename to Bench4Q-Master/src/test/resources/repository-test-context.xml diff --git a/src/test/resources/service-test-context.xml b/Bench4Q-Master/src/test/resources/service-test-context.xml similarity index 100% rename from src/test/resources/service-test-context.xml rename to Bench4Q-Master/src/test/resources/service-test-context.xml diff --git a/license.txt b/license.txt deleted file mode 100644 index 33e77493..00000000 --- a/license.txt +++ /dev/null @@ -1,339 +0,0 @@ -GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., [http://fsf.org/] - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {description} - Copyright (C) {year} {fullname} - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - {signature of Ty Coon}, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. \ No newline at end of file diff --git a/src/main/java/org/bench4q/master/report/MonitorReportService.java b/src/main/java/org/bench4q/master/report/MonitorReportService.java deleted file mode 100644 index a24a1daa..00000000 --- a/src/main/java/org/bench4q/master/report/MonitorReportService.java +++ /dev/null @@ -1,246 +0,0 @@ -package org.bench4q.master.report; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.bench4q.master.domain.entity.MonitorResult; -import org.bench4q.master.domain.service.MonitorResultService; -import org.bench4q.master.domain.service.TestPlanScriptService; -import org.bench4q.master.domain.service.TestPlanService; -import org.bench4q.master.exception.Bench4QException; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.master.MonitorResultContainerModel; -import org.bench4q.share.models.monitor.MemoryModel; -import org.bench4q.share.models.monitor.NetworkInterfaceModel; -import org.bench4q.share.models.monitor.PhysicalDiskModel; -import org.bench4q.share.models.monitor.ProcessorModel; -import org.jfree.data.time.Second; -import org.jfree.data.time.TimeSeries; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.lowagie.text.Document; - -@Component -public class MonitorReportService { - public static String Processor = "ProcessorTimePercent (unit: %)"; - public static String Memory = "Memory Available Memory(unit: KiloByte)"; - public static String logical_Disk = "logicalDisk IO (unit: Byte)"; - public static String network_Interface = "networkInterface IO (unit: Byte/second)"; - private TestPlanScriptService testPlanScriptService; - private TestPlanService testPlanService; - private MonitorResultService monitorResultService; - - public TestPlanScriptService getTestPlanScriptService() { - return testPlanScriptService; - } - - @Autowired - public void setTestPlanScriptService( - TestPlanScriptService testPlanScriptService) { - this.testPlanScriptService = testPlanScriptService; - } - - public TestPlanService getTestPlanService() { - return testPlanService; - } - - @Autowired - public void setTestPlanService(TestPlanService testPlanService) { - this.testPlanService = testPlanService; - } - - public MonitorResultService getMonitorResultService() { - return monitorResultService; - } - - @Autowired - public void setMonitorResultService( - MonitorResultService monitorResultService) { - this.monitorResultService = monitorResultService; - } - - void createMonitorResultImages(UUID testPlanRunID, Document document) throws Bench4QException { - Map SUTResultMap = new HashMap(); - List results = this.getMonitorResultService() - .queryMonitorResults(testPlanRunID); - if (results == null) { - return; - } - - for (MonitorResult result : results) { - if (result == null) { - continue; - } - buildSUTResultMap(SUTResultMap, result); - } - - for (String hostName : SUTResultMap.keySet()) { - createSUTImage(hostName, SUTResultMap.get(hostName), document); - } - } - - private void buildSUTResultMap( - Map sUTResultMap, - MonitorResult result) { - String hostName = result.getHostNameUnderMonitor(); - if (!sUTResultMap.containsKey(hostName)) { - sUTResultMap.put(result.getHostNameUnderMonitor(), - new MonitorResultContainerModel()); - } - sortResultToList(result, sUTResultMap.get(hostName)); - } - - private void sortResultToList(final MonitorResult result, - MonitorResultContainerModel container) { - try { - if (Class.forName(result.getType()).equals(PhysicalDiskModel.class)) { - container.getLogicalDiskModels().add( - (PhysicalDiskModel) MarshalHelper.unmarshal( - PhysicalDiskModel.class, result.getContent())); - } else if (Class.forName(result.getType()) - .equals(MemoryModel.class)) { - container.getMemoryModels().add( - (MemoryModel) MarshalHelper.unmarshal( - MemoryModel.class, result.getContent())); - } else if (Class.forName(result.getType()).equals( - NetworkInterfaceModel.class)) { - container.getNetWorkModels().add( - (NetworkInterfaceModel) MarshalHelper.unmarshal( - NetworkInterfaceModel.class, - result.getContent())); - } else if (Class.forName(result.getType()).equals( - ProcessorModel.class)) { - container.getProcessorModels().add( - (ProcessorModel) MarshalHelper.unmarshal( - ProcessorModel.class, result.getContent())); - } - } catch (Exception e) { - e.printStackTrace(); - return; - } - } - - private void createSUTImage(String hostName, - MonitorResultContainerModel container, Document document) { - try { - ReportService.addParagraph(logical_Disk, document); - createLogicalDiskImage(container.getLogicalDiskModels(), document); - ReportService.addParagraph(Memory, document); - createMemoryImage(container.getMemoryModels(), document); - ReportService.addParagraph(network_Interface, document); -// createNetworkImage(container.getNetWorkModels(), document); - ReportService.addParagraph(Processor, document); - createProcessorImage(container.getProcessorModels(), document); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private void createProcessorImage(List list, - Document document) throws Exception { - if (list == null || list.size() == 0) { - return; - } - int seriesCount = list.get(0).getProcessorModelList().size(); - - List timeSeriesArray = ReportService.buildSeries( - seriesCount, Processor); - - for (ProcessorModel model : list) { - if (model == null) - continue; - for (int i = 0; i < timeSeriesArray.size(); i++) { - timeSeriesArray.get(i).addOrUpdate( - new Second(model.getSamplingTime()), - model.getProcessorModelList().get(i) - .getProcessorTimePercent()); - } - } - ReportService.writeImageIntoPdf( - ReportService.buildChartStream(document, seriesCount, - timeSeriesArray, Processor).toByteArray(), document); - - } - - private void createMemoryImage(List list, Document document) - throws Exception { - if (list == null || list.size() == 0) { - return; - } - int seriesCount = 1; - List timeSeriesArray = ReportService.buildSeries( - seriesCount, Memory); - for (MemoryModel model : list) { - if (model == null) - continue; - for (int i = 0; i < timeSeriesArray.size(); i++) { - timeSeriesArray.get(i).addOrUpdate( - new Second(model.getSamplingTime()), - model.getAvailableKiloBytes()); - } - } - ReportService.writeImageIntoPdf( - ReportService.buildChartStream(document, seriesCount, - timeSeriesArray, Memory).toByteArray(), document); - } - - private void createLogicalDiskImage(List list, - Document document) throws Exception { - if (list == null || list.size() == 0) { - return; - } - int seriesCount = list.get(0).getFieFileSystemModels().size(); - List timeSeriesArray = ReportService.buildSeries( - seriesCount, logical_Disk); - - for (PhysicalDiskModel model : list) { - if (model == null) - continue; - for (int i = 0; i < timeSeriesArray.size(); i++) { - timeSeriesArray.get(i).addOrUpdate( - new Second(model.getSamplingTime()), - model.getFieFileSystemModels().get(i) - .getDiskTotalKBytesRate()); - } - } - - ReportService.writeImageIntoPdf( - ReportService.buildChartStream(document, seriesCount, - timeSeriesArray, logical_Disk).toByteArray(), document); - } - - - /** - * refactor this kind of use - * - * @param list - * @param document - * @throws Exception - */ - -// private void createNetworkImage(List list, -// Document document) throws Exception { -// if (list == null || list.size() == 0) { -// return; -// } -// int seriesCount = list.get(0).getNetworkList().size(); -// List timeSeriesArray = ReportService.buildSeries( -// seriesCount, network_Interface); -// for (NetworkInterfaceModel model : list) { -// for (int i = 0; i < timeSeriesArray.size(); i++) { -// timeSeriesArray.get(i).addOrUpdate( -// new Second(model.getSamplingTime()), -// model.getNetworkList().get(i).getBytesTotalPerSecond()); -// } -// } -// ReportService.writeImageIntoPdf( -// ReportService.buildChartStream(document, seriesCount, -// timeSeriesArray, network_Interface).toByteArray(), -// document); -// } -//} -} diff --git a/src/main/java/org/bench4q/master/report/ReportService.java b/src/main/java/org/bench4q/master/report/ReportService.java deleted file mode 100644 index 38d750bb..00000000 --- a/src/main/java/org/bench4q/master/report/ReportService.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.bench4q.master.report; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Font; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.apache.commons.io.FileUtils; -import org.apache.log4j.Logger; -import org.bench4q.master.exception.ExceptionLog; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.ChartUtilities; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.title.TextTitle; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.lowagie.text.Document; -import com.lowagie.text.DocumentException; -import com.lowagie.text.Element; -import com.lowagie.text.Image; -import com.lowagie.text.Paragraph; -import com.lowagie.text.pdf.PdfWriter; - -@Component -public class ReportService { - public static String Time = "time"; - public static String PDF_FOLDER = "report"; - private ScriptReportService scriptReportService; - private MonitorReportService monitorReportService; - private Logger logger = Logger.getLogger(ReportService.class); - private static int PICTURE_WIDTH = 500; - private static int PICTURE_HIGHT = 450; - - public ScriptReportService getScriptReportService() { - return scriptReportService; - } - - @Autowired - public void setScriptReportService(ScriptReportService scriptReportService) { - this.scriptReportService = scriptReportService; - } - - public MonitorReportService getMonitorReportService() { - return monitorReportService; - } - - @Autowired - public void setMonitorReportService( - MonitorReportService monitorReportService) { - this.monitorReportService = monitorReportService; - } - - public byte[] createReport(UUID testPlanRunID) { - try { - if (isReportCreated(testPlanRunID)) { - return FileUtils.readFileToByteArray(new File(ReportService - .buildFilePath(testPlanRunID))); - } - isFolderExist(); - Document document = new Document(); - PdfWriter.getInstance(document, new FileOutputStream( - buildFilePath(testPlanRunID))); - document.open(); - this.getScriptReportService().createScriptsResultsImage( - testPlanRunID, document); - this.getMonitorReportService().createMonitorResultImages( - testPlanRunID, document); - document.close(); - return FileUtils.readFileToByteArray(new File( - buildFilePath(testPlanRunID))); - } catch (Exception e) { - logger.error(ExceptionLog.getStackTrace(e)); - return null; - } - } - - public boolean isReportCreated(UUID testPlanRunID) { - return new File(buildFilePath(testPlanRunID)).exists(); - } - - public static String buildFilePath(UUID testPlanRunID) { - return PDF_FOLDER + System.getProperty("file.separator") - + testPlanRunID + ".pdf"; - } - - private void isFolderExist() { - try { - if (!new File(PDF_FOLDER).isDirectory()) { - new File(PDF_FOLDER).mkdir(); - } - } catch (SecurityException e) { - e.printStackTrace(); - } - } - - static void addParagraph(String content, Document document) - throws DocumentException { - Paragraph paragraph = new Paragraph(content); - paragraph.setAlignment(Element.ALIGN_CENTER); - document.add(paragraph); - } - - public static ByteArrayOutputStream buildChartStream(Document document, - int seriesCount, List timeSeriesArray, String value) - throws IOException { - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - JFreeChart chart = ChartFactory.createTimeSeriesChart(value, - ReportService.Time, value, buildDataSet(timeSeriesArray), true, - true, true); - adjustChartFont(value, chart); - - ChartUtilities.writeChartAsPNG(outputStream, chart, PICTURE_WIDTH, - PICTURE_HIGHT); - return outputStream; - } - - private static void adjustChartFont(String value, JFreeChart chart) { - Font xfont = new Font("����", Font.CENTER_BASELINE, 14);// X - Font yfont = new Font("����", Font.CENTER_BASELINE, 14);// Y - Font kfont = new Font("����", Font.CENTER_BASELINE, 12);// - Font titleFont = new Font("΢���ź�", Font.CENTER_BASELINE, 16); // title - - chart.setBorderStroke(new BasicStroke(1)); - chart.setBorderVisible(true); - chart.setBorderPaint(Color.cyan); - - chart.setTitle(new TextTitle(value, titleFont)); - XYPlot plot = chart.getXYPlot(); - plot.getRangeAxis().setLabelFont(yfont); - plot.getRangeAxis().setTickLabelFont(kfont); - plot.getDomainAxis().setLabelFont(xfont); - plot.getDomainAxis().setTickLabelFont(kfont); - chart.setBackgroundPaint(java.awt.Color.white); - } - - public static List buildSeries(int seriesCount, String mainTitle) { - List timeSeriesArray = new ArrayList( - seriesCount); - for (int i = 0; i < seriesCount; i++) { - timeSeriesArray.add(new TimeSeries(mainTitle + "-" + i)); - } - return timeSeriesArray; - } - - static TimeSeriesCollection buildDataSet( - final List timeSeriesArray) { - TimeSeriesCollection lineDataset = new TimeSeriesCollection(); - if (timeSeriesArray == null) { - return null; - } - for (TimeSeries timeSeries : timeSeriesArray) { - lineDataset.addSeries(timeSeries); - } - return lineDataset; - } - - public static void writeImageIntoPdf(byte[] buffer, Document document) - throws Exception { - Image image = Image.getInstance(buffer); - image.setAlignment(Element.ALIGN_CENTER); - document.add(image); - } - -} diff --git a/src/main/java/org/bench4q/master/report/ScriptReportService.java b/src/main/java/org/bench4q/master/report/ScriptReportService.java deleted file mode 100644 index 3c58f80d..00000000 --- a/src/main/java/org/bench4q/master/report/ScriptReportService.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.bench4q.master.report; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -import org.apache.log4j.Logger; -import org.bench4q.master.domain.entity.TestPlanScript; -import org.bench4q.master.domain.entity.TestPlanScriptResult; -import org.bench4q.master.domain.repository.TestPlanRepository; -import org.bench4q.master.domain.service.MonitorResultService; -import org.bench4q.master.domain.service.TestPlanScriptService; -import org.bench4q.master.domain.service.TestPlanService; -import org.bench4q.share.models.master.statistics.ScriptBriefResultModel; -import org.jfree.data.time.Second; -import org.jfree.data.time.TimeSeries; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.lowagie.text.Document; - -@Component -public class ScriptReportService { - public static String SCRIPT_TITLE = "Script result"; - public static String Average_Response_Time = "averageResponseTime(unit: ms)"; - public static String MAX_RESPONSE_TIME = "maxResponseTime(unit : time)"; - private TestPlanScriptService testPlanScriptService; - private TestPlanService testPlanService; - private TestPlanRepository testPlanRepository; - private MonitorResultService monitorResultService; - private Logger logger = Logger.getLogger(ScriptReportService.class); - - public TestPlanScriptService getTestPlanScriptService() { - return testPlanScriptService; - } - - @Autowired - public void setTestPlanScriptService( - TestPlanScriptService testPlanScriptService) { - this.testPlanScriptService = testPlanScriptService; - } - - public TestPlanService getTestPlanService() { - return testPlanService; - } - - @Autowired - public void setTestPlanService(TestPlanService testPlanService) { - this.testPlanService = testPlanService; - } - - public MonitorResultService getMonitorResultService() { - return monitorResultService; - } - - @Autowired - public void setMonitorResultService( - MonitorResultService monitorResultService) { - this.monitorResultService = monitorResultService; - } - - private TestPlanRepository getTestPlanRepository() { - return testPlanRepository; - } - - @Autowired - private void setTestPlanRepository(TestPlanRepository testPlanRepository) { - this.testPlanRepository = testPlanRepository; - } - - void createScriptsResultsImage(UUID testPlanRunId, Document document) { - - Set scripts = this.getTestPlanRepository() - .getTestPlanBy(testPlanRunId).getTestPlanScripts(); - if (scripts == null) { - return; - } - for (TestPlanScript testPlanScript : scripts) { - createScriptImage(this.getTestPlanScriptService() - .queryScriptBriefResults(testPlanScript), document); - } - - } - - private void createScriptImage(List results, - Document document) { - - if (results == null) { - return; - } - createAverageReponseTimeImage(results, document); - } - - private void createAverageReponseTimeImage( - List results, Document document) { - List timeSeriesList = new ArrayList(); - if (results == null) { - return; - } - addScriptSeries(results, timeSeriesList, "averageResponseTime"); - addScriptSeries(results, timeSeriesList, "maxResponseTime"); - try { - ReportService.writeImageIntoPdf( - ReportService.buildChartStream(document, - timeSeriesList.size(), timeSeriesList, - Average_Response_Time + "&" + MAX_RESPONSE_TIME) - .toByteArray(), document); - } catch (Exception e) { - e.printStackTrace(); - } - } - - // TODO: refactor this to a kind of command mode - private void addScriptSeries(List results, - List timeSeriesList, String fieldName) { - try { - TimeSeries timeSeries = new TimeSeries(fieldName); - for (TestPlanScriptResult result : results) { - if (!result.getResultType().equals( - ScriptBriefResultModel.class.getName())) { - continue; - } - ScriptBriefResultModel scriptBriefResultModel = result - .extractScriptBriefResultModel(); - Field field = scriptBriefResultModel.getClass() - .getDeclaredField(fieldName); - field.setAccessible(true); - timeSeries.addOrUpdate(new Second(result.getCreateDatetime()), - field.getLong(scriptBriefResultModel)); - } - timeSeriesList.add(timeSeries); - } catch (Exception e) { - logger.error(e.toString() - + " in addScriptSeries where fieldName is : " + fieldName); - } - - } -} diff --git a/src/test/java/org/bench4q/master/test/report/ReportFontTest.java b/src/test/java/org/bench4q/master/test/report/ReportFontTest.java deleted file mode 100644 index c982d6ab..00000000 --- a/src/test/java/org/bench4q/master/test/report/ReportFontTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.bench4q.master.test.report; - -import static org.junit.Assert.*; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import org.bench4q.master.report.ReportService; -import org.jfree.data.time.Second; -import org.jfree.data.time.TimeSeries; -import org.junit.Test; - -import com.lowagie.text.Document; -import com.lowagie.text.DocumentException; -import com.lowagie.text.pdf.PdfWriter; - -public class ReportFontTest { - - @Test - public void test() { - fail("Not yet implemented"); - } - - public void createReportTest() throws FileNotFoundException, - DocumentException { - - Document document = new Document(); - PdfWriter.getInstance( - document, - new FileOutputStream(ReportService.buildFilePath(UUID - .randomUUID()))); - document.open(); - - } - - public void createTestImage(UUID id, Document document) throws IOException, - Exception { - List timeSeriesList = new ArrayList(); - TimeSeries timeSeries = new TimeSeries("test"); - long now = System.currentTimeMillis(); - timeSeries.add(new Second(new Date(now)), 3000); - timeSeries.add(new Second(new Date(now + 100)), 4000); - timeSeriesList.add(timeSeries); - ReportService.buildSeries(1, "test"); - ReportService.writeImageIntoPdf( - ReportService.buildChartStream(document, 1, timeSeriesList, - "test").toByteArray(), document); - } -}