<commit_before>package com.maxmind.db;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

public class ReaderTest {
    private final ObjectMapper om = new ObjectMapper();

    @Test
    public void test() throws IOException, URISyntaxException {
        for (long recordSize : new long[] { 24, 28, 32 }) {
            for (int ipVersion : new int[] { 4, 6 }) {
                URI file = ReaderTest.class.getResource(
                        "/maxmind-db/test-data/MaxMind-DB-test-ipv" + ipVersion
                                + "-" + recordSize + ".mmdb").toURI();
                Reader reader = new Reader(new File(file));
                try {
                    this.testMetadata(reader, ipVersion, recordSize);
                } finally {
                    reader.close();
                }

                if (ipVersion == 4) {
                    this.testIpV4(reader, file);
                } else {
                    this.testIpV6(reader, file);
                }
            }
        }
    }

    @Test
    public void testNoIpV4SearchTreeFile() throws IOException,
            URISyntaxException {
        URI file = ReaderTest.class.getResource(
                "/maxmind-db/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb")
                .toURI();

        Reader reader = new Reader(new File(file));
        this.testNoIpV4SearchTree(reader);
    }

    @Test
    public void testNoIpV4SearchTreeURL() throws IOException,
            URISyntaxException {
        InputStream stream = ReaderTest.class.getResource(
                "/maxmind-db/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb")
                .openStream();
        Reader reader = new Reader(stream);
        this.testNoIpV4SearchTree(reader);
    }

    private void testNoIpV4SearchTree(Reader reader) throws IOException,
            URISyntaxException {

        assertEquals("::/64", reader.get(InetAddress.getByName("1.1.1.1"))
                .textValue());
        assertEquals("::/64", reader.get(InetAddress.getByName("172.16.17.32"))
                .textValue());
    }

    @Test
    public void testDecodingTypesFile() throws URISyntaxException, IOException {
        URI file = ReaderTest.class.getResource(
                "/maxmind-db/test-data/MaxMind-DB-test-decoder.mmdb").toURI();

        Reader reader = new Reader(new File(file));
        this.testDecodingTypes(reader);
    }<commit_msg>Update test for test database change<commit_after>package com.maxmind.db;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

public class ReaderTest {
    private final ObjectMapper om = new ObjectMapper();

    @Test
    public void test() throws IOException, URISyntaxException {
        for (long recordSize : new long[] { 24, 28, 32 }) {
            for (int ipVersion : new int[] { 4, 6 }) {
                URI file = ReaderTest.class.getResource(
                        "/maxmind-db/test-data/MaxMind-DB-test-ipv" + ipVersion
                                + "-" + recordSize + ".mmdb").toURI();
                Reader reader = new Reader(new File(file));
                try {
                    this.testMetadata(reader, ipVersion, recordSize);
                } finally {
                    reader.close();
                }

                if (ipVersion == 4) {
                    this.testIpV4(reader, file);
                } else {
                    this.testIpV6(reader, file);
                }
            }
        }
    }

    @Test
    public void testNoIpV4SearchTreeFile() throws IOException,
            URISyntaxException {
        URI file = ReaderTest.class.getResource(
                "/maxmind-db/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb")
                .toURI();

        Reader reader = new Reader(new File(file));
        this.testNoIpV4SearchTree(reader);
    }

    @Test
    public void testNoIpV4SearchTreeURL() throws IOException,
            URISyntaxException {
        InputStream stream = ReaderTest.class.getResource(
                "/maxmind-db/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb")
                .openStream();
        Reader reader = new Reader(stream);
        this.testNoIpV4SearchTree(reader);
    }

    private void testNoIpV4SearchTree(Reader reader) throws IOException,
            URISyntaxException {

        assertEquals("::0/64", reader.get(InetAddress.getByName("1.1.1.1"))
                .textValue());
        assertEquals("::0/64", reader.get(InetAddress.getByName("172.16.17.32"))
                .textValue());
    }

    @Test
    public void testDecodingTypesFile() throws URISyntaxException, IOException {
        URI file = ReaderTest.class.getResource(
                "/maxmind-db/test-data/MaxMind-DB-test-decoder.mmdb").toURI();

        Reader reader = new Reader(new File(file));
        this.testDecodingTypes(reader);
    }
{'fraction_non_alphanumeric': 0.10976202039825157, 'fraction_numerical': 0.011656143759106362, 'mean_word_length': 2.2244258872651357, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3511089', 'n_tokens_mistral': 1888, 'n_tokens_neox': 1724, 'n_words': 343}