|
16 | 16 | */
|
17 | 17 | package org.apache.logging.log4j.core.impl;
|
18 | 18 |
|
| 19 | +import static org.assertj.core.api.Assertions.assertThat; |
19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
20 | 21 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
21 | 22 | import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
|
24 | 25 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
25 | 26 | import static org.junit.jupiter.api.Assertions.fail;
|
26 | 27 |
|
| 28 | +import java.util.Collections; |
27 | 29 | import java.util.HashMap;
|
28 | 30 | import java.util.Map;
|
| 31 | +import java.util.stream.Stream; |
29 | 32 | import org.apache.logging.log4j.util.BiConsumer;
|
30 | 33 | import org.apache.logging.log4j.util.TriConsumer;
|
31 | 34 | import org.junit.jupiter.api.Test;
|
| 35 | +import org.junit.jupiter.params.ParameterizedTest; |
| 36 | +import org.junit.jupiter.params.provider.Arguments; |
| 37 | +import org.junit.jupiter.params.provider.MethodSource; |
32 | 38 |
|
33 | 39 | /**
|
34 | 40 | * Tests the JdkMapAdapterStringMap class.
|
@@ -812,4 +818,18 @@ public void testForEachTriConsumer() throws Exception {
|
812 | 818 | original.forEach(COUNTER, state);
|
813 | 819 | assertEquals(state.count, original.size());
|
814 | 820 | }
|
| 821 | + |
| 822 | + static Stream<Arguments> testImmutability() { |
| 823 | + return Stream.of( |
| 824 | + Arguments.of(new HashMap<>(), false), |
| 825 | + Arguments.of(Map.of(), true), |
| 826 | + Arguments.of(Collections.emptyMap(), true), |
| 827 | + Arguments.of(Collections.unmodifiableMap(new HashMap<>()), true)); |
| 828 | + } |
| 829 | + |
| 830 | + @ParameterizedTest |
| 831 | + @MethodSource |
| 832 | + void testImmutability(final Map<String, String> map, final boolean frozen) { |
| 833 | + assertThat(new JdkMapAdapterStringMap(map).isFrozen()).as("Frozen").isEqualTo(frozen); |
| 834 | + } |
815 | 835 | }
|
0 commit comments