Example usage for org.apache.commons.cli DefaultParser DefaultParser

List of usage examples for org.apache.commons.cli DefaultParser DefaultParser

Introduction

In this page you can find the example usage for org.apache.commons.cli DefaultParser DefaultParser.

Prototype

DefaultParser

Source Link

Usage

From source file:com.hpe.nv.samples.advanced.AdvRealtimeUpdate.java

public static void main(String[] args) throws Exception {
    try {/*from   ww  w  .j a  va  2  s  .  co  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:com.heliosdecompiler.bootstrapper.Bootstrapper.java

public static void main(String[] args) {
    Options options = new Options();
    options.addOption(Option.builder("Xfu").longOpt("Xforceupdate").desc("Force the patching process").build());
    options.addOption(Option.builder("Xh").longOpt("Xhelp").desc("Help!").build());
    CommandLineParser parser = new DefaultParser();
    try {/*from w  w  w  . jav a 2s.co  m*/
        CommandLine commandLine = parser.parse(options, args, true);
        if (commandLine.hasOption("Xhelp")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("java -jar bootstrapper.jar", options);
        } else if (commandLine.hasOption("Xforceupdate")) {
            forceUpdate();
        } else {
            //                boolean shouldStart = true;
            //                ServerSocket socket = null;
            //                try {
            //                    socket = new ServerSocket(21354);
            //                } catch (IOException e) {
            //                    shouldStart = false;
            //                } finally {
            //                    if (socket != null) {
            //                        socket.close();
            //                    }
            //                }

            //                if (shouldStart) {
            String[] forward = commandLine.getArgs();
            HeliosData heliosData = loadHelios();
            System.out.println("Running Helios version " + heliosData.buildNumber);

            System.getProperties().put("com.heliosdecompiler.buildNumber",
                    String.valueOf(heliosData.buildNumber));
            System.getProperties().put("com.heliosdecompiler.version", String.valueOf(heliosData.version));
            System.getProperties().put("com.heliosdecompiler.args", args);

            new Thread(new UpdaterTask(heliosData.buildNumber)).start();

            ClassLoader classLoader = new URLClassLoader(new URL[] { IMPL_FILE.toURI().toURL() }, null);
            Class<?> bootloader = Class.forName(heliosData.mainClass, false, classLoader);
            bootloader.getMethod("main", String[].class).invoke(null, new Object[] { forward });
            //                } else {
            //                    String message = Arrays.asList(forward).stream().collect(Collectors.joining(" "));
            //                    Socket clientSocket = new Socket("127.0.0.1", 21354);
            //                    clientSocket.getOutputStream().write(message.getBytes(StandardCharsets.UTF_8));
            //                    clientSocket.getOutputStream().close();
            //                    clientSocket.close();
            //                }
        }
    } catch (Throwable t) {
        displayError(t);
        System.exit(1);
    }
}

From source file:com.examples.cloud.speech.StreamingRecognizeClient.java

public static void main(String[] args) throws Exception {

    String audioFile = "";
    String host = "speech.googleapis.com";
    Integer port = 443;//from ww  w  .j  a va  2  s  . c  om
    Integer sampling = 16000;

    CommandLineParser parser = new DefaultParser();

    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("file").withDescription("path to audio file").hasArg()
            .withArgName("FILE_PATH").create());
    options.addOption(
            OptionBuilder.withLongOpt("host").withDescription("endpoint for api, e.g. speech.googleapis.com")
                    .hasArg().withArgName("ENDPOINT").create());
    options.addOption(OptionBuilder.withLongOpt("port").withDescription("SSL port, usually 443").hasArg()
            .withArgName("PORT").create());
    options.addOption(OptionBuilder.withLongOpt("sampling").withDescription("Sampling Rate, i.e. 16000")
            .hasArg().withArgName("RATE").create());

    try {
        CommandLine line = parser.parse(options, args);
        if (line.hasOption("file")) {
            audioFile = line.getOptionValue("file");
        } else {
            System.err.println("An Audio file must be specified (e.g. /foo/baz.raw).");
            System.exit(1);
        }

        if (line.hasOption("host")) {
            host = line.getOptionValue("host");
        } else {
            System.err.println("An API enpoint must be specified (typically speech.googleapis.com).");
            System.exit(1);
        }

        if (line.hasOption("port")) {
            port = Integer.parseInt(line.getOptionValue("port"));
        } else {
            System.err.println("An SSL port must be specified (typically 443).");
            System.exit(1);
        }

        if (line.hasOption("sampling")) {
            sampling = Integer.parseInt(line.getOptionValue("sampling"));
        } else {
            System.err.println("An Audio sampling rate must be specified.");
            System.exit(1);
        }
    } catch (ParseException exp) {
        System.err.println("Unexpected exception:" + exp.getMessage());
        System.exit(1);
    }

    ManagedChannel channel = AsyncRecognizeClient.createChannel(host, port);
    StreamingRecognizeClient client = new StreamingRecognizeClient(channel, audioFile, sampling);
    try {
        client.recognize();
    } finally {
        client.shutdown();
    }
}

From source file:com.astexample.Recognize.java

public static void main(String[] args) throws Exception {

    String audioFile = "";
    String host = "speech.googleapis.com";
    Integer port = 443;/*from w w  w .ja v a  2 s.  c  o m*/
    Integer sampling = 16000;

    CommandLineParser parser = new DefaultParser();

    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("file").withDescription("path to audio file").hasArg()
            .withArgName("FILE_PATH").create());
    options.addOption(
            OptionBuilder.withLongOpt("host").withDescription("endpoint for api, e.g. speech.googleapis.com")
                    .hasArg().withArgName("ENDPOINT").create());
    options.addOption(OptionBuilder.withLongOpt("port").withDescription("SSL port, usually 443").hasArg()
            .withArgName("PORT").create());
    options.addOption(OptionBuilder.withLongOpt("sampling").withDescription("Sampling Rate, i.e. 16000")
            .hasArg().withArgName("RATE").create());

    try {
        CommandLine line = parser.parse(options, args);
        if (line.hasOption("file")) {
            audioFile = line.getOptionValue("file");
        } else {
            System.err.println("An Audio file must be specified (e.g. /foo/baz.raw).");
            System.exit(1);
        }

        if (line.hasOption("host")) {
            host = line.getOptionValue("host");
        } else {
            System.err.println("An API enpoint must be specified (typically speech.googleapis.com).");
            System.exit(1);
        }

        if (line.hasOption("port")) {
            port = Integer.parseInt(line.getOptionValue("port"));
        } else {
            System.err.println("An SSL port must be specified (typically 443).");
            System.exit(1);
        }

        if (line.hasOption("sampling")) {
            sampling = Integer.parseInt(line.getOptionValue("sampling"));
        } else {
            System.err.println("An Audio sampling rate must be specified.");
            System.exit(1);
        }
    } catch (ParseException exp) {
        System.err.println("Unexpected exception:" + exp.getMessage());
        System.exit(1);
    }

    Recognize client = new Recognize(host, port, audioFile, sampling);
    try {
        client.recognize();
    } finally {
        client.shutdown();
    }
}

From source file:com.astexample.RecognizeGoogleTest.java

public static void main(String[] args) throws Exception {

    String audioFile = "";
    String host = "speech.googleapis.com";
    Integer port = 443;/*from  ww  w .  ja  v a  2 s  .c om*/
    Integer sampling = 16000;

    CommandLineParser parser = new DefaultParser();

    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("file").withDescription("path to audio file").hasArg()
            .withArgName("FILE_PATH").create());
    options.addOption(
            OptionBuilder.withLongOpt("host").withDescription("endpoint for api, e.g. speech.googleapis.com")
                    .hasArg().withArgName("ENDPOINT").create());
    options.addOption(OptionBuilder.withLongOpt("port").withDescription("SSL port, usually 443").hasArg()
            .withArgName("PORT").create());
    options.addOption(OptionBuilder.withLongOpt("sampling").withDescription("Sampling Rate, i.e. 16000")
            .hasArg().withArgName("RATE").create());

    try {
        CommandLine line = parser.parse(options, args);
        if (line.hasOption("file")) {
            audioFile = line.getOptionValue("file");
        } else {
            System.err.println("An Audio file must be specified (e.g. /foo/baz.raw).");
            System.exit(1);
        }

        if (line.hasOption("host")) {
            host = line.getOptionValue("host");
        } else {
            System.err.println("An API enpoint must be specified (typically speech.googleapis.com).");
            System.exit(1);
        }

        if (line.hasOption("port")) {
            port = Integer.parseInt(line.getOptionValue("port"));
        } else {
            System.err.println("An SSL port must be specified (typically 443).");
            System.exit(1);
        }

        if (line.hasOption("sampling")) {
            sampling = Integer.parseInt(line.getOptionValue("sampling"));
        } else {
            System.err.println("An Audio sampling rate must be specified.");
            System.exit(1);
        }
    } catch (ParseException exp) {
        System.err.println("Unexpected exception:" + exp.getMessage());
        System.exit(1);
    }

    RecognizeGoogleTest client = new RecognizeGoogleTest(host, port, audioFile, sampling);
    try {
        client.recognize();
    } finally {
        client.shutdown();
    }
}

From source file:com.google.cloud.speech.grpc.demos.RecognizeClient.java

public static void main(String[] args) throws Exception {

    String audioFile = "";
    String host = "speech.googleapis.com";
    Integer port = 443;/*www.jav  a2  s .co m*/
    Integer sampling = 16000;

    CommandLineParser parser = new DefaultParser();

    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("file").withDescription("path to audio file").hasArg()
            .withArgName("FILE_PATH").create());
    options.addOption(
            OptionBuilder.withLongOpt("host").withDescription("endpoint for api, e.g. speech.googleapis.com")
                    .hasArg().withArgName("ENDPOINT").create());
    options.addOption(OptionBuilder.withLongOpt("port").withDescription("SSL port, usually 443").hasArg()
            .withArgName("PORT").create());
    options.addOption(OptionBuilder.withLongOpt("sampling").withDescription("Sampling Rate, i.e. 16000")
            .hasArg().withArgName("RATE").create());

    try {
        CommandLine line = parser.parse(options, args);
        if (line.hasOption("file")) {
            audioFile = line.getOptionValue("file");
        } else {
            System.err.println("An Audio file must be specified (e.g. /foo/baz.raw).");
            System.exit(1);
        }

        if (line.hasOption("host")) {
            host = line.getOptionValue("host");
        } else {
            System.err.println("An API enpoint must be specified (typically speech.googleapis.com).");
            System.exit(1);
        }

        if (line.hasOption("port")) {
            port = Integer.parseInt(line.getOptionValue("port"));
        } else {
            System.err.println("An SSL port must be specified (typically 443).");
            System.exit(1);
        }

        if (line.hasOption("sampling")) {
            sampling = Integer.parseInt(line.getOptionValue("sampling"));
        } else {
            System.err.println("An Audio sampling rate must be specified.");
            System.exit(1);
        }
    } catch (ParseException exp) {
        System.err.println("Unexpected exception:" + exp.getMessage());
        System.exit(1);
    }

    RecognizeClient client = new RecognizeClient(host, port, audioFile, sampling);
    try {
        client.recognize();
    } finally {
        client.shutdown();
    }
}

From source file:com.hpe.nv.samples.basic.BasicAnalyze2Scenarios.java

public static void main(String[] args) {
    try {/* ww  w  . j  av  a2  s  .co 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("a", "active-adapter-ip", true,
                "[optional] Active adapter IP. Default: --server-ip argument");
        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("BasicAnalyze2Scenarios.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("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 demonstrates a comparison between two network scenarios - \"WiFi\" and \"3G Busy\".                                 ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***   In this sample, the NV test starts with the \"WiFi\" network scenario, running three transactions (see below).                ***"
                + newLine
                + "***   Then, the sample updates the NV test's network scenario to \"3G Busy\" using the real-time update API and runs the same       ***"
                + newLine
                + "***   transactions again.                                                                                                         ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***   After the sample analyzes the NV test and extracts the transaction times from the analysis results, it prints a             ***"
                + newLine
                + "***   summary to the console. The summary displays the comparative network times for each transaction in both                     ***"
                + newLine
                + "***   network scenarios.                                                                                                          ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***   This sample runs three identical NV transactions before and after the real-time update:                                     ***"
                + newLine
                + "***   1. \"Home Page\" transaction: Navigates to the home page in the HPE Network Virtualization website                            ***"
                + newLine
                + "***   2. \"Get Started\" transaction: Navigates to the Get Started Now page in the HPE Network Virtualization website               ***"
                + newLine
                + "***   3. \"Overview\" transaction: Navigates back to the home page in the HPE Network Virtualization website                        ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***   You can view the actual steps of this sample in the BasicAnalyze2Scenarios.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 - Start the NV test with the "WiFi" network scenario                                                                      *****/
        printPartDescription("\b------    Part 1 - Start the NV test with the \"WiFi\" network scenario");
        initTestManager();
        setActiveAdapter();
        startTest();
        testRunning = true;
        printPartSeparator();
        /*****    Part 2 - Run three transactions - "Home Page", "Get Started" and "Overview"                                                      *****/
        printPartDescription(
                "------    Part 2 - Run three transactions - \"Home Page\", \"Get Started\" and \"Overview\"");
        connectToTransactionManager();
        startTransaction(1);
        transactionInProgress = true;
        buildSeleniumWebDriver();
        seleniumNavigateToPage();
        stopTransaction(1);
        transactionInProgress = false;
        startTransaction(2);
        transactionInProgress = true;
        seleniumGetStartedClick();
        stopTransaction(2);
        transactionInProgress = false;
        startTransaction(3);
        transactionInProgress = true;
        seleniumOverviewClick();
        stopTransaction(3);
        transactionInProgress = false;
        driverCloseAndQuit();
        printPartSeparator();
        /*****    Part 3 - Update the NV test in real time to the "3G Busy" network scenario                                                     *****/
        printPartDescription(
                "------    Part 3 - Update the NV test in real time to the \"3G Busy\" network scenario");
        realTimeUpdateTest();
        printPartSeparator();
        /*****    Part 4 - Rerun the transactions                                                                                                *****/
        printPartDescription("------    Part 4 - Rerun the transactions");
        startTransactionAfterRTU(1);
        transactionInProgress = true;
        buildSeleniumWebDriver();
        seleniumNavigateToPage();
        stopTransaction(1);
        transactionInProgress = false;
        startTransactionAfterRTU(2);
        transactionInProgress = true;
        seleniumGetStartedClick();
        stopTransaction(2);
        transactionInProgress = false;
        startTransactionAfterRTU(3);
        transactionInProgress = true;
        seleniumOverviewClick();
        stopTransaction(3);
        transactionInProgress = false;
        driverCloseAndQuit();
        printPartSeparator();
        /*****    Part 5 - Stop the NV test, analyze it and print the results to the console                                                                *****/
        printPartDescription(
                "------    Part 5 - Stop the NV test, analyze it and print the results to the console");
        stopTest();
        testRunning = false;
        analyzeTestZip();
        analyzeTestJson();
        printPartSeparator();
        doneCallback();
    } catch (Exception e) {
        try {
            handleError(e.getMessage());
        } catch (Exception e2) {
            System.out.println("Error occurred: " + e2.getMessage());
        }
    }
}

From source file:com.example.bigquery.QuerySample.java

/** Prompts the user for the required parameters to perform a query. */
public static void main(final String[] args)
        throws IOException, InterruptedException, TimeoutException, ParseException {
    Options options = new Options();

    // Use an OptionsGroup to choose which sample to run.
    OptionGroup samples = new OptionGroup();
    samples.addOption(Option.builder().longOpt("runSimpleQuery").build());
    samples.addOption(Option.builder().longOpt("runStandardSqlQuery").build());
    samples.addOption(Option.builder().longOpt("runPermanentTableQuery").build());
    samples.addOption(Option.builder().longOpt("runUncachedQuery").build());
    samples.addOption(Option.builder().longOpt("runBatchQuery").build());
    samples.isRequired();//from w  w  w  . j  av  a2s  . c  o  m
    options.addOptionGroup(samples);

    options.addOption(Option.builder().longOpt("query").hasArg().required().build());
    options.addOption(Option.builder().longOpt("destDataset").hasArg().build());
    options.addOption(Option.builder().longOpt("destTable").hasArg().build());
    options.addOption(Option.builder().longOpt("allowLargeResults").build());

    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);

    String query = cmd.getOptionValue("query");
    if (cmd.hasOption("runSimpleQuery")) {
        runSimpleQuery(query);
    } else if (cmd.hasOption("runStandardSqlQuery")) {
        runStandardSqlQuery(query);
    } else if (cmd.hasOption("runPermanentTableQuery")) {
        String destDataset = cmd.getOptionValue("destDataset");
        String destTable = cmd.getOptionValue("destTable");
        boolean allowLargeResults = cmd.hasOption("allowLargeResults");
        runQueryPermanentTable(query, destDataset, destTable, allowLargeResults);
    } else if (cmd.hasOption("runUncachedQuery")) {
        runUncachedQuery(query);
    } else if (cmd.hasOption("runBatchQuery")) {
        runBatchQuery(query);
    }
}

From source file:com.act.lcms.v2.TraceIndexExtractor.java

public static void main(String[] args) throws Exception {
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());/*w  w w.java 2 s.  c  o m*/
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        System.err.format("Argument parsing failed: %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        return;
    }

    // Not enough memory available?  We're gonna need a bigger heap.
    long maxMemory = Runtime.getRuntime().maxMemory();
    if (maxMemory < 1 << 34) { // 16GB
        String msg = StringUtils.join(
                String.format(
                        "You have run this class with a maximum heap size of less than 16GB (%d to be exact). ",
                        maxMemory),
                "There is no way this process will complete with that much space available. ",
                "Crank up your heap allocation with -Xmx and try again.", "");
        throw new RuntimeException(msg);
    }

    File inputFile = new File(cl.getOptionValue(OPTION_SCAN_FILE));
    if (!inputFile.exists()) {
        System.err.format("Cannot find input scan file at %s\n", inputFile.getAbsolutePath());
        HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    File rocksDBFile = new File(cl.getOptionValue(OPTION_INDEX_PATH));
    if (rocksDBFile.exists()) {
        System.err.format("Index file at %s already exists--remove and retry\n", rocksDBFile.getAbsolutePath());
        HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    List<Double> targetMZs = new ArrayList<>();
    try (BufferedReader reader = new BufferedReader(new FileReader(cl.getOptionValue(OPTION_TARGET_MASSES)))) {
        String line;
        while ((line = reader.readLine()) != null) {
            targetMZs.add(Double.valueOf(line));
        }
    }

    TraceIndexExtractor extractor = new TraceIndexExtractor();
    extractor.processScan(targetMZs, inputFile, rocksDBFile);
}

From source file:com.twentyn.patentTextProcessor.WordCountProcessor.java

public static void main(String[] args) throws Exception {
    System.out.println("Starting up...");
    System.out.flush();//from  w  ww .j a  v a2 s  .  c  o  m
    Options opts = new Options();
    opts.addOption(Option.builder("i").longOpt("input").hasArg().required()
            .desc("Input file or directory to score").build());
    opts.addOption(Option.builder("h").longOpt("help").desc("Print this help message and exit").build());
    opts.addOption(Option.builder("v").longOpt("verbose").desc("Print verbose log output").build());

    HelpFormatter helpFormatter = new HelpFormatter();
    CommandLineParser cmdLineParser = new DefaultParser();
    CommandLine cmdLine = null;
    try {
        cmdLine = cmdLineParser.parse(opts, args);
    } catch (ParseException e) {
        System.out.println("Caught exception when parsing command line: " + e.getMessage());
        helpFormatter.printHelp("WordCountProcessor", opts);
        System.exit(1);
    }

    if (cmdLine.hasOption("help")) {
        helpFormatter.printHelp("DocumentIndexer", opts);
        System.exit(0);
    }

    String inputFileOrDir = cmdLine.getOptionValue("input");
    File splitFileOrDir = new File(inputFileOrDir);
    if (!(splitFileOrDir.exists())) {
        LOGGER.error("Unable to find directory at " + inputFileOrDir);
        System.exit(1);
    }

    WordCountProcessor wcp = new WordCountProcessor();
    PatentCorpusReader corpusReader = new PatentCorpusReader(wcp, splitFileOrDir);
    corpusReader.readPatentCorpus();
}