use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestElementConverter method unmarshal.
/** {@inheritDoc} */
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
String classAttribute = reader.getAttribute(ConversionHelp.ATT_CLASS);
Class<?> type;
if (classAttribute == null) {
type = mapper().realClass(reader.getNodeName());
} else {
type = mapper().realClass(classAttribute);
}
// Update the test class name if necessary (Bug 52466)
String inputName = type.getName();
String targetName = inputName;
String guiClassName = SaveService.aliasToClass(reader.getAttribute(ConversionHelp.ATT_TE_GUICLASS));
targetName = NameUpdater.getCurrentTestName(inputName, guiClassName);
if (!targetName.equals(inputName)) {
// remap the class name
type = mapper().realClass(targetName);
}
// needed by property converters (Bug 52466)
context.put(SaveService.TEST_CLASS_NAME, targetName);
try {
TestElement el = (TestElement) type.newInstance();
// No need to check version, just process the attributes if present
ConversionHelp.restoreSpecialProperties(el, reader);
// Slight hack - we need to ensure the TestClass is not reset by the previous call
el.setProperty(TestElement.TEST_CLASS, targetName);
while (reader.hasMoreChildren()) {
reader.moveDown();
JMeterProperty prop = (JMeterProperty) readItem(reader, context, el);
if (prop != null) {
// could be null if it has been deleted via NameUpdater
el.setProperty(prop);
}
reader.moveUp();
}
return el;
} catch (InstantiationException | IllegalAccessException e) {
log.error("TestElement not instantiable: {}", type, e);
return null;
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class LdapExtConfigGui method configure.
/**
* A newly created component can be initialized with the contents of a Test
* Element object by calling this method. The component is responsible for
* querying the Test Element object for the relevant information to display
* in its GUI.
*
* @param element
* the TestElement to configure
*/
@Override
public void configure(TestElement element) {
super.configure(element);
servername.setText(element.getPropertyAsString(LDAPExtSampler.SERVERNAME));
port.setText(element.getPropertyAsString(LDAPExtSampler.PORT));
rootdn.setText(element.getPropertyAsString(LDAPExtSampler.ROOTDN));
scope.setSelectedIndex(element.getPropertyAsInt(LDAPExtSampler.SCOPE));
countlim.setText(element.getPropertyAsString(LDAPExtSampler.COUNTLIM));
timelim.setText(element.getPropertyAsString(LDAPExtSampler.TIMELIM));
attribs.setText(element.getPropertyAsString(LDAPExtSampler.ATTRIBS));
retobj.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.RETOBJ));
deref.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.DEREF));
connto.setText(element.getPropertyAsString(LDAPExtSampler.CONNTO));
parseflag.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.PARSEFLAG));
secure.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.SECURE));
userpw.setText(element.getPropertyAsString(LDAPExtSampler.USERPW));
userdn.setText(element.getPropertyAsString(LDAPExtSampler.USERDN));
comparedn.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREDN));
comparefilt.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREFILT));
modddn.setText(element.getPropertyAsString(LDAPExtSampler.MODDDN));
newdn.setText(element.getPropertyAsString(LDAPExtSampler.NEWDN));
CardLayout cl = (CardLayout) (cards.getLayout());
final String testType = element.getPropertyAsString(LDAPExtSampler.TEST);
if (testType.equals(LDAPExtSampler.UNBIND)) {
unbind.setSelected(true);
cl.show(cards, CARDS_DEFAULT);
} else if (testType.equals(LDAPExtSampler.BIND)) {
bind.setSelected(true);
cl.show(cards, CARDS_BIND);
} else if (testType.equals(LDAPExtSampler.SBIND)) {
sbind.setSelected(true);
cl.show(cards, CARDS_BIND);
} else if (testType.equals(LDAPExtSampler.COMPARE)) {
compare.setSelected(true);
cl.show(cards, CARDS_COMPARE);
} else if (testType.equals(LDAPExtSampler.ADD)) {
addTest.setSelected(true);
add.setText(element.getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
tableAddPanel.configure((TestElement) element.getProperty(LDAPExtSampler.ARGUMENTS).getObjectValue());
cl.show(cards, CARDS_ADD);
} else if (testType.equals(LDAPExtSampler.MODIFY)) {
modifyTest.setSelected(true);
modify.setText(element.getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
tableModifyPanel.configure((TestElement) element.getProperty(LDAPExtSampler.LDAPARGUMENTS).getObjectValue());
cl.show(cards, CARDS_MODIFY);
} else if (testType.equals(LDAPExtSampler.DELETE)) {
deleteTest.setSelected(true);
delete.setText(element.getPropertyAsString(LDAPExtSampler.DELETE));
cl.show(cards, CARDS_DELETE);
} else if (testType.equals(LDAPExtSampler.RENAME)) {
rename.setSelected(true);
cl.show(cards, CARDS_RENAME);
} else if (testType.equals(LDAPExtSampler.SEARCH)) {
searchTest.setSelected(true);
searchbase.setText(element.getPropertyAsString(LDAPExtSampler.SEARCHBASE));
searchfilter.setText(element.getPropertyAsString(LDAPExtSampler.SEARCHFILTER));
cl.show(cards, CARDS_SEARCH);
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class GenerateTreeGui method createTestElement.
@Override
public TestElement createTestElement() {
TestElement el = new ConfigTestElement();
modifyTestElement(el);
return el;
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class ProxyControl method notifyTestListenersOfEnd.
/**
* This will notify test listeners directly within the Proxy that the 'test'
* (here meaning the proxy recording) has ended.
*/
private void notifyTestListenersOfEnd() {
JMeterTreeModel treeModel = getJmeterTreeModel();
JMeterTreeNode myNode = treeModel.getNodeOf(this);
Enumeration<JMeterTreeNode> kids = myNode.children();
while (kids.hasMoreElements()) {
JMeterTreeNode subNode = kids.nextElement();
if (subNode.isEnabled()) {
TestElement testElement = subNode.getTestElement();
if (testElement instanceof TestStateListener) {
// TL - TE
((TestStateListener) testElement).testEnded();
}
}
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class ProxyControl method notifyTestListenersOfStart.
/**
* This will notify test listeners directly within the Proxy that the 'test'
* (here meaning the proxy recording) has started.
*/
private void notifyTestListenersOfStart() {
JMeterTreeModel treeModel = getJmeterTreeModel();
JMeterTreeNode myNode = treeModel.getNodeOf(this);
Enumeration<JMeterTreeNode> kids = myNode.children();
while (kids.hasMoreElements()) {
JMeterTreeNode subNode = kids.nextElement();
if (subNode.isEnabled()) {
TestElement testElement = subNode.getTestElement();
if (testElement instanceof TestStateListener) {
((TestStateListener) testElement).testStarted();
}
}
}
}
Aggregations