233234235236237238239240241242243
} public void testKeySet() { Cache cache = initialize(); Set set = cache.keySet(); assertEquals(3, set.size()); assertTrue(set.contains("first key")); assertTrue(set.contains("second key")); assertTrue(set.contains("third key"));
7374757677787980818283
assertEquals(0, cache.size()); cache.clear(); assertEquals(0, cache.size()); Set keys = cache.keySet(); assertEquals(0, keys.size()); Collection values = cache.values(); assertEquals(0, values.size());
215216217218219220221222223224225
} public void testKeySet() throws CacheAcquireException { Cache cache = initialize(); Set set = cache.keySet(); assertEquals(3, set.size()); assertTrue(set.contains("first key")); assertTrue(set.contains("second key")); assertTrue(set.contains("third key"));
103104105106107108109110111112113
} catch (Throwable t) { fail("UnsupportedOperationException should have been thrown."); } try { c.keySet(); fail("UnsupportedOperationException should have been thrown."); } catch (UnsupportedOperationException ex) { assertEquals("keySet()", ex.getMessage()); } catch (Throwable t) { fail("UnsupportedOperationException should have been thrown.");
189190191192193194195196197198199
147148149150151152153154155156157
} catch (UnsupportedOperationException ex) { assertEquals("containsValue(Object)", ex.getMessage()); } try { c.keySet(); fail("keySet() should throw an UnsupportedOperationException"); } catch (UnsupportedOperationException ex) { assertEquals("keySet()", ex.getMessage()); }