diff --git a/src/test/java/com/maxmind/geoip2/DatabaseReaderTest.java b/src/test/java/com/maxmind/geoip2/DatabaseReaderTest.java index dada9a1c..97e1bb76 100644 --- a/src/test/java/com/maxmind/geoip2/DatabaseReaderTest.java +++ b/src/test/java/com/maxmind/geoip2/DatabaseReaderTest.java @@ -10,12 +10,14 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Files; import java.util.Arrays; import static org.hamcrest.CoreMatchers.containsString; @@ -104,6 +106,18 @@ private void testMemoryMode(DatabaseReader reader) throws IOException, reader.close(); } + @Test + public void testStreamFile() throws Exception { + byte[] bytes = Files.readAllBytes( + this.getFile("GeoIP2-Anonymous-IP-Test.mmdb").toPath()); + InputStream stream = new ByteArrayInputStream(bytes); + DatabaseReader reader = new DatabaseReader.Builder(stream).build(); + InetAddress ipAddress = InetAddress.getByName("1.2.0.1"); + AnonymousIpResponse response = reader.anonymousIp(ipAddress); + assertTrue(response.isAnonymous()); + reader.close(); + } + @Test public void metadata() throws IOException { DatabaseReader reader = new DatabaseReader.Builder(this.geoipFile)