use of org.apache.jmeter.gui.UnsharedComponent 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