|
16 | 16 | */
|
17 | 17 | package org.apache.logging.log4j.core.impl;
|
18 | 18 |
|
19 |
| -import static org.junit.jupiter.api.Assertions.*; |
| 19 | +import static org.assertj.core.api.Assertions.assertThat; |
| 20 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 21 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 22 | +import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 25 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 26 | +import static org.junit.jupiter.api.Assertions.fail; |
20 | 27 |
|
21 | 28 | import java.io.ByteArrayInputStream;
|
22 | 29 | import java.io.ByteArrayOutputStream;
|
23 | 30 | import java.io.IOException;
|
24 | 31 | import java.io.ObjectInputStream;
|
25 | 32 | import java.io.ObjectOutputStream;
|
| 33 | +import java.util.Collections; |
26 | 34 | import java.util.HashMap;
|
27 | 35 | import java.util.Map;
|
| 36 | +import java.util.stream.Stream; |
28 | 37 | import org.apache.logging.log4j.util.BiConsumer;
|
29 | 38 | import org.apache.logging.log4j.util.TriConsumer;
|
30 | 39 | import org.junit.jupiter.api.Test;
|
| 40 | +import org.junit.jupiter.params.ParameterizedTest; |
| 41 | +import org.junit.jupiter.params.provider.Arguments; |
| 42 | +import org.junit.jupiter.params.provider.MethodSource; |
31 | 43 |
|
32 | 44 | /**
|
33 | 45 | * Tests the JdkMapAdapterStringMap class.
|
@@ -837,4 +849,17 @@ public void testForEachTriConsumer() throws Exception {
|
837 | 849 | original.forEach(COUNTER, state);
|
838 | 850 | assertEquals(state.count, original.size());
|
839 | 851 | }
|
| 852 | + |
| 853 | + static Stream<Arguments> testImmutability() { |
| 854 | + return Stream.of( |
| 855 | + Arguments.of(new HashMap<>(), false), |
| 856 | + Arguments.of(Collections.emptyMap(), true), |
| 857 | + Arguments.of(Collections.unmodifiableMap(new HashMap<>()), true)); |
| 858 | + } |
| 859 | + |
| 860 | + @ParameterizedTest |
| 861 | + @MethodSource |
| 862 | + void testImmutability(final Map<String, String> map, final boolean frozen) { |
| 863 | + assertThat(new JdkMapAdapterStringMap(map).isFrozen()).as("Frozen").isEqualTo(frozen); |
| 864 | + } |
840 | 865 | }
|
0 commit comments