/** * Returns UserAgent based on combined string representation * * @param name * @return */ public static UserAgent valueOf(String name) { if (name == null) throw new NullPointerException("Name is null"); String[] elements = name.split("-"); if (elements.length == 2) { OperatingSystem operatingSystem = OperatingSystem.valueOf(elements[0]); Browser browser = Browser.valueOf(elements[1]); return new UserAgent(operatingSystem, browser); } throw new IllegalArgumentException("Invalid string for userAgent " + name); }
private static void initializeTestParameters(String[] args) { System.setProperty("ReportPath", args[0]); Properties properties = Settings.getInstance(); testParameters = new SeleniumTestParameters(args[1], args[2]); if (args.length >= 4 && !args[3].equalsIgnoreCase("SKIP")) { testParameters.setCurrentTestDescription(args[3]); } if (args.length >= 5 && !args[4].equalsIgnoreCase("SKIP")) { testParameters.setIterationMode(IterationOptions.valueOf(args[4])); } else { testParameters.setIterationMode(IterationOptions.RunAllIterations); } if (args.length >= 6 && !args[5].equalsIgnoreCase("SKIP")) { testParameters.setStartIteration(Integer.parseInt(args[5])); } if (args.length >= 7 && !args[6].equalsIgnoreCase("SKIP")) { testParameters.setEndIteration(Integer.parseInt(args[6])); } if (args.length >= 8 && !args[7].equalsIgnoreCase("SKIP")) { testParameters.setBrowser(Browser.valueOf(args[7])); } else { testParameters.setBrowser(Browser.valueOf(properties.getProperty("DefaultBrowser"))); } if (args.length >= 9 && !args[8].equalsIgnoreCase("SKIP")) { testParameters.setBrowserVersion(args[8]); } if (args.length >= 10 && !args[9].equalsIgnoreCase("SKIP")) { testParameters.setPlatform(Platform.valueOf(args[9])); } else { testParameters.setPlatform(Platform.valueOf(properties.getProperty("DefaultPlatform"))); } }
public synchronized void initialize() { Browser browser = targetTestBrowser; if (browser == null) { browser = Browser.valueOf(Browser.class, System.getProperty("browser", "firefox").toUpperCase()); } WebDriver webDriver = createDriver(browser); delegate.set(webDriver); drivers.add(webDriver); try { webDriver .manage() .timeouts() .pageLoadTimeout(60, TimeUnit.SECONDS) .setScriptTimeout(30, TimeUnit.SECONDS) .implicitlyWait(20, TimeUnit.SECONDS); webDriver.manage().window().maximize(); } catch (Exception e) { LOGGER.error("ODWebDriverProvider initialize()", e); // $NON-NLS-1$ throw new RuntimeException(e); } }
@Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { parser.parse(value); if (!parser.hasParseError()) { String browser = parser.getBrowser(); // if (!browser.isEmpty()) { Browser b; b = Browser.valueOf(browser); context.getCounter(b).increment(1); } if (parser.isInvalidBytesValue()) { context.getCounter(LogRecord.INAVLID_BYTES_VALUE).increment(1); } // SumCountWritable scw = new SumCountWritable(parser.getBytesDouble(), 1); context.write(new Text(parser.getIP()), scw); } else { System.err.println("Ignoring possibly corrupt input: " + value); context.getCounter(LogRecord.BAD).increment(1); } }
/** * Returns UserAgent based on specified unique id * * @param id * @return */ public static UserAgent valueOf(int id) { OperatingSystem operatingSystem = OperatingSystem.valueOf((short) (id >> 16)); Browser browser = Browser.valueOf((short) (id & 0x0FFFF)); return new UserAgent(operatingSystem, browser); }