/** * Generate a list of paths to search. * The output array always starts with * JMETER_HOME/lib/ext * and is followed by any paths obtained from the "search_paths" JMeter property. * * @return array of path strings */ public static String[] getSearchPaths() { String p = JMeterUtils.getPropDefault("search_paths", null); // $NON-NLS-1$ String[] result = new String[1]; if (p != null) { String[] paths = p.split(";"); // $NON-NLS-1$ result = new String[paths.length + 1]; System.arraycopy(paths, 0, result, 1, paths.length); } result[0] = getJMeterHome() + "/lib/ext"; // $NON-NLS-1$ return result; }
for (String templateFile : templateFiles) { if(!StringUtils.isEmpty(templateFile)) { final File f = new File(JMeterUtils.getJMeterHome(), templateFile); try { if(f.exists() && f.canRead()) {
fileToUse=JMeterUtils.getJMeterHome() +File.separator+"bin" // $NON-NLS-1$ +File.separator+initFile;
public static void prepareJMeterEnv(String homeDir) { if (JMeterUtils.getJMeterHome() != null) { log.warn("JMeter env exists. No one should see this normally."); return; } log.debug("Orig jmeter home dir: " + homeDir); File dir = new File(homeDir); while (dir.exists() && dir.getName().equals("ext") && dir.getParentFile().getName().equals("lib")) { dir = dir.getParentFile(); } if (!dir.exists()) { throw new IllegalArgumentException("CMDRunner.jar must be placed in <jmeter>/lib/ext directory"); } homeDir = dir.getParent(); if (!isJMeterHome(homeDir)) { homeDir = getJMeterHomeFromCP(System.getProperty("java.class.path")); } log.debug("Final jmeter home dir: " + homeDir); JMeterUtils.setJMeterHome(homeDir); initializeProperties(); }
/** {@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 void prepareJMeterEnv(String homeDir) { if (JMeterUtils.getJMeterHome() != null) { log.warn("JMeter env exists. No one should see this normally."); return; } log.debug("Orig jmeter home dir: " + homeDir); File dir = new File(homeDir); while (dir.exists() && dir.getName().equals("ext") && dir.getParentFile().getName().equals("lib")) { dir = dir.getParentFile(); } if (!dir.exists()) { throw new IllegalArgumentException("CMDRunner.jar must be placed in <jmeter>/lib/ext directory"); } homeDir = dir.getParent(); if (!isJMeterHome(homeDir)) { homeDir = getJMeterHomeFromCP(System.getProperty("java.class.path")); } log.debug("Final jmeter home dir: " + homeDir); JMeterUtils.setJMeterHome(homeDir); initializeProperties(); }
JMeterUtils.loadJMeterProperties(JMeterUtils.getJMeterHome() + File.separator + "bin" + File.separator
JMeterUtils.loadJMeterProperties(JMeterUtils.getJMeterHome() + File.separator + "bin" + File.separator
log.info("Default Locale={}", Locale.getDefault().getDisplayName()); log.info("JMeter Locale={}", JMeterUtils.getLocale().getDisplayName()); log.info("JMeterHome={}", JMeterUtils.getJMeterHome()); log.info("user.dir ={}", System.getProperty("user.dir"));//$NON-NLS-1$ //$NON-NLS-2$ log.info("PWD ={}", new File(".").getCanonicalPath());//$NON-NLS-1$
final File fileToCopy = parent != null ? new File(parent, template.getFileName()) : new File(JMeterUtils.getJMeterHome(), template.getFileName()); Load.loadProjectFile(actionEvent, fileToCopy, !isTestPlan, false); this.setVisible(false);
public static void createJmeterEnv() { JMeterUtils.setJMeterHome(getTempDir()); File dst = new File(JMeterUtils.getJMeterHome() + "/ss.props"); InputStream src = DirectoryAnchor.class.getResourceAsStream("/kg/apc/jmeter/bin/saveservice.properties"); try {
public static void createJmeterEnv() { JMeterUtils.setJMeterHome(getTempDir()); File dst = new File(JMeterUtils.getJMeterHome() + "/ss.props"); InputStream src = DirectoryAnchor.class.getResourceAsStream("/kg/apc/jmeter/bin/saveservice.properties"); try {