/** * {@inheritDoc} */ @Override public Iterator<Entry<K, V>> iterator() { return cache.iterator(); }
/** * Tests {@link Ehcache#iterator()} on an empty cache. */ @Test public void testIteratorEmptyStoreGet() throws Exception { this.store = new FakeStore(Collections.emptyMap()); final InternalCache<String, String> ehcache = this.getEhcache(); assertThat(ehcache.iterator(), is(notNullValue())); }
/** * Tests {@link java.util.Iterator#hasNext()} from {@link Ehcache#iterator()} on an empty cache. */ @Test public void testIteratorEmptyStoreHasNext() throws Exception { this.store = new FakeStore(Collections.emptyMap()); final InternalCache<String, String> ehcache = this.getEhcache(); final Iterator<Cache.Entry<String, String>> iterator = ehcache.iterator(); assertThat(iterator.hasNext(), is(false)); }
/** * Tests {@link java.util.Iterator#hasNext()} <b>after</b> exhausting the {@code Iterator} returned * from {@link Ehcache#iterator()} on a non-empty cache. */ @Test public void testIteratorNonEmptyHasNextAfterLast() throws Exception { this.store = new FakeStore(this.getTestStoreEntries()); final InternalCache<String, String> ehcache = this.getEhcache(); final Iterator<Cache.Entry<String, String>> iterator = ehcache.iterator(); while (iterator.hasNext()) { iterator.next(); } assertThat(iterator.hasNext(), is(false)); }
/** * Tests {@link java.util.Iterator#next()} from {@link Ehcache#iterator()} on a non-empty cache. */ @Test public void testIteratorNonEmptyStoreNext() throws Exception { this.store = new FakeStore(this.getTestStoreEntries()); final InternalCache<String, String> ehcache = this.getEhcache(); final Iterator<Cache.Entry<String, String>> iterator = ehcache.iterator(); assertThat(iterator.next(), is(notNullValue())); }
/** * Tests {@link java.util.Iterator#next()} from {@link Ehcache#iterator()} on an empty cache. */ @Test public void testIteratorEmptyStoreNext() throws Exception { this.store = new FakeStore(Collections.emptyMap()); final InternalCache<String, String> ehcache = this.getEhcache(); final Iterator<Cache.Entry<String, String>> iterator = ehcache.iterator(); try { iterator.next(); fail(); } catch (NoSuchElementException e) { // expected } }
/** * Tests {@link java.util.Iterator#remove()} from {@link Ehcache#iterator()} on an empty cache. */ @Test public void testIteratorEmptyStoreRemoveBeforeNext() throws Exception { this.store = new FakeStore(Collections.emptyMap()); final InternalCache<String, String> ehcache = this.getEhcache(); final Iterator<Cache.Entry<String, String>> iterator = ehcache.iterator(); try { iterator.remove(); fail(); } catch (IllegalStateException e) { // expected } }
/** * Tests {@link Ehcache#iterator()} on a non-empty cache. */ @Test public void testIteratorNonEmptyStoreGet() throws Exception { this.store = new FakeStore(this.getTestStoreEntries()); final InternalCache<String, String> ehcache = this.getEhcache(); assertThat(ehcache.iterator(), is(notNullValue())); }
/** * Tests {@link java.util.Iterator#hasNext()} from {@link Ehcache#iterator()} on a non-empty cache. */ @Test public void testIteratorNonEmptyStoreHasNext() throws Exception { this.store = new FakeStore(this.getTestStoreEntries()); final InternalCache<String, String> ehcache = this.getEhcache(); final Iterator<Cache.Entry<String, String>> iterator = ehcache.iterator(); assertThat(iterator.hasNext(), is(true)); }
/** * Tests {@link java.util.Iterator#next()} <b>after</b> exhausting the {@code Iterator} returned * from {@link Ehcache#iterator()} on a non-empty cache. */ @Test public void testIteratorNonEmptyNextAfterLast() throws Exception { this.store = new FakeStore(this.getTestStoreEntries()); final InternalCache<String, String> ehcache = this.getEhcache(); final Iterator<Cache.Entry<String, String>> iterator = ehcache.iterator(); while (iterator.hasNext()) { iterator.next(); } try { iterator.next(); fail(); } catch (NoSuchElementException e) { // expected } }
final Iterator<Cache.Entry<String, String>> iterator = ehcache.iterator(); assertThat(iterator, is(notNullValue())); assertThat(iterator.hasNext(), is(true));
/** * {@inheritDoc} */ @Override public Iterator<Entry<K, V>> iterator() { return cache.iterator(); }