Skip to content

Commit b3a6dba

Browse files
committed
Polishing
1 parent ed49f86 commit b3a6dba

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Diff for: spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import static org.assertj.core.api.Assertions.assertThat;
3838
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
3939
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
40+
import static org.assertj.core.api.Assertions.assertThatNoException;
4041

4142
/**
4243
* Tests for {@link ConcurrentReferenceHashMap}.
@@ -95,26 +96,23 @@ void shouldCreateFullyCustom() {
9596

9697
@Test
9798
void shouldNeedNonNegativeInitialCapacity() {
98-
new ConcurrentReferenceHashMap<Integer, String>(0, 1);
99-
assertThatIllegalArgumentException().isThrownBy(() ->
100-
new TestWeakConcurrentCache<Integer, String>(-1, 1))
101-
.withMessageContaining("Initial capacity must not be negative");
99+
assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 1));
100+
assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(-1, 1))
101+
.withMessageContaining("Initial capacity must not be negative");
102102
}
103103

104104
@Test
105105
void shouldNeedPositiveLoadFactor() {
106-
new ConcurrentReferenceHashMap<Integer, String>(0, 0.1f, 1);
107-
assertThatIllegalArgumentException().isThrownBy(() ->
108-
new TestWeakConcurrentCache<Integer, String>(0, 0.0f, 1))
109-
.withMessageContaining("Load factor must be positive");
106+
assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 0.1f, 1));
107+
assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 0.0f, 1))
108+
.withMessageContaining("Load factor must be positive");
110109
}
111110

112111
@Test
113112
void shouldNeedPositiveConcurrencyLevel() {
114-
new ConcurrentReferenceHashMap<Integer, String>(1, 1);
115-
assertThatIllegalArgumentException().isThrownBy(() ->
116-
new TestWeakConcurrentCache<Integer, String>(1, 0))
117-
.withMessageContaining("Concurrency level must be positive");
113+
assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(1, 1));
114+
assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(1, 0))
115+
.withMessageContaining("Concurrency level must be positive");
118116
}
119117

120118
@Test

0 commit comments

Comments
 (0)