This commit is contained in:
coderfengyun 2013-12-23 09:29:26 +08:00
parent 0cbffbc270
commit acca5e1cbd
2 changed files with 29 additions and 36 deletions

View File

@ -202,23 +202,23 @@ public class TestController {
if (scenarioContext == null || scenarioContext.isFinished()) {
return null;
}
for (Page page : scenarioContext.getScenario().getPages()) {
for (Batch batch : page.getBatches()) {
for (Behavior behavior : batch.getBehaviors()) {
int behaviorId = behavior.getId();
Map<Integer, DetailStatusCodeResult> map = scenarioContext
.getDataStatistics()
.getDetailStatistics(behaviorId);
if (map == null) {
continue;
}
behaviorBriefModels.add(buildBehaviorBrief(runId,
behaviorId, map));
}
// for (Page page : scenarioContext.getScenario().getPages()) {
// for (Batch batch : page.getBatches()) {
// for (Behavior behavior : batch.getBehaviors()) {
for (Behavior behavior : scenarioContext.getScenario()
.getAllBehaviorsInScenario()) {
int behaviorId = behavior.getId();
Map<Integer, DetailStatusCodeResult> map = scenarioContext
.getDataStatistics().getDetailStatistics(behaviorId);
if (map == null) {
continue;
}
behaviorBriefModels.add(buildBehaviorBrief(runId, behaviorId, map));
}
// }
// }
//
// }
ret.setBehaviorBriefModels(behaviorBriefModels);
return ret;
}

View File

@ -93,27 +93,21 @@ public class ScenarioEngine {
public void doRunScenario(ScenarioContext context) {
Map<String, Object> plugins = new HashMap<String, Object>();
preparePlugins(context.getScenario(), plugins);
for (Page page : context.getScenario().getPages()) {
for (Batch batch : page.getBatches()) {
for (Behavior behavior : batch.getBehaviors()) {
Object plugin = plugins.get(behavior.getUse());
Map<String, String> behaviorParameters = prepareBehaviorParameters(behavior);
Date startDate = new Date(System.currentTimeMillis());
PluginReturn pluginReturn = (PluginReturn) this
.getPluginManager().doBehavior(plugin,
behavior.getName(), behaviorParameters);
Date endDate = new Date(System.currentTimeMillis());
if (!behavior.shouldBeCountResponseTime()) {
continue;
}
context.getDataStatistics().add(
buildBehaviorResult(behavior, plugin, startDate,
pluginReturn, endDate));
}
for (Behavior behavior : context.getScenario()
.getAllBehaviorsInScenario()) {
Object plugin = plugins.get(behavior.getUse());
Map<String, String> behaviorParameters = prepareBehaviorParameters(behavior);
Date startDate = new Date(System.currentTimeMillis());
PluginReturn pluginReturn = (PluginReturn) this.getPluginManager()
.doBehavior(plugin, behavior.getName(), behaviorParameters);
Date endDate = new Date(System.currentTimeMillis());
if (!behavior.shouldBeCountResponseTime()) {
continue;
}
context.getDataStatistics().add(
buildBehaviorResult(behavior, plugin, startDate,
pluginReturn, endDate));
}
}
private BehaviorResult buildBehaviorResult(Behavior behavior,
@ -148,8 +142,7 @@ public class ScenarioEngine {
return behaviorParameters;
}
private void preparePlugins(Scenario scenario,
Map<String, Object> plugins) {
private void preparePlugins(Scenario scenario, Map<String, Object> plugins) {
for (UsePlugin usePlugin : scenario.getUsePlugins()) {
String pluginId = usePlugin.getId();
Class<?> pluginClass = this.getPluginManager().getPlugins()