|
1 | 1 | package com.maxmind.db; |
2 | 2 |
|
3 | | -import static org.hamcrest.CoreMatchers.containsString; |
4 | | -import static org.junit.Assert.assertArrayEquals; |
5 | | -import static org.junit.Assert.assertEquals; |
6 | | -import static org.junit.Assert.assertNull; |
7 | | -import static org.junit.Assert.assertTrue; |
| 3 | +import com.fasterxml.jackson.databind.JsonNode; |
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 5 | +import com.fasterxml.jackson.databind.node.ArrayNode; |
| 6 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
| 7 | +import org.junit.After; |
| 8 | +import org.junit.Before; |
| 9 | +import org.junit.Rule; |
| 10 | +import org.junit.Test; |
| 11 | +import org.junit.rules.ExpectedException; |
8 | 12 |
|
9 | 13 | import java.io.File; |
10 | 14 | import java.io.IOException; |
11 | 15 | import java.io.InputStream; |
12 | 16 | import java.math.BigInteger; |
13 | 17 | import java.net.InetAddress; |
14 | | -import java.util.ArrayList; |
15 | | -import java.util.Arrays; |
16 | | -import java.util.Calendar; |
17 | | -import java.util.HashMap; |
18 | | -import java.util.List; |
19 | | -import java.util.Map; |
20 | | - |
21 | | -import org.junit.After; |
22 | | -import org.junit.Before; |
23 | | -import org.junit.Rule; |
24 | | -import org.junit.Test; |
25 | | -import org.junit.rules.ExpectedException; |
| 18 | +import java.util.*; |
26 | 19 |
|
27 | | -import com.fasterxml.jackson.databind.JsonNode; |
28 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
29 | | -import com.fasterxml.jackson.databind.node.ObjectNode; |
| 20 | +import static org.hamcrest.CoreMatchers.containsString; |
| 21 | +import static org.junit.Assert.*; |
30 | 22 |
|
31 | 23 | public class ReaderTest { |
32 | 24 | private final ObjectMapper om = new ObjectMapper(); |
@@ -243,6 +235,24 @@ private void testBrokenDataPointer(Reader reader) throws IOException { |
243 | 235 | reader.get(InetAddress.getByName("1.1.1.16")); |
244 | 236 | } |
245 | 237 |
|
| 238 | + @Test |
| 239 | + public void testObjectNodeMutation() throws IOException { |
| 240 | + Reader reader = new Reader(getFile("MaxMind-DB-test-decoder.mmdb")); |
| 241 | + ObjectNode record = (ObjectNode) reader.get(InetAddress.getByName("::1.1.1.0")); |
| 242 | + |
| 243 | + thrown.expect(UnsupportedOperationException.class); |
| 244 | + record.put("Test", "value"); |
| 245 | + } |
| 246 | + |
| 247 | + @Test |
| 248 | + public void testArrayNodeMutation() throws IOException { |
| 249 | + Reader reader = new Reader(getFile("MaxMind-DB-test-decoder.mmdb")); |
| 250 | + ObjectNode record = (ObjectNode) reader.get(InetAddress.getByName("::1.1.1.0")); |
| 251 | + |
| 252 | + thrown.expect(UnsupportedOperationException.class); |
| 253 | + ((ArrayNode) record.get("array")).add(1); |
| 254 | + } |
| 255 | + |
246 | 256 | @Test |
247 | 257 | public void testClosedReaderThrowsException() throws IOException { |
248 | 258 | Reader reader = new Reader(getFile("MaxMind-DB-test-decoder.mmdb")); |
|
0 commit comments