/** * Initializes the generator by retrieving the name for the DTD file. * * @param configuration The config, not null */ @Override protected void doInit(Properties configuration) { dtdFileName = PropertyUtils.getString(PROPKEY_DTD_FILENAME, configuration); }
/** * Initializes the generator. * * @param configuration The config, not null */ @Override protected void doInit(Properties configuration) { xsdDirectoryName = PropertyUtils.getString(PROPKEY_XSD_DIR_NAME, configuration); complexTypeSuffix = PropertyUtils.getString(PROPKEY_XSD_COMPLEX_TYPE_SUFFIX, configuration); }
protected File getRootTempDir(Properties configuration) { String systemTempDirName = System.getProperty("java.io.tmpdir"); String rootTempDirName = getString(ROOT_TEMP_DIR, systemTempDirName, configuration); File rootTempDir = new File(rootTempDirName); if (rootTempDir.isFile()) { throw new UnitilsException("Root temp dir " + rootTempDirName + " is not a directory. Please fill in a directory for property " + ROOT_TEMP_DIR); } rootTempDir.mkdirs(); return rootTempDir; } }
@Override public void init(Properties properties) { String url = PropertyUtils.getString(packageName + ".url", properties); String devkey = PropertyUtils.getString(packageName + ".devkey", properties); String username = PropertyUtils.getString(packageName + ".username", properties); String projectName = PropertyUtils.getString(packageName + ".project", properties); String testPlanId = PropertyUtils.getString(packageName + ".testPlan", properties); String buildName = PropertyUtils.getString(packageName + ".buildName", properties); Boolean overwrite = PropertyUtils.getBoolean(packageName + ".overwrite", true, properties); String xmlRpcLocation = PropertyUtils.getString(packageName + ".xmlRpcLocation", null, properties); Boolean createTestIfNeeded = PropertyUtils.getBoolean(packageName + ".createTestIfNeeded", false, properties); Boolean createPlanIfNeeded = PropertyUtils.getBoolean(packageName + ".createTestPlanIfNeeded", false, properties); Boolean assignTestToPlan = PropertyUtils.getBoolean(packageName + ".assingTestIfNeeded", false, properties); if (LOGGER.isInfoEnabled()) { LOGGER.info("Connection to testlink will be made with url " + url + " ; devkey " + devkey + " ; projectName " + projectName + " ; testPlan " + testPlanId); } TestLinkConnectorFactory factory = new TestLinkConnectorFactory(url, devkey, projectName,username, xmlRpcLocation); connector = factory.create(testPlanId, overwrite, buildName, createPlanIfNeeded, createTestIfNeeded, assignTestToPlan); }
/** * This method sets the log levels for IE. */ public static void setLogPropertiesIE() { String logLevel = PropertyUtils.getString(LOGGINGPROP_IE, "FATAL", getUnitilsProperties()); System.setProperty("webdriver.ie.driver.loglevel", logLevel); File fileFromProperty = getFileFromProperty(WebDriverModule.LOGGING_FILE_PROP); if (fileFromProperty != null) { System.setProperty("webdriver.ie.driver.logfile", fileFromProperty.getAbsolutePath()); } }
/** * Creates a {@link org.openqa.selenium.logging.LoggingPreferences} object with the values of the unitils.properties. * * @return {@link org.openqa.selenium.logging.LoggingPreferences} */ protected static LoggingPreferences createLoggingPreferences() { LoggingPreferences logPrefs = new LoggingPreferences(); Properties unitilsProperties = getUnitilsProperties(); logPrefs.enable(LogType.PERFORMANCE, Level.parse(PropertyUtils.getString(WebDriverModule.LOGGINGPROP_PERFORMANCE, "ALL", unitilsProperties))); logPrefs.enable(LogType.BROWSER, Level.parse(PropertyUtils.getString(WebDriverModule.LOGGINGPROP_BROWSER, "ALL", unitilsProperties))); logPrefs.enable(LogType.CLIENT, Level.parse(PropertyUtils.getString(WebDriverModule.LOGGINGPROP_CLIENT, "ALL", unitilsProperties))); logPrefs.enable(LogType.DRIVER, Level.parse(PropertyUtils.getString(WebDriverModule.LOGGINGPROP_DRIVER, "ALL", unitilsProperties))); logPrefs.enable(LogType.PROFILER, Level.parse(PropertyUtils.getString(WebDriverModule.LOGGINGPROP_PROFILER, "ALL", unitilsProperties))); logPrefs.enable(LogType.SERVER, Level.parse(PropertyUtils.getString(WebDriverModule.LOGGINGPROP_SERVER, "ALL", unitilsProperties))); return logPrefs; }
/** * Check if the key exists in the unitils.properties and check if the value for that key is a valid location. * * @param key : the key to find the correct driver location in the unitils.properties. * @param driver : the type of driver. * @param systemKey : the system key where the module should set the new location of the driver. * @return boolean */ public boolean checkIfDriverPropertyExistsInUnitilsProperties(String key, String driver, String systemKey) { String unitilsDriver = PropertyUtils.getString(key, "", configuration); if (configuration.containsKey(key) && !StringUtils.isEmpty(unitilsDriver)) { File driverFile = new File(unitilsDriver); if (driverFile.exists()) { StringBuilder builder = new StringBuilder().append("The WebdriverModule uses the ").append(driver).append(" from the unitils.properties. location: ").append(driverFile.toString()); LOGGER.info(builder.toString()); System.setProperty(systemKey, driverFile.getAbsolutePath()); return true; } else { StringBuilder builder = new StringBuilder().append("The location of the ").append(driver).append(" defined in the unitils.properties does not exists. location: ").append(driverFile.getAbsolutePath()); LOGGER.error(builder.toString()); } } return false; }
/** * Checks if the value of the property is an already existing file, otherwise it tries to create a new file. * * @param property : the name of the property in the untils.property. * @return {@link File} */ protected static File getFileFromProperty(String property) { String str = PropertyUtils.getString(property, "", getUnitilsProperties()); if (StringUtils.isEmpty(str)) { return null; } File file = new File(str); if (!file.exists()) { LOGGER.debug("The file for property " + property + " is created at location: " + file.getAbsolutePath()); try { file.createNewFile(); } catch (IOException e) { LOGGER.error("Oops, something went wrong with creating " + file.getAbsolutePath() + "."); return null; } } return file; }
/** * This method creates a new {@link ChromeDriver}. * * @return {@link WebDriver} */ protected static WebDriver createChromeDriver() { if (!StringUtils.isEmpty(PropertyUtils.getString(WebDriverModule.LOGGING_FILE_PROP, "", getUnitilsProperties()))) { System.setProperty("webdriver.chrome.logfile", PropertyUtils.getString(WebDriverModule.LOGGING_FILE_PROP, "", getUnitilsProperties())); } return new ChromeDriver(createCapabilitiesChrome()); }
protected static CapabilitiesChoice getChosenCapabilities() { String chosenCapability = PropertyUtils.getString(WebDriverModule.REMOTE_CAPABILITIES, "", getUnitilsProperties()); if (StringUtils.isBlank(chosenCapability)) { return CapabilitiesChoice.FIREFOX; } return CapabilitiesChoice.valueOf(chosenCapability); }
/** * Initializes the resolver with the given configuration. * * @param configuration The configuration, not null */ public void init(Properties configuration) { boolean prefixWithPackageName = getBoolean(PROPKEY_PREFIX_WITH_PACKAGE_NAME, configuration); String pathPrefix = getString(PROPKEY_DATA_SET_PATH_PREFIX, null, configuration); this.fileResolver = new FileResolver(prefixWithPackageName, pathPrefix); }
/** * @param configuration The Unitils configuration, not null */ public void init(Properties configuration) { super.init(configuration); String configurationImplClassName = getString(PROPKEY_CONFIGURATION_CLASS_NAME, configuration); configurationObjectClass = ReflectionUtils.getClassWithName(configurationImplClassName); }
/** * @param configuration The Unitils configuration, not null */ public void init(Properties configuration) { super.init(configuration); String persistenceProviderImplClassName = getString(PROPKEY_PERSISTENCE_PROVIDER, configuration); jpaProviderSupport = ConfigUtils.getInstanceOf(JpaProviderSupport.class, configuration, persistenceProviderImplClassName); }
/** * Initializes the name of the version table and its columns using the given configuration. * * @param configuration the configuration, not null */ @Override protected void doInit(Properties configuration) { this.executedScriptsTableName = defaultDbSupport.toCorrectCaseIdentifier( PropertyUtils.getString(PROPERTY_EXECUTED_SCRIPTS_TABLE_NAME, configuration)); this.fileNameColumnName = defaultDbSupport.toCorrectCaseIdentifier(PropertyUtils.getString(PROPERTY_FILE_NAME_COLUMN_NAME, configuration)); this.fileNameColumnSize = PropertyUtils.getInt(PROPERTY_FILE_NAME_COLUMN_SIZE, configuration); this.versionColumnName = defaultDbSupport.toCorrectCaseIdentifier(PropertyUtils.getString(PROPERTY_SCRIPT_VERSION_COLUMN_NAME, configuration)); this.versionColumnSize = PropertyUtils.getInt(PROPERTY_SCRIPT_VERSION_COLUMN_SIZE, configuration); this.fileLastModifiedAtColumnName = defaultDbSupport.toCorrectCaseIdentifier(PropertyUtils.getString(PROPERTY_FILE_LAST_MODIFIED_AT_COLUMN_NAME, configuration)); this.checksumColumnName = defaultDbSupport.toCorrectCaseIdentifier(PropertyUtils.getString(PROPERTY_CHECKSUM_COLUMN_NAME, configuration)); this.checksumColumnSize = PropertyUtils.getInt(PROPERTY_CHECKSUM_COLUMN_SIZE, configuration); this.executedAtColumnName = defaultDbSupport.toCorrectCaseIdentifier(PropertyUtils.getString(PROPERTY_EXECUTED_AT_COLUMN_NAME, configuration)); this.executedAtColumnSize = PropertyUtils.getInt(PROPERTY_EXECUTED_AT_COLUMN_SIZE, configuration); this.succeededColumnName = defaultDbSupport.toCorrectCaseIdentifier(PropertyUtils.getString(PROPERTY_SUCCEEDED_COLUMN_NAME, configuration)); this.autoCreateExecutedScriptsTable = PropertyUtils.getBoolean(PROPERTY_AUTO_CREATE_EXECUTED_SCRIPTS_TABLE, configuration); this.timestampFormat = new SimpleDateFormat(PropertyUtils.getString(PROPERTY_TIMESTAMP_FORMAT, configuration)); }
@Override public void init(Properties configuration) { dataLocator = new ClassPathDataLocator(); browserChoice = resolveBrowserChoice(configuration); baseUrl = resolveBaseUrl(configuration); proxyUrl = resolveProxyHost(configuration); LOGGER.debug("Driver Module loaded"); downloadPath = PropertyUtils.getString(DOWNLOADPATH, "", configuration); fileType = PropertyUtils.getString(FILETYPE, LIST_AUTOMATICALLY_DOWNLOAD, configuration); this.configuration = configuration; String bit = System.getProperty("sun.arch.data.model"); ClassLoader classLoader = getClass().getClassLoader(); checkFirefoxDriver(); checkChromeDriver(bit, classLoader); checkIEDriver(bit, classLoader); }
public FileResolvingStrategy createFileResolvingStrategy(Properties configuration) { boolean prefixWithPackageName = getBoolean(PREFIX_WITH_PACKAGE_NAME_PROPERTY, configuration); String pathPrefix = getString(PATH_PREFIX_PROPERTY, null, configuration); FileResolver fileResolver = new FileResolver(prefixWithPackageName, pathPrefix); return new DefaultFileResolvingStrategy(fileResolver); } }
public FileContentReader createFileContentReader(Properties configuration) { ReadingStrategy readingStrategy = createReadingStrategy(configuration); List<ConversionStrategy<?>> conversionStrategies = createConversionStrategies(configuration); String defaultEncoding = getString(DEFAULT_FILE_ENCODING, configuration); return new DefaultFileContentReader(readingStrategy, conversionStrategies, defaultEncoding); }
/** * Creates the DesiredCapabilities for the Chrome Webdriver. * @return DesiredCapabilities */ protected static DesiredCapabilities createCapabilitiesChrome() { DesiredCapabilities cap = DesiredCapabilities.chrome(); cap.setCapability(CapabilityType.LOGGING_PREFS, createLoggingPreferences()); String filePathBinary = PropertyUtils.getString(WebDriverModule.CHROME_BINARY_KEY, "", getUnitilsProperties()); // This part checks if there is another path for the chrome binary than the default path. // This makes it possible to work with liberkey chrome etc. if (!StringUtils.isEmpty(filePathBinary)) { ChromeOptions options = new ChromeOptions(); File tempFileLocation = new File(filePathBinary); if (tempFileLocation.exists()) { options.setBinary(tempFileLocation.getAbsolutePath()); cap.setCapability(ChromeOptions.CAPABILITY, options); } } return cap; }
protected static WebDriver createRemoteWebdriver(String proxyUrl, String fileType, String downloadPath) { DesiredCapabilities capabilities = null; CapabilitiesChoice choice = getChosenCapabilities(); switch (choice) { case CHROME: capabilities = createCapabilitiesChrome(); break; case FIREFOX: capabilities = createCapabilitesFirefox(proxyUrl, createFirefoxProfile(fileType, downloadPath)); break; case IE: capabilities = createCapabilitiesIE(proxyUrl); break; } URL remoteUrl; try { String urlProp = PropertyUtils.getString(WebDriverModule.REMOTE_URL_KEY, "", getUnitilsProperties()); if (StringUtils.isBlank(urlProp)) { return new RemoteWebDriver(capabilities); } remoteUrl = new URL(urlProp); } catch (MalformedURLException e) { throw new UnitilsException("The following URL is not valid.", e); } return new RemoteWebDriver(remoteUrl, capabilities); }