List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:Main.java
/** * Get New-line character remove/*from w w w.ja v a 2s.c o m*/ * * @param message changed message * @return Removed New-line character */ public static String removeNewLineCharacter(String message) { return message.replace(System.getProperty("line.separator"), ""); }
From source file:com.hpe.nv.samples.advanced.AdvRealtimeUpdate.java
public static void main(String[] args) throws Exception { try {//from w w w . ja v a 2s . c o m // program arguments Options options = new Options(); options.addOption("i", "server-ip", true, "[mandatory] NV Test Manager IP"); options.addOption("o", "server-port", true, "[mandatory] NV Test Manager port"); options.addOption("u", "username", true, "[mandatory] NV username"); options.addOption("w", "password", true, "[mandatory] NV password"); options.addOption("e", "ssl", true, "[optional] Pass true to use SSL. Default: false"); options.addOption("y", "proxy", true, "[optional] Proxy server host:port"); options.addOption("t", "site-url", true, "[optional] Site under test URL. Default: HPE Network Virtualization site URL. If you change this value, make sure to change the --xpath argument too"); options.addOption("x", "xpath", true, "[optional] Parameter for ExpectedConditions.visibilityOfElementLocated(By.xpath(...)) method. Use an xpath expression of some element in the site. Default: //div[@id='content']"); options.addOption("a", "active-adapter-ip", true, "[optional] Active adapter IP. Default: --server-ip argument"); options.addOption("n", "ntx-file-path", true, "[optional] File path (of an .ntx or .ntxx file) to update the test in ntx mode"); options.addOption("z", "zip-result-file-path", true, "[optional] File path to store the analysis results as a .zip file"); options.addOption("k", "analysis-ports", true, "[optional] A comma-separated list of ports for test analysis"); options.addOption("b", "browser", true, "[optional] The browser for which the Selenium WebDriver is built. Possible values: Chrome and Firefox. Default: Firefox"); options.addOption("d", "debug", true, "[optional] Pass true to view console debug messages during execution. Default: false"); options.addOption("h", "help", false, "[optional] Generates and prints help information"); // parse and validate the command line arguments CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); if (line.hasOption("help")) { // print help if help argument is passed HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("AdvRealtimeUpdate.java", options); return; } if (line.hasOption("server-ip")) { serverIp = line.getOptionValue("server-ip"); if (serverIp.equals("0.0.0.0")) { throw new Exception( "Please replace the server IP argument value (0.0.0.0) with your NV Test Manager IP"); } } else { throw new Exception("Missing argument -i/--server-ip <serverIp>"); } if (line.hasOption("server-port")) { serverPort = Integer.parseInt(line.getOptionValue("server-port")); } else { throw new Exception("Missing argument -o/--server-port <serverPort>"); } if (line.hasOption("username")) { username = line.getOptionValue("username"); } else { throw new Exception("Missing argument -u/--username <username>"); } if (line.hasOption("password")) { password = line.getOptionValue("password"); } else { throw new Exception("Missing argument -w/--password <password>"); } if (line.hasOption("ssl")) { ssl = Boolean.parseBoolean(line.getOptionValue("ssl")); } if (line.hasOption("zip-result-file-path")) { zipResultFilePath = line.getOptionValue("zip-result-file-path"); } if (line.hasOption("site-url")) { siteUrl = line.getOptionValue("site-url"); } else { siteUrl = "http://www8.hp.com/us/en/software-solutions/network-virtualization/index.html"; } if (line.hasOption("xpath")) { xpath = line.getOptionValue("xpath"); } else { xpath = "//div[@id='content']"; } if (line.hasOption("proxy")) { proxySetting = line.getOptionValue("proxy"); } if (line.hasOption("active-adapter-ip")) { activeAdapterIp = line.getOptionValue("active-adapter-ip"); } else { activeAdapterIp = serverIp; } if (line.hasOption("analysis-ports")) { String analysisPortsStr = line.getOptionValue("analysis-ports"); analysisPorts = analysisPortsStr.split(","); } else { analysisPorts = new String[] { "80", "8080" }; } if (line.hasOption("ntx-file-path")) { ntxFilePath = line.getOptionValue("ntx-file-path"); } if (line.hasOption("browser")) { browser = line.getOptionValue("browser"); } else { browser = "Firefox"; } if (line.hasOption("debug")) { debug = Boolean.parseBoolean(line.getOptionValue("debug")); } String newLine = System.getProperty("line.separator"); String testDescription = "*** This sample demonstrates the real-time update API. You can use this API to update the test during runtime. ***" + newLine + "*** For example, you can update the network scenario to run several \"mini tests\" in a single test. ***" + newLine + "*** ***" + newLine + "*** This sample starts by running an NV test with a single transaction that uses the \"3G Busy\" network scenario. Then the ***" + newLine + "*** sample updates the network scenario to \"3G Good\" and reruns the transaction. You can update the test in real time ***" + newLine + "*** using either the NTX or Custom real-time update modes. ***" + newLine + "*** ***" + newLine + "*** You can view the actual steps of this sample in the AdvRealtimeUpdate.java file. ***" + newLine; // print the sample's description System.out.println(testDescription); // start console spinner if (!debug) { spinner = new Thread(new Spinner()); spinner.start(); } // sample execution steps /***** Part 1 - Navigate to the site with the NV "3G Busy" network scenario *****/ printPartDescription( "\b------ Part 1 - Navigate to the site with the NV \"3G Busy\" network scenario"); initTestManager(); setActiveAdapter(); startBusyTest(); testRunning = true; connectToTransactionManager(); startTransaction(); transactionInProgress = true; buildSeleniumWebDriver(); seleniumNavigateToPage(); stopTransaction(); transactionInProgress = false; driverCloseAndQuit(); printPartSeparator(); /***** Part 2 - Update the NV test in real-time---update the network scenario to "3G Good" *****/ printPartDescription( "------ Part 2 - Update the NV test in real time to the \"3G Good\" network scenario"); realTimeUpdateTest(); printPartSeparator(); /***** Part 3 - Navigate to the site with the NV \"3G Good\" network scenario *****/ printPartDescription( "------ Part 3 - Navigate to the site with the NV \"3G Good\" network scenario"); startTransactionAfterRTU(); transactionInProgress = true; buildSeleniumWebDriver(); seleniumNavigateToPage(); stopTransaction(); transactionInProgress = false; driverCloseAndQuit(); printPartSeparator(); /***** Part 4 - Stop the NV test, analyze it and print the results to the console *****/ printPartDescription( "------ Part 4 - Stop the NV test, analyze it and print the results to the console"); stopTest(); testRunning = false; analyzeTest(); printPartSeparator(); doneCallback(); } catch (Exception e) { try { handleError(e.getMessage()); } catch (Exception e2) { System.out.println("Error occurred: " + e2.getMessage()); } } }
From source file:Main.java
/** * Indetifca em qual arquitetura a JRE esta executando * @return/* ww w .j ava2s.c om*/ */ public static int getArchitecture() { String architecture = System.getProperty("sun.arch.data.model"); if (architecture.equalsIgnoreCase("64")) { return ARC_JRE_64; } else { return ARC_JRE_32; } }
From source file:Main.java
public static void setUseSaxonTransformFactory() { if (System.getProperty(XSLT_TRANSFORMER_FACTORY) == null) { System.setProperty(XSLT_TRANSFORMER_FACTORY, SAXON_TRANSFORMER_FACTORY); } else {//from w ww .j a v a 2s .c o m throw new IllegalStateException(XSLT_TRANSFORMER_FACTORY + " is already set"); } }
From source file:Main.java
public static File getSaveMapDir() { if (mapsDir != null) { return mapsDir; }//from w w w . ja v a2s .co m File userHome = new File(System.getProperty("user.home")); File userMaps = new File(userHome, "maps"); if (!userMaps.isDirectory() && !userMaps.mkdirs()) { // if it does not exist and i cant make it throw new RuntimeException("can not create dir " + userMaps); } mapsDir = userMaps; return userMaps; }
From source file:Main.java
public static String readFile(String pathname) { File file = new File(pathname); StringBuilder fileContents = new StringBuilder((int) file.length()); String lineSeparator = System.getProperty("line.separator"); try {/*w w w. j av a2 s . co m*/ try (Scanner scanner = new Scanner(file)) { while (scanner.hasNextLine()) { fileContents.append(scanner.nextLine()).append(lineSeparator); } return fileContents.toString(); } } catch (FileNotFoundException e) { e.printStackTrace(); } return ""; }
From source file:Main.java
private static String getPrivilegedProperty(final String property_name) { return AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty(property_name); }/* w w w .j a v a 2s .co m*/ }); }
From source file:com.hpe.nv.samples.advanced.AdvMultipleTestsSequential.java
public static void main(String[] args) throws Exception { try {// ww w . jav a2 s .c o m // program arguments Options options = new Options(); options.addOption("i", "server-ip", true, "[mandatory] NV Test Manager IP"); options.addOption("o", "server-port", true, "[mandatory] NV Test Manager port"); options.addOption("u", "username", true, "[mandatory] NV username"); options.addOption("w", "password", true, "[mandatory] NV password"); options.addOption("e", "ssl", true, "[optional] Pass true to use SSL. Default: false"); options.addOption("y", "proxy", true, "[optional] Proxy server host:port"); options.addOption("t", "site-url", true, "[optional] Site under test URL. Default: HPE Network Virtualization site URL. If you change this value, make sure to change the --xpath argument too"); options.addOption("x", "xpath", true, "[optional] Parameter for ExpectedConditions.visibilityOfElementLocated(By.xpath(...)) method. Use an xpath expression of some element in the site. Default: //div[@id='content']"); options.addOption("a", "active-adapter-ip", true, "[optional] Active adapter IP. Default: --server-ip argument"); options.addOption("f", "first-zip-result-file-path", true, "[optional] File path to store the first test analysis results as a .zip file"); options.addOption("s", "second-zip-result-file-path", true, "[optional] File path to store the second test analysis results as a .zip file"); options.addOption("k", "analysis-ports", true, "[optional] A comma-separated list of ports for test analysis"); options.addOption("b", "browser", true, "[optional] The browser for which the Selenium WebDriver is built. Possible values: Chrome and Firefox. Default: Firefox"); options.addOption("d", "debug", true, "[optional] Pass true to view console debug messages during execution. Default: false"); options.addOption("h", "help", false, "[optional] Generates and prints help information"); // parse and validate the command line arguments CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); if (line.hasOption("help")) { // print help if help argument is passed HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("AdvMultipleTestsSequential.java", options); return; } if (line.hasOption("server-ip")) { serverIp = line.getOptionValue("server-ip"); if (serverIp.equals("0.0.0.0")) { throw new Exception( "Please replace the server IP argument value (0.0.0.0) with your NV Test Manager IP"); } } else { throw new Exception("Missing argument -i/--server-ip <serverIp>"); } if (line.hasOption("server-port")) { serverPort = Integer.parseInt(line.getOptionValue("server-port")); } else { throw new Exception("Missing argument -o/--server-port <serverPort>"); } if (line.hasOption("username")) { username = line.getOptionValue("username"); } else { throw new Exception("Missing argument -u/--username <username>"); } if (line.hasOption("password")) { password = line.getOptionValue("password"); } else { throw new Exception("Missing argument -w/--password <password>"); } if (line.hasOption("ssl")) { ssl = Boolean.parseBoolean(line.getOptionValue("ssl")); } if (line.hasOption("site-url")) { siteUrl = line.getOptionValue("site-url"); } else { siteUrl = "http://www8.hp.com/us/en/software-solutions/network-virtualization/index.html"; } if (line.hasOption("xpath")) { xpath = line.getOptionValue("xpath"); } else { xpath = "//div[@id='content']"; } if (line.hasOption("first-zip-result-file-path")) { firstZipResultFilePath = line.getOptionValue("first-zip-result-file-path"); } if (line.hasOption("second-zip-result-file-path")) { secondZipResultFilePath = line.getOptionValue("second-zip-result-file-path"); } if (line.hasOption("proxy")) { proxySetting = line.getOptionValue("proxy"); } if (line.hasOption("active-adapter-ip")) { activeAdapterIp = line.getOptionValue("active-adapter-ip"); } else { activeAdapterIp = serverIp; } if (line.hasOption("analysis-ports")) { String analysisPortsStr = line.getOptionValue("analysis-ports"); analysisPorts = analysisPortsStr.split(","); } else { analysisPorts = new String[] { "80", "8080" }; } if (line.hasOption("browser")) { browser = line.getOptionValue("browser"); } else { browser = "Firefox"; } if (line.hasOption("debug")) { debug = Boolean.parseBoolean(line.getOptionValue("debug")); } String newLine = System.getProperty("line.separator"); String testDescription = "*** This sample shows how to run several tests sequentially with different network scenarios. ***" + newLine + "*** ***" + newLine + "*** You can view the actual steps of this sample in the AdvMultipleTestsSequential.java file. ***" + newLine; // print the sample's description System.out.println(testDescription); // start console spinner if (!debug) { spinner = new Thread(new Spinner()); spinner.start(); } // sample execution steps /***** Part 1 - Initialize the TestManager object and set the active adapter *****/ printPartDescription( "\b------ Part 1 - Initialize the TestManager object and set the active adapter"); initTestManager(); setActiveAdapter(); printPartSeparator(); /***** Part 2 - Start the first NV test with the "3G Busy" network scenario and run the "Home Page" transaction *****/ printPartDescription( "------ Part 2 - Start the first NV test with the \"3G Busy\" network scenario and run the \"Home Page\" transaction"); startTest("3G Busy"); testRunning = true; connectToTransactionManager(); startTransaction(); transactionInProgress = true; buildSeleniumWebDriver(); seleniumNavigateToPage(); stopTransaction(); transactionInProgress = false; driverCloseAndQuit(); printPartSeparator(); /***** Part 3 - Stop the first NV test, analyze it and print the results to the console *****/ printPartDescription( "------ Part 3 - Stop the first NV test, analyze it and print the results to the console"); stopTest(); testRunning = false; analyzeTest(); printPartSeparator(); /***** Part 4 - Start the second NV test with the "3G Good" network scenario and run the "Home Page" transaction *****/ printPartDescription( "------ Part 4 - Start the second NV test with the \"3G Good\" network scenario and run the \"Home Page\" transaction"); startTest("3G Good"); testRunning = true; connectToTransactionManager(); startTransaction(); transactionInProgress = true; buildSeleniumWebDriver(); seleniumNavigateToPage(); stopTransaction(); transactionInProgress = false; driverCloseAndQuit(); printPartSeparator(); /***** Part 5 - Stop the second NV test, analyze it and print the results to the console *****/ printPartDescription( "------ Part 3 - Stop the second NV test, analyze it and print the results to the console"); stopTest(); testRunning = false; analyzeTest(); printPartSeparator(); doneCallback(); } catch (Exception e) { try { handleError(e.getMessage()); } catch (Exception e2) { System.out.println("Error occurred: " + e2.getMessage()); } } }
From source file:Main.java
public static ByteBuffer getDataBuffer() { String lineSeparator = System.getProperty("line.separator"); StringBuilder sb = new StringBuilder(); sb.append("test"); sb.append(lineSeparator);/*from w ww .j av a 2 s .c o m*/ String str = sb.toString(); Charset cs = Charset.forName("UTF-8"); ByteBuffer bb = ByteBuffer.wrap(str.getBytes(cs)); return bb; }
From source file:OSUtils.java
public static final boolean isWindows() { return System.getProperty("os.name").startsWith("Windows"); }