diff options
author | Philipp Wollermann <philwo@google.com> | 2017-09-03 10:51:44 +0200 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2017-09-04 11:23:17 +0200 |
commit | a6d3f52fef62955b6b25a3832440f041a93bc5e2 (patch) | |
tree | c6d20779e7cd3558c51bf986fb15a1d1e4bfdf77 /third_party/java | |
parent | 663df9d96f10a2dd0fa8a85b4aac39cd2cc368fb (diff) |
Remove third_party/java/jopt-simple/src/{site,test}.
They are unused and the tests depend on Joda Time which I'm going to
remove.
Also document the removal in the package's README.bazel.md.
Change-Id: I7b0ee89718bfc2cffcc60a8262cf53dbf9035669
Diffstat (limited to 'third_party/java')
154 files changed, 1 insertions, 14233 deletions
diff --git a/third_party/java/jopt-simple/README.bazel.md b/third_party/java/jopt-simple/README.bazel.md index 9985e82975..759711bf04 100644 --- a/third_party/java/jopt-simple/README.bazel.md +++ b/third_party/java/jopt-simple/README.bazel.md @@ -4,3 +4,4 @@ This is jopt-simple 5.0.3. Reproduction: 2. `git checkout jopt-simple-5.0.3` (commithash `b52b94611dba126a8236a10277d15676e31ab5f6`) 3. Dump the contents of the `git` tree into `third_party/java/jopt-simple` 4. Keep the existing, trivial `BUILD` file +5. Remove the src/test and src/site directories. diff --git a/third_party/java/jopt-simple/src/site/apt/acknowledgments.apt b/third_party/java/jopt-simple/src/site/apt/acknowledgments.apt deleted file mode 100644 index ec35ed7e19..0000000000 --- a/third_party/java/jopt-simple/src/site/apt/acknowledgments.apt +++ /dev/null @@ -1,90 +0,0 @@ - --------------- - Acknowledgments - --------------- - - Thanks to the following people who have offered constructive feedback, support, contribution, - and/or praise for JOpt Simple: - - * Paul Armstrong - - * Guillaume Aubert - - * David Beckingsale - - * Jochen Bedersdorfer - - * Louis Bergelson - - * Ryan Breidenbach - - * Erik Broes - - * Carlos Cadete - - * Laurent Caillette - - * Matthew Daniel - - * Hans Dockter - - * Kevin C. Dorff - - * Adam Fisk - - * Raymund F\u00FCl\u00F6p - - * Dave Jarvis - - * Paul King - - * El Kodus - - * Alexander Kriegisch - - * Zachary Kurmas - - * Henning Luebbers - - * Derek Mahar - - * Bruno Mascret - - * Antoine Neveux - - * Christian Ohr - - * Michael Osipov - - * Brian Oxley (binkley) - - * Andrew Parker - - * Julien Ponge - - * Rob Reed - - * Mark Reinhold - - * Alex Renger - - * Andrew Robinson - - * Jonathan Shook - - * Jason Smith - - * Emils Solmanis - - * Leo Uzcategui - - * Alan van Dam - - * Douglas Wegscheid - - * Chris K Wensel - - * Ashley Williams - - * Daniel Yokomizo - - [] diff --git a/third_party/java/jopt-simple/src/site/apt/changes.apt b/third_party/java/jopt-simple/src/site/apt/changes.apt deleted file mode 100644 index 2bc0d7d9c6..0000000000 --- a/third_party/java/jopt-simple/src/site/apt/changes.apt +++ /dev/null @@ -1,385 +0,0 @@ - ---------- - Change Log - ---------- - -Changes in version 5.0.3 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/96} gh-96}} so that - options that take an argument but don't change the argument type from - <<<String>>> still show a <<<String>>> type indicator in the default - option help. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/104} gh-104}} so - that <<<EnumConverter>>> performs case-insensitive matching against arguments - of options. Thanks to Martin Paljak for this. - -Changes in version 5.0.2 - - * Made some package-private abstract classes become public classes - with package-private constructors. This makes it possible to call some methods - from Kotlin that were previously inaccessible. Thanks to Mirko Friedenhagen - for this. - -Changes in version 5.0.1 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/92} gh-92}} so that - in the event that <<<printHelpOn()>>> is called more than once, the output - is not duplicated. - -Changes in version 5.0 - - * Abandoning JDKs prior to 7. All source is Java 7-compatible, and bytecode is compiled to 1.7 - version. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/51} gh-51}} by adding - <<<OptionSpecBuilder.availableIf()>>> and <<<OptionSpecBuilder.availableUnless()>>>. Thanks - to Christian Ohr for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/70} gh-70}} by adding - <<<EnumConverter>>> and <<<PathConverter>>>. Thanks to Christian Ohr for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/88} gh-88}} by adding - an <<<OptionParser>>> constructor to allow suppression of option abbreviations. - Thanks to Louis Bergelson for this. - -Changes in version 4.10 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/85} gh-85}} - by correcting the description column width consumption of the built-in - help formatter. - -Changes in version 4.9 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/79} gh-79}} - by correcting the behavior of <<<OptionException.multipleOptionString>>> - when handling options with synonyms. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/72} gh-72}} - by externalizing some of the literal strings in <<<BuiltinHelpFormatter>>> - into resource bundles. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/76} gh-76}} - by modifying the behavior of <<<OptionalArgumentOptionSpec>>> so that if - the argument following the option does not "look like" an option but can - be converted to the option argument's type, treat the argument as the argument - of the option. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/68} gh-68}} - by modifying <<<BuiltinHelpFormatter>>> to be more extensible and documenting - the behavior of the newly accessible methods. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/73} gh-73}} - by correcting the behavior of <<<OptionSet.specs()>>> to remove all instances - of the non-option argument spec. - -Changes in version 4.8 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/65} gh-65}} - by modifying the build file to create a JAR with OSGi metadata. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/63} gh-63}} - by externalizing exception messages into resource bundles. - Currently, we ship only with messages for locale "en_US". - Translations for other locales are more than welcome. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/58} gh-58}} by - rewriting exception messaging to clarify synonymous options. - Synonyms are be separated by slashes (/); lists of distinct options will - be separated by commas (,) in square brackets ([]). - -Changes in version 4.7 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/57} gh-57}} by admitting - the underscore as a legal option character. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/53} gh-53}} by correcting - <<<OptionSet.hasOptions()>>> to answer correctly for no switches. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/56} gh-56}} by correcting - the default help formatting not to use a <<<Set>>> for rows of output, - but <<<List>>>. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/59} gh-59}} by relaxing - the return type of <<<ValueConverter.valueType()>>>. - -Changes in version 4.6 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/31} gh-31}} by offering - <<<OptionSpecBuilder.requiredUnless()>>>. Thanks to Christian Ohr for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/38} gh-38}} by offering - <<<OptionParser.recognizedOptions()>>>. Thanks to Antoine Neveux for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/35} gh-35}} by offering - <<<OptionSet.asMap()>>>. Thanks to Brian Oxley for this. - -Changes in version 4.5 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/17} gh-17}} by offering - <<<OptionParser.nonOptions()>>> and <<<NonOptionArgumentSpec>>>. - - * Resolved {{{https://github.com/pholser/jopt-simple/pull/27} gh-27}} by offering - <<<OptionParser.allowsUnrecognizedOptions()>>>. Thanks to Erik Broes for this. - -Changes in version 4.4 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/16} gh-16}} by offering - <<<BuiltinHelpFormatter>>> that allows configuration of overall row width and - column separator width. Thanks to Ryan Breidenbach for contributing code to this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/12} gh-12}} by offering - <<<OptionSpecBuilder.requiredIf()>>>. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/22} gh-22}}. Thanks to - El Kodus for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/19} gh-19}}. Thanks to - El Kodus for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/14} gh-14}} by offering - <<<AbstractOptionSpec.forHelp()>>>. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/13} gh-13}} by offering - <<<ArgumentAcceptingOptionSpec.withValuesSeparatedBy(String)>>>. - - * Added <<<InetAddressValueConverter>>>. Thanks to Raymund F\u00FCl\u00F6p for this. - -Changes in version 4.3 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/9} gh-9}} by offering - <<<OptionSet.specs()>>>, which gives a list of the specs corresponding to the - options detected on a parse, in the order in which the options occurred on the - command line. - -Changes in version 4.2 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/8} gh-8}} by offering - <<<ArgumentAcceptingOptionSpec.defaultsTo(V[])>>> in addition to - <<<ArgumentAcceptingOptionSpec.defaultsTo(V, V...)>>>. - - * Removing some internal unused classes and methods. - -Changes in version 4.1 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/7} gh-7}} by allowing short option - clusters to contain options which can accept arguments. When such an option is encountered, - the remaining characters in the cluster are treated as the argument to the option. Thanks to - Alan van Dam for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/6} gh-6}} with general improvements - to the project's site. Thanks to Michael Osipov for this. - -Changes in version 4.0 - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/4} gh-4}} by adding method - <<<OptionParser.formatHelpWith(HelpFormatter)>>> to allow programmers to influence what - help is printed with <<<OptionParser.printHelpOn()>>>. A <<<HelpFormatter>>> is handed a - map, keyed by option text, whose values are <<<OptionDescriptor>>>s that describe the - options the parser has been configured with. - - * Added method <<<OptionSet.hasOptions()>>>. Thanks to Michael Osipov for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/pull/3} gh-3}} by using - <<<SimpleDateFormat.toPattern()>>> rather than <<<SimpleDateFormat.toLocalizedPattern()>>> - in <<<DateConverter>>>. Thanks to Michael Osipov for this. - - * Resolved {{{https://github.com/pholser/jopt-simple/issues/5} gh-5}} by allowing primitive - <<<Class>>> objects whose wrapper types are considered "value types" for purposes of - <<<ArgumentAcceptingOptionSpec.ofType()>>> in place of the wrapper classes. Thanks to - Daniel Yokomizo for suggesting this. - -Changes in version 3.3 - - * Resolved {{{https://github.com/pholser/jopt-simple/pull/1} gh-1}} by adding method - <<<required()>>> to class <<<ArgumentAcceptingOptionSpec>>>, to allow callers to indicate - that a given option must be present on the command line. Thanks to Emils Solmanis for - adding this. - -Changes in version 3.2 - - * Added method <<<defaultsTo()>>> to class <<<ArgumentAcceptingOptionSpec>>>, to allow - callers to specify default values for arguments of options. These influence the return - values of <<<OptionSpec.value(s)()>>> and <<<OptionSet.value(s)Of()>>>. Default values - also show up in the help screen entries for their options. This serves to resolve - {{{https://sourceforge.net/tracker/?func=detail&aid=2484524&group_id=125731&atid=703508} feature - request 2484524}}. - - * Fixed a problem whereby the empty string, a string consisting solely of whitespace, or a - string with embedded whitespace weren't being properly recognized as arguments of options - when they should have. - - * Resolved {{{https://sourceforge.net/tracker/?func=detail&aid=2793762&group_id=125731&atid=703508} feature - request 2793762}}, having to do with improving the behavior of embedded newlines in option - descriptions in help screens. - -Changes in version 3.1 - - * Added method <<<withValuesConvertedBy()>>> to class <<<ArgumentAcceptingOptionSpec>>>, - to allow callers to specify converters or validators that transform arguments of - options into instances of specific Java types. This is useful for types which do not - meet the requirements of <<<ofType()>>>. - - * Added classes <<<DateConverter>>> and <<<RegexMatcher>>> as examples of useful - argument converters. - -Changes in version 3.0.1 - - * Dependency on {{{http://ant.apache.org} Ant}} more appropriately test-scoped in the - {{{http://maven.apache.org} Maven}} POM. That way, if you use JOpt Simple with Maven, - you don't download Ant unnecessarily. - -Changes in version 3.0 - - * Version 3.0 supports Java 5 and greater only. If you need to use JOpt Simple in a - pre-Java-5 environment, use the latest 2.x release. - - * Where appropriate, existing API calls have been updated to use Java generics. - - * Extracted and surfaced interface <<<OptionSpec>>>. <<<OptionSpec>>>s returned by - the fluent interface methods can be used to retrieve arguments of the options they - represent in a type-safe manner. - - * Removed all previously deprecated methods. - - * Added methods to <<<OptionSet>>> to allow detection of options and retrieval of - option arguments using instances of <<<OptionSpec>>>. - - * Converted tests to JUnit 4. - - * Switched to MIT License. - - * Relaxing some <<<List>>> parameter types and return types of methods to - <<<Collection>>>. - - * <<<OptionArgumentConversionException>>> no longer drops the original cause on the - floor; hence <<<OptionException>>> can now be created with a cause. - - * {{{http://maven.apache.org} Maven}}-ized the project web site. - - * Overhauled the examples page. - -Changes in version 2.4.1 - - * Fixed {{{https://sourceforge.net/tracker/index.php?func=detail&aid=2018262&group_id=125731&atid=703505} bug 2018262}}. - -Changes in version 2.4 - - * Added the <<<acceptsAll()>>> method to class <<<OptionParser>>>. Options passed to - a given invocation of this method are treated as synonymous, so that each gives the - same answer when given as the argument to the methods <<<has()>>>, <<<valuesOf()>>>, - etc. on <<<OptionSet>>>. - - * Surfaced the class <<<KeyValuePair>>>. This class can be very handy as a value - type for arguments whose values take on the form <<<key=value>>>, such as the <<<-D>>> - arguments to JVMs. - - * Fixed {{{https://sourceforge.net/tracker/index.php?func=detail&aid=1932577&group_id=125731&atid=703505} bug 1932577}}. - - * Added method <<<withValuesSeparatedBy()>>> to class <<<ArgumentAcceptingOptionSpec>>>, - to allow callers to specify multiple values for an option as a single argument with - values separated by a given character. - - * Method <<<ofType()>>> on class <<<ArgumentAcceptingOptionSpec>>> now returns self - rather than <<<void>>>. - - * Deprecated another "get for get's sake": <<<OptionParser.setPosixlyCorrect()>>> - It is replaced with a less Java-beany-looking method. - - * Cleaned up the help screens produced by <<<OptionParser.printHelpOn()>>> so they are - rendered as two 40-character columns, with long space-broken values split across lines - as needed. - - * Fixed {{{https://sourceforge.net/tracker/index.php?func=detail&aid=1956418&group_id=125731&atid=703505} bug 1956418}}. - -Changes in version 2.3.6 - - * No changes to code; just getting {{{http://maven.apache.org} Maven}} to do releases - with its plugins. - -Changes in version 2.3.3 - - * Deprecated method <<<OptionSet.wasDetected()>>> in favor of <<<OptionSet.has()>>> -- - the new name seems to read better. - - * <<<OptionException>>>s now override <<<getMessage()>>> sensibly, so that if a caller - wants to handle the exception by catching it and displaying a message from the - exception, she can do so and get satisfactory results. - - * {{{http://maven.apache.org} Maven}}-ized project's build. - - * Minor internal changes. - -Changes in version 2.3.2 - - * Minor internal changes. - -Changes in version 2.3.1 - - * Fixed a bug with POSIX-ly correct parsers. It was previously thought that POSIX-ly - correct parsers should signal end of options when they detect an argument that does - not lexically look like an option and could not be an argument of a previous option, - required or optional. Such parsers now signal end of options when they detect an - argument that does not lexically look like an option, and is not an argument of a - previous option with a required argument. If you want such an argument to be treated - as the argument of a preceding option whose argument is optional, you can still get - this behavior by appending the argument to the option, either with abutting syntax - (<<<-d/tmp>>>) or key-value syntax (<<<-d=/tmp>>>). - -Changes in version 2.3 - - * No feature changes in this release; but this release can now be used with JDK 1.3. - Previous releases could be used only with JDK 1.4 or newer. - -Changes in version 2.2 - - * Removed all previously deprecated methods. - - * Re-clarified the contract of the one-arg <<<String>>> constructor of - <<<OptionParser>>>: the constructor now raises <<<NullPointerException>>> if its - argument is <<<null>>>. This is the convention for Java library methods which receive - illegal <<<null>>> parameters. - -Changes in version 2.1 - - * Introduced a facility for <<<OptionParser>>>s to print a help screen, which - describes the options they accept. - - * Added the ability to provide descriptions of options and their arguments when - configuring an <<<OptionParser>>>. These descriptions are printed in the - aforementioned help screens. - - * Clarified the contract of the one-arg <<<String>>> constructor of <<<OptionParser>>>: - the constructor raises <<<IllegalArgumentException>>> if its argument is <<<null>>>. - - * Deprecated <<<OptionParser.noArg()>>>, <<<OptionParser.requiredArg()>>>, and - <<<OptionParser.optionalArg()>>>. - - * Deprecated some "gets for gets' sake": <<<OptionException.getOption()>>>, - <<<OptionSet.getNonOptionArguments()>>>. They are replaced with less - Java-beany-looking methods. - -Changes in version 2.0 - - * Introduced a "fluent interface" API for specifying options for an <<<OptionParser>>> - to recognize. The old methods for option specification still work--you need not - convert to the new methods. - - * Added the ability to specify that option arguments should be converted to specific - types. You can do this either with the old option specification methods or with the - new fluent interface API. - - * Deprecated <<<OptionParser.requiresArg()>>> in favor of - <<<OptionParser.requiredArg()>>> -- the new name seems to read better. - -Version 1.0 - - * First major release. - - * Includes concrete classes <<<OptionParser>>> and <<<OptionSet>>>. - - * Supports POSIX <<<getopt()>>> and GNU <<<getopt_long()>>> command line syntax. - - * No type conversion on option arguments, they are all treated as <<<String>>>s. - - * Methods <<<noArg()>>>, <<<requiredArg()>>>, and <<<optionalArg()>>> tell an - <<<OptionParser>>> what options to recognize. diff --git a/third_party/java/jopt-simple/src/site/apt/developer.apt b/third_party/java/jopt-simple/src/site/apt/developer.apt deleted file mode 100644 index 59d5d82d5a..0000000000 --- a/third_party/java/jopt-simple/src/site/apt/developer.apt +++ /dev/null @@ -1,48 +0,0 @@ - -------------- - Developer Docs - -------------- - -Help for developing JOpt Simple - - This page has notes and hints for contributing to JOpt Simple, mostly around getting started and style questions. - -* Code Style - - Style is important. Why? Chiefly to aid merges. Reformatting code makes merging more difficult. When needing to reformat unchanged code, please do so on a separate commit with a clear commit message indicating a non-code change. - - In general use the Eclipse formatter (there is a plugin for IntelliJ IDEA). See <<<jopt-simple-eclipse-formatting.xml>>> and <<<jopt-simple.importorder>>> in the project root. - - The ultimate arbiter of good style is Paul Holser. - -** Braces - - * Yes: - -+----+ -for (int i = 0; i < 10; ++i) { - if (i < 5) - println(i); -} -+----+ - - * No: - -+----+ -for (int i = 0; i < 10; ++i) - if (i < 5) - println(i); -+----+ - -* {{Building}} - - There are no integration tests. Your typical command line is: - -+----+ -$ mvn clean test -+----+ - - Before pushing commits, please check that the site fully builds: - -+----+ -$ mvn clean post-site -+----+ diff --git a/third_party/java/jopt-simple/src/site/apt/download.apt.vm b/third_party/java/jopt-simple/src/site/apt/download.apt.vm deleted file mode 100644 index dde9015f5e..0000000000 --- a/third_party/java/jopt-simple/src/site/apt/download.apt.vm +++ /dev/null @@ -1,26 +0,0 @@ - -------- - Download - -------- - - Releases of JOpt Simple are synced to the central Maven repository. Declare a - dependency element in your POM like so: - -+--------------------------------------------- -... -<dependencies> - ... - <dependency> - <groupId>net.sf.jopt-simple</groupId> - <artifactId>jopt-simple</artifactId> - <version>${project.version}</version> - </dependency> - ... -</dependencies> -... -+--------------------------------------------- - - If you're not using Maven, you can still download the newer releases from the Maven - repository manually, {{{http://repo1.maven.org/maven2/net/sf/jopt-simple/jopt-simple} here}}. - - You can find older releases at - {{{http://sourceforge.net/project/showfiles.php?group_id=125731} SourceForge}}. diff --git a/third_party/java/jopt-simple/src/site/apt/examples.apt b/third_party/java/jopt-simple/src/site/apt/examples.apt deleted file mode 100644 index 3b43dee995..0000000000 --- a/third_party/java/jopt-simple/src/site/apt/examples.apt +++ /dev/null @@ -1,462 +0,0 @@ - ----------------- - Examples of Usage - ----------------- - -Preamble - - The simplicity in JOpt "Simple" arises from two guiding principles: - - * Stick as often as possible to supporting conventional Unix option syntaxes. - - * Keep the surface area of the published API as small and simple as possible. - - [] - - To the first principle: You will not see support in JOpt Simple for option "groups", - alternative option prefixes (<<<+>>>, <<</>>>), enforced multiplicity of option - arguments, etc. JOpt Simple believes you can create a useful and understandable CLI - without all that stuff. If you feel as though you need any of those features, there - are lots of other choices out there. The author of JOpt Simple believes you'll want - to leverage its easy configuration, parsing, and option interrogation APIs instead of - using more feature-laden, but perhaps more confusing libraries. - - To the second principle: JOpt Simple will make every attempt to keep the API free - of clutter. The API is well factored, making it intuitive to use, and the entire - library is well tested, making it more reliable and predictable. If you cannot look - at the Javadoc and quickly get a sense of what you need to do to use JOpt Simple, - then JOpt Simple has failed. So by all means, let the author know what needs - improved. - - With that said, let's take a tour through JOpt Simple's features. - -Options - - JOpt Simple supports short options and long options, using a syntax that attempts to - take from the best of POSIX <<<getopt()>>> and GNU <<<getopt_long()>>>. - -* Short Options - - Short options begin with a single hyphen (<<<->>>) followed by a single letter or - digit, or question mark (<<<?>>>), or dot (<<<.>>>). - -+---------------------------------------------------------------------------------------- -@SHORT_OPTIONS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - - When you construct an <<<OptionParser>>> with a string of short option characters, - you configure that parser to recognize the options with those characters. - -** Arguments of Options - - Short options can accept single arguments. The argument can be made required or - optional. When you construct an <<<OptionParser>>> with a string of short option - characters, append a single colon (<<<:>>>) to an option character to configure - that option to require an argument. Append two colons (<<<::>>>) to an option - character to configure that option to accept an optional argument. Append an - asterisk (<<<*>>>) to an option character, but before any "argument" indicators, - to configure that option as a "help" option. - - The syntax of the option specification string given to the <<<OptionParser>>> - constructor should look familiar to you if you have used GNU's <<<getopt()>>> - before. - -+---------------------------------------------------------------------------------------- -@SHORT_OPTIONS_WITH_ARGUMENTS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -*** Specifying Arguments for a Short Option on the Command Line - - A short option's argument can occur: - - * in the position on the command line after the option - - * right up against the option - - * right up against the option separated by an equals sign (<<<=>>>) - - [] - -+---------------------------------------------------------------------------------------- -@SHORT_OPTIONS_WITH_ARGUMENT_POSITIONING_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -*** Multiple Arguments for a Single Option - - To specify <n> arguments for a single option, specify the option <n> times on the - command line, once for each argument. JOpt Simple reports the arguments given to the - option in the order in which they were encountered on the command line. - -+---------------------------------------------------------------------------------------- -@SHORT_OPTIONS_WITH_MULTIPLE_ARGUMENTS_FOR_SINGLE_OPTION_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Clustering Short Options - - Short options can be <clustered> in a single argument. - -+---------------------------------------------------------------------------------------- -@SHORT_OPTIONS_CLUSTERING_EXAMPLE@ -+---------------------------------------------------------------------------------------- - - If one of the short options can accept an argument, the remaining characters are interpreted - as the argument for that option. - -+---------------------------------------------------------------------------------------- -@SHORT_OPTIONS_CLUSTERING_WITH_ARGUMENT_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -* Long Options/Fluent Interface - - Long options begin with two hyphens (<<<-->>>), followed by multiple letters, - digits, hyphens, question marks, or dots. A hyphen cannot be the first character of - a long option specification when configuring the parser. - - Whereas short options can be configured using a constructor argument to - <<<OptionParser>>>, both long and short options can be configured using a "fluent - interface" API, that enables some very descriptive and powerful features. - -+---------------------------------------------------------------------------------------- -@LONG_OPTIONS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Arguments of Options - - Like short options, long options can accept single arguments. The argument can be - made required or optional. Use the methods <<<withRequiredArg()>>> and - <<<withOptionalArg()>>> on the return value of <<<OptionParser.accepts()>>> to signal - that an option takes a required or optional argument. - -+---------------------------------------------------------------------------------------- -@LONG_OPTIONS_WITH_ARGUMENTS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Abbreviating Long Options - - Notice in the example above that the command line uses abbreviations of command line - options. You can abbreviate options so long as the abbreviation is unambiguous. - Even though you can abbreviate the options on the command line, you cannot address - the <<<OptionSet>>> using those abbreviations. You can use a special constructor - for the <<<OptionParser>>> that turns off abbreviation matching. - -** Using Single Hyphen on Long Options - - As demonstrated in the example above, you can use a single hyphen instead of a - double hyphen to specify a long option -- but be careful that doing so doesn't - introduce ambiguity. - -*** Specifying Arguments for a Long Option on the Command Line - - A long option's argument can occur: - - * in the position on the command line after the option - - * right up against the option separated by an equals sign (<<<=>>>) - - [] - -+---------------------------------------------------------------------------------------- -@LONG_OPTIONS_WITH_ARGUMENT_POSITIONING_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -*** Multiple Arguments for a Single Option - - Specify multiple arguments for a long option in the same manner as for short options - (see above). - -** Alternative Form of Long Options - - The option <<<-W>>> is reserved. If you tell the parser to recognize alternative - long options, then it will treat, for example, <<<-W foo=bar>>> as the long option - <<<foo>>> with argument bar, as though you had written <<<--foo=bar>>>. - - You can specify <<<-W>>> as a valid short option, or use it as an abbreviation for a - long option, but recognizing alternative long options will always supersede this - behavior. - - To recognize alternative long options, either construct an <<<OptionParser>>> with a - string of short option characters containing the sequence <<<W;>>> (a capital W - followed by a semicolon), or call the method - <<<OptionParser.recognizeAlternativeLongOptions()>>>. - -+---------------------------------------------------------------------------------------- -@ALTERNATIVE_LONG_OPTIONS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -* Other Features - -** Converting Option Arguments to Other Types - - Without action other than the <<<with*Arg()>>> methods, arguments of options are - returned as <<<String>>>s. For backwards compatibility, - <<<OptionSet.valueOf(String)>>> and <<<OptionSet.valuesOf(String)>>> return - <<<Object>>> and <<<List<?>>>>, respectively, so to get the values out as - <<<String>>>s, you will need to downcast the results of those methods. - - You can tell JOpt Simple to convert the arguments of options to different Java types - via the <<<ofType()>>> method on the return value of <<<with*Arg()>>>. The - <<<Class>>> argument of <<<ofType()>>> must represent a Java class that has either: - - * a <<<public static>>> method called <<<valueOf()>>> which accepts a single - <<<String>>> argument and whose return type is the type itself, or - - * a <<<public>>> constructor which takes a single <<<String>>> argument. - - [] - - If the class has both, the <<<valueOf()>>> method is used. - - Note that <<<enum>>>s have a <<<valueOf()>>> method. - -+---------------------------------------------------------------------------------------- -@OPTION_ARGUMENT_VALUE_TYPE_EXAMPLE@ -+---------------------------------------------------------------------------------------- - - Another way to convert arguments of options is to specify a converter object via - <<<withValuesConvertedBy()>>>. This is useful when the desired type for the arguments - does not meet the requirements that <<<ofType()>>> sets forth. Such objects may not - perform any "conversion" at all, but rather can validate that arguments conform to - certain restrictions before passing through as-is. - - You can also do this for the non-option arguments of your command line, if you desire - to treat them all as a single type. - -+---------------------------------------------------------------------------------------- -@OPTION_ARGUMENT_CONVERTER_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Retrieving Arguments of Options in a Type-Safe Manner - - In the previous examples, we have been discarding the return values of the methods - of JOpt Simple's fluent interface. If instead you retain them in variables of type - <<<OptionSpec>>>, you can use them to retrieve arguments of options in a type-safe - manner. - - You can also do this for the non-option arguments of your command line, if you desire - to treat them all as a single type. - -+---------------------------------------------------------------------------------------- -@TYPESAFE_OPTION_ARGUMENT_RETRIEVAL_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Exporting Options and Arguments to other Code - - As an integration aid for other libraries, you can use <<<OptionSet.asMap()>>> to - obtain a mapping of <<<OptionSpec>>> to option values, for example to create a - properties map of options. - - Here is sample code to create properties whose keys have a common prefix. The key is - choosen as the first non-short option: - -+---------------------------------------------------------------------------------------- -@EXPORTING_OPTIONS_AND_ARGUMENTS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Default Values for Option Arguments - - Often it is convenient to specify default values for the arguments of certain - command line options. To do this, call the <<<defaultsTo()>>> method. - -+---------------------------------------------------------------------------------------- -@DEFAULT_VALUES_FOR_OPTION_ARGUMENTS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - - You can see that <<<defaultsTo()>>> should relieve you of the burden of having to - check <<<has()>>> and/or <<<hasArgument()>>> on an <<<OptionSet>>> for a given option, - and has no bearing on the return values of those methods. Specifying a default value - for an option with a required argument does not mean that you can elide an argument for - the option on the command line. - - The type of values <<<defaultsTo()>>> expects is dictated by the class given by a - previous call to <<<ofType()>>> or <<<withValuesConvertedBy()>>>; if no such call has - been made, the type is <<<String>>>. - -** "Required" Options - - You can indicate that a given option must be present on the command line via the - <<<required()>>> method. Only options that accept arguments can be made "required". - - An option designated as a "help" option via <<<forHelp()>>>, when present on the - command line, causes missing "required" options not to reject the command line. - -+---------------------------------------------------------------------------------------- -@REQUIRED_OPTIONS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** "Required" Dependent Options - - You can indicate that a given option must be present on the command line if some - other option is present on the command line via the <<<requiredIf()>>> method. - Any option can be made "required if". - - An option designated as a "help" option via <<<forHelp()>>>, when present on the - command line, causes missing "required if" options not to reject the command line. - -+---------------------------------------------------------------------------------------- -@REQUIRED_IF_OPTIONS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - - You can also indicate that a given option must be present on the command line if some - other option is NOT present on the command line via the <<<requiredUnless()>>> method. - Any option can be made "required unless", but, to avoid potential conflicts, it should - not be "required if" at the same time. - -+---------------------------------------------------------------------------------------- -@REQUIRED_UNLESS_OPTIONS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** "Available" Dependent Options - - Similarly to <<<requiredIf()>>> and <<<requiredUnless()>>>, you can indicate that a - given option can be present on the command line only if/unless some other option is - present on the command line, via the <<<availableIf()>>> and <<<availableUnless()>>> - methods. - - -** Synonyms of Options - - Sometimes it is useful to allow many different options to share the same meaning in - the program that uses them. To specify that options are to be treated as synonymous, - use the <<<acceptsAll()>>> method of <<<OptionParser>>>. - -+---------------------------------------------------------------------------------------- -@OPTION_SYNONYM_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Concise Specification of Multiple Arguments for an Option - - Another way to specify multiple arguments for an option is to tell the parser to - treat a single argument containing multiple delimited values as multiple arguments - for the option using the <<<withValuesSeparatedBy()>>> method. - -+---------------------------------------------------------------------------------------- -@MULTIPLE_DELIMITED_ARGUMENTS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Signalling End of Options - - An argument consisting only of two hyphens (<<<-->>>) signals that the remaining - arguments are to be treated as non-options. - - An argument consisting only of a single hyphen is considered a non-option argument - (though it can be an argument of an option). Many Unix programs treat single hyphens - as stand-ins for the standard input or standard output stream. - -*** Non-Option Arguments - - Any arguments which are not options or arguments of options can be retrieved via - method <<<nonOptionArguments()>>> on <<<OptionSet>>>. If the double hyphen is an - argument, it is ignored and is not a non-option argument. - -+---------------------------------------------------------------------------------------- -@SIGNALLING_END_OF_OPTIONS_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** "POSIX-ly Correct"-ness - - By default, as with GNU <<<getopt()>>>, JOpt Simple allows intermixing of options and - non-options. If, however, the parser has been created to be "POSIX-ly correct", then - the first argument that does not look lexically like an option, and is not a required - argument of a preceding option, signals the end of options. You can still bind - optional arguments to their options using the abutting (for short options) or - <<<=>>> syntax. - - Unlike GNU <<<getopt()>>>, JOptSimple does not honor the environment variable - <<<POSIXLY_CORRECT>>>. "POSIX-ly correct" parsers are configured by either: - - * using the method <<<OptionParser.posixlyCorrect()>>> - - * using the <<<OptionParser>>> constructor with an argument whose first character is - a plus sign (<<<+>>>) - - [] - -+---------------------------------------------------------------------------------------- -@POSIXLY_CORRECT_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -** Special Optional Argument Handling - - If the parser detects an option whose argument is optional, and the next argument - "looks like" an option, that argument is not treated as the argument to the option, - but as a potentially valid option. If, on the other hand, the optional argument is - typed as a derivative of <<<Number>>>, then that argument is treated as the negative - number argument of the option, even if the parser recognizes the corresponding numeric - option. - -+---------------------------------------------------------------------------------------- -@SPECIAL_OPTIONAL_ARGUMENT_HANDLING_EXAMPLE@ -+---------------------------------------------------------------------------------------- - -Generating Command Line Help - - When you call method <<<OptionParser.printHelpOn()>>>, JOpt Simple will write a - help screen (80-column width) describing all the options it is configured with, - along with types of option arguments, whether the option is required (in angle - brackets) or optional (in square brackets), etc. To give an option a description, - use <<<OptionParser.accepts*()>>> with a description argument. To give an option - argument a description, use <<<describedAs()>>> on the return value of - <<<with*Arg()>>>. - -+---------------------------------------------------------------------------------------- -@HELP_SCREEN_EXAMPLE@ -+---------------------------------------------------------------------------------------- - - Here is what the help screen looks like for the example above: - -+---------------------------------------------------------------------------------------- -@HELP_SCREEN_EXAMPLE_HELP@ -+---------------------------------------------------------------------------------------- - - If you want to create your own help screen, give method - <<<OptionParser.formatHelpWith()>>> a <<<HelpFormatter>>> that builds the help screen - as a String. When you call <<<OptionParser.printHelpOn()>>>, JOpt Simple will use - your <<<HelpFormatter>>> to produce the help and write it to the given stream. - - For example, this program: - -+---------------------------------------------------------------------------------------- -@HELP_FORMATTER_EXAMPLE@ -+---------------------------------------------------------------------------------------- - - yields the following output: - -+---------------------------------------------------------------------------------------- -@HELP_FORMATTER_EXAMPLE_OUTPUT@ -+---------------------------------------------------------------------------------------- - -Handling Exceptions - - JOpt Simple's classes raise some derivative of <<<OptionException>>> if they encounter - problems during parsing. These exceptions are unchecked, so you don't have to do - anything with such an exception if you don't want to. The rationale behind this - decision is that you will most likely be invoking JOpt Simple's functionality from a - <<<main()>>> method or very near to it, where a failure such as unrecognized arguments - can just stop down the JVM and yield a stack trace without much user or programmer - inconvenience. So, without any exception handling at all, a user would see something - like this: - -+---------------------------------------------------------------------------------------- -@EXAMPLE_STACK_TRACE@ -+---------------------------------------------------------------------------------------- - - If you want to handle the exception yourself, you can catch <<<OptionException>>> in - your code, and do whatever you please with the contents of the exception, perhaps - using the help generation facility. - -* Suppressing <<<UnrecognizedOptionException>>> - - Sometimes you want to ignore unrecognized options on the command line. - - For example, you might be interested in handling only a part of the arguments given. - Or you might want to pass on options to another program and not bother the user with - providing two hyphens (<<<-->>>) to indicate the end of known options. Or maybe - you want to provide future forwards/backwards compatibility when you foresee passing - in new options to old code (or old code invoking new code with "old" arguments). - - You can achieve this by using the method <<<OptionParser.allowsUnrecognizedOptions()>>>. - When you call this method, then any unrecognized options handed to <<<parse()>>> are - treated as non-option arguments, rather than causing an exception to be raised. - -+---------------------------------------------------------------------------------------- -@UNRECOGNIZED_OPTIONS_ALLOWED_EXAMPLE@ -+---------------------------------------------------------------------------------------- diff --git a/third_party/java/jopt-simple/src/site/apt/index.apt b/third_party/java/jopt-simple/src/site/apt/index.apt deleted file mode 100644 index 88c2af858d..0000000000 --- a/third_party/java/jopt-simple/src/site/apt/index.apt +++ /dev/null @@ -1,71 +0,0 @@ - ----------- - JOpt Simple - ----------- - - JOpt Simple is a Java library for parsing command line options, such as those you - might pass to an invocation of <<<javac>>>. - - In the interest of striving for simplicity, as closely as possible JOpt Simple - attempts to honor the command line option syntaxes of - {{{http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html} POSIX <<<getopt()>>>}} - and - GNU {{{http://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html} <<<getopt_long()>>>}}. - It also aims to make option parser configuration and retrieval of options and their - arguments simple and expressive, without being overly clever. - - Here are some libraries that perform the same duties as JOpt Simple: - - * {{{http://jargs.sourceforge.net} JArgs}} - - * {{{http://jakarta.apache.org/commons/cli/} Jakarta Commons CLI}} - - * {{{http://te-code.sourceforge.net/} TE-Code}} has a command line parsing library. - - * {{{http://www.cs.ubc.ca/spider/lloyd/java/argparser.html} argparser}} - - * {{{http://www.urbanophile.com/arenn/hacking/download.html} Java port of GNU getopt}} - - * {{{https://args4j.dev.java.net/} Args4J}} - - * {{{http://www.martiansoftware.com/jsap/} JSAP}} - - * {{{http://clajr.sourceforge.net} CLAJR}} - - * {{{http://ostermiller.org/utils/CmdLn.html} CmdLn}} - - * {{{http://jewelcli.sourceforge.net} JewelCli}} - - * {{{http://jcommando.sourceforge.net} JCommando}} - - * {{{http://code.google.com/p/parse-cmd/} parse-cmd}} - - * {{{http://jcommander.org} JCommander}} - - * {{{http://types.cs.washington.edu/plume-lib/api/plume/Options.html} plume-lib Options}} - - [] - - I hope you'll agree that JOpt Simple tops them all in ease of use and cleanliness of - code (although I admire JewelCli quite a bit). - - I'd love to hear your constructive {{{mailto:pholser@alumni.rice.edu} feedback}}, - especially suggestions for improvements to the library or the site! If your project - is using JOpt Simple, do let me know. - -Projects Using JOpt Simple - - Here are some we know of or have known of: - - * {{{http://openjdk.java.net/} OpenJDK}}. - From {{{http://weblogs.java.net/blog/mreinhold/} Mark Reinhold}}: "I thought you might - be interested to know that we're using your jopt-simple library in the open-source - Java Development Kit. Thanks for writing such a nice little library! It's far - cleaner than any of the other alternatives out there." - - * {{{http://www.gradle.org/} Gradle}} - - * {{{http://natbraille.free.fr} NATBraille}} - - * {{{https://minecraft.net} Minecraft}} - - [] diff --git a/third_party/java/jopt-simple/src/site/resources/css/prettify.css b/third_party/java/jopt-simple/src/site/resources/css/prettify.css deleted file mode 100644 index f8c7db2a96..0000000000 --- a/third_party/java/jopt-simple/src/site/resources/css/prettify.css +++ /dev/null @@ -1,49 +0,0 @@ -/* Pretty printing styles. Used with prettify.js. */ - -.str { color: #080; } -.kwd { color: #008; } -.com { color: #800; } -.typ { color: #606; } -.lit { color: #066; } -.pun { color: #660; } -.pln { color: #000; } -.tag { color: #008; } -.atn { color: #606; } -.atv { color: #080; } -.dec { color: #606; } - -pre.prettyprint { - padding: 2px; - border: 1px solid #888; -} - -@media print { - .str { color: #060; } - - .kwd { - color: #006; - font-weight: bold; - } - - .com { - color: #600; - font-style: italic; - } - - .typ { - color: #404; - font-weight: bold; - } - - .lit { color: #044; } - .pun { color: #440; } - .pln { color: #000; } - - .tag { - color: #006; - font-weight: bold; - } - - .atn { color: #404; } - .atv { color: #060; } -} diff --git a/third_party/java/jopt-simple/src/site/resources/images/jopt-simple-logo.png b/third_party/java/jopt-simple/src/site/resources/images/jopt-simple-logo.png Binary files differdeleted file mode 100644 index 4a3f707d7a..0000000000 --- a/third_party/java/jopt-simple/src/site/resources/images/jopt-simple-logo.png +++ /dev/null diff --git a/third_party/java/jopt-simple/src/site/resources/scripts/prettify.js b/third_party/java/jopt-simple/src/site/resources/scripts/prettify.js deleted file mode 100644 index de1e07ffd3..0000000000 --- a/third_party/java/jopt-simple/src/site/resources/scripts/prettify.js +++ /dev/null @@ -1,1602 +0,0 @@ -// Copyright (C) 2006 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -/** - * @fileoverview - * some functions for browser-side pretty printing of code contained in html. - * - * The lexer should work on a number of languages including C and friends, - * Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. - * It works passably on Ruby, PHP and Awk and a decent subset of Perl, but, - * because of commenting conventions, doesn't work on Smalltalk, Lisp-like, or - * CAML-like languages. - * - * If there's a language not mentioned here, then I don't know it, and don't - * know whether it works. If it has a C-like, Bash-like, or XML-like syntax - * then it should work passably. - * - * Usage: - * 1) include this source file in an html page via - * <script type="text/javascript" src="/path/to/prettify.js"></script> - * 2) define style rules. See the example page for examples. - * 3) mark the <pre> and <code> tags in your source with class=prettyprint. - * You can also use the (html deprecated) <xmp> tag, but the pretty printer - * needs to do more substantial DOM manipulations to support that, so some - * css styles may not be preserved. - * That's it. I wanted to keep the API as simple as possible, so there's no - * need to specify which language the code is in. - * - * Change log: - * cbeust, 2006/08/22 - * Java annotations (start with "@") are now captured as literals ("lit") - */ - -var PR_keywords = {}; -/** initialize the keyword list for our target languages. */ -(function () { - var CPP_KEYWORDS = "abstract bool break case catch char class const " + - "const_cast continue default delete deprecated dllexport dllimport do " + - "double dynamic_cast else enum explicit extern false float for friend " + - "goto if inline int long mutable naked namespace new noinline noreturn " + - "nothrow novtable operator private property protected public register " + - "reinterpret_cast return selectany short signed sizeof static " + - "static_cast struct switch template this thread throw true try typedef " + - "typeid typename union unsigned using declaration, directive uuid " + - "virtual void volatile while typeof"; - var CSHARP_KEYWORDS = "as base by byte checked decimal delegate descending " + - "event finally fixed foreach from group implicit in interface internal " + - "into is lock null object out override orderby params readonly ref sbyte " + - "sealed stackalloc string select uint ulong unchecked unsafe ushort var"; - var JAVA_KEYWORDS = "package synchronized boolean implements import throws " + - "instanceof transient extends final strictfp native super"; - var JSCRIPT_KEYWORDS = "debugger export function with NaN Infinity"; - var PERL_KEYWORDS = "require sub unless until use elsif BEGIN END"; - var PYTHON_KEYWORDS = "and assert def del elif except exec global lambda " + - "not or pass print raise yield False True None"; - var RUBY_KEYWORDS = "then end begin rescue ensure module when undef next " + - "redo retry alias defined"; - var SH_KEYWORDS = "done fi"; - - var KEYWORDS = [CPP_KEYWORDS, CSHARP_KEYWORDS, JAVA_KEYWORDS, - JSCRIPT_KEYWORDS, PERL_KEYWORDS, PYTHON_KEYWORDS, - RUBY_KEYWORDS, SH_KEYWORDS]; - for ( var k = 0; k < KEYWORDS.length; k++ ) { - var kw = KEYWORDS[k].split(' '); - for ( var i = 0; i < kw.length; i++ ) { - if ( kw[i] ) { - PR_keywords[kw[i]] = true; - } - } - } -}).call(this); - -// token style names. correspond to css classes -/** token style for a string literal */ -var PR_STRING = 'str'; -/** token style for a keyword */ -var PR_KEYWORD = 'kwd'; -/** token style for a comment */ -var PR_COMMENT = 'com'; -/** token style for a type */ -var PR_TYPE = 'typ'; -/** token style for a literal value. e.g. 1, null, true. */ -var PR_LITERAL = 'lit'; -/** token style for a punctuation string. */ -var PR_PUNCTUATION = 'pun'; -/** token style for a punctuation string. */ -var PR_PLAIN = 'pln'; - -/** token style for an sgml tag. */ -var PR_TAG = 'tag'; -/** token style for a markup declaration such as a DOCTYPE. */ -var PR_DECLARATION = 'dec'; -/** token style for embedded source. */ -var PR_SOURCE = 'src'; -/** token style for an sgml attribute name. */ -var PR_ATTRIB_NAME = 'atn'; -/** token style for an sgml attribute value. */ -var PR_ATTRIB_VALUE = 'atv'; - -/** the number of characters between tab columns */ -var PR_TAB_WIDTH = 8; - -/** the position of the end of a token during. A division of a string into - * n tokens can be represented as a series n - 1 token ends, as long as - * runs of whitespace warrant their own token. - * @private - */ -function PR_TokenEnd( end, style ) { - if ( undefined === style ) { - throw new Error('BAD'); - } - if ( 'number' != typeof(end) ) { - throw new Error('BAD'); - } - this.end = end; - this.style = style; -} -PR_TokenEnd.prototype.toString = function () { - return '[PR_TokenEnd ' + this.end + - (this.style ? ':' + this.style : '') + ']'; -}; - -/** a chunk of text with a style. These are used to represent both the output - * from the lexing functions as well as intermediate results. - * @constructor - * @param token the token text - * @param style one of the token styles defined in designdoc-template, or null - * for a styleless token, such as an embedded html tag. - * @private - */ -function PR_Token( token, style ) { - if ( undefined === style ) { - throw new Error('BAD'); - } - this.token = token; - this.style = style; -} - -PR_Token.prototype.toString = function () { - return '[PR_Token ' + this.token + (this.style ? ':' + this.style : '') + ']'; -}; - -/** a helper class that decodes common html entities used to escape special - * characters in source code. - * @constructor - * @private - */ -function PR_DecodeHelper() { - this.next = 0; - this.ch = '\0'; -} - -var PR_NAMED_ENTITIES = { - 'lt': '<', - 'gt': '>', - 'quot': '"', - 'apos': "'", - 'amp': '&' // reencoding requires that & always be decoded properly -}; - -PR_DecodeHelper.prototype.decode = function ( s, i ) { - var next = i + 1; - var ch = s.charAt(i); - if ( '&' === ch ) { - var semi = s.indexOf(';', next); - if ( semi >= 0 && semi < next + 4 ) { - var entityName = s.substring(next, semi); - var decoded = null; - if ( entityName.charAt(0) === '#' ) { // check for numeric entity - var ch1 = entityName.charAt(1); - var charCode; - if ( ch1 === 'x' || ch1 === 'X' ) { // like   - charCode = parseInt(entityName.substring(2), 16); - } - else { // like   - charCode = parseInt(entityName.substring(1), 10); - } - if ( !isNaN(charCode) ) { - decoded = String.fromCharCode(charCode); - } - } - if ( !decoded ) { - decoded = PR_NAMED_ENTITIES[entityName.toLowerCase()]; - } - if ( decoded ) { - ch = decoded; - next = semi + 1; - } - else { // skip over unrecognized entity - next = i + 1; - ch = '\0'; - } - } - } - this.next = next; - this.ch = ch; - return this.ch; -}; - -// some string utilities -function PR_isWordChar( ch ) { - return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); -} - -function PR_isIdentifierStart( ch ) { - return PR_isWordChar(ch) || ch == '_' || ch == '$' || ch == '@'; -} - -function PR_isIdentifierPart( ch ) { - return PR_isIdentifierStart(ch) || PR_isDigitChar(ch); -} - -function PR_isSpaceChar( ch ) { - return "\t \r\n".indexOf(ch) >= 0; -} - -function PR_isDigitChar( ch ) { - return ch >= '0' && ch <= '9'; -} - -function PR_trim( s ) { - var i = 0, j = s.length - 1; - while ( i <= j && PR_isSpaceChar(s.charAt(i)) ) { - ++i; - } - while ( j > i && PR_isSpaceChar(s.charAt(j)) ) { - --j; - } - return s.substring(i, j + 1); -} - -function PR_startsWith( s, prefix ) { - return s.length >= prefix.length && prefix == s.substring(0, prefix.length); -} - -function PR_endsWith( s, suffix ) { - return s.length >= suffix.length && - suffix == s.substring(s.length - suffix.length, s.length); -} - -/** true iff prefix matches the first prefix characters in chars[0:len]. - * @private - */ -function PR_prefixMatch( chars, len, prefix ) { - if ( len < prefix.length ) { - return false; - } - for ( var i = 0, n = prefix.length; i < n; ++i ) { - if ( prefix.charAt(i) != chars[i] ) { - return false; - } - } - return true; -} - -/** like textToHtml but escapes double quotes to be attribute safe. */ -function PR_attribToHtml( str ) { - return str.replace(/&/g, '&') - .replace(/</g, '<') - .replace(/>/g, '>') - .replace(/\"/g, '"') - .replace(/\xa0/, ' '); -} - -/** escapest html special characters to html. */ -function PR_textToHtml( str ) { - return str.replace(/&/g, '&') - .replace(/</g, '<') - .replace(/>/g, '>') - .replace(/\xa0/g, ' '); -} - -/** is the given node's innerHTML normally unescaped? */ -function PR_isRawContent( node ) { - return 'XMP' == node.tagName; -} - -var PR_innerHtmlWorks = null; -function PR_getInnerHtml( node ) { - // inner html is hopelessly broken in Safari 2.0.4 when the content is - // an html description of well formed XML and the containing tag is a PRE - // tag, so we detect that case and emulate innerHTML. - if ( null == PR_innerHtmlWorks ) { - var testNode = document.createElement('PRE'); - testNode.appendChild( - document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />')); - PR_innerHtmlWorks = !/</.test(testNode.innerHTML); - } - - if ( PR_innerHtmlWorks ) { - var content = node.innerHTML; - // XMP tags contain unescaped entities so require special handling. - if ( PR_isRawContent(node) ) { - content = PR_textToHtml(content); - } - return content; - } - - var out = []; - for ( var child = node.firstChild; child; child = child.nextSibling ) { - PR_normalizedHtml(child, out); - } - return out.join(''); -} - -/** - * walks the DOM returning a properly escaped version of innerHTML. - */ -function PR_normalizedHtml( node, out ) { - switch ( node.nodeType ) { - case 1: // an element - var name = node.tagName.toLowerCase(); - out.push('\074', name); - for ( var i = 0; i < node.attributes.length; ++i ) { - var attr = node.attributes[i]; - if ( !attr.specified ) { - continue; - } - out.push(' '); - PR_normalizedHtml(attr, out); - } - out.push('>'); - for ( var child = node.firstChild; child; child = child.nextSibling ) { - PR_normalizedHtml(child, out); - } - if ( node.firstChild || !/^(?:br|link|img)$/.test(name) ) { - out.push('<\/', name, '>'); - } - break; - case 2: // an attribute - out.push(node.name.toLowerCase(), '="', PR_attribToHtml(node.value), '"'); - break; - case 3: case 4: // text - out.push(PR_textToHtml(node.nodeValue)); - break; - } -} - -/** expand tabs to spaces - * @param {Array} chunks PR_Tokens possibly containing tabs - * @param {Number} tabWidth number of spaces between tab columns - * @return {Array} chunks with tabs replaced with spaces - */ -function PR_expandTabs( chunks, tabWidth ) { - var SPACES = ' '; - - var charInLine = 0; - var decodeHelper = new PR_DecodeHelper(); - - var chunksOut = [] - for ( var chunkIndex = 0; chunkIndex < chunks.length; ++chunkIndex ) { - var chunk = chunks[chunkIndex]; - if ( chunk.style == null ) { - chunksOut.push(chunk); - continue; - } - - var s = chunk.token; - var pos = 0; - // index of last character output - var out = []; - - // walk over each character looking for tabs and newlines. - // On tabs, expand them. On newlines, reset charInLine. - // Otherwise increment charInLine - for ( var charIndex = 0, n = s.length; charIndex < n; - charIndex = decodeHelper.next ) { - decodeHelper.decode(s, charIndex); - var ch = decodeHelper.ch; - - switch ( ch ) { - case '\t': - out.push(s.substring(pos, charIndex)); - // calculate how much space we need in front of this part - // nSpaces is the amount of padding -- the number of spaces needed to - // move us to the next column, where columns occur at factors of - // tabWidth. - var nSpaces = tabWidth - (charInLine % tabWidth); - charInLine += nSpaces; - for ( ; nSpaces >= 0; nSpaces -= SPACES.length ) { - out.push(SPACES.substring(0, nSpaces)); - } - pos = decodeHelper.next; - break; - case '\n': case '\r': - charInLine = 0; - break; - default: - ++charInLine; - } - } - out.push(s.substring(pos)); - chunksOut.push(new PR_Token(out.join(''), chunk.style)); - } - return chunksOut -} - -/** split markup into chunks of html tags (style null) and - * plain text (style {@link #PR_PLAIN}). - * - * @param {String} s html. - * @return {Array} of PR_Tokens of style PR_PLAIN, and null. - * @private - */ -function PR_chunkify( s ) { - // The below pattern matches one of the following - // (1) /[^<]+/ : A run of characters other than '<' - // (2) /<\/?[a-zA-Z][^>]*>/ : A probably tag that should not be highlighted - // (3) /</ : A '<' that does not begin a larger chunk. Treated as 1 - var chunkPattern = /(?:[^<]+|<\/?[a-zA-Z][^>]*>|<)/g; - // since the pattern has the 'g' modifier and defines no capturing groups, - // this will return a list of all chunks which we then classify and wrap as - // PR_Tokens - var matches = s.match(chunkPattern); - var chunks = []; - if ( matches ) { - var lastChunk = null; - for ( var i = 0, n = matches.length; i < n; ++i ) { - var chunkText = matches[i]; - var style; - if ( chunkText.length < 2 || chunkText.charAt(0) !== '<' ) { - if ( lastChunk && lastChunk.style === PR_PLAIN ) { - lastChunk.token += chunkText; - continue; - } - style = PR_PLAIN; - } - else { // a tag - style = null; - } - lastChunk = new PR_Token(chunkText, style); - chunks.push(lastChunk); - } - } - return chunks; -} - -/** walk the tokenEnds list and the chunk list in parallel to generate a list - * of split tokens. - * @private - */ -function PR_splitChunks( chunks, tokenEnds ) { - var tokens = []; - // the output - - var ci = 0; - // index into chunks - // position of beginning of amount written so far in absolute space. - var posAbs = 0; - // position of amount written so far in chunk space - var posChunk = 0; - - // current chunk - var chunk = new PR_Token('', null); - - for ( var ei = 0, ne = tokenEnds.length, lastEnd = 0; ei < ne; ++ei ) { - var tokenEnd = tokenEnds[ei]; - var end = tokenEnd.end; - if ( end === lastEnd ) { - continue; - } // skip empty regions - - var tokLen = end - posAbs; - var remainingInChunk = chunk.token.length - posChunk; - while ( remainingInChunk <= tokLen ) { - if ( remainingInChunk > 0 ) { - tokens.push( - new PR_Token(chunk.token.substring(posChunk, chunk.token.length), - null == chunk.style ? null : tokenEnd.style)); - } - posAbs += remainingInChunk; - posChunk = 0; - if ( ci < chunks.length ) { - chunk = chunks[ci++]; - } - - tokLen = end - posAbs; - remainingInChunk = chunk.token.length - posChunk; - } - - if ( tokLen ) { - tokens.push( - new PR_Token(chunk.token.substring(posChunk, posChunk + tokLen), - tokenEnd.style)); - posAbs += tokLen; - posChunk += tokLen; - } - } - - return tokens; -} - -/** splits markup tokens into declarations, tags, and source chunks. - * @private - */ -function PR_splitMarkup( chunks ) { - // A state machine to split out declarations, tags, etc. - // This state machine deals with absolute space in the text, indexed by k, - // and position in the current chunk, indexed by pos and tokenStart to - // generate a list of the ends of tokens. - // Absolute space is calculated by considering the chunks as appended into - // one big string, as they were before being split. - - // Known failure cases - // Server side scripting sections such as <?...?> in attributes. - // i.e. <span class="<? foo ?>"> - // Handling this would require a stack, and we don't use PHP. - - // The output: a list of pairs of PR_TokenEnd instances - var tokenEnds = []; - - var state = 0; - // FSM state variable - var k = 0; - // position in absolute space of the start of the current chunk - var tokenStart = -1; - // the start of the current token - - // Try to find a closing tag for any open <style> or <script> tags - // We can't do this at a later stage because then the following case - // would fail: - // <script>document.writeln('<!--');</script> - - // We use tokenChars[:tokenCharsI] to accumulate the tag name so that we - // can check whether to enter into a no scripting section when the tag ends. - var tokenChars = new Array(12); - var tokenCharsI = 0; - // if non null, the tag prefix that we need to see to break out. - var endScriptTag = null; - var decodeHelper = new PR_DecodeHelper(); - - for ( var ci = 0, nc = chunks.length; ci < nc; ++ci ) { - var chunk = chunks[ci]; - if ( PR_PLAIN != chunk.style ) { - k += chunk.token.length; - continue; - } - - var s = chunk.token; - var pos = 0; - // the position past the last character processed so far in s - - for ( var i = 0, n = s.length; i < n; /* i = next at bottom */ ) { - decodeHelper.decode(s, i); - var ch = decodeHelper.ch; - var next = decodeHelper.next; - - var tokenStyle = null; - switch ( state ) { - case 0: - if ( '<' == ch ) { - state = 1; - } - break; - case 1: - tokenCharsI = 0; - if ( '/' == ch ) { // only consider close tags if we're in script/style - state = 7; - } - else if ( null == endScriptTag ) { - if ( '!' == ch ) { - state = 2; - } - else if ( PR_isWordChar(ch) ) { - state = 8; - } - else if ( '?' == ch ) { - state = 9; - } - else if ( '%' == ch ) { - state = 11; - } - else if ( '<' != ch ) { - state = 0; - } - } - else if ( '<' != ch ) { - state = 0; - } - break; - case 2: - if ( '-' == ch ) { - state = 4; - } - else if ( PR_isWordChar(ch) ) { - state = 3; - } - else if ( '<' == ch ) { - state = 1; - } - else { - state = 0; - } - break; - case 3: - if ( '>' == ch ) { - state = 0; - tokenStyle = PR_DECLARATION; - } - break; - case 4: - if ( '-' == ch ) { - state = 5; - } - break; - case 5: - if ( '-' == ch ) { - state = 6; - } - break; - case 6: - if ( '>' == ch ) { - state = 0; - tokenStyle = PR_COMMENT; - } - else if ( '-' == ch ) { - state = 6; - } - else { - state = 4; - } - break; - case 7: - if ( PR_isWordChar(ch) ) { - state = 8; - } - else if ( '<' == ch ) { - state = 1; - } - else { - state = 0; - } - break; - case 8: - if ( '>' == ch ) { - state = 0; - tokenStyle = PR_TAG; - } - break; - case 9: - if ( '?' == ch ) { - state = 10; - } - break; - case 10: - if ( '>' == ch ) { - state = 0; - tokenStyle = PR_SOURCE; - } - else if ( '?' != ch ) { - state = 9; - } - break; - case 11: - if ( '%' == ch ) { - state = 12; - } - break; - case 12: - if ( '>' == ch ) { - state = 0; - tokenStyle = PR_SOURCE; - } - else if ( '%' != ch ) { - state = 11; - } - break; - } - - if ( tokenCharsI < tokenChars.length ) { - tokenChars[tokenCharsI++] = ch.toLowerCase(); - } - if ( 1 == state ) { - tokenStart = k + i; - } - i = next; - if ( tokenStyle != null ) { - if ( null != tokenStyle ) { - if ( endScriptTag ) { - if ( PR_prefixMatch(tokenChars, tokenCharsI, endScriptTag) ) { - endScriptTag = null; - } - } - else { - if ( PR_prefixMatch(tokenChars, tokenCharsI, 'script') ) { - endScriptTag = '/script'; - } - else if ( PR_prefixMatch(tokenChars, tokenCharsI, 'style') ) { - endScriptTag = '/style'; - } - else if ( PR_prefixMatch(tokenChars, tokenCharsI, 'xmp') ) { - endScriptTag = '/xmp'; - } - } - // disallow the tag if endScriptTag is set and this was not an open - // tag. - if ( endScriptTag && tokenCharsI && '/' == tokenChars[0] ) { - tokenStyle = null; - } - } - if ( null != tokenStyle ) { - tokenEnds.push(new PR_TokenEnd(tokenStart, PR_PLAIN)); - tokenEnds.push(new PR_TokenEnd(k + next, tokenStyle)); - } - } - } - k += chunk.token.length; - } - tokenEnds.push(new PR_TokenEnd(k, PR_PLAIN)); - - return tokenEnds; -} - -/** splits the given string into comment, string, and "other" tokens. - * @return {Array} of PR_Tokens with style in - * (PR_STRING, PR_COMMENT, PR_PLAIN, null) - * The result array may contain spurious zero length tokens. Ignore them. - * - * @private - */ -function PR_splitStringAndCommentTokens( chunks ) { - // a state machine to split out comments, strings, and other stuff - var tokenEnds = []; - // positions of ends of tokens in absolute space - var state = 0; - // FSM state variable - var delim = -1; - // string delimiter - var k = 0; - // absolute position of beginning of current chunk - - for ( var ci = 0, nc = chunks.length; ci < nc; ++ci ) { - var chunk = chunks[ci]; - var s = chunk.token; - if ( PR_PLAIN == chunk.style ) { - var decodeHelper = new PR_DecodeHelper(); - var last = -1; - var next; - for ( var i = 0, n = s.length; i < n; last = i,i = next ) { - decodeHelper.decode(s, i); - var ch = decodeHelper.ch; - next = decodeHelper.next; - if ( 0 == state ) { - if ( ch == '"' || ch == '\'' || ch == '`' ) { - tokenEnds.push(new PR_TokenEnd(k + i, PR_PLAIN)); - state = 1; - delim = ch; - } - else if ( ch == '/' ) { - state = 3; - } - else if ( ch == '#' ) { - tokenEnds.push(new PR_TokenEnd(k + i, PR_PLAIN)); - state = 4; - } - } - else if ( 1 == state ) { - if ( ch == delim ) { - state = 0; - tokenEnds.push(new PR_TokenEnd(k + next, PR_STRING)); - } - else if ( ch == '\\' ) { - state = 2; - } - } - else if ( 2 == state ) { - state = 1; - } - else if ( 3 == state ) { - if ( ch == '/' ) { - state = 4; - tokenEnds.push(new PR_TokenEnd(k + last, PR_PLAIN)); - } - else if ( ch == '*' ) { - state = 5; - tokenEnds.push(new PR_TokenEnd(k + last, PR_PLAIN)); - } - else { - state = 0; - // next loop will reenter state 0 without same value of i, so - // ch will be reconsidered as start of new token. - next = i; - } - } - else if ( 4 == state ) { - if ( ch == '\r' || ch == '\n' ) { - state = 0; - tokenEnds.push(new PR_TokenEnd(k + i, PR_COMMENT)); - } - } - else if ( 5 == state ) { - if ( ch == '*' ) { - state = 6; - } - } - else if ( 6 == state ) { - if ( ch == '/' ) { - state = 0; - tokenEnds.push(new PR_TokenEnd(k + next, PR_COMMENT)); - } - else if ( ch != '*' ) { - state = 5; - } - } - } - } - k += s.length; - } - var endTokenType; - switch ( state ) { - case 1: case 2: - endTokenType = PR_STRING; - break; - case 4: case 5: case 6: - endTokenType = PR_COMMENT; - break; - default: - endTokenType = PR_PLAIN; - break; - } - // handle unclosed token which can legally happen for line comments (state 4) - tokenEnds.push(new PR_TokenEnd(k, endTokenType)); - // a token ends at the end - - return PR_splitChunks(chunks, tokenEnds); -} - -/** used by lexSource to split a non string, non comment token. - * @private - */ -function PR_splitNonStringNonCommentToken( s, outlist ) { - var pos = 0; - var state = 0; - - var decodeHelper = new PR_DecodeHelper(); - var next; - for ( var i = 0; i <= s.length; i = next ) { - if ( i == s.length ) { - // nstate will not be equal to state, so it will append the token - nstate = -2; - next = i + 1; - } - else { - decodeHelper.decode(s, i); - next = decodeHelper.next; - var ch = decodeHelper.ch; - - // the next state. - // if set to -1 then it will cause a reentry to state 0 without consuming - // another character. - var nstate = state; - - switch ( state ) { - case 0: // whitespace state - if ( PR_isIdentifierStart(ch) ) { - nstate = 1; - } - else if ( PR_isDigitChar(ch) ) { - nstate = 2; - } - else if ( !PR_isSpaceChar(ch) ) { - nstate = 3; - } - if ( nstate && pos < i ) { - var t = s.substring(pos, i); - outlist.push(new PR_Token(t, PR_PLAIN)); - pos = i; - } - break; - case 1: // identifier state - if ( !PR_isIdentifierPart(ch) ) { - nstate = -1; - } - break; - case 2: // number literal state - // handle numeric literals like - // 0x7f 300UL 100_000 - - // this does not treat floating point values as a single literal - // 0.1 and 3e-6 - // are each split into multiple tokens - if ( !(PR_isDigitChar(ch) || PR_isWordChar(ch) || ch == '_') ) { - nstate = -1; - } - break; - case 3: // punctuation state - if ( PR_isIdentifierStart(ch) || PR_isDigitChar(ch) || - PR_isSpaceChar(ch) ) { - nstate = -1; - } - break; - } - } - - if ( nstate != state ) { - if ( nstate < 0 ) { - if ( i > pos ) { - var t = s.substring(pos, i); - var wordDecodeHelper = new PR_DecodeHelper(); - wordDecodeHelper.decode(t, 0); - var ch0 = wordDecodeHelper.ch; - var isSingleCharacter = wordDecodeHelper.next == t.length; - var style; - if ( PR_isIdentifierStart(ch0) ) { - if ( PR_keywords[t] ) { - style = PR_KEYWORD; - } - else if ( ch0 === '@' ) { - style = PR_LITERAL; - } - else { - // Treat any word that starts with an uppercase character and - // contains at least one lowercase character as a type, or - // ends with _t. - // This works perfectly for Java, pretty well for C++, and - // passably for Python. The _t catches C structs. - var isType = false; - if ( ch0 >= 'A' && ch0 <= 'Z' ) { - for ( var j = wordDecodeHelper.next; - j < t.length; j = wordDecodeHelper.next ) { - wordDecodeHelper.decode(t, j); - var ch1 = wordDecodeHelper.ch; - if ( ch1 >= 'a' && ch1 <= 'z' ) { - isType = true; - break; - } - } - if ( !isType && !isSingleCharacter && - t.substring(t.length - 2) == '_t' ) { - isType = true; - } - } - style = isType ? PR_TYPE : PR_PLAIN; - } - } - else if ( PR_isDigitChar(ch0) ) { - style = PR_LITERAL; - } - else if ( !PR_isSpaceChar(ch0) ) { - style = PR_PUNCTUATION; - } - else { - style = PR_PLAIN; - } - pos = i; - outlist.push(new PR_Token(t, style)); - } - - state = 0; - if ( nstate == -1 ) { - // don't increment. This allows us to use state 0 to redispatch based - // on the current character. - next = i; - continue; - } - } - state = nstate; - } - } - -} - -/** split a group of chunks of markup. - * @private - */ -function PR_tokenizeMarkup( chunks ) { - if ( !(chunks && chunks.length) ) { - return chunks; - } - - var tokenEnds = PR_splitMarkup(chunks); - return PR_splitChunks(chunks, tokenEnds); -} - -/** split tags attributes and their values out from the tag name, and - * recursively lex source chunks. - * @private - */ -function PR_splitTagAttributes( tokens ) { - var tokensOut = []; - var state = 0; - var stateStyle = PR_TAG; - var delim = null; - // attribute delimiter for quoted value state. - var decodeHelper = new PR_DecodeHelper(); - for ( var ci = 0; ci < tokens.length; ++ci ) { - var tok = tokens[ci]; - if ( PR_TAG == tok.style ) { - var s = tok.token; - var start = 0; - for ( var i = 0; i < s.length; /* i = next at bottom */ ) { - decodeHelper.decode(s, i); - var ch = decodeHelper.ch; - var next = decodeHelper.next; - - var emitEnd = null; - // null or position of end of chunk to emit. - var nextStyle = null; - // null or next value of stateStyle - if ( ch == '>' ) { - if ( PR_TAG != stateStyle ) { - emitEnd = i; - nextStyle = PR_TAG; - } - } - else { - switch ( state ) { - case 0: - if ( '<' == ch ) { - state = 1; - } - break; - case 1: - if ( PR_isSpaceChar(ch) ) { - state = 2; - } - break; - case 2: - if ( !PR_isSpaceChar(ch) ) { - nextStyle = PR_ATTRIB_NAME; - emitEnd = i; - state = 3; - } - break; - case 3: - if ( '=' == ch ) { - emitEnd = i; - nextStyle = PR_TAG; - state = 5; - } - else if ( PR_isSpaceChar(ch) ) { - emitEnd = i; - nextStyle = PR_TAG; - state = 4; - } - break; - case 4: - if ( '=' == ch ) { - state = 5; - } - else if ( !PR_isSpaceChar(ch) ) { - emitEnd = i; - nextStyle = PR_ATTRIB_NAME; - state = 3; - } - break; - case 5: - if ( '"' == ch || '\'' == ch ) { - emitEnd = i; - nextStyle = PR_ATTRIB_VALUE; - state = 6; - delim = ch; - } - else if ( !PR_isSpaceChar(ch) ) { - emitEnd = i; - nextStyle = PR_ATTRIB_VALUE; - state = 7; - } - break; - case 6: - if ( ch == delim ) { - emitEnd = next; - nextStyle = PR_TAG; - state = 2; - } - break; - case 7: - if ( PR_isSpaceChar(ch) ) { - emitEnd = i; - nextStyle = PR_TAG; - state = 2; - } - break; - } - } - if ( emitEnd ) { - if ( emitEnd > start ) { - tokensOut.push( - new PR_Token(s.substring(start, emitEnd), stateStyle)); - start = emitEnd; - } - stateStyle = nextStyle; - } - i = next; - } - if ( s.length > start ) { - tokensOut.push(new PR_Token(s.substring(start, s.length), stateStyle)); - } - } - else { - if ( tok.style ) { - state = 0; - stateStyle = PR_TAG; - } - tokensOut.push(tok); - } - } - return tokensOut; -} - -/** identify regions of markup that are really source code, and recursivley - * lex them. - * @private - */ -function PR_splitSourceNodes( tokens ) { - var tokensOut = []; - // when we see a <script> tag, store '/' here so that we know to end the - // source processing - var endScriptTag = null; - var decodeHelper = new PR_DecodeHelper(); - - var sourceChunks = null; - - for ( var ci = 0, nc = tokens.length; /* break below */; ++ci ) { - var tok; - - if ( ci < nc ) { - tok = tokens[ci]; - if ( null == tok.style ) { - tokens.push(tok); - continue; - } - } - else if ( !endScriptTag ) { - break; - } - else { - // else pretend there's an end tag so we can gracefully handle - // unclosed source blocks - tok = new PR_Token('', null); - } - - var s = tok.token; - - if ( null == endScriptTag ) { - if ( PR_SOURCE == tok.style ) { - // split off any starting and trailing <?, <% - if ( '<' == decodeHelper.decode(s, 0) ) { - decodeHelper.decode(s, decodeHelper.next); - if ( '%' == decodeHelper.ch || '?' == decodeHelper.ch ) { - endScriptTag = decodeHelper.ch; - tokensOut.push(new PR_Token(s.substring(0, decodeHelper.next), - PR_TAG)); - s = s.substring(decodeHelper.next, s.length); - } - } - } - else if ( PR_TAG == tok.style ) { - if ( '<' == decodeHelper.decode(s, 0) && - '/' != s.charAt(decodeHelper.next) ) { - var tagContent = s.substring(decodeHelper.next).toLowerCase(); - // FIXME(msamuel): this does not mirror exactly the code in - // in PR_splitMarkup that defers splitting tags inside script and - // style blocks. - if ( PR_startsWith(tagContent, 'script') || - PR_startsWith(tagContent, 'style') || - PR_startsWith(tagContent, 'xmp') ) { - endScriptTag = '/'; - } - } - } - } - - if ( null != endScriptTag ) { - var endTok = null; - if ( PR_SOURCE == tok.style ) { - if ( endScriptTag == '%' || endScriptTag == '?' ) { - var pos = s.lastIndexOf(endScriptTag); - if ( pos >= 0 && '>' == decodeHelper.decode(s, pos + 1) && - s.length == decodeHelper.next ) { - endTok = new PR_Token(s.substring(pos, s.length), PR_TAG); - s = s.substring(0, pos); - } - } - if ( null == sourceChunks ) { - sourceChunks = []; - } - sourceChunks.push(new PR_Token(s, PR_PLAIN)); - } - else if ( PR_PLAIN == tok.style ) { - if ( null == sourceChunks ) { - sourceChunks = []; - } - sourceChunks.push(tok); - } - else if ( PR_TAG == tok.style ) { - // if it starts with </ then it must be the end tag. - if ( '<' == decodeHelper.decode(tok.token, 0) && - tok.token.length > decodeHelper.next && - '/' == decodeHelper.decode(tok.token, decodeHelper.next) ) { - endTok = tok; - } - else { - tokensOut.push(tok); - } - } - else if ( ci >= nc ) { - // force the token to close - endTok = tok; - } - else { - if ( sourceChunks ) { - sourceChunks.push(tok); - } - else { - // push remaining tag and attribute tokens from the opening tag - tokensOut.push(tok); - } - } - if ( endTok ) { - if ( sourceChunks ) { - var sourceTokens = PR_lexSource(sourceChunks); - tokensOut.push(new PR_Token('<span class=embsrc>', null)); - for ( var si = 0, ns = sourceTokens.length; si < ns; ++si ) { - tokensOut.push(sourceTokens[si]); - } - tokensOut.push(new PR_Token('</span>', null)); - sourceChunks = null; - } - if ( endTok.token ) { - tokensOut.push(endTok); - } - endScriptTag = null; - } - } - else { - tokensOut.push(tok); - } - } - return tokensOut; -} - -/** splits the quotes from an attribute value. - * ['"foo"'] -> ['"', 'foo', '"'] - * @private - */ -function PR_splitAttributeQuotes( tokens ) { - var firstPlain = null, lastPlain = null; - for ( var i = 0; i < tokens.length; ++i ) { - if ( PR_PLAIN == tokens[i].style ) { - firstPlain = i; - break; - } - } - for ( var i = tokens.length; --i >= 0; ) { - if ( PR_PLAIN == tokens[i].style ) { - lastPlain = i; - break; - } - } - if ( null == firstPlain ) { - return tokens; - } - - var decodeHelper = new PR_DecodeHelper(); - var fs = tokens[firstPlain].token; - var fc = decodeHelper.decode(fs, 0); - if ( '"' != fc && '\'' != fc ) { - return tokens; - } - var fpos = decodeHelper.next; - - var ls = tokens[lastPlain].token; - var lpos = ls.lastIndexOf('&'); - if ( lpos < 0 ) { - lpos = ls.length - 1; - } - var lc = decodeHelper.decode(ls, lpos); - if ( lc != fc || decodeHelper.next != ls.length ) { - lc = null; - lpos = ls.length; - } - - var tokensOut = []; - for ( var i = 0; i < firstPlain; ++i ) { - tokensOut.push(tokens[i]); - } - tokensOut.push(new PR_Token(fs.substring(0, fpos), PR_ATTRIB_VALUE)); - if ( lastPlain == firstPlain ) { - tokensOut.push(new PR_Token(fs.substring(fpos, lpos), PR_PLAIN)); - } - else { - tokensOut.push(new PR_Token(fs.substring(fpos, fs.length), PR_PLAIN)); - for ( var i = firstPlain + 1; i < lastPlain; ++i ) { - tokensOut.push(tokens[i]); - } - if ( lc ) { - tokens.push(new PR_Token(ls.substring(0, lpos), PR_PLAIN)); - } - else { - tokens.push(tokens[lastPlain]); - } - } - if ( lc ) { - tokensOut.push(new PR_Token(ls.substring(lpos, ls.length), PR_PLAIN)); - } - for ( var i = lastPlain + 1; i < tokens.length; ++i ) { - tokensOut.push(tokens[i]); - } - return tokensOut; -} - -/** identify attribute values that really contain source code and recursively - * lex them. - * @private - */ -function PR_splitSourceAttributes( tokens ) { - var tokensOut = []; - - var sourceChunks = null; - var inSource = false; - var name = ''; - - for ( var ci = 0, nc = tokens.length; ci < nc; ++ci ) { - var tok = tokens[ci]; - var outList = tokensOut; - if ( PR_TAG == tok.style ) { - if ( inSource ) { - inSource = false; - name = ''; - if ( sourceChunks ) { - tokensOut.push(new PR_Token('<span class=embsrc>', null)); - var sourceTokens = - PR_lexSource(PR_splitAttributeQuotes(sourceChunks)); - for ( var si = 0, ns = sourceTokens.length; si < ns; ++si ) { - tokensOut.push(sourceTokens[si]); - } - tokensOut.push(new PR_Token('</span>', null)); - sourceChunks = null; - } - } - else if ( name && tok.token.indexOf('=') >= 0 ) { - var nameLower = name.toLowerCase(); - if ( PR_startsWith(nameLower, 'on') || 'style' == nameLower ) { - inSource = true; - } - } - else { - name = ''; - } - } - else if ( PR_ATTRIB_NAME == tok.style ) { - name += tok.token; - } - else if ( PR_ATTRIB_VALUE == tok.style ) { - if ( inSource ) { - if ( null == sourceChunks ) { - sourceChunks = []; - } - outList = sourceChunks; - tok = new PR_Token(tok.token, PR_PLAIN); - } - } - else { - if ( sourceChunks ) { - outList = sourceChunks; - } - } - outList.push(tok); - } - return tokensOut; -} - -/** returns a list of PR_Token objects given chunks of source code. - * - * This code treats ", ', and ` as string delimiters, and \ as a string escape. - * It does not recognize perl's qq() style strings. It has no special handling - * for double delimiter escapes as in basic, or tje tripled delimiters used in - * python, but should work on those regardless although in those cases a single - * string literal may be broken up into multiple adjacent string literals. - * - * It recognizes C, C++, and shell style comments. - * - * @param chunks PR_Tokens with style in (null, PR_PLAIN) - */ -function PR_lexSource( chunks ) { - // split into strings, comments, and other. - // We do this because strings and comments are easily recognizable and can - // contain stuff that looks like other tokens, so we want to mark those early - // so we don't recurse into them. - var tokens = PR_splitStringAndCommentTokens(chunks); - - // split non comment|string tokens on whitespace and word boundaries - var tokensOut = []; - for ( var i = 0; i < tokens.length; ++i ) { - var tok = tokens[i]; - if ( PR_PLAIN === tok.style ) { - PR_splitNonStringNonCommentToken(tok.token, tokensOut); - continue; - } - tokensOut.push(tok); - } - - return tokensOut; -} - -/** returns a list of PR_Token objects given a string of markup. - * - * This code assumes that < tokens are html escaped, but " are not. - * It will do a resonable job with <, but will not recognize an " - * as starting a string. - * - * This code recognizes a number of constructs. - * <!-- ... --> comment - * <!\w ... > declaration - * <\w ... > tag - * </\w ... > tag - * <?...?> embedded source - * &[#\w]...; entity - * - * It does not recognizes %foo; entities. - * - * It will recurse into any <style>, <script>, and on* attributes using - * PR_lexSource. - */ -function PR_lexMarkup( chunks ) { - // This function works as follows: - // 1) Start by splitting the markup into text and tag chunks - // Input: String s - // Output: List<PR_Token> where style in (PR_PLAIN, null) - // 2) Then split the text chunks further into comments, declarations, - // tags, etc. - // After each split, consider whether the token is the start of an - // embedded source section, i.e. is an open <script> tag. If it is, - // find the corresponding close token, and don't bother to lex in between. - // Input: List<String> - // Output: List<PR_Token> with style in (PR_TAG, PR_PLAIN, PR_SOURCE, null) - // 3) Finally go over each tag token and split out attribute names and values. - // Input: List<PR_Token> - // Output: List<PR_Token> where style in - // (PR_TAG, PR_PLAIN, PR_SOURCE, NAME, VALUE, null) - var tokensOut = PR_tokenizeMarkup(chunks); - tokensOut = PR_splitTagAttributes(tokensOut); - tokensOut = PR_splitSourceNodes(tokensOut); - tokensOut = PR_splitSourceAttributes(tokensOut); - return tokensOut; -} - -/** - * classify the string as either source or markup and lex appropriately. - * @param {String} html - */ -function PR_lexOne( html ) { - var chunks = PR_expandTabs(PR_chunkify(html), PR_TAB_WIDTH); - - // treat it as markup if the first non whitespace character is a < and the - // last non-whitespace character is a > - var isMarkup = false; - for ( var i = 0; i < chunks.length; ++i ) { - if ( PR_PLAIN == chunks[i].style ) { - if ( PR_startsWith(PR_trim(chunks[i].token), '<') ) { - for ( var j = chunks.length; --j >= 0; ) { - if ( PR_PLAIN == chunks[j].style ) { - isMarkup = PR_endsWith(PR_trim(chunks[j].token), '>'); - break; - } - } - } - break; - } - } - - return isMarkup ? PR_lexMarkup(chunks) : PR_lexSource(chunks); -} - -/** pretty print a chunk of code. - * - * @param s code as html - * @return code as html, but prettier - */ -function prettyPrintOne( s ) { - try { - var tokens = PR_lexOne(s); - var out = []; - var lastStyle = null; - for ( var i = 0; i < tokens.length; i++ ) { - var t = tokens[i]; - if ( t.style != lastStyle ) { - if ( lastStyle != null ) { - out.push('</span>'); - } - if ( t.style != null ) { - out.push('<span class=', t.style, '>'); - } - lastStyle = t.style; - } - var html = t.token; - if ( null != t.style ) { - // This interacts badly with some wikis which introduces paragraph tags - // into pre blocks for some strange reason. - // It's necessary for IE though which seems to lose the preformattedness - // of <pre> tags when their innerHTML is assigned. - // http://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html - html = html - .replace(/(\r\n?|\n| ) /g, '$1 ') - .replace(/\r\n?|\n/g, '<br>'); - } - out.push(html); - } - if ( lastStyle != null ) { - out.push('</span>'); - } - return out.join(''); - } - catch ( e ) { - if ( 'console' in window ) { - console.log(e); - console.trace(); - } - return s; - } -} - -/** find all the < pre > and < code > tags in the DOM with class=prettyprint and - * prettify them. - */ -function prettyPrint() { - // fetch a list of nodes to rewrite - var codeSegments = [ - document.getElementsByTagName('pre'), - document.getElementsByTagName('code'), - document.getElementsByTagName('xmp') ]; - var elements = []; - for ( var i = 0; i < codeSegments.length; ++i ) { - for ( var j = 0; j < codeSegments[i].length; ++j ) { - elements.push(codeSegments[i][j]); - } - } - codeSegments = null; - - // the loop is broken into a series of continuations to make sure that we - // don't make the browser unresponsive when rewriting a large page. - var k = 0; - - function doWork() { - var endTime = new Date().getTime() + 250; - for ( ; k < elements.length && new Date().getTime() < endTime; k++ ) { - var cs = elements[k]; - if ( cs.className && cs.className.indexOf('prettyprint') >= 0 ) { - - // make sure this is not nested in an already prettified element - var nested = false; - for ( var p = cs.parentNode; p != null; p = p.parentNode ) { - if ( (p.tagName == 'pre' || p.tagName == 'code' || - p.tagName == 'xmp') && - p.className && p.className.indexOf('prettyprint') >= 0 ) { - nested = true; - break; - } - } - if ( !nested ) { - // fetch the content as a snippet of properly escaped HTML. - // Firefox adds newlines at the end. - var content = PR_getInnerHtml(cs); - content = content.replace(/(?:\r\n?|\n)$/, ''); - - // do the pretty printing - var newContent = prettyPrintOne(content); - - // push the prettified html back into the tag. - if ( !PR_isRawContent(cs) ) { - // just replace the old html with the new - cs.innerHTML = newContent; - } - else { - // we need to change the tag to a <pre> since <xmp>s do not allow - // embedded tags such as the span tags used to attach styles to - // sections of source code. - var pre = document.createElement('PRE'); - for ( var i = 0; i < cs.attributes.length; ++i ) { - var a = cs.attributes[i]; - if ( a.specified ) { - pre.setAttribute(a.name, a.value); - } - } - pre.innerHTML = newContent; - // remove the old - cs.parentNode.replaceChild(pre, cs); - } - } - } - } - if ( k < elements.length ) { - // finish up in a continuation - setTimeout(doWork, 250); - } - } - - doWork(); -} diff --git a/third_party/java/jopt-simple/src/site/site.xml b/third_party/java/jopt-simple/src/site/site.xml deleted file mode 100644 index 8dafe09e18..0000000000 --- a/third_party/java/jopt-simple/src/site/site.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="JOpt Simple - a Java command line parsing library"> - <bannerLeft> - <name>JOpt Simple</name> - <src>images/jopt-simple-logo.png</src> - <href>http://pholser.github.com/jopt-simple/</href> - </bannerLeft> - <body> - <menu name="JOpt Simple"> - <item name="Overview" href="index.html"/> - <item name="Download" href="download.html"/> - <item name="Examples" href="examples.html"/> - <item name="Change Log" href="changes.html"/> - <item name="Javadoc" href="apidocs/index.html"/> - <item name="Developer Docs" href="developer.html"/> - <item name="Acknowledgements" href="acknowledgments.html"/> - </menu> - <menu ref="reports"/> - </body> -</project> diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionParserFixture.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionParserFixture.java deleted file mode 100644 index 3385c51249..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionParserFixture.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.ExpectedException; - -import static org.junit.Assert.*; -import static org.junit.rules.ExpectedException.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public abstract class AbstractOptionParserFixture { - @Rule public final ExpectedException thrown = none(); - - protected OptionParser parser; - - @Before - public final void createNewParser() { - parser = new OptionParser(); - } - - static void assertOptionDetected( OptionSet detectedOptions, String option ) { - assertTrue( "option '" + option + "' not detected?", detectedOptions.has( option ) ); - } - - static void assertOptionNotDetected( OptionSet detectedOptions, String option ) { - assertOptionNotDetected( "option '" + option + "' detected?", detectedOptions, option ); - } - - static void assertOptionNotDetected( String message, OptionSet detectedOptions, String option ) { - assertFalse( message, detectedOptions.has( option ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecFixture.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecFixture.java deleted file mode 100644 index 91901c9bd4..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecFixture.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.infinitest.toolkit.EqualsHashCodeTestSupport; -import org.junit.Test; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public abstract class AbstractOptionSpecFixture extends EqualsHashCodeTestSupport { - @Override - protected AbstractOptionSpec<?> equal() { - return createEqualOptionSpecInstance(); - } - - @Override - protected AbstractOptionSpec<?> notEqual() { - return createNotEqualOptionSpecInstance(); - } - - protected abstract AbstractOptionSpec<?> createEqualOptionSpecInstance(); - - protected abstract AbstractOptionSpec<?> createNotEqualOptionSpecInstance(); - - @Test( expected = NullPointerException.class ) - public final void testValuesWithNullOptionSet() { - createEqualOptionSpecInstance().values( null ); - } - - @Test( expected = NullPointerException.class ) - public final void testValueWithNullOptionSet() { - createNotEqualOptionSpecInstance().value( null ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecOptionsImmutabilityTestCase.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecOptionsImmutabilityTestCase.java deleted file mode 100644 index 0660640efa..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecOptionsImmutabilityTestCase.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import org.infinitest.toolkit.UnmodifiableListTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public abstract class AbstractOptionSpecOptionsImmutabilityTestCase extends UnmodifiableListTestSupport<String> { - @Override - protected List<String> newList() { - AbstractOptionSpec<?> spec = newOptionSpec( containedItem() ); - return spec.options(); - } - - @Override - protected final String newItem() { - return "not"; - } - - @Override - protected String containedItem() { - return "in"; - } - - protected abstract AbstractOptionSpec<?> newOptionSpec( String option ); -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecValuesImmutabilityTestCase.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecValuesImmutabilityTestCase.java deleted file mode 100644 index 9e41ef8fc3..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AbstractOptionSpecValuesImmutabilityTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collections; -import java.util.List; - -import org.infinitest.toolkit.UnmodifiableListTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public abstract class AbstractOptionSpecValuesImmutabilityTestCase<T> extends UnmodifiableListTestSupport<T> { - @Override - protected List<T> newList() { - AbstractOptionSpec<T> spec = newOptionSpec(); - OptionSet options = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - options.addWithArgument( spec, firstArg() ); - options.addWithArgument( spec, secondArg() ); - - return spec.values( options ); - } - - protected abstract AbstractOptionSpec<T> newOptionSpec(); - - protected abstract String firstArg(); - - protected abstract String secondArg(); -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AlternativeLongOptionSpecOptionsImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AlternativeLongOptionSpecOptionsImmutabilityTest.java deleted file mode 100644 index 529557d6ab..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AlternativeLongOptionSpecOptionsImmutabilityTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static joptsimple.ParserRules.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class AlternativeLongOptionSpecOptionsImmutabilityTest extends AbstractOptionSpecOptionsImmutabilityTestCase { - @Override - protected AbstractOptionSpec<?> newOptionSpec( String option ) { - return new AlternativeLongOptionSpec(); - } - - @Override - protected String containedItem() { - return RESERVED_FOR_EXTENSIONS; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AlternativeLongOptionSpecValuesImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AlternativeLongOptionSpecValuesImmutabilityTest.java deleted file mode 100644 index 933c171865..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AlternativeLongOptionSpecValuesImmutabilityTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class AlternativeLongOptionSpecValuesImmutabilityTest - extends AbstractOptionSpecValuesImmutabilityTestCase<String> { - - @Override - protected AbstractOptionSpec<String> newOptionSpec() { - return new AlternativeLongOptionSpec(); - } - - @Override - protected String firstArg() { - return "x=y"; - } - - @Override - protected String secondArg() { - return "z=w"; - } - - @Override - protected String newItem() { - return "a=b"; - } - - @Override - protected String containedItem() { - return "x=y"; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentAcceptingOptionSpecDefaultValuesImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentAcceptingOptionSpecDefaultValuesImmutabilityTest.java deleted file mode 100644 index d20c48cb9f..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentAcceptingOptionSpecDefaultValuesImmutabilityTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import org.infinitest.toolkit.UnmodifiableListTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ArgumentAcceptingOptionSpecDefaultValuesImmutabilityTest extends UnmodifiableListTestSupport<String> { - @Override - protected List<String> newList() { - return new RequiredArgumentOptionSpec<String>( "option" ).defaultsTo( "a", "b" ).defaultValues(); - } - - @Override - protected String containedItem() { - return "a"; - } - - @Override - protected String newItem() { - return "c"; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentAcceptingOptionSpecTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentAcceptingOptionSpecTest.java deleted file mode 100644 index 32ef589fec..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentAcceptingOptionSpecTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.infinitest.toolkit.Block; -import org.junit.Test; - -import static org.infinitest.toolkit.Assertions.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ArgumentAcceptingOptionSpecTest { - @Test( expected = NullPointerException.class ) - public void requiredArgOfNullType() { - new RequiredArgumentOptionSpec<Void>( "a" ).ofType( null ); - } - - @Test( expected = NullPointerException.class ) - public void optionalArgOfNullType() { - new OptionalArgumentOptionSpec<Void>( "verbose" ).ofType( null ); - } - - @Test( expected = IllegalArgumentException.class ) - public void requiredArgOfNonValueType() { - new RequiredArgumentOptionSpec<Void>( "threshold" ).ofType( Object.class ); - } - - @Test( expected = IllegalArgumentException.class ) - public void optionalArgOfNonValueType() { - new OptionalArgumentOptionSpec<Void>( "max" ).ofType( Object.class ); - } - - @Test - public void requiredArgOfValueTypeBasedOnValueOf() { - assertNoException( new Block() { - public void execute() { - new RequiredArgumentOptionSpec<Void>( "threshold" ).ofType( ValueOfHaver.class ); - } - } ); - } - - @Test - public void optionalArgOfValueTypeBasedOnValueOf() { - assertNoException( new Block() { - public void execute() { - new OptionalArgumentOptionSpec<Void>( "abc" ).ofType( ValueOfHaver.class ); - } - } ); - } - - @Test - public void requiredArgOfValueTypeBasedOnCtor() { - assertNoException( new Block() { - public void execute() { - new RequiredArgumentOptionSpec<Void>( "threshold" ).ofType( Ctor.class ); - } - } ); - } - - @Test - public void optionalArgOfValueTypeBasedOnCtor() { - final OptionalArgumentOptionSpec<Ctor> spec = new OptionalArgumentOptionSpec<>( "abc" ); - - assertNoException( new Block() { - public void execute() { - spec.ofType( Ctor.class ); - assertEquals( "foo", spec.convert( "foo" ).getS() ); - } - } ); - } - - @Test( expected = IllegalArgumentException.class ) - public void rejectsUnicodeZeroAsCharValueSeparatorForRequiredArgument() { - new RequiredArgumentOptionSpec<Void>( "a" ).withValuesSeparatedBy( '\u0000' ); - } - - @Test( expected = IllegalArgumentException.class ) - public void rejectsUnicodeZeroAsCharValueSeparatorForOptionalArgument() { - new OptionalArgumentOptionSpec<Void>( "b" ).withValuesSeparatedBy( '\u0000' ); - } - - @Test( expected = IllegalArgumentException.class ) - public void rejectsUnicodeZeroInStringValueSeparatorForRequiredArgument() { - new RequiredArgumentOptionSpec<Void>( "c" ).withValuesSeparatedBy( "::\u0000::" ); - } - - @Test( expected = IllegalArgumentException.class ) - public void rejectsUnicodeZeroInStringValueSeparatorForOptionalArgument() { - new OptionalArgumentOptionSpec<Void>( "d" ).withValuesSeparatedBy( "::::\u0000" ); - } - - @Test( expected = NullPointerException.class ) - public void rejectsNullConverter() { - new RequiredArgumentOptionSpec<Void>( "c" ).withValuesConvertedBy( null ); - } - - @Test( expected = NullPointerException.class ) - public void rejectsNullDefaultValue() { - new RequiredArgumentOptionSpec<Integer>( "d" ).defaultsTo( null ); - } - - @Test( expected = NullPointerException.class ) - public void rejectsNullDefaultValueRemainder() { - new RequiredArgumentOptionSpec<Integer>( "d" ).defaultsTo( 2, (Integer[]) null ); - } - - @Test( expected = NullPointerException.class ) - public void rejectsNullInDefaultValueRemainder() { - new RequiredArgumentOptionSpec<Integer>( "d" ).defaultsTo( 2, 3, null ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentListHasNoMoreArgsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentListHasNoMoreArgsTest.java deleted file mode 100644 index 1ae50755cd..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentListHasNoMoreArgsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ArgumentListHasNoMoreArgsTest { - private ArgumentList noMore; - - @Before - public void setUp() { - noMore = new ArgumentList(); - } - - @Test( expected = IndexOutOfBoundsException.class ) - public void peek() { - noMore.peek(); - } - - @Test( expected = IndexOutOfBoundsException.class ) - public void next() { - noMore.next(); - } - - @Test( expected = IndexOutOfBoundsException.class ) - public void treatNextAsLongOption() { - noMore.treatNextAsLongOption(); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentListTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentListTest.java deleted file mode 100644 index 425a41a97d..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ArgumentListTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ArgumentListTest { - private ArgumentList args; - - @Before - public void setUp() { - args = new ArgumentList( "-a", "b", "c" ); - } - - @Test - public void nextAndPeek() { - assertNextArgumentIs( "-a" ); - assertNextArgumentIs( "b" ); - assertNextArgumentIs( "c" ); - assertNoMoreArguments(); - } - - @Test - public void treatNextAsLongOption() { - args.treatNextAsLongOption(); - assertNextArgumentIs( "-a" ); - - args.treatNextAsLongOption(); - assertNextArgumentIs( "--b" ); - - args.treatNextAsLongOption(); - assertNextArgumentIs( "--c" ); - - assertNoMoreArguments(); - } - - private void assertNextArgumentIs( String expectedArg ) { - assertTrue( "no more arguments?", args.hasMore() ); - assertEquals( "peek?", expectedArg, args.peek() ); - assertEquals( "next?", expectedArg, args.next() ); - } - - private void assertNoMoreArguments() { - assertFalse( "more arguments?", args.hasMore() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableIfAnyTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableIfAnyTest.java deleted file mode 100644 index c3e4e592f6..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableIfAnyTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2014 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -import static java.util.Collections.emptyList; - -import static org.junit.Assert.assertEquals; - -public class AvailableIfAnyTest extends AbstractOptionParserFixture { - @Before - public void configureParser() { - OptionSpec<Void> a = parser.accepts( "a" ); - parser.accepts( "b" ); - OptionSpec<Void> c = parser.accepts( "c" ); - parser.accepts( "d" ); - parser.accepts( "n" ).availableIf( a, c ); - } - - @Test - public void rejectsCommandLineExistingForbiddenOption() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "-b", "-n" ); - } - - @Test - public void rejectsCommandLineExistingOtherForbiddenOption() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "-d", "-n" ); - } - - @Test - public void rejectsCommandLineOnlyForbiddenOption() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "-n" ); - } - - @Test - public void rejectsCommandLineWithNotAllConditionallyRequiredOptionsPresent() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "-b", "-d", "-n" ); - } - - @Test - public void acceptsCommandLineWithAllowedOptionsPresent() { - OptionSet options = parser.parse( "-a", "-c", "-n" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "c" ); - assertOptionDetected( options, "n" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableIfUnlessTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableIfUnlessTest.java deleted file mode 100644 index 6f394b8311..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableIfUnlessTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2014 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; - -import static org.junit.Assert.assertEquals; - -public class AvailableIfUnlessTest extends AbstractOptionParserFixture { - @Before - public void configureParser() { - parser.mutuallyExclusive( - parser.acceptsAll( asList( "ftp", "file-transfer" ) ), - parser.accepts( "file" ), - parser.accepts( "http" ) - ); - - parser.acceptsAll( asList( "username", "userid" ) ).availableIf( "file-transfer" ).withRequiredArg(); - parser.acceptsAll( asList( "password", "pwd" ) ).availableIf( "ftp" ).withRequiredArg(); - parser.acceptsAll( asList( "directory", "dir" ) ).availableIf( "file" ).withRequiredArg(); - parser.accepts( "?" ).forHelp(); - } - - @Test - public void rejectsEmptyMutualExclusiveness() { - thrown.expect( NullPointerException.class ); - - parser.mutuallyExclusive( (OptionSpecBuilder[]) null ); - } - - @Test - public void rejectsConflictingCommandLineOptions1() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "--ftp", "--file" ); - } - - @Test - public void rejectsConflictingCommandLineOptions2() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "--ftp", "--http" ); - } - - @Test - public void rejectsIncompatibleOptions1() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "--file", "--username", "joe" ); - } - - @Test - public void rejectsIncompatibleOptions2() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "--ftp", "--directory", "/tmp" ); - } - - - @Test - public void acceptsCommandLineWithConditionallyAllowedOptionsPresent1() { - OptionSet options = parser.parse( "--ftp", "--userid", "joe", "--password=secret" ); - - assertOptionDetected( options, "ftp" ); - assertOptionDetected( options, "username" ); - assertOptionDetected( options, "password" ); - assertEquals( singletonList( "joe" ), options.valuesOf( "username" ) ); - assertEquals( singletonList( "secret" ), options.valuesOf( "password" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void acceptsCommandLineWithConditionallyAllowedOptionsPresent2() { - OptionSet options = parser.parse( "--file", "--dir", "/tmp"); - - assertOptionDetected( options, "file" ); - assertOptionDetected( options, "dir" ); - assertEquals( singletonList( "/tmp" ), options.valuesOf( "dir" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void rejectsCommandLineOnlyContainingForbiddenOptionSynonym() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "--pwd", "secret" ); - } - - @Test - public void rejectsOptionNotAlreadyConfigured() { - thrown.expect( UnconfiguredOptionException.class ); - - parser.accepts( "foo" ).availableIf( "bar" ); - parser.accepts( "foo" ).availableUnless( "bar" ); - } - - @Test - public void presenceOfHelpOptionNegatesAllowedIfness() { - OptionSet options = parser.parse( "--file", "--userid", "joe", "-?" ); - - assertOptionDetected( options, "file" ); - assertOptionDetected( options, "?" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void presenceOfHelpOptionNegatesAllowedUnlessness() { - OptionSet options = parser.parse( "--file", "--ftp", "-?" ); - - assertOptionDetected( options, "file" ); - assertOptionDetected( options, "file-transfer" ); - assertOptionDetected( options, "?" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableUnlessAnyTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableUnlessAnyTest.java deleted file mode 100644 index c55191654b..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/AvailableUnlessAnyTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2014 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -import static java.util.Collections.emptyList; - -import static org.junit.Assert.assertEquals; - -public class AvailableUnlessAnyTest extends AbstractOptionParserFixture { - @Before - public void configureParser() { - parser.accepts( "a" ); - parser.accepts( "b" ); - OptionSpec<Void> c = parser.accepts( "c" ); - parser.accepts( "d" ); - parser.accepts( "n" ).availableUnless( "a" ).availableUnless( c ); - } - - @Test - public void rejectsCommandLineExistingForbiddenOption() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "-a", "-n" ); - } - - @Test - public void rejectsCommandLineExistingOtherForbiddenOption() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "-c", "-n" ); - } - - @Test - public void rejectsCommandLineOnlyForbiddenOption() { - OptionSet options = parser.parse( "-n" ); - - assertOptionDetected( options, "n" ); - } - - @Test - public void rejectsCommandLineWithNotAllConditionallyRequiredOptionsPresent() { - thrown.expect( UnavailableOptionException.class ); - - parser.parse( "-a", "-c", "-n" ); - } - - @Test - public void acceptsCommandLineWithAllowedOptionsPresent() { - OptionSet options = parser.parse( "-d", "-b", "-n" ); - - assertOptionDetected( options, "b" ); - assertOptionDetected( options, "d" ); - assertOptionDetected( options, "n" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionTest.java deleted file mode 100644 index be71a1eb2c..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ClusterVersusLongOptionTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "fox" ); - parser.accepts( "f" ); - parser.accepts( "o" ); - parser.accepts( "x" ); - } - - @Test - public void resolvesToLongOptionEvenWithMatchingShortOptions() { - OptionSet options = parser.parse( "--fox" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - } - - @Test - public void resolvesToLongOptionWithSingleDashEvenWithMatchingShortOptions() { - OptionSet options = parser.parse( "-fox" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - } - - @Test - public void resolvesAbbreviationToLongOption() { - OptionSet options = parser.parse( "-fo" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - } - - @Test - public void resolvesShortOptionToShortOption() { - OptionSet options = parser.parse( "-f" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - } - - @Test - public void resolvesShortOptionToShortOptionEvenWithDoubleHyphen() { - OptionSet options = parser.parse( "--f" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionWithOptionalArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionWithOptionalArgumentTest.java deleted file mode 100644 index 4e917648bb..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionWithOptionalArgumentTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ClusterVersusLongOptionWithOptionalArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "fox" ); - parser.accepts( "f" ); - parser.accepts( "o" ); - parser.accepts( "x" ).withOptionalArg(); - } - - @Test - public void resolvesToLongOptionEvenWithMatchingShortOptions() { - OptionSet options = parser.parse( "--fox" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - } - - @Test - public void resolvesToLongOptionWithSingleDashEvenWithMatchingShortOptions() { - OptionSet options = parser.parse( "-fox" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - } - - @Test - public void resolvesAbbreviationToLongOption() { - OptionSet options = parser.parse( "-fo" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - } - - @Test - public void resolvesShortOptionToShortOption() { - OptionSet options = parser.parse( "-f" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - } - - @Test - public void resolvesShortOptionToShortOptionEvenWithDoubleHyphen() { - OptionSet options = parser.parse( "--f" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - } - - @Test - public void resolvesToShortOptionsWithArgumentFollowingX() { - OptionSet options = parser.parse( "-foxbar" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - assertTrue( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - assertEquals( singletonList( "bar" ), options.valuesOf( "x" ) ); - } - - @Test - public void shortOptionsInDifferentOrder() { - OptionSet options = parser.parse( "-fxo" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - assertEquals( singletonList( "o" ), options.valuesOf( "x" ) ); - } - - @Test( expected = UnrecognizedOptionException.class ) - public void longOptionWithMessedUpOrder() { - parser.parse( "--fxo" ); - } - - @Test - public void withArgumentComingAfterCluster() { - OptionSet options = parser.parse( "-fox", "bar" ); - - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - assertEquals( singletonList( "bar" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionWithRequiredArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionWithRequiredArgumentTest.java deleted file mode 100644 index b20fe67d92..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterVersusLongOptionWithRequiredArgumentTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ClusterVersusLongOptionWithRequiredArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "fox" ); - parser.accepts( "f" ); - parser.accepts( "o" ); - parser.accepts( "x" ).withRequiredArg(); - } - - @Test - public void resolvesToLongOptionEvenWithMatchingShortOptions() { - OptionSet options = parser.parse( "--fox" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - } - - @Test - public void resolvesToLongOptionWithSingleDashEvenWithMatchingShortOptions() { - OptionSet options = parser.parse( "-fox" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - } - - @Test - public void resolvesAbbreviationToLongOption() { - OptionSet options = parser.parse( "-fo" ); - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - } - - @Test - public void resolvesShortOptionToShortOption() { - OptionSet options = parser.parse( "-f" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - } - - @Test - public void resolvesShortOptionToShortOptionEvenWithDoubleHyphen() { - OptionSet options = parser.parse( "--f" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - } - - @Test - public void resolvesToShortOptionsWithArgumentFollowingX() { - OptionSet options = parser.parse( "-foxbar" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - assertTrue( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - assertEquals( singletonList( "bar" ), options.valuesOf( "x" ) ); - } - - @Test - public void shortOptionsInDifferentOrder() { - OptionSet options = parser.parse( "-fxo" ); - assertFalse( options.has( "fox" ) ); - assertTrue( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - assertEquals( singletonList( "o" ), options.valuesOf( "x" ) ); - } - - @Test( expected = UnrecognizedOptionException.class ) - public void longOptionWithMessedUpOrder() { - parser.parse( "--fxo" ); - } - - @Test - public void withArgumentComingAfterCluster() { - OptionSet options = parser.parse( "-fox", "bar" ); - - assertTrue( options.has( "fox" ) ); - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - assertEquals( singletonList( "bar" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterWhereManyOptionsAcceptArgumentsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterWhereManyOptionsAcceptArgumentsTest.java deleted file mode 100644 index ae82f27662..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ClusterWhereManyOptionsAcceptArgumentsTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ClusterWhereManyOptionsAcceptArgumentsTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "f" ); - parser.accepts( "o" ).withOptionalArg(); - parser.accepts( "x" ).withRequiredArg(); - } - - @Test - public void foxPermutation() { - OptionSet options = parser.parse( "-fox" ); - - assertTrue( options.has( "f" ) ); - assertTrue( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - - assertEquals( singletonList( "x" ), options.valuesOf( "o" ) ); - } - - @Test - public void fxoPermutation() { - OptionSet options = parser.parse( "-fxo" ); - - assertTrue( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - - assertEquals( singletonList( "o" ), options.valuesOf( "x" ) ); - } - - @Test - public void ofxPermutation() { - OptionSet options = parser.parse( "-ofx" ); - - assertFalse( options.has( "f" ) ); - assertTrue( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - - assertEquals( singletonList( "fx" ), options.valuesOf( "o" ) ); - } - - @Test - public void oxfPermutation() { - OptionSet options = parser.parse( "-oxf" ); - - assertFalse( options.has( "f" ) ); - assertTrue( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - - assertEquals( singletonList( "xf" ), options.valuesOf( "o" ) ); - } - - @Test - public void xofPermutation() { - OptionSet options = parser.parse( "-xof" ); - - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - - assertEquals( singletonList( "of" ), options.valuesOf( "x" ) ); - } - - @Test - public void xfoPermutation() { - OptionSet options = parser.parse( "-xfo" ); - - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - - assertEquals( singletonList( "fo" ), options.valuesOf( "x" ) ); - } - - @Test - public void foxPermutationWithFollowingArg() { - OptionSet options = parser.parse( "-fox", "bar" ); - - assertTrue( options.has( "f" ) ); - assertTrue( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - - assertEquals( singletonList( "x" ), options.valuesOf( "o" ) ); - assertEquals( singletonList( "bar" ), options.nonOptionArguments() ); - } - - @Test - public void fxoPermutationWithFollowingArg() { - OptionSet options = parser.parse( "-fxo", "bar" ); - - assertTrue( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - - assertEquals( singletonList( "o" ), options.valuesOf( "x" ) ); - assertEquals( singletonList( "bar" ), options.nonOptionArguments() ); - } - - @Test - public void ofxPermutationWithFollowingArg() { - OptionSet options = parser.parse( "-ofx", "bar" ); - - assertFalse( options.has( "f" ) ); - assertTrue( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - - assertEquals( singletonList( "fx" ), options.valuesOf( "o" ) ); - assertEquals( singletonList( "bar" ), options.nonOptionArguments() ); - } - - @Test - public void oxfPermutationWithFollowingArg() { - OptionSet options = parser.parse( "-oxf", "bar" ); - - assertFalse( options.has( "f" ) ); - assertTrue( options.has( "o" ) ); - assertFalse( options.has( "x" ) ); - - assertEquals( singletonList( "xf" ), options.valuesOf( "o" ) ); - assertEquals( singletonList( "bar" ), options.nonOptionArguments() ); - } - - @Test - public void xofPermutationWithFollowingArg() { - OptionSet options = parser.parse( "-xof", "bar" ); - - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - - assertEquals( singletonList( "of" ), options.valuesOf( "x" ) ); - assertEquals( singletonList( "bar" ), options.nonOptionArguments() ); - } - - @Test - public void xfoPermutationWithFollowingArg() { - OptionSet options = parser.parse( "-xfo", "bar" ); - - assertFalse( options.has( "f" ) ); - assertFalse( options.has( "o" ) ); - assertTrue( options.has( "x" ) ); - - assertEquals( singletonList( "fo" ), options.valuesOf( "x" ) ); - assertEquals( singletonList( "bar" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ConfigurableOptionParserHelpTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ConfigurableOptionParserHelpTest.java deleted file mode 100644 index 066ca28a1d..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ConfigurableOptionParserHelpTest.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.io.StringWriter; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; - -import static java.math.BigDecimal.*; -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.internal.Strings.*; -import static joptsimple.util.DateConverter.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ConfigurableOptionParserHelpTest extends AbstractOptionParserFixture { - private StringWriter sink; - - @Before - public final void createSink() { - parser.formatHelpWith( new BuiltinHelpFormatter( 120, 3 ) ); - sink = new StringWriter(); - } - - @Test - public void unconfiguredParser() throws Exception { - parser.printHelpOn( sink ); - - assertHelpLines( "No options specified ", EMPTY ); - } - - @Test - public void oneOptionNoArgNoDescription() throws Exception { - parser.accepts( "apple" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--apple ", - EMPTY ); - } - - @Test - public void oneOptionNoArgWithDescription() throws Exception { - parser.accepts( "a", "some description" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a some description", - EMPTY ); - } - - @Test - public void twoOptionsNoArgWithDescription() throws Exception { - parser.accepts( "a", "some description" ); - parser.accepts( "verbose", "even more description" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a some description ", - "--verbose even more description", - EMPTY ); - } - - @Test - public void oneOptionRequiredArgNoDescription() throws Exception { - parser.accepts( "a" ).withRequiredArg(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-a <String> ", - EMPTY ); - } - - @Test - public void oneOptionRequiredArgNoDescriptionWithType() throws Exception { - parser.accepts( "a" ).withRequiredArg().ofType( Integer.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-a <Integer> ", - EMPTY ); - } - - @Test - public void oneOptionRequiredArgWithDescription() throws Exception { - parser.accepts( "a", "some value you need" ).withRequiredArg().describedAs( "numerical" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a <String: numerical> some value you need", - EMPTY ); - } - - @Test - public void oneOptionRequiredArgWithDescriptionAndType() throws Exception { - parser.accepts( "a", "some value you need" ).withRequiredArg().describedAs( "numerical" ) - .ofType( Integer.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a <Integer: numerical> some value you need", - EMPTY ); - } - - @Test - public void oneOptionOptionalArgNoDescription() throws Exception { - parser.accepts( "threshold" ).withOptionalArg(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--threshold [String] ", - EMPTY ); - } - - @Test - public void oneOptionOptionalArgNoDescriptionWithType() throws Exception { - parser.accepts( "a" ).withOptionalArg().ofType( Float.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-a [Float] ", - EMPTY ); - } - - @Test - public void oneOptionOptionalArgWithDescription() throws Exception { - parser.accepts( "threshold", "some value you need" ).withOptionalArg().describedAs( "positive integer" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "--threshold [String: positive integer] some value you need", - EMPTY ); - } - - @Test - public void oneOptionOptionalArgWithDescriptionAndType() throws Exception { - parser.accepts( "threshold", "some value you need" ).withOptionalArg().describedAs( "positive decimal" ) - .ofType( Double.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "--threshold [Double: positive decimal] some value you need", - EMPTY ); - } - - @Test - public void alternativeLongOptions() throws Exception { - parser.recognizeAlternativeLongOptions( true ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-W <String: opt=value> Alternative form of long options", - EMPTY ); - } - - @Test - public void optionSynonymsWithoutArguments() throws Exception { - parser.acceptsAll( asList( "v", "chatty" ), "be verbose" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-v, --chatty be verbose ", - EMPTY ); - } - - @Test - public void optionSynonymsWithRequiredArgument() throws Exception { - parser.acceptsAll( asList( "L", "index" ), "set level" ).withRequiredArg().ofType( Integer.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-L, --index <Integer> set level ", - EMPTY ); - } - - @Test - public void optionSynonymsWithOptionalArgument() throws Exception { - parser.acceptsAll( asList( "d", "since" ), "date filter" ).withOptionalArg().describedAs( "yyyyMMdd" ) - .ofType( Date.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-d, --since [Date: yyyyMMdd] date filter", - EMPTY ); - } - - @Test - public void optionSynonymsSortedByShortOptionThenLexicographical() throws Exception { - parser.acceptsAll( asList( "v", "prolix", "chatty" ) ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-v, --chatty, --prolix ", - EMPTY ); - } - - @Test - public void bothColumnsExceedingAllocatedWidths() throws Exception { - parser.acceptsAll( asList( "t", "threshold", "cutoff" ), - "a threshold value beyond which a certain level of the application should cease to write logs" ) - .withRequiredArg() - .describedAs( "a positive decimal number that will represent the threshold that has been outlined" ) - .ofType( Double.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-t, --cutoff, --threshold <Double: a positive decimal a threshold value beyond which a certain level of the", - " number that will represent the threshold that has been application should cease to write logs ", - " outlined> ", - EMPTY ); - } - - // Bug 2018262 - @Test - public void gradleHelp() throws Exception { - parser.acceptsAll( asList( "n", "non-recursive" ), "Do not execute primary tasks of child projects." ); - parser.acceptsAll( singletonList( "S" ), - "Don't trigger a System.exit(0) for normal termination. Used for Gradle's internal testing." ); - parser.acceptsAll( asList( "I", "no-imports" ), "Disable usage of default imports for build script files." ); - parser.acceptsAll( asList( "u", "no-search-upward" ), - "Don't search in parent folders for a settings.gradle file." ); - parser.acceptsAll( asList( "x", "cache-off" ), "No caching of compiled build scripts." ); - parser.acceptsAll( asList( "r", "rebuild-cache" ), "Rebuild the cache of compiled build scripts." ); - parser.acceptsAll( asList( "v", "version" ), "Print version info." ); - parser.acceptsAll( asList( "d", "debug" ), "Log in debug mode (includes normal stacktrace)." ); - parser.acceptsAll( asList( "q", "quiet" ), "Log errors only." ); - parser.acceptsAll( asList( "j", "ivy-debug" ), "Set Ivy log level to debug (very verbose)." ); - parser.acceptsAll( asList( "i", "ivy-quiet" ), "Set Ivy log level to quiet." ); - parser.acceptsAll( asList( "s", "stacktrace" ), - "Print out the stacktrace also for user exceptions (e.g. compile error)." ); - parser.acceptsAll( asList( "f", "full-stacktrace" ), - "Print out the full (very verbose) stacktrace for any exceptions." ); - parser.acceptsAll( asList( "t", "tasks" ), "Show list of all available tasks and their dependencies." ); - parser.acceptsAll( asList( "p", "project-dir" ), - "Specifies the start dir for Gradle. Defaults to current dir." ).withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "g", "gradle-user-home" ), "Specifies the gradle user home dir." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "l", "plugin-properties-file" ), "Specifies the plugin.properties file." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "b", "buildfile" ), - "Specifies the build file name (also for subprojects). Defaults to build.gradle." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "D", "systemprop" ), "Set system property of the JVM (e.g. -Dmyprop=myvalue)." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "P", "projectprop" ), - "Set project property for the build script (e.g. -Pmyprop=myvalue)." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "e", "embedded" ), "Specify an embedded build script." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "B", "bootstrap-debug" ), - "Specify a text to be logged at the beginning (e.g. used by Gradle's bootstrap class)." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "h", "?" ), "Shows this help message." ).forHelp(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-?, -h Shows this help message. ", - "-B, --bootstrap-debug <String> Specify a text to be logged at the beginning (e.g. used by Gradle's bootstrap ", - " class). ", - "-D, --systemprop <String> Set system property of the JVM (e.g. -Dmyprop=myvalue). ", - "-I, --no-imports Disable usage of default imports for build script files. ", - "-P, --projectprop <String> Set project property for the build script (e.g. -Pmyprop=myvalue). ", - "-S Don't trigger a System.exit(0) for normal termination. Used for Gradle's ", - " internal testing. ", - "-b, --buildfile <String> Specifies the build file name (also for subprojects). Defaults to build.gradle.", - "-d, --debug Log in debug mode (includes normal stacktrace). ", - "-e, --embedded <String> Specify an embedded build script. ", - "-f, --full-stacktrace Print out the full (very verbose) stacktrace for any exceptions. ", - "-g, --gradle-user-home <String> Specifies the gradle user home dir. ", - "-i, --ivy-quiet Set Ivy log level to quiet. ", - "-j, --ivy-debug Set Ivy log level to debug (very verbose). ", - "-l, --plugin-properties-file <String> Specifies the plugin.properties file. ", - "-n, --non-recursive Do not execute primary tasks of child projects. ", - "-p, --project-dir <String> Specifies the start dir for Gradle. Defaults to current dir. ", - "-q, --quiet Log errors only. ", - "-r, --rebuild-cache Rebuild the cache of compiled build scripts. ", - "-s, --stacktrace Print out the stacktrace also for user exceptions (e.g. compile error). ", - "-t, --tasks Show list of all available tasks and their dependencies. ", - "-u, --no-search-upward Don't search in parent folders for a settings.gradle file. ", - "-v, --version Print version info. ", - "-x, --cache-off No caching of compiled build scripts. ", - EMPTY ); - } - - @Test - public void dateConverterShowsDatePattern() throws Exception { - parser.accepts( "date", "a date" ).withRequiredArg().withValuesConvertedBy( datePattern( "MM/dd/yy" ) ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--date <MM/dd/yy> a date ", - EMPTY ); - } - - @Test - public void dateConverterShowsDatePatternInCombinationWithDescription() throws Exception { - parser.accepts( "date", "a date" ).withOptionalArg().describedAs( "your basic date pattern" ) - .withValuesConvertedBy( datePattern( "MM/dd/yy" ) ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--date [MM/dd/yy: your basic date pattern] a date ", - EMPTY ); - } - - @Test - public void leavesEmbeddedNewlinesInDescriptionsAlone() throws Exception { - List<String> descriptionPieces = - asList( "Specify the output type.", "'raw' = raw data.", "'java' = java class" ); - parser.accepts( "type", join( descriptionPieces, LINE_SEPARATOR ) ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "--type Specify the output type.", - " 'raw' = raw data. ", - " 'java' = java class ", - EMPTY ); - } - - @Test - public void includesDefaultValueForRequiredOptionArgument() throws Exception { - parser.accepts( "a" ).withRequiredArg().defaultsTo( "boo" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a <String> (default: boo)", - EMPTY ); - } - - @Test - public void includesDefaultValueForOptionalOptionArgument() throws Exception { - parser.accepts( "b" ).withOptionalArg().ofType( Integer.class ).defaultsTo( 5 ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-b [Integer] (default: 5)", - EMPTY ); - } - - @Test - public void includesDefaultValueForArgumentWithDescription() throws Exception { - parser.accepts( "c", "a quantity" ).withOptionalArg().ofType( BigDecimal.class ) - .describedAs( "quantity" ).defaultsTo( TEN ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-c [BigDecimal: quantity] a quantity (default: 10)", - EMPTY ); - } - - @Test - public void includesListOfDefaultsForArgumentWithDescription() throws Exception { - parser.accepts( "d", "dizzle" ).withOptionalArg().ofType( Integer.class ) - .describedAs( "double dizzle" ).defaultsTo( 2, 3, 5, 7 ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-d [Integer: double dizzle] dizzle (default: [2, 3, 5, 7])", - EMPTY ); - } - - @Test - public void marksRequiredOptionsSpecially() throws Exception { - parser.accepts( "e" ).withRequiredArg().required(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option (* = required) Description", - "--------------------- -----------", - "* -e <String> ", - EMPTY ); - } - - private void assertHelpLines( String... expectedLines ) { - assertEquals( join( expectedLines, LINE_SEPARATOR ), sink.toString() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/CreateWithOptionSpecificationStringTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/CreateWithOptionSpecificationStringTest.java deleted file mode 100644 index 545676ad12..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/CreateWithOptionSpecificationStringTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class CreateWithOptionSpecificationStringTest { - @Test - public void createsParserWithOptionSpecificationString() { - OptionParser first = new OptionParser() { - { - accepts( "i" ).withOptionalArg(); - accepts( "j" ).withRequiredArg(); - accepts( "k" ); - } - }; - - OptionParser second = new OptionParser( "i::j:k" ); - - String[] args = { "-k", "-ifoo", "-jbar" }; - assertEquals( first.parse( args ), second.parse( args ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/Ctor.java b/third_party/java/jopt-simple/src/test/java/joptsimple/Ctor.java deleted file mode 100644 index ad26a4de37..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/Ctor.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class Ctor { - private String s; - - public Ctor( String s ) { - this.s = s; - } - - public String getS() { - return s; - } - - static Ctor valueOf( String s ) { - return new Ctor( s ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/DefaultSettingsOptionParserHelpTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/DefaultSettingsOptionParserHelpTest.java deleted file mode 100644 index e9fd215b32..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/DefaultSettingsOptionParserHelpTest.java +++ /dev/null @@ -1,753 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.StringWriter; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import joptsimple.util.InetAddressConverter; -import org.junit.Before; -import org.junit.Test; - -import static java.math.BigDecimal.*; -import static java.util.Arrays.*; -import static java.util.Collections.*; -import static joptsimple.internal.Strings.*; -import static joptsimple.util.DateConverter.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class DefaultSettingsOptionParserHelpTest extends AbstractOptionParserFixture { - private StringWriter sink; - - @Before - public final void createSink() { - sink = new StringWriter(); - } - - @Test - public void unconfiguredParser() throws Exception { - parser.printHelpOn( sink ); - - assertHelpLines( "No options specified ", EMPTY ); - } - - @Test - public void repeatedCalls() throws Exception { - parser.accepts( "apple" ); - - parser.printHelpOn( sink ); - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--apple ", - "Option Description", - "------ -----------", - "--apple ", - EMPTY ); - } - - @Test - public void oneOptionNoArgNoDescription() throws Exception { - parser.accepts( "apple" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--apple ", - EMPTY ); - } - - @Test - public void oneOptionNoArgWithDescription() throws Exception { - parser.accepts( "a", "some description" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a some description", - EMPTY ); - } - - @Test - public void twoOptionsNoArgWithDescription() throws Exception { - parser.accepts( "a", "some description" ); - parser.accepts( "verbose", "even more description" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a some description ", - "--verbose even more description", - EMPTY ); - } - - @Test - public void oneOptionRequiredArgNoDescription() throws Exception { - parser.accepts( "a" ).withRequiredArg(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-a <String> ", - EMPTY ); - } - - @Test - public void oneOptionRequiredArgNoDescriptionWithType() throws Exception { - parser.accepts( "a" ).withRequiredArg().ofType( Integer.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-a <Integer> ", - EMPTY ); - } - - @Test - public void oneOptionRequiredArgWithDescription() throws Exception { - parser.accepts( "a", "some value you need" ).withRequiredArg().describedAs( "numerical" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a <String: numerical> some value you need", - EMPTY ); - } - - @Test - public void oneOptionRequiredArgWithDescriptionAndType() throws Exception { - parser.accepts( "a", "some value you need" ) - .withRequiredArg().describedAs( "numerical" ).ofType( Integer.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a <Integer: numerical> some value you need", - EMPTY ); - } - - @Test - public void oneOptionOptionalArgNoDescription() throws Exception { - parser.accepts( "threshold" ).withOptionalArg(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--threshold [String] ", - EMPTY ); - } - - @Test - public void oneOptionOptionalArgNoDescriptionWithType() throws Exception { - parser.accepts( "a" ).withOptionalArg().ofType( Float.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-a [Float] ", - EMPTY ); - } - - @Test - public void oneOptionOptionalArgWithDescription() throws Exception { - parser.accepts( "threshold", "some value you need" ).withOptionalArg().describedAs( "positive integer" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "--threshold [String: positive integer] some value you need", - EMPTY ); - } - - @Test - public void oneOptionOptionalArgWithDescriptionAndType() throws Exception { - parser.accepts( "threshold", "some value you need" ) - .withOptionalArg().describedAs( "positive decimal" ).ofType( Double.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "--threshold [Double: positive decimal] some value you need", - EMPTY ); - } - - @Test - public void alternativeLongOptions() throws Exception { - parser.recognizeAlternativeLongOptions( true ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-W <String: opt=value> Alternative form of long options", - EMPTY ); - } - - @Test - public void optionSynonymsWithoutArguments() throws Exception { - parser.acceptsAll( asList( "v", "chatty" ), "be verbose" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-v, --chatty be verbose ", - EMPTY ); - } - - @Test - public void optionSynonymsWithRequiredArgument() throws Exception { - parser.acceptsAll( asList( "L", "index" ), "set level" ).withRequiredArg().ofType( Integer.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-L, --index <Integer> set level ", - EMPTY ); - } - - @Test - public void optionSynonymsWithOptionalArgument() throws Exception { - parser.acceptsAll( asList( "d", "since" ), "date filter" ) - .withOptionalArg().describedAs( "yyyyMMdd" ).ofType( Date.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-d, --since [Date: yyyyMMdd] date filter", - EMPTY ); - } - - @Test - public void optionSynonymsSortedByShortOptionThenLexicographical() throws Exception { - parser.acceptsAll( asList( "v", "prolix", "chatty" ) ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "-v, --chatty, --prolix ", - EMPTY ); - } - - @Test - public void writingToOutputStream() throws Exception { - ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); - - parser.printHelpOn( bytesOut ); - - assertEquals( "No options specified " + LINE_SEPARATOR, bytesOut.toString() ); - } - - // Bug 1956418 - @Test - public void outputStreamFlushedButNotClosedWhenPrintingHelp() throws Exception { - FakeOutputStream fake = new FakeOutputStream(); - - parser.printHelpOn( fake ); - - assertTrue( fake.flushed ); - assertFalse( fake.closed ); - } - - @Test - public void bothColumnsExceedingAllocatedWidths() throws Exception { - parser.acceptsAll( asList( "t", "threshold", "cutoff" ), - "a threshold value beyond which a certain level of the application should cease to write logs" ) - .withRequiredArg() - .describedAs( "a positive decimal number that will represent the threshold that has been outlined" ) - .ofType( Double.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-t, --cutoff, --threshold <Double: a a threshold value beyond which a ", - " positive decimal number that will certain level of the application", - " represent the threshold that has should cease to write logs ", - " been outlined> ", - EMPTY ); - } - - // Bug 2018262 - @Test - public void gradleHelp() throws Exception { - parser.acceptsAll( asList( "n", "non-recursive" ), - "Do not execute primary tasks of child projects." ); - parser.acceptsAll( singletonList( "S" ), - "Don't trigger a System.exit(0) for normal termination. Used for Gradle's internal testing." ); - parser.acceptsAll( asList( "I", "no-imports" ), - "Disable usage of default imports for build script files." ); - parser.acceptsAll( asList( "u", "no-search-upward" ), - "Don't search in parent folders for a settings.gradle file." ); - parser.acceptsAll( asList( "x", "cache-off" ), - "No caching of compiled build scripts." ); - parser.acceptsAll( asList( "r", "rebuild-cache" ), - "Rebuild the cache of compiled build scripts." ); - parser.acceptsAll( asList( "v", "version" ), "Print version info." ); - parser.acceptsAll( asList( "d", "debug" ), - "Log in debug mode (includes normal stacktrace)." ); - parser.acceptsAll( asList( "q", "quiet" ), "Log errors only." ); - parser.acceptsAll( asList( "j", "ivy-debug" ), - "Set Ivy log level to debug (very verbose)." ); - parser.acceptsAll( asList( "i", "ivy-quiet" ), "Set Ivy log level to quiet." ); - parser.acceptsAll( asList( "s", "stacktrace" ), - "Print out the stacktrace also for user exceptions (e.g. compile error)." ); - parser.acceptsAll( asList( "f", "full-stacktrace" ), - "Print out the full (very verbose) stacktrace for any exceptions." ); - parser.acceptsAll( asList( "t", "tasks" ), - "Show list of all available tasks and their dependencies." ); - parser.acceptsAll( asList( "p", "project-dir" ), - "Specifies the start dir for Gradle. Defaults to current dir." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "g", "gradle-user-home" ), - "Specifies the gradle user home dir." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "l", "plugin-properties-file" ), - "Specifies the plugin.properties file." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "b", "buildfile" ), - "Specifies the build file name (also for subprojects). Defaults to build.gradle." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "D", "systemprop" ), - "Set system property of the JVM (e.g. -Dmyprop=myvalue)." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "P", "projectprop" ), - "Set project property for the build script (e.g. -Pmyprop=myvalue)." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "e", "embedded" ), - "Specify an embedded build script." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "B", "bootstrap-debug" ), - "Specify a text to be logged at the beginning (e.g. used by Gradle's bootstrap class)." ) - .withRequiredArg().ofType( String.class ); - parser.acceptsAll( asList( "h", "?" ), "Shows this help message" ).forHelp(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-?, -h Shows this help message ", - "-B, --bootstrap-debug <String> Specify a text to be logged at the ", - " beginning (e.g. used by Gradle's ", - " bootstrap class). ", - "-D, --systemprop <String> Set system property of the JVM (e.g. - ", - " Dmyprop=myvalue). ", - "-I, --no-imports Disable usage of default imports for ", - " build script files. ", - "-P, --projectprop <String> Set project property for the build ", - " script (e.g. -Pmyprop=myvalue). ", - "-S Don't trigger a System.exit(0) for ", - " normal termination. Used for Gradle's ", - " internal testing. ", - "-b, --buildfile <String> Specifies the build file name (also for ", - " subprojects). Defaults to build.gradle.", - "-d, --debug Log in debug mode (includes normal ", - " stacktrace). ", - "-e, --embedded <String> Specify an embedded build script. ", - "-f, --full-stacktrace Print out the full (very verbose) ", - " stacktrace for any exceptions. ", - "-g, --gradle-user-home <String> Specifies the gradle user home dir. ", - "-i, --ivy-quiet Set Ivy log level to quiet. ", - "-j, --ivy-debug Set Ivy log level to debug (very ", - " verbose). ", - "-l, --plugin-properties-file <String> Specifies the plugin.properties file. ", - "-n, --non-recursive Do not execute primary tasks of child ", - " projects. ", - "-p, --project-dir <String> Specifies the start dir for Gradle. ", - " Defaults to current dir. ", - "-q, --quiet Log errors only. ", - "-r, --rebuild-cache Rebuild the cache of compiled build ", - " scripts. ", - "-s, --stacktrace Print out the stacktrace also for user ", - " exceptions (e.g. compile error). ", - "-t, --tasks Show list of all available tasks and ", - " their dependencies. ", - "-u, --no-search-upward Don't search in parent folders for a ", - " settings.gradle file. ", - "-v, --version Print version info. ", - "-x, --cache-off No caching of compiled build scripts. ", - EMPTY ); - } - - @Test - public void dateConverterShowsDatePattern() throws Exception { - parser.accepts( "date", "a date" ) - .withRequiredArg() - .withValuesConvertedBy( datePattern( "MM/dd/yy" ) ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--date <MM/dd/yy> a date ", - EMPTY ); - } - - @Test - public void dateConverterShowsDatePatternInCombinationWithDescription() throws Exception { - parser.accepts( "date", "a date" ).withOptionalArg() - .describedAs( "your basic date pattern" ) - .withValuesConvertedBy( datePattern( "MM/dd/yy" ) ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description", - "------ -----------", - "--date [MM/dd/yy: your basic date a date ", - " pattern] ", - EMPTY ); - } - - @Test - public void inetAddressConverterShowsType() throws Exception { - parser.accepts( "addr", "an internet address" ) - .withRequiredArg() - .withValuesConvertedBy( new InetAddressConverter() ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "--addr <InetAddress> an internet address", - EMPTY ); - } - - @Test - public void leavesEmbeddedNewlinesInDescriptionsAlone() throws Exception { - List<String> descriptionPieces = - asList( "Specify the output type.", "'raw' = raw data.", "'java' = java class" ); - parser.accepts( "type", join( descriptionPieces, LINE_SEPARATOR ) ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "--type Specify the output type.", - " 'raw' = raw data. ", - " 'java' = java class ", - EMPTY ); - } - - @Test - public void includesDefaultValueForRequiredOptionArgument() throws Exception { - parser.accepts( "a" ).withRequiredArg().defaultsTo( "boo" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-a <String> (default: boo)", - EMPTY ); - } - - @Test - public void includesDefaultValueForOptionalOptionArgument() throws Exception { - parser.accepts( "b" ).withOptionalArg().ofType( Integer.class ).defaultsTo( 5 ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-b [Integer] (default: 5)", - EMPTY ); - } - - @Test - public void includesDefaultValueForArgumentWithDescription() throws Exception { - parser.accepts( "c", "a quantity" ).withOptionalArg().ofType( BigDecimal.class ) - .describedAs( "quantity" ).defaultsTo( TEN ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-c [BigDecimal: quantity] a quantity (default: 10)", - EMPTY ); - } - - @Test - public void includesListOfDefaultsForArgumentWithDescription() throws Exception { - parser.accepts( "d", "dizzle" ).withOptionalArg().ofType( Integer.class ) - .describedAs( "double dizzle" ).defaultsTo( 2, 3, 5, 7 ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-d [Integer: double dizzle] dizzle (default: [2, 3, 5, 7])", - EMPTY ); - } - - @Test - public void marksRequiredOptionsSpecially() throws Exception { - parser.accepts( "e" ).withRequiredArg().required(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option (* = required) Description", - "--------------------- -----------", - "* -e <String> ", - EMPTY ); - } - - @Test - public void showsNonOptionArgumentDescription() throws Exception { - parser.nonOptions( "stuff" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Non-option arguments:", - "[String] -- stuff ", - EMPTY, - "No options specified ", - EMPTY ); - } - - @Test - public void showsNonOptionArgumentType() throws Exception { - parser.nonOptions().ofType( File.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Non-option arguments:", - "[File] ", - EMPTY, - "No options specified ", - EMPTY ); - } - - @Test - public void showsNonOptionArgumentTypeDescribedAs() throws Exception { - parser.nonOptions().describedAs( "files" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Non-option arguments:", - "[String: files] ", - EMPTY, - "No options specified ", - EMPTY ); - } - - @Test - public void showsNonOptionArgumentTypeAndArgumentDescription() throws Exception { - parser.nonOptions().ofType( File.class ).describedAs( "files" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Non-option arguments:", - "[File: files] ", - EMPTY, - "No options specified ", - EMPTY ); - } - - @Test - public void showsNonOptionArgumentTypeAndDescription() throws Exception { - parser.nonOptions( "some files to operate on" ).ofType( File.class ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Non-option arguments: ", - "[File] -- some files to operate on", - EMPTY, - "No options specified ", - EMPTY ); - } - - @Test - public void showsNonOptionArgumentTypeAndDescriptionAndArgumentDescription() throws Exception { - parser.nonOptions( "some files to operate on" ).ofType( File.class ).describedAs( "files" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Non-option arguments: ", - "[File: files] -- some files to operate on", - EMPTY, - "No options specified ", - EMPTY ); - } - - @Test - public void canUseCustomHelpFormatter() { - parser.accepts( "f" ); - - parser.formatHelpWith( new HelpFormatter() { - public String format( Map<String, ? extends OptionDescriptor> options ) { - assertEquals( 1, options.size() ); - OptionDescriptor only = options.get( "f" ); - assertEquals( asList( "f" ), new ArrayList<>( only.options() ) ); - assertFalse( only.acceptsArguments() ); - assertEquals( "", only.argumentDescription() ); - assertEquals( "", only.argumentTypeIndicator() ); - assertEquals( emptyList(), only.defaultValues() ); - assertEquals( "", only.description() ); - assertFalse( only.isRequired() ); - assertFalse( only.requiresArgument() ); - return null; - } - } ); - } - - @Test( expected = NullPointerException.class ) - public void rejectsNullHelpFormatter() { - parser.formatHelpWith( null ); - } - - @Test - public void fixForIssue56() throws Exception { - parser.accepts( "password", "Server Password" ).withRequiredArg().ofType( String.class ); - parser.accepts( "F", "Forward port mapping (ie: localhost:5900:localhost:5900)" ).withRequiredArg(); - parser.accepts( "R", "Reverse port mapping (ie: localhost:5900:localhost:5900)" ).withRequiredArg(); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-F <String> Forward port mapping (ie: localhost:5900:localhost:5900)", - "-R <String> Reverse port mapping (ie: localhost:5900:localhost:5900)", - "--password <String> Server Password ", - EMPTY ); - } - - @Test - public void fixForIssue85() throws Exception { - parser.acceptsAll( asList( "?", "help" ), "Display this help text" ).forHelp(); - parser.acceptsAll( asList( "c", "check-avail" ), - "Check Galileo homepage for available books, compare with known ones" ); - parser.acceptsAll( asList( "d", "download-dir" ), - "Download directory for openbooks; must exist" ) - .withRequiredArg().ofType( File.class ).defaultsTo( new File( "." ) ); - parser.acceptsAll( asList( "l", "log-level" ), - "Log level (0=normal, 1=verbose, 2=debug, 3=trace" ) - .withRequiredArg().ofType( int.class ).defaultsTo( 0 ); - parser.acceptsAll( asList( "m", "check-md5" ), - "Download all known books without storing them, verifying their MD5 checksum (slow! >1 Gb download)" ); - parser.acceptsAll( asList( "t", "threading" ), - "Threading mode (0=single, 1=multi); single is slower, but better for diagnostics)" ) - .withRequiredArg().ofType( int.class ).defaultsTo( 1 ); - parser.acceptsAll( asList( "w", "write-config" ), - "Write editable book list to config.xml, enabling you to update MD5 checksums or add new books" ); - - parser.printHelpOn( sink ); - - assertHelpLines( - "Option Description ", - "------ ----------- ", - "-?, --help Display this help text ", - "-c, --check-avail Check Galileo homepage for available books, compare ", - " with known ones ", - "-d, --download-dir <File> Download directory for openbooks; must exist ", - " (default: .) ", - "-l, --log-level <Integer> Log level (0=normal, 1=verbose, 2=debug, 3=trace ", - " (default: 0) ", - "-m, --check-md5 Download all known books without storing them, ", - " verifying their MD5 checksum (slow! >1 Gb download)", - "-t, --threading <Integer> Threading mode (0=single, 1=multi); single is ", - " slower, but better for diagnostics) (default: 1) ", - "-w, --write-config Write editable book list to config.xml, enabling you ", - " to update MD5 checksums or add new books ", - EMPTY ); - } - - private void assertHelpLines( String... expectedLines ) { - assertEquals( join( expectedLines, LINE_SEPARATOR ), sink.toString() ); - } - - static class FakeOutputStream extends ByteArrayOutputStream { - boolean closed; - boolean flushed; - - @Override - public void close() { - this.closed = true; - } - - @Override - public void flush() { - this.flushed = true; - } - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/EmptyOptionSetTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/EmptyOptionSetTest.java deleted file mode 100644 index 640f0ff90f..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/EmptyOptionSetTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collections; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class EmptyOptionSetTest { - private OptionSet empty; - - @Before - public void setUp() { - empty = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - empty.add( new NonOptionArgumentSpec<>() ); - } - - @Test - public void valueOf() { - assertNull( empty.valueOf( "a" ) ); - } - - @Test - public void valuesOf() { - assertEquals( emptyList(), empty.valuesOf( "a" ) ); - } - - @Test - public void hasArgument() { - assertFalse( empty.hasArgument( "a" ) ); - } - - @Test - public void hasOptions() { - assertFalse( empty.hasOptions() ); - } - - @Test( expected = NullPointerException.class ) - public void valueOfWithNullString() { - empty.valueOf( (String) null ); - } - - @Test( expected = NullPointerException.class ) - public void valueOfWithNullOptionSpec() { - empty.valueOf( (OptionSpec<?>) null ); - } - - @Test( expected = NullPointerException.class ) - public void valuesOfWithNullString() { - empty.valuesOf( (String) null ); - } - - @Test( expected = NullPointerException.class ) - public void valuesOfWithNullOptionSpec() { - empty.valuesOf( (OptionSpec<?>) null ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ExceptionMatchers.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ExceptionMatchers.java deleted file mode 100644 index 5299fef2b9..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ExceptionMatchers.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.lang.reflect.InvocationTargetException; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ExceptionMatchers { - private ExceptionMatchers() { - throw new UnsupportedOperationException(); - } - - public static Matcher<OptionException> withOption( final String option ) { - return new TypeSafeMatcher<OptionException>() { - @Override - public boolean matchesSafely( OptionException target ) { - return target.options().contains( option ); - } - - public void describeTo( Description description ) { - description.appendText( "an OptionException indicating the option "); - description.appendValue( option ); - } - }; - } - - public static Matcher<Throwable> withCauseOfType( final Class<? extends Throwable> type ) { - return new TypeSafeMatcher<Throwable>() { - @Override - public boolean matchesSafely( Throwable target ) { - return type.isInstance( target.getCause() ); - } - - public void describeTo( Description description ) { - description.appendText( "an exception with cause of type " ); - description.appendValue( type ); - } - }; - } - - public static Matcher<InvocationTargetException> withTargetOfType( final Class<? extends Throwable> type ) { - return new TypeSafeMatcher<InvocationTargetException>() { - @Override - public boolean matchesSafely( InvocationTargetException target ) { - return type.isInstance( target.getTargetException() ); - } - - public void describeTo( Description description ) { - description.appendText( "an InvocationTargetException with target of type " ); - description.appendValue( type ); - } - }; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/HandlingDefaultValuesForOptionArgumentsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/HandlingDefaultValuesForOptionArgumentsTest.java deleted file mode 100644 index 5ed3141b97..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/HandlingDefaultValuesForOptionArgumentsTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.math.BigDecimal; -import java.util.List; - -import static java.math.BigDecimal.*; -import static java.util.Arrays.*; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class HandlingDefaultValuesForOptionArgumentsTest extends AbstractOptionParserFixture { - @Test - public void requiredArgOptionWithDefaultGivesArgIfArgSpecifiedOnCommandLine() { - OptionSpec<Integer> optionA = - parser.accepts( "a" ).withRequiredArg().ofType( Integer.class ).defaultsTo( 2 ); - - OptionSet options = parser.parse( "-a", "1" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.has( optionA ) ); - assertTrue( options.hasArgument( "a" ) ); - assertTrue( options.hasArgument( optionA ) ); - Integer expectedArgument = 1; - assertEquals( expectedArgument, options.valueOf( "a" ) ); - assertEquals( expectedArgument, options.valueOf( optionA ) ); - assertEquals( expectedArgument, optionA.value( options ) ); - assertEquals( asList( expectedArgument ), options.valuesOf( "a" ) ); - assertEquals( asList( expectedArgument ), options.valuesOf( optionA ) ); - assertEquals( asList( expectedArgument ), optionA.values( options ) ); - } - - @Test( expected = OptionMissingRequiredArgumentException.class ) - public void requiredArgOptionWithDefaultStillsFailToParseIfArgNotSpecifiedOnCommandLine() { - parser.accepts( "a" ).withRequiredArg().defaultsTo( "boo" ); - - parser.parse( "-a" ); - } - - @Test - public void optionalArgOptionWithDefaultGivesDefaultIfArgNotSpecifiedOnCommandLine() { - OptionSpec<Long> optionA = - parser.accepts( "a" ).withOptionalArg().ofType( Long.class ).defaultsTo( -1L ); - - OptionSet options = parser.parse( "-a" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.has( optionA ) ); - assertFalse( options.hasArgument( "a" ) ); - assertFalse( options.hasArgument( optionA ) ); - Long expectedArgument = -1L; - assertEquals( expectedArgument, options.valueOf( "a" ) ); - assertEquals( expectedArgument, options.valueOf( optionA ) ); - assertEquals( expectedArgument, optionA.value( options ) ); - assertEquals( asList( expectedArgument ), options.valuesOf( "a" ) ); - assertEquals( asList( expectedArgument ), options.valuesOf( optionA ) ); - assertEquals( asList( expectedArgument ), optionA.values( options ) ); - } - - @Test - public void optionalArgOptionWithDefaultGivesArgIfSpecifiedOnCommandLine() { - OptionSpec<Long> optionA = - parser.accepts( "a" ).withOptionalArg().ofType( Long.class ).defaultsTo( -1L ); - - OptionSet options = parser.parse( "-a", "2" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.has( optionA ) ); - assertTrue( options.hasArgument( "a" ) ); - assertTrue( options.hasArgument( optionA ) ); - Long expectedArgument = 2L; - assertEquals( expectedArgument, options.valueOf( "a" ) ); - assertEquals( expectedArgument, options.valueOf( optionA ) ); - assertEquals( expectedArgument, optionA.value( options ) ); - assertEquals( asList( expectedArgument ), options.valuesOf( "a" ) ); - assertEquals( asList( expectedArgument ), options.valuesOf( optionA ) ); - assertEquals( asList( expectedArgument ), optionA.values( options ) ); - } - - @Test - public void requiredArgOptionWithDefaultGivesDefaultIfOptionNotOnCommandLine() { - OptionSpec<BigDecimal> optionA = - parser.accepts( "a" ).withRequiredArg().ofType( BigDecimal.class ).defaultsTo( TEN ); - - OptionSet options = parser.parse(); - - assertFalse( options.has( "a" ) ); - assertFalse( options.has( optionA ) ); - assertFalse( options.hasArgument( "a" ) ); - assertFalse( options.hasArgument( optionA ) ); - assertEquals( TEN, options.valueOf( "a" ) ); - assertEquals( TEN, options.valueOf( optionA ) ); - assertEquals( TEN, optionA.value( options ) ); - assertEquals( asList( TEN ), options.valuesOf( "a" ) ); - assertEquals( asList( TEN ), options.valuesOf( optionA ) ); - assertEquals( asList( TEN ), optionA.values( options ) ); - } - - @Test - public void optionalArgOptionWithDefaultGivesDefaultIfOptionNotOnCommandLine() { - OptionSpec<BigDecimal> optionA = - parser.accepts( "a" ).withOptionalArg().ofType( BigDecimal.class ).defaultsTo( TEN ); - - OptionSet options = parser.parse(); - - assertFalse( options.has( "a" ) ); - assertFalse( options.has( optionA ) ); - assertFalse( options.hasArgument( "a" ) ); - assertFalse( options.hasArgument( optionA ) ); - assertEquals( TEN, options.valueOf( "a" ) ); - assertEquals( TEN, options.valueOf( optionA ) ); - assertEquals( TEN, optionA.value( options ) ); - assertEquals( asList( TEN ), options.valuesOf( "a" ) ); - assertEquals( asList( TEN ), options.valuesOf( optionA ) ); - assertEquals( asList( TEN ), optionA.values( options ) ); - } - - @Test - public void allowsListOfDefaults() { - OptionSpec<Integer> optionC = - parser.accepts( "c" ).withOptionalArg().ofType( Integer.class ).defaultsTo( 1, 2, 3 ); - - OptionSet options = parser.parse(); - - List<Integer> expected = asList( 1, 2, 3 ); - assertEquals( expected, optionC.values( options ) ); - assertEquals( expected, options.valuesOf( optionC ) ); - } - - @Test - public void specifiedOptionArgumentsTrumpsListOfDefaults() { - OptionSpec<Integer> optionC = - parser.accepts( "c" ).withRequiredArg().ofType( Integer.class ) - .defaultsTo( 1, 2, 3 ).withValuesSeparatedBy( ',' ); - - OptionSet options = parser.parse( "-c", "4", "-c", "5", "-c", "6,7,8" ); - - List<Integer> expected = asList( 4, 5, 6, 7, 8 ); - assertEquals( expected, optionC.values( options ) ); - assertEquals( expected, options.valuesOf( optionC ) ); - } - - @Test - public void withCompileTimeArraySpecifyingDefaults() { - OptionSpec<Integer> optionD = - parser.accepts( "d" ).withRequiredArg().ofType( Integer.class ).defaultsTo( new Integer[] { 1, 2, 3 } ); - - OptionSet options = parser.parse(); - - List<Integer> expected = asList( 1, 2, 3 ); - assertEquals( expected, optionD.values( options ) ); - assertEquals( expected, options.valuesOf( optionD ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/InterleavedArgumentsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/InterleavedArgumentsTest.java deleted file mode 100644 index e91fbd3210..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/InterleavedArgumentsTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class InterleavedArgumentsTest { - @Test - public void onlyAppearingToHaveOptionArguments() { - OptionParser parser = new OptionParser( "c" ); - - OptionSet options = parser.parse( "-c", "a", "-c", "b", "-c", "c", "-c", "d" ); - - assertTrue( options.has( "c" ) ); - assertEquals( emptyList(), options.valuesOf( "c" ) ); - assertEquals( asList( "a", "b", "c", "d" ), options.nonOptionArguments() ); - } - - @Test - public void onlyAppearingToHaveOptionArgumentsButPosixlyCorrect() { - OptionParser parser = new OptionParser( "+c" ); - - OptionSet options = parser.parse( "-c", "a", "-c", "b", "-c", "c", "-c", "d" ); - - assertTrue( options.has( "c" ) ); - assertEquals( emptyList(), options.valuesOf( "c" ) ); - assertEquals( - asList( "a", "-c", "b", "-c", "c", "-c", "d" ), - options.nonOptionArguments() ); - } - - @Test - public void requiredArgument() { - OptionParser parser = new OptionParser( "c:" ); - - OptionSet options = parser.parse( "-c", "a", "-c", "b", "-c", "c", "-c", "d" ); - - assertTrue( options.has( "c" ) ); - assertEquals( asList( "a", "b", "c", "d" ), options.valuesOf( "c" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void requiredArgumentAndPosixlyCorrect() { - OptionParser parser = new OptionParser( "+c:" ); - - OptionSet options = parser.parse( "-c", "a", "-c", "b", "-c", "c", "-c", "d" ); - - assertTrue( options.has( "c" ) ); - assertEquals( asList( "a", "b", "c", "d" ), options.valuesOf( "c" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void optionalArgument() { - OptionParser parser = new OptionParser( "c::" ); - - OptionSet options = parser.parse( "-c", "a", "-c", "b", "-c", "c", "-c", "d" ); - - assertTrue( options.has( "c" ) ); - assertEquals( asList( "a", "b", "c", "d" ), options.valuesOf( "c" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void optionalArgumentAndPosixlyCorrect() { - OptionParser parser = new OptionParser( "+c::" ); - - OptionSet options = parser.parse( "-c", "a", "-c", "b", "-c", "c", "-c", "d" ); - - assertTrue( options.has( "c" ) ); - assertEquals( emptyList(), options.valuesOf( "c" ) ); - assertEquals( asList( "a", "-c", "b", "-c", "c", "-c", "d" ), options.nonOptionArguments() ); - } - - @Test - public void leadingNonOptionCausesPosixlyCorrectToIgnoreRemainder() { - OptionParser parser = new OptionParser( "+c:" ); - String[] args = { "boo", "-c", "a", "-c", "b", "-c", "c", "-c", "d" }; - - OptionSet options = parser.parse( args ); - - assertFalse( options.has( "c" ) ); - assertEquals( emptyList(), options.valuesOf( "c" ) ); - assertEquals( asList( args ), options.nonOptionArguments() ); - } - - @Test - public void optionalAbuttedArgumentVersusPosixlyCorrect() { - OptionParser parser = new OptionParser( "+c::" ); - - OptionSet options = parser.parse( "-ca", "-cb", "-c", "c", "-c", "d" ); - - assertTrue( options.has( "c" ) ); - assertEquals( asList( "a", "b" ), options.valuesOf( "c" ) ); - assertEquals( asList( "c", "-c", "d" ), options.nonOptionArguments() ); - } - - @Test - public void optionalKeyValuePairArgumentVersusPosixlyCorrect() { - OptionParser parser = new OptionParser( "+c::" ); - - OptionSet options = parser.parse( "-c=a", "-c=b", "-c", "c", "-c", "d" ); - - assertTrue( options.has( "c" ) ); - assertEquals( asList( "a", "b" ), options.valuesOf( "c" ) ); - assertEquals( asList( "c", "-c", "d" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/Issue76Test.java b/third_party/java/jopt-simple/src/test/java/joptsimple/Issue76Test.java deleted file mode 100644 index 31221deba7..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/Issue76Test.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -import static java.util.Arrays.asList; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class Issue76Test { - private OptionParser parser; - private OptionSpec<Integer> nonOptions; - - @Before - public void setUp() { - parser = new OptionParser(); - parser.accepts( "flag" ).withOptionalArg().withValuesConvertedBy( new ValueConverter<Boolean>() { - public Boolean convert( String value ) { - if ( "true".equals( value ) ) - return true; - if ( "false".equals( value ) ) - return false; - throw new ValueConversionException( "need 'true' or 'false'" ); - } - - public Class<? extends Boolean> valueType() { - return boolean.class; - } - - public String valuePattern() { - return null; - } - }); - nonOptions = parser.nonOptions().ofType( Integer.class ); - } - - @Test - public void suppliedExample() { - OptionSet parsed = parser.parse( "--flag", "1", "2" ); - - assertTrue( parsed.has( "flag" ) ); - assertEquals( asList( 1, 2 ), nonOptions.values( parsed ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/JVMSystemPropertiesArgumentParsingTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/JVMSystemPropertiesArgumentParsingTest.java deleted file mode 100644 index 49366cf0fb..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/JVMSystemPropertiesArgumentParsingTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -import joptsimple.util.KeyValuePair; -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.util.KeyValuePair.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class JVMSystemPropertiesArgumentParsingTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "D" ).withRequiredArg().ofType( KeyValuePair.class ); - } - - @Test - public void parsingJVMSystemPropertiesArguments() { - OptionSet options = parser.parse( "-Dfile.encoding=UTF-8", "-Dpath.separator=:" ); - assertEquals( - asList( valueOf( "file.encoding=UTF-8" ), valueOf( "path.separator=:" ) ), - options.valuesOf( "D" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionNoArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionNoArgumentTest.java deleted file mode 100644 index c41f9bbd66..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionNoArgumentTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class LongOptionNoArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "verbose" ); - parser.accepts( "verb" ); - } - - @Test - public void singleLongOption() { - OptionSet options = parser.parse( "--verbose" ); - - assertTrue( options.has( "verbose" ) ); - assertEquals( emptyList(), options.valuesOf( "verbose" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void singleLongOptionAbbreviated() { - OptionSet options = parser.parse( "--verbo" ); - - assertTrue( options.has( "verbose" ) ); - assertFalse( options.has( "verb" ) ); - assertEquals( emptyList(), options.valuesOf( "verbose" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void abbreviationIsALegalOption() { - OptionSet options = parser.parse( "--verb" ); - - assertFalse( options.has( "verbose" ) ); - assertTrue( options.has( "verb" ) ); - assertEquals( emptyList(), options.valuesOf( "verb" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void ambiguousAbbreviation() { - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "ver" ) ); - - parser.parse( "--ver" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionOptionalArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionOptionalArgumentTest.java deleted file mode 100644 index 93e4b4d394..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionOptionalArgumentTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class LongOptionOptionalArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "output" ).withOptionalArg(); - parser.accepts( "a" ); - } - - @Test - public void argumentMissingTrailedByAnotherOption() { - OptionSet options = parser.parse( "--output", "-a" ); - - assertTrue( options.has( "output" ) ); - assertTrue( options.has( "a" ) ); - assertEquals( emptyList(), options.valuesOf( "output" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void argumentSeparate() { - OptionSet options = parser.parse( "--output", "opt" ); - - assertTrue( options.has( "output" ) ); - assertEquals( singletonList( "opt" ), options.valuesOf( "output" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void argumentTogether() { - OptionSet options = parser.parse( "--output=opt" ); - - assertTrue( options.has( "output" ) ); - assertEquals( singletonList( "opt" ), options.valuesOf( "output" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionRequiredArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionRequiredArgumentTest.java deleted file mode 100644 index fe77f06259..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/LongOptionRequiredArgumentTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class LongOptionRequiredArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "quiet" ).withRequiredArg(); - parser.accepts( "a" ).withOptionalArg(); - parser.accepts( "y" ).withRequiredArg(); - } - - @Test - public void argumentSeparate() { - OptionSet options = parser.parse( "--quiet", "23" ); - - assertOptionDetected( options, "quiet" ); - assertEquals( singletonList( "23" ), options.valuesOf( "quiet" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void argumentFollowedByLegalOption() { - OptionSet options = parser.parse( "--quiet", "-a" ); - - assertOptionDetected( options, "quiet" ); - assertOptionNotDetected( options, "a" ); - assertEquals( singletonList( "-a" ), options.valuesOf( "quiet" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void argumentTogether() { - OptionSet options = parser.parse( "--quiet=23" ); - - assertOptionDetected( options, "quiet" ); - assertEquals( singletonList( "23" ), options.valuesOf( "quiet" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void argumentMissing() { - thrown.expect( OptionMissingRequiredArgumentException.class ); - thrown.expect( withOption( "quiet" ) ); - - parser.parse( "--quiet" ); - } - - @Test - public void shortOptionSpecifiedAsLongOptionWithArgument() { - OptionSet options = parser.parse( "--y=bar" ); - - assertOptionDetected( options, "y" ); - assertEquals( singletonList( "bar" ), options.valuesOf( "y" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void whenEndOfOptionsMarkerIsInPlaceOfRequiredArgument() { - OptionSet options = parser.parse( "--quiet", "--", "-y", "foo", "-a" ); - - assertOptionDetected( options, "quiet" ); - assertOptionDetected( options, "y" ); - assertOptionDetected( options, "a" ); - assertEquals( singletonList( "--" ), options.valuesOf( "quiet" ) ); - assertEquals( singletonList( "foo" ), options.valuesOf( "y" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecOptionsImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecOptionsImmutabilityTest.java deleted file mode 100644 index ec9e6a79eb..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecOptionsImmutabilityTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class NoArgumentOptionSpecOptionsImmutabilityTest extends AbstractOptionSpecOptionsImmutabilityTestCase { - @Override - protected AbstractOptionSpec<?> newOptionSpec( String option ) { - return new NoArgumentOptionSpec( option ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecTest.java deleted file mode 100644 index e128308c2d..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -import org.junit.Test; - -import static org.infinitest.toolkit.CollectionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class NoArgumentOptionSpecTest extends AbstractOptionSpecFixture { - @Override - protected NoArgumentOptionSpec createEqualOptionSpecInstance() { - return new NoArgumentOptionSpec( "a" ); - } - - @Override - protected NoArgumentOptionSpec createNotEqualOptionSpecInstance() { - return new NoArgumentOptionSpec( "b" ); - } - - @Test - public void optionsContents() { - assertThat( createNotEqualOptionSpecInstance().options(), hasSameContentsAs( asList( "b" ) ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecValuesImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecValuesImmutabilityTest.java deleted file mode 100644 index c2212b3213..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/NoArgumentOptionSpecValuesImmutabilityTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class NoArgumentOptionSpecValuesImmutabilityTest extends AbstractOptionSpecValuesImmutabilityTestCase<Void> { - @Override - protected AbstractOptionSpec<Void> newOptionSpec() { - return new NoArgumentOptionSpec( "verbose" ); - } - - @Override - protected String firstArg() { - return "1"; - } - - @Override - protected String secondArg() { - return "2"; - } - - @Override - protected Void newItem() { - return null; - } - - @Override - protected Void containedItem() { - return null; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/NonOptionArgumentSpecTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/NonOptionArgumentSpecTest.java deleted file mode 100644 index feef72758c..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/NonOptionArgumentSpecTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Test; - -import java.io.File; -import java.text.SimpleDateFormat; -import java.util.*; - -import static java.util.Arrays.*; -import static java.util.Collections.*; -import static joptsimple.util.DateConverter.*; -import static org.junit.Assert.*; - -public class NonOptionArgumentSpecTest extends AbstractOptionParserFixture { - @Test - public void allowsTypingOfNonOptionArguments() { - OptionSpec<File> nonOptions = parser.nonOptions().ofType( File.class ); - - OptionSet options = parser.parse( "/opt", "/var" ); - - assertEquals( asList( new File( "/opt" ), new File( "/var" ) ), nonOptions.values( options ) ); - } - - @Test - public void allowsDescriptionOfNonOptionArguments() { - OptionSpec<String> nonOptions = parser.nonOptions( "directories" ); - - OptionSet options = parser.parse( "/opt", "/var" ); - - assertEquals( asList( "/opt", "/var" ), nonOptions.values( options ) ); - } - - @Test - public void allowsTypeAndDescriptionOfNonOptionArguments() { - OptionSpec<File> nonOptions = parser.nonOptions( "directories" ).ofType( File.class ); - - OptionSet options = parser.parse( "/opt", "/var" ); - - assertEquals( asList( new File( "/opt" ), new File( "/var" ) ), nonOptions.values( options ) ); - } - - @Test - public void allowsArgumentDescriptionForNonOptionArguments() { - OptionSpec<String> nonOptions = parser.nonOptions().describedAs( "dirs" ); - - OptionSet options = parser.parse( "/opt", "/var" ); - - assertEquals( asList( "/opt", "/var" ), nonOptions.values( options ) ); - } - - @Test - public void doesNotAcceptArguments() { - OptionDescriptor nonOptions = parser.nonOptions().describedAs( "dirs" ); - - assertFalse( nonOptions.acceptsArguments() ); - } - - @Test - public void convertingUsingConverter() throws Exception { - OptionSpec<Date> date = parser.nonOptions().withValuesConvertedBy( datePattern( "MM/dd/yyyy" ) ); - - OptionSet options = parser.parse( "01/24/2013" ); - - assertEquals( - singletonList( new SimpleDateFormat( "MM/dd/yyyy" ).parse( "01/24/2013" ) ), - date.values( options ) ); - } - - @Test( expected = NullPointerException.class ) - public void convertingUsingNullConverter() { - parser.nonOptions().withValuesConvertedBy( null ); - } - - @Test - public void noSpecsCorrespondingToNonOptions() { - OptionParser parser = new OptionParser(); - parser.nonOptions(); - - OptionSet options = parser.parse( "one", "two" ); - - assertEquals( emptyList(), options.specs() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionLocalizedMessageTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionLocalizedMessageTest.java deleted file mode 100644 index e4cd337a2e..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionLocalizedMessageTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Locale; - -import static java.util.Arrays.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -@RunWith( Parameterized.class ) -public class OptionExceptionLocalizedMessageTest { - private final OptionException subject; - private final String expectedMessage; - - public OptionExceptionLocalizedMessageTest( OptionException subject, String expectedMessage ) { - this.subject = subject; - this.expectedMessage = expectedMessage; - } - - @Parameterized.Parameters - public static Collection<?> exceptionsAndMessages() { - return asList( - new Object[] { new IllegalOptionSpecificationException( "," ), "illegal option specification exception" }, - new Object[] { new MultipleArgumentsForOptionException( - new RequiredArgumentOptionSpec<>( asList( "b", "c" ), "d" ) ), - "multiple arguments for option exception" }, - new Object[] { new OptionArgumentConversionException( - new RequiredArgumentOptionSpec<>( asList( "c", "number" ), "x" ), "d", null ), - "option argument conversion exception" }, - new Object[] { new OptionMissingRequiredArgumentException( - new RequiredArgumentOptionSpec<>( asList( "e", "honest" ), "" ) ), - "option missing required argument exception" }, - new Object[] { new UnrecognizedOptionException( "f" ), "unrecognized option exception" }, - new Object[] { new MissingRequiredOptionsException( - Arrays.<AbstractOptionSpec<?>> asList( - new NoArgumentOptionSpec( "g" ), new NoArgumentOptionSpec( "h" ) ) ), - "missing required option exception" }, - new Object[] { new MissingRequiredOptionsException( - Arrays.<AbstractOptionSpec<?>> asList( - new RequiredArgumentOptionSpec<>( asList( "p", "place" ), "spot" ), - new RequiredArgumentOptionSpec<>( asList( "d", "data-dir" ), "dir" ) ) ), - "missing required option exception" }, - new Object[] { new UnconfiguredOptionException( asList( "i", "j" ) ), - "unconfigured option exception" } - ); - } - - @Test - public void givesCorrectExceptionMessage() { - assertEquals( expectedMessage, subject.localizedMessage( new Locale( "xx", "YY" ) ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionMessageTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionMessageTest.java deleted file mode 100644 index 3afdd8350f..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionMessageTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import static com.google.common.collect.Lists.newArrayList; -import static java.util.Arrays.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -@RunWith( Parameterized.class ) -public class OptionExceptionMessageTest { - private final OptionException subject; - private final String expectedMessage; - - public OptionExceptionMessageTest( OptionException subject, String expectedMessage ) { - this.subject = subject; - this.expectedMessage = expectedMessage; - } - - @Parameterized.Parameters - public static Collection<?> exceptionsAndMessages() { - return asList( - new Object[] { new IllegalOptionSpecificationException( "," ), ", is not a legal option character" }, - new Object[] { new MultipleArgumentsForOptionException( - new RequiredArgumentOptionSpec<>( asList( "b", "c" ), "d" ) ), - "Found multiple arguments for option b/c, but you asked for only one" }, - new Object[] { new OptionArgumentConversionException( - new RequiredArgumentOptionSpec<>( asList( "c", "number" ), "x" ), "d", null ), - "Cannot parse argument 'd' of option c/number" }, - new Object[] { new OptionMissingRequiredArgumentException( - new RequiredArgumentOptionSpec<>( asList( "e", "honest" ), "" ) ), - "Option e/honest requires an argument" }, - new Object[] { new UnrecognizedOptionException( "f" ), "f is not a recognized option" }, - new Object[] { new MissingRequiredOptionsException( - Arrays.<AbstractOptionSpec<?>> asList( - new NoArgumentOptionSpec( "g" ), new NoArgumentOptionSpec( "h" ) ) ), - "Missing required option(s) [g, h]" }, - new Object[] { new MissingRequiredOptionsException( - Arrays.<AbstractOptionSpec<?>> asList( - new RequiredArgumentOptionSpec<>( asList( "p", "place" ), "spot" ), - new RequiredArgumentOptionSpec<>( asList( "d", "data-dir" ), "dir" ) ) ), - "Missing required option(s) [p/place, d/data-dir]" }, - new Object[] { new UnconfiguredOptionException( asList( "i", "j" ) ), - "Option(s) [i, j] not configured on this parser" }, - new Object[] { - new UnavailableOptionException( - newArrayList( new NoArgumentOptionSpec( "a" ), new NoArgumentOptionSpec( "b" ) ) ), - "Option(s) [a, b] are unavailable given other options on the command line" - } - ); - } - - @Test - public void givesCorrectExceptionMessage() { - assertEquals( expectedMessage, subject.getLocalizedMessage() ); - assertEquals( expectedMessage, subject.getMessage() ); - assertEquals( subject.getClass().getName() + ": " + expectedMessage, subject.toString() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionOptionsImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionOptionsImmutabilityTest.java deleted file mode 100644 index 465d960cf7..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionExceptionOptionsImmutabilityTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import org.infinitest.toolkit.UnmodifiableListTestSupport; - -import static java.util.Arrays.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionExceptionOptionsImmutabilityTest extends UnmodifiableListTestSupport<String> { - @Override - protected List<String> newList() { - return new OptionException( asList( "a", "b" ) ) { - private static final long serialVersionUID = -1L; - - @Override - Object[] messageArguments() { - return new Object[0]; - } - }.options(); - } - - @Override - protected String newItem() { - return "c"; - } - - @Override - protected String containedItem() { - return "a"; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserAlternateHelpFormatterTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserAlternateHelpFormatterTest.java deleted file mode 100644 index b799df696b..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserAlternateHelpFormatterTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package joptsimple; - -import java.io.StringWriter; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import static java.util.Arrays.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.infinitest.toolkit.CollectionMatchers.*; -import static org.junit.Assert.*; - -public class OptionParserAlternateHelpFormatterTest extends AbstractOptionParserFixture { - private StringWriter sink; - private Map<String, ? extends OptionDescriptor> captured; - - @Before - public void primeParser() throws Exception { - captured = new HashMap<>(); - - parser.accepts( "b", "boo" ); - - parser.formatHelpWith( new HelpFormatter() { - public String format( Map<String, ? extends OptionDescriptor> options ) { - captured = options; - return "some help you are"; - } - } ); - - sink = new StringWriter(); - - parser.printHelpOn( sink ); - } - - @Test - public void asksAlternateFormatterForHelpString() { - assertEquals( "some help you are", sink.toString() ); - } - - @Test - public void getsFedOptionDescriptorsForRecognizedOptions() { - assertEquals( 2, captured.size() ); - Iterator<? extends Map.Entry<String,? extends OptionDescriptor>> iterator = captured.entrySet().iterator(); - Map.Entry<String, ? extends OptionDescriptor> first = iterator.next(); - assertEquals( "[arguments]", first.getKey() ); - Map.Entry<String, ? extends OptionDescriptor> second = iterator.next(); - assertEquals("b", second.getKey()); - OptionDescriptor descriptor = second.getValue(); - assertThat( descriptor.options(), hasSameContentsAs( asList( "b" ) ) ); - assertEquals( "boo", descriptor.description() ); - assertFalse( descriptor.acceptsArguments() ); - assertFalse( descriptor.requiresArgument() ); - assertEquals( "", descriptor.argumentDescription() ); - assertEquals( "", descriptor.argumentTypeIndicator() ); - assertEquals( Collections.emptyList(), descriptor.defaultValues() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserArgumentExceptionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserArgumentExceptionTest.java deleted file mode 100644 index 4661795a74..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserArgumentExceptionTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collections; - -import static java.util.Collections.*; - -import org.junit.Test; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionParserArgumentExceptionTest extends AbstractOptionParserFixture { - @Test( expected = NullPointerException.class ) - public void createWithNullOptionSpec() { - new OptionParser( null ); - } - - @Test( expected = NullPointerException.class ) - public void parseNull() { - parser.parse( (String[]) null ); - } - - @Test( expected = NullPointerException.class ) - public void nullOptionToAccepts() { - parser.accepts( null ); - } - - @Test( expected = NullPointerException.class ) - public void nullOptionToAcceptsWithDescription() { - parser.accepts( null, "a weird option" ); - } - - @Test( expected = NullPointerException.class ) - public void nullOptionListToAcceptsAll() { - parser.acceptsAll( null ); - } - - @Test( expected = IllegalArgumentException.class ) - public void emptyOptionListToAcceptsAll() { - parser.acceptsAll( Collections.<String> emptyList() ); - } - - @Test( expected = NullPointerException.class ) - public void optionListContainingNullToAcceptsAll() { - parser.acceptsAll( singletonList( (String) null ) ); - } - - @Test( expected = NullPointerException.class ) - public void nullOptionListToAcceptsAllWithDescription() { - parser.acceptsAll( null, "some weird options" ); - } - - @Test( expected = NullPointerException.class ) - public void optionListContainingNullToAcceptsAllWithDescription() { - parser.acceptsAll( singletonList( (String) null ), "some weird options" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserNewDeclarationTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserNewDeclarationTest.java deleted file mode 100644 index 0381af24d4..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserNewDeclarationTest.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.math.BigInteger; -import java.sql.Time; -import java.sql.Timestamp; - -import static java.lang.Boolean.*; -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionParserNewDeclarationTest extends AbstractOptionParserFixture { - @Test( expected = IllegalOptionSpecificationException.class ) - public void acceptsIllegalCharacters() { - parser.accepts( "!" ); - } - - @Test - public void booleanArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Boolean.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Boolean.class ); - - OptionSet options = parser.parse( "-a", "true", "-b", "false" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( TRUE, options.valueOf( "a" ) ); - assertEquals( singletonList( TRUE ), options.valuesOf( "a" ) ); - assertEquals( FALSE, options.valueOf( "b" ) ); - assertEquals( singletonList( FALSE ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void byteArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Byte.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Byte.class ); - - OptionSet options = parser.parse( "-a", "-1", "-b", "-2" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Byte.valueOf( "-1" ), options.valueOf( "a" ) ); - assertEquals( singletonList( Byte.valueOf( "-1" ) ), options.valuesOf( "a" ) ); - assertEquals( Byte.valueOf( "-2" ), options.valueOf( "b" ) ); - assertEquals( singletonList( Byte.valueOf( "-2" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void doubleArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Double.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Double.class ); - - OptionSet options = parser.parse( "-a", "3.1415926D", "-b", "6.02E23" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Double.valueOf( "3.1415926D" ), options.valueOf( "a" ) ); - assertEquals( asList( Double.valueOf( "3.1415926D" ) ), options.valuesOf( "a" ) ); - assertEquals( Double.valueOf( "6.02E23" ), options.valueOf( "b" ) ); - assertEquals( asList( Double.valueOf( "6.02E23" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void floatArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Float.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Float.class ); - - OptionSet options = parser.parse( "-a", "3.1415926F", "-b", "6.02E23F" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Float.valueOf( "3.1415926F" ), options.valueOf( "a" ) ); - assertEquals( asList( Float.valueOf( "3.1415926F" ) ), options.valuesOf( "a" ) ); - assertEquals( Float.valueOf( "6.02E23F" ), options.valueOf( "b" ) ); - assertEquals( asList( Float.valueOf( "6.02E23F" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void integerArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Integer.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Integer.class ); - - OptionSet options = parser.parse( "-a", "12", "-b", "34" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Integer.valueOf( "12" ), options.valueOf( "a" ) ); - assertEquals( asList( Integer.valueOf( "12" ) ), options.valuesOf( "a" ) ); - assertEquals( Integer.valueOf( "34" ), options.valueOf( "b" ) ); - assertEquals( asList( Integer.valueOf( "34" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void longArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Long.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Long.class ); - - OptionSet options = parser.parse( "-a", "123454678901234", "-b", "98765432109876" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Long.valueOf( "123454678901234" ), options.valueOf( "a" ) ); - assertEquals( singletonList( Long.valueOf( "123454678901234" ) ), options.valuesOf( "a" ) ); - assertEquals( Long.valueOf( "98765432109876" ), options.valueOf( "b" ) ); - assertEquals( singletonList( Long.valueOf( "98765432109876" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void shortArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Short.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Short.class ); - - OptionSet options = parser.parse( "-a", "5675", "-b", "345" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Short.valueOf( "5675" ), options.valueOf( "a" ) ); - assertEquals( asList( Short.valueOf( "5675" ) ), options.valuesOf( "a" ) ); - assertEquals( Short.valueOf( "345" ), options.valueOf( "b" ) ); - assertEquals( asList( Short.valueOf( "345" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void sqlDateArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( java.sql.Date.class ); - parser.accepts( "b" ).withOptionalArg().ofType( java.sql.Date.class ); - - OptionSet options = parser.parse( "-a", "2001-09-11", "-b", "1941-12-07" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( java.sql.Date.valueOf( "2001-09-11" ), options.valueOf( "a" ) ); - assertEquals( singletonList( java.sql.Date.valueOf( "2001-09-11" ) ), options.valuesOf( "a" ) ); - assertEquals( java.sql.Date.valueOf( "1941-12-07" ), options.valueOf( "b" ) ); - assertEquals( singletonList( java.sql.Date.valueOf( "1941-12-07" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void sqlTimeArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Time.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Time.class ); - - OptionSet options = parser.parse( "-a", "08:57:39", "-b", "23:59:59" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Time.valueOf( "08:57:39" ), options.valueOf( "a" ) ); - assertEquals( asList( Time.valueOf( "08:57:39" ) ), options.valuesOf( "a" ) ); - assertEquals( Time.valueOf( "23:59:59" ), options.valueOf( "b" ) ); - assertEquals( asList( Time.valueOf( "23:59:59" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void sqlTimestampArgumentType() { - parser.accepts( "a" ).withRequiredArg().ofType( Timestamp.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Timestamp.class ); - - OptionSet options = parser.parse( "-a", "1970-01-01 00:00:00", "-b", "1979-12-31 23:59:59.0123456" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Timestamp.valueOf( "1970-01-01 00:00:00" ), options.valueOf( "a" ) ); - assertEquals( singletonList( Timestamp.valueOf( "1970-01-01 00:00:00" ) ), options.valuesOf( "a" ) ); - assertEquals( Timestamp.valueOf( "1979-12-31 23:59:59.0123456" ), options.valueOf( "b" ) ); - assertEquals( singletonList( Timestamp.valueOf( "1979-12-31 23:59:59.0123456" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test( expected = OptionException.class ) - public void illegalOptionArgumentMethodConversion() { - parser.accepts( "a" ).withRequiredArg().ofType( Integer.class ); - - OptionSet options = parser.parse( "-a", "foo" ); - - options.valueOf( "a" ); - } - - @Test( expected = OptionException.class ) - public void illegalOptionArgumentConstructorConversion() { - parser.accepts( "a" ).withRequiredArg().ofType( BigInteger.class ); - - OptionSet options = parser.parse( "-a", "foo" ); - - options.valueOf( "a" ); - } - - @Test - public void optionsWithOptionalNegativeNumberArguments() { - parser.accepts( "a" ).withOptionalArg().ofType( Integer.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Integer.class ); - parser.accepts( "1" ); - parser.accepts( "2" ); - - OptionSet options = parser.parse( "-a", "-1", "-b", "-2" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( Integer.valueOf( "-1" ), options.valueOf( "a" ) ); - assertEquals( asList( Integer.valueOf( "-1" ) ), options.valuesOf( "a" ) ); - assertEquals( Integer.valueOf( "-2" ), options.valueOf( "b" ) ); - assertEquals( asList( Integer.valueOf( "-2" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void optionsWithOptionalNegativeNumberArgumentsAndNumberOptions() { - parser.accepts( "a" ).withOptionalArg().ofType( Integer.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Integer.class ); - parser.accepts( "1" ); - parser.accepts( "2" ); - - OptionSet options = parser.parse( "-1", "-2", "-a", "-b" ); - - assertOptionDetected( options, "1" ); - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "2" ); - assertOptionDetected( options, "b" ); - assertNull( options.valueOf( "1" ) ); - assertNull( options.valueOf( "a" ) ); - assertNull( options.valueOf( "2" ) ); - assertNull( options.valueOf( "b" ) ); - assertEquals( emptyList(), options.valuesOf( "1" ) ); - assertEquals( emptyList(), options.valuesOf( "a" ) ); - assertEquals( emptyList(), options.valuesOf( "2" ) ); - assertEquals( emptyList(), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void optionsWithNegativeNumberArgumentsAndNonNumberOptions() { - parser.accepts( "a" ).withOptionalArg().ofType( Integer.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Integer.class ); - parser.accepts( "1" ); - parser.accepts( "2" ); - - OptionSet options = parser.parse( "-1", "-a", "-b", "-2" ); - - assertOptionDetected( options, "1" ); - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertOptionNotDetected( options, "2" ); - assertNull( options.valueOf( "1" ) ); - assertNull( options.valueOf( "a" ) ); - assertEquals( Integer.valueOf( "-2" ), options.valueOf( "b" ) ); - assertEquals( emptyList(), options.valuesOf( "1" ) ); - assertEquals( emptyList(), options.valuesOf( "a" ) ); - assertEquals( asList( Integer.valueOf( "-2" ) ), options.valuesOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserOptionExceptionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserOptionExceptionTest.java deleted file mode 100644 index 3e219d5207..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserOptionExceptionTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionParserOptionExceptionTest extends AbstractOptionParserFixture { - @Test - public void unrecognizedOption() { - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "a" ) ); - - parser.parse( "-a" ); - } - - @Test - public void illegalOptionCharacter() { - thrown.expect( IllegalOptionSpecificationException.class ); - thrown.expect( withOption( "%" ) ); - - parser.accepts( "%" ); - } - - @Test - public void asteriskIsIllegalOptionCharacter() { - thrown.expect( IllegalOptionSpecificationException.class ); - thrown.expect( withOption( "*" ) ); - - parser.accepts( "*" ); - } - - @Test - public void tooManyHyphens() { - parser.accepts( "b" ); - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "-b" ) ); - - parser.parse( "---b" ); - } - - @Test - public void valueOfWhenMultiples() { - parser.accepts( "e" ).withRequiredArg(); - OptionSet options = parser.parse( "-e", "foo", "-e", "bar" ); - thrown.expect( MultipleArgumentsForOptionException.class ); - thrown.expect( withOption( "e" ) ); - - options.valueOf( "e" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserRecognizedOptionsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserRecognizedOptionsTest.java deleted file mode 100644 index 3bddfb998b..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserRecognizedOptionsTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package joptsimple; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Map; - -import static java.util.Arrays.asList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -public class OptionParserRecognizedOptionsTest extends AbstractOptionParserFixture { - @Test - public void basicOptionsRecognized() { - parser.accepts( "first" ).withRequiredArg().required(); - parser.accepts( "second" ).withOptionalArg(); - parser.accepts( "third" ).forHelp(); - - Map<String, OptionSpec<?>> recognizedOptions = parser.recognizedOptions(); - - assertEquals( 4, recognizedOptions.size() ); - assertTrue( recognizedOptions.keySet().contains( "first" ) ); - assertTrue( recognizedOptions.keySet().contains( "second" ) ); - assertTrue( recognizedOptions.keySet().contains( "third" ) ); - assertTrue( recognizedOptions.keySet().contains( "[arguments]" ) ); - assertTrue( recognizedOptions.get( "third" ).isForHelp() ); - assertFalse( recognizedOptions.get( "second" ).isForHelp() ); - assertNotNull( recognizedOptions.get( "first" ).options() ); - } - - @Test - public void parserPreservesTrainingOrder() { - final OptionSpecBuilder z = parser.acceptsAll( asList( "zebra", "aardvark" ) ); - final OptionSpecBuilder y = parser.accepts( "yak" ); - final OptionSpecBuilder x = parser.acceptsAll( asList( "baboon", "xantus" ) ); - - assertEquals( asList( "[arguments]", "aardvark", "zebra", "yak", "baboon", "xantus" ), new ArrayList<String>( - parser.recognizedOptions().keySet() ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserTest.java deleted file mode 100644 index 5538f2d171..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserTest.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.lang.Boolean.*; -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.hamcrest.Description; -import org.hamcrest.TypeSafeMatcher; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionParserTest extends AbstractOptionParserFixture { - @Test - public void optionsAndNonOptionsInterspersed() { - parser.accepts( "i" ).withOptionalArg(); - parser.accepts( "j" ).withOptionalArg(); - parser.accepts( "k" ); - - OptionSet options = - parser.parse( "-ibar", "-i", "junk", "xyz", "-jixnay", "foo", "-k", "blah", "--", "yermom" ); - - assertOptionDetected( options, "i" ); - assertOptionDetected( options, "j" ); - assertOptionDetected( options, "k" ); - assertEquals( asList( "bar", "junk" ), options.valuesOf( "i" ) ); - assertEquals( singletonList( "ixnay" ), options.valuesOf( "j" ) ); - assertEquals( emptyList(), options.valuesOf( "k" ) ); - assertEquals( asList( "xyz", "foo", "blah", "yermom" ), options.nonOptionArguments() ); - } - - @Test - public void shortOptionSpecifiedAsLongOptionWithoutArgument() { - parser.accepts( "x" ); - - OptionSet options = parser.parse( "--x" ); - assertOptionDetected( options, "x" ); - assertEquals( emptyList(), options.valuesOf( "x" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void longOptionLeadsWithSingleDash() { - parser.accepts( "quiet" ); - parser.accepts( "queen" ); - - OptionSet options = parser.parse( "-quiet" ); - assertOptionDetected( options, "quiet" ); - assertEquals( emptyList(), options.valuesOf( "quiet" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void parsesLongOptionAsAbbreviatedShortOption() { - parser.accepts( "queen" ); - - parser.parse( "-que" ); - } - - @Test - public void parsesLongOptionAsAbbreviatedLongOption() { - parser.accepts( "queen" ); - - parser.parse( "--que" ); - } - - @Test - public void longOptionLeadsWithSingleDashAmbiguous() { - parser.accepts( "quiet" ); - parser.accepts( "queen" ); - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "q" ) ); - - parser.parse( "-q" ); - } - - @Test - public void longOptionLeadsWithSingleDashAmbiguousButShortsAreLegal() { - parser.accepts( "quiet" ); - parser.accepts( "queen" ); - parser.accepts( "q" ); - parser.accepts( "u" ); - - OptionSet options = parser.parse( "-qu" ); - assertOptionDetected( options, "q" ); - assertOptionDetected( options, "u" ); - assertOptionNotDetected( options, "quiet" ); - assertOptionNotDetected( options, "queen" ); - assertEquals( emptyList(), options.valuesOf( "q" ) ); - assertEquals( emptyList(), options.valuesOf( "u" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void longOptionLeadsWithSingleDashAmbiguousButAShortIsIllegal() { - parser.accepts( "quiet" ); - parser.accepts( "queen" ); - parser.accepts( "q" ); - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "u" ) ); - - parser.parse( "-qu" ); - } - - @Test - public void longOptionLeadsWithSingleDashAmbiguousButAShortAcceptsAnArgument() { - parser.accepts( "quiet" ); - parser.accepts( "queen" ); - parser.accepts( "q" ).withOptionalArg(); - - OptionSet options = parser.parse( "-qu" ); - assertOptionDetected( options, "q" ); - assertOptionNotDetected( options, "quiet" ); - assertOptionNotDetected( options, "queen" ); - assertEquals( singletonList( "u" ), options.valuesOf( "q" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void resetHappensAfterParsing() { - parser.accepts( "i" ).withOptionalArg(); - parser.accepts( "j" ).withOptionalArg(); - parser.accepts( "k" ); - - String[] args = { "-ibar", "-i", "junk", "xyz", "-jixnay", "foo", "-k", "blah", "--", "yermom" }; - - OptionSet options = parser.parse( args ); - assertEquals( options, parser.parse( args ) ); - } - - @Test - public void typedArguments() { - parser.accepts( "a" ).withRequiredArg().ofType( Boolean.class ); - parser.accepts( "b" ).withOptionalArg().ofType( Integer.class ); - - OptionSet options = parser.parse( "-a", "false", "-b", "3", "extra" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertEquals( FALSE, options.valueOf( "a" ) ); - assertEquals( singletonList( FALSE ), options.valuesOf( "a" ) ); - assertEquals( Integer.valueOf( "3" ), options.valueOf( "b" ) ); - assertEquals( singletonList( Integer.valueOf( "3" ) ), options.valuesOf( "b" ) ); - assertEquals( singletonList( "extra" ), options.nonOptionArguments() ); - } - - @Test - public void allowsMixingOfOptionsAndNonOptions() { - parser.accepts( "i" ).withRequiredArg(); - parser.accepts( "j" ).withOptionalArg(); - parser.accepts( "k" ); - - OptionSet options = parser.parse( "a", "b", "c", "-i", "boo", "d", "e", "-k", "f", "-j" ); - - assertOptionDetected( options, "i" ); - assertEquals( singletonList( "boo" ), options.valuesOf( "i" ) ); - assertOptionDetected( options, "j" ); - assertEquals( emptyList(), options.valuesOf( "j" ) ); - assertOptionDetected( options, "k" ); - assertEquals( emptyList(), options.valuesOf( "k" ) ); - assertEquals( asList( "a", "b", "c", "d", "e", "f" ), options.nonOptionArguments() ); - } - - @Test - public void disallowsMixingOfOptionsAndNonOptionsUnderPosixlyCorrect() { - parser.accepts( "i" ).withRequiredArg(); - parser.accepts( "j" ).withOptionalArg(); - parser.accepts( "k" ); - parser.posixlyCorrect( true ); - - OptionSet options = parser.parse( "a", "b", "c", "-i", "boo", "d", "e", "-k", "f", "-j" ); - - assertOptionNotDetected( options, "i" ); - assertEquals( emptyList(), options.valuesOf( "i" ) ); - assertOptionNotDetected( options, "j" ); - assertEquals( emptyList(), options.valuesOf( "j" ) ); - assertOptionNotDetected( options, "k" ); - assertEquals( emptyList(), options.valuesOf( "j" ) ); - assertEquals( asList( "a", "b", "c", "-i", "boo", "d", "e", "-k", "f", "-j" ), options.nonOptionArguments() ); - } - - @Test - public void doubleHyphenSignalsEndsOfOptions() { - OptionSet options = new OptionParser( "ab:c::de:f::" ) { - { - accepts( "verbose" ); - } - }.parse( "-a", "-b=foo", "-c=bar", "--", "-d", "-verbose", "-e", "baz", "-f", "biz" ); - - assertOptionDetected( options, "a" ); - assertEquals( emptyList(), options.valuesOf( "a" ) ); - assertOptionDetected( options, "b" ); - assertEquals( singletonList( "foo" ), options.valuesOf( "b" ) ); - assertOptionDetected( options, "c" ); - assertEquals( singletonList( "bar" ), options.valuesOf( "c" ) ); - assertOptionNotDetected( options, "d" ); - assertOptionNotDetected( options, "verbose" ); - assertOptionNotDetected( options, "e" ); - assertOptionNotDetected( options, "f" ); - assertEquals( asList( "-d", "-verbose", "-e", "baz", "-f", "biz" ), options.nonOptionArguments() ); - } - - @Test - public void allowsEmptyStringAsArgumentOfOption() { - OptionSpec<String> optionI = parser.accepts( "i" ).withOptionalArg(); - - OptionSet options = parser.parse( "-i", "" ); - - assertOptionDetected( options, "i" ); - assertEquals( "", optionI.value( options ) ); - } - - @Test - public void allowsWhitespaceyStringAsArgumentOfOption() { - String whitespace = " \t\t\n\n\f\f \r\r "; - OptionSpec<String> optionJ = parser.accepts( "j" ).withRequiredArg(); - - OptionSet options = parser.parse( "-j", whitespace ); - - assertOptionDetected( options, "j" ); - assertEquals( whitespace, optionJ.value( options ) ); - } - - @Test - public void allowsEmbeddedWhitespaceInArgumentOfOption() { - String withEmbeddedWhitespace = " look at me, I'm flaunting the rules! "; - OptionSpec<String> optionJ = parser.accepts( "j" ).withRequiredArg(); - - OptionSet options = parser.parse( "-j", withEmbeddedWhitespace ); - - assertOptionDetected( options, "j" ); - assertEquals( withEmbeddedWhitespace, optionJ.value( options ) ); - } - - @Test - public void requiredOptionWithArgMissing() { - parser.accepts( "t" ).withOptionalArg().required(); - thrown.expect( MissingRequiredOptionsException.class ); - thrown.expect( withOption( "t" ) ); - - parser.parse(); - } - - @Test - public void requiredOptionButHelpOptionPresent() { - parser.accepts( "t" ).withOptionalArg().required(); - parser.accepts( "h" ).forHelp(); - - parser.parse( "-h" ); - } - - @Test - public void configurationPerformedLaterOverrideThosePerformedEarlierForTheSameOption() { - parser.accepts( "t" ).withRequiredArg(); - parser.accepts( "t" ).withOptionalArg(); - - parser.parse( "-t" ); - } - - @Test - public void requiredOptionWithSynonymsMissing() { - parser.acceptsAll( asList( "h", "help", "?" ) ); - parser.acceptsAll( asList( "f", "ff", "csv-file-name" ) ).withRequiredArg().required(); - - thrown.expect( MissingRequiredOptionsException.class ); - thrown.expectMessage( new TypeSafeMatcher<String>() { - @Override - protected boolean matchesSafely( String item ) { - return "Missing required option(s) [f/csv-file-name/ff]".equals( item ); - } - - public void describeTo(Description description) { - // purposely doing nothing here - } - } ); - - parser.parse(); - } - - @Test - public void abbreviationsCanBeDisallowed() { - OptionParser parser = new OptionParser(false); - parser.accepts( "abbreviatable" ); - - thrown.expect( UnrecognizedOptionException.class ); - - parser.parse( "--abb" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserUnrecognizedOptionsAllowedTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserUnrecognizedOptionsAllowedTest.java deleted file mode 100644 index 8df74cacb2..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionParserUnrecognizedOptionsAllowedTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static joptsimple.ExceptionMatchers.withOption; -import static java.util.Arrays.asList; - -import org.junit.Test; - -import static org.junit.Assert.*; - -public class OptionParserUnrecognizedOptionsAllowedTest extends AbstractOptionParserFixture { - @Test - public void unrecognizedOptionDisallowed() { - assertFalse( parser.doesAllowsUnrecognizedOptions() ); - - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "a" ) ); - - parser.parse( "-a" ); - } - - @Test - public void unrecognizedOptionAllowed() { - parser.allowsUnrecognizedOptions(); - - OptionSet options = parser.parse( "-a" ); - - assertEquals( asList( "-a" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetAsMapTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetAsMapTest.java deleted file mode 100644 index 0a8c9a67d6..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetAsMapTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package joptsimple; - -import org.junit.Test; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static java.util.Arrays.asList; -import static java.util.Collections.*; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -/** - * @author <a href="mailto:binkley@alumni.rice.edu">B. K. Oxley (binkley)</a> - */ -public class OptionSetAsMapTest extends AbstractOptionParserFixture { - @Test - public void gives() { - final OptionSpec<Void> a = parser.accepts( "a" ); - final OptionSpec<String> b = parser.accepts( "b" ).withRequiredArg(); - final OptionSpec<String> c = parser.accepts( "c" ).withOptionalArg(); - final OptionSpec<String> d = parser.accepts( "d" ).withRequiredArg().defaultsTo( "1" ); - final OptionSpec<String> e = parser.accepts( "e" ).withOptionalArg().defaultsTo( "2" ); - final OptionSpec<String> f = parser.accepts( "f" ).withRequiredArg().defaultsTo( "3" ); - final OptionSpec<String> g = parser.accepts( "g" ).withOptionalArg().defaultsTo( "4" ); - final OptionSpec<Void> h = parser.accepts( "h" ); - - OptionSet options = parser.parse( "-a", "-e", "-c", "5", "-d", "6", "-b", "4", "-d", "7", "-e", "8" ); - - Map<OptionSpec<?>, List<?>> expected = new HashMap<OptionSpec<?>, List<?>>() { - private static final long serialVersionUID = Long.MIN_VALUE; - - { - put( a, emptyList() ); - put( b, asList( "4" ) ); - put( c, asList( "5" ) ); - put( d, asList( "6", "7" ) ); - put( e, asList( "8" ) ); - put( f, asList( "3" ) ); - put( g, asList( "4" ) ); - put( h, emptyList() ); - } - }; - - assertThat( options.asMap(), is( equalTo( expected ) ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetDetectedOptionsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetDetectedOptionsTest.java deleted file mode 100644 index 3a7766472e..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetDetectedOptionsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Arrays; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSetDetectedOptionsTest extends AbstractOptionParserFixture { - @Test - public void givesSpecsInOrderOfCommandLinePresentation() { - OptionSpec<Void> a = parser.accepts( "a" ); - OptionSpec<String> b = parser.accepts( "b" ).withRequiredArg(); - OptionSpec<String> c = parser.accepts( "c" ).withOptionalArg(); - OptionSpec<String> d = parser.accepts( "d" ).withRequiredArg().defaultsTo( "1" ); - OptionSpec<String> e = parser.accepts( "e" ).withOptionalArg().defaultsTo( "2" ); - - OptionSet options = parser.parse( "-a", "-e", "-c", "5", "-d", "6", "-b", "4", "-d", "7", "-e", "8" ); - - assertEquals( Arrays.asList( a, e, c, d, b, d, e ), options.specs() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetEqualsHashCodeTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetEqualsHashCodeTest.java deleted file mode 100644 index 28757ff0c8..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetEqualsHashCodeTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collections; - -import org.infinitest.toolkit.StrictEqualsHashCodeTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSetEqualsHashCodeTest extends StrictEqualsHashCodeTestSupport { - @Override - protected OptionSet equal() { - OptionSet options = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - options.addWithArgument( new RequiredArgumentOptionSpec<String>( "anOption" ), "anArg" ); - return options; - } - - @Override - protected OptionSet notEqual() { - OptionSet options = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - options.addWithArgument( new RequiredArgumentOptionSpec<String>( "anOption" ), "aDifferentArg" ); - return options; - } - - @Override - protected Object equalButDifferentClass() { - OptionSet options = - new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ) { - // anonymous subclass - }; - options.addWithArgument( new RequiredArgumentOptionSpec<String>( "anOption" ), "anArg" ); - return options; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetNonOptionArgumentsImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetNonOptionArgumentsImmutabilityTest.java deleted file mode 100644 index 7a2f352a51..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetNonOptionArgumentsImmutabilityTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collections; -import java.util.List; - -import org.infinitest.toolkit.UnmodifiableListTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSetNonOptionArgumentsImmutabilityTest extends UnmodifiableListTestSupport<String> { - @SuppressWarnings( "unchecked" ) - @Override - protected List<String> newList() { - OptionSet options = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - NonOptionArgumentSpec<String> nonOptions = new NonOptionArgumentSpec<>( null ); - options.addWithArgument( nonOptions, "1" ); - options.addWithArgument( nonOptions, "2" ); - return (List<String>) options.nonOptionArguments(); - } - - @Override - protected String newItem() { - return "3"; - } - - @Override - protected String containedItem() { - return "2"; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetSpecsImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetSpecsImmutabilityTest.java deleted file mode 100644 index d728828c12..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetSpecsImmutabilityTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collections; -import java.util.List; - -import org.infinitest.toolkit.UnmodifiableListTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSetSpecsImmutabilityTest extends UnmodifiableListTestSupport<OptionSpec<?>> { - @Override - protected List<OptionSpec<?>> newList() { - OptionSet options = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - options.add( new NoArgumentOptionSpec( "a" ) ); - return options.specs(); - } - - @Override - protected OptionSpec<?> newItem() { - return new NoArgumentOptionSpec( "b" ); - } - - @Override - protected OptionSpec<?> containedItem() { - return new NoArgumentOptionSpec( "a" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetValuesOfOptionStringImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetValuesOfOptionStringImmutabilityTest.java deleted file mode 100644 index 6f5189a196..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetValuesOfOptionStringImmutabilityTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collections; -import java.util.List; - -import org.infinitest.toolkit.UnmodifiableListTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSetValuesOfOptionStringImmutabilityTest extends UnmodifiableListTestSupport<Object> { - @SuppressWarnings( "unchecked" ) - @Override - protected List<Object> newList() { - RequiredArgumentOptionSpec<String> optionB = new RequiredArgumentOptionSpec<>( "b" ); - OptionSet options = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - options.addWithArgument( optionB, "foo" ); - options.addWithArgument( optionB, "bar" ); - - return (List<Object>) options.valuesOf( "b" ); - } - - @Override - protected String newItem() { - return "baz"; - } - - @Override - protected String containedItem() { - return "bar"; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetValuesOfSpecImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetValuesOfSpecImmutabilityTest.java deleted file mode 100644 index 146652a861..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSetValuesOfSpecImmutabilityTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collections; -import java.util.List; - -import org.infinitest.toolkit.UnmodifiableListTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSetValuesOfSpecImmutabilityTest extends UnmodifiableListTestSupport<String> { - @Override - protected List<String> newList() { - RequiredArgumentOptionSpec<String> optionA = new RequiredArgumentOptionSpec<>( "a" ); - OptionSet options = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - options.addWithArgument( optionA, "anArgument" ); - options.addWithArgument( optionA, "anotherArgument" ); - return options.valuesOf( optionA ); - } - - @Override - protected String newItem() { - return "yetAnotherArgument"; - } - - @Override - protected String containedItem() { - return "anArgument"; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecBuilderOptionsImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecBuilderOptionsImmutabilityTest.java deleted file mode 100644 index 231e690cc3..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecBuilderOptionsImmutabilityTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSpecBuilderOptionsImmutabilityTest extends AbstractOptionSpecOptionsImmutabilityTestCase { - @Override - protected AbstractOptionSpec<?> newOptionSpec( String option ) { - return new OptionSpecBuilder( new OptionParser(), asList( option ), "" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecBuilderValuesImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecBuilderValuesImmutabilityTest.java deleted file mode 100644 index 3adc17dadc..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecBuilderValuesImmutabilityTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSpecBuilderValuesImmutabilityTest extends AbstractOptionSpecValuesImmutabilityTestCase<Void> { - @Override - protected AbstractOptionSpec<Void> newOptionSpec() { - return new OptionSpecBuilder( new OptionParser(), asList( "a" ), "" ); - } - - @Override - protected String firstArg() { - return "Q"; - } - - @Override - protected String secondArg() { - return "W"; - } - - @Override - protected Void newItem() { - return null; - } - - @Override - protected Void containedItem() { - return null; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecTokenizerTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecTokenizerTest.java deleted file mode 100644 index 6e403078f7..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecTokenizerTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.NoSuchElementException; - -import static java.util.Collections.*; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.infinitest.toolkit.CollectionMatchers.*; -import static org.junit.Assert.*; -import static org.junit.rules.ExpectedException.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSpecTokenizerTest { - @Rule public final ExpectedException thrown = none(); - - @Test - public void tokenizeEmpty() { - assertNoMoreTokens( new OptionSpecTokenizer( "" ) ); - } - - @Test - public void tokenizeOptionsWithoutArguments() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "ab" ); - assertNextTokenTakesNoArgument( lexer, 'a', false ); - assertNextTokenTakesNoArgument( lexer, 'b', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void tokenizeOptionsWithRequiredArguments() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "c:d:" ); - assertNextTokenRequiresAnArgument( lexer, 'c', false ); - assertNextTokenRequiresAnArgument( lexer, 'd', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void tokenizeOptionsWithOptionalArguments() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "e::f::" ); - assertNextTokenTakesAnOptionalArgument( lexer, 'e', false ); - assertNextTokenTakesAnOptionalArgument( lexer, 'f', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void tokenizeOptionsWithMixtureOfSpecTypes() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "gh:i::j" ); - assertNextTokenTakesNoArgument( lexer, 'g', false ); - assertNextTokenRequiresAnArgument( lexer, 'h', false ); - assertNextTokenTakesAnOptionalArgument( lexer, 'i', false ); - assertNextTokenTakesNoArgument( lexer, 'j', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void wByItself() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "W" ); - assertNextTokenTakesNoArgument( lexer, 'W', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void wRequiredArg() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "W:" ); - assertNextTokenRequiresAnArgument( lexer, 'W', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void wOptionalArg() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "W::" ); - assertNextTokenTakesAnOptionalArgument( lexer, 'W', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void alternativeLongOptionsMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "W;" ); - assertNextTokenRequiresAnArgument( lexer, 'W', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void tokenizeOptionsWithoutArgumentsAndHelpMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "ab*" ); - assertNextTokenTakesNoArgument( lexer, 'a', false ); - assertNextTokenTakesNoArgument( lexer, 'b', true ); - assertNoMoreTokens( lexer ); - } - - @Test - public void tokenizeOptionsWithRequiredArgumentsAndHelpMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "c*:d:" ); - assertNextTokenRequiresAnArgument( lexer, 'c', true ); - assertNextTokenRequiresAnArgument( lexer, 'd', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void tokenizeOptionsWithOptionalArgumentsAndHelpMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "e*::f*::" ); - assertNextTokenTakesAnOptionalArgument( lexer, 'e', true ); - assertNextTokenTakesAnOptionalArgument( lexer, 'f', true ); - assertNoMoreTokens( lexer ); - } - - @Test - public void tokenizeOptionsWithMixtureOfSpecTypesAndHelpMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "g*h:i*::j" ); - assertNextTokenTakesNoArgument( lexer, 'g', true ); - assertNextTokenRequiresAnArgument( lexer, 'h', false ); - assertNextTokenTakesAnOptionalArgument( lexer, 'i', true ); - assertNextTokenTakesNoArgument( lexer, 'j', false ); - assertNoMoreTokens( lexer ); - } - - @Test - public void wByItselfWithHelpMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "W*" ); - assertNextTokenTakesNoArgument( lexer, 'W', true ); - assertNoMoreTokens( lexer ); - } - - @Test - public void wRequiredArgWithHelpMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "W*:" ); - assertNextTokenRequiresAnArgument( lexer, 'W', true ); - assertNoMoreTokens( lexer ); - } - - @Test - public void wOptionalArgWithHelpMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "W*::" ); - assertNextTokenTakesAnOptionalArgument( lexer, 'W', true ); - assertNoMoreTokens( lexer ); - } - - @Test - public void alternativeLongOptionsMarkerWithHelpMarker() { - OptionSpecTokenizer lexer = new OptionSpecTokenizer( "W*;" ); - assertNextTokenTakesNoArgument( lexer, 'W', true ); - } - - private void assertNoMoreTokens( OptionSpecTokenizer lexer ) { - assertFalse( lexer.hasMore() ); - - thrown.expect( NoSuchElementException.class ); - lexer.next(); - } - - private static void assertNextTokenTakesNoArgument( OptionSpecTokenizer lexer, char option, boolean forHelp ) { - assertNextToken( lexer, option, false, false, forHelp ); - } - - private static void assertNextTokenRequiresAnArgument( OptionSpecTokenizer lexer, char option, boolean forHelp ) { - assertNextToken( lexer, option, true, true, forHelp ); - } - - private static void assertNextTokenTakesAnOptionalArgument( OptionSpecTokenizer lexer, char option, - boolean forHelp ) { - - assertNextToken( lexer, option, true, false, forHelp ); - } - - private static void assertNextToken( OptionSpecTokenizer lexer, char option, boolean acceptsArguments, - boolean requiresArgument, boolean forHelp ) { - - assertTrue( "no more tokens?", lexer.hasMore() ); - AbstractOptionSpec<?> spec = lexer.next(); - assertThat( "option?", spec.options(), hasSameContentsAs( singleton( String.valueOf( option ) ) ) ); - assertEquals( "accepts args?", acceptsArguments, spec.acceptsArguments() ); - assertEquals( "requires arg?", requiresArgument, spec.requiresArgument() ); - assertEquals( "for help?", forHelp, spec.isForHelp() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecsReportTheirOptionsSortedSpeciallyTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecsReportTheirOptionsSortedSpeciallyTest.java deleted file mode 100644 index ff531dd198..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSpecsReportTheirOptionsSortedSpeciallyTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.ArrayList; -import java.util.List; - -import static java.util.Arrays.*; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSpecsReportTheirOptionsSortedSpeciallyTest { - @Test - public void shortOptionsComeFirstFollowedByLongOptionsLexicographically() { - AbstractOptionSpec<Void> spec = new NoArgumentOptionSpec( asList( "after-date", "n", "N", "past" ), "" ); - - List<String> actualOptions = new ArrayList<>( spec.options() ); - - assertEquals( asList( "N", "n", "after-date", "past" ), actualOptions ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymCommonPrefixesTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymCommonPrefixesTest.java deleted file mode 100644 index 986761d7ff..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymCommonPrefixesTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -import org.junit.Before; -import org.junit.Test; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSynonymCommonPrefixesTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.acceptsAll( asList( "v", "verbose" ) ); - } - - @Test - public void parsingFirstPrefix() { - assertDetections( "-v" ); - } - - @Test - public void parsingSecondPrefix() { - assertDetections( "-ve" ); - } - - @Test - public void parsingThirdPrefix() { - assertDetections( "-ver" ); - } - - @Test - public void parsingFourthPrefix() { - assertDetections( "-verb" ); - } - - @Test - public void parsingFifthPrefix() { - assertDetections( "-verbo" ); - } - - @Test - public void parsingSixthPrefix() { - assertDetections( "-verbos" ); - } - - @Test - public void parsingSeventhPrefix() { - assertDetections( "-verbose" ); - } - - private void assertDetections( String option ) { - OptionSet options = parser.parse( option ); - - assertOptionDetected( options, "v" ); - assertOptionNotDetected( options, "ve" ); - assertOptionNotDetected( options, "ver" ); - assertOptionNotDetected( options, "verb" ); - assertOptionNotDetected( options, "verbo" ); - assertOptionNotDetected( options, "verbos" ); - assertOptionDetected( options, "verbose" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymNoArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymNoArgumentTest.java deleted file mode 100644 index 2b66176194..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymNoArgumentTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSynonymNoArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.acceptsAll( asList( "N", "after-date", "newer" ) ); - } - - @Test - public void hasAllSynonymsWhenFirstSynonymParsed() { - assertDetections( "-N" ); - } - - @Test - public void hasAllSynonymsWhenSecondSynonymParsed() { - assertDetections( "--after-d" ); - } - - @Test - public void hasAllSynonymsWhenThirdSynonymParsed() { - assertDetections( "--n" ); - } - - private void assertDetections( String option ) { - OptionSet options = parser.parse( option ); - - assertOptionDetected( options, "N" ); - assertOptionDetected( options, "after-date" ); - assertOptionDetected( options, "newer" ); - assertEquals( emptyList(), options.valuesOf( "N" ) ); - assertEquals( emptyList(), options.valuesOf( "after-date" ) ); - assertEquals( emptyList(), options.valuesOf( "newer" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymOptionalArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymOptionalArgumentTest.java deleted file mode 100644 index 5ff03e5cba..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymOptionalArgumentTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.io.File; -import java.util.List; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSynonymOptionalArgumentTest extends AbstractOptionParserFixture { - private String optionArgument; - - @Before - public final void initializeParser() { - parser.acceptsAll( asList( "d", "output-dir", "folder" ), "file" ).withRequiredArg().ofType( File.class ); - optionArgument = "tmp"; - } - - @Test - public void hasAllSynonymsWhenFirstSynonymParsed() { - assertDetections( new String[] { "-d", optionArgument }, singletonList( new File( optionArgument ) ) ); - } - - @Test - public void hasAllSynonymsWhenSecondSynonymParsed() { - assertDetections( new String[] { "--ou", optionArgument }, singletonList( new File( optionArgument ) ) ); - } - - @Test - public void hasAllSynonymsWhenThirdSynonymParsed() { - assertDetections( new String[] { "--fold", optionArgument }, singletonList( new File( optionArgument ) ) ); - } - - @Test - public void reportsSameListOfArgumentsForEverySynonymOption() { - assertDetections( - new String[] { "-d", "opt", "--output-dir", "tmp", "--folder", "usr" }, - asList( new File( "opt" ), new File( "tmp" ), new File( "usr" ) ) ); - } - - private void assertDetections( String[] args, List<?> optionArguments ) { - OptionSet options = parser.parse( args ); - assertEquals( optionArguments, options.valuesOf( "d" ) ); - assertEquals( optionArguments, options.valuesOf( "output-dir" ) ); - assertEquals( optionArguments, options.valuesOf( "folder" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymOverwritingTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymOverwritingTest.java deleted file mode 100644 index 3294d341fa..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymOverwritingTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -import org.junit.Before; -import org.junit.Test; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSynonymOverwritingTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.acceptsAll( asList( "h", "help" ) ); - parser.acceptsAll( asList( "h", "oops" ) ); - } - - @Test - public void treatsHAsThoughItWereLastDefinedSynonymOfH() { - OptionSet options = parser.parse( "-h" ); - - assertOptionDetected( options, "h" ); - assertOptionDetected( options, "oops" ); - assertOptionNotDetected( options, "help" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymRequiredArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymRequiredArgumentTest.java deleted file mode 100644 index 10d788907d..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionSynonymRequiredArgumentTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionSynonymRequiredArgumentTest extends AbstractOptionParserFixture { - private String optionArgument; - - @Before - public final void initializeParser() { - parser.acceptsAll( asList( "N", "after-date", "newer" ), "date" ).withRequiredArg().ofType( Integer.class ); - optionArgument = "2000"; - } - - @Test - public void hasAllSynonymsWhenFirstSynonymParsed() { - assertDetections( new String[] { "-N", optionArgument }, singletonList( Integer.valueOf( optionArgument ) ) ); - } - - @Test - public void hasAllSynonymsWhenSecondSynonymParsed() { - assertDetections( - new String[] { "--after-date", optionArgument }, - singletonList( Integer.valueOf( optionArgument ) ) ); - } - - @Test - public void hasAllSynonymsWhenThirdSynonymParsed() { - assertDetections( - new String[] { "--newer", optionArgument }, - singletonList( Integer.valueOf( optionArgument ) ) ); - } - - @Test - public void reportsSameListOfArgumentsForEverySynonymOption() { - assertDetections( new String[] { "-N", "1", "-aft", "2", "--ne", "3" }, asList( 1, 2, 3 ) ); - } - - private void assertDetections( String[] args, List<?> optionArguments ) { - OptionSet options = parser.parse( args ); - - assertEquals( optionArguments, options.valuesOf( "N" ) ); - assertEquals( optionArguments, options.valuesOf( "after-date" ) ); - assertEquals( optionArguments, options.valuesOf( "newer" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecOptionsImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecOptionsImmutabilityTest.java deleted file mode 100644 index 86765a55ab..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecOptionsImmutabilityTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionalArgumentOptionSpecOptionsImmutabilityTest extends AbstractOptionSpecOptionsImmutabilityTestCase { - @Override - protected AbstractOptionSpec<?> newOptionSpec( String option ) { - return new OptionalArgumentOptionSpec<Integer>( option ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecTest.java deleted file mode 100644 index 6f5c275ced..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -import org.junit.Test; - -import static org.infinitest.toolkit.CollectionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionalArgumentOptionSpecTest extends AbstractOptionSpecFixture { - @Override - protected OptionalArgumentOptionSpec<?> createEqualOptionSpecInstance() { - return new OptionalArgumentOptionSpec<Void>( "d" ); - } - - @Override - protected OptionalArgumentOptionSpec<?> createNotEqualOptionSpecInstance() { - return new OptionalArgumentOptionSpec<Void>( "c" ); - } - - @Test - public void optionsContents() { - assertThat( createNotEqualOptionSpecInstance().options(), hasSameContentsAs( asList( "c" ) ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecValuesImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecValuesImmutabilityTest.java deleted file mode 100644 index 841b9460c7..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/OptionalArgumentOptionSpecValuesImmutabilityTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class OptionalArgumentOptionSpecValuesImmutabilityTest - extends AbstractOptionSpecValuesImmutabilityTestCase<Integer> { - - @Override - protected AbstractOptionSpec<Integer> newOptionSpec() { - return new OptionalArgumentOptionSpec<Integer>( "life" ).ofType( Integer.class ); - } - - @Override - protected String firstArg() { - return "1"; - } - - @Override - protected String secondArg() { - return "2"; - } - - @Override - protected Integer newItem() { - return 3; - } - - @Override - protected Integer containedItem() { - return 2; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ParserRulesUtilityClassTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ParserRulesUtilityClassTest.java deleted file mode 100644 index 82317befba..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ParserRulesUtilityClassTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ParserRulesUtilityClassTest extends UtilityClassesUninstantiabilityHarness { - public ParserRulesUtilityClassTest() { - super( ParserRules.class ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedConvertedOptionValuesTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedConvertedOptionValuesTest.java deleted file mode 100644 index 4e18003782..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedConvertedOptionValuesTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.io.File; - -import static java.util.Arrays.*; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ParsingSeparatedConvertedOptionValuesTest extends AbstractOptionParserFixture { - @Test - public void parsesSeparatedValuesAsSeparateArgument() { - assertCorrectParse( "classpath", ':', "--classpath", "/usr:/opt:/var" ); - } - - @Test - public void parsesSeparatedValuesWhenArgumentAbuttedWithEquals() { - assertCorrectParse( "classpath", ':', "--classpath=/usr:/opt:/var" ); - } - - @Test - public void parsesEqualsSeparatedValuesWhenArgumentAbuttedWithEquals() { - assertCorrectParse( "classpath", '=', "--classpath=/usr=/opt=/var" ); - } - - @Test - public void parsesSeparatedValuesAbutting() { - assertCorrectParse( "c", ':', "-c/usr:/opt:/var" ); - } - - private void assertCorrectParse( String option, char separator, String... args ) { - parser.accepts( option ).withRequiredArg().withValuesSeparatedBy( separator ) - .withValuesConvertedBy( new ValueConverter<File>() { - public File convert( String value ) { - return new File( value ); - } - - public Class<File> valueType() { - return File.class; - } - - public String valuePattern() { - return null; - } - } ); - - OptionSet options = parser.parse( args ); - - assertEquals( - asList( new File( "/usr" ), new File( "/opt" ), new File( "/var" ) ), - options.valuesOf( option ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedStringOptionValuesTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedStringOptionValuesTest.java deleted file mode 100644 index 6cfe17f862..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedStringOptionValuesTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ParsingSeparatedStringOptionValuesTest extends AbstractOptionParserFixture { - @Test - public void parsesSeparatedValuesAsSeparateArgument() { - assertCorrectParse( "classpath", ":::", "--classpath", "/usr:::/opt:::/var" ); - } - - @Test - public void parsesSeparatedValuesWhenArgumentAbuttedWithEquals() { - assertCorrectParse( "classpath", ":", "--classpath=/usr:/opt:/var" ); - } - - @Test - public void parsesEqualsSeparatedValuesWhenArgumentAbuttedWithEquals() { - assertCorrectParse( "classpath", ":=", "--classpath=/usr:=/opt:=/var" ); - } - - @Test - public void parsesSeparatedValuesAbutting() { - assertCorrectParse( "c", ";", "-c/usr;/opt;/var" ); - } - - @Test - public void parsesHyphenSeparatedValuesAbutting() { - assertCorrectParse( "c", "--", "-c/usr--/opt--/var" ); - } - - @Test - public void handlesConsecutiveDelimiters() { - assertCorrectParse( "c", ",", "-c,/usr,,,/opt,,,/var,,,,," ); - } - - private void assertCorrectParse( String option, String separator, String... args ) { - parser.accepts( option ).withRequiredArg().withValuesSeparatedBy( separator ); - - OptionSet options = parser.parse( args ); - - assertEquals( asList( "/usr", "/opt", "/var" ), options.valuesOf( option ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedTypedOptionValuesTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedTypedOptionValuesTest.java deleted file mode 100644 index 0cfc1e93fb..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ParsingSeparatedTypedOptionValuesTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.io.File; - -import static java.util.Arrays.*; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ParsingSeparatedTypedOptionValuesTest extends AbstractOptionParserFixture { - @Test - public void parsesSeparatedValuesAsSeparateArgument() { - assertCorrectParse( "classpath", ':', "--classpath", "/usr:/opt:/var" ); - } - - @Test - public void parsesSeparatedValuesWhenArgumentAbuttedWithEquals() { - assertCorrectParse( "classpath", ':', "--classpath=/usr:/opt:/var" ); - } - - @Test - public void parsesEqualsSeparatedValuesWhenArgumentAbuttedWithEquals() { - assertCorrectParse( "classpath", '=', "--classpath=/usr=/opt=/var" ); - } - - @Test - public void parsesSeparatedValuesAbutting() { - assertCorrectParse( "c", ':', "-c/usr:/opt:/var" ); - } - - private void assertCorrectParse( String option, char separator, String... args ) { - parser.accepts( option ).withRequiredArg().ofType( File.class ).withValuesSeparatedBy( separator ); - - OptionSet options = parser.parse( args ); - - assertEquals( - asList( new File( "/usr" ), new File( "/opt" ), new File( "/var" ) ), - options.valuesOf( option ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/PlainOldOptionParserTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/PlainOldOptionParserTest.java deleted file mode 100644 index 3fe8f509f8..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/PlainOldOptionParserTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class PlainOldOptionParserTest extends AbstractOptionParserFixture { - @Test - public void nonOptionsOnly() { - String[] arguments = { "foo", "bar" }; - - OptionSet options = parser.parse( arguments ); - - assertEquals( asList( arguments ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/PopulatedOptionSetTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/PopulatedOptionSetTest.java deleted file mode 100644 index 5ac50368d2..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/PopulatedOptionSetTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package joptsimple; - -import java.util.Collections; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class PopulatedOptionSetTest { - private OptionSet populated; - - @Before - public void setUp() { - populated = new OptionSet( Collections.<String, AbstractOptionSpec<?>> emptyMap() ); - populated.add( new NoArgumentOptionSpec( "a" ) ); - populated.addWithArgument( new RequiredArgumentOptionSpec<String>( "b" ), "arg-of-b" ); - } - - @Test - public void hasArgument() { - assertFalse( populated.hasArgument( "a" ) ); - assertTrue( populated.hasArgument( "b" ) ); - } - - @Test - public void valueOf() { - assertNull( populated.valueOf( "a" ) ); - assertEquals( "arg-of-b", populated.valueOf( "b" ) ); - } - - @Test - public void valuesOf() { - assertEquals( emptyList(), populated.valuesOf( "a" ) ); - assertEquals( singletonList( "arg-of-b" ), populated.valuesOf( "b" ) ); - } - - @Test - public void hasOptions() { - assertTrue( populated.hasOptions() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/PosixlyCorrectOptionParserTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/PosixlyCorrectOptionParserTest.java deleted file mode 100644 index 027c0a29c7..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/PosixlyCorrectOptionParserTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collection; - -import static java.util.Arrays.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -@RunWith( Parameterized.class ) -public class PosixlyCorrectOptionParserTest { - private final OptionParser parser; - - public PosixlyCorrectOptionParserTest( OptionParser parser ) { - this.parser = parser; - } - - @Parameterized.Parameters - public static Collection<?> parsers() { - return asList( new Object[] { - new OptionParser() { { - posixlyCorrect( true ); - accepts( "i" ).withRequiredArg(); - accepts( "j" ).withOptionalArg(); - accepts( "k" ); - } } }, - new Object[] { new OptionParser( "+i:j::k" ) } ); - } - - @Test - public void parseWithPosixlyCorrect() { - OptionSet options = - parser.parse( "-ibar", "-i", "junk", "xyz", "-jixnay", "foo", "-k", "blah", "--", "yermom" ); - - assertTrue( "i?", options.has( "i" ) ); - assertFalse( "j?", options.has( "j" ) ); - assertFalse( "k?", options.has( "k" ) ); - assertEquals( "args of i?", asList( "bar", "junk" ), options.valuesOf( "i" ) ); - assertEquals( "non-option args?", - asList( "xyz", "-jixnay", "foo", "-k", "blah", "--", "yermom" ), - options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/PunctuationInLongOptionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/PunctuationInLongOptionTest.java deleted file mode 100644 index 94e4e23a76..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/PunctuationInLongOptionTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class PunctuationInLongOptionTest extends AbstractOptionParserFixture { - @Test - public void allowsHyphensInTheMiddleOfOptionNames() { - assertOptionAllowed( "hyphenated-option" ); - } - - @Test - public void allowsHyphensPrettyMuchAnywhereButTheFront() { - assertOptionAllowed( "a-cra-zy-but-le--gal---o-p-t-i-o--n-----" ); - } - - @Test( expected = IllegalOptionSpecificationException.class ) - public void disallowsHyphensAtFrontOfOptionName() { - parser.accepts( "-weird-option" ); - } - - @Test - public void allowsDotInOptionNames() { - assertOptionAllowed( "..what.is.the.d..e...a....l..." ); - } - - @Test - public void allowsQuestionMarkInOptionNames() { - assertOptionAllowed( "??who?k??n???e????w?" ); - } - - @Test - public void allowsUnderscoreInOptionNames() { - assertOptionAllowed( "super_long_option_name" ); - } - - private void assertOptionAllowed( String option ) { - parser.accepts( option ); - - OptionSet options = parser.parse( "--" + option ); - - assertTrue( options.has( option ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/PunctuationInShortOptionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/PunctuationInShortOptionTest.java deleted file mode 100644 index 20565b9b9b..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/PunctuationInShortOptionTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class PunctuationInShortOptionTest { - @Test( expected = IllegalOptionSpecificationException.class ) - public void disallowsHyphenAsShortOption() { - new OptionParser( "-" ); - } - - @Test - public void allowsQuestionMarkAsShortOption() { - assertOptionAllowed( "?" ); - } - - @Test - public void allowsDotAsShortOption() { - assertOptionAllowed( "." ); - } - - @Test - public void allowsUnderscoreAsShortOption() { - assertOptionAllowed( "_" ); - } - - private void assertOptionAllowed( String option ) { - OptionSet options = new OptionParser( option ).parse( '-' + option ); - - assertTrue( options.has( option ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecEqualsHashCodeTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecEqualsHashCodeTest.java deleted file mode 100644 index 9235d5cc12..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecEqualsHashCodeTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class RequiredArgumentOptionSpecEqualsHashCodeTest extends AbstractOptionSpecFixture { - @Override - protected RequiredArgumentOptionSpec<?> createEqualOptionSpecInstance() { - return new RequiredArgumentOptionSpec<Void>( "a" ); - } - - @Override - protected RequiredArgumentOptionSpec<?> createNotEqualOptionSpecInstance() { - return new RequiredArgumentOptionSpec<Void>( "b" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecOptionsImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecOptionsImmutabilityTest.java deleted file mode 100644 index e834d1b745..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecOptionsImmutabilityTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class RequiredArgumentOptionSpecOptionsImmutabilityTest extends AbstractOptionSpecOptionsImmutabilityTestCase { - @Override - protected AbstractOptionSpec<?> newOptionSpec( String option ) { - return new RequiredArgumentOptionSpec<String>( option ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecValuesImmutabilityTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecValuesImmutabilityTest.java deleted file mode 100644 index f75a068b75..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredArgumentOptionSpecValuesImmutabilityTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class RequiredArgumentOptionSpecValuesImmutabilityTest - extends AbstractOptionSpecValuesImmutabilityTestCase<String> { - - @Override - protected AbstractOptionSpec<String> newOptionSpec() { - return new RequiredArgumentOptionSpec<>( "file" ); - } - - @Override - protected String firstArg() { - return "arg1"; - } - - @Override - protected String secondArg() { - return "arg2"; - } - - @Override - protected String newItem() { - return "arg3"; - } - - @Override - protected String containedItem() { - return "arg1"; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredIfAnyTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredIfAnyTest.java deleted file mode 100644 index 75c39d8121..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredIfAnyTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class RequiredIfAnyTest extends AbstractOptionParserFixture { - @Before - public void configureParser() { - parser.accepts( "a" ); - parser.accepts( "b" ); - OptionSpec<Void> c = parser.accepts( "c" ); - OptionSpec<Void> d = parser.accepts( "d" ); - parser.accepts( "e" ); - parser.accepts( "n" ).requiredIf( "a", "b" ).requiredIf( c, d ); - } - - @Test - public void rejectsCommandLineMissingConditionallyRequiredOption() { - thrown.expect( MissingRequiredOptionsException.class ); - - parser.parse( "-a" ); - } - - @Test - public void rejectsCommandLineMissingOtherConditionallyRequiredOption() { - thrown.expect( MissingRequiredOptionsException.class ); - - parser.parse( "-b" ); - } - - @Test - public void rejectsCommandLineWithNotAllConditionallyRequiredOptionsPresent() { - thrown.expect( MissingRequiredOptionsException.class ); - - parser.parse( "-a", "-b", "-c", "-d" ); - } - - @Test - public void acceptsCommandLineWithConditionallyRequiredOptionsPresent() { - OptionSet options = parser.parse( "-b", "-n" ); - - assertOptionDetected( options, "b" ); - assertOptionDetected( options, "n" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void acceptsOptionWithPrerequisiteAsNormalIfPrerequisiteNotInPlay() { - OptionSet options = parser.parse( "-n" ); - - assertOptionDetected( options, "n" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredIfTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredIfTest.java deleted file mode 100644 index d5cbb17c28..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredIfTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class RequiredIfTest extends AbstractOptionParserFixture { - @Before - public void configureParser() { - OptionSpec<Void> ftp = parser.acceptsAll( asList( "ftp", "file-transfer" ) ); - parser.acceptsAll( asList( "username", "userid" ) ).requiredIf( "file-transfer" ).withRequiredArg(); - parser.acceptsAll( asList( "password", "pwd" ) ).requiredIf( ftp ).withRequiredArg(); - parser.accepts( "?" ).forHelp(); - } - - @Test - public void rejectsCommandLineMissingConditionallyRequiredOption() { - thrown.expect( MissingRequiredOptionsException.class ); - - parser.parse( "--ftp" ); - } - - @Test - public void rejectsCommandLineMissingConditionallyRequiredOptionSynonym() { - thrown.expect( MissingRequiredOptionsException.class ); - - parser.parse( "--file-transfer" ); - } - - @Test - public void rejectsCommandLineWithNotAllConditionallyRequiredOptionsPresent() { - thrown.expect( MissingRequiredOptionsException.class ); - - parser.parse( "--ftp", "--username", "joe" ); - } - - @Test - public void acceptsCommandLineWithConditionallyRequiredOptionsPresent() { - OptionSet options = parser.parse( "--ftp", "--userid", "joe", "--password=secret" ); - - assertOptionDetected( options, "ftp" ); - assertOptionDetected( options, "username" ); - assertOptionDetected( options, "password" ); - assertEquals( singletonList( "joe" ), options.valuesOf( "username" ) ); - assertEquals( singletonList( "secret" ), options.valuesOf( "password" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void acceptsOptionWithPrerequisiteAsNormalIfPrerequisiteNotInPlay() { - OptionSet options = parser.parse( "--pwd", "secret" ); - - assertOptionDetected( options, "pwd" ); - assertEquals( singletonList( "secret" ), options.valuesOf( "pwd" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void rejectsOptionNotAlreadyConfigured() { - thrown.expect( UnconfiguredOptionException.class ); - - parser.accepts( "foo" ).requiredIf( "bar" ); - } - - @Test - public void rejectsOptionSpecNotAlreadyConfigured() { - thrown.expect( UnconfiguredOptionException.class ); - - parser.accepts( "foo" ).requiredIf( "bar" ); - } - - @Test - public void presenceOfHelpOptionNegatesRequiredIfness() { - OptionSet options = parser.parse( "--ftp", "-?" ); - - assertOptionDetected( options, "ftp" ); - assertOptionDetected( options, "?" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredUnlessAnyTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredUnlessAnyTest.java deleted file mode 100644 index d61dd78206..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredUnlessAnyTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -import static java.util.Collections.emptyList; -import static org.junit.Assert.assertEquals; - -public class RequiredUnlessAnyTest extends AbstractOptionParserFixture { - @Before - public void configureParser() { - parser.accepts( "a" ); - parser.accepts( "b" ); - OptionSpec<Void> c = parser.accepts( "c" ); - OptionSpec<Void> d = parser.accepts( "d" ); - parser.accepts( "e" ); - parser.accepts( "n" ).requiredUnless( "a", "b" ).requiredUnless( c, d ); - } - - @Test - public void commandLineMissingConditionallyRequiredOption() { - OptionSet options = parser.parse( "-a" ); - assertOptionDetected( options, "a" ); - assertOptionNotDetected( options, "n" ); - } - - @Test - public void commandLineWithNotAllConditionallyRequiredOptionsPresent() { - OptionSet options = parser.parse( "-a", "-b", "-c", "-d" ); - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertOptionDetected( options, "c" ); - assertOptionDetected( options, "d" ); - assertOptionNotDetected( options, "n" ); - } - - @Test - public void acceptsCommandLineWithConditionallyRequiredOptionsPresent() { - OptionSet options = parser.parse( "-n" ); - - assertOptionDetected( options, "n" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void acceptsOptionWithPrerequisiteAsNormalIfPrerequisiteNotInPlay() { - OptionSet options = parser.parse( "-a", "-n" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "n" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredUnlessTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredUnlessTest.java deleted file mode 100644 index ed5b47b023..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/RequiredUnlessTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Before; -import org.junit.Test; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.junit.Assert.assertEquals; - -public class RequiredUnlessTest extends AbstractOptionParserFixture { - @Before - public void configureParser() { - OptionSpec<Void> anonymous = parser.accepts( "anonymous" ); - parser.acceptsAll( asList( "username", "userid" ) ).requiredUnless( "anonymous" ).withRequiredArg(); - parser.acceptsAll( asList( "password", "pwd" ) ).requiredUnless( anonymous ).withRequiredArg(); - parser.accepts( "?" ).forHelp(); - } - - @Test - public void rejectsCommandLineMissingConditionallyRequiredOption() { - thrown.expect( MissingRequiredOptionsException.class ); - - parser.parse( "" ); - } - - @Test - public void rejectsCommandLineWithNotAllConditionallyRequiredOptionsPresent() { - thrown.expect( MissingRequiredOptionsException.class ); - - parser.parse( "--username", "joe" ); - } - - @Test - public void acceptsCommandLineWithConditionallyRequiredOptionsPresent() { - OptionSet options = parser.parse( "--userid", "joe", "--password=secret" ); - - assertOptionNotDetected( options, "anonymous" ); - assertOptionDetected( options, "username" ); - assertOptionDetected( options, "password" ); - assertEquals( singletonList( "joe" ), options.valuesOf( "username" ) ); - assertEquals( singletonList( "secret" ), options.valuesOf( "password" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void acceptsOptionWithPrerequisite() { - OptionSet options = parser.parse( "--anonymous" ); - - assertOptionDetected( options, "anonymous" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void acceptsOptionWithPrerequisiteAsNormal() { - OptionSet options = parser.parse( "--anonymous", "--pwd", "secret" ); - - assertOptionDetected( options, "anonymous" ); - assertOptionDetected( options, "pwd" ); - assertEquals( singletonList( "secret" ), options.valuesOf( "pwd" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void rejectsOptionNotAlreadyConfigured() { - thrown.expect( UnconfiguredOptionException.class ); - - parser.accepts( "foo" ).requiredIf( "bar" ); - } - - @Test - public void rejectsOptionSpecNotAlreadyConfigured() { - thrown.expect( UnconfiguredOptionException.class ); - - parser.accepts( "foo" ).requiredIf( "bar" ); - } - - @Test - public void presenceOfHelpOptionNegatesRequiredUnlessness() { - OptionSet options = parser.parse( "-?" ); - - assertOptionDetected( options, "?" ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsNoArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsNoArgumentTest.java deleted file mode 100644 index 6c2af89cda..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsNoArgumentTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ParserRules.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ShortOptionsNoArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "a" ); - parser.accepts( "b" ); - parser.accepts( "c" ); - } - - @Test - public void singleOption() { - OptionSet options = parser.parse( "-a" ); - - assertOptionDetected( options, "a" ); - assertNull( options.valueOf( "a" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void twoSingleOptions() { - OptionSet options = parser.parse( "-a", "-b" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertNull( options.valueOf( "a" ) ); - assertNull( options.valueOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void singleOptionWithOneNonOptionArgument() { - OptionSet options = parser.parse( "-c", "foo" ); - - assertOptionDetected( options, "c" ); - assertNull( options.valueOf( "c" ) ); - assertEquals( singletonList( "foo" ), options.nonOptionArguments() ); - } - - @Test - public void clusteredOptions() { - OptionSet options = parser.parse( "-bac" ); - - assertOptionDetected( options, "a" ); - assertOptionDetected( options, "b" ); - assertOptionDetected( options, "c" ); - assertNull( options.valueOf( "a" ) ); - assertNull( options.valueOf( "b" ) ); - assertNull( options.valueOf( "c" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void optionsTerminator() { - OptionSet options = parser.parse( "-a", OPTION_TERMINATOR, "-a", "-b" ); - - assertOptionDetected( options, "a" ); - assertNull( options.valueOf( "a" ) ); - assertOptionNotDetected( options, "b" ); - assertEquals( asList( "-a", "-b" ), options.nonOptionArguments() ); - } - - @Test - public void appearingMultipleTimes() { - OptionSet options = parser.parse( "-b", "-b", "-b" ); - - assertOptionDetected( options, "b" ); - assertNull( options.valueOf( "b" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsOptionalArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsOptionalArgumentTest.java deleted file mode 100644 index 3616d88c04..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsOptionalArgumentTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ShortOptionsOptionalArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "f" ).withOptionalArg(); - parser.accepts( "g" ).withOptionalArg(); - parser.accepts( "bar" ).withOptionalArg(); - } - - @Test - public void optionWithOptionalArgumentNotPresent() { - OptionSet options = parser.parse( "-f" ); - - assertOptionDetected( options, "f" ); - assertEquals( emptyList(), options.valuesOf( "f" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void optionWithOptionalArgumentPresent() { - OptionSet options = parser.parse( "-f", "bar" ); - - assertOptionDetected( options, "f" ); - assertEquals( singletonList( "bar" ), options.valuesOf( "f" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void optionWithOptionalArgumentThatLooksLikeAnInvalidOption() { - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "biz" ) ); - - parser.parse( "-f", "--biz" ); - } - - @Test - public void optionWithOptionalArgumentThatLooksLikeAValidOption() { - OptionSet options = parser.parse( "-f", "--bar" ); - - assertOptionDetected( options, "f" ); - assertOptionDetected( options, "bar" ); - assertEquals( emptyList(), options.valuesOf( "f" ) ); - assertEquals( emptyList(), options.valuesOf( "bar" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void optionWithOptionalArgumentFollowedByLegalOption() { - OptionSet options = parser.parse( "-f", "-g" ); - - assertOptionDetected( options, "f" ); - assertOptionDetected( options, "g" ); - assertEquals( emptyList(), options.valuesOf( "f" ) ); - assertEquals( emptyList(), options.valuesOf( "g" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void multipleOfSameOptionSomeWithArgsAndSomeWithout() { - OptionSet options = parser.parse( "-f", "-f", "foo", "-f", "-f", "bar", "-f" ); - - assertEquals( asList( "foo", "bar" ), options.valuesOf( "f" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsRequiredArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsRequiredArgumentTest.java deleted file mode 100644 index dea86ca34e..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ShortOptionsRequiredArgumentTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ShortOptionsRequiredArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "d" ).withRequiredArg(); - parser.accepts( "e" ); - parser.accepts( "f" ); - parser.accepts( "infile" ).withOptionalArg(); - } - - @Test - public void argumentNotPresent() { - thrown.expect( OptionMissingRequiredArgumentException.class ); - thrown.expect( withOption( "d" ) ); - - parser.parse( "-d" ); - } - - @Test - public void withArgument() { - OptionSet options = parser.parse( "-d", "foo" ); - - assertOptionDetected( options, "d" ); - assertEquals( "foo", options.valueOf( "d" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void clusteredOptionsWithLastOneAcceptingAnArgumentButMissing() { - thrown.expect( OptionMissingRequiredArgumentException.class ); - - parser.parse( "-fed" ); - } - - @Test - public void clusteredOptionsWithLastOneAcceptingAnArgument() { - OptionSet options = parser.parse( "-fed", "foo" ); - - assertOptionDetected( options, "d" ); - assertOptionDetected( options, "f" ); - assertOptionDetected( options, "e" ); - assertEquals( "foo", options.valueOf( "d" ) ); - } - - @Test - public void clusteredOptionsWithOneAcceptingAnArgument() { - OptionSet options = parser.parse( "-fde" ); - - assertOptionDetected( options, "f" ); - assertOptionDetected( options, "d" ); - assertOptionNotDetected( options, "e" ); - - assertEquals( "e", options.valueOf( "d" ) ); - } - - @Test - public void argumentNotPresentFollowedByAnotherOption() { - OptionSet options = parser.parse( "-d", "--infile" ); - - assertOptionDetected( options, "d" ); - assertOptionNotDetected( options, "infile" ); - assertEquals( "--infile", options.valueOf( "d" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void appearingMultipleTimes() { - OptionSet options = parser.parse( "-d", "foo", "-d", "bar" ); - - assertOptionDetected( options, "d" ); - assertEquals( asList( "foo", "bar" ), options.valuesOf( "d" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void inSameToken() { - OptionSet options = parser.parse( "-dfoo" ); - - assertOptionDetected( options, "d" ); - assertEquals( singletonList( "foo" ), options.valuesOf( "d" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void whenEndOfOptionsMarkerIsInPlaceOfRequiredArgument() { - OptionSet options = parser.parse( "-d", "--", "foo", "bar" ); - - assertOptionDetected( options, "d" ); - assertEquals( singletonList( "--" ), options.valuesOf( "d" ) ); - assertEquals( asList( "foo", "bar" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/SingleHyphenTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/SingleHyphenTest.java deleted file mode 100644 index 7c88a7ddd2..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/SingleHyphenTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class SingleHyphenTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "o" ).withOptionalArg(); - } - - @Test - public void singleHyphen() { - OptionSet options = parser.parse( "-" ); - - assertEquals( singletonList( "-" ), options.nonOptionArguments() ); - } - - @Test - public void asArgumentOfOption() { - OptionSet options = parser.parse( "-o", "-" ); - - assertOptionDetected( options, "o" ); - assertEquals( singletonList( "-" ), options.valuesOf( "o" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void asArgumentOfOptionInSameToken() { - OptionSet options = parser.parse( "-o-" ); - - assertOptionDetected( options, "o" ); - assertEquals( singletonList( "-" ), options.valuesOf( "o" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ToStringTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ToStringTest.java deleted file mode 100644 index 0b01a789bb..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ToStringTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Collection; - -import static com.google.common.collect.Lists.newArrayList; -import static java.util.Arrays.*; - -import joptsimple.util.KeyValuePair; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -@RunWith( Parameterized.class ) -public class ToStringTest { - private final Object subject; - private final String[] substrings; - - public ToStringTest( Object subject, String[] substrings ) { - this.subject = subject; - this.substrings = substrings.clone(); - } - - @Parameterized.Parameters - public static Collection<?> objectsAndStringRepresentations() { - return asList( new Object[][] { - { KeyValuePair.valueOf( "key=value" ), new String[] { "key", "=", "value" } }, - { new UnrecognizedOptionException( "a" ), new String[] { "a" } }, - { new NoArgumentOptionSpec( asList( "a", "b" ), "" ), new String[] { "[a, b]" } }, - { new UnavailableOptionException( - newArrayList( new NoArgumentOptionSpec( "a" ), new NoArgumentOptionSpec( "b" ) ) ), - new String[] { "[a, b]" } }, - } ); - } - - @Test - public void givesUsefulStringRepresentations() { - String stringRepresentation = subject.toString(); - - for ( String each : substrings ) - assertThat( stringRepresentation, containsString( each ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/TypesafeOptionArgumentRetrievalTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/TypesafeOptionArgumentRetrievalTest.java deleted file mode 100644 index cea1e728a1..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/TypesafeOptionArgumentRetrievalTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import org.junit.Test; - -import static java.lang.Short.*; -import static java.util.Arrays.*; -import static java.util.Collections.*; -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class TypesafeOptionArgumentRetrievalTest extends AbstractOptionParserFixture { - @Test - public void retrievalOfTypedRequiredArgumentsInATypesafeManner() { - OptionSpec<Integer> optionA = parser.accepts( "a" ).withRequiredArg().ofType( Integer.class ); - - OptionSet options = parser.parse( "-a", "1" ); - - assertTrue( options.has( optionA ) ); - Integer valueFromOption = optionA.value( options ); - assertEquals( Integer.valueOf( 1 ), valueFromOption ); - Integer valueFromOptionSet = options.valueOf( optionA ); - assertEquals( valueFromOption, valueFromOptionSet ); - - List<Integer> valuesFromOption = optionA.values( options ); - assertEquals( asList( 1 ), valuesFromOption ); - List<Integer> valuesFromOptionSet = options.valuesOf( optionA ); - assertEquals( valuesFromOption, valuesFromOptionSet ); - } - - @Test - public void retrievalOfTypedOptionalArgumentsInATypesafeManner() { - OptionSpec<Double> optionB = parser.accepts( "b" ).withOptionalArg().ofType( Double.class ); - - OptionSet options = parser.parse( "-b", "3.14D" ); - - assertTrue( options.has( optionB ) ); - assertEquals( Double.valueOf( 3.14D ), optionB.value( options ) ); - assertEquals( asList( 3.14D ), optionB.values( options ) ); - } - - @Test - public void retrievalOfUntypedRequiredArgumentsInATypesafeManner() { - OptionSpec<String> optionC = parser.accepts( "c" ).withRequiredArg(); - - OptionSet options = parser.parse( "-c", "foo", "-c", "bar" ); - - assertTrue( options.has( optionC ) ); - assertEquals( asList( "foo", "bar" ), optionC.values( options ) ); - } - - @Test - public void retrievalOfUntypedOptionalArgumentsInATypesafeManner() { - OptionSpec<String> optionD = parser.accepts( "d" ).withRequiredArg(); - - OptionSet options = parser.parse( "-d", "foo", "-d", "bar", "-d", "baz" ); - - assertTrue( options.has( optionD ) ); - List<String> valuesFromOption = optionD.values( options ); - assertEquals( asList( "foo", "bar", "baz" ), valuesFromOption ); - List<String> valuesFromOptionSet = options.valuesOf( optionD ); - assertEquals( valuesFromOption, valuesFromOptionSet ); - } - - @Test - public void retrievalWithVoidOption() { - OptionSpec<Void> optionE = parser.accepts( "e" ); - - OptionSet options = parser.parse( "-e" ); - - assertTrue( options.has( optionE ) ); - assertEquals( emptyList(), options.valuesOf( optionE ) ); - } - - @Test - public void primitiveBooleanAllowedAsTypeSpecifier() { - OptionSpec<Boolean> optionA = parser.accepts( "a" ).withRequiredArg().ofType( boolean.class ); - - OptionSet options = parser.parse( "-a", "false" ); - - assertTrue( options.has( optionA ) ); - assertEquals( asList( false ), options.valuesOf( optionA ) ); - } - - @Test - public void primitiveByteAllowedAsTypeSpecifier() { - OptionSpec<Byte> optionB = parser.accepts( "b" ).withOptionalArg().ofType( byte.class ); - - OptionSet options = parser.parse( "-b", "3" ); - - assertTrue( options.has( optionB ) ); - assertEquals( asList( Byte.valueOf( "3" ) ), options.valuesOf( optionB ) ); - } - - @Test( expected = IllegalArgumentException.class ) - public void primitiveCharAllowedAsTypeSpecifier() { - parser.accepts( "c" ).withRequiredArg().ofType( char.class ); - } - - @Test - public void primitiveDoubleAllowedAsTypeSpecifier() { - OptionSpec<Double> optionD = parser.accepts( "d" ).withOptionalArg().ofType( double.class ); - - OptionSet options = parser.parse( "-d", "3.1" ); - - assertTrue( options.has( optionD ) ); - assertEquals( asList( 3.1D ), options.valuesOf( optionD ) ); - } - - @Test - public void primitiveFloatAllowedAsTypeSpecifier() { - OptionSpec<Float> optionE = parser.accepts( "e" ).withRequiredArg().ofType( float.class ); - - OptionSet options = parser.parse( "-e", "2.09" ); - - assertTrue( options.has( optionE ) ); - assertEquals( asList( 2.09F ), options.valuesOf( optionE ) ); - } - - @Test - public void primitiveIntAllowedAsTypeSpecifier() { - OptionSpec<Integer> optionF = parser.accepts( "F" ).withRequiredArg().ofType( int.class ); - - OptionSet options = parser.parse( "-F", "91" ); - - assertTrue( options.has( optionF ) ); - assertEquals( asList( 91 ), options.valuesOf( optionF ) ); - } - - @Test - public void primitiveLongAllowedAsTypeSpecifier() { - OptionSpec<Long> optionG = parser.accepts( "g" ).withOptionalArg().ofType( long.class ); - - OptionSet options = parser.parse("-g", "12"); - - assertTrue( options.has( optionG ) ); - assertEquals( asList( 12L ), options.valuesOf( optionG ) ); - } - - @Test - public void primitiveShortAllowedAsTypeSpecifier() { - OptionSpec<Short> optionH = parser.accepts( "H" ).withRequiredArg().ofType( short.class ); - - OptionSet options = parser.parse( "-H", "8" ); - - assertTrue( options.has( optionH ) ); - assertEquals( asList( Short.valueOf( "8" ) ), options.valuesOf( optionH ) ); - } - - @Test - public void cannotFoolHasWithAnOptionNotIssuedFromBuilder() { - parser.accepts( "e" ); - - OptionSet options = parser.parse( "-e" ); - - assertFalse( options.has( new FakeOptionSpec<Void>( "e" ) ) ); - } - - @Test - public void cannotFoolHasArgumentWithAnOptionNotIssuedFromBuilder() { - parser.accepts( "f" ).withRequiredArg(); - OptionSpec<String> fakeOptionF = new FakeOptionSpec<>( "f" ); - - OptionSet options = parser.parse( "-f", "boo" ); - - assertFalse( options.hasArgument( fakeOptionF ) ); - } - - @Test - public void cannotFoolValueOfWithAnOptionNotIssuedFromBuilder() { - parser.accepts( "g" ).withRequiredArg(); - - OptionSet options = parser.parse( "-g", "foo" ); - - assertNull( options.valueOf( new FakeOptionSpec<String>( "g" ) ) ); - } - - @Test - public void cannotFoolValuesOfWithAnOptionNotIssuedFromBuilder() { - parser.accepts( "h" ).withRequiredArg(); - - OptionSet options = parser.parse( "-h", "foo", "-h", "bar" ); - - assertEquals( emptyList(), options.valuesOf( new FakeOptionSpec<String>( "h" ) ) ); - } - - @Test( expected = ClassCastException.class ) - public void canSubvertTypeSafetyIfYouUseAnOptionSpecAsTheWrongType() { - ArgumentAcceptingOptionSpec<String> optionI = parser.accepts( "i" ).withRequiredArg(); - optionI.ofType( Integer.class ); - - OptionSet options = parser.parse( "-i", "2" ); - - @SuppressWarnings( "unused" ) - String value = optionI.value( options ); - } - - @Test( expected = ClassCastException.class ) - public void canSubvertTypeSafetyIfYouGiveAnOptionSpecToOptionSetAsTheWrongType() { - ArgumentAcceptingOptionSpec<String> optionJ = parser.accepts( "j" ).withRequiredArg(); - optionJ.ofType( Integer.class ); - - OptionSet options = parser.parse( "-j", "3" ); - - @SuppressWarnings( "unused" ) - String value = options.valuesOf( optionJ ).get( 0 ); - } - - @Test - public void canUseBooleanType() { - OptionSpec<Boolean> optionK = parser.accepts( "k" ).withRequiredArg().ofType( Boolean.class ); - - OptionSet options = parser.parse( "-k", "true" ); - - assertTrue( optionK.value( options ) ); - } - - @Test - public void usesConverterIfProvided() { - OptionSpec<Short> optionL = parser.accepts( "L" ).withRequiredArg().withValuesConvertedBy( - new ValueConverter<Short>() { - public Short convert( String value ) { - return parseShort( value ); - } - - public Class<Short> valueType() { - return Short.class; - } - - public String valuePattern() { - return null; - } - } ); - - OptionSet options = parser.parse( "-L", "34" ); - - assertEquals( new Short( (short) 34 ), optionL.value( options ) ); - } - - @Test - public void wrapsValueConversionExceptionsRaisedByConverter() { - OptionSpec<Character> optionM = parser.accepts( "m" ).withRequiredArg().withValuesConvertedBy( - new ValueConverter<Character>() { - public Character convert( String value ) { - throw new ValueConversionException( value ); - } - - public Class<Character> valueType() { - return Character.class; - } - - public String valuePattern() { - return null; - } - } ); - - OptionSet options = parser.parse( "-m", "a" ); - - thrown.expect( OptionArgumentConversionException.class ); - thrown.expect( withCauseOfType( ValueConversionException.class ) ); - - optionM.value( options ); - } - - private static class FakeOptionSpec<V> implements OptionSpec<V> { - private final String option; - - FakeOptionSpec( String option ) { - this.option = option; - } - - public List<String> options() { - return asList( option ); - } - - public V value( OptionSet detectedOptions ) { - return detectedOptions.valueOf( this ); - } - - public List<V> values( OptionSet detectedOptions ) { - return detectedOptions.valuesOf( this ); - } - - public boolean isForHelp() { - return false; - } - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/UtilityClassesUninstantiabilityHarness.java b/third_party/java/jopt-simple/src/test/java/joptsimple/UtilityClassesUninstantiabilityHarness.java deleted file mode 100644 index e70dba7135..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/UtilityClassesUninstantiabilityHarness.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.rules.ExpectedException.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public abstract class UtilityClassesUninstantiabilityHarness { - @Rule public final ExpectedException thrown = none(); - - private final Class<?> utility; - - protected UtilityClassesUninstantiabilityHarness( Class<?> utility ) { - this.utility = utility; - } - - @Test - public final void attemptToInstantiate() throws Exception { - Constructor<?> constructor = utility.getDeclaredConstructor(); - constructor.setAccessible( true ); - - thrown.expect( InvocationTargetException.class ); - thrown.expect( withTargetOfType( UnsupportedOperationException.class ) ); - - constructor.newInstance(); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ValueConverterAdmitsSubclassesOfValueTypeTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ValueConverterAdmitsSubclassesOfValueTypeTest.java deleted file mode 100644 index a7e726ed91..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ValueConverterAdmitsSubclassesOfValueTypeTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ValueConverterAdmitsSubclassesOfValueTypeTest { - @Test - public void subclassOfValueType() { - ValueConverter<List<String>> converter = new ValueConverter<List<String>>() { - public List<String> convert( String value ) { - return Collections.singletonList( value ); - } - - public Class<? extends List<String>> valueType() { - return ListOfStrings.class; - } - - public String valuePattern() { - return null; - } - }; - - assertEquals( Arrays.asList( "foo" ), converter.convert( "foo" ) ); - } - - static class ListOfStrings extends ArrayList<String> { - private static final long serialVersionUID = 1L; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/ValueOfHaver.java b/third_party/java/jopt-simple/src/test/java/joptsimple/ValueOfHaver.java deleted file mode 100644 index a3092601d8..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/ValueOfHaver.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ValueOfHaver { - private ValueOfHaver() { - // no-op - } - - public static ValueOfHaver valueOf( String s ) { - return null; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/WAsAbbreviationForLongOptionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/WAsAbbreviationForLongOptionTest.java deleted file mode 100644 index 119c14b810..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/WAsAbbreviationForLongOptionTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class WAsAbbreviationForLongOptionTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "Wally" ).withRequiredArg(); - } - - @Test - public void abbreviation() { - OptionSet options = parser.parse( "--W", "silent" ); - - assertOptionDetected( options, "Wally" ); - assertOptionNotDetected( options, "W" ); - assertEquals( singletonList( "silent" ), options.valuesOf( "Wally" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void recognizeLongOptionsTrumpsLongOptionAbbreviation() { - parser.recognizeAlternativeLongOptions( true ); - - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "silent" ) ); - - parser.parse( "--W", "silent" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/WAsShortOptionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/WAsShortOptionTest.java deleted file mode 100644 index 8cfb5231ae..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/WAsShortOptionTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class WAsShortOptionTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "W" ); - } - - @Test - public void wIsLegal() { - OptionSet options = parser.parse( "-W", "silent" ); - - assertOptionDetected( options, "W" ); - assertEquals( emptyList(), options.valuesOf( "W" ) ); - assertEquals( singletonList( "silent" ), options.nonOptionArguments() ); - } - - @Test - public void recognizeLongOptionsTrumpsShortOptionW() { - parser.recognizeAlternativeLongOptions( true ); - - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "silent" ) ); - - parser.parse( "-W", "silent" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/WExtensionNoArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/WExtensionNoArgumentTest.java deleted file mode 100644 index cb8a5e93ef..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/WExtensionNoArgumentTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class WExtensionNoArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.accepts( "silent" ); - parser.recognizeAlternativeLongOptions( true ); - } - - @Test - public void turnOffWExtension() { - parser.recognizeAlternativeLongOptions( false ); - - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "W" ) ); - - parser.parse( "-W", "silent" ); - } - - @Test - public void wExtensionWithLongOptionWithoutAnArgument() { - OptionSet options = parser.parse( "-W", "silent" ); - - assertOptionNotDetected( options, "W" ); - assertOptionDetected( options, "silent" ); - assertEquals( emptyList(), options.valuesOf( "silent" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/WExtensionWithArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/WExtensionWithArgumentTest.java deleted file mode 100644 index 76f247a3a3..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/WExtensionWithArgumentTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static joptsimple.ExceptionMatchers.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class WExtensionWithArgumentTest extends AbstractOptionParserFixture { - @Before - public final void initializeParser() { - parser.recognizeAlternativeLongOptions( true ); - parser.accepts( "silent" ).withOptionalArg(); - } - - @Test - public void separateArgument() { - OptionSet options = parser.parse( "-W", "silent", "4" ); - - assertOptionNotDetected( options, "W" ); - assertOptionDetected( options, "silent" ); - assertEquals( singletonList( "4" ), options.valuesOf( "silent" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void togetherArgument() { - OptionSet options = parser.parse( "-W", "silent=6" ); - - assertOptionNotDetected( options, "W" ); - assertOptionDetected( options, "silent" ); - assertEquals( singletonList( "6" ), options.valuesOf( "silent" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void abbreviationWithTogetherArgument() { - OptionSet options = parser.parse( "-W", "s=6" ); - - assertOptionNotDetected( options, "W" ); - assertOptionDetected( options, "silent" ); - assertOptionNotDetected( options, "s" ); - assertEquals( singletonList( "6" ), options.valuesOf( "silent" ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void illegalLongOption() { - thrown.expect( UnrecognizedOptionException.class ); - thrown.expect( withOption( "foo" ) ); - - parser.parse( "-W", "foo=bar" ); - } - - @Test - public void noMoreArguments() { - thrown.expect( OptionMissingRequiredArgumentException.class ); - thrown.expect( withOption( "W" ) ); - - parser.parse( "-W" ); - } - - @Test - public void typedTogetherArg() { - OptionSpec<Integer> level = parser.accepts( "level" ).withRequiredArg().ofType( Integer.class ); - - OptionSet options = parser.parse( "-W", "level=4" ); - - assertOptionNotDetected( options, "W" ); - assertOptionDetected( options, "level" ); - assertEquals( singletonList( 4 ), options.valuesOf( level ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } - - @Test - public void typedSeparateArg() { - OptionSpec<Integer> floor = parser.accepts( "floor" ).withRequiredArg().ofType( Integer.class ); - - OptionSet options = parser.parse( "-W", "floor", "5" ); - - assertOptionNotDetected( options, "W" ); - assertOptionDetected( options, "floor" ); - assertEquals( singletonList( 5 ), options.valuesOf( floor ) ); - assertEquals( emptyList(), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/AlternativeLongOptionsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/AlternativeLongOptionsTest.java deleted file mode 100644 index 3657a40eab..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/AlternativeLongOptionsTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class AlternativeLongOptionsTest { - @Test - public void handlesAlternativeLongOptions() { - OptionParser parser = new OptionParser( "W;" ); - parser.recognizeAlternativeLongOptions( true ); // same effect as above - parser.accepts( "level" ).withRequiredArg(); - - OptionSet options = parser.parse( "-W", "level=5" ); - - assertTrue( options.has( "level" ) ); - assertTrue( options.hasArgument( "level" ) ); - assertEquals( "5", options.valueOf( "level" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/DefaultValuesForOptionArgumentsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/DefaultValuesForOptionArgumentsTest.java deleted file mode 100644 index cd11f07b63..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/DefaultValuesForOptionArgumentsTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package joptsimple.examples; - -import java.io.File; - -import joptsimple.OptionException; -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import joptsimple.OptionSpec; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static joptsimple.examples.Level.*; -import static org.junit.Assert.*; -import static org.junit.rules.ExpectedException.*; - -public class DefaultValuesForOptionArgumentsTest { - @Rule public final ExpectedException thrown = none(); - - @Test - public void allowsSpecificationOfDefaultValues() throws Exception { - File tempDir = new File( System.getProperty( "java.io.tmpdir" ) ); - File tempFile = File.createTempFile( "aFile", ".txt" ); - OptionParser parser = new OptionParser(); - OptionSpec<File> infile = - parser.accepts( "infile" ).withRequiredArg().ofType( File.class ).defaultsTo( tempFile ); - OptionSpec<File> outdir = - parser.accepts( "outdir" ).withRequiredArg().ofType( File.class ).defaultsTo( tempDir ); - OptionSpec<Integer> bufferSize = - parser.accepts( "buffer-size" ).withOptionalArg().ofType( Integer.class ).defaultsTo( 4096 ); - OptionSpec<Level> level = - parser.accepts( "level" ).withOptionalArg().ofType( Level.class ).defaultsTo( INFO ); - OptionSpec<Integer> count = - parser.accepts( "count" ).withOptionalArg().ofType( Integer.class ).defaultsTo( 10 ); - - OptionSet options = parser.parse( "--level", "WARNING", "--count", "--infile", "/etc/passwd" ); - - assertEquals( new File( "/etc/passwd" ), infile.value( options ) ); - assertTrue( options.has( infile ) ); - assertTrue( options.hasArgument( infile ) ); - assertEquals( tempDir, outdir.value( options ) ); - assertFalse( options.has( outdir ) ); - assertFalse( options.hasArgument( outdir ) ); - assertEquals( Integer.valueOf( 4096 ), bufferSize.value( options ) ); - assertFalse( options.has( bufferSize ) ); - assertFalse( options.hasArgument( bufferSize ) ); - assertEquals( WARNING, level.value( options ) ); - assertTrue( options.has( level ) ); - assertTrue( options.hasArgument( level ) ); - assertEquals( Integer.valueOf( 10 ), count.value( options ) ); - assertTrue( options.has( count ) ); - assertFalse( options.hasArgument( count ) ); - - thrown.expect( OptionException.class ); - - parser.parse( "--outdir" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ExceptionExample.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ExceptionExample.java deleted file mode 100644 index fb4a9e723a..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ExceptionExample.java +++ /dev/null @@ -1,11 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; - -public class ExceptionExample { - public static void main( String[] args ) { - OptionParser parser = new OptionParser(); - - parser.parse( "-x" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ExportOptionsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ExportOptionsTest.java deleted file mode 100644 index 730e31834c..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ExportOptionsTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package joptsimple.examples; - -import com.google.common.base.Joiner; -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import joptsimple.OptionSpec; -import org.junit.Test; - -import java.io.File; -import java.util.List; -import java.util.Map.Entry; -import java.util.Properties; - -import static org.junit.Assert.assertEquals; - -public class ExportOptionsTest { - private static Properties asProperties( OptionSet options, String prefix ) { - Properties properties = new Properties(); - for ( Entry<OptionSpec<?>, List<?>> entry : options.asMap().entrySet() ) { - OptionSpec<?> spec = entry.getKey(); - properties.setProperty( - asPropertyKey( prefix, spec ), - asPropertyValue( entry.getValue(), options.has( spec ) ) ); - } - return properties; - } - - private static String asPropertyKey( String prefix, OptionSpec<?> spec ) { - List<String> flags = spec.options(); - for ( String flag : flags ) - if ( 1 < flag.length() ) - return null == prefix ? flag : ( prefix + '.' + flag ); - throw new IllegalArgumentException( "No usable non-short flag: " + flags ); - } - - private static String asPropertyValue( List<?> values, boolean present ) { - // Simple flags have no values; treat presence/absence as true/false - return values.isEmpty() ? String.valueOf( present ) : Joiner.on( "," ).join( values ); - } - - @Test - public void allowsExportOfOptions() { - Properties expected = new Properties(); - expected.setProperty( "rice.count", "3" ); - // Cannot check path as string directly - Windows flips the leading slash - expected.setProperty( "rice.output-dir", new File( "/tmp" ).toString() ); - expected.setProperty( "rice.fun", "false" ); - expected.setProperty( "rice.verbose", "true" ); - - OptionParser parser = new OptionParser(); - OptionSpec<Integer> count = parser.accepts( "count" ).withRequiredArg().ofType( Integer.class ); - OptionSpec<File> outputDir = parser.accepts( "output-dir" ).withOptionalArg().ofType( File.class ); - OptionSpec<Void> verbose = parser.accepts( "verbose" ); - OptionSpec<Void> fun = parser.accepts( "fun" ); - OptionSpec<File> files = parser.nonOptions().ofType( File.class ); - - OptionSet options = parser.parse( "--count", "3", "--output-dir", "/tmp", "--verbose", "a.txt", "b.txt" ); - - assertEquals( expected, asProperties( options, "rice" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpFormatterExample.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpFormatterExample.java deleted file mode 100644 index 0262d2a76a..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpFormatterExample.java +++ /dev/null @@ -1,69 +0,0 @@ -package joptsimple.examples; - -import java.io.File; -import java.util.HashSet; -import java.util.Map; - -import static java.io.File.*; -import static java.util.Arrays.*; - -import joptsimple.HelpFormatter; -import joptsimple.OptionDescriptor; -import joptsimple.OptionParser; - -import static joptsimple.util.DateConverter.*; - -public class HelpFormatterExample { - static class MyFormatter implements HelpFormatter { - public String format( Map<String, ? extends OptionDescriptor> options ) { - StringBuilder buffer = new StringBuilder(); - for ( OptionDescriptor each : new HashSet<>( options.values() ) ) { - buffer.append( lineFor( each ) ); - } - return buffer.toString(); - } - - private String lineFor( OptionDescriptor descriptor ) { - if ( descriptor.representsNonOptions() ) { - return descriptor.argumentDescription() + '(' + descriptor.argumentTypeIndicator() + "): " - + descriptor.description() + System.getProperty( "line.separator" ); - } - - StringBuilder line = new StringBuilder( descriptor.options().toString() ); - line.append( ": description = " ).append( descriptor.description() ); - line.append( ", required = " ).append( descriptor.isRequired() ); - line.append( ", accepts arguments = " ).append( descriptor.acceptsArguments() ); - line.append( ", requires argument = " ).append( descriptor.requiresArgument() ); - line.append( ", argument description = " ).append( descriptor.argumentDescription() ); - line.append( ", argument type indicator = " ).append( descriptor.argumentTypeIndicator() ); - line.append( ", default values = " ).append( descriptor.defaultValues() ); - line.append( System.getProperty( "line.separator" ) ); - return line.toString(); - } - } - - public static void main( String[] args ) throws Exception { - OptionParser parser = new OptionParser() { - { - accepts( "c" ).withRequiredArg().ofType( Integer.class ) - .describedAs( "count" ).defaultsTo( 1 ); - accepts( "q" ).withOptionalArg().ofType( Double.class ) - .describedAs( "quantity" ); - accepts( "d", "some date" ).withRequiredArg().required() - .withValuesConvertedBy( datePattern( "MM/dd/yy" ) ); - acceptsAll( asList( "v", "talkative", "chatty" ), "be more verbose" ); - accepts( "output-file" ).withOptionalArg().ofType( File.class ) - .describedAs( "file" ); - acceptsAll( asList( "h", "?" ), "show help" ).forHelp(); - acceptsAll( asList( "cp", "classpath" ) ).withRequiredArg() - .describedAs( "path1" + pathSeparatorChar + "path2:..." ) - .ofType( File.class ) - .withValuesSeparatedBy( pathSeparatorChar ); - nonOptions( "files to chew on" ).ofType( File.class ).describedAs( "input files" ); - } - }; - - parser.formatHelpWith( new MyFormatter() ); - parser.printHelpOn( System.out ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java deleted file mode 100644 index 44f024b793..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java +++ /dev/null @@ -1,35 +0,0 @@ -package joptsimple.examples; - -import java.io.File; - -import static java.io.File.*; -import static java.util.Arrays.*; - -import joptsimple.OptionParser; - -import static joptsimple.util.DateConverter.*; - -public class HelpScreenExample { - public static void main( String[] args ) throws Exception { - OptionParser parser = new OptionParser() { - { - accepts( "c" ).withRequiredArg().ofType( Integer.class ) - .describedAs( "count" ).defaultsTo( 1 ); - accepts( "q" ).withOptionalArg().ofType( Double.class ) - .describedAs( "quantity" ); - accepts( "d", "some date" ).withRequiredArg().required() - .withValuesConvertedBy( datePattern( "MM/dd/yy" ) ); - acceptsAll( asList( "v", "talkative", "chatty" ), "be more verbose" ); - accepts( "output-file" ).withOptionalArg().ofType( File.class ) - .describedAs( "file" ); - acceptsAll( asList( "h", "?" ), "show help" ).forHelp(); - acceptsAll( asList( "cp", "classpath" ) ).withRequiredArg() - .describedAs( "path1" + pathSeparatorChar + "path2:..." ) - .ofType( File.class ) - .withValuesSeparatedBy( pathSeparatorChar ); - } - }; - - parser.printHelpOn( System.out ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/Level.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/Level.java deleted file mode 100644 index b3d95d4e58..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/Level.java +++ /dev/null @@ -1,7 +0,0 @@ -package joptsimple.examples; - -public enum Level { - WARNING, - INFO, - DEBUG -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsTest.java deleted file mode 100644 index 30fac0c4d1..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class LongOptionsTest { - @Test - public void acceptsLongOptions() { - OptionParser parser = new OptionParser(); - parser.accepts( "flag" ); - parser.accepts( "verbose" ); - - OptionSet options = parser.parse( "--flag" ); - - assertTrue( options.has( "flag" ) ); - assertFalse( options.has( "verbose" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsWithArgumentPositioningTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsWithArgumentPositioningTest.java deleted file mode 100644 index 1cf018b867..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsWithArgumentPositioningTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class LongOptionsWithArgumentPositioningTest { - @Test - public void allowsDifferentFormsOfPairingArgumentWithOption() { - OptionParser parser = new OptionParser(); - parser.accepts( "count" ).withRequiredArg(); - parser.accepts( "level" ).withOptionalArg(); - - OptionSet options = parser.parse( "--count", "4", "--level=3" ); - - assertTrue( options.has( "count" ) ); - assertTrue( options.hasArgument( "count" ) ); - assertEquals( "4", options.valueOf( "count" ) ); - - assertTrue( options.has( "level" ) ); - assertTrue( options.hasArgument( "level" ) ); - assertEquals( "3", options.valueOf( "level" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsWithArgumentsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsWithArgumentsTest.java deleted file mode 100644 index 38ef67cfec..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/LongOptionsWithArgumentsTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package joptsimple.examples; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class LongOptionsWithArgumentsTest { - @Test - public void supportsLongOptionsWithArgumentsAndAbbreviations() { - OptionParser parser = new OptionParser(); - parser.accepts( "flag" ); - parser.accepts( "count" ).withRequiredArg(); - parser.accepts( "level" ).withOptionalArg(); - - OptionSet options = parser.parse( "-flag", "--co", "3", "--lev" ); - - assertTrue( options.has( "flag" ) ); - - assertTrue( options.has( "count" ) ); - assertTrue( options.hasArgument( "count" ) ); - assertEquals( "3", options.valueOf( "count" ) ); - assertEquals( asList( "3" ), options.valuesOf( "count" ) ); - - assertTrue( options.has( "level" ) ); - assertFalse( options.hasArgument( "level" ) ); - assertNull( options.valueOf( "level" ) ); - assertEquals( emptyList(), options.valuesOf( "level" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/MultipleDelimitedArgumentsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/MultipleDelimitedArgumentsTest.java deleted file mode 100644 index 47eefd066e..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/MultipleDelimitedArgumentsTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package joptsimple.examples; - -import java.io.File; - -import static java.io.File.*; -import static java.util.Arrays.*; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import joptsimple.OptionSpec; -import org.junit.Test; - -import static joptsimple.examples.Strings.*; -import static org.junit.Assert.*; - -public class MultipleDelimitedArgumentsTest { - @Test - public void supportsMultipleDelimitedArguments() { - OptionParser parser = new OptionParser(); - OptionSpec<File> path = parser.accepts( "path" ).withRequiredArg().ofType( File.class ) - .withValuesSeparatedBy( pathSeparatorChar ); - - OptionSet options = parser.parse( "--path", join( pathSeparatorChar, "/tmp", "/var", "/opt" ) ); - - assertTrue( options.has( path ) ); - assertTrue( options.hasArgument( path ) ); - assertEquals( asList( new File( "/tmp" ), new File( "/var" ), new File( "/opt" ) ), options.valuesOf( path ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentConverterTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentConverterTest.java deleted file mode 100644 index 5841794d83..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentConverterTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2014 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.joda.time.LocalDate; -import org.junit.Test; - -import static joptsimple.util.DateConverter.*; -import static joptsimple.util.RegexMatcher.*; -import static org.junit.Assert.*; - -public class OptionArgumentConverterTest { - @Test - public void usesConvertersOnOptionArgumentsWhenTold() { - OptionParser parser = new OptionParser(); - parser.accepts( "birthdate" ).withRequiredArg().withValuesConvertedBy( datePattern( "MM/dd/yy" ) ); - parser.accepts( "ssn" ).withRequiredArg().withValuesConvertedBy( regex( "\\d{3}-\\d{2}-\\d{4}" )); - - OptionSet options = parser.parse( "--birthdate", "02/24/05", "--ssn", "123-45-6789" ); - - assertEquals( new LocalDate( 2005, 2, 24 ).toDate(), options.valueOf( "birthdate" ) ); - assertEquals( "123-45-6789", options.valueOf( "ssn" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java deleted file mode 100644 index 2f8e51c630..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class OptionArgumentValueTypeTest { - @Test - public void convertsArgumentsToJavaValueTypes() { - OptionParser parser = new OptionParser(); - parser.accepts( "flag" ); - parser.accepts( "count" ).withRequiredArg().ofType( Integer.class ); - parser.accepts( "level" ).withOptionalArg().ofType( Level.class ); - - OptionSet options = parser.parse( "--count", "3", "--level", "DEBUG" ); - - assertTrue( options.has( "count" ) ); - assertTrue( options.hasArgument( "count" ) ); - assertEquals( 3, options.valueOf( "count" ) ); - - assertTrue( options.has( "level" ) ); - assertTrue( options.hasArgument( "level" ) ); - assertEquals( Level.DEBUG, options.valueOf( "level" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionSynonymTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionSynonymTest.java deleted file mode 100644 index 336c4d005c..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionSynonymTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package joptsimple.examples; - -import java.util.List; - -import static java.util.Arrays.*; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class OptionSynonymTest { - @Test - public void supportsOptionSynonyms() { - OptionParser parser = new OptionParser(); - List<String> synonyms = asList( "message", "blurb", "greeting" ); - parser.acceptsAll( synonyms ).withRequiredArg(); - String expectedMessage = "Hello"; - - OptionSet options = parser.parse( "--message", expectedMessage ); - - for ( String each : synonyms ) { - assertTrue( each, options.has( each ) ); - assertTrue( each, options.hasArgument( each ) ); - assertEquals( each, expectedMessage, options.valueOf( each ) ); - assertEquals( each, asList( expectedMessage ), options.valuesOf( each ) ); - } - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/PosixlyCorrectTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/PosixlyCorrectTest.java deleted file mode 100644 index 7acb957a77..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/PosixlyCorrectTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package joptsimple.examples; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class PosixlyCorrectTest { - @Test - public void supportsPosixlyCorrectBehavior() { - OptionParser parser = new OptionParser( "i:j::k" ); - String[] arguments = { "-ibar", "-i", "junk", "xyz", "-jixnay", "foo", "-k", "blah", "--", "bah" }; - - OptionSet options = parser.parse( arguments ); - - assertTrue( options.has( "i" ) ); - assertTrue( options.has( "j" ) ); - assertTrue( options.has( "k" ) ); - assertEquals( asList( "bar", "junk" ), options.valuesOf( "i" ) ); - assertEquals( asList( "ixnay" ), options.valuesOf( "j" ) ); - assertEquals( asList( "xyz", "foo", "blah", "bah" ), options.nonOptionArguments() ); - - parser.posixlyCorrect( true ); - options = parser.parse( arguments ); - - assertTrue( options.has( "i" ) ); - assertFalse( options.has( "j" ) ); - assertFalse( options.has( "k" ) ); - assertEquals( asList( "bar", "junk" ), options.valuesOf( "i" ) ); - assertEquals( emptyList(), options.valuesOf( "j" ) ); - assertEquals( asList( "xyz", "-jixnay", "foo", "-k", "blah", "--", "bah" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredIfExample.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredIfExample.java deleted file mode 100644 index c062fff87e..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredIfExample.java +++ /dev/null @@ -1,14 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; - -public class RequiredIfExample { - public static void main( String[] args ) { - OptionParser parser = new OptionParser(); - parser.accepts( "ftp" ); - parser.accepts( "username" ).requiredIf( "ftp" ).withRequiredArg(); - parser.accepts( "password" ).requiredIf( "ftp" ).withRequiredArg(); - - parser.parse( "--ftp" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredOptionsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredOptionsTest.java deleted file mode 100644 index 5a40ea2ed9..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredOptionsTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionException; -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class RequiredOptionsTest { - @Test( expected = OptionException.class ) - public void allowsSpecificationOfRequiredOptions() { - OptionParser parser = new OptionParser() { - { - accepts( "userid" ).withRequiredArg().required(); - accepts( "password" ).withRequiredArg().required(); - } - }; - - parser.parse( "--userid", "bob" ); - } - - @Test - public void aHelpOptionMeansRequiredOptionsNeedNotBePresent() { - OptionParser parser = new OptionParser() { - { - accepts( "userid" ).withRequiredArg().required(); - accepts( "password" ).withRequiredArg().required(); - accepts( "help" ).forHelp(); - } - }; - - OptionSet options = parser.parse( "--help" ); - assertTrue( options.has( "help" ) ); - } - - @Test( expected = OptionException.class ) - public void missingHelpOptionMeansRequiredOptionsMustBePresent() { - OptionParser parser = new OptionParser() { - { - accepts( "userid" ).withRequiredArg().required(); - accepts( "password" ).withRequiredArg().required(); - accepts( "help" ).forHelp(); - } - }; - - parser.parse( "" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredUnlessExample.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredUnlessExample.java deleted file mode 100644 index f55f6ca91d..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/RequiredUnlessExample.java +++ /dev/null @@ -1,14 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; - -public class RequiredUnlessExample { - public static void main( String[] args ) { - OptionParser parser = new OptionParser(); - parser.accepts( "anonymous" ); - parser.accepts( "username" ).requiredUnless( "anonymous" ).withRequiredArg(); - parser.accepts( "password" ).requiredUnless( "anonymous" ).withRequiredArg(); - - parser.parse( "--anonymous" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsClusteringTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsClusteringTest.java deleted file mode 100644 index 9143e45d7d..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsClusteringTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class ShortOptionsClusteringTest { - @Test - public void allowsClusteringShortOptions() { - OptionParser parser = new OptionParser( "aBcd" ); - - OptionSet options = parser.parse( "-cdBa" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.has( "B" ) ); - assertTrue( options.has( "c" ) ); - assertTrue( options.has( "d" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsClusteringWithArgumentTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsClusteringWithArgumentTest.java deleted file mode 100644 index 695f6cebbc..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsClusteringWithArgumentTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class ShortOptionsClusteringWithArgumentTest { - @Test - public void allowsClusteringShortOptionsThatAcceptArguments() { - OptionParser parser = new OptionParser(); - parser.accepts( "a" ); - parser.accepts( "B" ); - parser.accepts( "c" ).withRequiredArg(); - - OptionSet options = parser.parse( "-aBcfoo" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.has( "B" ) ); - assertTrue( options.has( "c" ) ); - assertEquals( "foo", options.valueOf( "c" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsTest.java deleted file mode 100644 index 4e3487cd0e..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class ShortOptionsTest { - @Test - public void supportsShortOptions() { - OptionParser parser = new OptionParser( "aB?*." ); - - OptionSet options = parser.parse( "-a", "-B", "-?" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.has( "B" ) ); - assertTrue( options.has( "?" ) ); - assertFalse( options.has( "." ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithArgumentPositioningTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithArgumentPositioningTest.java deleted file mode 100644 index 720253ebf2..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithArgumentPositioningTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class ShortOptionsWithArgumentPositioningTest { - @Test - public void allowsDifferentFormsOfPairingArgumentWithOption() { - OptionParser parser = new OptionParser( "a:b:c::" ); - - OptionSet options = parser.parse( "-a", "foo", "-bbar", "-c=baz" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.hasArgument( "a" ) ); - assertEquals( "foo", options.valueOf( "a" ) ); - - assertTrue( options.has( "b" ) ); - assertTrue( options.hasArgument( "b" ) ); - assertEquals( "bar", options.valueOf( "b" ) ); - - assertTrue( options.has( "c" ) ); - assertTrue( options.hasArgument( "c" ) ); - assertEquals( "baz", options.valueOf( "c" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithArgumentsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithArgumentsTest.java deleted file mode 100644 index 3ee7911bd0..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithArgumentsTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package joptsimple.examples; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class ShortOptionsWithArgumentsTest { - @Test - public void allowsOptionsToAcceptArguments() { - OptionParser parser = new OptionParser( "fc:q::" ); - - OptionSet options = parser.parse( "-f", "-c", "foo", "-q" ); - - assertTrue( options.has( "f" ) ); - - assertTrue( options.has( "c" ) ); - assertTrue( options.hasArgument( "c" ) ); - assertEquals( "foo", options.valueOf( "c" ) ); - assertEquals( asList( "foo" ), options.valuesOf( "c" ) ); - - assertTrue( options.has( "q" ) ); - assertFalse( options.hasArgument( "q" ) ); - assertNull( options.valueOf( "q" ) ); - assertEquals( emptyList(), options.valuesOf( "q" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithMultipleArgumentsForSingleOptionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithMultipleArgumentsForSingleOptionTest.java deleted file mode 100644 index 8f113f859a..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ShortOptionsWithMultipleArgumentsForSingleOptionTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package joptsimple.examples; - -import static java.util.Arrays.*; - -import joptsimple.OptionException; -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.junit.Assert.*; -import static org.junit.rules.ExpectedException.*; - -public class ShortOptionsWithMultipleArgumentsForSingleOptionTest { - @Rule public final ExpectedException thrown = none(); - - @Test - public void allowsMultipleValuesForAnOption() { - OptionParser parser = new OptionParser( "a:" ); - - OptionSet options = parser.parse( "-a", "foo", "-abar", "-a=baz" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.hasArgument( "a" ) ); - assertEquals( asList( "foo", "bar", "baz" ), options.valuesOf( "a" ) ); - - thrown.expect( OptionException.class ); - options.valueOf( "a" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/SignallingEndOfOptionsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/SignallingEndOfOptionsTest.java deleted file mode 100644 index 9fd1faefe7..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/SignallingEndOfOptionsTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package joptsimple.examples; - -import static java.util.Arrays.*; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class SignallingEndOfOptionsTest { - @Test - public void doubleHyphenSignalsEndOfOptions() { - OptionParser parser = new OptionParser( "ab:c::de:f::" ); - - OptionSet options = parser.parse( "-a", "-b=foo", "-c=bar", "--", "-d", "-e", "baz", "-f", "biz" ); - - assertTrue( options.has( "a" ) ); - assertFalse( options.hasArgument( "a" ) ); - assertTrue( options.has( "b" ) ); - assertTrue( options.hasArgument( "b" ) ); - assertEquals( asList( "foo" ), options.valuesOf( "b" ) ); - assertTrue( options.has( "c" ) ); - assertTrue( options.hasArgument( "c" ) ); - assertEquals( asList( "bar" ), options.valuesOf( "c" ) ); - assertFalse( options.has( "d" ) ); - assertFalse( options.has( "e" ) ); - assertFalse( options.has( "f" ) ); - assertEquals( asList( "-d", "-e", "baz", "-f", "biz" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/SpecialOptionalArgumentHandlingTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/SpecialOptionalArgumentHandlingTest.java deleted file mode 100644 index 4f05559310..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/SpecialOptionalArgumentHandlingTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package joptsimple.examples; - -import static java.util.Arrays.*; -import static java.util.Collections.*; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class SpecialOptionalArgumentHandlingTest { - @Test - public void handlesNegativeNumberOptionalArguments() { - OptionParser parser = new OptionParser(); - parser.accepts( "a" ).withOptionalArg().ofType( Integer.class ); - parser.accepts( "2" ); - - OptionSet options = parser.parse( "-a", "-2" ); - - assertTrue( options.has( "a" ) ); - assertFalse( options.has( "2" ) ); - assertEquals( asList( -2 ), options.valuesOf( "a" ) ); - - options = parser.parse( "-2", "-a" ); - - assertTrue( options.has( "a" ) ); - assertTrue( options.has( "2" ) ); - assertEquals( emptyList(), options.valuesOf( "a" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/Strings.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/Strings.java deleted file mode 100644 index 432350632e..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/Strings.java +++ /dev/null @@ -1,19 +0,0 @@ -package joptsimple.examples; - -import java.util.Iterator; - -import static java.util.Arrays.*; - -public class Strings { - public static String join( char delimiter, String... pieces ) { - StringBuilder builder = new StringBuilder(); - - for ( Iterator<String> iter = asList( pieces ).iterator(); iter.hasNext(); ) { - builder.append( iter.next() ); - if ( iter.hasNext() ) - builder.append( delimiter ); - } - - return builder.toString(); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/TypesafeOptionArgumentRetrievalTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/TypesafeOptionArgumentRetrievalTest.java deleted file mode 100644 index 93cd0a5c5b..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/TypesafeOptionArgumentRetrievalTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package joptsimple.examples; - -import java.io.File; - -import static java.util.Arrays.*; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import joptsimple.OptionSpec; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class TypesafeOptionArgumentRetrievalTest { - @Test - public void allowsTypesafeRetrievalOfOptionArguments() { - OptionParser parser = new OptionParser(); - OptionSpec<Integer> count = parser.accepts( "count" ).withRequiredArg().ofType( Integer.class ); - OptionSpec<File> outputDir = parser.accepts( "output-dir" ).withOptionalArg().ofType( File.class ); - OptionSpec<Void> verbose = parser.accepts( "verbose" ); - OptionSpec<File> files = parser.nonOptions().ofType( File.class ); - - OptionSet options = parser.parse( "--count", "3", "--output-dir", "/tmp", "--verbose", "a.txt", "b.txt" ); - - assertTrue( options.has( verbose ) ); - - assertTrue( options.has( count ) ); - assertTrue( options.hasArgument( count ) ); - Integer expectedCount = 3; - assertEquals( expectedCount, options.valueOf( count ) ); - assertEquals( expectedCount, count.value( options ) ); - assertEquals( asList( expectedCount ), options.valuesOf( count ) ); - assertEquals( asList( expectedCount ), count.values( options ) ); - assertEquals( asList( new File( "a.txt" ), new File( "b.txt" ) ), options.valuesOf( files ) ); - - assertTrue( options.has( outputDir ) ); - assertTrue( options.hasArgument( outputDir ) ); - File expectedFile = new File( "/tmp" ); - assertEquals( expectedFile, options.valueOf( outputDir ) ); - assertEquals( expectedFile, outputDir.value( options ) ); - assertEquals( asList( expectedFile ), options.valuesOf( outputDir ) ); - assertEquals( asList( expectedFile ), outputDir.values( options ) ); - assertEquals( asList( new File( "a.txt" ), new File( "b.txt" ) ), files.values( options ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/UnrecognizedOptionsAllowedTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/UnrecognizedOptionsAllowedTest.java deleted file mode 100644 index 6dc9972028..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/UnrecognizedOptionsAllowedTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package joptsimple.examples; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.junit.Test; - -import static java.util.Arrays.*; -import static org.junit.Assert.*; - -public class UnrecognizedOptionsAllowedTest { - @Test - public void acceptsLongOptions() { - OptionParser parser = new OptionParser(); - parser.allowsUnrecognizedOptions(); - parser.accepts( "f" ); - - OptionSet options = parser.parse( "-f", "-d" ); - - assertTrue( options.has( "f" ) ); - assertFalse( options.has( "d" ) ); - assertEquals( asList( "-d" ), options.nonOptionArguments() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ant/filters/HTMLEntitifier.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ant/filters/HTMLEntitifier.java deleted file mode 100644 index 0eabe4ffa7..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/ant/filters/HTMLEntitifier.java +++ /dev/null @@ -1,80 +0,0 @@ -package joptsimple.examples.ant.filters; - -import java.io.IOException; -import java.io.Reader; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tools.ant.filters.BaseFilterReader; -import org.apache.tools.ant.filters.ChainableReader; - -/** - * Ant filter class that transforms HTML special characters into their equivalent entities. - * - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class HTMLEntitifier extends BaseFilterReader implements ChainableReader { - private static final Map<Integer, String> ENTITIES = new HashMap<>(); - - static { - ENTITIES.put( (int) '<', "<" ); - ENTITIES.put( (int) '>', ">" ); - ENTITIES.put( (int) '"', """ ); - ENTITIES.put( (int) '&', "&" ); - } - - private String replacementData; - private int replacementIndex = -1; - - /** - * Creates "dummy" instances. - */ - public HTMLEntitifier() { - // empty on purpose - } - - /** - * @param source where the data to filter comes from - */ - public HTMLEntitifier( Reader source ) { - super( source ); - } - - /** - * {@inheritDoc} - */ - public Reader chain( Reader source ) { - HTMLEntitifier newFilter = new HTMLEntitifier( source ); - newFilter.setInitialized( true ); - - return newFilter; - } - - /** - * {@inheritDoc} - */ - @Override - public int read() throws IOException { - if ( !getInitialized() ) - setInitialized( true ); - - if ( replacementIndex > -1 ) { - int ch = replacementData.charAt( replacementIndex++ ); - - if ( replacementIndex >= replacementData.length() ) - replacementIndex = -1; - - return ch; - } - - int nextChar = in.read(); - - if ( ENTITIES.containsKey( nextChar ) ) { - replacementData = ENTITIES.get( nextChar ); - replacementIndex = 1; - return replacementData.charAt( 0 ); - } - - return nextChar; - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/AbbreviationMapTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/AbbreviationMapTest.java deleted file mode 100644 index abd4302a0b..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/AbbreviationMapTest.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class AbbreviationMapTest { - private AbbreviationMap<String> abbreviations; - - @Before - public void setUp() { - abbreviations = new AbbreviationMap<>(); - } - - @Test( expected = NullPointerException.class ) - public void nullValuesAreIllegal() { - abbreviations.put( "cannotAddNullValue", null ); - } - - @Test( expected = NullPointerException.class ) - public void nullKeysAreIllegalToAdd() { - abbreviations.put( null, "-1" ); - } - - @Test( expected = NullPointerException.class ) - public void nullKeysAreIllegalToCheckForContains() { - abbreviations.contains( null ); - } - - @Test( expected = IllegalArgumentException.class ) - public void zeroLengthKeysAreIllegalToAdd() { - abbreviations.put( "", "1" ); - } - - @Test( expected = NullPointerException.class ) - public void nullKeysAreIllegalToRemove() { - abbreviations.remove( null ); - } - - @Test( expected = IllegalArgumentException.class ) - public void zeroLengthKeysAreIllegalToRemove() { - abbreviations.remove( "" ); - } - - @Test - public void empty() { - assertFalse( abbreviations.contains( "boo" ) ); - assertNull( abbreviations.get( "boo" ) ); - } - - @Test - public void addingOne() { - abbreviations.put( "box", "2" ); - - assertTrue( abbreviations.contains( "box" ) ); - assertEquals( "2", abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "2", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "2", abbreviations.get( "b" ) ); - } - - @Test - public void addingManyWithNoCommonPrefix() { - abbreviations.put( "box", "1" ); - abbreviations.put( "cat", "2" ); - abbreviations.put( "dog", "3" ); - - assertTrue( abbreviations.contains( "box" ) ); - assertEquals( "1", abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "1", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "1", abbreviations.get( "b" ) ); - assertTrue( abbreviations.contains( "cat" ) ); - assertEquals( "2", abbreviations.get( "cat" ) ); - assertTrue( abbreviations.contains( "ca" ) ); - assertEquals( "2", abbreviations.get( "ca" ) ); - assertTrue( abbreviations.contains( "c" ) ); - assertEquals( "2", abbreviations.get( "c" ) ); - assertTrue( abbreviations.contains( "dog" ) ); - assertEquals( "3", abbreviations.get( "dog" ) ); - assertTrue( abbreviations.contains( "do" ) ); - assertEquals( "3", abbreviations.get( "do" ) ); - assertTrue( abbreviations.contains( "d" ) ); - assertEquals( "3", abbreviations.get( "d" ) ); - } - - @Test - public void addingTwoWithCommonPrefix() { - abbreviations.put( "box", "3" ); - abbreviations.put( "boy", "4" ); - - assertTrue( abbreviations.contains( "box" ) ); - assertEquals( "3", abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "boy" ) ); - assertEquals( "4", abbreviations.get( "boy" ) ); - assertFalse( abbreviations.contains( "bo" ) ); - assertNull( abbreviations.get( "bo" ) ); - assertFalse( abbreviations.contains( "b" ) ); - assertNull( abbreviations.get( "b" ) ); - } - - @Test - public void addingThreeWithSuccessivelySmallerPrefixes() { - abbreviations.put( "boy", "3" ); - abbreviations.put( "bo", "2" ); - abbreviations.put( "b", "1" ); - - assertTrue( abbreviations.contains( "boy" ) ); - assertEquals( "3", abbreviations.get( "boy" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "2", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "1", abbreviations.get( "b" ) ); - } - - @Test - public void addingThreeWithSuccessivelyLargerPrefixes() { - abbreviations.put( "b", "1" ); - abbreviations.put( "bo", "2" ); - abbreviations.put( "boy", "3" ); - - assertTrue( abbreviations.contains( "boy" ) ); - assertEquals( "3", abbreviations.get( "boy" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "2", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "1", abbreviations.get( "b" ) ); - } - - @Test - public void addingThreeWithMixOfPrefixSize() { - abbreviations.put( "boy", "3" ); - abbreviations.put( "b", "1" ); - abbreviations.put( "bo", "2" ); - - assertTrue( abbreviations.contains( "boy" ) ); - assertEquals( "3", abbreviations.get( "boy" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "2", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "1", abbreviations.get( "b" ) ); - } - - @Test - public void addingOneThenReplacing() { - abbreviations.put( "box", "2" ); - - assertTrue( abbreviations.contains( "box" ) ); - assertEquals( "2", abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "2", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "2", abbreviations.get( "b" ) ); - - abbreviations.put( "box", "3" ); - - assertTrue( abbreviations.contains( "box" ) ); - assertEquals( "3", abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "3", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "3", abbreviations.get( "b" ) ); - } - - @Test - public void removingNonExistentKeyHasNoEffect() { - abbreviations.put( "box", "2" ); - - abbreviations.remove( "cat" ); - - assertTrue( abbreviations.contains( "box" ) ); - assertEquals( "2", abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "2", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "2", abbreviations.get( "b" ) ); - } - - @Test - public void removingSingleKey() { - abbreviations.put( "box", "3" ); - - abbreviations.remove( "box" ); - - assertFalse( abbreviations.contains( "box" ) ); - assertNull( abbreviations.get( "box" ) ); - assertFalse( abbreviations.contains( "bo" ) ); - assertNull( abbreviations.get( "bo" ) ); - assertFalse( abbreviations.contains( "b" ) ); - assertNull( abbreviations.get( "b" ) ); - } - - @Test - public void cannotRemoveByUniqueAbbreviation() { - abbreviations.put( "box", "4" ); - - abbreviations.remove( "bo" ); - abbreviations.remove( "b" ); - - assertTrue( abbreviations.contains( "box" ) ); - assertEquals( "4", abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "4", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "4", abbreviations.get( "b" ) ); - } - - @Test - public void removeKeyWithCommonPrefix() { - abbreviations.put( "box", "-1" ); - abbreviations.put( "boy", "-2" ); - - abbreviations.remove( "box" ); - - assertFalse( abbreviations.contains( "box" ) ); - assertNull( abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "boy" ) ); - assertEquals( "-2", abbreviations.get( "boy" ) ); - assertTrue( abbreviations.contains( "bo" ) ); - assertEquals( "-2", abbreviations.get( "bo" ) ); - assertTrue( abbreviations.contains( "b" ) ); - assertEquals( "-2", abbreviations.get( "b" ) ); - } - - @Test - public void addKeysWithCommonPrefixThenRemoveNonExistentKeyWithCommonPrefix() { - abbreviations.put( "box", "-1" ); - abbreviations.put( "boy", "-2" ); - - abbreviations.remove( "bop" ); - - assertTrue( abbreviations.contains( "box" ) ); - assertEquals( "-1", abbreviations.get( "box" ) ); - assertTrue( abbreviations.contains( "boy" ) ); - assertEquals( "-2", abbreviations.get( "boy" ) ); - assertFalse( abbreviations.contains( "bo" ) ); - assertNull( abbreviations.get( "bo" ) ); - assertFalse( abbreviations.contains( "b" ) ); - assertNull( abbreviations.get( "b" ) ); - } - - @Test - public void addKeysWithCommonPrefixesStairstepStyle() { - abbreviations.put( "a", "1" ); - abbreviations.put( "abc", "2" ); - - assertTrue( abbreviations.contains( "a" ) ); - assertEquals( "1", abbreviations.get( "a" ) ); - assertTrue( abbreviations.contains( "ab" ) ); - assertEquals( "2", abbreviations.get( "ab" ) ); - assertTrue( abbreviations.contains( "abc" ) ); - assertEquals( "2", abbreviations.get( "abc" ) ); - - abbreviations.put( "abcde", "3" ); - - assertTrue( abbreviations.contains( "a" ) ); - assertEquals( "1", abbreviations.get( "a" ) ); - assertFalse( abbreviations.contains( "ab" ) ); - assertNull( abbreviations.get( "ab" ) ); - assertTrue( abbreviations.contains( "abc" ) ); - assertEquals( "2", abbreviations.get( "abc" ) ); - assertTrue( abbreviations.contains( "abcd" ) ); - assertEquals( "3", abbreviations.get( "abcd" ) ); - assertTrue( abbreviations.contains( "abcde" ) ); - assertEquals( "3", abbreviations.get( "abcde" ) ); - } - - @Test - public void addKeysWithCommonPrefixesStairstepStyleJumbled() { - abbreviations.put( "a", "1" ); - abbreviations.put( "abcde", "3" ); - abbreviations.put( "abc", "2" ); - - assertTrue( abbreviations.contains( "a" ) ); - assertEquals( "1", abbreviations.get( "a" ) ); - assertFalse( abbreviations.contains( "ab" ) ); - assertNull( abbreviations.get( "ab" ) ); - assertTrue( abbreviations.contains( "abc" ) ); - assertEquals( "2", abbreviations.get( "abc" ) ); - assertTrue( abbreviations.contains( "abcd" ) ); - assertEquals( "3", abbreviations.get( "abcd" ) ); - assertTrue( abbreviations.contains( "abcde" ) ); - assertEquals( "3", abbreviations.get( "abcde" ) ); - } - - @Test - public void multipleKeysWithCommonPrefix() { - abbreviations.put( "good", "4" ); - abbreviations.put( "goodyear", "8" ); - abbreviations.put( "go", "2" ); - abbreviations.put( "goodyea", "7" ); - abbreviations.put( "goodye", "6" ); - - assertFalse( abbreviations.contains( "g" ) ); - assertNull( abbreviations.get( "g" ) ); - assertTrue( abbreviations.contains( "go" ) ); - assertEquals( "2", abbreviations.get( "go" ) ); - assertFalse( abbreviations.contains( "goo" ) ); - assertNull( abbreviations.get( "goo" ) ); - assertTrue( abbreviations.contains( "good" ) ); - assertEquals( "4", abbreviations.get( "good" ) ); - assertFalse( abbreviations.contains( "goody" ) ); - assertNull( abbreviations.get( "goody" ) ); - assertTrue( abbreviations.contains( "goodye" ) ); - assertEquals( "6", abbreviations.get( "goodye" ) ); - assertTrue( abbreviations.contains( "goodyea" ) ); - assertEquals( "7", abbreviations.get( "goodyea" ) ); - assertTrue( abbreviations.contains( "goodyea" ) ); - assertEquals( "8", abbreviations.get( "goodyear" ) ); - - abbreviations.remove( "goodyea" ); - - assertFalse( abbreviations.contains( "g" ) ); - assertNull( abbreviations.get( "g" ) ); - assertTrue( abbreviations.contains( "go" ) ); - assertEquals( "2", abbreviations.get( "go" ) ); - assertFalse( abbreviations.contains( "goo" ) ); - assertNull( abbreviations.get( "goo" ) ); - assertTrue( abbreviations.contains( "good" ) ); - assertEquals( "4", abbreviations.get( "good" ) ); - assertFalse( abbreviations.contains( "goody" ) ); - assertNull( abbreviations.get( "goody" ) ); - assertTrue( abbreviations.contains( "goodye" ) ); - assertEquals( "6", abbreviations.get( "goodye" ) ); - assertTrue( abbreviations.contains( "goodyea" ) ); - assertEquals( "8", abbreviations.get( "goodyea" ) ); - assertTrue( abbreviations.contains( "goodyea" ) ); - assertEquals( "8", abbreviations.get( "goodyear" ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/AbbreviationMapToJavaUtilMapTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/AbbreviationMapToJavaUtilMapTest.java deleted file mode 100644 index 8bc062135b..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/AbbreviationMapToJavaUtilMapTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import static java.util.Collections.*; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class AbbreviationMapToJavaUtilMapTest { - private AbbreviationMap<String> abbreviations; - - @Before - public void setUp() { - abbreviations = new AbbreviationMap<>(); - } - - @Test - public void empty() { - assertEquals( emptyMap(), abbreviations.toJavaUtilMap() ); - } - - @Test - public void addingOne() { - abbreviations.put( "box", "2" ); - - assertEquals( singletonMap( "box", "2" ), abbreviations.toJavaUtilMap() ); - } - - @Test - public void addingManyWithNoCommonPrefix() { - abbreviations.put( "box", "1" ); - abbreviations.put( "cat", "2" ); - abbreviations.put( "dog", "3" ); - - assertEquals( "{box=1, cat=2, dog=3}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void addingTwoWithCommonPrefix() { - abbreviations.put( "box", "3" ); - abbreviations.put( "boy", "4" ); - - assertEquals( "{box=3, boy=4}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void addingThreeWithSuccessivelySmallerPrefixes() { - abbreviations.put( "boy", "3" ); - abbreviations.put( "bo", "2" ); - abbreviations.put( "b", "1" ); - - assertEquals( "{b=1, bo=2, boy=3}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void addingThreeWithSuccessivelyLargerPrefixes() { - abbreviations.put( "b", "1" ); - abbreviations.put( "bo", "2" ); - abbreviations.put( "boy", "3" ); - - assertEquals( "{b=1, bo=2, boy=3}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void addingThreeWithMixOfPrefixSize() { - abbreviations.put( "boy", "3" ); - abbreviations.put( "b", "1" ); - abbreviations.put( "bo", "2" ); - - assertEquals( "{b=1, bo=2, boy=3}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void addingOneThenReplacing() { - abbreviations.put( "box", "2" ); - abbreviations.put( "box", "3" ); - - assertEquals( "{box=3}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void removeKeyWithCommonPrefix() { - abbreviations.put( "box", "-1" ); - abbreviations.put( "boy", "-2" ); - abbreviations.remove( "box" ); - - assertEquals( "{boy=-2}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void addKeysWithCommonPrefixesStairstepStyle() { - abbreviations.put( "a", "1" ); - abbreviations.put( "abc", "2" ); - abbreviations.put( "abcde", "3" ); - - assertEquals( "{a=1, abc=2, abcde=3}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void addKeysWithCommonPrefixesStairstepStyleJumbled() { - abbreviations.put( "a", "1" ); - abbreviations.put( "abcde", "3" ); - abbreviations.put( "abc", "2" ); - - assertEquals( "{a=1, abc=2, abcde=3}", abbreviations.toJavaUtilMap().toString() ); - } - - @Test - public void multipleKeysWithCommonPrefix() { - abbreviations.put( "good", "4" ); - abbreviations.put( "goodyear", "8" ); - abbreviations.put( "go", "2" ); - abbreviations.put( "goodyea", "7" ); - abbreviations.put( "goodye", "6" ); - abbreviations.remove( "goodyea" ); - - assertEquals( "{go=2, good=4, goodye=6, goodyear=8}", abbreviations.toJavaUtilMap().toString() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ClassesUtilityClassTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ClassesUtilityClassTest.java deleted file mode 100644 index 89f3ea2430..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ClassesUtilityClassTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import joptsimple.UtilityClassesUninstantiabilityHarness; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ClassesUtilityClassTest extends UtilityClassesUninstantiabilityHarness { - public ClassesUtilityClassTest() { - super( Classes.class ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/MessagesUtilityClassTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/MessagesUtilityClassTest.java deleted file mode 100644 index a0c1051ed8..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/MessagesUtilityClassTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import joptsimple.UtilityClassesUninstantiabilityHarness; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class MessagesUtilityClassTest extends UtilityClassesUninstantiabilityHarness { - public MessagesUtilityClassTest() { - super( Messages.class ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/Problematic.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/Problematic.java deleted file mode 100644 index 9ec93d62a7..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/Problematic.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -class Problematic { - private Problematic() { - // no-op - } - - Problematic( String s ) { - throw new IllegalStateException(s); - } - - private static void boo() { - // no-op - } - - static void mute() { - new Problematic().stuff(); - } - - void stuff() { - boo(); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ReflectionTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ReflectionTest.java deleted file mode 100644 index 06f96829c4..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ReflectionTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static joptsimple.internal.Reflection.*; -import static org.junit.rules.ExpectedException.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ReflectionTest { - @Rule public final ExpectedException thrown = none(); - - @Test - public void invokingConstructorQuietlyWrapsInstantiationException() throws Exception { - Constructor<AbstractProblematic> constructor = AbstractProblematic.class.getDeclaredConstructor(); - - thrown.expect( ReflectionException.class ); - thrown.expectMessage( InstantiationException.class.getName() ); - - instantiate( constructor ); - } - - @Test - public void invokingConstructorQuietlyWrapsIllegalAccessException() throws Exception { - Constructor<Problematic> constructor = Problematic.class.getDeclaredConstructor(); - - thrown.expect( ReflectionException.class ); - thrown.expectMessage( IllegalAccessException.class.getName() ); - - instantiate( constructor ); - } - - @Test - public void invokingConstructorQuietlyWrapsCauseOfInvocationTargetException() throws Exception { - Constructor<Problematic> constructor = Problematic.class.getDeclaredConstructor( String.class ); - - thrown.expect( ReflectionException.class ); - thrown.expectMessage( IllegalStateException.class.getName() ); - - instantiate( constructor, "arg" ); - } - - @Test - public void invokingConstructorQuietlyWrapsIllegalArgumentException() throws Exception { - Constructor<Problematic> constructor = Problematic.class.getDeclaredConstructor(String.class); - - thrown.expect( ReflectionException.class ); - thrown.expectMessage( IllegalArgumentException.class.getName() ); - - instantiate( constructor ); - } - - @Test - public void invokingStaticMethodQuietlyWrapsIllegalAccessException() throws Exception { - Method method = Problematic.class.getDeclaredMethod( "boo" ); - - thrown.expect( ReflectionException.class ); - thrown.expectMessage( IllegalAccessException.class.getName() ); - - invoke( method ); - } - - @Test - public void invokingStaticMethodQuietlyWrapsIllegalArgumentException() throws Exception { - Method method = Problematic.class.getDeclaredMethod( "mute" ); - - thrown.expect( ReflectionException.class ); - thrown.expectMessage( IllegalArgumentException.class.getName() ); - - invoke( method, new Object() ); - } - - private abstract static class AbstractProblematic { - protected AbstractProblematic() { - // no-op - } - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ReflectionUtilityClassTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ReflectionUtilityClassTest.java deleted file mode 100644 index 7634a4900f..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/ReflectionUtilityClassTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import joptsimple.UtilityClassesUninstantiabilityHarness; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class ReflectionUtilityClassTest extends UtilityClassesUninstantiabilityHarness { - public ReflectionUtilityClassTest() { - super( Reflection.class ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/RowEqualsHashCodeTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/RowEqualsHashCodeTest.java deleted file mode 100644 index e1ad850945..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/RowEqualsHashCodeTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import org.infinitest.toolkit.StrictEqualsHashCodeTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class RowEqualsHashCodeTest extends StrictEqualsHashCodeTestSupport { - @Override - protected Object equalButDifferentClass() { - return new Row( "o", "d" ) { - }; - } - - @Override - protected Object equal() throws Exception { - return new Row( "o", "d" ); - } - - @Override - protected Object notEqual() throws Exception { - return new Row( "o", "e" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/RowsTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/RowsTest.java deleted file mode 100644 index c07522de15..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/RowsTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import org.junit.Test; - -import static joptsimple.internal.Strings.*; -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class RowsTest { - @Test - public void optionsAndDescriptionsWithinOverallWidth() { - Rows rows = new Rows( 40, 2 ); - rows.add( "left one", "right one" ); - rows.add( "another left one", "another right one" ); - - assertRows( rows, - "left one right one ", - "another left one another right one" ); - } - - @Test - public void someOptionsExceedOverallWidth() { - Rows rows = new Rows( 40, 2 ); - rows.add( "left one is pretty freaking long to be over here", "right one" ); - rows.add( "another left one also has length that is quite excessive", "another right one" ); - - assertRows( rows, - "left one is pretty right one ", - " freaking long to ", - " be over here ", - "another left one another right one", - " also has length ", - " that is quite ", - " excessive " ); - } - - @Test - public void someDescriptionsExceedOverallWidth() { - Rows rows = new Rows( 40, 2 ); - rows.add( "left one", "right one for the time we have chosen" ); - rows.add( "another left one", "another right one could be used here instead" ); - - assertRows( rows, - "left one right one for the ", - " time we have chosen", - "another left one another right one ", - " could be used here ", - " instead " ); - } - - private void assertRows( Rows rows, String... expected ) { - rows.fitToWidth(); - - assertEquals( join( expected, LINE_SEPARATOR ) + LINE_SEPARATOR, rows.render() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/SimpleOptionNameMapTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/SimpleOptionNameMapTest.java deleted file mode 100644 index ae9ae0d4fd..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/SimpleOptionNameMapTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.util.List; -import java.util.Map; - -import org.junit.Test; - -import static java.util.Arrays.*; - -import static org.junit.Assert.*; - -public class SimpleOptionNameMapTest { - private static final Integer VALUE = 1; - private static final String KEY = "someKey"; - private static final String KEY2 = "someOtherKey"; - - @Test - public void putAndContains() { - SimpleOptionNameMap<Integer> map = new SimpleOptionNameMap<>(); - assertFalse( map.contains( KEY ) ); - - map.put( KEY, 1 ); - - assertTrue( map.contains( KEY ) ); - } - - @Test - public void get() { - SimpleOptionNameMap<Integer> map = new SimpleOptionNameMap<>(); - assertNull( map.get( KEY ) ); - - map.put( KEY, VALUE ); - - assertEquals( VALUE, map.get( KEY ) ); - } - - @Test - public void putAll() { - SimpleOptionNameMap<Integer> map = new SimpleOptionNameMap<>(); - List<String> keys = asList( KEY, KEY2 ); - - map.putAll( keys, VALUE ); - - assertEquals( VALUE, map.get( KEY ) ); - assertEquals( VALUE, map.get( KEY2 ) ); - } - - @Test - public void remove() { - SimpleOptionNameMap<Integer> map = new SimpleOptionNameMap<>(); - map.put( KEY, 1 ); - - map.remove( KEY ); - - assertFalse( map.contains( KEY ) ); - } - - @Test - public void toJavaUtilMap() { - SimpleOptionNameMap<Integer> map = new SimpleOptionNameMap<>(); - map.put( KEY, VALUE ); - - Map<String, Integer> javaUtilMap = map.toJavaUtilMap(); - - assertEquals( VALUE, javaUtilMap.get( KEY ) ); - assertEquals( 1, javaUtilMap.size() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/StringsUtilityClassTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/internal/StringsUtilityClassTest.java deleted file mode 100644 index a56b2a53c5..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/internal/StringsUtilityClassTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import joptsimple.UtilityClassesUninstantiabilityHarness; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class StringsUtilityClassTest extends UtilityClassesUninstantiabilityHarness { - public StringsUtilityClassTest() { - super( Strings.class ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/DateConverterTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/DateConverterTest.java deleted file mode 100644 index 93baa0bacc..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/DateConverterTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import java.text.DateFormat; -import java.text.FieldPosition; -import java.text.NumberFormat; -import java.text.ParsePosition; -import java.text.SimpleDateFormat; -import java.util.Date; - -import static java.text.DateFormat.*; - -import joptsimple.ValueConversionException; -import joptsimple.ValueConverter; -import org.joda.time.LocalDate; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static joptsimple.util.DateConverter.*; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; -import static org.junit.rules.ExpectedException.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class DateConverterTest { - @Rule public final ExpectedException thrown = none(); - - private DateFormat notASimpleDateFormat; - private SimpleDateFormat monthDayYear; - - @Before - public void setUp() { - notASimpleDateFormat = new DateFormat() { - private static final long serialVersionUID = -1L; - - { - setNumberFormat( NumberFormat.getInstance() ); - } - - @Override - public StringBuffer format( Date date, StringBuffer toAppendTo, FieldPosition fieldPosition ) { - return null; - } - - @Override - public Date parse( String source, ParsePosition pos ) { - return null; - } - }; - - monthDayYear = new SimpleDateFormat( "MM/dd/yyyy" ); - } - - @Test( expected = NullPointerException.class ) - public void rejectsNullDateFormatter() { - new DateConverter( null ); - } - - @Test - public void shouldConvertValuesToDatesUsingADateFormat() { - ValueConverter<Date> converter = new DateConverter( monthDayYear ); - - assertEquals( new LocalDate( 2009, 1, 24 ).toDate(), converter.convert( "01/24/2009" ) ); - } - - @Test - public void rejectsNonParsableValues() { - thrown.expect( ValueConversionException.class ); - - new DateConverter( getDateInstance() ).convert( "@(#*^" ); - } - - @Test - public void rejectsValuesThatDoNotEntirelyMatch() { - thrown.expect( ValueConversionException.class ); - - new DateConverter( monthDayYear ).convert( "12/25/09 00:00:00" ); - } - - @Test - public void shouldCreateSimpleDateFormatConverter() { - assertEquals( new LocalDate( 2009, 7, 4 ).toDate(), datePattern( "MM/dd/yyyy" ).convert( "07/04/2009" ) ); - } - - @Test - public void rejectsNullDatePattern() { - thrown.expect( NullPointerException.class ); - - datePattern( null ); - } - - @Test - public void shouldRaiseExceptionThatContainsDatePatternAndValue() { - thrown.expect( ValueConversionException.class ); - thrown.expectMessage( "qwe" ); - thrown.expectMessage( monthDayYear.toPattern() ); - - new DateConverter( monthDayYear ).convert( "qwe" ); - } - - @Test - public void shouldRaiseExceptionThatContainsValueOnlyIfNotASimpleDateFormat() { - thrown.expect( ValueConversionException.class ); - thrown.expectMessage( "asdf" ); - thrown.expectMessage( not( containsString( notASimpleDateFormat.toString() ) ) ); - - new DateConverter( notASimpleDateFormat ).convert( "asdf" ); - } - - @Test - public void shouldAnswerCorrectValueType() { - assertSame( Date.class, new DateConverter( monthDayYear ).valueType() ); - } - - @Test - public void shouldGiveNoValuePatternIfFormatterNotASimpleDateFormat() { - assertEquals( "", new DateConverter( notASimpleDateFormat ).valuePattern() ); - } - - @Test - public void shouldGiveValuePatternIfFormatterIsASimpleDateFormat() { - assertEquals( monthDayYear.toPattern(), datePattern( monthDayYear.toPattern() ).valuePattern() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/EnumConverterTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/EnumConverterTest.java deleted file mode 100644 index 617f1462c1..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/EnumConverterTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2014 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import joptsimple.ValueConversionException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.rules.ExpectedException.none; - -/** - * @author <a href="mailto:christian.ohr@gmail.com">Christian Ohr</a> - */ -public class EnumConverterTest { - @Rule - public final ExpectedException thrown = none(); - - private EnumConverter<TestEnum> converter; - - @Before - public void setUp() { - converter = new TestEnumConverter(); - } - - @Test - public void convertsEnumValuesToEnum() { - assertEquals( TestEnum.A, converter.convert( "A" ) ); - } - - @Test - public void rejectsNonEnumeratedValues() { - thrown.expect( ValueConversionException.class ); - - converter.convert( "Z" ); - } - - @Test - public void answersCorrectValueType() { - assertSame( TestEnum.class, converter.valueType() ); - } - - @Test - public void givesDefaultValuePattern() { - assertEquals( "[A,B,C,D]", converter.valuePattern() ); - } - - @Test - public void givesCustomValuePattern() { - converter.setDelimiters( "(|)" ); - - assertEquals( "(A|B|C|D)", converter.valuePattern() ); - } - - @Test - public void ignoresCase() { - assertEquals( TestEnum.A, converter.convert( "a" ) ); - } - - private static class TestEnumConverter extends EnumConverter<TestEnum> { - TestEnumConverter() { - super( TestEnum.class ); - } - } - - private static enum TestEnum { - A, B, C, D - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/InetAddressConverterTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/InetAddressConverterTest.java deleted file mode 100644 index 98f418ff3a..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/InetAddressConverterTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import java.net.InetAddress; -import java.util.Random; - -import joptsimple.ValueConversionException; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; -import static org.junit.Assume.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class InetAddressConverterTest { - private InetAddressConverter converter; - - @Before - public void setUp() { - converter = new InetAddressConverter(); - } - - @Test - public void localhost() throws Exception { - assumeTrue( InetAddress.getByName( "127.0.0.1" ).isReachable( 5000 ) ); - - assertEquals( "127.0.0.1", converter.convert( "localhost" ).getHostAddress() ); - } - - @Test( expected = ValueConversionException.class ) - public void unknownHost() { - converter.convert( "!(@&#()!*@&#" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairTest.java deleted file mode 100644 index e0c64e9efd..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class KeyValuePairTest { - @Test( expected = NullPointerException.class ) - public void nullArg() { - KeyValuePair.valueOf( null ); - } - - @Test - public void empty() { - KeyValuePair pair = KeyValuePair.valueOf( "" ); - - assertEquals( "", pair.key ); - assertEquals( "", pair.value ); - } - - @Test - public void noEqualsSign() { - KeyValuePair pair = KeyValuePair.valueOf( "aString" ); - - assertEquals( "aString", pair.key ); - assertEquals( "", pair.value ); - } - - @Test - public void signAtEnd() { - KeyValuePair pair = KeyValuePair.valueOf( "aKey=" ); - - assertEquals( "aKey", pair.key ); - assertEquals( "", pair.value ); - } - - @Test - public void signAtStart() { - KeyValuePair pair = KeyValuePair.valueOf( "=aValue" ); - - assertEquals( "", pair.key ); - assertEquals( "aValue", pair.value ); - } - - @Test - public void typical() { - KeyValuePair pair = KeyValuePair.valueOf( "aKey=aValue" ); - - assertEquals( "aKey", pair.key ); - assertEquals( "aValue", pair.value ); - } - - @Test - public void multipleEqualsSignsDoNotMatter() { - KeyValuePair pair = KeyValuePair.valueOf( "aKey=1=2=3=4" ); - - assertEquals( "aKey", pair.key ); - assertEquals( "1=2=3=4", pair.value ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairUnequalKeysTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairUnequalKeysTest.java deleted file mode 100644 index fc130bf938..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairUnequalKeysTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import org.infinitest.toolkit.EqualsHashCodeTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class KeyValuePairUnequalKeysTest extends EqualsHashCodeTestSupport { - @Override - protected KeyValuePair equal() { - return KeyValuePair.valueOf( "x=z" ); - } - - @Override - protected KeyValuePair notEqual() { - return KeyValuePair.valueOf( "y=z" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairUnequalValuesTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairUnequalValuesTest.java deleted file mode 100644 index 4bb36b71c5..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/KeyValuePairUnequalValuesTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import org.infinitest.toolkit.EqualsHashCodeTestSupport; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class KeyValuePairUnequalValuesTest extends EqualsHashCodeTestSupport { - @Override - protected KeyValuePair equal() { - return KeyValuePair.valueOf( "x=y" ); - } - - @Override - protected KeyValuePair notEqual() { - return KeyValuePair.valueOf( "x=z" ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/PathConverterTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/PathConverterTest.java deleted file mode 100644 index 6b543936cd..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/PathConverterTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package joptsimple.util; - -import java.nio.file.Files; -import java.nio.file.Path; - -import joptsimple.ValueConversionException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static joptsimple.util.PathProperties.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class PathConverterTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - - @Test - public void convertsValuesToPaths() throws Exception { - Path path = Files.createTempFile( "prefix", null ); - path.toFile().deleteOnExit(); - - String pathName = path.toString(); - - assertEquals( path, new PathConverter( null ).convert( pathName ) ); - assertEquals( path, new PathConverter().convert( pathName ) ); - } - - @Test - public void answersCorrectValueType() { - assertEquals( Path.class, new PathConverter().valueType() ); - } - - @Test - public void testReadableAndOverwritableFile() throws Exception { - Path path = Files.createTempFile( "prefix", null ); - path.toFile().deleteOnExit(); - - String pathName = path.toString(); - - assertTrue( Files.isReadable( new PathConverter( READABLE ).convert( pathName ) ) ); - assertTrue( Files.exists( new PathConverter( READABLE ).convert( pathName ) ) ); - assertTrue( Files.isWritable( new PathConverter( READABLE ).convert( pathName ) ) ); - assertTrue( Files.isWritable( new PathConverter( FILE_OVERWRITABLE).convert( pathName ) ) ); - } - - @Test - public void testNotExisting() throws Exception { - Path path = Files.createTempFile( "prefix", null ); - - Files.deleteIfExists( path ); - - assertFalse( Files.exists( new PathConverter( NOT_EXISTING ).convert( path.toString() ) ) ); - } - - @Test - public void testNotReadable() throws Exception { - Path path = Files.createTempFile( "prefix", null ); - String pathName = path.toString(); - Files.deleteIfExists( path ); - - exception.expect( ValueConversionException.class ); - exception.expectMessage( "File [" + pathName ); - - new PathConverter( READABLE ).convert( pathName ); - } - - @Test - public void testDirectoryExisting() throws Exception { - Path path = Files.createTempDirectory( "prefix" ); - path.toFile().deleteOnExit(); - - String pathName = path.toString(); - - assertTrue( Files.isDirectory( new PathConverter( DIRECTORY_EXISTING ).convert( pathName ) ) ); - } - - @Test - public void testDirectoryNotOverwritable() throws Exception { - Path path = Files.createTempDirectory( "prefix" ); - path.toFile().deleteOnExit(); - - String pathName = path.toString(); - - exception.expect( ValueConversionException.class ); - exception.expectMessage( "File [" + pathName ); - - new PathConverter( FILE_OVERWRITABLE).convert( pathName ); - } - - @Test - public void testNotExistingNotOverwritable() throws Exception { - Path path = Files.createTempDirectory( "prefix" ); - String pathName = path.toString(); - Files.deleteIfExists( path ); - - exception.expect( ValueConversionException.class ); - exception.expectMessage( "File [" + pathName ); - - new PathConverter( FILE_OVERWRITABLE ).convert( pathName ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/PathPropertiesTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/PathPropertiesTest.java deleted file mode 100644 index 1c6bf59718..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/PathPropertiesTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package joptsimple.util; - -import java.nio.file.Files; -import java.nio.file.Path; - -import org.junit.Test; - -import static org.junit.Assert.*; - -import static joptsimple.util.PathProperties.*; - -public class PathPropertiesTest { - @Test - public void readableFile() throws Exception { - Path path = Files.createTempFile("prefix", null); - - path.toFile().deleteOnExit(); - - assertTrue( READABLE.accept( path ) ); - assertFalse( DIRECTORY_EXISTING.accept( path ) ); - assertTrue( FILE_EXISTING.accept( path ) ); - assertTrue( FILE_OVERWRITABLE.accept( path ) ); - assertTrue( WRITABLE.accept( path ) ); - assertFalse( NOT_EXISTING.accept( path ) ); - } - - @Test - public void nonExisting() throws Exception { - Path path = Files.createTempFile( "prefix", null ); - - Files.deleteIfExists( path ); - - assertFalse( READABLE.accept( path ) ); - assertFalse( DIRECTORY_EXISTING.accept( path ) ); - assertFalse( FILE_EXISTING.accept( path ) ); - assertFalse( FILE_OVERWRITABLE.accept( path ) ); - assertTrue( NOT_EXISTING.accept( path ) ); - assertFalse( WRITABLE.accept( path ) ); - } - - @Test - public void directory() throws Exception { - Path path = Files.createTempDirectory( "prefix" ); - - path.toFile().deleteOnExit(); - - assertTrue( READABLE.accept( path ) ); - assertTrue( DIRECTORY_EXISTING.accept( path ) ); - assertFalse( FILE_EXISTING.accept( path ) ); - assertFalse( FILE_OVERWRITABLE.accept( path ) ); - assertFalse( NOT_EXISTING.accept( path ) ); - assertTrue( WRITABLE.accept( path ) ); - } -} diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/util/RegexMatcherTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/util/RegexMatcherTest.java deleted file mode 100644 index 56eae7ec5a..0000000000 --- a/third_party/java/jopt-simple/src/test/java/joptsimple/util/RegexMatcherTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import joptsimple.ValueConversionException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static joptsimple.util.RegexMatcher.*; -import static org.junit.Assert.*; -import static org.junit.rules.ExpectedException.*; - -/** - * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> - */ -public class RegexMatcherTest { - @Rule public final ExpectedException thrown = none(); - - private RegexMatcher abc; - - @Before - public void setUp() { - abc = new RegexMatcher( "abc", 0 ); - } - - @Test - public void shouldAttemptToMatchValueAgainstARegex() { - assertEquals( "abc", abc.convert( "abc" ) ); - } - - @Test( expected = ValueConversionException.class ) - public void rejectsValueThatDoesNotMatchRegex() { - abc.convert( "abcd" ); - } - - @Test - public void raisesExceptionContainingValueAndPattern() { - thrown.expect( ValueConversionException.class ); - thrown.expectMessage( "\\d+" ); - thrown.expectMessage( "asdf" ); - - new RegexMatcher( "\\d+", 0 ).convert( "asdf" ); - } - - @Test - public void shouldOfferConvenienceMethodForCreatingMatcherWithNoFlags() { - assertEquals( "sourceforge.net", regex( "\\w+\\.\\w+" ).convert( "sourceforge.net" ) ); - } - - @Test - public void shouldAnswerCorrectValueType() { - assertEquals( String.class, abc.valueType() ); - } - - @Test - public void shouldGiveCorrectValuePattern() { - assertEquals( "abc", abc.valuePattern() ); - } -} diff --git a/third_party/java/jopt-simple/src/test/resources/joptsimple/ExceptionMessages_xx_YY.properties b/third_party/java/jopt-simple/src/test/resources/joptsimple/ExceptionMessages_xx_YY.properties deleted file mode 100644 index ac78a6227b..0000000000 --- a/third_party/java/jopt-simple/src/test/resources/joptsimple/ExceptionMessages_xx_YY.properties +++ /dev/null @@ -1,10 +0,0 @@ -joptsimple.IllegalOptionSpecificationException.message = illegal option specification exception -joptsimple.MissingRequiredOptionsException.message = missing required option exception -joptsimple.MultipleArgumentsForOptionException.message = multiple arguments for option exception -joptsimple.OptionArgumentConversionException.message = option argument conversion exception -joptsimple.OptionMissingRequiredArgumentException.message = option missing required argument exception -joptsimple.UnconfiguredOptionException.message = unconfigured option exception -joptsimple.UnrecognizedOptionException.message = unrecognized option exception -joptsimple.util.DateConverter.without.pattern.message = date converter without pattern -joptsimple.util.DateConverter.with.pattern.message = date converter with pattern -joptsimple.util.RegexMatcher.message = regex matcher
\ No newline at end of file |