From a0c22c3687054833c053c14c501381ee3eb57a19 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Tue, 11 Feb 2014 17:51:10 -0500 Subject: [PATCH] Add tests for cache invalidation with ref config and full config --- .../typesafe/config/impl/PublicApiTest.scala | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/config/src/test/scala/com/typesafe/config/impl/PublicApiTest.scala b/config/src/test/scala/com/typesafe/config/impl/PublicApiTest.scala index 67b6d3dc..64a2e2ef 100644 --- a/config/src/test/scala/com/typesafe/config/impl/PublicApiTest.scala +++ b/config/src/test/scala/com/typesafe/config/impl/PublicApiTest.scala @@ -937,6 +937,28 @@ class PublicApiTest extends TestUtils { assertTrue("stuff gets cached repeatedly conf", conf3 eq conf4) } + @Test + def invalidateReferenceConfig(): Unit = { + val orig = ConfigFactory.defaultReference() + val cached = ConfigFactory.defaultReference() + assertTrue("reference config was cached", orig eq cached) + + ConfigFactory.invalidateCaches() + val changed = ConfigFactory.defaultReference() + assertTrue("reference config was invalidated", orig ne changed) + } + + @Test + def invalidateFullConfig(): Unit = { + val orig = ConfigFactory.load() + val cached = ConfigFactory.load() + assertTrue("full config was cached", orig eq cached) + + ConfigFactory.invalidateCaches() + val changed = ConfigFactory.load() + assertTrue("full config was invalidated", orig ne changed) + } + @Test def canUseSomeValuesWithoutResolving(): Unit = { val conf = ConfigFactory.parseString("a=42,b=${NOPE}")