GeoIPLookupServiceTest.java from Tea Stats at Krugle
Show GeoIPLookupServiceTest.java syntax highlighted
/*
* This file is distributed under the GPL v2 as part of teastats site statistics package
* http://teastats.sourceforge.net
*/
package net.time4tea.webstats.geoip;
import com.maxmind.geoip.Country;
import com.maxmind.geoip.Location;
import com.maxmind.geoip.LookupService;
import junit.framework.TestCase;
/**
* Originally richja Mar 30, 2006
*/
public class GeoIPLookupServiceTest extends TestCase {
private LocationLookup countryLookup;
private LocationLookup cityLookup;
public void testWeCanFindTheCountryForAnIPAddress() throws Exception {
Country country = countryLookup.getCountry("158.152.1.58");
assertEquals("GB", country.getCode());
}
public void testWeCanFindTheCityForAnIPAddress() throws Exception {
Location location = cityLookup.getLocation("158.152.1.58");
assertEquals("London", location.city);
}
public void testWeCanFindTheCityForAnotherIPAddress() throws Exception {
Location location = cityLookup.getLocation("210.50.55.62");
assertEquals("Boondall", location.city);
}
protected void setUp() throws Exception {
super.setUp();
countryLookup = new GeoIPLocationLookupDelegate(new LookupService("src/resources/GeoIP.dat"));
cityLookup = new GeoIPLocationLookupDelegate(new LookupService("src/resources/GeoLiteCity.dat"));
}
}
See more files for this project here
Web log analyzer... Written in OO Perl, provides the usual host / page analysis. Can also do site graphing using graphviz, browser, os, worm and search engine identification, and country and session tracking.
Project homepage:
http://sourceforge.net/projects/teastats
Programming language(s): Java
License: other
GeoIPLookupServiceTest.java