This commit is contained in:
daisyonly 2014-09-01 14:38:19 +08:00
commit 7a04393a14
13 changed files with 1140 additions and 1048 deletions

View File

@ -82,13 +82,13 @@ public class TestController {
public String submitParams(
@PathVariable UUID runId,
@RequestParam(value = "files[]", required = false) List<MultipartFile> files,
@RequestParam("scenarioModel") String scenarioModel) {
@RequestParam(value = "testShedule", required = false) String scheduleContent,
@RequestParam(value = "scenarioModel") String scenarioModel) {
try {
this.getParamFileCollector().collectParamFiles(files, runId);
System.out.println(scenarioModel);
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.unmarshal(RunScenarioModel.class, scenarioModel);
this.getScenarioEngine().submitScenario(runId,
Scenario.scenarioBuilderWithCompile(runScenarioModel));
return MarshalHelper.tryMarshal(buildWith(runId));

View File

@ -16,6 +16,7 @@ public class Scenario {
private UsePlugin[] usePlugins;
private Page[] pages;
private List<Behavior> behaviors;
private TestSchedule schedule;
public UsePlugin[] getUsePlugins() {
return usePlugins;
@ -41,6 +42,14 @@ public class Scenario {
this.behaviors = behaviors;
}
public TestSchedule getSchedule() {
return schedule;
}
private void setSchedule(TestSchedule schedule) {
this.schedule = schedule;
}
public Scenario() {
this.setBehaviors(new ArrayList<Behavior>());
}
@ -88,6 +97,7 @@ public class Scenario {
scenario.setPages(new Page[runScenarioModel.getPages().size()]);
extractUsePlugins(runScenarioModel, scenario);
extractPages(runScenarioModel, scenario);
scenario.setSchedule(TestSchedule.build(runScenarioModel.getScheduleModel()));
return scenario;
}

View File

@ -0,0 +1,63 @@
package org.bench4q.agent.scenario;
import java.util.LinkedList;
import java.util.List;
import org.bench4q.share.models.agent.scriptrecord.TestScheduleModel;
import org.bench4q.share.models.agent.scriptrecord.TestScheduleModel.PointModel;
public class TestSchedule {
private List<Segment> points;
public List<Segment> getPoints() {
return points;
}
public void setPoints(List<Segment> points) {
this.points = points;
}
public static class Segment {
private final Point start;
private final Point end;
private final int growthUnit;
public Segment(Point startPoint, Point endPoint) {
this.start = new Point(startPoint.time, startPoint.load);
}
}
public static class Point {
private final int time;
private final int load;
public int getTime() {
return time;
}
public int getLoad() {
return load;
}
public Point(int time, int load) {
// TODO Auto-generated constructor stub
this.time = time;
this.load = load;
}
}
public static TestSchedule build(TestScheduleModel scheduleModel) {
TestSchedule schedule = new TestSchedule();
// schedule.setPoints(extractPoints(scheduleModel.getPoints()));
return null;
}
private static List<Point> extractPoints(List<PointModel> points) {
List<Point> result = new LinkedList<TestSchedule.Point>();
for (PointModel model : points) {
result.add(new Point(model.getTime(), model.getLoad()));
}
return result;
}
}

View File

@ -1,149 +1,149 @@
package org.bench4q.agent.scenario.engine;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ThreadPoolExecutor.DiscardPolicy;
import org.apache.log4j.Logger;
import org.bench4q.agent.datacollector.DataCollector;
import org.bench4q.agent.datacollector.impl.ScenarioResultCollector;
import org.bench4q.agent.plugin.PluginManager;
import org.bench4q.agent.scenario.Scenario;
public class ScenarioContext {
private static final long keepAliveTime = 10;
private UUID testId;
private Date startDate;
private Date endDate;
private ThreadPoolExecutor executor;
private Scenario scenario;
private boolean finished;
private DataCollector dataStatistics;
private PluginManager pluginManager;
public UUID getTestId() {
return testId;
}
private void setTestId(UUID testId) {
this.testId = testId;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date saveStartDate) {
this.startDate = saveStartDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public ThreadPoolExecutor getExecutor() {
return executor;
}
public void setExecutorService(ThreadPoolExecutor executor) {
this.executor = executor;
}
public Scenario getScenario() {
return scenario;
}
public void setScenario(Scenario scenario) {
this.scenario = scenario;
}
public boolean isFinished() {
return finished;
}
public void setFinished(boolean finished) {
this.finished = finished;
}
public DataCollector getDataStatistics() {
return dataStatistics;
}
private void setDataStatistics(DataCollector dataStatistics) {
this.dataStatistics = dataStatistics;
}
private PluginManager getPluginManager() {
return pluginManager;
}
private void setPluginManager(PluginManager pluginManager) {
this.pluginManager = pluginManager;
}
private ScenarioContext() {
}
public static ScenarioContext buildScenarioContext(UUID testId,
final Scenario scenario, int poolSize, PluginManager pluginManager) {
ScenarioContext scenarioContext = buildScenarioContextWithoutScenario(
testId, poolSize, pluginManager);
scenarioContext.setScenario(scenario);
return scenarioContext;
}
public static ScenarioContext buildScenarioContextWithoutScenario(
UUID testId, int poolSize, PluginManager pluginManager) {
ScenarioContext scenarioContext = new ScenarioContext();
scenarioContext.setTestId(testId);
scenarioContext.setPluginManager(pluginManager);
final ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(
poolSize);
ThreadPoolExecutor executor = new ThreadPoolExecutor(poolSize,
poolSize, keepAliveTime, TimeUnit.MINUTES, workQueue,
new DiscardPolicy());
scenarioContext.setStartDate(new Date(System.currentTimeMillis()));
scenarioContext.setExecutorService(executor);
scenarioContext.setDataStatistics(new ScenarioResultCollector(testId));
return scenarioContext;
}
public ScenarioContext addScenrio(Scenario scenario) {
this.setScenario(scenario);
return this;
}
/**
* Now, I tolerate that if the requiredLoad <
* this.getExecutor.getCorePoolSize(), then the excess threads will be
* killed when its current task complete
*
* @param requiredLoad
*/
void updatePopulation(int requiredLoad) {
this.getExecutor().setCorePoolSize(requiredLoad);
this.getExecutor().setMaximumPoolSize(requiredLoad);
}
public void addTask() {
if (this.isFinished()) {
return;
}
this.getExecutor().execute(new VUser(this, 1, getPluginManager()));
Logger.getLogger(this.getClass()).info(
this.getExecutor().getActiveCount());
}
public void initTasks() {
for (int i = 0; i < this.getExecutor().getCorePoolSize(); i++) {
addTask();
}
}
}
package org.bench4q.agent.scenario.engine;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ThreadPoolExecutor.DiscardPolicy;
import org.apache.log4j.Logger;
import org.bench4q.agent.datacollector.DataCollector;
import org.bench4q.agent.datacollector.impl.ScenarioResultCollector;
import org.bench4q.agent.plugin.PluginManager;
import org.bench4q.agent.scenario.Scenario;
public class ScenarioContext {
private static final long keepAliveTime = 10;
private UUID testId;
private Date startDate;
private Date endDate;
private ThreadPoolExecutor executor;
private Scenario scenario;
private boolean finished;
private DataCollector dataStatistics;
private PluginManager pluginManager;
public UUID getTestId() {
return testId;
}
private void setTestId(UUID testId) {
this.testId = testId;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date saveStartDate) {
this.startDate = saveStartDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public ThreadPoolExecutor getExecutor() {
return executor;
}
public void setExecutorService(ThreadPoolExecutor executor) {
this.executor = executor;
}
public Scenario getScenario() {
return scenario;
}
public void setScenario(Scenario scenario) {
this.scenario = scenario;
}
public boolean isFinished() {
return finished;
}
public void setFinished(boolean finished) {
this.finished = finished;
}
public DataCollector getDataStatistics() {
return dataStatistics;
}
private void setDataStatistics(DataCollector dataStatistics) {
this.dataStatistics = dataStatistics;
}
private PluginManager getPluginManager() {
return pluginManager;
}
private void setPluginManager(PluginManager pluginManager) {
this.pluginManager = pluginManager;
}
private ScenarioContext() {
}
public static ScenarioContext buildScenarioContext(UUID testId,
final Scenario scenario, int poolSize, PluginManager pluginManager) {
ScenarioContext scenarioContext = buildScenarioContextWithoutScenario(
testId, poolSize, pluginManager);
scenarioContext.setScenario(scenario);
return scenarioContext;
}
public static ScenarioContext buildScenarioContextWithoutScenario(
UUID testId, int poolSize, PluginManager pluginManager) {
ScenarioContext scenarioContext = new ScenarioContext();
scenarioContext.setTestId(testId);
scenarioContext.setPluginManager(pluginManager);
final ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(
poolSize);
ThreadPoolExecutor executor = new ThreadPoolExecutor(poolSize,
poolSize, keepAliveTime, TimeUnit.MINUTES, workQueue,
new DiscardPolicy());
scenarioContext.setStartDate(new Date(System.currentTimeMillis()));
scenarioContext.setExecutorService(executor);
scenarioContext.setDataStatistics(new ScenarioResultCollector(testId));
return scenarioContext;
}
public ScenarioContext addScenrio(Scenario scenario) {
this.setScenario(scenario);
return this;
}
/**
* Now, I tolerate that if the requiredLoad <
* this.getExecutor.getCorePoolSize(), then the excess threads will be
* killed when its current task complete
*
* @param requiredLoad
*/
void updatePopulation(int requiredLoad) {
this.getExecutor().setCorePoolSize(requiredLoad);
this.getExecutor().setMaximumPoolSize(requiredLoad);
}
public void addTask() {
if (this.isFinished()) {
return;
}
this.getExecutor().execute(new VUser(this, 1, getPluginManager()));
Logger.getLogger(this.getClass()).info(
this.getExecutor().getActiveCount());
}
public void initTasks() {
for (int i = 0; i < this.getExecutor().getCorePoolSize(); i++) {
addTask();
}
}
}

View File

@ -1,79 +1,79 @@
package org.bench4q.agent.scenario.engine;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.bench4q.agent.plugin.PluginManager;
import org.bench4q.agent.scenario.Scenario;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ScenarioEngine {
private Map<UUID, ScenarioContext> runningTests;
private Logger logger = Logger.getLogger(ScenarioEngine.class);
private PluginManager pluginManager;
public ScenarioEngine() {
this.setRunningTests(new HashMap<UUID, ScenarioContext>());
}
public Map<UUID, ScenarioContext> getRunningTests() {
return runningTests;
}
private void setRunningTests(Map<UUID, ScenarioContext> runningTests) {
this.runningTests = runningTests;
}
private PluginManager getPluginManager() {
return pluginManager;
}
@Autowired
private void setPluginManager(PluginManager pluginManager) {
this.pluginManager = pluginManager;
}
public void addRunningTestWithoutScenario(UUID runId, int poolSize) {
try {
final ScenarioContext scenarioContext = ScenarioContext
.buildScenarioContextWithoutScenario(runId, poolSize,
getPluginManager());
this.getRunningTests().put(runId, scenarioContext);
} catch (Exception e) {
e.printStackTrace();
}
}
public void submitScenario(UUID runId, final Scenario scenario) {
try {
this.getRunningTests().get(runId).addScenrio(scenario);
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean runWith(UUID runId) {
if (!this.getRunningTests().containsKey(runId)) {
return false;
}
final ScenarioContext context = this.getRunningTests().get(runId);
return runWith(context);
}
private boolean runWith(final ScenarioContext scenarioContext) {
if (scenarioContext == null) {
logger.error("The context required is null");
return false;
}
scenarioContext.initTasks();
return true;
}
public void updatePopulation(UUID testId, int requiredLoad) {
ScenarioContext context = this.getRunningTests().get(testId);
context.updatePopulation(requiredLoad);
}
}
package org.bench4q.agent.scenario.engine;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.bench4q.agent.plugin.PluginManager;
import org.bench4q.agent.scenario.Scenario;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ScenarioEngine {
private Map<UUID, ScenarioContext> runningTests;
private Logger logger = Logger.getLogger(ScenarioEngine.class);
private PluginManager pluginManager;
public ScenarioEngine() {
this.setRunningTests(new HashMap<UUID, ScenarioContext>());
}
public Map<UUID, ScenarioContext> getRunningTests() {
return runningTests;
}
private void setRunningTests(Map<UUID, ScenarioContext> runningTests) {
this.runningTests = runningTests;
}
private PluginManager getPluginManager() {
return pluginManager;
}
@Autowired
private void setPluginManager(PluginManager pluginManager) {
this.pluginManager = pluginManager;
}
public void addRunningTestWithoutScenario(UUID runId, int poolSize) {
try {
final ScenarioContext scenarioContext = ScenarioContext
.buildScenarioContextWithoutScenario(runId, poolSize,
getPluginManager());
this.getRunningTests().put(runId, scenarioContext);
} catch (Exception e) {
e.printStackTrace();
}
}
public void submitScenario(UUID runId, final Scenario scenario) {
try {
this.getRunningTests().get(runId).addScenrio(scenario);
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean runWith(UUID runId) {
if (!this.getRunningTests().containsKey(runId)) {
return false;
}
final ScenarioContext context = this.getRunningTests().get(runId);
return runWith(context);
}
private boolean runWith(final ScenarioContext scenarioContext) {
if (scenarioContext == null) {
logger.error("The context required is null");
return false;
}
scenarioContext.initTasks();
return true;
}
public void updatePopulation(UUID testId, int requiredLoad) {
ScenarioContext context = this.getRunningTests().get(testId);
context.updatePopulation(requiredLoad);
}
}

View File

@ -1,325 +1,325 @@
package org.bench4q.master.api;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.service.TestPlanEngine;
import org.bench4q.master.domain.service.TestPlanScriptResultService;
import org.bench4q.master.domain.service.TestPlanService;
import org.bench4q.master.domain.service.UserService;
import org.bench4q.master.domain.service.report.ReportService;
import org.bench4q.master.exception.Bench4QException;
import org.bench4q.master.exception.Bench4QRunTimeException;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.models.master.MonitorModel;
import org.bench4q.share.models.master.ScriptHandleModel;
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
import org.bench4q.share.models.master.TestPlanModel;
import org.bench4q.share.models.master.TestPlanDBModel;
import org.bench4q.share.models.master.TestPlanResponseModel;
import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
@Controller
@RequestMapping("/testPlan")
public class TestPlanController extends BaseController {
private TestPlanEngine testPlanRunner;
private TestPlanService testPlanService;
private ReportService reportService;
private TestPlanScriptResultService testPlanScriptResultService;
private BusinessModelMapFactory businessMapFactory;
private Logger logger = Logger.getLogger(TestPlanController.class);
private TestPlanEngine getTestPlanRunner() {
return testPlanRunner;
}
@Autowired
private void setTestPlanRunner(TestPlanEngine testPlanRunner) {
this.testPlanRunner = testPlanRunner;
}
private TestPlanService getTestPlanService() {
return this.testPlanService;
}
@Autowired
private void setTestPlanService(TestPlanService testPlanService) {
this.testPlanService = testPlanService;
}
private ReportService getReportService() {
return reportService;
}
@Autowired
private void setReportService(ReportService reportService) {
this.reportService = reportService;
}
private BusinessModelMapFactory getBusinessMapFactory() {
return businessMapFactory;
}
@Autowired
private void setBusinessMapFactory(
BusinessModelMapFactory businessMapFactory) {
this.businessMapFactory = businessMapFactory;
}
private TestPlanScriptResultService getTestPlanScriptResultService() {
return testPlanScriptResultService;
}
@Autowired
private void setTestPlanScriptResultService(
TestPlanScriptResultService testPlanScriptResultService) {
this.testPlanScriptResultService = testPlanScriptResultService;
}
@RequestMapping(value = "/runTestPlanWithTestPlanModel", method = {
RequestMethod.POST, RequestMethod.GET })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResultModel runTestPlanWithTestPlanModel(
@RequestBody TestPlanModel testPlanBusinessModel)
throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You don't have enough power to run a test plan!",
"/runTestPlanWithTestPlanModel");
}
UUID testPlanRunID = this.getTestPlanRunner().runWith(
testPlanBusinessModel, this.getPrincipal());
if (testPlanRunID == null) {
throw new Bench4QException("TestPlan_Commit_Error",
"There is an exception when commit the test plan",
"/runTestPlanWithTestPlanModel");
}
return buildResponseModel(this.getTestPlanService()
.queryTestPlanStatus(testPlanRunID), testPlanRunID, null,
testPlanBusinessModel.getMonitorModels());
}
private TestPlanResultModel buildResponseModel(
TestPlanStatus currentStatus, UUID testPlanId,
List<ScriptHandleModel> scripts, List<MonitorModel> monitorModels) {
TestPlanResultModel result = new TestPlanResultModel();
result.setCurrentStatus(currentStatus);
result.setTestPlanId(testPlanId);
result.setScripts(scripts);
result.setMonitorModels(monitorModels);
return result;
}
@RequestMapping(value = "/getRunningInfo", method = { RequestMethod.GET,
RequestMethod.POST })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResultModel getTestPlanRunningInfo(
@RequestParam UUID testPlanId) throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You have not power to get test plan running info",
"/getRunningInfo");
}
return this.getTestPlanService().buildResultModel(testPlanId);
}
@RequestMapping(value = "/scriptBrief/{testPlanId}/{scriptId}/{duationBegin}", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanScriptBriefResultModel getScriptBrief(
@PathVariable UUID testPlanId, @PathVariable int scriptId,
@PathVariable long duationBegin) throws Bench4QException,
NullPointerException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You have not power to get test plan script brief",
"/getRunningInfo");
}
List<ScriptBriefResultModel> scriptBriefResultModels = this
.getTestPlanScriptResultService().loadScriptBriefWithDuation(
testPlanId, scriptId, duationBegin);
System.out.println("Script Result Size : "
+ scriptBriefResultModels.size());
TestPlanScriptBriefResultModel ret = new TestPlanScriptBriefResultModel();
ret.setScriptBriefResultModels(scriptBriefResultModels);
return ret;
}
@RequestMapping(value = "/getBehaviorsBrief/{testPlanRunID}/{scriptId}")
@ResponseBody
public ScriptBehaviorsBriefModel getBehaviorsBrief(
@PathVariable UUID testPlanRunID, @PathVariable int scriptId)
throws Bench4QException, NullPointerException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER, EXCEPTION_HAPPEND
+ "when get behaviors's brief", "/getBehaviorsBrief");
}
ScriptBehaviorsBriefModel result = this
.getTestPlanScriptResultService()
.getLatestScriptBehaviorsBrief(testPlanRunID, scriptId);
return result;
}
@RequestMapping(value = "/pagesBrief/{testPlanRunId}/{scriptId}")
@ResponseBody
public ScriptPagesBriefModel getPagesBrief(
@PathVariable UUID testPlanRunId, @PathVariable int scriptId)
throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER, EXCEPTION_HAPPEND
+ "when get behaviors's brief", "/getBehaviorsBrief");
}
ScriptPagesBriefModel pagesBriefModel = this
.getTestPlanScriptResultService().getLatestScriptPagesBrief(
testPlanRunId, scriptId);
return pagesBriefModel;
}
@RequestMapping(value = "/loadTestPlans", method = { RequestMethod.GET,
RequestMethod.POST })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResponseModel loadTestPlans() {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildTestPlanResponseModel(false, "no scope", null);
}
List<TestPlan> testPlanDBs = this.testPlanService.loadTestPlans(this
.getPrincipal());
return testPlanDBs == null ? buildTestPlanResponseModel(false,
"exception", null) : buildTestPlanResponseModel(true, null,
testPlanDBs);
}
@RequestMapping(value = "/queryTestPlan/{runId}", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanDBModel queryTestPlan(@PathVariable UUID runId)
throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER, HAVE_NO_POWER,
"/queryTestPlan/{runId}");
}
return this.getTestPlanService().getTestPlanDBModel(runId);
}
@RequestMapping(value = "/removeTestPlanFromPool", method = {
RequestMethod.GET, RequestMethod.POST })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResponseModel removeTestPlanFromPool(int testPlanId) {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildTestPlanResponseModel(false, "no scope", null);
}
return buildTestPlanResponseModel(
this.testPlanService.removeTestPlanInDB(testPlanId), null, null);
}
private TestPlanResponseModel buildTestPlanResponseModel(boolean success,
String failCause, List<TestPlan> testPlanDBs) {
TestPlanResponseModel result = new TestPlanResponseModel();
result.setSuccess(success);
result.setFailCause(failCause);
List<TestPlanDBModel> modelList = new ArrayList<TestPlanDBModel>();
if (testPlanDBs != null) {
for (TestPlan testPlanDB : testPlanDBs) {
modelList.add(this.getBusinessMapFactory().toModel(testPlanDB));
}
}
result.setTestPlanDBModels(modelList);
return result;
}
@RequestMapping(value = "/getTestPlanReport", method = { RequestMethod.GET,
RequestMethod.POST })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public void getTestPlanReport(HttpServletResponse response,
@RequestParam UUID testPlanRunID) throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You have no power to get test plan report",
"/getTestPlanReport");
}
buildFileStream(response, testPlanRunID, this.getReportService()
.createReport(testPlanRunID));
}
private void buildFileStream(HttpServletResponse response,
UUID testPlanRunID, byte[] pdfBuffer) {
try {
ServletOutputStream outputStream = response.getOutputStream();
response.reset();
response.setHeader("Content-disposition", "attachment; filename=\""
+ testPlanRunID.toString() + ".pdf\"");
response.addHeader("Content-Length", "" + pdfBuffer.length);
this.logger.info("report of test plan " + testPlanRunID.toString()
+ " length is: " + pdfBuffer.length);
response.setContentType("application/pdf");
outputStream.write(pdfBuffer);
outputStream.flush();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping(value = "/scriptBrief/{testPlanId}/{scriptId}/latestResult")
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public ScriptBriefResultModel getLatestScriptResult(
@PathVariable UUID testPlanId, @PathVariable int scriptId)
throws Bench4QException {
guardHasAuthentication(
"You have not power to get test plan script brief",
"/getLatestScriptResult");
return this.getTestPlanScriptResultService()
.getLatestScriptBriefResultModel(testPlanId, scriptId);
}
@RequestMapping(value = "/stop/{testPlanId}")
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResponseModel stop(@PathVariable UUID testPlanId)
throws Bench4QException {
guardHasAuthentication("You have no power to stop test plan",
"/stop/{testPlanId}");
guardIsTheOwner(testPlanId);
return buildTestPlanResponseModel(
this.getTestPlanRunner().stop(testPlanId), "",
Collections.<TestPlan> emptyList());
}
private void guardIsTheOwner(UUID testPlanId) {
if (!getPrincipal().getUserName().equals(
this.getTestPlanService().getTestPlanDBModel(testPlanId)
.getUserModel().getUserName())) {
throw new Bench4QRunTimeException("You are not the owner");
}
}
}
package org.bench4q.master.api;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.service.TestPlanEngine;
import org.bench4q.master.domain.service.TestPlanScriptResultService;
import org.bench4q.master.domain.service.TestPlanService;
import org.bench4q.master.domain.service.UserService;
import org.bench4q.master.domain.service.report.ReportService;
import org.bench4q.master.exception.Bench4QException;
import org.bench4q.master.exception.Bench4QRunTimeException;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.models.master.MonitorModel;
import org.bench4q.share.models.master.ScriptHandleModel;
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
import org.bench4q.share.models.master.TestPlanModel;
import org.bench4q.share.models.master.TestPlanDBModel;
import org.bench4q.share.models.master.TestPlanResponseModel;
import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
@Controller
@RequestMapping("/testPlan")
public class TestPlanController extends BaseController {
private TestPlanEngine testPlanRunner;
private TestPlanService testPlanService;
private ReportService reportService;
private TestPlanScriptResultService testPlanScriptResultService;
private BusinessModelMapFactory businessMapFactory;
private Logger logger = Logger.getLogger(TestPlanController.class);
private TestPlanEngine getTestPlanRunner() {
return testPlanRunner;
}
@Autowired
private void setTestPlanRunner(TestPlanEngine testPlanRunner) {
this.testPlanRunner = testPlanRunner;
}
private TestPlanService getTestPlanService() {
return this.testPlanService;
}
@Autowired
private void setTestPlanService(TestPlanService testPlanService) {
this.testPlanService = testPlanService;
}
private ReportService getReportService() {
return reportService;
}
@Autowired
private void setReportService(ReportService reportService) {
this.reportService = reportService;
}
private BusinessModelMapFactory getBusinessMapFactory() {
return businessMapFactory;
}
@Autowired
private void setBusinessMapFactory(
BusinessModelMapFactory businessMapFactory) {
this.businessMapFactory = businessMapFactory;
}
private TestPlanScriptResultService getTestPlanScriptResultService() {
return testPlanScriptResultService;
}
@Autowired
private void setTestPlanScriptResultService(
TestPlanScriptResultService testPlanScriptResultService) {
this.testPlanScriptResultService = testPlanScriptResultService;
}
@RequestMapping(value = "/run", method = {
RequestMethod.POST, RequestMethod.GET })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResultModel runTestPlanWithTestPlanModel(
@RequestBody TestPlanModel testPlanBusinessModel)
throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You don't have enough power to run a test plan!",
"/run");
}
UUID testPlanRunID = this.getTestPlanRunner().runWith(
testPlanBusinessModel, this.getPrincipal());
if (testPlanRunID == null) {
throw new Bench4QException("TestPlan_Commit_Error",
"There is an exception when commit the test plan",
"/run");
}
return buildResponseModel(this.getTestPlanService()
.queryTestPlanStatus(testPlanRunID), testPlanRunID, null,
testPlanBusinessModel.getMonitorModels());
}
private TestPlanResultModel buildResponseModel(
TestPlanStatus currentStatus, UUID testPlanId,
List<ScriptHandleModel> scripts, List<MonitorModel> monitorModels) {
TestPlanResultModel result = new TestPlanResultModel();
result.setCurrentStatus(currentStatus);
result.setTestPlanId(testPlanId);
result.setScripts(scripts);
result.setMonitorModels(monitorModels);
return result;
}
@RequestMapping(value = "/getRunningInfo", method = { RequestMethod.GET,
RequestMethod.POST })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResultModel getTestPlanRunningInfo(
@RequestParam UUID testPlanId) throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You have not power to get test plan running info",
"/getRunningInfo");
}
return this.getTestPlanService().buildResultModel(testPlanId);
}
@RequestMapping(value = "/scriptBrief/{testPlanId}/{scriptId}/{duationBegin}", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanScriptBriefResultModel getScriptBrief(
@PathVariable UUID testPlanId, @PathVariable int scriptId,
@PathVariable long duationBegin) throws Bench4QException,
NullPointerException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You have not power to get test plan script brief",
"/getRunningInfo");
}
List<ScriptBriefResultModel> scriptBriefResultModels = this
.getTestPlanScriptResultService().loadScriptBriefWithDuation(
testPlanId, scriptId, duationBegin);
System.out.println("Script Result Size : "
+ scriptBriefResultModels.size());
TestPlanScriptBriefResultModel ret = new TestPlanScriptBriefResultModel();
ret.setScriptBriefResultModels(scriptBriefResultModels);
return ret;
}
@RequestMapping(value = "/getBehaviorsBrief/{testPlanRunID}/{scriptId}")
@ResponseBody
public ScriptBehaviorsBriefModel getBehaviorsBrief(
@PathVariable UUID testPlanRunID, @PathVariable int scriptId)
throws Bench4QException, NullPointerException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER, EXCEPTION_HAPPEND
+ "when get behaviors's brief", "/getBehaviorsBrief");
}
ScriptBehaviorsBriefModel result = this
.getTestPlanScriptResultService()
.getLatestScriptBehaviorsBrief(testPlanRunID, scriptId);
return result;
}
@RequestMapping(value = "/pagesBrief/{testPlanRunId}/{scriptId}")
@ResponseBody
public ScriptPagesBriefModel getPagesBrief(
@PathVariable UUID testPlanRunId, @PathVariable int scriptId)
throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER, EXCEPTION_HAPPEND
+ "when get behaviors's brief", "/getBehaviorsBrief");
}
ScriptPagesBriefModel pagesBriefModel = this
.getTestPlanScriptResultService().getLatestScriptPagesBrief(
testPlanRunId, scriptId);
return pagesBriefModel;
}
@RequestMapping(value = "/loadTestPlans", method = { RequestMethod.GET,
RequestMethod.POST })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResponseModel loadTestPlans() {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildTestPlanResponseModel(false, "no scope", null);
}
List<TestPlan> testPlanDBs = this.testPlanService.loadTestPlans(this
.getPrincipal());
return testPlanDBs == null ? buildTestPlanResponseModel(false,
"exception", null) : buildTestPlanResponseModel(true, null,
testPlanDBs);
}
@RequestMapping(value = "/queryTestPlan/{runId}", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanDBModel queryTestPlan(@PathVariable UUID runId)
throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER, HAVE_NO_POWER,
"/queryTestPlan/{runId}");
}
return this.getTestPlanService().getTestPlanDBModel(runId);
}
@RequestMapping(value = "/removeTestPlanFromPool", method = {
RequestMethod.GET, RequestMethod.POST })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResponseModel removeTestPlanFromPool(int testPlanId) {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildTestPlanResponseModel(false, "no scope", null);
}
return buildTestPlanResponseModel(
this.testPlanService.removeTestPlanInDB(testPlanId), null, null);
}
private TestPlanResponseModel buildTestPlanResponseModel(boolean success,
String failCause, List<TestPlan> testPlanDBs) {
TestPlanResponseModel result = new TestPlanResponseModel();
result.setSuccess(success);
result.setFailCause(failCause);
List<TestPlanDBModel> modelList = new ArrayList<TestPlanDBModel>();
if (testPlanDBs != null) {
for (TestPlan testPlanDB : testPlanDBs) {
modelList.add(this.getBusinessMapFactory().toModel(testPlanDB));
}
}
result.setTestPlanDBModels(modelList);
return result;
}
@RequestMapping(value = "/getTestPlanReport", method = { RequestMethod.GET,
RequestMethod.POST })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public void getTestPlanReport(HttpServletResponse response,
@RequestParam UUID testPlanRunID) throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You have no power to get test plan report",
"/getTestPlanReport");
}
buildFileStream(response, testPlanRunID, this.getReportService()
.createReport(testPlanRunID));
}
private void buildFileStream(HttpServletResponse response,
UUID testPlanRunID, byte[] pdfBuffer) {
try {
ServletOutputStream outputStream = response.getOutputStream();
response.reset();
response.setHeader("Content-disposition", "attachment; filename=\""
+ testPlanRunID.toString() + ".pdf\"");
response.addHeader("Content-Length", "" + pdfBuffer.length);
this.logger.info("report of test plan " + testPlanRunID.toString()
+ " length is: " + pdfBuffer.length);
response.setContentType("application/pdf");
outputStream.write(pdfBuffer);
outputStream.flush();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping(value = "/scriptBrief/{testPlanId}/{scriptId}/latestResult")
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public ScriptBriefResultModel getLatestScriptResult(
@PathVariable UUID testPlanId, @PathVariable int scriptId)
throws Bench4QException {
guardHasAuthentication(
"You have not power to get test plan script brief",
"/getLatestScriptResult");
return this.getTestPlanScriptResultService()
.getLatestScriptBriefResultModel(testPlanId, scriptId);
}
@RequestMapping(value = "/stop/{testPlanId}")
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public TestPlanResponseModel stop(@PathVariable UUID testPlanId)
throws Bench4QException {
guardHasAuthentication("You have no power to stop test plan",
"/stop/{testPlanId}");
guardIsTheOwner(testPlanId);
return buildTestPlanResponseModel(
this.getTestPlanRunner().stop(testPlanId), "",
Collections.<TestPlan> emptyList());
}
private void guardIsTheOwner(UUID testPlanId) {
if (!getPrincipal().getUserName().equals(
this.getTestPlanService().getTestPlanDBModel(testPlanId)
.getUserModel().getUserName())) {
throw new Bench4QRunTimeException("You are not the owner");
}
}
}

View File

@ -29,13 +29,13 @@ public class ProxyServer implements Runnable {
public void removeObserver(Observer proxy) {
this.listeners.removeElement(proxy);
}
public void processRequest(HttpRequestHeader header, byte[] requestBody)
throws Exception {
for (Enumeration<Observer> e = this.listeners.elements(); e
.hasMoreElements();) {
Observer pl = (Observer) e.nextElement();
pl.processRequest(header, requestBody);
pl.processRequest(header, requestBody);
}
}

View File

@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.bench4q.share.models.agent.scriptrecord.PageModel;
import org.bench4q.share.models.agent.scriptrecord.TestScheduleModel;
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
@XmlRootElement(name = "runScenario")
@ -15,6 +16,7 @@ public class RunScenarioModel {
private int poolSize;
private List<UsePluginModel> usePlugins;
private List<PageModel> pages;
private TestScheduleModel scheduleModel;
@XmlElement
public int getPoolSize() {
@ -45,6 +47,15 @@ public class RunScenarioModel {
this.pages = pages;
}
@XmlElement
public TestScheduleModel getScheduleModel() {
return scheduleModel;
}
public void setScheduleModel(TestScheduleModel scheduleModel) {
this.scheduleModel = scheduleModel;
}
public RunScenarioModel() {
this.setUsePlugins(new LinkedList<UsePluginModel>());
this.setPages(new LinkedList<PageModel>());

View File

@ -1,44 +0,0 @@
package org.bench4q.share.models.agent.scriptrecord;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class RunScenarioModelNew {
private int poolSize;
private List<UsePluginModel> usePlugins;
private List<BehaviorModel> behaviors;
@XmlElement
public int getPoolSize() {
return poolSize;
}
public void setPoolSize(int poolSize) {
this.poolSize = poolSize;
}
@XmlElementWrapper(name = "plugins")
@XmlElement(name = "plugin")
public List<UsePluginModel> getUsePlugins() {
return usePlugins;
}
public void setUsePlugins(List<UsePluginModel> usePlugins) {
this.usePlugins = usePlugins;
}
@XmlElementWrapper(name = "behaviors")
@XmlElement(name = "behavior")
public List<BehaviorModel> getBehaviors() {
return behaviors;
}
public void setBehaviors(List<BehaviorModel> behaviors) {
this.behaviors = behaviors;
}
}

View File

@ -0,0 +1,52 @@
package org.bench4q.share.models.agent.scriptrecord;
import java.util.LinkedList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class TestScheduleModel {
private List<PointModel> points;
@XmlElementWrapper(name = "points")
@XmlElement(name = "point")
public List<PointModel> getPoints() {
return points;
}
public void setPoints(List<PointModel> points) {
this.points = points;
}
public TestScheduleModel() {
this.points = new LinkedList<PointModel>();
}
@XmlRootElement
public static class PointModel {
private int time;
private int load;
@XmlElement
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
@XmlElement
public int getLoad() {
return load;
}
public void setLoad(int load) {
this.load = load;
}
}
}

View File

@ -1,271 +1,271 @@
package org.bench4q.web.masterMessager;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
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.TestPlanDBModel;
import org.bench4q.share.models.master.TestPlanResponseModel;
import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel;
import org.springframework.stereotype.Component;
@Component
public class TestPlanMessager extends MasterMessager {
public TestPlanMessager() {
super(MasterAddressManamger.getMasterAddress() + "/testPlan");
}
public HttpResponse loadReport(String accessToken, String testPlanId) {
String url = this.getBaseUrl() + "/getTestPlanReport";
HttpResponse httpResponse = null;
try {
Map<String, String> params = new HashMap<String, String>();
params.put("testPlanRunID", testPlanId);
httpResponse = this.getHttpRequester().sendGet(url, params,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
return null;
}
return httpResponse;
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
public TestPlanResultModel runTestPlan(String accessToken,
String testPlanXmlContent) {
String url = this.getBaseUrl() + "/runTestPlanWithTestPlanModel";
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPostXml(url,
testPlanXmlContent, makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return extractTestPlanResultModel(httpResponse);
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
public TestPlanResultModel getRunningTestInfo(String accessToken,
String testPlanId) {
String url = this.getBaseUrl() + "/getRunningInfo";
Map<String, String> params = new HashMap<String, String>();
params.put("testPlanId", testPlanId);
return this.getTestPlanResultModelByPost(url, params, accessToken);
}
public TestPlanScriptBriefResultModel getScriptBriefResult(
String accessToken, String testPlanId, String scriptId,
String duationBegin) {
String url = this.getBaseUrl() + "/scriptBrief" + "/" + testPlanId
+ "/" + scriptId + "/" + duationBegin;
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return (TestPlanScriptBriefResultModel) MarshalHelper.unmarshal(
TestPlanScriptBriefResultModel.class,
httpResponse.getContent());
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
public ScriptBehaviorsBriefModel getScriptBehaviorsBriefResult(
String accessToken, String testPlanId, String scriptId) {
String url = this.getBaseUrl() + "/getBehaviorsBrief" + "/"
+ testPlanId + "/" + scriptId;
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return (ScriptBehaviorsBriefModel) MarshalHelper.unmarshal(
ScriptBehaviorsBriefModel.class, httpResponse.getContent());
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
public TestPlanDBModel queryTestPlanById(String accessToken,
String testPlanRunId) {
String url = this.getBaseUrl() + "/queryTestPlan" + "/" + testPlanRunId;
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return (TestPlanDBModel) MarshalHelper.unmarshal(
TestPlanDBModel.class, httpResponse.getContent());
} catch (Exception e) {
handleException(httpResponse, e);
return null;
}
}
public TestPlanResponseModel deleteTestPlan(String accessToken,
String testPlanId) {
String url = this.getBaseUrl() + "/removeTestPlanFromPool";
Map<String, String> params = new HashMap<String, String>();
params.put("testPlanId", testPlanId);
return getTestPlanResponseModel(url, params, accessToken);
}
public TestPlanResponseModel loadTestPlans(String accessToken) {
String url = this.getBaseUrl() + "/loadTestPlans";
return getTestPlanResponseModel(url, null, accessToken);
}
public HttpResponse getTestPlanReport(String accessToken,
String testPlanRunId) {
String url = this.getBaseUrl() + "/getTestPlanReport";
Map<String, String> params = new HashMap<String, String>();
params.put("testPlanRunID", testPlanRunId);
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPost(url, params,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return httpResponse;
} catch (IOException e) {
this.handleException(httpResponse, e);
return null;
}
}
private TestPlanResponseModel getTestPlanResponseModel(String url,
Map<String, String> params, String accessToken) {
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPost(url, params,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return extractTestPlanResponseModel(httpResponse);
} catch (Exception e) {
this.handleException(httpResponse, e);
return createFailTestPlanResponseModel();
}
}
private TestPlanResponseModel createFailTestPlanResponseModel() {
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
testPlanResponseModel.setSuccess(false);
testPlanResponseModel.setFailCause("");
return testPlanResponseModel;
}
private TestPlanResultModel getTestPlanResultModelByPost(String url,
Map<String, String> params, String accessToken) {
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPost(url, params,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return extractTestPlanResultModel(httpResponse);
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
private TestPlanResponseModel extractTestPlanResponseModel(
HttpResponse httpResponse) throws JAXBException,
UnsupportedEncodingException {
return (TestPlanResponseModel) MarshalHelper.unmarshal(
TestPlanResponseModel.class, httpResponse.getContent());
}
private TestPlanResultModel extractTestPlanResultModel(
HttpResponse httpResponse) throws JAXBException,
UnsupportedEncodingException {
return (TestPlanResultModel) MarshalHelper.unmarshal(
TestPlanResultModel.class, httpResponse.getContent());
}
public ScriptBriefResultModel getLatestScriptBriefResult(
String accessToken, String testPlanId, String scriptId) {
String url = this.baseUrl + "/scriptBrief" + "/" + testPlanId + "/"
+ scriptId + "/latestResult";
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return (ScriptBriefResultModel) MarshalHelper.tryUnmarshal(
ScriptBriefResultModel.class, httpResponse.getContent());
} catch (Exception e) {
handleException(httpResponse, e);
return null;
}
}
public ScriptPagesBriefModel getScriptPageBriefModel(String accessToken,
String testPlanId, String scriptId) {
String url = this.baseUrl + "/pagesBrief" + "/" + testPlanId + "/"
+ scriptId;
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return (ScriptPagesBriefModel) MarshalHelper.unmarshal(
ScriptPagesBriefModel.class, httpResponse.getContent());
} catch (Exception e) {
handleException(httpResponse, e);
return null;
}
}
public TestPlanResponseModel stopTestPlan(String accessToken,
String testPlanRunId) {
String url = this.baseUrl + "/stop" + "/" + testPlanRunId;
return getTestPlanResponseModel(url, null, accessToken);
}
package org.bench4q.web.masterMessager;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
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.TestPlanDBModel;
import org.bench4q.share.models.master.TestPlanResponseModel;
import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel;
import org.springframework.stereotype.Component;
@Component
public class TestPlanMessager extends MasterMessager {
public TestPlanMessager() {
super(MasterAddressManamger.getMasterAddress() + "/testPlan");
}
public HttpResponse loadReport(String accessToken, String testPlanId) {
String url = this.getBaseUrl() + "/getTestPlanReport";
HttpResponse httpResponse = null;
try {
Map<String, String> params = new HashMap<String, String>();
params.put("testPlanRunID", testPlanId);
httpResponse = this.getHttpRequester().sendGet(url, params,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
return null;
}
return httpResponse;
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
public TestPlanResultModel runTestPlan(String accessToken,
String testPlanXmlContent) {
String url = this.getBaseUrl() + "/run";
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPostXml(url,
testPlanXmlContent, makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return extractTestPlanResultModel(httpResponse);
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
public TestPlanResultModel getRunningTestInfo(String accessToken,
String testPlanId) {
String url = this.getBaseUrl() + "/getRunningInfo";
Map<String, String> params = new HashMap<String, String>();
params.put("testPlanId", testPlanId);
return this.getTestPlanResultModelByPost(url, params, accessToken);
}
public TestPlanScriptBriefResultModel getScriptBriefResult(
String accessToken, String testPlanId, String scriptId,
String duationBegin) {
String url = this.getBaseUrl() + "/scriptBrief" + "/" + testPlanId
+ "/" + scriptId + "/" + duationBegin;
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return (TestPlanScriptBriefResultModel) MarshalHelper.unmarshal(
TestPlanScriptBriefResultModel.class,
httpResponse.getContent());
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
public ScriptBehaviorsBriefModel getScriptBehaviorsBriefResult(
String accessToken, String testPlanId, String scriptId) {
String url = this.getBaseUrl() + "/getBehaviorsBrief" + "/"
+ testPlanId + "/" + scriptId;
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return (ScriptBehaviorsBriefModel) MarshalHelper.unmarshal(
ScriptBehaviorsBriefModel.class, httpResponse.getContent());
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
public TestPlanDBModel queryTestPlanById(String accessToken,
String testPlanRunId) {
String url = this.getBaseUrl() + "/queryTestPlan" + "/" + testPlanRunId;
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return (TestPlanDBModel) MarshalHelper.unmarshal(
TestPlanDBModel.class, httpResponse.getContent());
} catch (Exception e) {
handleException(httpResponse, e);
return null;
}
}
public TestPlanResponseModel deleteTestPlan(String accessToken,
String testPlanId) {
String url = this.getBaseUrl() + "/removeTestPlanFromPool";
Map<String, String> params = new HashMap<String, String>();
params.put("testPlanId", testPlanId);
return getTestPlanResponseModel(url, params, accessToken);
}
public TestPlanResponseModel loadTestPlans(String accessToken) {
String url = this.getBaseUrl() + "/loadTestPlans";
return getTestPlanResponseModel(url, null, accessToken);
}
public HttpResponse getTestPlanReport(String accessToken,
String testPlanRunId) {
String url = this.getBaseUrl() + "/getTestPlanReport";
Map<String, String> params = new HashMap<String, String>();
params.put("testPlanRunID", testPlanRunId);
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPost(url, params,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return httpResponse;
} catch (IOException e) {
this.handleException(httpResponse, e);
return null;
}
}
private TestPlanResponseModel getTestPlanResponseModel(String url,
Map<String, String> params, String accessToken) {
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPost(url, params,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return extractTestPlanResponseModel(httpResponse);
} catch (Exception e) {
this.handleException(httpResponse, e);
return createFailTestPlanResponseModel();
}
}
private TestPlanResponseModel createFailTestPlanResponseModel() {
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
testPlanResponseModel.setSuccess(false);
testPlanResponseModel.setFailCause("");
return testPlanResponseModel;
}
private TestPlanResultModel getTestPlanResultModelByPost(String url,
Map<String, String> params, String accessToken) {
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPost(url, params,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return extractTestPlanResultModel(httpResponse);
} catch (Exception e) {
this.handleException(httpResponse, e);
return null;
}
}
private TestPlanResponseModel extractTestPlanResponseModel(
HttpResponse httpResponse) throws JAXBException,
UnsupportedEncodingException {
return (TestPlanResponseModel) MarshalHelper.unmarshal(
TestPlanResponseModel.class, httpResponse.getContent());
}
private TestPlanResultModel extractTestPlanResultModel(
HttpResponse httpResponse) throws JAXBException,
UnsupportedEncodingException {
return (TestPlanResultModel) MarshalHelper.unmarshal(
TestPlanResultModel.class, httpResponse.getContent());
}
public ScriptBriefResultModel getLatestScriptBriefResult(
String accessToken, String testPlanId, String scriptId) {
String url = this.baseUrl + "/scriptBrief" + "/" + testPlanId + "/"
+ scriptId + "/latestResult";
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return (ScriptBriefResultModel) MarshalHelper.tryUnmarshal(
ScriptBriefResultModel.class, httpResponse.getContent());
} catch (Exception e) {
handleException(httpResponse, e);
return null;
}
}
public ScriptPagesBriefModel getScriptPageBriefModel(String accessToken,
String testPlanId, String scriptId) {
String url = this.baseUrl + "/pagesBrief" + "/" + testPlanId + "/"
+ scriptId;
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendGet(url, null,
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse)) {
handleInvalidatedResponse(url);
return null;
}
return (ScriptPagesBriefModel) MarshalHelper.unmarshal(
ScriptPagesBriefModel.class, httpResponse.getContent());
} catch (Exception e) {
handleException(httpResponse, e);
return null;
}
}
public TestPlanResponseModel stopTestPlan(String accessToken,
String testPlanRunId) {
String url = this.baseUrl + "/stop" + "/" + testPlanRunId;
return getTestPlanResponseModel(url, null, accessToken);
}
}

View File

@ -1 +1 @@
masterAddress=localhost:8901
masterAddress=133.133.2.105:8901

View File

@ -1,176 +1,176 @@
package org.bench4q.web.test.masterMessager;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.*;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.TestPlanResponseModel;
import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.web.masterMessager.TestPlanMessager;
import org.junit.AfterClass;
import org.junit.BeforeClass;
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("file:src/test/resources/bench4qweb-servlet.xml")
public class TestPlanMessageTest extends MessagerTestBase {
private TestPlanMessager testPlanMessager;
private String baseUrl = "/testPlan";
private String testPlanId = "testPlanId";
private String scriptId = "scriptId";
public TestPlanMessager getTestPlanMessager() {
return testPlanMessager;
}
@Autowired
public void setTestPlanMessager(TestPlanMessager testPlanMessager) {
this.testPlanMessager = testPlanMessager;
}
@BeforeClass
public static void setUp() {
startServer();
}
@AfterClass
public static void clear() {
stopServer();
}
@Test
public void test_runTestPlan() {
String url = baseUrl + "/runTestPlanWithTestPlanModel";
this.getWireMock().register(
post(urlEqualTo(url)).willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(this.createResponse())));
assertNotNull(this.testPlanMessager.runTestPlan(null, ""));
}
@Test
public void test_getRunningTestInfo() {
String url = baseUrl + "/getRunningInfo";
this.getWireMock().register(
post(urlEqualTo(url)).withRequestBody(containing("testPlanId"))
.willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(this.createResponse())));
assertNotNull(this.testPlanMessager.getRunningTestInfo(null, ""));
}
// @Test
// public void test_getScriptBriefResult() {
// TestPlanScriptBriefResultModel testPlanScriptBriefResultModel = new
// TestPlanScriptBriefResultModel();
// String response = MarshalHelper
// .tryMarshal(testPlanScriptBriefResultModel);
// String url = baseUrl + '/' + testPlanId + '/' + scriptId + '/'
// + duationBegin;
// System.out.println(url);
// this.getWireMock().register(
// get(urlEqualTo(url)).willReturn(
// aResponse().withStatus(200)
// .withHeader("Content-Type", "text/xml")
// .withBody(response)));
// assertNotNull(this.testPlanMessager.getScriptBriefResult(null,
// testPlanId, scriptId, duationBegin));
// }
@Test
public void test_getScriptBehaviorsBriefResult() {
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = new ScriptBehaviorsBriefModel();
scriptBehaviorsBriefModel.setFinished(true);
String response = MarshalHelper.tryMarshal(scriptBehaviorsBriefModel);
String url = baseUrl +"/getBehaviorsBrief"+ '/' + testPlanId + '/' + scriptId;
this.getWireMock().register(
get(urlEqualTo(url)).willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(response)));
assertNotNull(this.testPlanMessager.getScriptBehaviorsBriefResult(null,
testPlanId, scriptId));
assertTrue(this.testPlanMessager.getScriptBehaviorsBriefResult(null,
testPlanId, scriptId).isFinished());
}
// @Test
// public void test_getPageBriefResult() {
// ScriptPagesBriefModel scriptPagesBriefModel = new ScriptPagesBriefModel();
// String response = MarshalHelper.tryMarshal(scriptPagesBriefModel);
// String url = baseUrl + '/' + testPlanId + '/' + scriptId;
// this.getWireMock().register(
// get(urlEqualTo(url)).willReturn(
// aResponse().withStatus(200)
// .withHeader("Content-Type", "text/xml")
// .withBody(response)));
// assertNotNull(this.testPlanMessager.getPageBriefResult(null,
// testPlanId, scriptId));
// }
// @Test
// public void test_queryTestPlanById() {
// String testPlanRunId = "testPlanRunId";
// String url = baseUrl + "/queryTestPlan/" + testPlanRunId;
// this.getWireMock().register(
// get(urlEqualTo(url)).willReturn(
// aResponse().withStatus(200)
// .withHeader("Content-Type", "text/xml")
// .withBody(this.createResponse())));
// assertNotNull(this.testPlanMessager.queryTestPlanById(null,
// testPlanRunId));
// }
@Test
public void test_deleteTestPlan() {
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
testPlanResponseModel.setSuccess(true);
String response = MarshalHelper.tryMarshal(testPlanResponseModel);
String url = baseUrl + "/removeTestPlanFromPool";
this.getWireMock().register(
post(urlEqualTo(url)).withRequestBody(containing("testPlanId"))
.willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(response)));
assertNotNull(this.testPlanMessager.deleteTestPlan(null, testPlanId));
assertTrue(this.testPlanMessager.deleteTestPlan(null, testPlanId)
.isSuccess());
}
@Test
public void test_loadTestPlans() {
String url = baseUrl + "/loadTestPlans";
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
testPlanResponseModel.setSuccess(true);
String response = MarshalHelper.tryMarshal(testPlanResponseModel);
this.getWireMock().register(
post(urlEqualTo(url)).willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(response)));
assertNotNull(this.testPlanMessager.loadTestPlans(null));
assertTrue(this.testPlanMessager.loadTestPlans(null).isSuccess());
}
@Test
public void test_getTestPlanReport() {
}
public String createResponse() {
TestPlanResultModel testPlanResultModel = new TestPlanResultModel();
return MarshalHelper.tryMarshal(testPlanResultModel);
}
}
package org.bench4q.web.test.masterMessager;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.*;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.TestPlanResponseModel;
import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.web.masterMessager.TestPlanMessager;
import org.junit.AfterClass;
import org.junit.BeforeClass;
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("file:src/test/resources/bench4qweb-servlet.xml")
public class TestPlanMessageTest extends MessagerTestBase {
private TestPlanMessager testPlanMessager;
private String baseUrl = "/testPlan";
private String testPlanId = "testPlanId";
private String scriptId = "scriptId";
public TestPlanMessager getTestPlanMessager() {
return testPlanMessager;
}
@Autowired
public void setTestPlanMessager(TestPlanMessager testPlanMessager) {
this.testPlanMessager = testPlanMessager;
}
@BeforeClass
public static void setUp() {
startServer();
}
@AfterClass
public static void clear() {
stopServer();
}
@Test
public void test_runTestPlan() {
String url = baseUrl + "/run";
this.getWireMock().register(
post(urlEqualTo(url)).willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(this.createResponse())));
assertNotNull(this.testPlanMessager.runTestPlan(null, ""));
}
@Test
public void test_getRunningTestInfo() {
String url = baseUrl + "/getRunningInfo";
this.getWireMock().register(
post(urlEqualTo(url)).withRequestBody(containing("testPlanId"))
.willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(this.createResponse())));
assertNotNull(this.testPlanMessager.getRunningTestInfo(null, ""));
}
// @Test
// public void test_getScriptBriefResult() {
// TestPlanScriptBriefResultModel testPlanScriptBriefResultModel = new
// TestPlanScriptBriefResultModel();
// String response = MarshalHelper
// .tryMarshal(testPlanScriptBriefResultModel);
// String url = baseUrl + '/' + testPlanId + '/' + scriptId + '/'
// + duationBegin;
// System.out.println(url);
// this.getWireMock().register(
// get(urlEqualTo(url)).willReturn(
// aResponse().withStatus(200)
// .withHeader("Content-Type", "text/xml")
// .withBody(response)));
// assertNotNull(this.testPlanMessager.getScriptBriefResult(null,
// testPlanId, scriptId, duationBegin));
// }
@Test
public void test_getScriptBehaviorsBriefResult() {
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = new ScriptBehaviorsBriefModel();
scriptBehaviorsBriefModel.setFinished(true);
String response = MarshalHelper.tryMarshal(scriptBehaviorsBriefModel);
String url = baseUrl +"/getBehaviorsBrief"+ '/' + testPlanId + '/' + scriptId;
this.getWireMock().register(
get(urlEqualTo(url)).willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(response)));
assertNotNull(this.testPlanMessager.getScriptBehaviorsBriefResult(null,
testPlanId, scriptId));
assertTrue(this.testPlanMessager.getScriptBehaviorsBriefResult(null,
testPlanId, scriptId).isFinished());
}
// @Test
// public void test_getPageBriefResult() {
// ScriptPagesBriefModel scriptPagesBriefModel = new ScriptPagesBriefModel();
// String response = MarshalHelper.tryMarshal(scriptPagesBriefModel);
// String url = baseUrl + '/' + testPlanId + '/' + scriptId;
// this.getWireMock().register(
// get(urlEqualTo(url)).willReturn(
// aResponse().withStatus(200)
// .withHeader("Content-Type", "text/xml")
// .withBody(response)));
// assertNotNull(this.testPlanMessager.getPageBriefResult(null,
// testPlanId, scriptId));
// }
// @Test
// public void test_queryTestPlanById() {
// String testPlanRunId = "testPlanRunId";
// String url = baseUrl + "/queryTestPlan/" + testPlanRunId;
// this.getWireMock().register(
// get(urlEqualTo(url)).willReturn(
// aResponse().withStatus(200)
// .withHeader("Content-Type", "text/xml")
// .withBody(this.createResponse())));
// assertNotNull(this.testPlanMessager.queryTestPlanById(null,
// testPlanRunId));
// }
@Test
public void test_deleteTestPlan() {
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
testPlanResponseModel.setSuccess(true);
String response = MarshalHelper.tryMarshal(testPlanResponseModel);
String url = baseUrl + "/removeTestPlanFromPool";
this.getWireMock().register(
post(urlEqualTo(url)).withRequestBody(containing("testPlanId"))
.willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(response)));
assertNotNull(this.testPlanMessager.deleteTestPlan(null, testPlanId));
assertTrue(this.testPlanMessager.deleteTestPlan(null, testPlanId)
.isSuccess());
}
@Test
public void test_loadTestPlans() {
String url = baseUrl + "/loadTestPlans";
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
testPlanResponseModel.setSuccess(true);
String response = MarshalHelper.tryMarshal(testPlanResponseModel);
this.getWireMock().register(
post(urlEqualTo(url)).willReturn(
aResponse().withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(response)));
assertNotNull(this.testPlanMessager.loadTestPlans(null));
assertTrue(this.testPlanMessager.loadTestPlans(null).isSuccess());
}
@Test
public void test_getTestPlanReport() {
}
public String createResponse() {
TestPlanResultModel testPlanResultModel = new TestPlanResultModel();
return MarshalHelper.tryMarshal(testPlanResultModel);
}
}