avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fo...@apache.org
Subject [avro] branch master updated: AVRO-2241. Fix Jsr310/Joda datetime tests (#346)
Date Tue, 23 Oct 2018 15:03:39 GMT
This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new d695a50  AVRO-2241. Fix Jsr310/Joda datetime tests (#346)
d695a50 is described below

commit d695a50ae56398b7daeac40f9a0bbbd605b68731
Author: Fokko Driesprong <fokko@driesprong.frl>
AuthorDate: Tue Oct 23 17:03:33 2018 +0200

    AVRO-2241. Fix Jsr310/Joda datetime tests (#346)
    
    Whe comparing Instant, DateTime, LocalTime with its Joda equivalents
    the tests fail since the java.time.* adds support for microseconds,
    and Joda only miliseconds. For example:
    
    Failed tests:
      TestSpecificLogicalTypes.testAbilityToReadJodaRecordWrittenAsJsr310Record:183
    Expected: is "11:45:07.170331"
         but: was "11:45:07.170"
      TestSpecificLogicalTypes.testRecordWithJsr310LogicalTypes:115 Should match written record
expected:
    
    <{"b": true, "i32": 34, "i64": 35, "f32": 3.14, "f64": 3019.34, "s": null, "d": 2018-10-11,
"t": 11:45:06.513252, "ts": 2018-10-11T11:45:06.513358Z, "dec": 123.45}>
    
    but was:
    
    <{"b": true, "i32": 34, "i64": 35, "f32": 3.14, "f64": 3019.34, "s": null, "d": 2018-10-11,
"t": 11:45:06.513, "ts": 2018-10-11T11:45:06.513Z, "dec": 123.45}>
---
 .../org/apache/avro/specific/TestSpecificLogicalTypes.java     | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java
b/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java
index a07dec5..9a9fec4 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java
@@ -40,6 +40,8 @@ import org.junit.rules.TemporaryFolder;
 import java.io.File;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -103,8 +105,8 @@ public class TestSpecificLogicalTypes {
         3019.34,
         null,
         java.time.LocalDate.now(),
-        java.time.LocalTime.now(),
-        java.time.Instant.now(),
+        java.time.LocalTime.now().truncatedTo(ChronoUnit.MILLIS),
+        java.time.Instant.now().truncatedTo(ChronoUnit.MILLIS),
         new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN)
     );
 
@@ -160,8 +162,8 @@ public class TestSpecificLogicalTypes {
             3019.34,
             null,
             java.time.LocalDate.now(),
-            java.time.LocalTime.now(),
-            java.time.Instant.now(),
+            java.time.LocalTime.now().truncatedTo(ChronoUnit.MILLIS),
+            java.time.Instant.now().truncatedTo(ChronoUnit.MILLIS),
             new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN)
     );
 


Mime
View raw message