use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestInterleaveControl method testProcessing3.
@Test
public void testProcessing3() throws Exception {
testLog.debug("Testing Interleave Controller 3");
GenericController controller = new GenericController();
InterleaveControl sub_1 = new InterleaveControl();
sub_1.setStyle(InterleaveControl.USE_SUB_CONTROLLERS);
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"));
sub_1.addTestElement(sub_2);
String[] order = new String[] { "one", "three", "two", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven", "three", "one", "three", "two", "three" };
int counter = 0;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
assertEquals("failed on" + counter, order[counter], sampler.getName());
counter++;
}
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestInterleaveControl method testProcessing5.
@Test
public void testProcessing5() throws Exception {
testLog.debug("Testing Interleave Controller 5");
GenericController controller = new GenericController();
InterleaveControl sub_1 = new InterleaveControl();
sub_1.setStyle(InterleaveControl.USE_SUB_CONTROLLERS);
controller.addTestElement(sub_1);
GenericController sub_2 = new GenericController();
sub_2.addTestElement(new TestSampler("one"));
sub_2.addTestElement(new TestSampler("two"));
sub_1.addTestElement(sub_2);
GenericController sub_3 = new GenericController();
sub_3.addTestElement(new TestSampler("three"));
sub_3.addTestElement(new TestSampler("four"));
sub_1.addTestElement(sub_3);
String[] order = new String[] { "one", "two", "three", "four" };
int counter = 0;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
assertEquals("failed on" + counter, order[counter], sampler.getName());
counter++;
}
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class JMeterTest method GUIComponents2.
/*
* Test GUI elements - not run for TestBeanGui items
*/
public void GUIComponents2() throws Exception {
String name = guiItem.getClass().getName();
// TODO these assertions should be separate tests
TestElement el = guiItem.createTestElement();
assertNotNull(name + ".createTestElement should be non-null ", el);
assertEquals("GUI-CLASS: Failed on " + name, name, el.getPropertyAsString(TestElement.GUI_CLASS));
assertEquals("NAME: Failed on " + name, guiItem.getName(), el.getName());
assertEquals("TEST-CLASS: Failed on " + name, el.getClass().getName(), el.getPropertyAsString(TestElement.TEST_CLASS));
TestElement el2 = guiItem.createTestElement();
el.setName("hey, new name!:");
el.setProperty("NOT", "Shouldn't be here");
if (!(guiItem instanceof UnsharedComponent)) {
assertEquals("SHARED: Failed on " + name, "", el2.getPropertyAsString("NOT"));
}
log.debug("Saving element: {}", el.getClass());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
SaveService.saveElement(el, bos);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
bos.close();
el = (TestElement) SaveService.loadElement(bis);
bis.close();
assertNotNull("Load element failed on: " + name, el);
guiItem.configure(el);
assertEquals("CONFIGURE-TEST: Failed on " + name, el.getName(), guiItem.getName());
guiItem.modifyTestElement(el2);
assertEquals("Modify Test: Failed on " + name, "hey, new name!:", el2.getName());
}
Aggregations