You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/05/17 12:35:13 UTC

[commons-rng] branch master updated (2363d3c -> c9d8a87)

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git.


    from 2363d3c  Fixed apache-rat:check.
     new 9f434e9  Update examples stress to expose a single public application class.
     new c9d8a87  Remove declared exceptions that are not thrown.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 commons-rng-examples/examples-stress/pom.xml       |  2 +-
 .../rng/examples/stress/EndianessCommand.java      |  2 +-
 ...Command.java => ExamplesStressApplication.java} | 47 +++++----------
 .../rng/examples/stress/ExamplesStressCommand.java | 70 +---------------------
 .../commons/rng/examples/stress/OutputCommand.java |  2 +-
 .../rng/examples/stress/ResultsCommand.java        |  2 +-
 6 files changed, 21 insertions(+), 104 deletions(-)
 copy commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/{ExamplesStressCommand.java => ExamplesStressApplication.java} (78%)


[commons-rng] 02/02: Remove declared exceptions that are not thrown.

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git

commit c9d8a8782c932b42cacd184fb969c903162e60c3
Author: aherbert <ah...@apache.org>
AuthorDate: Fri May 17 13:35:08 2019 +0100

    Remove declared exceptions that are not thrown.
---
 .../java/org/apache/commons/rng/examples/stress/EndianessCommand.java   | 2 +-
 .../main/java/org/apache/commons/rng/examples/stress/OutputCommand.java | 2 +-
 .../java/org/apache/commons/rng/examples/stress/ResultsCommand.java     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/EndianessCommand.java b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/EndianessCommand.java
index 5f325b5..a5508c5 100644
--- a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/EndianessCommand.java
+++ b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/EndianessCommand.java
@@ -40,7 +40,7 @@ class EndianessCommand implements Callable<Void> {
      * Prints a template generators list to stdout.
      */
     @Override
-    public Void call() throws Exception {
+    public Void call() {
         // Log level will be relevant for any exception logging
         LogUtils.setLogLevel(reusableOptions.logLevel);
         LogUtils.info(ByteOrder.nativeOrder().toString());
diff --git a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/OutputCommand.java b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/OutputCommand.java
index 9c01b91..79ba654 100644
--- a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/OutputCommand.java
+++ b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/OutputCommand.java
@@ -224,7 +224,7 @@ class OutputCommand implements Callable<Void> {
         }
         return new FilterOutputStream(System.out) {
             @Override
-            public void close() throws IOException {
+            public void close() {
                 // Do not close stdout
             }
         };
diff --git a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
index ccee7bb..d526693 100644
--- a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
+++ b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
@@ -587,7 +587,7 @@ class ResultsCommand implements Callable<Void> {
         }
         return new FilterOutputStream(System.out) {
             @Override
-            public void close() throws IOException {
+            public void close() {
                 // Do not close stdout
             }
         };


[commons-rng] 01/02: Update examples stress to expose a single public application class.

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git

commit 9f434e9d0dd3170f5493bb9e721b9834fd2ddfef
Author: aherbert <ah...@apache.org>
AuthorDate: Fri May 17 13:33:27 2019 +0100

    Update examples stress to expose a single public application class.
    
    This fixes the javadoc plugin as all other classes are package-private.
---
 commons-rng-examples/examples-stress/pom.xml       |  2 +-
 ...Command.java => ExamplesStressApplication.java} | 47 +++++----------
 .../rng/examples/stress/ExamplesStressCommand.java | 70 +---------------------
 3 files changed, 18 insertions(+), 101 deletions(-)

diff --git a/commons-rng-examples/examples-stress/pom.xml b/commons-rng-examples/examples-stress/pom.xml
index f471600..d652bab 100644
--- a/commons-rng-examples/examples-stress/pom.xml
+++ b/commons-rng-examples/examples-stress/pom.xml
@@ -48,7 +48,7 @@
     <rng.parent.dir>${basedir}/../..</rng.parent.dir>
 
     <uberjar.name>examples-stress</uberjar.name>
-    <project.mainClass>org.apache.commons.rng.examples.stress.ExamplesStressCommand</project.mainClass>
+    <project.mainClass>org.apache.commons.rng.examples.stress.ExamplesStressApplication</project.mainClass>
 
     <rng.picocli.version>3.9.5</rng.picocli.version>
   </properties>
diff --git a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressCommand.java b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressApplication.java
similarity index 78%
copy from commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressCommand.java
copy to commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressApplication.java
index 6b54d91..0a8f1c4 100644
--- a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressCommand.java
+++ b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressApplication.java
@@ -19,54 +19,44 @@ package org.apache.commons.rng.examples.stress;
 import org.apache.commons.rng.UniformRandomProvider;
 
 import picocli.CommandLine;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Mixin;
-import picocli.CommandLine.Model.CommandSpec;
 import picocli.CommandLine.RunLast;
-import picocli.CommandLine.Spec;
-
-import java.util.concurrent.Callable;
 
 /**
- * Class containing utilities for the random number generators in the Commons
- * RNG library.
+ * Executes testing utilities for the random number generators in the Commons RNG library.
  *
  * <p>The principle action is testing a generator by piping the values
  * returned by its {@link UniformRandomProvider#nextInt()} method to a
  * program that reads {@code int} values from its standard input and
  * writes an analysis report to standard output.
  * The <a href="http://www.phy.duke.edu/~rgb/General/dieharder.php">
- * "dieharder"</a> test suite is such a software.</p>
+ * "Dieharder"</a> test suite is such a software.</p>
  *
  * <p>Example of command line, assuming that "examples-stress.jar" specifies this
- * class as the "main" class (see {@link #main(String[]) main} method):
+ * class as the "main" class (see {@link #main(String[]) main} method):</p>
+ *
  * <pre>{@code $ java -jar examples-stress.jar stress /usr/bin/dieharder -a -g 200 -Y 1 -k 2}</pre>
- * </p>
  *
  * <p>Other functionality includes:</p>
  *
  * <ul>
- *   <li>Listing all the generators
- *   <li>...
+ *   <li>Listing all the available generators
+ *   <li>Collating results from known stress test applications
+ *   <li>Outputting data from a random generator
+ *   <li>Showing the platform native byte order
+ *   <li>Testing data transfer to an application sub-process via its standard input
  * </ul>
  */
-@Command(name = "examples-stress",
-         description = "Apache Commons RNG Examples Stress Utilities.")
-class ExamplesStressCommand implements Callable<Void> {
-    /** The command specification. Used to print the usage built by Picocli. */
-    @Spec
-    private CommandSpec spec;
-
-    /** The standard options. */
-    @Mixin
-    private StandardOptions reusableOptions;
+public class ExamplesStressApplication {
+    /** No public constructor. */
+    private ExamplesStressApplication() {}
 
     /**
-     * Run the RNG Utilities command line application.
+     * Run the RNG examples stress command line application.
      *
      * @param args Application's arguments.
      */
-    public static void main(String[] args) {
+    public static void main(String[] args)
+    {
         // Build the command line manually so we can configure options.
         final CommandLine cmd = new CommandLine(new ExamplesStressCommand())
                 .addSubcommand("bridge",  new CommandLine(new BridgeTestCommand())
@@ -104,11 +94,4 @@ class ExamplesStressCommand implements Callable<Void> {
             throw ex;
         }
     }
-
-    @Override
-    public Void call() {
-        // All work is done in sub-commands so just print the usage
-        spec.commandLine().usage(System.out);
-        return null;
-    }
 }
diff --git a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressCommand.java b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressCommand.java
index 6b54d91..ac9e186 100644
--- a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressCommand.java
+++ b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ExamplesStressCommand.java
@@ -16,39 +16,17 @@
  */
 package org.apache.commons.rng.examples.stress;
 
-import org.apache.commons.rng.UniformRandomProvider;
-
-import picocli.CommandLine;
 import picocli.CommandLine.Command;
 import picocli.CommandLine.Mixin;
 import picocli.CommandLine.Model.CommandSpec;
-import picocli.CommandLine.RunLast;
 import picocli.CommandLine.Spec;
 
 import java.util.concurrent.Callable;
 
 /**
- * Class containing utilities for the random number generators in the Commons
- * RNG library.
- *
- * <p>The principle action is testing a generator by piping the values
- * returned by its {@link UniformRandomProvider#nextInt()} method to a
- * program that reads {@code int} values from its standard input and
- * writes an analysis report to standard output.
- * The <a href="http://www.phy.duke.edu/~rgb/General/dieharder.php">
- * "dieharder"</a> test suite is such a software.</p>
- *
- * <p>Example of command line, assuming that "examples-stress.jar" specifies this
- * class as the "main" class (see {@link #main(String[]) main} method):
- * <pre>{@code $ java -jar examples-stress.jar stress /usr/bin/dieharder -a -g 200 -Y 1 -k 2}</pre>
- * </p>
- *
- * <p>Other functionality includes:</p>
+ * Specification for the top-level command in the examples stress application.
  *
- * <ul>
- *   <li>Listing all the generators
- *   <li>...
- * </ul>
+ * <p>This command is will print the top-level help message.</p>
  */
 @Command(name = "examples-stress",
          description = "Apache Commons RNG Examples Stress Utilities.")
@@ -61,50 +39,6 @@ class ExamplesStressCommand implements Callable<Void> {
     @Mixin
     private StandardOptions reusableOptions;
 
-    /**
-     * Run the RNG Utilities command line application.
-     *
-     * @param args Application's arguments.
-     */
-    public static void main(String[] args) {
-        // Build the command line manually so we can configure options.
-        final CommandLine cmd = new CommandLine(new ExamplesStressCommand())
-                .addSubcommand("bridge",  new CommandLine(new BridgeTestCommand())
-                                                          .setStopAtPositional(true))
-                .addSubcommand("endian",  new EndianessCommand())
-                .addSubcommand("list",    new ListCommand())
-                .addSubcommand("output",  new CommandLine(new OutputCommand())
-                                                          // Allow the input seed using hex (0x, 0X, #)
-                                                          // or octal (starting with 0)
-                                                          .registerConverter(Long.class, Long::decode))
-                .addSubcommand("results", new ResultsCommand())
-                .addSubcommand("stress",  new CommandLine(new StressTestCommand())
-                                                          .setStopAtPositional(true))
-                // Call last to apply to all sub-commands
-                .setCaseInsensitiveEnumValuesAllowed(true);
-
-        try {
-            // Parse the command line and invokes the Callable program (RNGUtilities)
-            cmd.parseWithHandler(new RunLast(), args);
-        } catch (final picocli.CommandLine.ExecutionException ex) {
-            final Throwable cause = ex.getCause();
-            if (cause != null) {
-                // If this was an exception generated by the application then the full
-                // stack trace is not needed depending on log level. This limits stack
-                // trace output to unexpected errors in the common use case.
-                if (cause instanceof ApplicationException &&
-                        !LogUtils.isLoggable(LogUtils.LogLevel.DEBUG)) {
-                    LogUtils.error(cause.getMessage());
-                } else {
-                    LogUtils.error(cause, cause.getMessage());
-                }
-                System.exit(1);
-            }
-            // No cause so re-throw. This may be a Picocli parsing error.
-            throw ex;
-        }
-    }
-
     @Override
     public Void call() {
         // All work is done in sub-commands so just print the usage