refactor MarshalHelper to generic

refactor MarshalHelper to generic
This commit is contained in:
coderfengyun 2014-09-15 21:46:03 +08:00
parent 7d7d8c7837
commit b1d0f3eb1d
40 changed files with 184 additions and 205 deletions

View File

@ -86,11 +86,11 @@ public class TestController {
try {
this.getParamFileCollector().collectParamFiles(files, runId);
System.out.println(scenarioModel);
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.unmarshal(RunScenarioModel.class, scenarioModel);
RunScenarioModel runScenarioModel = MarshalHelper.unmarshal(
RunScenarioModel.class, scenarioModel);
System.out.println(scheduleContent);
this.logger.info(scheduleContent);
ScheduleModel scheduleModel = (ScheduleModel) MarshalHelper
ScheduleModel scheduleModel = MarshalHelper
.unmarshal(ScheduleModel.class, scheduleContent);
this.getScenarioEngine().submitScenario(runId,
Scenario.scenarioCompiler(runScenarioModel),

View File

@ -67,12 +67,11 @@ public class Scenario {
}
public static Scenario scenarioBuilderWithCompile(String scenarioContent) {
return scenarioCompiler((RunScenarioModel) MarshalHelper
.tryUnmarshal(RunScenarioModel.class, scenarioContent));
return scenarioCompiler(MarshalHelper.tryUnmarshal(
RunScenarioModel.class, scenarioContent));
}
public static Scenario scenarioCompiler(
RunScenarioModel scenarioModel) {
public static Scenario scenarioCompiler(RunScenarioModel scenarioModel) {
if (scenarioModel == null) {
throw new NullPointerException();
}

View File

@ -17,7 +17,7 @@ public class ExtractScenarioTest {
@Test
public void test() throws JAXBException, IOException {
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
RunScenarioModel runScenarioModel = MarshalHelper
.unmarshal(RunScenarioModel.class, FileUtils
.readFileToString(new File("Scripts/goodForPage.xml")));
Scenario scenario = Scenario.scenarioCompiler(runScenarioModel);

View File

@ -82,9 +82,8 @@ public class TestWithScriptFile extends TestBase {
HttpResponse httpResponse = this.getHttpRequester().sendPostXml(
this.url + "/runWithoutParams",
marshalRunScenarioModel(runScenarioModel), null);
RunScenarioResultModel resultModel = (RunScenarioResultModel) MarshalHelper
.unmarshal(RunScenarioResultModel.class,
httpResponse.getContent());
RunScenarioResultModel resultModel = MarshalHelper.unmarshal(
RunScenarioResultModel.class, httpResponse.getContent());
this.setTestId(resultModel.getRunId());
} catch (IOException e) {
System.out.println("IO exception!");
@ -138,9 +137,8 @@ public class TestWithScriptFile extends TestBase {
HttpResponse httpResponse = this.getHttpRequester().sendGet(
this.url + "/brief/" + this.getTestId().toString(), null, null);
System.out.println(httpResponse.getContent());
AgentBriefStatusModel briefModel = (AgentBriefStatusModel) MarshalHelper
.unmarshal(AgentBriefStatusModel.class,
httpResponse.getContent());
AgentBriefStatusModel briefModel = MarshalHelper.unmarshal(
AgentBriefStatusModel.class, httpResponse.getContent());
assertTrue(briefModel.getTimeFrame() > 0);
}
@ -150,9 +148,8 @@ public class TestWithScriptFile extends TestBase {
this.url + "/behaviorsBrief/" + this.getTestId().toString(),
null, null);
System.out.println(httpResponse.getContent());
AgentBehaviorsBriefModel behaviorsBriefModel = (AgentBehaviorsBriefModel) MarshalHelper
.unmarshal(AgentBehaviorsBriefModel.class,
httpResponse.getContent());
AgentBehaviorsBriefModel behaviorsBriefModel = MarshalHelper.unmarshal(
AgentBehaviorsBriefModel.class, httpResponse.getContent());
assertTrue(behaviorsBriefModel.getBehaviorBriefModels().size() > 0);
}
@ -161,8 +158,8 @@ public class TestWithScriptFile extends TestBase {
HttpResponse httpResponse = this.getHttpRequester().sendGet(
this.url + "/brief/" + this.getTestId().toString() + "/0",
null, null);
BehaviorBriefModel behaviorBriefModel = (BehaviorBriefModel) MarshalHelper
.unmarshal(BehaviorBriefModel.class, httpResponse.getContent());
BehaviorBriefModel behaviorBriefModel = MarshalHelper.unmarshal(
BehaviorBriefModel.class, httpResponse.getContent());
assertTrue(behaviorBriefModel.getDetailStatusCodeResultModels().size() > 0);
}
@ -196,7 +193,7 @@ public class TestWithScriptFile extends TestBase {
+ "testJD.xml"));
HttpResponse httpResponse1 = this.getHttpRequester().sendPost(
url + "/bookTest/20", null, null);
RunScenarioResultModel bookResponse = (RunScenarioResultModel) MarshalHelper
RunScenarioResultModel bookResponse = MarshalHelper
.tryUnmarshal(RunScenarioResultModel.class,
httpResponse1.getContent());
assertNotNull(bookResponse);
@ -216,7 +213,7 @@ public class TestWithScriptFile extends TestBase {
assertNotNull(httpResponse);
assertNotNull(httpResponse.getContent());
assertEquals(200, httpResponse.getCode());
RunScenarioResultModel resultModel = (RunScenarioResultModel) MarshalHelper
RunScenarioResultModel resultModel = MarshalHelper
.tryUnmarshal(RunScenarioResultModel.class,
httpResponse.getContent());
String dirPath = (String) TestHelper.invokePrivate(
@ -244,9 +241,8 @@ public class TestWithScriptFile extends TestBase {
fail();
}
System.out.println(httpResponse);
AgentPageBriefModel pageBriefModel = (AgentPageBriefModel) MarshalHelper
.unmarshal(AgentPageBriefModel.class,
httpResponse.getContent());
AgentPageBriefModel pageBriefModel = MarshalHelper.unmarshal(
AgentPageBriefModel.class, httpResponse.getContent());
assertTrue(pageBriefModel.getCountFromBegin() > 0);
} catch (Exception e) {
this.stopTest();

View File

@ -149,7 +149,7 @@ public class Test_HttpPlugin extends TestBase {
@Test
public void buildAScenario() throws IOException {
RunScenarioModel scenarioMode = (RunScenarioModel) MarshalHelper
RunScenarioModel scenarioMode = MarshalHelper
.tryUnmarshal(RunScenarioModel.class, FileUtils
.readFileToString(new File(
"Scripts/httpWithoutTimer.xml")));

View File

@ -178,11 +178,11 @@ public class RunningAgentDB implements RunningAgentInterface {
public boolean distributeScriptAndParams() {
Script script2 = this.getTestPlanScript().getScript();
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.tryUnmarshal(RunScenarioModel.class, this.getTestPlanScript()
RunScenarioModel runScenarioModel = MarshalHelper.tryUnmarshal(
RunScenarioModel.class, this.getTestPlanScript()
.getFilteredScriptCnt());
runScenarioModel.setPoolSize(getLoadInUse());
ScheduleModel scheduleModel = generateScheduleModelWithRatio((ScheduleModel) MarshalHelper
ScheduleModel scheduleModel = generateScheduleModelWithRatio(MarshalHelper
.tryUnmarshal(ScheduleModel.class, this.getTestPlanScript()
.getScheduleContent()));
RunScenarioResultModel runScenarioResultModel = this

View File

@ -147,9 +147,8 @@ public class TestPlanScript implements RunningScriptInterface {
@Transient
public RunScenarioModel getScenario() {
try {
return (RunScenarioModel) MarshalHelper
.unmarshal(RunScenarioModel.class, this.getScript()
.getScriptContent());
return MarshalHelper.unmarshal(RunScenarioModel.class, this
.getScript().getScriptContent());
} catch (Exception e) {
Logger.getLogger(TestPlanScript.class).error(
ExceptionLog.getStackTrace(e));

View File

@ -18,8 +18,8 @@ import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
@Entity
@Table(name = "TestPlanScriptResult")
public class TestPlanScriptResult {
// private int testPlanId;
// private int scriptId,
// private int testPlanId;
// private int scriptId,
private int id;
private TestPlanScript testPlanScript;
private String resultContent;
@ -76,8 +76,8 @@ public class TestPlanScriptResult {
public ScriptBriefResultModel extractScriptBriefResultModel() {
try {
return (ScriptBriefResultModel) MarshalHelper.unmarshal(
ScriptBriefResultModel.class, this.getResultContent());
return MarshalHelper.unmarshal(ScriptBriefResultModel.class,
this.getResultContent());
} catch (JAXBException e) {
return null;
}

View File

@ -172,7 +172,7 @@ public class TestPlanFactory {
if (scriptFilterOptionsModel == null) {
return scriptContent;
}
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
RunScenarioModel runScenarioModel = MarshalHelper
.tryUnmarshal(RunScenarioModel.class, scriptContent);
List<String> filterPluginId = new ArrayList<String>();
if (scriptFilterOptionsModel.isFilterTimer()) {

View File

@ -129,7 +129,6 @@ public class MonitorResultService {
}
}
@SuppressWarnings("unchecked")
private <T1 extends SampleModel, T2 extends MonitorResultBase> T2 loadMonitorResultModel(
UUID testPlanRunId, String hostName, long beginTime,
Class<T1> fromMonitorClass, Class<T2> resultClass) throws Exception {
@ -143,7 +142,7 @@ public class MonitorResultService {
assert (fromMonitorClass.getName().equals(monitorResult
.getType()));
T1 result = (T1) MarshalHelper.unmarshal(fromMonitorClass,
T1 result = MarshalHelper.unmarshal(fromMonitorClass,
monitorResult.getContent());
ret.add(result);

View File

@ -94,8 +94,7 @@ public class ScriptService {
return null;
}
try {
return (RunScenarioModel) MarshalHelper.unmarshal(
RunScenarioModel.class, content);
return MarshalHelper.unmarshal(RunScenarioModel.class, content);
} catch (JAXBException e) {
logger.error(ExceptionLog.getStackTrace(e));
return null;

View File

@ -58,7 +58,7 @@ public class TestPlanScriptResultService {
System.out.println("Script Result Size from DB : "
+ scriptResults.size());
for (TestPlanScriptResult testPlanScriptResult : scriptResults) {
result.add((ScriptBriefResultModel) MarshalHelper.unmarshal(
result.add(MarshalHelper.unmarshal(
ScriptBriefResultModel.class,
testPlanScriptResult.getResultContent()));
}
@ -98,8 +98,7 @@ public class TestPlanScriptResultService {
if (testPlanScriptResult == null) {
return new ScriptBehaviorsBriefModel();
}
return (ScriptBehaviorsBriefModel) MarshalHelper.unmarshal(
ScriptBehaviorsBriefModel.class,
return MarshalHelper.unmarshal(ScriptBehaviorsBriefModel.class,
testPlanScriptResult.getResultContent());
} catch (Exception e) {
logger.error(ExceptionLog.getStackTrace(e));
@ -138,8 +137,7 @@ public class TestPlanScriptResultService {
if (testPlanScriptResult == null) {
return result;
}
result = (ScriptPagesBriefModel) MarshalHelper.unmarshal(
ScriptPagesBriefModel.class,
result = MarshalHelper.unmarshal(ScriptPagesBriefModel.class,
testPlanScriptResult.getResultContent());
} catch (Exception e) {
logger.error(ExceptionLog.getStackTrace(e));
@ -159,7 +157,7 @@ public class TestPlanScriptResultService {
if (testPlanScriptResult == null) {
return null;
}
return (ScriptBriefResultModel) MarshalHelper.tryUnmarshal(
return MarshalHelper.tryUnmarshal(
ScriptBriefResultModel.class,
testPlanScriptResult.getResultContent());
}

View File

@ -62,7 +62,8 @@ public class MonitorReportService {
this.monitorResultService = monitorResultService;
}
void createMonitorResultImages(UUID testPlanRunID, Document document) throws Bench4QException {
void createMonitorResultImages(UUID testPlanRunID, Document document)
throws Bench4QException {
Map<String, MonitorResultContainerModel> SUTResultMap = new HashMap<String, MonitorResultContainerModel>();
List<MonitorResult> results = this.getMonitorResultService()
.queryMonitorResults(testPlanRunID);
@ -98,23 +99,23 @@ public class MonitorReportService {
try {
if (Class.forName(result.getType()).equals(PhysicalDiskModel.class)) {
container.getLogicalDiskModels().add(
(PhysicalDiskModel) MarshalHelper.unmarshal(
PhysicalDiskModel.class, result.getContent()));
MarshalHelper.unmarshal(PhysicalDiskModel.class,
result.getContent()));
} else if (Class.forName(result.getType())
.equals(MemoryModel.class)) {
container.getMemoryModels().add(
(MemoryModel) MarshalHelper.unmarshal(
MarshalHelper.unmarshal(
MemoryModel.class, result.getContent()));
} else if (Class.forName(result.getType()).equals(
NetworkInterfaceModel.class)) {
container.getNetWorkModels().add(
(NetworkInterfaceModel) MarshalHelper.unmarshal(
MarshalHelper.unmarshal(
NetworkInterfaceModel.class,
result.getContent()));
} else if (Class.forName(result.getType()).equals(
ProcessorModel.class)) {
container.getProcessorModels().add(
(ProcessorModel) MarshalHelper.unmarshal(
MarshalHelper.unmarshal(
ProcessorModel.class, result.getContent()));
}
} catch (Exception e) {
@ -131,7 +132,7 @@ public class MonitorReportService {
ReportService.addParagraph(Memory, document);
createMemoryImage(container.getMemoryModels(), document);
ReportService.addParagraph(network_Interface, document);
// createNetworkImage(container.getNetWorkModels(), document);
// createNetworkImage(container.getNetWorkModels(), document);
ReportService.addParagraph(Processor, document);
createProcessorImage(container.getProcessorModels(), document);
} catch (Exception e) {
@ -213,7 +214,6 @@ public class MonitorReportService {
timeSeriesArray, logical_Disk).toByteArray(), document);
}
/**
* refactor this kind of use
*
@ -222,25 +222,25 @@ public class MonitorReportService {
* @throws Exception
*/
// private void createNetworkImage(List<NetworkInterfaceModel> list,
// Document document) throws Exception {
// if (list == null || list.size() == 0) {
// return;
// }
// int seriesCount = list.get(0).getNetworkList().size();
// List<TimeSeries> 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);
// }
//}
// private void createNetworkImage(List<NetworkInterfaceModel> list,
// Document document) throws Exception {
// if (list == null || list.size() == 0) {
// return;
// }
// int seriesCount = list.get(0).getNetworkList().size();
// List<TimeSeries> 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);
// }
// }
}

View File

@ -55,8 +55,8 @@ public class AgentMessengerImpl implements AgentMessenger {
null, null);
System.out.println(buildBaseUrl(agent) + "/test/bookTest/"
+ requireLoad);
return (RunScenarioResultModel) MarshalHelper.unmarshal(
RunScenarioResultModel.class, httpResponse.getContent());
return MarshalHelper.unmarshal(RunScenarioResultModel.class,
httpResponse.getContent());
} catch (Exception e) {
logger.error(httpResponse.getContent(), e);
return null;
@ -90,8 +90,8 @@ public class AgentMessengerImpl implements AgentMessenger {
buildBaseUrl(agent) + "/test/submitScenarioWithParams/"
+ agentRunId + "/" + realStartDate.getTime(),
"files[]", paramFiles, stringParts);
return (RunScenarioResultModel) MarshalHelper.unmarshal(
RunScenarioResultModel.class, httpResponse.getContent());
return MarshalHelper.unmarshal(RunScenarioResultModel.class,
httpResponse.getContent());
} catch (Exception e) {
logIt(httpResponse, e);
return null;
@ -126,8 +126,8 @@ public class AgentMessengerImpl implements AgentMessenger {
logger.error("the response is not valid");
return null;
}
return (RunScenarioResultModel) MarshalHelper.unmarshal(
RunScenarioResultModel.class, httpResponse.getContent());
return MarshalHelper.unmarshal(RunScenarioResultModel.class,
httpResponse.getContent());
} catch (Exception e) {
logIt(httpResponse, e);
return null;
@ -157,8 +157,8 @@ public class AgentMessengerImpl implements AgentMessenger {
return null;
}
logger.info(httpResponse.getContent());
return (TestBriefStatusModel) MarshalHelper.unmarshal(
TestBriefStatusModel.class, httpResponse.getContent());
return MarshalHelper.unmarshal(TestBriefStatusModel.class,
httpResponse.getContent());
} catch (Exception e) {
logIt(httpResponse, e);
logger.error(e.toString()
@ -191,7 +191,7 @@ public class AgentMessengerImpl implements AgentMessenger {
if (HttpRequester.isInvalidResponse(httpResponse)) {
return null;
}
return (StopTestModel) MarshalHelper.unmarshal(StopTestModel.class,
return MarshalHelper.unmarshal(StopTestModel.class,
httpResponse.getContent());
} catch (Exception e) {
logger.error(e.toString() + " when stop the agent with hostName "
@ -222,8 +222,8 @@ public class AgentMessengerImpl implements AgentMessenger {
if (HttpRequester.isInvalidResponse(httpResponse)) {
return null;
}
return (ServerStatusModel) MarshalHelper.unmarshal(
ServerStatusModel.class, httpResponse.getContent());
return MarshalHelper.unmarshal(ServerStatusModel.class,
httpResponse.getContent());
} catch (Exception e) {
logger.error("agent :" + agent.getHostName() + " break down!");
return null;

View File

@ -1,10 +1,7 @@
package org.bench4q.master.infrastructure.communication.impl;
import java.io.IOException;
import java.util.Date;
import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
@ -55,19 +52,10 @@ public class MonitorMessengerImpl implements MonitorMessenger {
logger.info("The httpResponse is invalid ");
return null;
}
@SuppressWarnings("unchecked")
T model = (T) MarshalHelper.unmarshal(resultClass,
T model = MarshalHelper.unmarshal(resultClass,
httpResponse.getContent());
model.setSamplingTime(sampleDate);
return model;
} catch (IOException e) {
logger.error(ExceptionLog.getStackTrace(e));
return null;
} catch (JAXBException e) {
logger.error(ExceptionLog.getStackTrace(e));
return null;
} catch (Exception e) {
logger.error(ExceptionLog.getStackTrace(e));
return null;

View File

@ -22,7 +22,7 @@ public class MarshallerTest {
public void testUnmarshal() throws JAXBException {
RunningAgentModel input = new RunningAgentModel();
String content = MarshalHelper.marshal(RunningAgentModel.class, input);
RunningAgentModel output = (RunningAgentModel) MarshalHelper.unmarshal(
RunningAgentModel output = MarshalHelper.unmarshal(
RunningAgentModel.class, content);
System.out.println(input.getLoadInUse());
assertTrue(input.getLoadInUse() == output.getLoadInUse());

View File

@ -64,9 +64,9 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan {
File scenarioFile = new File("Scripts" + FILE_SEPARATOR
+ "homepage.xml");
assertTrue(scenarioFile.exists());
RunScenarioModel inputModel = (RunScenarioModel) MarshalHelper
.unmarshal(RunScenarioModel.class,
FileUtils.readFileToString(scenarioFile));
RunScenarioModel inputModel = MarshalHelper.unmarshal(
RunScenarioModel.class,
FileUtils.readFileToString(scenarioFile));
inputModel.setPoolSize(20);
Agent agent = Agent

View File

@ -47,8 +47,8 @@ public class AgentPoolControllerTest extends TestBase {
MarshalHelper.marshal(AgentModel.class, agent),
makeAccessTockenMap(this.getAccessTocken()));
agentResponseModel = (AgentResponseModel) MarshalHelper.unmarshal(
AgentResponseModel.class, httpResponse.getContent());
agentResponseModel = MarshalHelper.unmarshal(AgentResponseModel.class,
httpResponse.getContent());
System.out.println(httpResponse.getContent());
System.out.println(agentResponseModel.isSuccess());

View File

@ -78,7 +78,7 @@ public class PluginControllerTest extends TestBase {
String pluginContent = FileUtils.readFileToString(file);
HttpResponse httpResponse = this.httpRequester.sendPutXml(url,
pluginContent, makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
PluginResponseModel pluginResponseModel = MarshalHelper
.tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent());
Assert.assertNotNull(pluginResponseModel);
@ -94,7 +94,7 @@ public class PluginControllerTest extends TestBase {
this.test_PluginHelper.addPlugin(fileName, pluginService, pluginName);
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
PluginResponseModel pluginResponseModel = MarshalHelper
.tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent());
System.out.println(httpResponse.getContent());
@ -116,7 +116,7 @@ public class PluginControllerTest extends TestBase {
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken()));
System.out.println(httpResponse.getContent());
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
PluginResponseModel pluginResponseModel = MarshalHelper
.tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent());
assertNotNull(pluginResponseModel);
@ -133,7 +133,7 @@ public class PluginControllerTest extends TestBase {
String url = URLSTRING + "/deletePlugin" + "/" + this.pluginName;
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
PluginResponseModel pluginResponseModel = MarshalHelper
.tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent());
assertNotNull(pluginResponseModel);
@ -148,7 +148,7 @@ public class PluginControllerTest extends TestBase {
String url = URLSTRING + "/loadBehaviors/" + this.pluginName;
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
PluginResponseModel pluginResponseModel = MarshalHelper
.tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent());
assertNotNull(pluginResponseModel);
@ -170,9 +170,8 @@ public class PluginControllerTest extends TestBase {
properties);
PluginResponseModel pluginResponseModel = null;
try {
pluginResponseModel = (PluginResponseModel) MarshalHelper
.unmarshal(PluginResponseModel.class,
httpResponse.getContent());
pluginResponseModel = MarshalHelper.unmarshal(
PluginResponseModel.class, httpResponse.getContent());
} catch (Exception e) {
logger.info(ExceptionLog.getStackTrace(e));
}

View File

@ -31,9 +31,9 @@ public class RecordScriptControllerTest extends TestBase {
+ "/startScriptRecordServer", null,
this.makeAccessTockenMap(this.getAccessTocken()));
System.out.println(httpResponse.getContent());
OperateScriptServerResponseModel ret = (OperateScriptServerResponseModel) MarshalHelper
.unmarshal(OperateScriptServerResponseModel.class,
httpResponse.getContent());
OperateScriptServerResponseModel ret = MarshalHelper.unmarshal(
OperateScriptServerResponseModel.class,
httpResponse.getContent());
assertTrue(ret.isSuccess());
return ret;
}
@ -46,9 +46,9 @@ public class RecordScriptControllerTest extends TestBase {
HttpResponse httpResponse = this.httpRequester.sendPost(this.SCRIPT_URL
+ "/stopScriptRecordServer", paramsMap,
this.makeAccessTockenMap(this.accessTocken));
OperateScriptServerResponseModel ret = (OperateScriptServerResponseModel) MarshalHelper
.unmarshal(OperateScriptServerResponseModel.class,
httpResponse.getContent());
OperateScriptServerResponseModel ret = MarshalHelper.unmarshal(
OperateScriptServerResponseModel.class,
httpResponse.getContent());
assertTrue(ret.isSuccess());
}
@ -67,9 +67,9 @@ public class RecordScriptControllerTest extends TestBase {
HttpResponse httpResponse = this.httpRequester.sendPost(this.SCRIPT_URL
+ "/saveScriptToDB", params,
this.makeAccessTockenMap(this.getAccessTocken()));
OperateScriptServerResponseModel ret = (OperateScriptServerResponseModel) MarshalHelper
.unmarshal(OperateScriptServerResponseModel.class,
httpResponse.getContent());
OperateScriptServerResponseModel ret = MarshalHelper.unmarshal(
OperateScriptServerResponseModel.class,
httpResponse.getContent());
assertTrue(ret.isSuccess());
assertNotNull(ret.getScriptModels());
assertNotNull(ret.getScriptModels().get(0));
@ -88,7 +88,7 @@ public class RecordScriptControllerTest extends TestBase {
test.stopRecord(model);
ScriptModel scriptModel = test.saveScriptToDB(model, "chen2");
assertNotNull(scriptModel.getScriptContent());
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
RunScenarioModel runScenarioModel = MarshalHelper
.unmarshal(RunScenarioModel.class,
scriptModel.getScriptContent());
assertNotNull(runScenarioModel);

View File

@ -28,7 +28,7 @@ public class ScriptControllerTest extends TestBase {
String url = this.controllerUrl + "/loadScriptList";
HttpResponse httpResponse = this.httpRequester.sendGet(url, null,
this.makeAccessTockenMap(this.login()));
OperateScriptServerResponseModel ret = (OperateScriptServerResponseModel) MarshalHelper
OperateScriptServerResponseModel ret = MarshalHelper
.unmarshal(OperateScriptServerResponseModel.class,
httpResponse.getContent());
assertTrue(ret.getScriptModels().size() > 0);

View File

@ -39,9 +39,8 @@ public class TestBase {
try {
httpResponse = this.httpRequester.sendGet(urlString, map, null);
System.out.println("http content:" + httpResponse.getContent());
return ((AuthorizeResponseModel) MarshalHelper.unmarshal(
AuthorizeResponseModel.class, httpResponse.getContent()))
.getAccessToken();
return MarshalHelper.unmarshal(AuthorizeResponseModel.class,
httpResponse.getContent()).getAccessToken();
} catch (Exception e) {
e.printStackTrace();
return null;

View File

@ -38,7 +38,7 @@ public class TestPlanScriptResultControllerTest extends TestBase_MakeUpTestPlan
+ "/loadScriptBirefResults/" + this.getScriptId()
+ "/averageResponseTime", null,
this.makeAccessTockenMap(this.getAccessTocken()));
ResultLoadModel loadModel = (ResultLoadModel) MarshalHelper.unmarshal(
ResultLoadModel loadModel = MarshalHelper.unmarshal(
ResultLoadModel.class, httpResponse.getContent());
assertEquals(3, loadModel.getValueTimeModels().size());
}

View File

@ -35,7 +35,7 @@ public class Test_MonitorController extends TestBase {
if (HttpRequester.isInvalidResponse(httpResponse)) {
fail("not valid response!");
}
MonitorMemoryResponseModel memoryResponseModel = (MonitorMemoryResponseModel) MarshalHelper
MonitorMemoryResponseModel memoryResponseModel = MarshalHelper
.unmarshal(MonitorMemoryResponseModel.class,
httpResponse.getContent());
assertEquals(3, memoryResponseModel.getMemoryModels().size());

View File

@ -143,7 +143,7 @@ public class Test_TestPlanController extends TestBase_MakeUpTestPlan {
+ "/runTestPlanWithTestPlanModel", content,
this.makeAccessTockenMap(this.accessTocken));
result = (TestPlanResultModel) MarshalHelper.unmarshal(
result = MarshalHelper.unmarshal(
TestPlanResultModel.class, httpResponse.getContent());
System.out.println(result.getCurrentStatus());
return result.getTestPlanId();
@ -182,7 +182,7 @@ public class Test_TestPlanController extends TestBase_MakeUpTestPlan {
HttpResponse httpResponse = this.httpRequester.sendGet(this._url
+ "/getRunningInfo", params,
this.makeAccessTockenMap(this.getAccessTocken()));
TestPlanResultModel ret = (TestPlanResultModel) MarshalHelper
TestPlanResultModel ret = MarshalHelper
.unmarshal(TestPlanResultModel.class, httpResponse.getContent());
System.out.println(ret.getCurrentStatus());
return ret;
@ -194,7 +194,7 @@ public class Test_TestPlanController extends TestBase_MakeUpTestPlan {
+ "/scriptBrief/" + testPlanId.toString() + "/" + scriptId
+ "/" + 0, null, createAccessTokenMap());
System.out.println(httpResponse.getContent());
TestPlanScriptBriefResultModel ret = (TestPlanScriptBriefResultModel) MarshalHelper
TestPlanScriptBriefResultModel ret = MarshalHelper
.unmarshal(TestPlanScriptBriefResultModel.class,
httpResponse.getContent());
for (ScriptBriefResultModel scriptBriefResultModel : ret
@ -210,7 +210,7 @@ public class Test_TestPlanController extends TestBase_MakeUpTestPlan {
+ "/pagesBrief/" + testPlanId.toString() + "/" + scriptId,
null, createAccessTokenMap());
System.out.println(httpResponse.getContent());
ScriptPagesBriefModel ret = (ScriptPagesBriefModel) MarshalHelper
ScriptPagesBriefModel ret = MarshalHelper
.unmarshal(ScriptPagesBriefModel.class,
httpResponse.getContent());
return ret;
@ -254,7 +254,7 @@ public class Test_TestPlanController extends TestBase_MakeUpTestPlan {
+ testPlanID.toString() + "/" + hostName + "/6565/0",
null, this.createAccessTokenMap());
System.out.println(httpResponse.getContent());
MonitorPhysicalDiskResponseModel logicalDiskResponseModel = (MonitorPhysicalDiskResponseModel) MarshalHelper
MonitorPhysicalDiskResponseModel logicalDiskResponseModel = MarshalHelper
.unmarshal(MonitorPhysicalDiskResponseModel.class,
httpResponse.getContent());
assertNotNull(logicalDiskResponseModel);

View File

@ -31,7 +31,7 @@ public class Test_TestPlanResultController extends TestBase {
+ testPlanRunId, null,
makeAccessTockenMap(this.getAccessTocken()));
assertTrue(httpResponse != null);
ResultLoadModel resultModel = (ResultLoadModel) MarshalHelper
ResultLoadModel resultModel = MarshalHelper
.unmarshal(ResultLoadModel.class, httpResponse.getContent());
assertTrue(resultModel.getValueTimeModels().size() > 0);
}

View File

@ -27,7 +27,7 @@ public class UserControllerTest extends TestBase {
+ "/user/normalAuthorize?userName=chen&password=123";
HttpResponse httpResponse = this.httpRequester.sendGet(urlString, null,
null);
AuthorizeResponseModel ret = (AuthorizeResponseModel) MarshalHelper
AuthorizeResponseModel ret = MarshalHelper
.unmarshal(AuthorizeResponseModel.class,
httpResponse.getContent());
assertTrue(ret.isSuccess());
@ -38,7 +38,7 @@ public class UserControllerTest extends TestBase {
String url = BASE_URL
+ "/user/adminAuthorize?userName=chen&password=123";
HttpResponse httpResponse = this.httpRequester.sendGet(url, null, null);
AuthorizeResponseModel ret = (AuthorizeResponseModel) MarshalHelper
AuthorizeResponseModel ret = MarshalHelper
.unmarshal(AuthorizeResponseModel.class,
httpResponse.getContent());
assertTrue(ret.isSuccess());
@ -56,7 +56,7 @@ public class UserControllerTest extends TestBase {
params.put("scope", "1");
HttpResponse httpResponse = this.httpRequester.sendGet(url, params,
null);
RegisterResponseModel registerResponseModel = (RegisterResponseModel) MarshalHelper
RegisterResponseModel registerResponseModel = MarshalHelper
.tryUnmarshal(RegisterResponseModel.class,
httpResponse.getContent());
assertNotNull(registerResponseModel);
@ -70,7 +70,7 @@ public class UserControllerTest extends TestBase {
String url = BASE_URL + "/user/deleteUser" + "/" + userName;
HttpResponse httpResponse = this.httpRequester.sendGet(url, null, null);
System.out.println(httpResponse.getContent());
AuthorizeResponseModel authorizeResponseModel = (AuthorizeResponseModel) MarshalHelper
AuthorizeResponseModel authorizeResponseModel = MarshalHelper
.tryUnmarshal(AuthorizeResponseModel.class,
httpResponse.getContent());

View File

@ -82,7 +82,7 @@ public class Test_Agent {
assertEquals(AgentStatus.InIdle, agentModel.getCurrentEnumStatus());
String content = MarshalHelper.tryMarshal(agentModel);
System.out.println(content);
AgentModel modelAfterUnMarshal = (AgentModel) MarshalHelper
AgentModel modelAfterUnMarshal = MarshalHelper
.tryUnmarshal(AgentModel.class, content);
assertEquals(modelAfterUnMarshal.getCurrentEnumStatus(),
AgentStatus.InIdle);

View File

@ -92,9 +92,9 @@ public class Test_RunningScript extends TestBase_MakeUpTestPlan {
double ratio = (double) runningAgentDB.getLoadInUse()
/ (double) testPlanScript.getRequireLoad();
ScheduleModel scheduleModelInRunningAgent = runningAgentDB
.generateScheduleModelWithRatio((ScheduleModel) MarshalHelper
.tryUnmarshal(ScheduleModel.class,
testPlanScript.getScheduleContent()));
.generateScheduleModelWithRatio(MarshalHelper.tryUnmarshal(
ScheduleModel.class,
testPlanScript.getScheduleContent()));
assertEquals(Math.round(ratio * testPlanScript.getRequireLoad()),
scheduleModelInRunningAgent.getMaxLoad());
System.out.println(scheduleModelInRunningAgent.getMaxLoad());

View File

@ -158,7 +158,7 @@ public class Test_ScriptService {
String content = this.getScriptService()
.getScript(getUploadScriptId(getUserForTest()))
.getScriptContent();
RunScenarioModel afterUpdate = (RunScenarioModel) MarshalHelper
RunScenarioModel afterUpdate = MarshalHelper
.unmarshal(RunScenarioModel.class, content);
assertEquals(1, afterUpdate.getPages().size());
}

View File

@ -20,11 +20,10 @@ import org.bench4q.share.models.agent.scriptrecord.PageModel;
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
public class Bench4qTestScriptAdapter implements IScriptAdapter {
private int idGenerator =1;
private int idGenerator = 1;
private int pageCount;
private RunScenarioModel runScenarioModel;
private List<ChildrenUrl> childrenUrls = new ArrayList<ChildrenUrl>();
private BehaviorModel preTimerBehavior = null;
private static Logger logger = Logger
.getLogger(Bench4qTestScriptAdapter.class);
@ -86,29 +85,31 @@ public class Bench4qTestScriptAdapter implements IScriptAdapter {
return;
}
guardChildBatchExist(batches, parentBatchId);
getBatchById(batches, getBatchById(batches, parentBatchId).getChildId()).getBehaviors()
.add(model);
getBatchById(batches, getBatchById(batches, parentBatchId).getChildId())
.getBehaviors().add(model);
}
private BatchModel getBatchById(List<BatchModel> batches, int batchId){
for(BatchModel batchModel : batches){
if(batchModel.getId() == batchId){
private BatchModel getBatchById(List<BatchModel> batches, int batchId) {
for (BatchModel batchModel : batches) {
if (batchModel.getId() == batchId) {
return batchModel;
}
}
return null;
}
private boolean guardChildBatchExist(List<BatchModel> batches,
int parentBatchId) {
if (isChildBatchAbsent(batches, parentBatchId)) {
BatchModel batchBehavior = createBatchBehaviorWithProperBatchId();
batchBehavior.setParentId(parentBatchId);
batches.add(batchBehavior);
BatchModel parentBatch = getBatchById(batches,parentBatchId);
if(parentBatch != null){
BatchModel parentBatch = getBatchById(batches, parentBatchId);
if (parentBatch != null) {
parentBatch.setChildId(batchBehavior.getId());
}
return false;
}else{
} else {
return true;
}
}
@ -132,22 +133,22 @@ public class Bench4qTestScriptAdapter implements IScriptAdapter {
private BatchModel createBatchBehaviorWithProperBatchId() {
BatchModel batchBehavior = new BatchModel(idGenerator++);
// batchBehavior.setId(RunScenarioModelHelper.getBatches(
// this.runScenarioModel).size());
// batchBehavior.setId(RunScenarioModelHelper.getBatches(
// this.runScenarioModel).size());
batchBehavior.setParentId(-1);
batchBehavior.setChildId(-1);
// List<BehaviorModel> behaviors = new ArrayList<BehaviorModel>();
// batchBehavior.setBehaviors(behaviors);
// List<BehaviorModel> behaviors = new ArrayList<BehaviorModel>();
// batchBehavior.setBehaviors(behaviors);
return batchBehavior;
}
private boolean isChildBatchAbsent(List<BatchModel> batches,
int parentBatchId) {
// if (parentBatchId >= batches.size()) {
// return false;
// }
// if (parentBatchId >= batches.size()) {
// return false;
// }
BatchModel batchModel = getBatchById(batches, parentBatchId);
if(batchModel != null){
if (batchModel != null) {
return batchModel.getChildId() < 0;
}
return false;
@ -189,17 +190,18 @@ public class Bench4qTestScriptAdapter implements IScriptAdapter {
public int getParentBatchIdWithParentUrl(String url) {
List<BatchModel> batchesInScenario = RunScenarioModelHelper
.getBatches(this.getRunScenarioModel());
// for (int batchId = 0; batchId < batchesInScenario.size(); batchId++) {
// BatchModel batch = batchesInScenario.get(batchId);
// for (BehaviorModel behavior : batch.getBehaviors()) {
// for (ParameterModel parameter : behavior.getParameters()) {
// if (parameter.getKey().equals("url")
// && parameter.getValue().equals(url)) {
// return batchId;
// }
// }
// }
// }
// for (int batchId = 0; batchId < batchesInScenario.size(); batchId++)
// {
// BatchModel batch = batchesInScenario.get(batchId);
// for (BehaviorModel behavior : batch.getBehaviors()) {
// for (ParameterModel parameter : behavior.getParameters()) {
// if (parameter.getKey().equals("url")
// && parameter.getValue().equals(url)) {
// return batchId;
// }
// }
// }
// }
for (int i = 0; i < batchesInScenario.size(); i++) {
BatchModel batch = batchesInScenario.get(i);
for (BehaviorModel behavior : batch.getBehaviors()) {
@ -238,8 +240,8 @@ public class Bench4qTestScriptAdapter implements IScriptAdapter {
return;
}
try {
this.setRunScenarioModel((RunScenarioModel) MarshalHelper
.unmarshal(RunScenarioModel.class, text));
this.setRunScenarioModel(MarshalHelper.unmarshal(
RunScenarioModel.class, text));
} catch (JAXBException e) {
logger.error(e, e);
this.setRunScenarioModel(new RunScenarioModel());

View File

@ -28,14 +28,15 @@ public class MarshalHelper {
}
}
public static Object unmarshal(Class<?> classToUnmarshal, String input)
@SuppressWarnings("unchecked")
public static <T> T unmarshal(Class<T> classToUnmarshal, String input)
throws JAXBException {
try {
Unmarshaller unmarshaller;
unmarshaller = JAXBContext.newInstance(classToUnmarshal)
.createUnmarshaller();
return unmarshaller.unmarshal(new ByteArrayInputStream(input
return (T) unmarshaller.unmarshal(new ByteArrayInputStream(input
.getBytes("utf-8")));
} catch (Exception e) {
e.printStackTrace();
@ -53,9 +54,9 @@ public class MarshalHelper {
* @param input
* @return null if there is an exception happened.
*/
public static Object tryUnmarshal(Class<?> classToUnmarshal, String input) {
public static <T> T tryUnmarshal(Class<T> classToUnmarshal, String input) {
try {
return unmarshal(classToUnmarshal, input);
return (T) unmarshal(classToUnmarshal, input);
} catch (Exception e) {
e.printStackTrace();
return null;

View File

@ -105,7 +105,7 @@ public class ScriptController extends BaseController {
if (operateScriptServerResponseModel.isSuccess()) {
ScriptModel scriptModel = operateScriptServerResponseModel
.getScriptModels().get(0);
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
RunScenarioModel runScenarioModel = MarshalHelper
.tryUnmarshal(RunScenarioModel.class,
scriptModel.getScriptContent());
if (runScenarioModel == null) {
@ -135,7 +135,7 @@ public class ScriptController extends BaseController {
if (operateScriptServerResponseModel.isSuccess()) {
ScriptModel scriptModel = operateScriptServerResponseModel
.getScriptModels().get(0);
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
RunScenarioModel runScenarioModel = MarshalHelper
.tryUnmarshal(RunScenarioModel.class,
scriptModel.getScriptContent());
if (runScenarioModel == null) {
@ -362,7 +362,7 @@ public class ScriptController extends BaseController {
return fail(map, "");
}
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
RunScenarioModel runScenarioModel = MarshalHelper
.tryUnmarshal(
RunScenarioModel.class,
operateScriptServerResponseModel.getScriptModels()

View File

@ -30,7 +30,7 @@ public class AgentManagerMessager extends MasterMessager {
createFaliAgentResponseModel();
}
return (AgentResponseModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
AgentResponseModel.class, httpResponse.getContent());
} catch (Exception e) {
this.handleException(httpResponse, e);
@ -71,7 +71,7 @@ public class AgentManagerMessager extends MasterMessager {
return createFaliAgentResponseModel();
}
return (AgentResponseModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
AgentResponseModel.class, httpResponse.getContent());
} catch (Exception e) {
this.handleException(httpResponse, e);

View File

@ -35,7 +35,7 @@ public class MonitorMessager extends MasterMessager {
return null;
}
MonitorMemoryResponseModel memoryResponseModel = (MonitorMemoryResponseModel) MarshalHelper
MonitorMemoryResponseModel memoryResponseModel = MarshalHelper
.unmarshal(MonitorMemoryResponseModel.class,
httpResponse.getContent());
return memoryResponseModel;
@ -61,7 +61,7 @@ public class MonitorMessager extends MasterMessager {
return null;
}
MonitorProcessorResponseModel monitorProcessorResponseModel = (MonitorProcessorResponseModel) MarshalHelper
MonitorProcessorResponseModel monitorProcessorResponseModel = MarshalHelper
.unmarshal(MonitorProcessorResponseModel.class,
httpResponse.getContent());
return monitorProcessorResponseModel;
@ -85,7 +85,7 @@ public class MonitorMessager extends MasterMessager {
handleInvalidatedResponse(url);
return null;
}
MonitorNetworkReponseModel networkInterfaceModel = (MonitorNetworkReponseModel) MarshalHelper
MonitorNetworkReponseModel networkInterfaceModel = MarshalHelper
.unmarshal(MonitorNetworkReponseModel.class,
httpResponse.getContent());
return networkInterfaceModel;
@ -110,7 +110,7 @@ public class MonitorMessager extends MasterMessager {
this.handleInvalidatedResponse(url);
return null;
}
MonitorPhysicalDiskResponseModel monitorPhysicalDiskResponseModel = (MonitorPhysicalDiskResponseModel) MarshalHelper
MonitorPhysicalDiskResponseModel monitorPhysicalDiskResponseModel = MarshalHelper
.unmarshal(MonitorPhysicalDiskResponseModel.class,
httpResponse.getContent());
return monitorPhysicalDiskResponseModel;

View File

@ -112,7 +112,7 @@ public class PluginMessager extends MasterMessager {
private PluginResponseModel extractPluginResponseModel(
HttpResponse httpResponse) throws JAXBException {
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
PluginResponseModel pluginResponseModel = MarshalHelper
.unmarshal(PluginResponseModel.class, httpResponse.getContent());
if (!pluginResponseModel.isSuccess()) {
logger.info(pluginResponseModel.getFailMessage());

View File

@ -68,7 +68,7 @@ public class RecordPortMessager extends MasterMessager {
private OrganizeRecordPortResponseModel extractOrganizeRecordPortResponseModel(
HttpResponse httpResponse) throws JAXBException {
OrganizeRecordPortResponseModel organizeRecordPortResponseModel = (OrganizeRecordPortResponseModel) MarshalHelper
OrganizeRecordPortResponseModel organizeRecordPortResponseModel = MarshalHelper
.unmarshal(OrganizeRecordPortResponseModel.class,
httpResponse.getContent());
if (organizeRecordPortResponseModel.getPortModels() == null) {

View File

@ -84,7 +84,7 @@ public class ScriptMessager extends MasterMessager {
System.out.println(httpResponse.getContent());
if (!validateHttpResponse(httpResponse))
return null;
return (OperateScriptServerResponseModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
OperateScriptServerResponseModel.class,
httpResponse.getContent());
@ -108,7 +108,7 @@ public class ScriptMessager extends MasterMessager {
paramFiles, stringParts);
if (!validateHttpResponse(httpResponse))
return null;
return (OperateScriptServerResponseModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
OperateScriptServerResponseModel.class,
httpResponse.getContent());
@ -154,7 +154,7 @@ public class ScriptMessager extends MasterMessager {
// paramFiles, "paramContents[]", stringPart);
// if (!validateHttpResponse(httpResponse))
// return null;
// return (OperateScriptServerResponseModel) MarshalHelper.unmarshal(
// return MarshalHelper.unmarshal(
// OperateScriptServerResponseModel.class,
// httpResponse.getContent());
//
@ -224,7 +224,7 @@ public class ScriptMessager extends MasterMessager {
private OperateScriptServerResponseModel extractOperateScriptServerResponseModel(
HttpResponse httpResponse) throws JAXBException {
return (OperateScriptServerResponseModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
OperateScriptServerResponseModel.class,
httpResponse.getContent());
}
@ -239,7 +239,7 @@ public class ScriptMessager extends MasterMessager {
handleInvalidatedResponse(url);
return null;
}
return (ScriptFilterModel) MarshalHelper.tryUnmarshal(
return MarshalHelper.tryUnmarshal(
ScriptFilterModel.class, httpResponse.getContent());
} catch (Exception e) {
this.handleException(httpResponse, e);

View File

@ -92,7 +92,7 @@ public class TestPlanMessager extends MasterMessager {
return null;
}
return (TestPlanScriptBriefResultModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
TestPlanScriptBriefResultModel.class,
httpResponse.getContent());
} catch (Exception e) {
@ -111,7 +111,7 @@ public class TestPlanMessager extends MasterMessager {
makeAccessTockenMap(accessToken));
if (!validateHttpResponse(httpResponse))
return null;
return (ScriptBehaviorsBriefModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
ScriptBehaviorsBriefModel.class, httpResponse.getContent());
} catch (Exception e) {
this.handleException(httpResponse, e);
@ -131,7 +131,7 @@ public class TestPlanMessager extends MasterMessager {
handleInvalidatedResponse(url);
return null;
}
return (TestPlanDBModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
TestPlanDBModel.class, httpResponse.getContent());
} catch (Exception e) {
handleException(httpResponse, e);
@ -205,14 +205,14 @@ public class TestPlanMessager extends MasterMessager {
private TestPlanResponseModel extractTestPlanResponseModel(
HttpResponse httpResponse) throws JAXBException,
UnsupportedEncodingException {
return (TestPlanResponseModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
TestPlanResponseModel.class, httpResponse.getContent());
}
private TestPlanResultModel extractTestPlanResultModel(
HttpResponse httpResponse) throws JAXBException,
UnsupportedEncodingException {
return (TestPlanResultModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
TestPlanResultModel.class, httpResponse.getContent());
}
@ -231,7 +231,7 @@ public class TestPlanMessager extends MasterMessager {
}
System.out.println("getLatestScriptBriefResult:\r\n"
+ httpResponse.getContent());
return (ScriptBriefResultModel) MarshalHelper.tryUnmarshal(
return MarshalHelper.tryUnmarshal(
ScriptBriefResultModel.class, httpResponse.getContent());
} catch (Exception e) {
@ -252,7 +252,7 @@ public class TestPlanMessager extends MasterMessager {
handleInvalidatedResponse(url);
return null;
}
return (ScriptPagesBriefModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
ScriptPagesBriefModel.class, httpResponse.getContent());
} catch (Exception e) {

View File

@ -28,7 +28,7 @@ public class UserMessager extends MasterMessager {
if (!validateHttpResponse(httpResponse)) {
return null;
}
return (RegisterResponseModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
RegisterResponseModel.class, httpResponse.getContent());
} catch (Exception e) {
@ -69,7 +69,7 @@ public class UserMessager extends MasterMessager {
httpResponse = this.getHttpRequester().sendGet(url, params, null);
if (!validateHttpResponse(httpResponse))
return null;
return (AuthorizeResponseModel) MarshalHelper.unmarshal(
return MarshalHelper.unmarshal(
AuthorizeResponseModel.class, httpResponse.getContent());
} catch (Exception e) {