[ 
https://issues.apache.org/jira/browse/AVRO-2241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16660790#comment-16660790
 ] 

ASF GitHub Bot commented on AVRO-2241:
--------------------------------------

Fokko closed pull request #346: AVRO-2241. Fix Jsr310/Joda datetime tests
URL: https://github.com/apache/avro/pull/346
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 a07dec5c8..9a9fec410 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 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 void testRecordWithJsr310LogicalTypes() throws 
IOException {
         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 void 
testAbilityToReadJodaRecordWrittenAsJsr310Record() throws IOExceptio
             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)
     );
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Fix Jsr310/Joda tests when comparing datetimes
> ----------------------------------------------
>
>                 Key: AVRO-2241
>                 URL: https://issues.apache.org/jira/browse/AVRO-2241
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.8.2
>            Reporter: Fokko Driesprong
>            Assignee: Fokko Driesprong
>            Priority: Major
>             Fix For: 1.9.0
>
>
> 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}>



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to