use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class UndoHistory method add.
/**
* Add tree model copy to the history
* <p>
* This method relies on the rule that the record in history made AFTER
* change has been made to test plan
*
* @param treeModel JMeterTreeModel
* @param comment String
*/
public void add(JMeterTreeModel treeModel, String comment) {
if (!isEnabled()) {
log.debug("undo.history.size is set to 0, undo/redo feature is disabled");
return;
}
// don't add element if we are in the middle of undo/redo or a big loading
if (working) {
log.debug("Not adding history because of noop");
return;
}
JMeterTreeNode root = (JMeterTreeNode) treeModel.getRoot();
if (root.getChildCount() < 1) {
log.debug("Not adding history because of no children");
return;
}
String name = root.getName();
log.debug("Adding history element {}: {}", name, comment);
working = true;
// get test plan tree
HashTree tree = treeModel.getCurrentSubTree((JMeterTreeNode) treeModel.getRoot());
// first clone to not convert original tree
tree = (HashTree) tree.getTree(tree.getArray()[0]).clone();
position++;
while (history.size() > position) {
if (log.isDebugEnabled()) {
log.debug("Removing further record, position: {}, size: {}", position, history.size());
}
history.remove(history.size() - 1);
}
// cloning is required because we need to immute stored data
HashTree copy = UndoCommand.convertAndCloneSubTree(tree);
history.add(new UndoHistoryItem(copy, comment));
log.debug("Added history element, position: {}, size: {}", position, history.size());
working = false;
notifyListeners();
}
use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class TestLoad method checkTestFile.
public void checkTestFile() throws Exception {
HashTree tree = null;
try {
tree = getTree(testFile);
} catch (Exception e) {
fail(parent + ": " + testFile.getName() + " caused " + e);
}
assertTree(tree);
}
use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class TestSave method testTreeConversion.
@Test
public void testTreeConversion() throws Exception {
HashTree tree = new ListedHashTree();
JMeterTreeNode root = new JMeterTreeNode(new Arguments(), null);
tree.add(root, root);
tree.getTree(root).add(root, root);
save.convertSubTree(tree);
assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
tree = tree.getTree(tree.getArray()[0]);
assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
assertEquals(tree.getTree(tree.getArray()[0]).getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
}
use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class TestSaveService method testLoad.
@Test
public void testLoad() throws Exception {
for (String fileName : FILES_LOAD_ONLY) {
File file = findTestFile("testfiles/" + fileName);
try {
HashTree tree = SaveService.loadTree(file);
assertNotNull(tree);
} catch (IllegalArgumentException ex) {
fail("Exception loading " + file.getAbsolutePath());
}
}
}
use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class DistributedRunnerTest method initRunner.
private void initRunner(DistributedRunnerEmul runner, List<String> hosts) {
PrintStream origSystemOut = System.out;
ByteArrayOutputStream catchingOut = new ByteArrayOutputStream();
System.setOut(new PrintStream(catchingOut));
try {
runner.init(hosts, new HashTree());
fail();
} catch (RuntimeException ignored) {
}
System.setOut(origSystemOut);
}
Aggregations