use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestInterleaveControl method testProcessing6.
@Test
public void testProcessing6() throws Exception {
testLog.debug("Testing Interleave Controller 6");
GenericController controller = new GenericController();
InterleaveControl sub_1 = new InterleaveControl();
controller.addTestElement(new TestSampler("one"));
sub_1.setStyle(InterleaveControl.IGNORE_SUB_CONTROLLERS);
controller.addTestElement(sub_1);
LoopController sub_2 = new LoopController();
sub_1.addTestElement(sub_2);
sub_2.setLoops(3);
int counter = 1;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
controller.initialize();
for (int i = 0; i < 4; i++) {
assertEquals(1, counter);
counter = 0;
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
assertEquals("one", sampler.getName());
counter++;
}
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestOnceOnlyController method testProcessing2.
@Test
public void testProcessing2() throws Exception {
GenericController controller = new GenericController();
GenericController sub_1 = new OnceOnlyController();
sub_1.addTestElement(new TestSampler("one"));
sub_1.addTestElement(new TestSampler("two"));
controller.addTestElement(sub_1);
controller.addTestElement(new TestSampler("three"));
LoopController sub_2 = new LoopController();
sub_2.setLoops(3);
OnceOnlyController sub_3 = new OnceOnlyController();
sub_2.addTestElement(new TestSampler("four"));
sub_3.addTestElement(new TestSampler("five"));
sub_3.addTestElement(new TestSampler("six"));
sub_2.addTestElement(sub_3);
sub_2.addIterationListener(sub_3);
sub_2.addTestElement(new TestSampler("seven"));
controller.addTestElement(sub_2);
String[] interleaveOrder = new String[] { "one", "two" };
String[] order = new String[] { "", "", "three", "four", "five", "six", "seven", "four", "seven", "four", "seven" };
int counter = 11;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
for (int i = 0; i < 4; i++) {
assertEquals(11, counter);
counter = 0;
if (i > 0) {
counter = 2;
}
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
if (i == 0 && counter < 2) {
assertEquals(interleaveOrder[counter], sampler.getName());
} else {
assertEquals(order[counter], sampler.getName());
}
counter++;
}
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestOnceOnlyController method testProcessing.
@Test
public void testProcessing() throws Exception {
GenericController controller = new GenericController();
GenericController sub_1 = new OnceOnlyController();
sub_1.addTestElement(new TestSampler("one"));
sub_1.addTestElement(new TestSampler("two"));
controller.addTestElement(sub_1);
controller.addTestElement(new TestSampler("three"));
LoopController sub_2 = new LoopController();
sub_2.setLoops(3);
GenericController sub_3 = new GenericController();
sub_2.addTestElement(new TestSampler("four"));
sub_3.addTestElement(new TestSampler("five"));
sub_3.addTestElement(new TestSampler("six"));
sub_2.addTestElement(sub_3);
sub_2.addTestElement(new TestSampler("seven"));
controller.addTestElement(sub_2);
String[] interleaveOrder = new String[] { "one", "two" };
String[] order = new String[] { "", "", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven" };
int counter = 15;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
for (int i = 0; i < 4; i++) {
assertEquals(15, counter);
counter = 0;
if (i > 0) {
counter = 2;
}
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
if (i == 0 && counter < 2) {
assertEquals(interleaveOrder[counter], sampler.getName());
} else {
assertEquals(order[counter], sampler.getName());
}
counter++;
}
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class GuiPackage method getCurrentGui.
/**
* Convenience method for grabbing the gui for the current node.
*
* @return the GUI component associated with the currently selected node
*/
public JMeterGUIComponent getCurrentGui() {
try {
updateCurrentNode();
TestElement curNode = treeListener.getCurrentNode().getTestElement();
JMeterGUIComponent comp = getGui(curNode);
if (comp == null) {
log.debug("No Component found for {}.", treeListener.getCurrentNode().getName());
return null;
}
comp.clearGui();
log.debug("Updating gui to new node");
comp.configure(curNode);
currentNodeUpdated = false;
return comp;
} catch (Exception e) {
log.error("Problem retrieving gui", e);
return null;
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class GuiPackage method updateCurrentNode.
/**
* This method should be called in order for GuiPackage to change the
* current node. This will save any changes made to the earlier node before
* choosing the new node.
*/
public void updateCurrentNode() {
try {
if (currentNode != null && !currentNodeUpdated) {
log.debug("Updating current node " + currentNode.getName());
JMeterGUIComponent comp = getGui(currentNode.getTestElement());
if (comp == null) {
log.debug("No component found for {}", currentNode.getName());
return;
}
TestElement el = currentNode.getTestElement();
int before = 0;
int after = 0;
final boolean historyEnabled = UndoHistory.isEnabled();
if (historyEnabled) {
before = getTestElementCheckSum(el);
}
comp.modifyTestElement(el);
if (historyEnabled) {
after = getTestElementCheckSum(el);
}
if (!historyEnabled || (before != after)) {
// Bug 50221 - ensure label is updated
currentNode.nameChanged();
}
}
// The current node is now updated
currentNodeUpdated = true;
currentNode = treeListener.getCurrentNode();
} catch (Exception e) {
log.error("Problem retrieving gui", e);
}
}
Aggregations