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

View File

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