1 /*
2  * Copyright (C) 2011 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.common.cache;
18 
19 import static com.google.common.cache.CacheBuilderSpec.parse;
20 import static com.google.common.cache.TestingWeighers.constantWeigher;
21 
22 import com.google.common.base.Suppliers;
23 import com.google.common.cache.LocalCache.Strength;
24 import com.google.common.testing.EqualsTester;
25 import java.util.concurrent.TimeUnit;
26 import junit.framework.TestCase;
27 
28 /**
29  * Tests CacheBuilderSpec. TODO(user): tests of a few invalid input conditions, boundary
30  * conditions.
31  *
32  * @author Adam Winer
33  */
34 public class CacheBuilderSpecTest extends TestCase {
testParse_empty()35   public void testParse_empty() {
36     CacheBuilderSpec spec = parse("");
37     assertNull(spec.initialCapacity);
38     assertNull(spec.maximumSize);
39     assertNull(spec.maximumWeight);
40     assertNull(spec.concurrencyLevel);
41     assertNull(spec.keyStrength);
42     assertNull(spec.valueStrength);
43     assertNull(spec.writeExpirationTimeUnit);
44     assertNull(spec.accessExpirationTimeUnit);
45     assertCacheBuilderEquivalence(CacheBuilder.newBuilder(), CacheBuilder.from(spec));
46   }
47 
testParse_initialCapacity()48   public void testParse_initialCapacity() {
49     CacheBuilderSpec spec = parse("initialCapacity=10");
50     assertEquals(10, spec.initialCapacity.intValue());
51     assertNull(spec.maximumSize);
52     assertNull(spec.maximumWeight);
53     assertNull(spec.concurrencyLevel);
54     assertNull(spec.keyStrength);
55     assertNull(spec.valueStrength);
56     assertNull(spec.writeExpirationTimeUnit);
57     assertNull(spec.accessExpirationTimeUnit);
58     assertCacheBuilderEquivalence(
59         CacheBuilder.newBuilder().initialCapacity(10), CacheBuilder.from(spec));
60   }
61 
testParse_initialCapacityRepeated()62   public void testParse_initialCapacityRepeated() {
63     try {
64       parse("initialCapacity=10, initialCapacity=20");
65       fail("Expected exception");
66     } catch (IllegalArgumentException expected) {
67     }
68   }
69 
testParse_maximumSize()70   public void testParse_maximumSize() {
71     CacheBuilderSpec spec = parse("maximumSize=9000");
72     assertNull(spec.initialCapacity);
73     assertEquals(9000, spec.maximumSize.longValue());
74     assertNull(spec.concurrencyLevel);
75     assertNull(spec.keyStrength);
76     assertNull(spec.valueStrength);
77     assertNull(spec.writeExpirationTimeUnit);
78     assertNull(spec.accessExpirationTimeUnit);
79     assertCacheBuilderEquivalence(
80         CacheBuilder.newBuilder().maximumSize(9000), CacheBuilder.from(spec));
81   }
82 
testParse_maximumSizeRepeated()83   public void testParse_maximumSizeRepeated() {
84     try {
85       parse("maximumSize=10, maximumSize=20");
86       fail("Expected exception");
87     } catch (IllegalArgumentException expected) {
88     }
89   }
90 
testParse_maximumWeight()91   public void testParse_maximumWeight() {
92     CacheBuilderSpec spec = parse("maximumWeight=9000");
93     assertNull(spec.initialCapacity);
94     assertEquals(9000, spec.maximumWeight.longValue());
95     assertNull(spec.concurrencyLevel);
96     assertNull(spec.keyStrength);
97     assertNull(spec.valueStrength);
98     assertNull(spec.writeExpirationTimeUnit);
99     assertNull(spec.accessExpirationTimeUnit);
100     assertCacheBuilderEquivalence(
101         CacheBuilder.newBuilder().maximumWeight(9000), CacheBuilder.from(spec));
102   }
103 
testParse_maximumWeightRepeated()104   public void testParse_maximumWeightRepeated() {
105     try {
106       parse("maximumWeight=10, maximumWeight=20");
107       fail("Expected exception");
108     } catch (IllegalArgumentException expected) {
109     }
110   }
111 
testParse_maximumSizeAndMaximumWeight()112   public void testParse_maximumSizeAndMaximumWeight() {
113     try {
114       parse("maximumSize=10, maximumWeight=20");
115       fail("Expected exception");
116     } catch (IllegalArgumentException expected) {
117     }
118   }
119 
testParse_concurrencyLevel()120   public void testParse_concurrencyLevel() {
121     CacheBuilderSpec spec = parse("concurrencyLevel=32");
122     assertNull(spec.initialCapacity);
123     assertNull(spec.maximumSize);
124     assertNull(spec.maximumWeight);
125     assertEquals(32, spec.concurrencyLevel.intValue());
126     assertNull(spec.keyStrength);
127     assertNull(spec.valueStrength);
128     assertNull(spec.writeExpirationTimeUnit);
129     assertNull(spec.accessExpirationTimeUnit);
130     assertCacheBuilderEquivalence(
131         CacheBuilder.newBuilder().concurrencyLevel(32), CacheBuilder.from(spec));
132   }
133 
testParse_concurrencyLevelRepeated()134   public void testParse_concurrencyLevelRepeated() {
135     try {
136       parse("concurrencyLevel=10, concurrencyLevel=20");
137       fail("Expected exception");
138     } catch (IllegalArgumentException expected) {
139     }
140   }
141 
testParse_weakKeys()142   public void testParse_weakKeys() {
143     CacheBuilderSpec spec = parse("weakKeys");
144     assertNull(spec.initialCapacity);
145     assertNull(spec.maximumSize);
146     assertNull(spec.maximumWeight);
147     assertNull(spec.concurrencyLevel);
148     assertEquals(Strength.WEAK, spec.keyStrength);
149     assertNull(spec.valueStrength);
150     assertNull(spec.writeExpirationTimeUnit);
151     assertNull(spec.accessExpirationTimeUnit);
152     assertCacheBuilderEquivalence(CacheBuilder.newBuilder().weakKeys(), CacheBuilder.from(spec));
153   }
154 
testParse_weakKeysCannotHaveValue()155   public void testParse_weakKeysCannotHaveValue() {
156     try {
157       parse("weakKeys=true");
158       fail("Expected exception");
159     } catch (IllegalArgumentException expected) {
160     }
161   }
162 
testParse_repeatedKeyStrength()163   public void testParse_repeatedKeyStrength() {
164     try {
165       parse("weakKeys, weakKeys");
166       fail("Expected exception");
167     } catch (IllegalArgumentException expected) {
168     }
169   }
170 
testParse_softValues()171   public void testParse_softValues() {
172     CacheBuilderSpec spec = parse("softValues");
173     assertNull(spec.initialCapacity);
174     assertNull(spec.maximumSize);
175     assertNull(spec.maximumWeight);
176     assertNull(spec.concurrencyLevel);
177     assertNull(spec.keyStrength);
178     assertEquals(Strength.SOFT, spec.valueStrength);
179     assertNull(spec.writeExpirationTimeUnit);
180     assertNull(spec.accessExpirationTimeUnit);
181     assertCacheBuilderEquivalence(CacheBuilder.newBuilder().softValues(), CacheBuilder.from(spec));
182   }
183 
testParse_softValuesCannotHaveValue()184   public void testParse_softValuesCannotHaveValue() {
185     try {
186       parse("softValues=true");
187       fail("Expected exception");
188     } catch (IllegalArgumentException expected) {
189     }
190   }
191 
testParse_weakValues()192   public void testParse_weakValues() {
193     CacheBuilderSpec spec = parse("weakValues");
194     assertNull(spec.initialCapacity);
195     assertNull(spec.maximumSize);
196     assertNull(spec.maximumWeight);
197     assertNull(spec.concurrencyLevel);
198     assertNull(spec.keyStrength);
199     assertEquals(Strength.WEAK, spec.valueStrength);
200     assertNull(spec.writeExpirationTimeUnit);
201     assertNull(spec.accessExpirationTimeUnit);
202     assertCacheBuilderEquivalence(CacheBuilder.newBuilder().weakValues(), CacheBuilder.from(spec));
203   }
204 
testParse_weakValuesCannotHaveValue()205   public void testParse_weakValuesCannotHaveValue() {
206     try {
207       parse("weakValues=true");
208       fail("Expected exception");
209     } catch (IllegalArgumentException expected) {
210     }
211   }
212 
testParse_repeatedValueStrength()213   public void testParse_repeatedValueStrength() {
214     try {
215       parse("softValues, softValues");
216       fail("Expected exception");
217     } catch (IllegalArgumentException expected) {
218     }
219 
220     try {
221       parse("softValues, weakValues");
222       fail("Expected exception");
223     } catch (IllegalArgumentException expected) {
224     }
225 
226     try {
227       parse("weakValues, softValues");
228       fail("Expected exception");
229     } catch (IllegalArgumentException expected) {
230     }
231 
232     try {
233       parse("weakValues, weakValues");
234       fail("Expected exception");
235     } catch (IllegalArgumentException expected) {
236     }
237   }
238 
testParse_writeExpirationDays()239   public void testParse_writeExpirationDays() {
240     CacheBuilderSpec spec = parse("expireAfterWrite=10d");
241     assertNull(spec.initialCapacity);
242     assertNull(spec.maximumSize);
243     assertNull(spec.maximumWeight);
244     assertNull(spec.concurrencyLevel);
245     assertNull(spec.keyStrength);
246     assertNull(spec.valueStrength);
247     assertEquals(TimeUnit.DAYS, spec.writeExpirationTimeUnit);
248     assertEquals(10L, spec.writeExpirationDuration);
249     assertNull(spec.accessExpirationTimeUnit);
250     assertCacheBuilderEquivalence(
251         CacheBuilder.newBuilder().expireAfterWrite(10L, TimeUnit.DAYS), CacheBuilder.from(spec));
252   }
253 
testParse_writeExpirationHours()254   public void testParse_writeExpirationHours() {
255     CacheBuilderSpec spec = parse("expireAfterWrite=150h");
256     assertEquals(TimeUnit.HOURS, spec.writeExpirationTimeUnit);
257     assertEquals(150L, spec.writeExpirationDuration);
258     assertCacheBuilderEquivalence(
259         CacheBuilder.newBuilder().expireAfterWrite(150L, TimeUnit.HOURS), CacheBuilder.from(spec));
260   }
261 
testParse_writeExpirationMinutes()262   public void testParse_writeExpirationMinutes() {
263     CacheBuilderSpec spec = parse("expireAfterWrite=10m");
264     assertEquals(TimeUnit.MINUTES, spec.writeExpirationTimeUnit);
265     assertEquals(10L, spec.writeExpirationDuration);
266     assertCacheBuilderEquivalence(
267         CacheBuilder.newBuilder().expireAfterWrite(10L, TimeUnit.MINUTES), CacheBuilder.from(spec));
268   }
269 
testParse_writeExpirationSeconds()270   public void testParse_writeExpirationSeconds() {
271     CacheBuilderSpec spec = parse("expireAfterWrite=10s");
272     assertEquals(TimeUnit.SECONDS, spec.writeExpirationTimeUnit);
273     assertEquals(10L, spec.writeExpirationDuration);
274     assertCacheBuilderEquivalence(
275         CacheBuilder.newBuilder().expireAfterWrite(10L, TimeUnit.SECONDS), CacheBuilder.from(spec));
276   }
277 
testParse_writeExpirationRepeated()278   public void testParse_writeExpirationRepeated() {
279     try {
280       parse("expireAfterWrite=10s,expireAfterWrite=10m");
281       fail("Expected exception");
282     } catch (IllegalArgumentException expected) {
283     }
284   }
285 
testParse_accessExpirationDays()286   public void testParse_accessExpirationDays() {
287     CacheBuilderSpec spec = parse("expireAfterAccess=10d");
288     assertNull(spec.initialCapacity);
289     assertNull(spec.maximumSize);
290     assertNull(spec.maximumWeight);
291     assertNull(spec.concurrencyLevel);
292     assertNull(spec.keyStrength);
293     assertNull(spec.valueStrength);
294     assertNull(spec.writeExpirationTimeUnit);
295     assertEquals(TimeUnit.DAYS, spec.accessExpirationTimeUnit);
296     assertEquals(10L, spec.accessExpirationDuration);
297     assertCacheBuilderEquivalence(
298         CacheBuilder.newBuilder().expireAfterAccess(10L, TimeUnit.DAYS), CacheBuilder.from(spec));
299   }
300 
testParse_accessExpirationHours()301   public void testParse_accessExpirationHours() {
302     CacheBuilderSpec spec = parse("expireAfterAccess=150h");
303     assertEquals(TimeUnit.HOURS, spec.accessExpirationTimeUnit);
304     assertEquals(150L, spec.accessExpirationDuration);
305     assertCacheBuilderEquivalence(
306         CacheBuilder.newBuilder().expireAfterAccess(150L, TimeUnit.HOURS), CacheBuilder.from(spec));
307   }
308 
testParse_accessExpirationMinutes()309   public void testParse_accessExpirationMinutes() {
310     CacheBuilderSpec spec = parse("expireAfterAccess=10m");
311     assertEquals(TimeUnit.MINUTES, spec.accessExpirationTimeUnit);
312     assertEquals(10L, spec.accessExpirationDuration);
313     assertCacheBuilderEquivalence(
314         CacheBuilder.newBuilder().expireAfterAccess(10L, TimeUnit.MINUTES),
315         CacheBuilder.from(spec));
316   }
317 
testParse_accessExpirationSeconds()318   public void testParse_accessExpirationSeconds() {
319     CacheBuilderSpec spec = parse("expireAfterAccess=10s");
320     assertEquals(TimeUnit.SECONDS, spec.accessExpirationTimeUnit);
321     assertEquals(10L, spec.accessExpirationDuration);
322     assertCacheBuilderEquivalence(
323         CacheBuilder.newBuilder().expireAfterAccess(10L, TimeUnit.SECONDS),
324         CacheBuilder.from(spec));
325   }
326 
testParse_accessExpirationRepeated()327   public void testParse_accessExpirationRepeated() {
328     try {
329       parse("expireAfterAccess=10s,expireAfterAccess=10m");
330       fail("Expected exception");
331     } catch (IllegalArgumentException expected) {
332     }
333   }
334 
testParse_recordStats()335   public void testParse_recordStats() {
336     CacheBuilderSpec spec = parse("recordStats");
337     assertTrue(spec.recordStats);
338     assertCacheBuilderEquivalence(CacheBuilder.newBuilder().recordStats(), CacheBuilder.from(spec));
339   }
340 
testParse_recordStatsValueSpecified()341   public void testParse_recordStatsValueSpecified() {
342     try {
343       parse("recordStats=True");
344       fail("Expected exception");
345     } catch (IllegalArgumentException expected) {
346     }
347   }
348 
testParse_recordStatsRepeated()349   public void testParse_recordStatsRepeated() {
350     try {
351       parse("recordStats,recordStats");
352       fail("Expected exception");
353     } catch (IllegalArgumentException expected) {
354     }
355   }
356 
testParse_accessExpirationAndWriteExpiration()357   public void testParse_accessExpirationAndWriteExpiration() {
358     CacheBuilderSpec spec = parse("expireAfterAccess=10s,expireAfterWrite=9m");
359     assertEquals(TimeUnit.MINUTES, spec.writeExpirationTimeUnit);
360     assertEquals(9L, spec.writeExpirationDuration);
361     assertEquals(TimeUnit.SECONDS, spec.accessExpirationTimeUnit);
362     assertEquals(10L, spec.accessExpirationDuration);
363     assertCacheBuilderEquivalence(
364         CacheBuilder.newBuilder()
365             .expireAfterAccess(10L, TimeUnit.SECONDS)
366             .expireAfterWrite(9L, TimeUnit.MINUTES),
367         CacheBuilder.from(spec));
368   }
369 
testParse_multipleKeys()370   public void testParse_multipleKeys() {
371     CacheBuilderSpec spec =
372         parse(
373             "initialCapacity=10,maximumSize=20,concurrencyLevel=30,"
374                 + "weakKeys,weakValues,expireAfterAccess=10m,expireAfterWrite=1h");
375     assertEquals(10, spec.initialCapacity.intValue());
376     assertEquals(20, spec.maximumSize.intValue());
377     assertNull(spec.maximumWeight);
378     assertEquals(30, spec.concurrencyLevel.intValue());
379     assertEquals(Strength.WEAK, spec.keyStrength);
380     assertEquals(Strength.WEAK, spec.valueStrength);
381     assertEquals(TimeUnit.HOURS, spec.writeExpirationTimeUnit);
382     assertEquals(TimeUnit.MINUTES, spec.accessExpirationTimeUnit);
383     assertEquals(1L, spec.writeExpirationDuration);
384     assertEquals(10L, spec.accessExpirationDuration);
385     CacheBuilder<?, ?> expected =
386         CacheBuilder.newBuilder()
387             .initialCapacity(10)
388             .maximumSize(20)
389             .concurrencyLevel(30)
390             .weakKeys()
391             .weakValues()
392             .expireAfterAccess(10L, TimeUnit.MINUTES)
393             .expireAfterWrite(1L, TimeUnit.HOURS);
394     assertCacheBuilderEquivalence(expected, CacheBuilder.from(spec));
395   }
396 
testParse_whitespaceAllowed()397   public void testParse_whitespaceAllowed() {
398     CacheBuilderSpec spec =
399         parse(
400             " initialCapacity=10,\nmaximumSize=20,\t\r"
401                 + "weakKeys \t ,softValues \n , \r  expireAfterWrite \t =  15s\n\n");
402     assertEquals(10, spec.initialCapacity.intValue());
403     assertEquals(20, spec.maximumSize.intValue());
404     assertNull(spec.maximumWeight);
405     assertNull(spec.concurrencyLevel);
406     assertEquals(Strength.WEAK, spec.keyStrength);
407     assertEquals(Strength.SOFT, spec.valueStrength);
408     assertEquals(TimeUnit.SECONDS, spec.writeExpirationTimeUnit);
409     assertEquals(15L, spec.writeExpirationDuration);
410     assertNull(spec.accessExpirationTimeUnit);
411     CacheBuilder<?, ?> expected =
412         CacheBuilder.newBuilder()
413             .initialCapacity(10)
414             .maximumSize(20)
415             .weakKeys()
416             .softValues()
417             .expireAfterWrite(15L, TimeUnit.SECONDS);
418     assertCacheBuilderEquivalence(expected, CacheBuilder.from(spec));
419   }
420 
testParse_unknownKey()421   public void testParse_unknownKey() {
422     try {
423       parse("foo=17");
424       fail("Expected exception");
425     } catch (IllegalArgumentException expected) {
426     }
427   }
428 
testParse_extraCommaIsInvalid()429   public void testParse_extraCommaIsInvalid() {
430     try {
431       parse("weakKeys,");
432       fail("Expected exception");
433     } catch (IllegalArgumentException expected) {
434     }
435 
436     try {
437       parse(",weakKeys");
438       fail("Expected exception");
439     } catch (IllegalArgumentException expected) {
440     }
441 
442     try {
443       parse("weakKeys,,softValues");
444       fail("Expected exception");
445     } catch (IllegalArgumentException expected) {
446     }
447   }
448 
testEqualsAndHashCode()449   public void testEqualsAndHashCode() {
450     new EqualsTester()
451         .addEqualityGroup(parse(""), parse(""))
452         .addEqualityGroup(parse("concurrencyLevel=7"), parse("concurrencyLevel=7"))
453         .addEqualityGroup(parse("concurrencyLevel=15"), parse("concurrencyLevel=15"))
454         .addEqualityGroup(parse("initialCapacity=7"), parse("initialCapacity=7"))
455         .addEqualityGroup(parse("initialCapacity=15"), parse("initialCapacity=15"))
456         .addEqualityGroup(parse("maximumSize=7"), parse("maximumSize=7"))
457         .addEqualityGroup(parse("maximumSize=15"), parse("maximumSize=15"))
458         .addEqualityGroup(parse("maximumWeight=7"), parse("maximumWeight=7"))
459         .addEqualityGroup(parse("maximumWeight=15"), parse("maximumWeight=15"))
460         .addEqualityGroup(parse("expireAfterAccess=60s"), parse("expireAfterAccess=1m"))
461         .addEqualityGroup(parse("expireAfterAccess=60m"), parse("expireAfterAccess=1h"))
462         .addEqualityGroup(parse("expireAfterWrite=60s"), parse("expireAfterWrite=1m"))
463         .addEqualityGroup(parse("expireAfterWrite=60m"), parse("expireAfterWrite=1h"))
464         .addEqualityGroup(parse("weakKeys"), parse("weakKeys"))
465         .addEqualityGroup(parse("softValues"), parse("softValues"))
466         .addEqualityGroup(parse("weakValues"), parse("weakValues"))
467         .addEqualityGroup(parse("recordStats"), parse("recordStats"))
468         .testEquals();
469   }
470 
testMaximumWeight_withWeigher()471   public void testMaximumWeight_withWeigher() {
472     CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumWeight=9000"));
473     builder.weigher(constantWeigher(42)).build(CacheLoader.from(Suppliers.ofInstance(null)));
474   }
475 
testMaximumWeight_withoutWeigher()476   public void testMaximumWeight_withoutWeigher() {
477     CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumWeight=9000"));
478     try {
479       builder.build(CacheLoader.from(Suppliers.ofInstance(null)));
480       fail();
481     } catch (IllegalStateException expected) {
482     }
483   }
484 
testMaximumSize_withWeigher()485   public void testMaximumSize_withWeigher() {
486     CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumSize=9000"));
487     builder.weigher(constantWeigher(42)).build(CacheLoader.from(Suppliers.ofInstance(null)));
488   }
489 
testMaximumSize_withoutWeigher()490   public void testMaximumSize_withoutWeigher() {
491     CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumSize=9000"));
492     builder.build(CacheLoader.from(Suppliers.ofInstance(null)));
493   }
494 
testDisableCaching()495   public void testDisableCaching() {
496     // Functional test: assert that CacheBuilderSpec.disableCaching()
497     // disables caching.  It's irrelevant how it does so.
498     CacheBuilder<Object, Object> builder = CacheBuilder.from(CacheBuilderSpec.disableCaching());
499     Object key = new Object();
500     Object value = new Object();
501     LoadingCache<Object, Object> cache =
502         builder.build(CacheLoader.from(Suppliers.ofInstance(value)));
503     assertSame(value, cache.getUnchecked(key));
504     assertEquals(0, cache.size());
505     assertFalse(cache.asMap().containsKey(key));
506   }
507 
testCacheBuilderFrom_string()508   public void testCacheBuilderFrom_string() {
509     CacheBuilder<?, ?> fromString =
510         CacheBuilder.from(
511             "initialCapacity=10,maximumSize=20,concurrencyLevel=30,"
512                 + "weakKeys,weakValues,expireAfterAccess=10m");
513     CacheBuilder<?, ?> expected =
514         CacheBuilder.newBuilder()
515             .initialCapacity(10)
516             .maximumSize(20)
517             .concurrencyLevel(30)
518             .weakKeys()
519             .weakValues()
520             .expireAfterAccess(10L, TimeUnit.MINUTES);
521     assertCacheBuilderEquivalence(expected, fromString);
522   }
523 
assertCacheBuilderEquivalence(CacheBuilder<?, ?> a, CacheBuilder<?, ?> b)524   private static void assertCacheBuilderEquivalence(CacheBuilder<?, ?> a, CacheBuilder<?, ?> b) {
525     assertEquals("concurrencyLevel", a.concurrencyLevel, b.concurrencyLevel);
526     assertEquals("expireAfterAccessNanos", a.expireAfterAccessNanos, b.expireAfterAccessNanos);
527     assertEquals("expireAfterWriteNanos", a.expireAfterWriteNanos, b.expireAfterWriteNanos);
528     assertEquals("initialCapacity", a.initialCapacity, b.initialCapacity);
529     assertEquals("maximumSize", a.maximumSize, b.maximumSize);
530     assertEquals("maximumWeight", a.maximumWeight, b.maximumWeight);
531     assertEquals("refreshNanos", a.refreshNanos, b.refreshNanos);
532     assertEquals("keyEquivalence", a.keyEquivalence, b.keyEquivalence);
533     assertEquals("keyStrength", a.keyStrength, b.keyStrength);
534     assertEquals("removalListener", a.removalListener, b.removalListener);
535     assertEquals("weigher", a.weigher, b.weigher);
536     assertEquals("valueEquivalence", a.valueEquivalence, b.valueEquivalence);
537     assertEquals("valueStrength", a.valueStrength, b.valueStrength);
538     assertEquals("statsCounterSupplier", a.statsCounterSupplier, b.statsCounterSupplier);
539     assertEquals("ticker", a.ticker, b.ticker);
540     assertEquals("recordStats", a.isRecordingStats(), b.isRecordingStats());
541   }
542 }
543