public Path getCurrentScriptDataFolder() { return getCurrentScriptFolder().resolve("data"); }
private String getCurrentScriptName(){ return reader.getCurrentScriptName(); }
public ImmutableMappingMethod getCustomActionMappingMethod(final String methodName) { return reader.getCustomActionMappingMethod(methodName); } }
@Override public synchronized Project read() { try { final ImmutableProject.Builder projectBuilder = Project.builder().name(this.projectName); final List<File> projectFolders = getProjectFolders(); final int totalScriptNumber = projectFolders.size(); eventListener.startReadingScripts(totalScriptNumber); if (projectFolders.isEmpty()) { throw new IllegalStateException("No Load Runner project found."); } for (final File projectFolder : projectFolders) { readScript(projectBuilder, projectFolder); } projectBuilder.servers(currentProjectServers.values()); return projectBuilder.build(); } finally { eventListener.endReadingScripts(); } }
final String uniqueName = findUniqueName(container.getName(), currentSharedContainerNames); currentSharedContainerNames.add(uniqueName); container.setShared(true); if(hasOneNotSharedChild(init)){ final Container childContainer = (Container) init.getChilds().get(0); userPathBuilder.initContainer(ImmutableContainerForMulti.builder().name(NAME_INIT).tag(TAG_INIT).addAllChilds(childContainer.getChilds()).build()); userPathBuilder.initContainer(init); if(hasOneNotSharedChild(actions)){ final Container childContainer = (Container) actions.getChilds().get(0); userPathBuilder.actionsContainer(ImmutableContainerForMulti.builder().name(NAME_ACTIONS).tag(TAG_ACTIONS).addAllChilds(childContainer.getChilds()).build()); userPathBuilder.actionsContainer(actions); if(hasOneNotSharedChild(end)){ final Container childContainer = (Container) end.getChilds().get(0); userPathBuilder.endContainer(ImmutableContainerForMulti.builder().name(NAME_END).tag(TAG_END).addAllChilds(childContainer.getChilds()).build());
protected static Optional<Properties> getSnapshotProperties(final LoadRunnerVUVisitor visitor, final MethodCall method) { final String snapshotFileName = getParameterValueWithName(visitor.getLeftBrace(), visitor.getRightBrace(), method, "Snapshot").orElse(""); if (isNullOrEmpty(snapshotFileName)) { return Optional.empty(); } try{ final Properties properties = new Properties(); properties.load(newInputStream(visitor.getReader().getCurrentScriptDataFolder().resolve(snapshotFileName))); return Optional.of(properties); } catch (final IOException e) { LOGGER.warn("Cannot find snapshot properties files: ", e); } return Optional.empty(); }
public LoadRunnerVUVisitor(final LoadRunnerReader reader, final String leftBrace, final String rightBrace, final MutableContainer mutableContainer) { this.currentContainers.add(mutableContainer); this.currentExtractors = new ArrayList<>(); this.currentValidators = new ArrayList<>(); this.currentHeaders = new ArrayList<>(); this.globalHeaders = new ArrayList<>(); this.leftBrace = leftBrace; this.rightBrace = rightBrace; this.reader = reader; this.eventListener = reader.getEventListener(); }
/** * Build or get the server from the list of server already build from the passed url * @param url extracting the server from this url * @return the corresponding server */ public Server getServer(final URL url) { return getOrAddServerIfNotExist( MethodUtils.normalizeName(url.getHost()), url.getHost(), String.valueOf(url.getPort() != -1 ? url.getPort() : url.getDefaultPort()), Optional.of(url.getProtocol())); }
private void parseTableParameter(final Wini.Section paramSection, final String sectionIdentifier, final String paramName) { if (paramSection.get("SelectNextRow").startsWith("\"Same line as ")) { variablesNotDone.add(sectionIdentifier); return; } FileVariable variable = ParametersReaderUtils.parseTableParameter(leftBrace, rightBrace, paramSection, folder.getAbsolutePath()); if (variable != null) { if ("Local".equals(MethodUtils.normalizeString(leftBrace, rightBrace, paramSection.get(ParametersReaderUtils.TABLE_LOCATION)))) { reader.addDataFilesToCopy(new File(variable.getFileName().orElseThrow(IllegalStateException::new))); } nLVarValueFromLRVarName.put(variable.getName(), variable.getName() + "." + variable.getColumnsNames().get(0)); variables.put(paramName, variable); } }
/** * Check if a identical server already exist, if exist the function return it * If not but there exist a server with the same "uid", we create a new server with a different uid. * @return the unique server to use */ public Server getOrAddServerIfNotExist(final String name, final String host, final String port, final Optional<String> scheme) { // Search if exact same server exists for (final Server server : currentProjectServers.values()) { if (server.getHost().equals(host) && server.getPort().equals(port) && server.getScheme().equals(scheme) && server.getName().equals(name)) { return server; } } final Server server = ImmutableServer.builder().name( currentProjectServers.get(name) == null ? name : findUniqueName(name, currentProjectServers.keySet())).host(host).port(port).scheme( scheme).build(); currentProjectServers.put(server.getName(), server); return server; }
final LoadRunnerMethod lrMethod = reader.getLrSupportedMethod(method.getName()); if(lrMethod == null){ readUnsupportedFunction(method.getName(), ctx);
protected static Optional<RecordedFiles> getRecordedFilesFromSnapshotProperties(final LoadRunnerVUVisitor visitor, final Optional<Properties> snapshotProperties) { if(!snapshotProperties.isPresent()){ return Optional.empty(); } final Path projectDataPath = visitor.getReader().getCurrentScriptDataFolder(); final Optional<String> requestHeaderFile = getRecordedFileName(snapshotProperties.get(), "RequestHeaderFile", projectDataPath); final Optional<String> requestBodyFile = getRecordedFileName(snapshotProperties.get(), "RequestBodyFile", projectDataPath); final Optional<String> responseHeaderFile = getRecordedFileName(snapshotProperties.get(),"ResponseHeaderFile", projectDataPath); final Optional<String> responseBodyFile = getRecordedFileName(snapshotProperties.get(),"FileName1", projectDataPath); return Optional.of(ImmutableRecordedFiles.builder() .recordedRequestHeaderFile(requestHeaderFile) .recordedRequestBodyFile(requestBodyFile) .recordedResponseHeaderFile(responseHeaderFile) .recordedResponseBodyFile(responseBodyFile) .build()); }
public void readUnsupportedParameter(final String parameterType, final String parameterName) { eventListener.readUnsupportedParameter(reader.getCurrentScriptName(), parameterType, parameterName); } }
public void readSupportedParameter(final String parameterType, final String parameterName) { eventListener.readSupportedParameter(reader.getCurrentScriptName(), parameterType, parameterName); }
public void readSupportedParameterWithWarn(final String parameterType, final String parameterName, final String warning) { eventListener.readSupportedParameterWithWarn(reader.getCurrentScriptName(), parameterType, parameterName, warning); }