Polishing tests
This commit adds more test coverage of SpringCoreBlockHoundIntegration. See gh-33450
This commit is contained in:
parent
f6e96a24d4
commit
de4ff4b44b
|
@ -66,7 +66,7 @@ class SpringCoreBlockHoundIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void concurrentReferenceHashMap() {
|
||||
void concurrentReferenceHashMapSegmentDoTask() {
|
||||
int size = 10000;
|
||||
Map<String, String> map = new ConcurrentReferenceHashMap<>(size);
|
||||
|
||||
|
@ -88,6 +88,29 @@ class SpringCoreBlockHoundIntegrationTests {
|
|||
assertThat(map).hasSize(size);
|
||||
}
|
||||
|
||||
@Test
|
||||
void concurrentReferenceHashMapSegmentClear() {
|
||||
int size = 10000;
|
||||
Map<String, String> map = new ConcurrentReferenceHashMap<>(size);
|
||||
|
||||
CompletableFuture<Object> future1 = new CompletableFuture<>();
|
||||
testNonBlockingTask(() -> {
|
||||
for (int i = 0; i < size / 2; i++) {
|
||||
map.put("a" + i, "bar");
|
||||
}
|
||||
}, future1);
|
||||
|
||||
CompletableFuture<Object> future2 = new CompletableFuture<>();
|
||||
testNonBlockingTask(() -> {
|
||||
for (int i = 0; i < size; i++) {
|
||||
map.clear();
|
||||
}
|
||||
}, future2);
|
||||
|
||||
CompletableFuture.allOf(future1, future2).join();
|
||||
assertThat(map).isEmpty();
|
||||
}
|
||||
|
||||
private void testNonBlockingTask(NonBlockingTask task) {
|
||||
CompletableFuture<Object> future = new CompletableFuture<>();
|
||||
testNonBlockingTask(task, future);
|
||||
|
|
Loading…
Reference in New Issue