Examples of CityResponse


Examples of com.maxmind.geoip2.model.CityResponse

        try {
            final InetAddress address = InetAddress.getByName(customerRemoteAddr);
           
            final DatabaseReader databaseReader = new DatabaseReader.Builder(getCityDataBase()).build();

            final CityResponse cityResponse = databaseReader.city(address);
            if(cityResponse != null){
                return cityResponse.getCity();
               
            }
        } catch (AddressNotFoundException e) {
            logger.warn("Geoloc city, can't find this address:" + customerRemoteAddr);
        } catch (FileNotFoundException e) {
View Full Code Here

Examples of com.maxmind.geoip2.model.CityResponse

    public void testNames() throws IOException, GeoIp2Exception {
        WebServiceClient client = new WebServiceClient.Builder(42,
                "abcdef123456").testTransport(this.transport)
                .locales(Arrays.asList("zh-CN", "ru")).build();

        CityResponse city = client.city(InetAddress.getByName("1.1.1.2"));
        assertEquals("country.getContinent().getName() does not return 北美洲",
                "北美洲", city.getContinent().getName());
        assertEquals("country.getCountry().getName() does not return 美国", "美国",
                city.getCountry().getName());
        assertEquals("toString() returns getName()", city.getCountry()
                .getName(), city.getCountry().getName());
    }
View Full Code Here

Examples of com.maxmind.geoip2.model.CityResponse

    public void russianFallback() throws IOException, GeoIp2Exception {
        WebServiceClient client = new WebServiceClient.Builder(42,
                "abcdef123456").testTransport(this.transport)
                .locales(Arrays.asList("as", "ru")).build();

        CityResponse city = client.city(InetAddress.getByName("1.1.1.2"));
        assertEquals(
                "country.getCountry().getName() does not return объединяет государства",
                "объединяет государства", city.getCountry().getName());

    }
View Full Code Here

Examples of com.maxmind.geoip2.model.CityResponse

    @Test
    public void testFallback() throws IOException, GeoIp2Exception {
        WebServiceClient client = new WebServiceClient.Builder(42,
                "abcdef123456").testTransport(this.transport)
                .locales(Arrays.asList("pt", "en", "zh-CN")).build();
        CityResponse city = client.city(InetAddress.getByName("1.1.1.2"));
        assertEquals("en is returned when pt is missing", city.getContinent()
                .getName(), "North America");

    }
View Full Code Here

Examples of com.maxmind.geoip2.model.CityResponse

    @Test
    public void noFallback() throws IOException, GeoIp2Exception {
        WebServiceClient client = new WebServiceClient.Builder(42,
                "abcdef123456").testTransport(this.transport)
                .locales(Arrays.asList("pt", "es", "af")).build();
        CityResponse city = client.city(InetAddress.getByName("1.1.1.2"));

        assertNull("null is returned when locale is not available", city
                .getContinent().getName());
    }
View Full Code Here

Examples of com.maxmind.geoip2.model.CityResponse

    @Test
    public void noLocale() throws IOException, GeoIp2Exception {
        WebServiceClient client = new WebServiceClient.Builder(42,
                "abcdef123456").testTransport(this.transport).build();
        CityResponse city = client.city(InetAddress.getByName("1.1.1.2"));
        assertEquals("en is returned when no locales are specified", city
                .getContinent().getName(), "North America");

    }
View Full Code Here

Examples of com.maxmind.geoip2.model.CityResponse

    public void testMissing() throws IOException, GeoIp2Exception {
        WebServiceClient client = new WebServiceClient.Builder(42,
                "abcdef123456").testTransport(this.transport)
                .locales(Arrays.asList("en")).build();

        CityResponse city = client.city(InetAddress.getByName("1.1.1.2"));
        assertNotNull(city.getCity());
        assertNull("null is returned when names object is missing", city
                .getCity().getName());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.