/** * Get the nth variable value (zero-based) * * @param i * specifies which variable value should be returned (zero-based) * @return the value of the nth variable * @throws JMeterError * when an invalid index <code>i</code> was given */ public String getVarValue(int i){ try { return values[i]; } catch (ArrayIndexOutOfBoundsException e) { throw new JMeterError("Check the sample_variable settings!", e); } }
/** * @see org.apache.jmeter.gui.action.AbstractActionWithNoRunningTest#doActionAfterCheck(ActionEvent) */ @Override public void doActionAfterCheck(ActionEvent e) { String locale = ((Component) e.getSource()).getName(); Locale loc; int sep = locale.indexOf('_'); if (sep > 0) { loc = new Locale(locale.substring(0, sep), locale.substring(sep + 1)); } else { loc = new Locale(locale, ""); } log.debug("Changing locale to {}", loc); try { JMeterUtils.setLocale(loc); } catch (JMeterError err) { JMeterUtils.reportErrorToUser(err.toString()); } }
/** * Return delimiterValue handling the TAB case * @param delimiterValue Delimited value * @return String delimited modified to handle correctly tab * @throws JMeterError if delimiterValue has a length different from 1 */ public static String getDelimiter(String delimiterValue) { if ("\\t".equals(delimiterValue)) {// Make it easier to enter a tab (can use \<tab> but that is awkward) delimiterValue="\t"; } if (delimiterValue.length() != 1){ throw new JMeterError("Delimiter '"+delimiterValue+"' must be of length 1."); } return delimiterValue; }
private void processAssertion(SampleResult result, Assertion assertion) { AssertionResult assertionResult; try { assertionResult = assertion.getResult(result); } catch (AssertionError e) { log.debug("Error processing Assertion.", e); assertionResult = new AssertionResult("Assertion failed! See log file (debug level, only)."); assertionResult.setFailure(true); assertionResult.setFailureMessage(e.toString()); } catch (JMeterError e) { log.error("Error processing Assertion.", e); assertionResult = new AssertionResult("Assertion failed! See log file."); assertionResult.setError(true); assertionResult.setFailureMessage(e.toString()); } catch (Exception e) { log.error("Exception processing Assertion.", e); assertionResult = new AssertionResult("Assertion failed! See log file."); assertionResult.setError(true); assertionResult.setFailureMessage(e.toString()); } result.setSuccessful(result.isSuccessful() && !(assertionResult.isError() || assertionResult.isFailure())); result.addAssertionResult(assertionResult); }
private Object bshInvoke(Method m, Object[] o, boolean shouldLog) throws JMeterException { Object r = null; final String errorString = "Error invoking bsh method: "; try { r = m.invoke(bshInstance, o); } catch (IllegalArgumentException | IllegalAccessException e) { // Programming error final String message = errorString + m.getName(); log.error(message); throw new JMeterError(message, e); } catch (InvocationTargetException e) { // Can occur at run-time // could be caused by the bsh Exceptions: // EvalError, ParseException or TargetError String message = errorString + m.getName(); Throwable cause = e.getCause(); if (cause != null) { message += "\t" + cause.getLocalizedMessage(); } if (shouldLog) { log.error(message); } throw new JMeterException(message, e); } return r; }
/** {@inheritDoc} */ @Override public void replaceKey(Object currentKey, Object newKey) { HashTree tree = getTree(currentKey); data.remove(currentKey); data.put(newKey, tree); // find order.indexOf(currentKey) using == rather than equals() // there may be multiple entries which compare equals (Bug 50898) // This will be slightly slower than the built-in method, // but replace() is not used frequently. int entry=-1; for (int i=0; i < order.size(); i++) { Object ent = order.get(i); if (ent == currentKey) { entry = i; break; } } if (entry == -1) { throw new JMeterError("Impossible state, data key not present in order: "+currentKey.getClass()); } order.set(entry, newKey); }
@Override public void sampleOccurred(SampleEvent e) { try { listener.sampleOccurred(e); } catch (RemoteException err) { if (err.getCause() instanceof java.net.ConnectException){ throw new JMeterError("Could not return sample",err); } log.error("sampleOccurred", err); } }
private Object doInvoke(Class<?> _class, Object _invokee, Object[] _args) { Class<?>[] argTypes = getTypes(_args); try { Method method = doCreateMethod(_class , argTypes); if (method == null){ final String message = "Can't find method " +_class.getName()+"#"+methodName+typesToString(argTypes); log.error(message, new Throwable()); throw new JMeterError(message); } return method.invoke(_invokee, _args); } catch (Exception e) { final String message = "Trouble functing: " +_class.getName() +"."+methodName+"(...) : " +" invokee: "+_invokee +" "+e.getMessage(); log.warn(message, e); throw new JMeterError(message,e); } }
} catch (RemoteException err) { if (err.getCause() instanceof java.net.ConnectException){ throw new JMeterError("Could not return sample",err);
} catch (RemoteException err) { if (err.getCause() instanceof java.net.ConnectException){ throw new JMeterError("Could not return sample",err);
throw new JMeterError("No action handlers found - check JMeterHome and libraries");
} catch (IOException | NoSuchAlgorithmException e) { log.error("Can't compute checksum for saveservice properties file", e); throw new JMeterError("JMeter requires the checksum of saveservice properties file to continue", e); throw new JMeterError("JMeter requires the saveservice properties file to continue");
public ImageIcon getIcon(boolean enabled) { TestElement testElement = getTestElement(); try { if (testElement instanceof TestBean) { Class<?> testClass = testElement.getClass(); try { Image img = Introspector.getBeanInfo(testClass).getIcon(BeanInfo.ICON_COLOR_16x16); // If icon has not been defined, then use GUI_CLASS property if (img == null) { Object clazz = Introspector.getBeanInfo(testClass).getBeanDescriptor() .getValue(TestElement.GUI_CLASS); if (clazz == null) { log.warn("getIcon(): Can't obtain GUI class from {}", testClass); return null; } return GUIFactory.getIcon(Class.forName((String) clazz), enabled); } return new ImageIcon(img); } catch (IntrospectionException e1) { log.error("Can't obtain icon for class {}", testElement, e1); throw new org.apache.jorphan.util.JMeterError(e1); } } return GUIFactory.getIcon(Class.forName(testElement.getPropertyAsString(TestElement.GUI_CLASS)), enabled); } catch (ClassNotFoundException e) { log.warn("Can't get icon for class {}", testElement, e); return null; } }
final String msg = "Unknown timestamp format"; log.warn(msg); throw new JMeterError(msg); log.warn("Error parsing field '{}' at line {}. {}", field, lineNumber, e.toString()); throw new JMeterError(e); } catch (ArrayIndexOutOfBoundsException e) { log.warn("Insufficient columns to parse field '{}' at line {}", field, lineNumber); throw new JMeterError(e);
final String errrorMessage = "ParserConfigurationException while processing ("+getXPathQuery()+")"; log.error(errrorMessage,e); throw new JMeterError(errrorMessage,e); } catch (SAXException e) {// Can happen for bad input document if (log.isWarnEnabled()) {