org.springframework.util.ConcurrentReferenceHashMap.Entry Java Examples

The following examples show how to use org.springframework.util.ConcurrentReferenceHashMap.Entry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConcurrentReferenceHashMapTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected ReferenceManager createReferenceManager() {
	return new ReferenceManager() {
		@Override
		public Reference<K, V> createReference(Entry<K, V> entry, int hash, @Nullable Reference<K, V> next) {
			if (TestWeakConcurrentCache.this.disableTestHooks) {
				return super.createReference(entry, hash, next);
			}
			return new MockReference<>(entry, hash, next, TestWeakConcurrentCache.this.queue);
		}
		@Override
		public Reference<K, V> pollForPurge() {
			if (TestWeakConcurrentCache.this.disableTestHooks) {
				return super.pollForPurge();
			}
			return TestWeakConcurrentCache.this.queue.isEmpty() ? null : TestWeakConcurrentCache.this.queue.removeFirst();
		}
	};
}
 
Example #2
Source File: ConcurrentReferenceHashMapTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
protected ReferenceManager createReferenceManager() {
	return new ReferenceManager() {
		@Override
		public Reference<K, V> createReference(Entry<K, V> entry, int hash, @Nullable Reference<K, V> next) {
			if (TestWeakConcurrentCache.this.disableTestHooks) {
				return super.createReference(entry, hash, next);
			}
			return new MockReference<>(entry, hash, next, TestWeakConcurrentCache.this.queue);
		}
		@Override
		public Reference<K, V> pollForPurge() {
			if (TestWeakConcurrentCache.this.disableTestHooks) {
				return super.pollForPurge();
			}
			return TestWeakConcurrentCache.this.queue.isEmpty() ? null : TestWeakConcurrentCache.this.queue.removeFirst();
		}
	};
}
 
Example #3
Source File: ConcurrentReferenceHashMapTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
protected ReferenceManager createReferenceManager() {
	return new ReferenceManager() {
		@Override
		public Reference<K, V> createReference(Entry<K, V> entry, int hash,
				Reference<K, V> next) {
			if (TestWeakConcurrentCache.this.disableTestHooks) {
				return super.createReference(entry, hash, next);
			}
			return new MockReference<K, V>(entry, hash, next, TestWeakConcurrentCache.this.queue);
		}
		@Override
		public Reference<K, V> pollForPurge() {
			if (TestWeakConcurrentCache.this.disableTestHooks) {
				return super.pollForPurge();
			}
			return TestWeakConcurrentCache.this.queue.isEmpty() ? null : TestWeakConcurrentCache.this.queue.removeFirst();
		}
	};
}
 
Example #4
Source File: ConcurrentReferenceHashMapTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void shouldRemoveViaEntrySet() {
	this.map.put(1, "1");
	this.map.put(2, "2");
	this.map.put(3, "3");
	Iterator<Map.Entry<Integer, String>> iterator = this.map.entrySet().iterator();
	iterator.next();
	iterator.next();
	iterator.remove();
	iterator.next();
	assertThat(iterator.hasNext(), is(false));
	assertThat(this.map.size(), is(2));
	assertThat(this.map.containsKey(2), is(false));
}
 
Example #5
Source File: ConcurrentReferenceHashMapTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void shouldSetViaEntrySet() {
	this.map.put(1, "1");
	this.map.put(2, "2");
	this.map.put(3, "3");
	Iterator<Map.Entry<Integer, String>> iterator = this.map.entrySet().iterator();
	iterator.next();
	iterator.next().setValue("2b");
	iterator.next();
	assertThat(iterator.hasNext(), is(false));
	assertThat(this.map.size(), is(3));
	assertThat(this.map.get(2), is("2b"));
}
 
Example #6
Source File: ConcurrentReferenceHashMapTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void shouldRemoveViaEntrySet() {
	this.map.put(1, "1");
	this.map.put(2, "2");
	this.map.put(3, "3");
	Iterator<Map.Entry<Integer, String>> iterator = this.map.entrySet().iterator();
	iterator.next();
	iterator.next();
	iterator.remove();
	iterator.next();
	assertThat(iterator.hasNext(), is(false));
	assertThat(this.map.size(), is(2));
	assertThat(this.map.containsKey(2), is(false));
}
 
Example #7
Source File: ConcurrentReferenceHashMapTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void shouldSetViaEntrySet() {
	this.map.put(1, "1");
	this.map.put(2, "2");
	this.map.put(3, "3");
	Iterator<Map.Entry<Integer, String>> iterator = this.map.entrySet().iterator();
	iterator.next();
	iterator.next().setValue("2b");
	iterator.next();
	assertThat(iterator.hasNext(), is(false));
	assertThat(this.map.size(), is(3));
	assertThat(this.map.get(2), is("2b"));
}
 
Example #8
Source File: ConcurrentReferenceHashMapTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldRemoveViaEntrySet() throws Exception {
	this.map.put(1, "1");
	this.map.put(2, "2");
	this.map.put(3, "3");
	Iterator<Map.Entry<Integer, String>> iterator = this.map.entrySet().iterator();
	iterator.next();
	iterator.next();
	iterator.remove();
	iterator.next();
	assertThat(iterator.hasNext(), is(false));
	assertThat(this.map.size(), is(2));
	assertThat(this.map.containsKey(2), is(false));
}
 
Example #9
Source File: ConcurrentReferenceHashMapTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSetViaEntrySet() throws Exception {
	this.map.put(1, "1");
	this.map.put(2, "2");
	this.map.put(3, "3");
	Iterator<Map.Entry<Integer, String>> iterator = this.map.entrySet().iterator();
	iterator.next();
	iterator.next().setValue("2b");
	iterator.next();
	assertThat(iterator.hasNext(), is(false));
	assertThat(this.map.size(), is(3));
	assertThat(this.map.get(2), is("2b"));
}
 
Example #10
Source File: ConcurrentReferenceHashMapTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public MockReference(Entry<K, V> entry, int hash, Reference<K, V> next, LinkedList<MockReference<K, V>> queue) {
	this.hash = hash;
	this.entry = entry;
	this.next = next;
	this.queue = queue;
}
 
Example #11
Source File: ConcurrentReferenceHashMapTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Entry<K, V> get() {
	return this.entry;
}
 
Example #12
Source File: ConcurrentReferenceHashMapTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
public MockReference(Entry<K, V> entry, int hash, Reference<K, V> next, LinkedList<MockReference<K, V>> queue) {
	this.hash = hash;
	this.entry = entry;
	this.next = next;
	this.queue = queue;
}
 
Example #13
Source File: ConcurrentReferenceHashMapTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public Entry<K, V> get() {
	return this.entry;
}
 
Example #14
Source File: ConcurrentReferenceHashMapTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public MockReference(Entry<K, V> entry, int hash, Reference<K, V> next, LinkedList<MockReference<K, V>> queue) {
	this.hash = hash;
	this.entry = entry;
	this.next = next;
	this.queue = queue;
}
 
Example #15
Source File: ConcurrentReferenceHashMapTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public Entry<K, V> get() {
	return this.entry;
}