本文整理汇总了Java中org.apache.jorphan.collections.HashTree类的典型用法代码示例。如果您正苦于以下问题:Java HashTree类的具体用法?Java HashTree怎么用?Java HashTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HashTree类属于org.apache.jorphan.collections包,在下文中一共展示了HashTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadControl1
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
@Test
public void loadControl1() throws Exception {
log.info("start loadControl1()");
// Initialize Properties, logging, locale, etc.
JMeterUtils.loadJMeterProperties(JMETER_HOME + "/bin/jmeter.properties");
JMeterUtils.setJMeterHome(JMETER_HOME);
JMeterUtils.initLocale();
// Initialize JMeter SaveService
SaveService.loadProperties();
// Load existing .jmx Test Plan
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL url = classLoader.getResource("tutorial/jmeter/Tutorial6.jmx");
File file = new File(url.toURI());
HashTree testPlanTree = SaveService.loadTree(file);
// Run JMeter Test
StandardJMeterEngine jmeter = new StandardJMeterEngine();
jmeter.configure(testPlanTree);
jmeter.run();
}
示例2: start
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
public void start() {
log.debug("Start debugging");
frontend.started();
HashTree hashTree = getSelectedTree();
StandardJMeterEngine.register(new StateListener()); // oh, dear, they use static field then clean it...
engine = new DebuggerEngine(JMeterContextService.getContext());
engine.setStepper(this);
JMeter.convertSubTree(hashTree);
engine.configure(hashTree);
try {
engine.runTest();
} catch (JMeterEngineException e) {
log.error("Failed to pauseContinue debug", e);
stop();
}
}
示例3: runRealEngine
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
@Test
public void runRealEngine() throws Exception {
TestTreeProvider prov = new TestProvider();
HashTree hashTree = prov.getTestTree();
JMeter.convertSubTree(hashTree);
StandardJMeterEngine engine = new StandardJMeterEngine();
engine.configure(hashTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
}
示例4: startEngine
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
/**
* Start JMeter engine
* @param noTimer ignore timers
*/
private void startEngine(boolean ignoreTimer) {
GuiPackage gui = GuiPackage.getInstance();
HashTree testTree = gui.getTreeModel().getTestPlan();
JMeter.convertSubTree(testTree);
testTree.add(testTree.getArray()[0], gui.getMainFrame());
log.debug("test plan before cloning is running version: "
+ ((TestPlan) testTree.getArray()[0]).isRunningVersion());
TreeCloner cloner = cloneTree(testTree, ignoreTimer);
engine = new StandardJMeterEngine();
engine.configure(cloner.getClonedTree());
try {
engine.runTest();
} catch (JMeterEngineException e) {
JOptionPane.showMessageDialog(gui.getMainFrame(), e.getMessage(),
JMeterUtils.getResString("error_occurred"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
}
log.debug("test plan after cloning and running test is running version: "
+ ((TestPlan) testTree.getArray()[0]).isRunningVersion());
}
示例5: runDebugEngine
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
@Test
public void runDebugEngine() throws Exception {
TestProvider prov = new TestProvider();
Debugger sel = new Debugger(prov, new FrontendMock());
AbstractThreadGroup tg = prov.getTG(0);
sel.selectThreadGroup(tg);
HashTree testTree = sel.getSelectedTree();
DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree);
LoopController samplerController = (LoopController) tg2.getSamplerController();
samplerController.setLoops(1);
samplerController.setContinueForever(false);
JMeter.convertSubTree(testTree);
DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext());
StepTriggerCounter hook = new StepTriggerCounter();
engine.setStepper(hook);
engine.configure(testTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
assertEquals(88, hook.cnt);
}
示例6: testThreadStopping
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
@Test
public void testThreadStopping() throws Exception {
DirectoryListingConfig config = new DirectoryListingConfig();
File rootDir = TestDirectoryListingConfigActionTest.createFileTree();
setDirectoryConfig(config, rootDir.getAbsolutePath(), VARIABLE_NAME, true, false, false, false, true, false);
final HashTree hashTree = new HashTree();
hashTree.add(new LoopController());
JMeterThread thread = new JMeterThread(hashTree, null, null);
JMeterContextService.getContext().setThread(thread);
testFlow(config);
try {
config.iterationStart(null);
} catch (JMeterStopThreadException ex) {
assertEquals("All files in the directory have been passed.", ex.getMessage());
}
}
示例7: selectThreadGroup
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
private void selectThreadGroup(AbstractThreadGroup tg) {
debugger.selectThreadGroup(tg);
treeModel.clearTestPlan();
HashTree origTree = debugger.getSelectedTree();
TreeCloner cloner = new TreeCloner();
origTree.traverse(cloner);
HashTree selectedTree = cloner.getClonedTree();
// Hack to resolve ModuleControllers from JMeter.java
SearchClass<ReplaceableController> replaceableControllers = new SearchClass<>(ReplaceableController.class);
selectedTree.traverse(replaceableControllers);
Collection<ReplaceableController> replaceableControllersRes = replaceableControllers.getSearchResults();
for (ReplaceableController replaceableController : replaceableControllersRes) {
replaceableController.resolveReplacementSubTree((JMeterTreeNode) treeModel.getRoot());
}
JMeter.convertSubTree(selectedTree);
try {
treeModel.addSubTree(selectedTree, (JMeterTreeNode) treeModel.getRoot());
} catch (IllegalUserActionException e) {
throw new RuntimeException(e);
}
// select TG for visual convenience
SearchByClass<DebuggingThreadGroup> tgs = new SearchByClass<>(DebuggingThreadGroup.class);
selectedTree.traverse(tgs);
for (DebuggingThreadGroup forSel : tgs.getSearchResults()) {
Wrapper<AbstractThreadGroup> wtg = new ThreadGroupWrapper();
wtg.setWrappedElement(forSel);
selectTargetInTree(wtg);
}
}
示例8: runVariablesDebugEngine
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
@Test
public void runVariablesDebugEngine() throws Exception {
TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/vars.jmx", "vars.jmx");
Debugger sel = new Debugger(prov, new FrontendMock());
AbstractThreadGroup tg = prov.getTG(0);
sel.selectThreadGroup(tg);
HashTree testTree = sel.getSelectedTree();
TestSampleListener listener = new TestSampleListener();
testTree.add(testTree.getArray()[0], listener);
DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree);
LoopController samplerController = (LoopController) tg2.getSamplerController();
samplerController.setLoops(1);
samplerController.setContinueForever(false);
JMeter.convertSubTree(testTree);
DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext());
StepTriggerCounter hook = new StepTriggerCounter();
engine.setStepper(hook);
engine.configure(testTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
assertEquals(8, hook.cnt);
assertEquals(3, listener.events.size());
for (SampleEvent event : listener.events) {
SampleResult res = event.getResult();
String label = res.getSampleLabel();
assertTrue("Label: " + label + " must end with '123'", label.endsWith("123"));
assertFalse("Variable ${VAR} must be changed to '123' value. label: " + label, label.contains("${VAR}"));
assertTrue("label: '" + label + "' response: '" + res.getResponseMessage() +"'", res.isSuccessful());
}
}
示例9: runVariablesInAssertions
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
@Test
public void runVariablesInAssertions() throws Exception {
TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/debug.jmx", "debug.jmx");
Debugger sel = new Debugger(prov, new FrontendMock());
AbstractThreadGroup tg = prov.getTG(0);
sel.selectThreadGroup(tg);
HashTree testTree = sel.getSelectedTree();
TestSampleListener listener = new TestSampleListener();
testTree.add(testTree.getArray()[0], listener);
DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree);
LoopController samplerController = (LoopController) tg2.getSamplerController();
samplerController.setLoops(1);
samplerController.setContinueForever(false);
JMeter.convertSubTree(testTree);
DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext());
StepTriggerCounter hook = new StepTriggerCounter();
engine.setStepper(hook);
engine.configure(testTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
assertEquals(4, hook.cnt);
assertEquals(1, listener.events.size());
SampleEvent event = listener.events.get(0);
SampleResult result = event.getResult();
AssertionResult[] assertionResults = result.getAssertionResults();
assertEquals(1, assertionResults.length);
AssertionResult assertionRes = assertionResults[0];
assertNull(assertionRes.getFailureMessage());
}
示例10: runVariablesInControllers
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
@Test
public void runVariablesInControllers() throws Exception {
TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/loops.jmx", "loops.jmx");
Debugger sel = new Debugger(prov, new FrontendMock());
AbstractThreadGroup tg = prov.getTG(0);
sel.selectThreadGroup(tg);
HashTree testTree = sel.getSelectedTree();
TestSampleListener listener = new TestSampleListener();
testTree.add(testTree.getArray()[0], listener);
DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree);
LoopController samplerController = (LoopController) tg2.getSamplerController();
samplerController.setLoops(1);
samplerController.setContinueForever(false);
JMeter.convertSubTree(testTree);
DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext());
StepTriggerCounter hook = new StepTriggerCounter();
engine.setStepper(hook);
engine.configure(testTree);
engine.runTest();
while (engine.isActive()) {
Thread.sleep(1000);
}
assertEquals(12, hook.cnt);
assertEquals(3, listener.events.size());
}
示例11: getProperBranch
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
/**
* Extract from tree (included test plan) all Test Elements located in a Test Fragment
* @param tree HashTree included Test Plan
* @return HashTree Subset within Test Fragment or Empty HashTree
*/
private HashTree getProperBranch(HashTree tree) {
for (Object o : new LinkedList<>(tree.list())) {
TestElement item = (TestElement) o;
//if we found a TestPlan, then we are on our way to the TestFragment
if (item instanceof TestPlan)
{
return getProperBranch(tree.getTree(item));
}
if (item instanceof TestFragmentController)
{
return tree.getTree(item);
}
}
log.warn("No Test Fragment was found in included Test Plan, returning empty HashTree");
return new HashTree();
}
示例12: getTestPlan
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
@RequestMapping(value = "/testplan", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody TestPlanModel getTestPlan(@QueryParam(value = "name") String name){
if(name == null || name.isEmpty()){
return new TestPlanModel();
}else{
File testplan = new File("./testplans/" + name);
try {
HashTree tree = SaveService.loadTree(testplan);
return new TestPlanModel(tree);
} catch (IOException e) {
log.error("Couldn't read file for tesplan {}. Message is {}", testplan, e.getMessage());
}
return new TestPlanModel();
}
}
示例13: newElementByBeanName
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
public TestElementModel newElementByBeanName(String name) {
if (name == null)
return null;
try {
TestElementModel model = new TestElementModel();
TestElement ele = (TestElement) context.getBean(name);
model.setTestElement(ele);
//model.setType(TestElementModel.getElementType(ele));
model.setHashTree(new HashTree());
return model;
} catch (Exception e) {
log.error("Couldn't initialize element {} because of exception {} reason {}",
name,e.getClass().getName(), e.getMessage());
return null;
}
}
示例14: unmarshal
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
ScriptWrapper wrap = new ScriptWrapper();
wrap.version = reader.getAttribute(ATT_VERSION);
ConversionHelp.setInVersion(wrap.version);// Make sure decoding
// follows input file
reader.moveDown();
// Catch errors and rethrow as ConversionException so we get location details
try {
wrap.testPlan = (HashTree) context.convertAnother(wrap, getNextType(reader));
} catch (NoClassDefFoundError | Exception e) {
throw createConversionException(e);
}
return wrap;
}
示例15: unmarshal
import org.apache.jorphan.collections.HashTree; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
boolean isKey = true;
Object current = null;
HashTree tree = (HashTree) createCollection(context.getRequiredType());
while (reader.hasMoreChildren()) {
reader.moveDown();
Object item = readItem(reader, context, tree);
if (isKey) {
tree.add(item);
current = item;
isKey = false;
} else {
tree.set(current, (HashTree) item);
isKey = true;
}
reader.moveUp();
}
return tree;
}