Running tests will pollute the cache, so we need to clear it before each
test.
Change-Id: I0cc171c22409d81092d82d5570a3c0068bbfc889
Signed-off-by: Robert Varga <rovarga@cisco.com>
*/
package org.opendaylight.yangtools.util;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
return (Map<T, Integer>) CACHE.getUnchecked(args);
}
+ @VisibleForTesting
+ static void invalidateCache() {
+ CACHE.invalidateAll();
+ }
+
static <T> Map<T, Integer> orderedOffsets(final Collection<T> args) {
if (args.size() == 1) {
return unorderedOffsets(args);
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
+import org.junit.Before;
import org.junit.Test;
public class OffsetMapTest {
return (ImmutableOffsetMap<String, String>) ImmutableOffsetMap.copyOf(twoEntryMap);
}
+ @Before
+ public void setup() {
+ OffsetMapCache.invalidateCache();
+ }
+
@Test(expected=IllegalArgumentException.class)
public void testWrongImmutableConstruction() {
new ImmutableOffsetMap.Ordered<String, String>(Collections.<String, Integer>emptyMap(), new String[1]);