You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/04/07 17:12:53 UTC
(commons-cli) branch master updated (57e3d45 -> c258dae)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
from 57e3d45 Add @SuppressWarnings
new 1e98376 Testing TypeHandler.createDate() should not have been removed
new c258dae Testing TypeHandler.createFile() should not have been removed
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/commons/cli/TypeHandlerTest.java | 30 ++++++++++++++++------
1 file changed, 22 insertions(+), 8 deletions(-)
(commons-cli) 01/02: Testing TypeHandler.createDate() should not have been removed
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
commit 1e98376d99c407821838f5b847f52db928ee0f7c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 7 13:12:43 2024 -0400
Testing TypeHandler.createDate() should not have been removed
---
.../org/apache/commons/cli/TypeHandlerTest.java | 24 ++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/test/java/org/apache/commons/cli/TypeHandlerTest.java b/src/test/java/org/apache/commons/cli/TypeHandlerTest.java
index 1218831..cd1c33d 100644
--- a/src/test/java/org/apache/commons/cli/TypeHandlerTest.java
+++ b/src/test/java/org/apache/commons/cli/TypeHandlerTest.java
@@ -32,6 +32,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -68,6 +69,11 @@ public class TypeHandlerTest {
/** Always returns the same Path. */
private static final Converter<Path, InvalidPathException> PATH_CONVERTER = s -> Paths.get("foo");
+ static Stream<Date> createDateFixtures() {
+ return Stream.of(Date.from(Instant.EPOCH), Date.from(Instant.ofEpochSecond(0)), Date.from(Instant.ofEpochSecond(40_000)));
+
+ }
+
private static Stream<Arguments> createValueTestParameters() {
// force the PatternOptionBuilder to load / modify the TypeHandler table.
@SuppressWarnings("unused")
@@ -77,10 +83,8 @@ public class TypeHandlerTest {
final List<Arguments> lst = new ArrayList<>();
/*
- * Dates calculated from strings are dependent upon configuration and environment settings for the
- * machine on which the test is running. To avoid this problem, convert the time into a string
- * and then unparse that using the converter. This produces strings that always match the correct
- * time zone.
+ * Dates calculated from strings are dependent upon configuration and environment settings for the machine on which the test is running. To avoid this
+ * problem, convert the time into a string and then unparse that using the converter. This produces strings that always match the correct time zone.
*/
final Date date = new Date(1023400137000L);
final DateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
@@ -148,8 +152,7 @@ public class TypeHandlerTest {
lst.add(Arguments.of("not a number", PatternOptionBuilder.NUMBER_VALUE, ParseException.class));
lst.add(Arguments.of(Instantiable.class.getName(), PatternOptionBuilder.OBJECT_VALUE, new Instantiable()));
- lst.add(Arguments.of(NotInstantiable.class.getName(), PatternOptionBuilder.OBJECT_VALUE,
- ParseException.class));
+ lst.add(Arguments.of(NotInstantiable.class.getName(), PatternOptionBuilder.OBJECT_VALUE, ParseException.class));
lst.add(Arguments.of("unknown", PatternOptionBuilder.OBJECT_VALUE, ParseException.class));
lst.add(Arguments.of("String", PatternOptionBuilder.STRING_VALUE, "String"));
@@ -189,10 +192,15 @@ public class TypeHandlerTest {
}
}
+ @ParameterizedTest
+ @MethodSource("createDateFixtures")
+ public void testCreateDate(final Date date) {
+ assertEquals(date, TypeHandler.createDate(date.toString()));
+ }
+
@Test
public void testCreateValueExistingFile() throws Exception {
- try (FileInputStream result = TypeHandler.createValue(
- "src/test/resources/org/apache/commons/cli/existing-readable.file",
+ try (FileInputStream result = TypeHandler.createValue("src/test/resources/org/apache/commons/cli/existing-readable.file",
PatternOptionBuilder.EXISTING_FILE_VALUE)) {
assertNotNull(result);
}
(commons-cli) 02/02: Testing TypeHandler.createFile() should not have been removed
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
commit c258dae36fd9d1543505fea8ec818631c8a3e34f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 7 13:12:49 2024 -0400
Testing TypeHandler.createFile() should not have been removed
---
src/test/java/org/apache/commons/cli/TypeHandlerTest.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/test/java/org/apache/commons/cli/TypeHandlerTest.java b/src/test/java/org/apache/commons/cli/TypeHandlerTest.java
index cd1c33d..e2a3bfc 100644
--- a/src/test/java/org/apache/commons/cli/TypeHandlerTest.java
+++ b/src/test/java/org/apache/commons/cli/TypeHandlerTest.java
@@ -198,6 +198,12 @@ public class TypeHandlerTest {
assertEquals(date, TypeHandler.createDate(date.toString()));
}
+ @Test
+ public void testCreateFile() {
+ final File file = new File("").getAbsoluteFile();
+ assertEquals(file, TypeHandler.createFile(file.toString()));
+ }
+
@Test
public void testCreateValueExistingFile() throws Exception {
try (FileInputStream result = TypeHandler.createValue("src/test/resources/org/apache/commons/cli/existing-readable.file",