Injecting Clock in Java

993 views

Published on

A lightning presentation on using injected Clock instances from JSR-310 (Java 8's java.time.*).

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
993
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Injecting Clock in Java

  1. 1. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. Injecting Clock
  2. 2. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. Injecting Clock is about
  3. 3. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. Injecting Clock is about
  4. 4. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. Injecting Clock is about
  5. 5. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. Injecting Clock is about
  6. 6. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. Injecting Clock is about
  7. 7. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. Why do we care? •  You can write tests that do not depend on when they are run – Ward against Daylight Savings transition •  You can write tests for specific timing conditions – Test these “after NN hours” rules •  Offers another way of controlling timezone to be used by some code – More selective than default time zone
  8. 8. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. How does it work?
  9. 9. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. How does it work?
  10. 10. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. How does it work?
  11. 11. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. How does it work?
  12. 12. © 2014 RichRelevance, Inc. All Rights Reserved. Confidential. How do I test? •  Inject a clock explicitly – Mocked – From a Clock factory

×