public static String[] split(String splittee,String splitChar) { return split(splittee,splitChar,true); }
/** * Get the mains file encoding * list from https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html * @return a String[] with the list of file encoding */ private String[] getListFileEncoding() { return JOrphanUtils.split(JMeterUtils.getPropDefault("csvdataset.file.encoding_list", ""), "|"); //$NON-NLS-1$ } }
/** * Get the list of JDBC driver classname for the main databases * @return a String[] with the list of JDBC driver classname */ private String[] getListJDBCDriverClass() { return JOrphanUtils.split(JMeterUtils.getPropDefault("jdbc.config.jdbc.driver.class", ""), "|"); //$NON-NLS-1$ }
/** * Get the check queries for the main databases * Based in https://stackoverflow.com/questions/10684244/dbcp-validationquery-for-different-databases * @return a String[] with the list of check queries */ private String[] getListCheckQuery() { return JOrphanUtils.split(JMeterUtils.getPropDefault("jdbc.config.check.query", ""), "|"); //$NON-NLS-1$ }
public String[] getTestPlanClasspathArray() { return JOrphanUtils.split(this.getTestPlanClasspath(),CLASSPATH_SEPARATOR); }
/** * Use this method to set the entire data set. It takes an array of strings. * It uses the first row as the headers, and the next rows as the data * elements. Delimiter represents the delimiting character(s) that separate * each item in a data row. * * @param contents * array of strings, the first element is a list of the column * headers, the next elements each represent a single row of * data. * @param delimiter * the delimiter character that separates columns within the * string array. */ public void setData(String[] contents, String delimiter) { setHeaders(JOrphanUtils.split(contents[0], delimiter)); int x = 1; while (x < contents.length) { setLine(JOrphanUtils.split(contents[x++], delimiter)); } }
/** * Initialise the JMeter Locale */ public static void initLocale() { String loc = appProperties.getProperty("language"); // $NON-NLS-1$ if (loc != null) { String []parts = JOrphanUtils.split(loc,"_");// $NON-NLS-1$ if (parts.length==2) { setLocale(new Locale(parts[0], parts[1])); } else { setLocale(new Locale(loc, "")); // $NON-NLS-1$ } } else { setLocale(Locale.getDefault()); } }
String[] charSets = JOrphanUtils.split(acceptCharSet, ",");
public JMeterMenuBar() { // List for recent files menu items fileLoadRecentFiles = new LinkedList<>(); // Lists for remote engines menu items remoteEngineStart = new LinkedList<>(); remoteEngineStop = new LinkedList<>(); remoteEngineShut = new LinkedList<>(); remoteEngineExit = new LinkedList<>(); remoteHosts = JOrphanUtils.split(JMeterUtils.getPropDefault("remote_hosts", ""), ","); //$NON-NLS-1$ if (remoteHosts.length == 1 && remoteHosts[0].isEmpty()) { remoteHosts = new String[0]; } this.getRemoteItems(); createMenuBar(); JMeterUtils.addLocaleChangeListener(this); }
public void parseArguments(String queryString, String contentEncoding) { String[] args = JOrphanUtils.split(queryString, QRY_SEP); for (int i = 0; i < args.length; i++) {
continue; String[] st = JOrphanUtils.split(line, "\t", " ");// $NON-NLS-1$ $NON-NLS-2$ int name = 0; int value = 1;
while (pe.hasMoreElements()) { String key = (String) pe.nextElement(); String[] icons = JOrphanUtils.split(p.getProperty(key), " ");//$NON-NLS-1$ iconlist[i][0] = key; iconlist[i][1] = icons[0].replace(KEY_SIZE, iconSize);
String[] parts = JOrphanUtils.split(queryString, "--" + getBoundary()); //$NON-NLS-1$ for (String part : parts) { String contentDisposition = getHeaderValue("Content-disposition", part); //$NON-NLS-1$
bindings.put("FileName", fileName); // $NON-NLS-1$ (this name is fixed) bindings.put("Parameters", scriptParameters); // $NON-NLS-1$ (this name is fixed) String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$ bindings.put("args", args); // $NON-NLS-1$ (this name is fixed)
@SuppressWarnings("unchecked") private void setupClasslist(){ classnameCombo.removeAllItems(); methodName.removeAllItems(); try { List<String> classList; if (junit4.isSelected()){ classList = ClassFinder.findAnnotatedClasses(SPATHS, new Class[] {Test.class}, false); } else { classList = ClassFinder.findClassesThatExtend(SPATHS, new Class[] { TestCase.class }); } ClassFilter filter = new ClassFilter(); filter.setPackges(JOrphanUtils.split(filterpkg.getText(),",")); //$NON-NLS-1$ // change the classname drop down String[] clist = filter.filterArray(classList); for (String classStr : clist) { classnameCombo.addItem(classStr); } } catch (IOException e) { log.error("Exception getting interfaces.", e); } }
/** {@inheritDoc} */ @Override public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); String stringToSplit = ((CompoundVariable) values[0]).execute(); String varNamePrefix = ((CompoundVariable) values[1]).execute().trim(); String splitString = ","; if (values.length > 2) { // Split string provided String newSplitString = ((CompoundVariable) values[2]).execute(); splitString = newSplitString.length() > 0 ? newSplitString : splitString; } if (log.isDebugEnabled()){ log.debug("Split "+stringToSplit+ " using "+ splitString+ " into "+varNamePrefix); } String[] parts = JOrphanUtils.split(stringToSplit, splitString, "?");// $NON-NLS-1$ vars.put(varNamePrefix, stringToSplit); vars.put(varNamePrefix + "_n", Integer.toString(parts.length));// $NON-NLS-1$ for (int i = 1; i <= parts.length; i++) { if (log.isDebugEnabled()){ log.debug(parts[i-1]); } vars.put(varNamePrefix + "_" + i, parts[i - 1]);// $NON-NLS-1$ } vars.remove(varNamePrefix + "_" + (parts.length+1)); return stringToSplit; }
@Override public void iterationStart(LoopIterationEvent event) { Jedis connection = null; try { connection = pool.getResource(); // Get data from list's head String line = getDataFromConnection(connection, redisKey); if(line == null) { // i.e. no more data (nil) throw new JMeterStopThreadException("End of redis data detected"); } if (getRecycleDataOnUse()) { addDataToConnection(connection, redisKey, line); } final String names = variableNames; if (vars == null) { vars = JOrphanUtils.split(names, ","); } final JMeterContext context = getThreadContext(); JMeterVariables threadVars = context.getVariables(); String[] values = JOrphanUtils.split(line, delimiter, false); for (int a = 0; a < vars.length && a < values.length; a++) { threadVars.put(vars[a], values[a]); } } finally { pool.returnResource(connection); } }
@Override public void iterationStart(LoopIterationEvent event) { Jedis connection = null; try { connection = pool.getResource(); String line = null; if(getMode.equals(GetMode.RANDOM_REMOVE)) { line = connection.lpop(redisKey); } else { line = connection.srandmember(redisKey); } if(line == null) { // i.e. no more data (nil) throw new JMeterStopThreadException("End of redis data detected, thread will exit"); } final String names = variableNames; if (vars == null) { vars = JOrphanUtils.split(names, ","); } final JMeterContext context = getThreadContext(); JMeterVariables threadVars = context.getVariables(); String[] values = JOrphanUtils.split(line, delimiter, false); for (int a = 0; a < vars.length && a < values.length; a++) { threadVars.put(vars[a], values[a]); } } finally { pool.returnResource(connection); } }
protected void initManager(BSFManager mgr) throws BSFException{ final String label = getName(); final String fileName = getFilename(); final String scriptParameters = getParameters(); // Use actual class name for log final Logger logger = LoggerFactory.getLogger(getClass()); mgr.declareBean("log", logger, Logger.class); // $NON-NLS-1$ mgr.declareBean("Label",label, String.class); // $NON-NLS-1$ mgr.declareBean("FileName",fileName, String.class); // $NON-NLS-1$ mgr.declareBean("Parameters", scriptParameters, String.class); // $NON-NLS-1$ String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$ mgr.declareBean("args",args,args.getClass());//$NON-NLS-1$ // Add variables for access to context and variables JMeterContext jmctx = JMeterContextService.getContext(); JMeterVariables vars = jmctx.getVariables(); Properties props = JMeterUtils.getJMeterProperties(); mgr.declareBean("ctx", jmctx, jmctx.getClass()); // $NON-NLS-1$ mgr.declareBean("vars", vars, vars.getClass()); // $NON-NLS-1$ mgr.declareBean("props", props, props.getClass()); // $NON-NLS-1$ // For use in debugging: mgr.declareBean("OUT", System.out, PrintStream.class); // $NON-NLS-1$ // Most subclasses will need these: Sampler sampler = jmctx.getCurrentSampler(); mgr.declareBean("sampler", sampler, Sampler.class); SampleResult prev = jmctx.getPreviousResult(); mgr.declareBean("prev", prev, SampleResult.class); }
/** * Process the file or script from the test element. * <p> * Sets the following script variables: * <ul> * <li>FileName</li> * <li>Parameters</li> * <li>bsh.args</li> * </ul> * @param bsh the interpreter, not {@code null} * @return the result of the script, may be {@code null} * * @throws JMeterException when working with the bsh fails */ protected Object processFileOrScript(BeanShellInterpreter bsh) throws JMeterException{ String fileName = getFilename(); String params = getParameters(); bsh.set("FileName", fileName);//$NON-NLS-1$ // Set params as a single line bsh.set("Parameters", params); // $NON-NLS-1$ // and set as an array bsh.set("bsh.args",//$NON-NLS-1$ JOrphanUtils.split(params, " "));//$NON-NLS-1$ if (fileName.length() == 0) { return bsh.eval(getScript()); } return bsh.source(fileName); }