diff --git b/iplocator-api/pom.xml a/iplocator-api/pom.xml new file mode 100644 index 0000000..c0b5ede --- /dev/null +++ a/iplocator-api/pom.xml @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>pl.labno.bernard.geobytes</groupId> + <artifactId>iplocator-api</artifactId> + <version>1.0</version> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>net.sourceforge.yarfraw</groupId> + <artifactId>yarfraw</artifactId> + <version>0.92</version> + </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>1.4</version> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging-api</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.1</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-impl</artifactId> + <version>2.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>generate-jaxb-artifacts</id> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxb2-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>xjc</goal> + </goals> + </execution> + </executions> + <configuration> + <packageName>pl.labno.bernard.geobytes.iplocator.rest.generated</packageName> + <outputDirectory>${build.sourceDirectory}</outputDirectory> + <clearOutputDir>false</clearOutputDir> + <extension>false</extension> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemProperties> + <property> + <name>testOutputDirectory</name> + <value>${build.testOutputDirectory}</value> + </property> + </systemProperties> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + <encoding>${project.build.sourceEncoding}</encoding> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.1.1</version> + <executions> + <execution> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.2</version> + <configuration> + <encoding>${project.build.sourceEncoding}</encoding> + </configuration> + </plugin> + + </plugins> + </build> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + <distributionManagement> + <repository> + <id>bernard.labno.pl</id> + <name>MyCo Internal Repository</name> + <url>http://bernard.labno.pl/artifactory/libs-release-local</url> + </repository> + </distributionManagement> + +</project><!--<?xml version="1.0" encoding="ISO-8859-1" ?>--><!--<info>--><!--<IP>87.207.25.131</IP>--><!--<countryid>197</countryid>--><!--<country>Poland</country>--><!--<fips>PL</fips>--><!--<iso2>PL</iso2>--><!--<iso3>POL</iso3>--><!--<ison>616</ison>--><!--<internet>PL</internet>--> + + <!--<comment></comment>--><!--<regionid>3275</regionid>--><!--<region>Kujawsko-Pomorskie</region>--><!--<code>KP</code>--><!--<adm>PL73</adm>--><!--<cityid>12699</cityid>--><!--<city>Bydgoszcz</city>--><!--<latitude>53.1500</latitude>--><!--<longitude>18.0000</longitude>--> + + <!--<timezone>+01:00</timezone>--><!--<dmaid></dmaid>--><!--<dma></dma>--><!--<market></market>--><!--<certainty>90</certainty>--><!--<locationcode>PLKPBYDG</locationcode>--><!--<ipaddress>87.207.25.131</ipaddress>--><!--</info>--> + + \ No newline at end of file diff --git b/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/Service.java a/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/Service.java new file mode 100644 index 0000000..8eccc03 --- /dev/null +++ a/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/Service.java @@ -0,0 +1,26 @@ +package pl.labno.bernard.geobytes.iplocator; + +import pl.labno.bernard.geobytes.iplocator.rest.InfoUnmarshaller; +import pl.labno.bernard.geobytes.iplocator.rest.generated.IpInfo; +import yarfraw.core.datamodel.YarfrawException; + +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.net.InetAddress; + +public class Service { + private String serviceURL = "http://www.geobytes.com/IpLocator.htm?GetLocation&template=xml.txt&IpAddress="; + + public String getServiceURL() { + return serviceURL; + } + + public void setServiceURL(String serviceURL) { + this.serviceURL = serviceURL; + } + + public IpInfo getInfo(InetAddress address) throws IOException, YarfrawException, JAXBException { + return InfoUnmarshaller.unmarshal(serviceURL + address.getHostAddress()); + } + +} diff --git b/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/InfoUnmarshaller.java a/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/InfoUnmarshaller.java new file mode 100644 index 0000000..bcf4599 --- /dev/null +++ a/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/InfoUnmarshaller.java @@ -0,0 +1,40 @@ +package pl.labno.bernard.geobytes.iplocator.rest; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import pl.labno.bernard.geobytes.iplocator.rest.generated.IpInfo; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.URL; + +public class InfoUnmarshaller { + + private static final Log LOG = LogFactory.getLog(InfoUnmarshaller.class); + + public static IpInfo unmarshal(String url) throws JAXBException, IOException { + return unmarshal(new URL(url).openStream()); + } + + public static IpInfo unmarshal(InputStream stream) throws JAXBException, IOException { + return unmarshal(new InputStreamReader(stream)); + } + + public static IpInfo unmarshal(Reader reader) throws JAXBException, IOException { + String content = IOUtils.toString(reader); + try { + JAXBContext jaxbContext = JAXBContext.newInstance(IpInfo.class.getPackage().getName()); + return (IpInfo) jaxbContext.createUnmarshaller().unmarshal(new StringReader(content)); + } catch (JAXBException e) { + LOG.error("Cannot unmarshal input stream.\n" + content, e); + throw e; + } + } + +} diff --git b/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/generated/IpInfo.java a/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/generated/IpInfo.java new file mode 100644 index 0000000..ea9dca8 --- /dev/null +++ a/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/generated/IpInfo.java @@ -0,0 +1,654 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.05.17 at 03:13:16 PM GMT +// + + +package pl.labno.bernard.geobytes.iplocator.rest.generated; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for info element declaration. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <element name="info"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="IP" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="countryid" type="{http://www.w3.org/2001/XMLSchema}short"/> + * <element name="country" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="fips" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="iso2" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="iso3" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="ison" type="{http://www.w3.org/2001/XMLSchema}short"/> + * <element name="internet" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="comment" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="regionid" type="{http://www.w3.org/2001/XMLSchema}short"/> + * <element name="region" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="code" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="adm" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="cityid" type="{http://www.w3.org/2001/XMLSchema}short"/> + * <element name="city" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="latitude" type="{http://www.w3.org/2001/XMLSchema}float"/> + * <element name="longitude" type="{http://www.w3.org/2001/XMLSchema}float"/> + * <element name="timezone" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="dmaid" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="dma" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="market" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="certainty" type="{http://www.w3.org/2001/XMLSchema}byte"/> + * <element name="locationcode" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="ipaddress" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "ip", + "countryid", + "country", + "fips", + "iso2", + "iso3", + "ison", + "internet", + "comment", + "regionid", + "region", + "code", + "adm", + "cityid", + "city", + "latitude", + "longitude", + "timezone", + "dmaid", + "dma", + "market", + "certainty", + "locationcode", + "ipaddress" +}) +@XmlRootElement(name = "info") +public class IpInfo { + + @XmlElement(name = "IP", required = true) + protected String ip; + protected short countryid; + @XmlElement(required = true) + protected String country; + @XmlElement(required = true) + protected String fips; + @XmlElement(required = true) + protected String iso2; + @XmlElement(required = true) + protected String iso3; + protected short ison; + @XmlElement(required = true) + protected String internet; + @XmlElement(required = true) + protected String comment; + protected short regionid; + @XmlElement(required = true) + protected String region; + @XmlElement(required = true) + protected String code; + @XmlElement(required = true) + protected String adm; + protected short cityid; + @XmlElement(required = true) + protected String city; + protected float latitude; + protected float longitude; + @XmlElement(required = true) + protected String timezone; + @XmlElement(required = true) + protected String dmaid; + @XmlElement(required = true) + protected String dma; + @XmlElement(required = true) + protected String market; + protected byte certainty; + @XmlElement(required = true) + protected String locationcode; + @XmlElement(required = true) + protected String ipaddress; + + /** + * Gets the value of the ip property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIP() { + return ip; + } + + /** + * Sets the value of the ip property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIP(String value) { + this.ip = value; + } + + /** + * Gets the value of the countryid property. + * + */ + public short getCountryid() { + return countryid; + } + + /** + * Sets the value of the countryid property. + * + */ + public void setCountryid(short value) { + this.countryid = value; + } + + /** + * Gets the value of the country property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountry() { + return country; + } + + /** + * Sets the value of the country property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountry(String value) { + this.country = value; + } + + /** + * Gets the value of the fips property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFips() { + return fips; + } + + /** + * Sets the value of the fips property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFips(String value) { + this.fips = value; + } + + /** + * Gets the value of the iso2 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIso2() { + return iso2; + } + + /** + * Sets the value of the iso2 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIso2(String value) { + this.iso2 = value; + } + + /** + * Gets the value of the iso3 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIso3() { + return iso3; + } + + /** + * Sets the value of the iso3 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIso3(String value) { + this.iso3 = value; + } + + /** + * Gets the value of the ison property. + * + */ + public short getIson() { + return ison; + } + + /** + * Sets the value of the ison property. + * + */ + public void setIson(short value) { + this.ison = value; + } + + /** + * Gets the value of the internet property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getInternet() { + return internet; + } + + /** + * Sets the value of the internet property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setInternet(String value) { + this.internet = value; + } + + /** + * Gets the value of the comment property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getComment() { + return comment; + } + + /** + * Sets the value of the comment property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setComment(String value) { + this.comment = value; + } + + /** + * Gets the value of the regionid property. + * + */ + public short getRegionid() { + return regionid; + } + + /** + * Sets the value of the regionid property. + * + */ + public void setRegionid(short value) { + this.regionid = value; + } + + /** + * Gets the value of the region property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRegion() { + return region; + } + + /** + * Sets the value of the region property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRegion(String value) { + this.region = value; + } + + /** + * Gets the value of the code property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCode() { + return code; + } + + /** + * Sets the value of the code property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCode(String value) { + this.code = value; + } + + /** + * Gets the value of the adm property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAdm() { + return adm; + } + + /** + * Sets the value of the adm property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAdm(String value) { + this.adm = value; + } + + /** + * Gets the value of the cityid property. + * + */ + public short getCityid() { + return cityid; + } + + /** + * Sets the value of the cityid property. + * + */ + public void setCityid(short value) { + this.cityid = value; + } + + /** + * Gets the value of the city property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCity() { + return city; + } + + /** + * Sets the value of the city property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCity(String value) { + this.city = value; + } + + /** + * Gets the value of the latitude property. + * + */ + public float getLatitude() { + return latitude; + } + + /** + * Sets the value of the latitude property. + * + */ + public void setLatitude(float value) { + this.latitude = value; + } + + /** + * Gets the value of the longitude property. + * + */ + public float getLongitude() { + return longitude; + } + + /** + * Sets the value of the longitude property. + * + */ + public void setLongitude(float value) { + this.longitude = value; + } + + /** + * Gets the value of the timezone property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTimezone() { + return timezone; + } + + /** + * Sets the value of the timezone property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTimezone(String value) { + this.timezone = value; + } + + /** + * Gets the value of the dmaid property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDmaid() { + return dmaid; + } + + /** + * Sets the value of the dmaid property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDmaid(String value) { + this.dmaid = value; + } + + /** + * Gets the value of the dma property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDma() { + return dma; + } + + /** + * Sets the value of the dma property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDma(String value) { + this.dma = value; + } + + /** + * Gets the value of the market property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMarket() { + return market; + } + + /** + * Sets the value of the market property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMarket(String value) { + this.market = value; + } + + /** + * Gets the value of the certainty property. + * + */ + public byte getCertainty() { + return certainty; + } + + /** + * Sets the value of the certainty property. + * + */ + public void setCertainty(byte value) { + this.certainty = value; + } + + /** + * Gets the value of the locationcode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLocationcode() { + return locationcode; + } + + /** + * Sets the value of the locationcode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLocationcode(String value) { + this.locationcode = value; + } + + /** + * Gets the value of the ipaddress property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIpaddress() { + return ipaddress; + } + + /** + * Sets the value of the ipaddress property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIpaddress(String value) { + this.ipaddress = value; + } + +} diff --git b/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/generated/ObjectFactory.java a/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/generated/ObjectFactory.java new file mode 100644 index 0000000..0d1c657 --- /dev/null +++ a/iplocator-api/src/main/java/pl/labno/bernard/geobytes/iplocator/rest/generated/ObjectFactory.java @@ -0,0 +1,47 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.05.17 at 03:13:16 PM GMT +// + + +package pl.labno.bernard.geobytes.iplocator.rest.generated; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the pl.labno.bernard.geobytes.iplocator.rest.generated package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pl.labno.bernard.geobytes.iplocator.rest.generated + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link IpInfo } + * + */ + public IpInfo createIpInfo() { + return new IpInfo(); + } + +} diff --git b/iplocator-api/src/main/xjb/bindings.xjb a/iplocator-api/src/main/xjb/bindings.xjb new file mode 100644 index 0000000..5daf00d --- /dev/null +++ a/iplocator-api/src/main/xjb/bindings.xjb @@ -0,0 +1,13 @@ +<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <jxb:bindings schemaLocation="../xsd/response.xsd" node="/xs:schema"> + + <jxb:globalBindings localScoping="toplevel"/> + + <jxb:bindings node="//xs:element[@name='info']"> + + <jxb:class name="IpInfo"/> + + </jxb:bindings> + + </jxb:bindings> +</jxb:bindings> \ No newline at end of file diff --git b/iplocator-api/src/main/xsd/response.xml a/iplocator-api/src/main/xsd/response.xml new file mode 100644 index 0000000..41f55a4 --- /dev/null +++ a/iplocator-api/src/main/xsd/response.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?><!--This is sample response to generate response.xsd from--> +<info> + <IP>87.207.25.131</IP> + <countryid>197</countryid> + <country>Poland</country> + <fips>PL</fips> + <iso2>PL</iso2> + <iso3>POL</iso3> + <ison>616</ison> + <internet>PL</internet> + + <comment></comment> + <regionid>3275</regionid> + <region>Kujawsko-Pomorskie</region> + <code>KP</code> + <adm>PL73</adm> + <cityid>12699</cityid> + <city>Bydgoszcz</city> + <latitude>53.1500</latitude> + <longitude>18.0000</longitude> + + <timezone>+01:00</timezone> + <dmaid></dmaid> + <dma></dma> + <market></market> + <certainty>90</certainty> + <locationcode>PLKPBYDG</locationcode> + <ipaddress>87.207.25.131</ipaddress> +</info> + diff --git b/iplocator-api/src/main/xsd/response.xsd a/iplocator-api/src/main/xsd/response.xsd new file mode 100644 index 0000000..f4bc5c3 --- /dev/null +++ a/iplocator-api/src/main/xsd/response.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="info"> + <xs:complexType> + <xs:sequence> + <xs:element type="xs:string" name="IP"/> + <xs:element type="xs:short" name="countryid"/> + <xs:element type="xs:string" name="country"/> + <xs:element type="xs:string" name="fips"/> + <xs:element type="xs:string" name="iso2"/> + <xs:element type="xs:string" name="iso3"/> + <xs:element type="xs:short" name="ison"/> + <xs:element type="xs:string" name="internet"/> + <xs:element type="xs:string" name="comment"/> + <xs:element type="xs:short" name="regionid"/> + <xs:element type="xs:string" name="region"/> + <xs:element type="xs:string" name="code"/> + <xs:element type="xs:string" name="adm"/> + <xs:element type="xs:short" name="cityid"/> + <xs:element type="xs:string" name="city"/> + <xs:element type="xs:float" name="latitude"/> + <xs:element type="xs:float" name="longitude"/> + <xs:element type="xs:string" name="timezone"/> + <xs:element type="xs:string" name="dmaid"/> + <xs:element type="xs:string" name="dma"/> + <xs:element type="xs:string" name="market"/> + <xs:element type="xs:byte" name="certainty"/> + <xs:element type="xs:string" name="locationcode"/> + <xs:element type="xs:string" name="ipaddress"/> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> \ No newline at end of file diff --git b/iplocator-api/src/test/java/pl/labno/bernard/geobytes/iplocator/ServiceTest.java a/iplocator-api/src/test/java/pl/labno/bernard/geobytes/iplocator/ServiceTest.java new file mode 100644 index 0000000..8e194ad --- /dev/null +++ a/iplocator-api/src/test/java/pl/labno/bernard/geobytes/iplocator/ServiceTest.java @@ -0,0 +1,24 @@ +package pl.labno.bernard.geobytes.iplocator; + +import org.junit.Assert; +import org.junit.Test; +import pl.labno.bernard.geobytes.iplocator.rest.generated.IpInfo; +import yarfraw.core.datamodel.YarfrawException; + +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.net.Inet4Address; + +public class ServiceTest { + + @Test + public void testGetRecentExchangeTable() throws YarfrawException, IOException, JAXBException { + final Service service = new Service(); + IpInfo info = service.getInfo(Inet4Address.getByAddress(new byte[]{87, (byte) 207, 25, (byte) 131})); + Assert.assertNotNull(info); + Assert.assertEquals(197, info.getCountryid()); + info = service.getInfo(Inet4Address.getByAddress(new byte[]{(byte) 165, 69, 10, 27})); + Assert.assertNotNull(info); + Assert.assertEquals(14, info.getCountryid()); + } +}