-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2232] fix bug for Optional<T> arguments with initial value
- Loading branch information
Showing
7 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Picocli Java 8 Tests | ||
|
||
This subproject contains tests that use Java 8, and the JUnit 5 and System Lambda test frameworks. | ||
|
||
This module does not publish any artifacts. | ||
|
||
NOTE: only put tests here that require Java 8 and cannot be run in earlier versions of Java. | ||
|
||
Tests that require Java 9 or later should be located in the `picocli-tests-java9plus` subproject. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
group 'info.picocli' | ||
description 'Picocli Tests Requiring Java 8' | ||
version "$projectVersion" | ||
|
||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
|
||
dependencies { | ||
api rootProject | ||
testImplementation supportDependencies.junit5Api | ||
testRuntimeOnly supportDependencies.junit5Engine | ||
testImplementation supportDependencies.systemLambda | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes 'Specification-Title': 'Picocli Tests Requiring Java 8', | ||
'Specification-Vendor' : 'Remko Popma', | ||
'Specification-Version' : archiveVersion.get(), | ||
'Implementation-Title' : 'Picocli Tests Requiring Java 8', | ||
'Implementation-Vendor' : 'Remko Popma', | ||
'Implementation-Version': archiveVersion.get(), | ||
'Automatic-Module-Name' : 'info.picocli.tests.java8' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package picocli; | ||
|
||
import org.junit.Test; | ||
import picocli.CommandLine; | ||
import picocli.CommandLine.*; | ||
|
||
import java.io.File; | ||
import java.util.Optional; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class Issue2232 { | ||
static class Tar { | ||
@Option(names = { "-f", "--file" }, paramLabel = "ARCHIVE", description = "the archive file") | ||
Optional<File> archive; | ||
|
||
public Tar() { | ||
archive = Optional.of(new File("helloworld")); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDefault() { | ||
Tar tar = new Tar(); | ||
System.out.println(tar.archive); | ||
assertEquals(Optional.of(new File("helloworld")), tar.archive); | ||
new CommandLine(tar).parseArgs(); | ||
assertEquals(Optional.of(new File("helloworld")), tar.archive); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters