DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Unit Test CacheBuilder/Cache's configured values (expireAfterAccess and maximumSize) #1559

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
After adding two values to my application's Config class to set 
expireAfterAccess and maximumSize on CacheBuilder, I'm finding it difficult to 
verify in a unit test that I've configured the CacheBuilder correctly. I'd like 
to ensure that the value provided by my config class is the value set for these 
two properties, but I don't see anything on CacheBuilder or Cache's interface 
to check the configured values. I would mock the CacheBuidler, but it is final, 
so I'm forced to wrap it. It feels absurd to do this as the CacheBuilder is the 
abstraction for constructing a Cache object. Any advice on this would be 
appreciated.

Original issue reported on code.google.com by cob...@gmail.com on 20 Oct 2013 at 3:48

GoogleCodeExporter commented 9 years ago
Any advice is simple: Use CacheBuilder.toString. While no sane program relies 
on toString, in a test it's acceptable if you compare it strictly. Should the 
representation change, then your test will fail, no damage done.

Original comment by Maaarti...@gmail.com on 24 Oct 2013 at 11:29

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 20 Nov 2013 at 8:15

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08