diff options
Diffstat (limited to 'third_party/java/jopt-simple/src/test/java/joptsimple/examples')
30 files changed, 0 insertions, 978 deletions
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; - } -} |