use of org.apache.jmeter.protocol.java.sampler.JavaSamplerClient in project jmeter by apache.
the class JavaConfigGui method configureClassName.
/**
*
*/
private void configureClassName() {
String className = classNameLabeledChoice.getText().trim();
try {
JavaSamplerClient client = (JavaSamplerClient) Class.forName(className, true, Thread.currentThread().getContextClassLoader()).newInstance();
Arguments currArgs = new Arguments();
argsPanel.modifyTestElement(currArgs);
Map<String, String> currArgsMap = currArgs.getArgumentsAsMap();
Arguments newArgs = new Arguments();
Arguments testParams = null;
try {
testParams = client.getDefaultParameters();
} catch (AbstractMethodError e) {
log.warn("JavaSamplerClient doesn't implement " + "getDefaultParameters. Default parameters won't " + "be shown. Please update your client class: " + className);
}
if (testParams != null) {
for (JMeterProperty jMeterProperty : testParams.getArguments()) {
Argument arg = (Argument) jMeterProperty.getObjectValue();
String name = arg.getName();
String value = arg.getValue();
// values that they did in the original test.
if (currArgsMap.containsKey(name)) {
String newVal = currArgsMap.get(name);
if (newVal != null && newVal.length() > 0) {
value = newVal;
}
}
newArgs.addArgument(name, value);
}
}
argsPanel.configure(newArgs);
warningLabel.setVisible(false);
} catch (Exception e) {
log.error("Error getting argument list for " + className, e);
warningLabel.setVisible(true);
}
}
use of org.apache.jmeter.protocol.java.sampler.JavaSamplerClient in project jmeter by apache.
the class JavaConfigGui method createClassnamePanel.
/**
* Create a panel with GUI components allowing the user to select a test
* class.
*
* @return a panel containing the relevant components
*/
private JPanel createClassnamePanel() {
List<String> possibleClasses = new ArrayList<>();
try {
// Find all the classes which implement the JavaSamplerClient
// interface.
possibleClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { JavaSamplerClient.class });
// Remove the JavaConfig class from the list since it only
// implements the interface for error conditions.
possibleClasses.remove(JavaSampler.class.getName() + "$ErrorSamplerClient");
} catch (Exception e) {
log.debug("Exception getting interfaces.", e);
}
classNameLabeledChoice = new JLabeledChoice(JMeterUtils.getResString("protocol_java_classname"), possibleClasses.toArray(ArrayUtils.EMPTY_STRING_ARRAY), true, false);
classNameLabeledChoice.addChangeListener(this);
warningLabel.setForeground(Color.RED);
Font font = warningLabel.getFont();
warningLabel.setFont(new Font(font.getFontName(), Font.BOLD, (int) (font.getSize() * 1.1)));
warningLabel.setVisible(false);
VerticalPanel panel = new VerticalPanel();
panel.add(classNameLabeledChoice);
panel.add(warningLabel);
return panel;
}
Aggregations