private void preloadVariables(){ for (String property : PRE_LOAD) { String value = JMeterUtils.getProperty(property); if (value != null) { variables.put(property, value); } } }
/** * Set up the additional variable names to be saved * from the value in the {@link #SAMPLE_VARIABLES} property */ public static void initSampleVariables() { String vars = JMeterUtils.getProperty(SAMPLE_VARIABLES); variableNames=vars != null ? vars.split(",") : new String[0]; if (log.isInfoEnabled()) { log.info("List of sample_variables: {}", Arrays.toString(variableNames)); } }
private void reloadLabelToColorMapping() { String labelToColorMappingString = JMeterUtils.getProperty("jmeterPlugin.labelToColorMapping"); labelToColorMapping = LabelToColorMapping.load(labelToColorMappingString); }
/** * Format the specified time stamp to string using JMeter properties. * * @param timeStamp * the time stamp * @return the string */ public static String formatTimeStamp(long timeStamp) { return formatTimeStamp(timeStamp, JMeterUtils.getProperty(TIMESTAMP_FORMAT_PROPERTY)); }
private void reloadLabelToColorMapping() { String labelToColorMappingString = JMeterUtils.getProperty("jmeterPlugin.labelToColorMapping"); labelToColorMapping = LabelToColorMapping.load(labelToColorMappingString); }
@Override public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String propertyName = values[0].execute(); String propertyValue = JMeterUtils.getProperty(propertyName); return Boolean.toString(propertyValue != null); }
int getSemaphores() { synchronized (semaphoreLock) { final String semaphores = JMeterUtils.getProperty(HONO_PREFIX + getAddress()); if (semaphores == null) { return 0; } else { return Integer.parseInt(semaphores); } } }
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final) parameters=""; // ensure variables are not null filename=""; script=""; try { String initFileName = JMeterUtils.getProperty(getInitFileProperty()); hasInitFile = initFileName != null; bshInterpreter = new BeanShellInterpreter(initFileName, log); } catch (ClassNotFoundException e) { log.error("Cannot find BeanShell: "+e.toString()); } }
public TCPClientImpl() { super(); setEolByte(EOL_INT); if (useEolByte) { log.info("Using eolByte={}", eolByte); } setCharset(CHARSET); String configuredCharset = JMeterUtils.getProperty("tcp.charset"); if(StringUtils.isEmpty(configuredCharset)) { log.info("Using platform default charset:{}",CHARSET); } else { log.info("Using charset:{}", configuredCharset); } }
/** * Generate the list of supported languages. * * @return array of language Strings */ // Also used by org.apache.jmeter.resources.PackageTest public static String[] getLanguages(){ List<String> lang = new ArrayList<>(20); lang.add(Locale.ENGLISH.toString()); // en lang.add(Locale.FRENCH.toString()); // fr lang.add(Locale.GERMAN.toString()); // de lang.add("no"); // $NON-NLS-1$ lang.add("pl"); // $NON-NLS-1$ lang.add("pt_BR"); // $NON-NLS-1$ lang.add("es"); // $NON-NLS-1$ lang.add("tr"); // $NON-NLS-1$ lang.add(Locale.JAPANESE.toString()); // ja lang.add(Locale.SIMPLIFIED_CHINESE.toString()); // zh_CN lang.add(Locale.TRADITIONAL_CHINESE.toString()); // zh_TW final String addedLocales = JMeterUtils.getProperty("locales.add"); if (addedLocales != null) { Arrays.stream(addedLocales.split(",")) .peek(newLang -> log.info("Adding locale {}", newLang)) .forEachOrdered(lang::add); } return lang.toArray(new String[lang.size()]); }
private void trySettingLoadFromProperty() { String loadProp = JMeterUtils.getProperty(DATA_PROPERTY); log.debug("Loading property: {}={}", DATA_PROPERTY, loadProp); if (!StringUtils.isEmpty(loadProp)) { log.info("GUI load profile will be ignored as property {} is defined", DATA_PROPERTY); PowerTableModel dataModel = new PowerTableModel(VariableThroughputTimer.columnIdentifiers, VariableThroughputTimer.columnClasses); String[] chunks = loadProp.split("\\)"); for (String chunk : chunks) { try { parseChunk(chunk, dataModel); } catch (RuntimeException e) { log.warn("Wrong load chunk {} will be ignored", chunk, e); } } log.info("Setting load profile from property {}: {}", DATA_PROPERTY, loadProp); overrideProp = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, VariableThroughputTimer.DATA_PROPERTY); } }
/** {@inheritDoc} */ @Override public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { checkParameterCount(parameters, 1, 2); values = parameters.toArray(); try { bshInterpreter = new BeanShellInterpreter(JMeterUtils.getProperty(INIT_FILE), log); } catch (ClassNotFoundException e) { throw new InvalidVariableException("BeanShell not found", e); } }
public static ColorsDispatcher getColorsDispatcher() { String customDispatcher = JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher"); String customOptions = JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options"); if (customDispatcher != null) { if (customDispatcher.equalsIgnoreCase("huerotate")) { log.debug("customDispatcher hue rotate"); return new HueRotatePalette(customOptions); } else if (customDispatcher.equalsIgnoreCase("custompalette")) { log.debug("customDispatcher custom palette"); return new CustomPalette(customOptions); } } log.debug("Original boring cycle colors"); return new CycleColors(); // original "cycle" colors dispatcher }
/** {@inheritDoc} */ @Override public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { checkParameterCount(parameters, 1, 2); values = parameters.toArray(); scriptEngine = JSR223TestElement.getInstance().getEngineByName(GROOVY_ENGINE_NAME); //$NON-NLS-N$ String fileName = JMeterUtils.getProperty(INIT_FILE); if(!StringUtils.isEmpty(fileName)) { File file = new File(fileName); if(!(file.exists() && file.canRead())) { // File maybe relative to JMeter home File oldFile = file; file = new File(JMeterUtils.getJMeterHome(), fileName); if(!(file.exists() && file.canRead())) { throw new InvalidVariableException("Cannot read file, neither from:"+oldFile.getAbsolutePath()+ ", nor from:"+file.getAbsolutePath()+", check property '"+INIT_FILE+"'"); } } try (Reader reader = Files.newBufferedReader(file.toPath(), Charset.defaultCharset())) { Bindings bindings = scriptEngine.createBindings(); bindings.put("log", log); scriptEngine.eval(reader, bindings); } catch(Exception ex) { throw new InvalidVariableException("Failed loading script:"+file.getAbsolutePath(), ex); } } }
public static ColorsDispatcher getColorsDispatcher() { String customDispatcher = JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher"); String customOptions = JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options"); if (customDispatcher != null) { if (customDispatcher.equalsIgnoreCase("huerotate")) { log.debug("customDispatcher hue rotate"); return new HueRotatePalette(customOptions); } else if (customDispatcher.equalsIgnoreCase("custompalette")) { log.debug("customDispatcher custom palette"); return new CustomPalette(customOptions); } } log.debug("Original boring cycle colors"); return new CycleColors(); // original "cycle" colors dispatcher }
private JPanel createContentTypePanel() { contentTypeInclude = new JTextField(35); contentTypeInclude.addKeyListener(this); contentTypeInclude.setName(ENABLE_RESTART); JLabel labelInclude = new JLabel(JMeterUtils.getResString("proxy_content_type_include")); // $NON-NLS-1$ labelInclude.setLabelFor(contentTypeInclude); // Default value contentTypeInclude.setText(JMeterUtils.getProperty("proxy.content_type_include")); // $NON-NLS-1$ contentTypeExclude = new JTextField(35); contentTypeExclude.addKeyListener(this); contentTypeExclude.setName(ENABLE_RESTART); JLabel labelExclude = new JLabel(JMeterUtils.getResString("proxy_content_type_exclude")); // $NON-NLS-1$ labelExclude.setLabelFor(contentTypeExclude); // Default value contentTypeExclude.setText(JMeterUtils.getProperty("proxy.content_type_exclude")); // $NON-NLS-1$ HorizontalPanel panel = new HorizontalPanel(); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("proxy_content_type_filter"))); // $NON-NLS-1$ panel.add(labelInclude); panel.add(contentTypeInclude); panel.add(labelExclude); panel.add(contentTypeExclude); return panel; }
private CollectionProperty getLoadFromExternalProperty() { String loadProp = JMeterUtils.getProperty(EXTERNAL_DATA_PROPERTY); log.debug("Profile prop: " + loadProp); if (loadProp != null && loadProp.length() > 0) { //expected format : threads_schedule="spawn(1,1s,1s,1s,1s) spawn(2,1s,3s,1s,2s)" log.info("GUI threads profile will be ignored"); PowerTableModel dataModel = new PowerTableModel(UltimateThreadGroupGui.columnIdentifiers, UltimateThreadGroupGui.columnClasses); String[] chunks = loadProp.split("\\)"); for (String chunk : chunks) { try { parseChunk(chunk, dataModel); } catch (RuntimeException e) { log.warn("Wrong chunk ignored: " + chunk, e); } } log.info("Setting threads profile from property " + EXTERNAL_DATA_PROPERTY + ": " + loadProp); return JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY); } return null; }
private void trySettingLoadFromProperty() { String loadProp = JMeterUtils.getProperty(DATA_PROPERTY); log.debug("Load prop: " + loadProp); if (loadProp != null && loadProp.length() > 0) { log.info("GUI load profile will be ignored"); PowerTableModel dataModel = new PowerTableModel(VariableThroughputTimer.columnIdentifiers, VariableThroughputTimer.columnClasses); String[] chunks = loadProp.split("\\)"); for (String chunk : chunks) { try { parseChunk(chunk, dataModel); } catch (RuntimeException e) { log.warn("Wrong load chunk ignored: " + chunk, e); } } log.info("Setting load profile from property " + DATA_PROPERTY + ": " + loadProp); overrideProp = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, VariableThroughputTimer.DATA_PROPERTY); } }
private CollectionProperty getLoadFromExternalProperty() { String loadProp = JMeterUtils.getProperty(EXTERNAL_DATA_PROPERTY); log.debug("Profile prop: " + loadProp); if (loadProp != null && loadProp.length() > 0) { //expected format : threads_schedule="spawn(1,1s,1s,1s,1s) spawn(2,1s,3s,1s,2s)" log.info("GUI threads profile will be ignored"); PowerTableModel dataModel = new PowerTableModel(UltimateThreadGroupGui.columnIdentifiers, UltimateThreadGroupGui.columnClasses); String[] chunks = loadProp.split("\\)"); for (String chunk : chunks) { try { parseChunk(chunk, dataModel); } catch (RuntimeException e) { log.warn("Wrong chunk ignored: " + chunk, e); } } log.info("Setting threads profile from property " + EXTERNAL_DATA_PROPERTY + ": " + loadProp); return JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY); } return null; }
private CollectionProperty getLoadFromExternalProperty() { String loadProp = JMeterUtils.getProperty(EXTERNAL_DATA_PROPERTY); log.debug("Profile prop: " + loadProp); if (loadProp != null && loadProp.length() > 0) { //expected format : threads_schedule="spawn(1,1s,1s,1s,1s) spawn(2,1s,3s,1s,2s)" log.info("GUI threads profile will be ignored"); PowerTableModel dataModel = new PowerTableModel(UltimateThreadGroupGui.columnIdentifiers, UltimateThreadGroupGui.columnClasses); String[] chunks = loadProp.split("\\)"); for (String chunk : chunks) { try { parseChunk(chunk, dataModel); } catch (RuntimeException e) { log.warn("Wrong chunk ignored: " + chunk, e); } } log.info("Setting threads profile from property " + EXTERNAL_DATA_PROPERTY + ": " + loadProp); return JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY); } return null; }