org.hd.d.pg2k.test.dev
Class LocationTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.hd.d.pg2k.test.dev.LocationTest
All Implemented Interfaces:
junit.framework.Test

public final class LocationTest
extends junit.framework.TestCase

Test of various aspects of Location and GeoUtils, etc. This includes geographical lookup by client IP address, though maybe these should be moved to a separate GeoUtilsTests class.

TODO: test that exhibits correctly get specific/generic flag depending on details being with exhibit or looked up in generic map


Field Summary
private static java.util.Random rnd
          Private source of OK pseudo-random numbers.
 
Constructor Summary
LocationTest(java.lang.String name)
           
 
Method Summary
static void testAddrPrefix()
          Test AddrPrefix class briefly.
static void testAddrPrefixHashCode()
          Check AddrPrefix.hashCode() effectiveness, as this may be important for performance.
static void testAddrPrefixParsing()
          Test some simple cases for AddrPrefix dotted-quad parsing.
static void testDNSLookup()
          Check DNS lookup.
static void testGeoProximity()
          Test that we can use the geographical-proximity-by-ccTLD data.
static void testLocationEstdContains()
          Tests use of contains() and related operations on Location.Estd.
 void testLocationLookup()
          Test that we can look up exhibits by name in the sample auxInfo file.
static void testLocationMapBasics()
          Basic tests of LocationMap behaviour.
static void testRegionLookup()
          Check lookup of geographic location of IP address.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rnd

private static final java.util.Random rnd
Private source of OK pseudo-random numbers.

Constructor Detail

LocationTest

public LocationTest(java.lang.String name)
Method Detail

testLocationMapBasics

public static void testLocationMapBasics()
Basic tests of LocationMap behaviour. These tests are not dependent on external data.


testLocationEstdContains

public static void testLocationEstdContains()
                                     throws java.lang.Exception
Tests use of contains() and related operations on Location.Estd. We use some randomness to stochastically test the entire space of parameters that should be unimportant (ie the "specific" flag).

Throws:
java.lang.Exception

testLocationLookup

public void testLocationLookup()
                        throws java.lang.Exception
Test that we can look up exhibits by name in the sample auxInfo file. FIXME: Also needs stand-alone tests that do not depend on the vast config file.

We skip these tests if we do not have full/normal access to the filesystem.

Throws:
java.lang.Exception

testGeoProximity

public static void testGeoProximity()
Test that we can use the geographical-proximity-by-ccTLD data. This tests that we can find close-by countries (in connectivity terms).


testRegionLookup

public static void testRegionLookup()
                             throws java.lang.Exception
Check lookup of geographic location of IP address. This checks that basic lookup of location by IP address (ie in which country is the machine/interface with that address) works for some simple basic cases.

TODO: whitebox check that mappings in source data are actually visible.

Throws:
java.lang.Exception

testDNSLookup

public static void testDNSLookup()
Check DNS lookup. If DNS lookup is working at all, check that forward and reverse lookup is working as expected.


testAddrPrefix

public static void testAddrPrefix()
Test AddrPrefix class briefly.


testAddrPrefixParsing

public static void testAddrPrefixParsing()
Test some simple cases for AddrPrefix dotted-quad parsing.


testAddrPrefixHashCode

public static void testAddrPrefixHashCode()
Check AddrPrefix.hashCode() effectiveness, as this may be important for performance. We test this against any real data we have to hand plus a few choice manually-selected values.

The aim is to ensure that there are not excessive collisions for real data values, as that would make HashSet and related containers behave badly.


DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.