parent
021ee6dd97
commit
87605edcad
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<runScenario>
|
||||
<pages>
|
||||
<page>
|
||||
<batches>
|
||||
<batch>
|
||||
</batch>
|
||||
</batches>
|
||||
</page>
|
||||
</pages>
|
||||
|
||||
<usePlugins>
|
||||
<usePlugin>
|
||||
<id>hBase</id>
|
||||
<name>HBase</name>
|
||||
<parameters />
|
||||
</usePlugin>
|
||||
</usePlugins>
|
||||
</runScenario>
|
|
@ -0,0 +1,97 @@
|
|||
package org.bench4q.agent.test.plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bench4q.share.models.agent.ParameterModel;
|
||||
import org.bench4q.share.models.agent.RunScenarioModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.BatchModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.PageModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
|
||||
|
||||
public class Test_HBasePlugin {
|
||||
@Test
|
||||
public void testBuildScenario() {
|
||||
RunScenarioModel result = buildScenario(10);
|
||||
assertEquals(1, result.getUsePlugins().size());
|
||||
assertEquals("hBase", result.getUsePlugins().get(0).getId());
|
||||
assertEquals("HBase", result.getUsePlugins().get(0).getName());
|
||||
assertEquals(1, result.getPages().size());
|
||||
assertEquals(1, result.getPages().get(0).getBatches().size());
|
||||
assertEquals(10, result.getPages().get(0).getBatches().get(0)
|
||||
.getBehaviors().size());
|
||||
for (int i = 0; i < 10; i++) {
|
||||
BehaviorModel behavior = result.getPages().get(0).getBatches()
|
||||
.get(0).getBehaviors().get(i);
|
||||
assertEquals(i, behavior.getId());
|
||||
assertEquals("Send", behavior.getName());
|
||||
assertEquals(3, behavior.getParameters().size());
|
||||
assertEquals("USERBEHAVIOR", behavior.getType());
|
||||
assertEquals("hBase", behavior.getUse());
|
||||
assertEquals("beginTime", behavior.getParameters().get(0).getKey());
|
||||
assertEquals("201309111715001", behavior.getParameters().get(0)
|
||||
.getValue());
|
||||
assertEquals(1000 * i + 1 + "", behavior.getParameters().get(1)
|
||||
.getValue());
|
||||
assertEquals("beginUser", behavior.getParameters().get(1).getKey());
|
||||
assertEquals(1000 * i + 100 + "", behavior.getParameters().get(2)
|
||||
.getValue());
|
||||
assertEquals("endUser", behavior.getParameters().get(2).getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public RunScenarioModel buildScenario(int behaviorSize) {
|
||||
RunScenarioModel runScenarioModel = new RunScenarioModel();
|
||||
|
||||
List<UsePluginModel> usePluginList = new ArrayList<UsePluginModel>();
|
||||
UsePluginModel plugin = new UsePluginModel();
|
||||
plugin.setId("hBase");
|
||||
plugin.setName("HBase");
|
||||
plugin.setParameters(Collections.<ParameterModel> emptyList());
|
||||
usePluginList.add(plugin);
|
||||
runScenarioModel.setUsePlugins(usePluginList);
|
||||
|
||||
List<PageModel> pageList = new ArrayList<PageModel>();
|
||||
PageModel page = new PageModel();
|
||||
List<BatchModel> batchModelList = new ArrayList<BatchModel>();
|
||||
BatchModel batch = new BatchModel();
|
||||
batch.setChildId(-1);
|
||||
batch.setId(0);
|
||||
batch.setParentId(-1);
|
||||
|
||||
List<BehaviorModel> behaviorList = new ArrayList<BehaviorModel>();
|
||||
for (int i = 0; i < behaviorSize; i++) {
|
||||
behaviorList.add(createABehavior(i));
|
||||
}
|
||||
batch.setBehaviors(behaviorList);
|
||||
batchModelList.add(batch);
|
||||
page.setBatches(batchModelList);
|
||||
pageList.add(page);
|
||||
runScenarioModel.setPages(pageList);
|
||||
return runScenarioModel;
|
||||
}
|
||||
|
||||
private BehaviorModel createABehavior(int i) {
|
||||
List<ParameterModel> parameters = new ArrayList<ParameterModel>();
|
||||
ParameterModel beginTimePara = new ParameterModel();
|
||||
beginTimePara.setKey("beginTime");
|
||||
beginTimePara.setValue("201309111715001");
|
||||
parameters.add(beginTimePara);
|
||||
ParameterModel beginUser = new ParameterModel();
|
||||
beginUser.setKey("beginUser");
|
||||
beginUser.setValue(1000 * i + 1 + "");
|
||||
parameters.add(beginUser);
|
||||
ParameterModel endUser = new ParameterModel();
|
||||
endUser.setKey("endUser");
|
||||
endUser.setValue(1000 * i + 100 + "");
|
||||
parameters.add(endUser);
|
||||
return BehaviorModel
|
||||
.UserBehaviorBuilder(i, "Send", "hBase", parameters);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue