@Override public void executeAScript(String configName, String scriptPath) { //Resolve the script path relative to the feature file File script = feature.getFeatureDir().toPath().resolve(scriptPath).toFile(); String scriptContents = FileUtils.readScriptFile(log, configName, scriptPath, script); Tuple2<Connection, SqlConfig> connectionDetails = getConnectionDetails(configName); executeJdbcStatements(connectionDetails.getOne(), configName, scriptContents, "script at " + scriptPath); }
@Override public Object executeScriptFile(String configName, String scriptPath) { //Resolve the script path relative to the feature file File script = feature.getFeatureDir().toPath().resolve(scriptPath).toFile(); String scriptContents = FileUtils.readScriptFile(log, configName, scriptPath, script); log.trace(format("About to execute script on web driver %s: [%n%s%n]", configName, scriptContents)); Object result = ((JavascriptExecutor)getWebDriver(configName)).executeScript(scriptContents); log.debug("Finished executing script from " + scriptPath); return result; }
private boolean replaceWithChorusProperty(String fullPropertyName, String variable, StringBuilder sb, String property) { boolean replaced = false; int start = sb.indexOf(variable); if ( CHORUS_FEATURE_DIR_VARIABLE.equals(property)) { sb.replace(start, start + variable.length(), featureToken.getFeatureDir().getPath()); log.debug("Replaced variable " + variable + " with value " + featureToken.getFeatureDir().getPath() + " for property " + fullPropertyName); replaced = true; } else if ( CHORUS_FEATURE_FILE_VARIABLE.equals(property)) { sb.replace(start, start + variable.length(), featureToken.getFeatureFile().getPath()); log.debug("Replaced variable " + variable + " with value " + featureToken.getFeatureFile().getPath() + " for property " + fullPropertyName); replaced = true; } else if ( CHORUS_FEATURE_CONFIGURATION_VARIABLE.equals(property)) { sb.replace(start, start + variable.length(), featureToken.getConfigurationName()); log.debug("Replaced variable " + variable + " with value " + featureToken.getConfigurationName() + " for property " + fullPropertyName); replaced = true; } else if ( CHORUS_FEATURE_NAME_VARIABLE.equals(property)) { sb.replace(start, start + variable.length(), featureToken.getName()); log.debug("Replaced variable " + variable + " with value " + featureToken.getConfigurationName() + " for property " + fullPropertyName); replaced = true; } return replaced; }
private void loadFeatureProperties(FeatureToken feature) { PropertyOperations featureProps = PropertyOperations.emptyProperties(); featureProps = mergeLoadersForDirectory(featureProps, feature.getFeatureDir(), feature); featureProps = mergeLoadersForDirectory(featureProps, new File(feature.getFeatureDir(), "conf"), feature); featureProps = addPropertiesFromDatabase(properties(featureProps.loadProperties())); //load the feature props once then merge any db props this.featureProperties = featureProps.loadProperties(); }
private List<String> buildCommandLine(NamedProcess namedProcess, FeatureToken featureToken, String logFileBaseName) { File featureDir = featureToken.getFeatureDir(); AbstractCommandLineBuilder b = namedProcess.isJavaProcess() ? new JavaProcessCommandLineBuilder(featureDir, namedProcess, logFileBaseName) : new NativeProcessCommandLineBuilder(namedProcess, featureDir); List<String> commandTokens = b.buildCommandLine(); logCommandLine(namedProcess, commandTokens); return commandTokens; }
public ProcessOutputConfiguration(FeatureToken featureToken, NamedProcess processesConfig) { this.featureDir = featureToken.getFeatureDir(); this.logFileBaseName = calculateLogFileBaseName(featureToken, featureToken.getFeatureFile(), processesConfig.getProcessName()); this.processesConfig = processesConfig; this.isAppendToLogs = processesConfig.isAppendToLogs(); this.featureToken = featureToken; logDirectory = calculateLogDirectory(); stdOutFileAndMode = new LogFileAndMode( new File(logDirectory, String.format("%s-out.log", logFileBaseName)), processesConfig.getStdOutMode(), "stdOut", false ); stdErrFileAndMode = new LogFileAndMode( new File(logDirectory, String.format("%s-err.log", logFileBaseName)), processesConfig.getStdErrMode(), "stdErr", true ); //let's fail the feature if we cannot create the log directory //alternative would be to log inline but this might swamp interpreter output if ( OutputMode.isWriteToLogFile(stdOutFileAndMode.getMode()) || OutputMode.isWriteToLogFile(stdErrFileAndMode.getMode()) ) { getOrCreateLogDirectory(logDirectory); ChorusAssert.assertTrue("Cannot write to the logs directory at " + logDirectory, logDirectory.canWrite()); } }