commit 91c2cba598d0a359b9a97ac784330403a396219d Author: Karsten Loesing karsten.loesing@gmx.net Date: Wed Nov 27 19:12:24 2013 +0100
Simplify tests by getting rid of test helpers. --- src/org/torproject/onionoo/ResponseBuilder.java | 4 - test/org/torproject/onionoo/LookupServiceTest.java | 392 ++++++----- .../torproject/onionoo/ResourceServletTest.java | 702 ++++++++++---------- 3 files changed, 533 insertions(+), 565 deletions(-)
diff --git a/src/org/torproject/onionoo/ResponseBuilder.java b/src/org/torproject/onionoo/ResponseBuilder.java index 5cc1e04..b79623e 100644 --- a/src/org/torproject/onionoo/ResponseBuilder.java +++ b/src/org/torproject/onionoo/ResponseBuilder.java @@ -337,8 +337,6 @@ public class ResponseBuilder { relayFingerprintSummaryLines); Map<String, String> filteredBridges = new HashMap<String, String>( bridgeFingerprintSummaryLines); - System.out.println(filteredRelays.size() + " relays left, " - + filteredBridges.size() + " bridges left."); filterByType(filteredRelays, filteredBridges); filterByRunning(filteredRelays, filteredBridges); filterBySearchTerms(filteredRelays, filteredBridges); @@ -349,8 +347,6 @@ public class ResponseBuilder { filterNodesByFirstSeenDays(filteredRelays, filteredBridges); filterNodesByLastSeenDays(filteredRelays, filteredBridges); filterByContact(filteredRelays, filteredBridges); - System.out.println(filteredRelays.size() + " relays left, " - + filteredBridges.size() + " bridges left.");
/* Re-order and limit results. */ List<String> orderedRelays = new ArrayList<String>(); diff --git a/test/org/torproject/onionoo/LookupServiceTest.java b/test/org/torproject/onionoo/LookupServiceTest.java index 42df61f..4834092 100644 --- a/test/org/torproject/onionoo/LookupServiceTest.java +++ b/test/org/torproject/onionoo/LookupServiceTest.java @@ -26,195 +26,181 @@ import org.torproject.onionoo.LookupService.LookupResult;
public class LookupServiceTest {
- private static class LookupServiceTestHelper { + private List<String> manualGeoLiteCityBlocksLines, + automaticGeoLiteCityBlocksLines, geoLiteCityBlocksLines, + geoLiteCityLocationLines, iso3166Lines, regionLines, + geoipASNum2Lines;
- private File tempGeoipDir; + private LookupService lookupService;
- private List<String> manualGeoLiteCityBlocksLines, - automaticGeoLiteCityBlocksLines, geoLiteCityBlocksLines, - geoLiteCityLocationLines, iso3166Lines, regionLines, - geoipASNum2Lines; + private SortedSet<String> addressStrings = new TreeSet<String>();
- private LookupService lookupService; + private SortedMap<String, LookupResult> lookupResults;
- private SortedSet<String> addressStrings; - - private SortedMap<String, LookupResult> lookupResults; - - private LookupServiceTestHelper(File tempGeoipDir, - SortedSet<String> addressStrings) { - this.tempGeoipDir = tempGeoipDir; - this.addressStrings = addressStrings; - } + private void populateLines() { + this.manualGeoLiteCityBlocksLines = new ArrayList<String>(); + this.manualGeoLiteCityBlocksLines.add( + "Copyright (c) 2011 MaxMind Inc. All Rights Reserved."); + this.manualGeoLiteCityBlocksLines.add("startIpNum,endIpNum,locId"); + this.manualGeoLiteCityBlocksLines.add(""134739200","134744063"," + + ""223""); + this.manualGeoLiteCityBlocksLines.add(""134744064","134744319"," + + ""32191""); + this.manualGeoLiteCityBlocksLines.add(""134744320","134751743"," + + ""223""); + this.geoLiteCityLocationLines = new ArrayList<String>(); + this.geoLiteCityLocationLines.add("Copyright (c) 2012 MaxMind " + + "LLC. All Rights Reserved."); + this.geoLiteCityLocationLines.add("locId,country,region,city," + + "postalCode,latitude,longitude,metroCode,areaCode"); + this.geoLiteCityLocationLines.add("223,"US","","",""," + + "38.0000,-97.0000,,"); + this.geoLiteCityLocationLines.add("32191,"US","CA"," + + ""Mountain View","",37.3860,-122.0838,807,650"); + this.iso3166Lines = new ArrayList<String>(); + this.iso3166Lines.add("US,"United States""); + this.regionLines = new ArrayList<String>(); + this.regionLines.add("US,CA,"California""); + this.geoipASNum2Lines = new ArrayList<String>(); + this.geoipASNum2Lines.add("134743296,134744063,"AS3356 Level 3 " + + "Communications""); + this.geoipASNum2Lines.add("134744064,134744319,"AS15169 Google " + + "Inc.""); + this.geoipASNum2Lines.add("134744320,134750463,"AS3356 Level 3 " + + "Communications""); + }
- private void populateLines() { - this.manualGeoLiteCityBlocksLines = new ArrayList<String>(); - this.manualGeoLiteCityBlocksLines.add( - "Copyright (c) 2011 MaxMind Inc. All Rights Reserved."); - this.manualGeoLiteCityBlocksLines.add("startIpNum,endIpNum,locId"); - this.manualGeoLiteCityBlocksLines.add(""134739200","134744063"," - + ""223""); - this.manualGeoLiteCityBlocksLines.add(""134744064","134744319"," - + ""32191""); - this.manualGeoLiteCityBlocksLines.add(""134744320","134751743"," - + ""223""); - this.geoLiteCityLocationLines = new ArrayList<String>(); - this.geoLiteCityLocationLines.add("Copyright (c) 2012 MaxMind " - + "LLC. All Rights Reserved."); - this.geoLiteCityLocationLines.add("locId,country,region,city," - + "postalCode,latitude,longitude,metroCode,areaCode"); - this.geoLiteCityLocationLines.add("223,"US","","",""," - + "38.0000,-97.0000,,"); - this.geoLiteCityLocationLines.add("32191,"US","CA"," - + ""Mountain View","",37.3860,-122.0838,807,650"); - this.iso3166Lines = new ArrayList<String>(); - this.iso3166Lines.add("US,"United States""); - this.regionLines = new ArrayList<String>(); - this.regionLines.add("US,CA,"California""); - this.geoipASNum2Lines = new ArrayList<String>(); - this.geoipASNum2Lines.add("134743296,134744063,"AS3356 Level 3 " - + "Communications""); - this.geoipASNum2Lines.add("134744064,134744319,"AS15169 Google " - + "Inc.""); - this.geoipASNum2Lines.add("134744320,134750463,"AS3356 Level 3 " - + "Communications""); + private void writeCsvFiles() { + try { + this.writeCsvFile(this.manualGeoLiteCityBlocksLines, + "Manual-GeoLiteCity-Blocks.csv"); + this.writeCsvFile(this.automaticGeoLiteCityBlocksLines, + "Automatic-GeoLiteCity-Blocks.csv"); + this.writeCsvFile(this.geoLiteCityBlocksLines, + "GeoLiteCity-Blocks.csv"); + this.writeCsvFile(this.geoLiteCityLocationLines, + "GeoLiteCity-Location.csv"); + this.writeCsvFile(this.iso3166Lines, "iso3166.csv"); + this.writeCsvFile(this.regionLines, "region.csv"); + this.writeCsvFile(this.geoipASNum2Lines, "GeoIPASNum2.csv"); + } catch (IOException e) { + throw new RuntimeException(e); } + }
- private void writeCsvFiles() { - try { - this.writeCsvFile(this.manualGeoLiteCityBlocksLines, - "Manual-GeoLiteCity-Blocks.csv"); - this.writeCsvFile(this.automaticGeoLiteCityBlocksLines, - "Automatic-GeoLiteCity-Blocks.csv"); - this.writeCsvFile(this.geoLiteCityBlocksLines, - "GeoLiteCity-Blocks.csv"); - this.writeCsvFile(this.geoLiteCityLocationLines, - "GeoLiteCity-Location.csv"); - this.writeCsvFile(this.iso3166Lines, "iso3166.csv"); - this.writeCsvFile(this.regionLines, "region.csv"); - this.writeCsvFile(this.geoipASNum2Lines, "GeoIPASNum2.csv"); - } catch (IOException e) { - throw new RuntimeException(e); + private void writeCsvFile(List<String> lines, String fileName) + throws IOException { + if (lines != null && !lines.isEmpty()) { + BufferedWriter bw = new BufferedWriter(new FileWriter( + new File(this.tempGeoipDir, fileName))); + for (String line : lines) { + bw.write(line + "\n"); } + bw.close(); } + }
- private void writeCsvFile(List<String> lines, String fileName) - throws IOException { - if (lines != null && !lines.isEmpty()) { - BufferedWriter bw = new BufferedWriter(new FileWriter( - new File(this.tempGeoipDir, fileName))); - for (String line : lines) { - bw.write(line + "\n"); - } - bw.close(); - } - } + private void performLookups() { + this.lookupService = new LookupService(this.tempGeoipDir); + this.lookupResults = this.lookupService.lookup(this.addressStrings); + }
- private void performLookups() { - this.lookupService = new LookupService(this.tempGeoipDir); - this.lookupResults = this.lookupService.lookup(this.addressStrings); + private void assertLookupResult( + List<String> manualGeoLiteCityBlocksLines, + List<String> automaticGeoLiteCityBlocksLines, + List<String> geoLiteCityBlocksLines, + List<String> geoLiteCityLocationLines, List<String> iso3166Lines, + List<String> regionLines, List<String> geoipASNum2Lines, + String addressString, String countryCode, String countryName, + String regionName, String cityName, String latitude, + String longitude, String aSNumber, String aSName) { + this.addressStrings.add(addressString); + this.populateLines(); + if (manualGeoLiteCityBlocksLines != null) { + this.manualGeoLiteCityBlocksLines = + manualGeoLiteCityBlocksLines; } - - private static void assertLookupResult(File tempGeoipDir, - List<String> manualGeoLiteCityBlocksLines, - List<String> automaticGeoLiteCityBlocksLines, - List<String> geoLiteCityBlocksLines, - List<String> geoLiteCityLocationLines, List<String> iso3166Lines, - List<String> regionLines, List<String> geoipASNum2Lines, - String addressString, String countryCode, String countryName, - String regionName, String cityName, String latitude, - String longitude, String aSNumber, String aSName) { - SortedSet<String> addressStrings = new TreeSet<String>(); - addressStrings.add(addressString); - LookupServiceTestHelper helper = new LookupServiceTestHelper( - tempGeoipDir, addressStrings); - helper.populateLines(); - if (manualGeoLiteCityBlocksLines != null) { - helper.manualGeoLiteCityBlocksLines = - manualGeoLiteCityBlocksLines; - } - if (automaticGeoLiteCityBlocksLines != null) { - helper.automaticGeoLiteCityBlocksLines = - automaticGeoLiteCityBlocksLines; - } - if (geoLiteCityBlocksLines != null) { - helper.geoLiteCityBlocksLines = geoLiteCityBlocksLines; - } - if (geoLiteCityLocationLines != null) { - helper.geoLiteCityLocationLines = geoLiteCityLocationLines; - } - if (iso3166Lines != null) { - helper.iso3166Lines = iso3166Lines; - } - if (regionLines != null) { - helper.regionLines = regionLines; - } - if (geoipASNum2Lines != null) { - helper.geoipASNum2Lines = geoipASNum2Lines; - } - helper.writeCsvFiles(); - /* Disable log messages printed to System.err. */ - System.setErr(new PrintStream(new OutputStream() { - public void write(int b) { - } - })); - helper.performLookups(); - if (countryCode == null) { - assertTrue(!helper.lookupResults.containsKey(addressString) || - helper.lookupResults.get(addressString).countryCode == null); - } else { - assertEquals(countryCode, - helper.lookupResults.get(addressString).countryCode); - } - if (countryName == null) { - assertTrue(!helper.lookupResults.containsKey(addressString) || - helper.lookupResults.get(addressString).countryName == null); - } else { - assertEquals(countryName, - helper.lookupResults.get(addressString).countryName); - } - if (regionName == null) { - assertTrue(!helper.lookupResults.containsKey(addressString) || - helper.lookupResults.get(addressString).regionName == null); - } else { - assertEquals(regionName, - helper.lookupResults.get(addressString).regionName); - } - if (cityName == null) { - assertTrue(!helper.lookupResults.containsKey(addressString) || - helper.lookupResults.get(addressString).cityName == null); - } else { - assertEquals(cityName, - helper.lookupResults.get(addressString).cityName); - } - if (latitude == null) { - assertTrue(!helper.lookupResults.containsKey(addressString) || - helper.lookupResults.get(addressString).latitude == null); - } else { - assertEquals(latitude, - helper.lookupResults.get(addressString).latitude); - } - if (longitude == null) { - assertTrue(!helper.lookupResults.containsKey(addressString) || - helper.lookupResults.get(addressString).longitude == null); - } else { - assertEquals(longitude, - helper.lookupResults.get(addressString).longitude); - } - if (aSNumber == null) { - assertTrue(!helper.lookupResults.containsKey(addressString) || - helper.lookupResults.get(addressString).aSNumber == null); - } else { - assertEquals(aSNumber, - helper.lookupResults.get(addressString).aSNumber); - } - if (aSName == null) { - assertTrue(!helper.lookupResults.containsKey(addressString) || - helper.lookupResults.get(addressString).aSName == null); - } else { - assertEquals(aSName, - helper.lookupResults.get(addressString).aSName); + if (automaticGeoLiteCityBlocksLines != null) { + this.automaticGeoLiteCityBlocksLines = + automaticGeoLiteCityBlocksLines; + } + if (geoLiteCityBlocksLines != null) { + this.geoLiteCityBlocksLines = geoLiteCityBlocksLines; + } + if (geoLiteCityLocationLines != null) { + this.geoLiteCityLocationLines = geoLiteCityLocationLines; + } + if (iso3166Lines != null) { + this.iso3166Lines = iso3166Lines; + } + if (regionLines != null) { + this.regionLines = regionLines; + } + if (geoipASNum2Lines != null) { + this.geoipASNum2Lines = geoipASNum2Lines; + } + this.writeCsvFiles(); + /* Disable log messages printed to System.err. */ + System.setErr(new PrintStream(new OutputStream() { + public void write(int b) { } + })); + this.performLookups(); + if (countryCode == null) { + assertTrue(!this.lookupResults.containsKey(addressString) || + this.lookupResults.get(addressString).countryCode == null); + } else { + assertEquals(countryCode, + this.lookupResults.get(addressString).countryCode); + } + if (countryName == null) { + assertTrue(!this.lookupResults.containsKey(addressString) || + this.lookupResults.get(addressString).countryName == null); + } else { + assertEquals(countryName, + this.lookupResults.get(addressString).countryName); + } + if (regionName == null) { + assertTrue(!this.lookupResults.containsKey(addressString) || + this.lookupResults.get(addressString).regionName == null); + } else { + assertEquals(regionName, + this.lookupResults.get(addressString).regionName); + } + if (cityName == null) { + assertTrue(!this.lookupResults.containsKey(addressString) || + this.lookupResults.get(addressString).cityName == null); + } else { + assertEquals(cityName, + this.lookupResults.get(addressString).cityName); + } + if (latitude == null) { + assertTrue(!this.lookupResults.containsKey(addressString) || + this.lookupResults.get(addressString).latitude == null); + } else { + assertEquals(latitude, + this.lookupResults.get(addressString).latitude); + } + if (longitude == null) { + assertTrue(!this.lookupResults.containsKey(addressString) || + this.lookupResults.get(addressString).longitude == null); + } else { + assertEquals(longitude, + this.lookupResults.get(addressString).longitude); + } + if (aSNumber == null) { + assertTrue(!this.lookupResults.containsKey(addressString) || + this.lookupResults.get(addressString).aSNumber == null); + } else { + assertEquals(aSNumber, + this.lookupResults.get(addressString).aSNumber); + } + if (aSName == null) { + assertTrue(!this.lookupResults.containsKey(addressString) || + this.lookupResults.get(addressString).aSName == null); + } else { + assertEquals(aSName, + this.lookupResults.get(addressString).aSName); } }
@@ -230,7 +216,7 @@ public class LookupServiceTest {
@Test() public void testLookup8888() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, null, "8.8.8.8", "us", "United States", "California", "Mountain View", "37.3860", "-122.0838", "AS15169", "Google Inc."); @@ -238,7 +224,7 @@ public class LookupServiceTest {
@Test() public void testLookup8880() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, null, "8.8.8.0", "us", "United States", "California", "Mountain View", "37.3860", "-122.0838", "AS15169", "Google Inc."); @@ -246,7 +232,7 @@ public class LookupServiceTest {
@Test() public void testLookup888255() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, null, "8.8.8.255", "us", "United States", "California", "Mountain View", "37.3860", "-122.0838", "AS15169", "Google Inc."); @@ -254,56 +240,56 @@ public class LookupServiceTest {
@Test() public void testLookup888256() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, null, "8.8.8.256", null, null, null, null, null, null, null, null); }
@Test() public void testLookup888Minus1() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, null, "8.8.8.-1", null, null, null, null, null, null, null, null); }
@Test() public void testLookup000() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, null, "0.0.0.0", null, null, null, null, null, null, null, null); }
@Test() public void testLookupNoBlocksLines() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, + this.assertLookupResult( new ArrayList<String>(), null, null, null, null, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); }
@Test() public void testLookupNoLocationLines() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, new ArrayList<String>(), null, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); }
@Test() public void testLookupNoIso3166Lines() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, new ArrayList<String>(), null, null, "8.8.8.8", null, null, null, null, null, null, null, null); }
@Test() public void testLookupNoRegionLines() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, new ArrayList<String>(), null, "8.8.8.8", null, null, null, null, null, null, null, null); }
@Test() public void testLookupNoGeoipASNum2Lines() { - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, new ArrayList<String>(), "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -317,7 +303,7 @@ public class LookupServiceTest { + "latitude,longitude,metroCode,areaCode"); geoLiteCityLocationLines.add("223,"US","","","",38.0000," + "-97.0000,,"); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, geoLiteCityLocationLines, null, null, null, "8.8.8.8", null, null, null, null, null, null, "AS15169", "Google Inc."); } @@ -326,7 +312,7 @@ public class LookupServiceTest { public void testLookupNoCorrespondingCountryName() { List<String> iso3166Lines = new ArrayList<String>(); iso3166Lines.add("UY,"Uruguay""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, iso3166Lines, null, null, "8.8.8.8", "us", null, "California", "Mountain View", "37.3860", "-122.0838", "AS15169", "Google Inc."); @@ -336,7 +322,7 @@ public class LookupServiceTest { public void testLookupNoCorrespondingRegionName() { List<String> regionLines = new ArrayList<String>(); regionLines.add("US,CO,"Colorado""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, regionLines, null, "8.8.8.8", "us", "United States", null, "Mountain View", "37.3860", "-122.0838", "AS15169", "Google Inc."); @@ -354,7 +340,7 @@ public class LookupServiceTest { + ""32191""); manualGeoLiteCityBlocksLines.add(""134744320","134751743"," + ""223""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, + this.assertLookupResult( manualGeoLiteCityBlocksLines, null, null, null, null, null, null, "8.8.8.8", null, null, null, null, null, null, "AS15169", "Google Inc."); @@ -368,7 +354,7 @@ public class LookupServiceTest { manualGeoLiteCityBlocksLines.add("startIpNum,endIpNum,locId"); manualGeoLiteCityBlocksLines.add(""one","134744319"," + ""32191""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, + this.assertLookupResult( manualGeoLiteCityBlocksLines, null, null, null, null, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -381,7 +367,7 @@ public class LookupServiceTest { manualGeoLiteCityBlocksLines.add("startIpNum,endIpNum,locId"); manualGeoLiteCityBlocksLines.add(""1" + String.valueOf(Long.MAX_VALUE) + "","134744319","32191""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, + this.assertLookupResult( manualGeoLiteCityBlocksLines, null, null, null, null, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -393,7 +379,7 @@ public class LookupServiceTest { + "All Rights Reserved."); manualGeoLiteCityBlocksLines.add("startIpNum,endIpNum,locId"); manualGeoLiteCityBlocksLines.add(""134744064","134744319","X""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, + this.assertLookupResult( manualGeoLiteCityBlocksLines, null, null, null, null, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -405,7 +391,7 @@ public class LookupServiceTest { + "All Rights Reserved."); manualGeoLiteCityBlocksLines.add("startIpNum,endIpNum,locId"); manualGeoLiteCityBlocksLines.add(""134744064","134744319""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, + this.assertLookupResult( manualGeoLiteCityBlocksLines, null, null, null, null, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -419,7 +405,7 @@ public class LookupServiceTest { + "latitude,longitude,metroCode,areaCode"); geoLiteCityLocationLines.add("threetwoonenineone,"US","CA"," + ""Mountain View","",37.3860,-122.0838,807,650"); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, geoLiteCityLocationLines, null, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -433,7 +419,7 @@ public class LookupServiceTest { + "latitude,longitude,metroCode,areaCode"); geoLiteCityLocationLines.add("32191,"US","CA","Mountain View"," + """,37.3860,-122.0838,807"); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, geoLiteCityLocationLines, null, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -442,7 +428,7 @@ public class LookupServiceTest { public void testLookupIso3166TooFewFields() { List<String> iso3166Lines = new ArrayList<String>(); iso3166Lines.add("US"); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, iso3166Lines, null, null, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -451,7 +437,7 @@ public class LookupServiceTest { public void testLookupRegionTooFewFields() { List<String> regionLines = new ArrayList<String>(); regionLines.add("US,CA"); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, regionLines, null, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -464,7 +450,7 @@ public class LookupServiceTest { geoipASNum2Lines.add("134744319,134744064,"AS15169 Google Inc.""); geoipASNum2Lines.add("134744320,134750463,"AS3356 Level 3 " + "Communications""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, geoipASNum2Lines, "8.8.8.8", "us", "United States", "California", "Mountain View", "37.3860", "-122.0838", null, null); @@ -474,7 +460,7 @@ public class LookupServiceTest { public void testLookupGeoipASNum2StartNotANumber() { List<String> geoipASNum2Lines = new ArrayList<String>(); geoipASNum2Lines.add("one,134744319,"AS15169 Google Inc.""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, geoipASNum2Lines, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -484,7 +470,7 @@ public class LookupServiceTest { List<String> geoipASNum2Lines = new ArrayList<String>(); geoipASNum2Lines.add("1" + String.valueOf(Long.MAX_VALUE) + ",134744319,"AS15169 Google Inc.""); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, geoipASNum2Lines, "8.8.8.8", null, null, null, null, null, null, null, null); } @@ -493,7 +479,7 @@ public class LookupServiceTest { public void testLookupGeoipASNum2TooFewFields() { List<String> geoipASNum2Lines = new ArrayList<String>(); geoipASNum2Lines.add("134744064,134744319"); - LookupServiceTestHelper.assertLookupResult(this.tempGeoipDir, null, + this.assertLookupResult(null, null, null, null, null, null, geoipASNum2Lines, "8.8.8.8", null, null, null, null, null, null, null, null); } diff --git a/test/org/torproject/onionoo/ResourceServletTest.java b/test/org/torproject/onionoo/ResourceServletTest.java index fbe7db7..ca7cd69 100644 --- a/test/org/torproject/onionoo/ResourceServletTest.java +++ b/test/org/torproject/onionoo/ResourceServletTest.java @@ -32,243 +32,233 @@ import com.google.gson.Gson;
public class ResourceServletTest {
- private static class ResourceServletTestHelper { + private SortedMap<String, String> relays, bridges;
- private File tempOutDir; + // 2013-04-24 12:22:22 + private static long lastModified = 1366806142000L;
- private SortedMap<String, String> - relays = new TreeMap<String, String>(), - bridges = new TreeMap<String, String>(); + private long currentTimeMillis = 1366806142000L;
- // 2013-04-24 12:22:22 - private static long lastModified = 1366806142000L; - - private static long currentTimeMillis = 1366806142000L; - - private class TestingTime extends Time { - public long currentTimeMillis() { - return currentTimeMillis; - } + private class TestingTime extends Time { + public long currentTimeMillis() { + return currentTimeMillis; } + }
- private Time testingTime = new TestingTime(); + private Time testingTime = new TestingTime();
- private boolean maintenanceMode = false; + private boolean maintenanceMode = false;
- private class TestingHttpServletRequestWrapper - extends HttpServletRequestWrapper { - private String requestURI; - private Map<String, String[]> parameterMap; - private TestingHttpServletRequestWrapper(String requestURI, - Map<String, String[]> parameterMap) { - super(null); - this.requestURI = requestURI; - this.parameterMap = parameterMap == null - ? new HashMap<String, String[]>() : parameterMap; - } - protected String getRequestURI() { - return this.requestURI; - } - protected Map getParameterMap() { - return this.parameterMap; - } - protected String[] getParameterValues(String parameterKey) { - return this.parameterMap.get(parameterKey); - } + private class TestingHttpServletRequestWrapper + extends HttpServletRequestWrapper { + private String requestURI; + private Map<String, String[]> parameterMap; + private TestingHttpServletRequestWrapper(String requestURI, + Map<String, String[]> parameterMap) { + super(null); + this.requestURI = requestURI; + this.parameterMap = parameterMap == null + ? new HashMap<String, String[]>() : parameterMap; + } + protected String getRequestURI() { + return this.requestURI; + } + protected Map getParameterMap() { + return this.parameterMap; + } + protected String[] getParameterValues(String parameterKey) { + return this.parameterMap.get(parameterKey); } + }
- private class TestingHttpServletResponseWrapper extends - HttpServletResponseWrapper { - private TestingHttpServletResponseWrapper() { - super(null); - } - private int errorStatusCode; - protected void sendError(int errorStatusCode) throws IOException { - this.errorStatusCode = errorStatusCode; - } - private Map<String, String> headers = new HashMap<String, String>(); - protected void setHeader(String headerName, String headerValue) { - this.headers.put(headerName, headerValue); - } - protected void setContentType(String contentType) { - } - protected void setCharacterEncoding(String characterEncoding) { - } - private StringWriter stringWriter; - protected PrintWriter getWriter() throws IOException { - if (this.stringWriter == null) { - this.stringWriter = new StringWriter(); - return new PrintWriter(this.stringWriter); - } else { - throw new IOException("Can only request writer once"); - } - } - private String getWrittenContent() { - return this.stringWriter == null ? null - : this.stringWriter.toString(); + private class TestingHttpServletResponseWrapper extends + HttpServletResponseWrapper { + private TestingHttpServletResponseWrapper() { + super(null); + } + private int errorStatusCode; + protected void sendError(int errorStatusCode) throws IOException { + this.errorStatusCode = errorStatusCode; + } + private Map<String, String> headers = new HashMap<String, String>(); + protected void setHeader(String headerName, String headerValue) { + this.headers.put(headerName, headerValue); + } + protected void setContentType(String contentType) { + } + protected void setCharacterEncoding(String characterEncoding) { + } + private StringWriter stringWriter; + protected PrintWriter getWriter() throws IOException { + if (this.stringWriter == null) { + this.stringWriter = new StringWriter(); + return new PrintWriter(this.stringWriter); + } else { + throw new IOException("Can only request writer once"); } } + private String getWrittenContent() { + return this.stringWriter == null ? null + : this.stringWriter.toString(); + } + }
- private TestingHttpServletRequestWrapper request; + private TestingHttpServletRequestWrapper request;
- private TestingHttpServletResponseWrapper response; + private TestingHttpServletResponseWrapper response;
- private String responseString; + private String responseString;
- private SummaryDocument summaryDocument; + private SummaryDocument summaryDocument;
- private ResourceServletTestHelper(File tempOutDir, String requestURI, - Map<String, String[]> parameterMap) { - this.tempOutDir = tempOutDir; - this.relays = new TreeMap<String, String>(); - this.relays.put("000C5F55", "r\tTorkaZ\t" - + "000C5F55BD4814B917CC474BD537F1A3B33CCE2A\t" - + "62.216.201.221;;62.216.201.222+62.216.201.223\t" - + "2013-04-19\t05:00:00\t9001\t0\tRunning,Valid\t20\tde\tnull\t" - + "-1\treject\t1-65535\t2013-04-18\t05:00:00\t" - + "2013-04-19\t05:00:00\tAS8767\ttorkaz <klaus dot zufall at " - + "gmx dot de> fb-token:np5_g_83jmf="); - this.relays.put("001C13B3", "r\tFerrari458\t" - + "001C13B3A55A71B977CA65EC85539D79C653A3FC\t" - + "68.38.171.200;[2001:4f8:3:2e::51]:9001;\t" - + "2013-04-24\t12:00:00\t9001\t9030\t" - + "Fast,Named,Running,V2Dir,Valid\t1140\tus\t" - + "c-68-38-171-200.hsd1.pa.comcast.net\t1366805763009\treject\t" - + "1-65535\t2013-02-12\t16:00:00\t2013-02-26\t18:00:00\t" - + "AS7922\t"); - this.relays.put("0025C136", "r\tTimMayTribute\t" - + "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B\t89.69.68.246;;\t" - + "2013-04-22\t20:00:00\t9001\t9030\t" - + "Fast,Running,Unnamed,V2Dir,Valid\t63\ta1\tnull\t-1\treject\t" - + "1-65535\t2013-04-16\t18:00:00\t2013-04-16\t18:00:00\t" - + "AS6830\t1024D/51E2A1C7 steven j. murdoch " - + "tor+steven.murdoch@cl.cam.ac.uk fb-token:5sr_k_zs2wm="); - this.bridges.put("0000831B", "b\tec2bridgercc7f31fe\t" - + "0000831B236DFF73D409AD17B40E2A728A53994F\t10.199.7.176;;\t" - + "2013-04-21\t18:07:03\t443\t0\tValid\t-1\t??\tnull\t-1\t" - + "null\tnull\t2013-04-20\t15:37:04\tnull\tnull\tnull\tnull"); - this.bridges.put("0002D9BD", "b\tUnnamed\t" - + "0002D9BDBBC230BD9C78FF502A16E0033EF87E0C\t10.0.52.84;;\t" - + "2013-04-20\t17:37:04\t443\t0\tValid\t-1\t??\tnull\t-1\t" - + "null\tnull\t2013-04-14\t07:07:05\tnull\tnull\tnull\tnull"); - this.bridges.put("0010D49C", "b\tgummy\t" - + "1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB756\t10.63.169.98;;\t" - + "2013-04-24\t01:07:04\t9001\t0\tRunning,Valid\t-1\t??\tnull\t" - + "-1\tnull\tnull\t2013-01-16\t21:07:04\tnull\tnull\tnull\t" - + "null"); - this.request = new TestingHttpServletRequestWrapper(requestURI, - parameterMap); - this.response = new TestingHttpServletResponseWrapper(); + @Before + public void createSampleRelaysAndBridges() { + this.relays = new TreeMap<String, String>(); + this.relays.put("000C5F55", "r\tTorkaZ\t" + + "000C5F55BD4814B917CC474BD537F1A3B33CCE2A\t" + + "62.216.201.221;;62.216.201.222+62.216.201.223\t" + + "2013-04-19\t05:00:00\t9001\t0\tRunning,Valid\t20\tde\tnull\t" + + "-1\treject\t1-65535\t2013-04-18\t05:00:00\t" + + "2013-04-19\t05:00:00\tAS8767\ttorkaz <klaus dot zufall at " + + "gmx dot de> fb-token:np5_g_83jmf="); + this.relays.put("001C13B3", "r\tFerrari458\t" + + "001C13B3A55A71B977CA65EC85539D79C653A3FC\t" + + "68.38.171.200;[2001:4f8:3:2e::51]:9001;\t" + + "2013-04-24\t12:00:00\t9001\t9030\t" + + "Fast,Named,Running,V2Dir,Valid\t1140\tus\t" + + "c-68-38-171-200.hsd1.pa.comcast.net\t1366805763009\treject\t" + + "1-65535\t2013-02-12\t16:00:00\t2013-02-26\t18:00:00\t" + + "AS7922\t"); + this.relays.put("0025C136", "r\tTimMayTribute\t" + + "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B\t89.69.68.246;;\t" + + "2013-04-22\t20:00:00\t9001\t9030\t" + + "Fast,Running,Unnamed,V2Dir,Valid\t63\ta1\tnull\t-1\treject\t" + + "1-65535\t2013-04-16\t18:00:00\t2013-04-16\t18:00:00\t" + + "AS6830\t1024D/51E2A1C7 steven j. murdoch " + + "tor+steven.murdoch@cl.cam.ac.uk fb-token:5sr_k_zs2wm="); + this.bridges = new TreeMap<String, String>(); + this.bridges.put("0000831B", "b\tec2bridgercc7f31fe\t" + + "0000831B236DFF73D409AD17B40E2A728A53994F\t10.199.7.176;;\t" + + "2013-04-21\t18:07:03\t443\t0\tValid\t-1\t??\tnull\t-1\t" + + "null\tnull\t2013-04-20\t15:37:04\tnull\tnull\tnull\tnull"); + this.bridges.put("0002D9BD", "b\tUnnamed\t" + + "0002D9BDBBC230BD9C78FF502A16E0033EF87E0C\t10.0.52.84;;\t" + + "2013-04-20\t17:37:04\t443\t0\tValid\t-1\t??\tnull\t-1\t" + + "null\tnull\t2013-04-14\t07:07:05\tnull\tnull\tnull\tnull"); + this.bridges.put("0010D49C", "b\tgummy\t" + + "1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB756\t10.63.169.98;;\t" + + "2013-04-24\t01:07:04\t9001\t0\tRunning,Valid\t-1\t??\tnull\t" + + "-1\tnull\tnull\t2013-01-16\t21:07:04\tnull\tnull\tnull\t" + + "null"); + } + + private void runTest(String requestURI, + Map<String, String[]> parameterMap) { + try { + this.writeSummaryFile(); + this.makeRequest(requestURI, parameterMap); + this.parseResponse(); + } catch (IOException e) { + throw new RuntimeException(e); } + }
- private void runTest() { - try { - this.writeSummaryFile(); - this.makeRequest(); - this.parseResponse(); - } catch (IOException e) { - throw new RuntimeException(e); - } + /* TODO Instead of writing out/summary and out/update to a temp + * directory, we could also write our own DocumentStore instance. */ + private void writeSummaryFile() throws IOException { + File summaryFile = new File(this.tempOutDir, "summary"); + BufferedWriter bw = new BufferedWriter(new FileWriter(summaryFile)); + for (String relay : this.relays.values()) { + bw.write(relay + "\n"); } - - /* TODO Instead of writing out/summary and out/update to a temp - * directory, we could also write our own DocumentStore instance. */ - private void writeSummaryFile() throws IOException { - File summaryFile = new File(this.tempOutDir, "summary"); - BufferedWriter bw = new BufferedWriter(new FileWriter(summaryFile)); - for (String relay : relays.values()) { - bw.write(relay + "\n"); - } - for (String bridge : bridges.values()) { - bw.write(bridge + "\n"); - } - bw.close(); - File updateFile = new File(this.tempOutDir, "update"); - bw = new BufferedWriter(new FileWriter(updateFile)); - bw.write(String.valueOf(lastModified++)); - bw.close(); + for (String bridge : this.bridges.values()) { + bw.write(bridge + "\n"); } - - private void makeRequest() throws IOException { - ResourceServlet rs = new ResourceServlet(); - rs.init(maintenanceMode, this.tempOutDir, this.testingTime); - rs.doGet(this.request, this.response); + bw.close(); + File updateFile = new File(this.tempOutDir, "update"); + bw = new BufferedWriter(new FileWriter(updateFile)); + bw.write(String.valueOf(lastModified++)); + bw.close(); + } + + private void makeRequest(String requestURI, + Map<String, String[]> parameterMap) throws IOException { + ResourceServlet rs = new ResourceServlet(); + rs.init(maintenanceMode, this.tempOutDir, this.testingTime); + this.request = new TestingHttpServletRequestWrapper(requestURI, + parameterMap); + this.response = new TestingHttpServletResponseWrapper(); + rs.doGet(this.request, this.response); + } + + private void parseResponse() { + this.responseString = this.response.getWrittenContent(); + if (this.responseString != null) { + Gson gson = new Gson(); + this.summaryDocument = gson.fromJson(this.responseString, + SummaryDocument.class); } + }
- private void parseResponse() { - this.responseString = this.response.getWrittenContent(); - if (this.responseString != null) { - Gson gson = new Gson(); - this.summaryDocument = gson.fromJson(this.responseString, - SummaryDocument.class); + private void assertErrorStatusCode(String request, + int errorStatusCode) { + String requestURI = parseRequestURI(request); + Map<String, String[]> parameters = parseParameters(request); + this.runTest(requestURI, parameters); + assertEquals(errorStatusCode, this.response.errorStatusCode); + } + + private void assertSummaryDocument(String request, + int expectedRelaysNumber, String[] expectedRelaysNicknames, + int expectedBridgesNumber, String[] expectedBridgesNicknames) { + String requestURI = parseRequestURI(request); + Map<String, String[]> parameters = parseParameters(request); + this.runTest(requestURI, parameters); + assertNotNull(this.summaryDocument); + assertEquals(expectedRelaysNumber, + this.summaryDocument.relays.length); + if (expectedRelaysNicknames != null) { + for (int i = 0; i < expectedRelaysNumber; i++) { + assertEquals(expectedRelaysNicknames[i], + this.summaryDocument.relays[i].n); } } - - private static void assertErrorStatusCode(File tempOutDir, - String request, int errorStatusCode) { - String requestURI = parseRequestURI(request); - Map<String, String[]> parameters = parseParameters(request); - ResourceServletTestHelper helper = new ResourceServletTestHelper( - tempOutDir, requestURI, parameters); - helper.runTest(); - assertEquals(errorStatusCode, helper.response.errorStatusCode); - } - - private static void assertSummaryDocument(File tempOutDir, - String request, int expectedRelaysNumber, - String[] expectedRelaysNicknames, int expectedBridgesNumber, - String[] expectedBridgesNicknames) { - String requestURI = parseRequestURI(request); - Map<String, String[]> parameters = parseParameters(request); - ResourceServletTestHelper helper = new ResourceServletTestHelper( - tempOutDir, requestURI, parameters); - helper.runTest(); - assertNotNull(helper.summaryDocument); - assertEquals(expectedRelaysNumber, - helper.summaryDocument.relays.length); - if (expectedRelaysNicknames != null) { - for (int i = 0; i < expectedRelaysNumber; i++) { - assertEquals(expectedRelaysNicknames[i], - helper.summaryDocument.relays[i].n); - } - } - assertEquals(expectedBridgesNumber, - helper.summaryDocument.bridges.length); - if (expectedBridgesNicknames != null) { - for (int i = 0; i < expectedBridgesNumber; i++) { - assertEquals(expectedBridgesNicknames[i], - helper.summaryDocument.bridges[i].n); - } + assertEquals(expectedBridgesNumber, + this.summaryDocument.bridges.length); + if (expectedBridgesNicknames != null) { + for (int i = 0; i < expectedBridgesNumber; i++) { + assertEquals(expectedBridgesNicknames[i], + this.summaryDocument.bridges[i].n); } } + }
- private static String parseRequestURI(String request) { - return request.split("\?")[0]; - } + private String parseRequestURI(String request) { + return request.split("\?")[0]; + }
- private static Map<String, String[]> parseParameters(String request) { - Map<String, String[]> parameters = null; - String[] uriParts = request.split("\?"); - if (uriParts.length == 2) { - Map<String, List<String>> parameterLists = - new HashMap<String, List<String>>(); - for (String parameter : uriParts[1].split("&")) { - String[] parameterParts = parameter.split("="); - if (!parameterLists.containsKey(parameterParts[0])) { - parameterLists.put(parameterParts[0], - new ArrayList<String>()); - } - parameterLists.get(parameterParts[0]).add(parameterParts[1]); - } - parameters = new HashMap<String, String[]>(); - for (Map.Entry<String, List<String>> e : - parameterLists.entrySet()) { - parameters.put(e.getKey(), - e.getValue().toArray(new String[e.getValue().size()])); + private Map<String, String[]> parseParameters(String request) { + Map<String, String[]> parameters = null; + String[] uriParts = request.split("\?"); + if (uriParts.length == 2) { + Map<String, List<String>> parameterLists = + new HashMap<String, List<String>>(); + for (String parameter : uriParts[1].split("&")) { + String[] parameterParts = parameter.split("="); + if (!parameterLists.containsKey(parameterParts[0])) { + parameterLists.put(parameterParts[0], + new ArrayList<String>()); } + parameterLists.get(parameterParts[0]).add(parameterParts[1]); + } + parameters = new HashMap<String, String[]>(); + for (Map.Entry<String, List<String>> e : + parameterLists.entrySet()) { + parameters.put(e.getKey(), + e.getValue().toArray(new String[e.getValue().size()])); } - return parameters; } + return parameters; }
@Rule @@ -278,7 +268,7 @@ public class ResourceServletTest {
@Before public void createTempOutDir() throws IOException { - tempOutDir = this.tempFolder.newFolder("out"); + this.tempOutDir = this.tempFolder.newFolder("out"); }
private static class SummaryDocument { @@ -303,19 +293,17 @@ public class ResourceServletTest {
@Test() public void testValidSummaryRelay() throws IOException { - ResourceServletTestHelper helper = new ResourceServletTestHelper( - this.tempOutDir, "/summary", null); - helper.relays.clear(); - helper.relays.put("000C5F55", "r TorkaZ " + this.relays.clear(); + this.relays.put("000C5F55", "r TorkaZ " + "000C5F55BD4814B917CC474BD537F1A3B33CCE2A 62.216.201.221;; " + "2013-04-19 05:00:00 9001 0 Running,Valid 20 de null -1 " + "reject 1-65535 2013-04-18 05:00:00 2013-04-19 05:00:00 " + "AS8767"); - helper.runTest(); + this.runTest("/summary", null); assertEquals("2013-04-19 05:00:00", - helper.summaryDocument.relays_published); - assertEquals(1, helper.summaryDocument.relays.length); - RelaySummary relay = helper.summaryDocument.relays[0]; + this.summaryDocument.relays_published); + assertEquals(1, this.summaryDocument.relays.length); + RelaySummary relay = this.summaryDocument.relays[0]; assertEquals("TorkaZ", relay.n); assertEquals("000C5F55BD4814B917CC474BD537F1A3B33CCE2A", relay.f); assertEquals(1, relay.a.length); @@ -325,18 +313,16 @@ public class ResourceServletTest {
@Test() public void testValidSummaryBridge() { - ResourceServletTestHelper helper = new ResourceServletTestHelper( - this.tempOutDir, "/summary", null); - helper.bridges.clear(); - helper.bridges.put("0000831", "b ec2bridgercc7f31fe " + this.bridges.clear(); + this.bridges.put("0000831", "b ec2bridgercc7f31fe " + "0000831B236DFF73D409AD17B40E2A728A53994F 10.199.7.176;; " + "2013-04-21 18:07:03 443 0 Valid -1 ?? null -1 null null " + "2013-04-20 15:37:04 null null null"); - helper.runTest(); + this.runTest("/summary", null); assertEquals("2013-04-21 18:07:03", - helper.summaryDocument.bridges_published); - assertEquals(1, helper.summaryDocument.bridges.length); - BridgeSummary bridge = helper.summaryDocument.bridges[0]; + this.summaryDocument.bridges_published); + assertEquals(1, this.summaryDocument.bridges.length); + BridgeSummary bridge = this.summaryDocument.bridges[0]; assertEquals("ec2bridgercc7f31fe", bridge.n); assertEquals("0000831B236DFF73D409AD17B40E2A728A53994F", bridge.h); assertFalse(bridge.r); @@ -344,708 +330,708 @@ public class ResourceServletTest {
@Test() public void testNonExistantDocumentType() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/doesnotexist", 400); }
@Test() public void testSUMMARYDocument() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/SUMMARY", 400); }
@Test() public void testTypeRelay() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?type=relay", 3, null, 0, null); }
@Test() public void testTypeBridge() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?type=bridge", 0, null, 3, null); }
@Test() public void testTypeBridgerelay() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?type=bridgerelay", 400); }
@Test() public void testTypeRelayBridge() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?type=relay&type=bridge", 3, null, 0, null); }
@Test() public void testTypeBridgeRelay() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?type=bridge&type=relay", 0, null, 3, null); }
@Test() public void testTypeRelayRelay() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?type=relay&type=relay", 3, null, 0, null); }
@Test() public void testTYPERelay() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?TYPE=relay", 400); }
@Test() public void testTypeRELAY() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?type=RELAY", 3, null, 0, null); }
@Test() public void testRunningTrue() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?running=true", 1, new String[] { "Ferrari458" }, 1, new String[] { "gummy" }); }
@Test() public void testRunningFalse() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?running=false", 2, null, 2, null); }
@Test() public void testRunningTruefalse() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?running=truefalse", 400); }
@Test() public void testRunningTrueFalse() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?running=true&running=false", 1, new String[] { "Ferrari458" }, 1, new String[] { "gummy" }); }
@Test() public void testRunningFalseTrue() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?running=false&running=true", 2, null, 2, null); }
@Test() public void testRunningTrueTrue() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?running=true&running=true", 1, new String[] { "Ferrari458" }, 1, new String[] { "gummy" }); }
@Test() public void testRUNNINGTrue() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?RUNNING=true", 400); }
@Test() public void testRunningTRUE() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?running=TRUE", 1, null, 1, null); }
@Test() public void testSearchTorkaZ() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=TorkaZ", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchTorkaX() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=TorkaX", 0, null, 0, null); }
@Test() public void testSearchOrkaZ() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=orkaZ", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchTorka() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=Torka", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchTORKAZ() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=TORKAZ", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchDollarFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$000C5F55BD4814B917CC474BD537F1A3B33CCE2A", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=000C5F55BD4814B917CC474BD537F1A3B33CCE2A", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchDollarFingerprint39() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$000C5F55BD4814B917CC474BD537F1A3B33CCE2", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchDollarFingerprintLowerCase39() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$000c5f55bd4814b917cc474bd537f1a3b33cce2", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchFingerprintLowerCase39() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=000c5f55bd4814b917cc474bd537f1a3b33cce2", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchDollarHashedFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$5aa14c08d62913e0057a9ad5863b458c0ce94cee", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchDollarHashedFingerprint39() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$5aa14c08d62913e0057a9ad5863b458c0ce94ce", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchDollarHashedFingerprint41() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?search=$5aa14c08d62913e0057a9ad5863b458c0ce94ceee", 400); }
@Test() public void testSearchIp() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=62.216.201.221", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchIp24Network() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=62.216.201", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchIpExit() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=62.216.201.222", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testSearchIpv6() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=[2001:4f8:3:2e::51]", 1, new String[] { "Ferrari458" }, 0, null); }
@Test() public void testSearchIpv6Slash64NoTrailingBracket() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=[2001:4f8:3:2e::", 1, new String[] { "Ferrari458" }, 0, null); }
@Test() public void testSearchIpv6Slash64TrailingBracket() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=[2001:4f8:3:2e::]", 0, null, 0, null); }
@Test() public void testSearchIpv6Uncompressed() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=[2001:04f8:0003:002e:0000:0000:0000:0051]", 0, null, 0, null); }
@Test() public void testSearchIpv6UpperCase() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=[2001:4F8:3:2E::51]", 1, new String[] { "Ferrari458" }, 0, null); }
@Test() public void testSearchIpv6ThreeColons() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=[2001:4f8:3:2e:::51]", 0, null, 0, null); }
@Test() public void testSearchIpv6FiveHex() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=[20014:f80:3:2e::51]", 0, null, 0, null); }
@Test() public void testSearchIpv6NineGroups() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=[1:2:3:4:5:6:7:8:9]", 0, null, 0, null); }
@Test() public void testSearchIpv6TcpPort() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?search=[2001:4f8:3:2e::51]:9001", 400); }
@Test() public void testSearchGummy() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=gummy", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchGummi() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=gummi", 0, null, 0, null); }
@Test() public void testSearchUmmy() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=ummy", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchGumm() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=gumm", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchGUMMY() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=GUMMY", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeDollarHashedFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB756", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeHashedFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB756", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeDollarHashedFingerprint39() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB75", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeDollarHashedFingerprintLowerCase39() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$1fede50ed8dba1dd9f9165f78c8131e4a44ab75", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeHashedFingerprintLowerCase39() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=1fede50ed8dba1dd9f9165f78c8131e4a44ab75", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeDollarHashedHashedFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$CE52F898DB3678BCE33FAC28C92774DE90D618B5", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeDollarHashedHashedFingerprint39() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$CE52F898DB3678BCE33FAC28C92774DE90D618B", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeDollarOriginalFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?search=$0010D49C6DA1E46A316563099F41BFE40B6C7183", 0, null, 0, null); }
@Test() public void testSearchUnderscore() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?search=_", 400); }
@Test() public void testLookupFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?lookup=000C5F55BD4814B917CC474BD537F1A3B33CCE2A", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testLookupDollarFingerprint() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?lookup=$000C5F55BD4814B917CC474BD537F1A3B33CCE2A", 400); }
@Test() public void testLookupDollarFingerprint39() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?lookup=$000C5F55BD4814B917CC474BD537F1A3B33CCE2", 400); }
@Test() public void testLookupFingerprintLowerCase39() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?lookup=000c5f55bd4814b917cc474bd537f1a3b33cce2", 400); }
@Test() public void testLookupHashedFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?lookup=5aa14c08d62913e0057a9ad5863b458c0ce94cee", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testLookupBridgeHashedFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?lookup=1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB756", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testSearchBridgeHashedHashedFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?lookup=CE52F898DB3678BCE33FAC28C92774DE90D618B5", 0, null, 1, new String[] { "gummy" }); }
@Test() public void testLookupBridgeOriginalFingerprint() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?lookup=0010D49C6DA1E46A316563099F41BFE40B6C7183", 0, null, 0, null); }
@Test() public void testCountryDe() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?country=de", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testCountryFr() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?country=fr", 0, null, 0, null); }
@Test() public void testCountryZz() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?country=zz", 0, null, 0, null); }
@Test() public void testCountryDE() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?country=DE", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testCountryDeu() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?country=deu", 400); }
@Test() public void testCountryD() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?country=d", 400); }
@Test() public void testCountryA1() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?country=a1", 1, new String[] { "TimMayTribute" }, 0, null); }
@Test() public void testCountryDeDe() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?country=de&country=de", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testAsAS8767() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?as=AS8767", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testAs8767() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?as=8767", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testAsAS() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?as=AS", 400); }
@Test() public void testAsas8767() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?as=as8767", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testAsASSpace8767() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?as=AS 8767", 400); }
@Test() public void testFlagRunning() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?flag=Running", 3, null, 0, null); }
@Test() public void testFlagValid() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?flag=Valid", 3, null, 0, null); }
@Test() public void testFlagFast() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?flag=Fast", 2, null, 0, null); }
@Test() public void testFlagNamed() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?flag=Named", 1, null, 0, null); }
@Test() public void testFlagUnnamed() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?flag=Unnamed", 1, null, 0, null); }
@Test() public void testFlagV2Dir() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?flag=V2Dir", 2, null, 0, null); }
@Test() public void testFlagGuard() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?flag=Guard", 0, null, 0, null); }
@Test() public void testFlagCool() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?flag=Cool", 0, null, 0, null); }
@Test() public void testFirstSeenDaysZeroToTwo() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?first_seen_days=0-2", 0, null, 0, null); }
@Test() public void testFirstSeenDaysUpToThree() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?first_seen_days=-3", 0, null, 1, null); }
@Test() public void testFirstSeenDaysThree() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?first_seen_days=3", 0, null, 1, null); }
@Test() public void testFirstSeenDaysTwoToFive() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?first_seen_days=2-5", 0, null, 1, null); }
@Test() public void testFirstSeenDaysSixToSixteen() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?first_seen_days=6-16", 2, null, 1, null); }
@Test() public void testFirstSeenDaysNinetysevenOrMore() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?first_seen_days=97-", 0, null, 1, null); }
@Test() public void testFirstSeenDaysNinetyeightOrMore() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?first_seen_days=98-", 0, null, 0, null); }
@Test() public void testFirstSeenDaysDashDash() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?first_seen_days=--", 400); }
@Test() public void testFirstSeenDaysDashOneDash() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?first_seen_days=-1-", 400); }
@Test() public void testFirstSeenDaysZeroDotDotOne() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?first_seen_days=0..1", 400); }
@Test() public void testFirstSeenDaysElevenDigits() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?first_seen_days=12345678901", 400); }
@Test() public void testFirstSeenDaysLargeTenDigitNumber() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?first_seen_days=9999999999", 400); }
@Test() public void testFirstSeenDaysMaxInt() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?last_seen_days=" + String.valueOf(Integer.MAX_VALUE), 0, null, 0, null); }
@Test() public void testFirstSeenDaysMaxIntPlusOne() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?first_seen_days=" + String.valueOf(Integer.MAX_VALUE + 1), 400); }
@Test() public void testLastSeenDaysZero() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?last_seen_days=0", 1, null, 1, null); }
@Test() public void testLastSeenDaysUpToZero() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?last_seen_days=-0", 1, null, 1, null); }
@Test() public void testLastSeenDaysOneToThree() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?last_seen_days=1-3", 1, null, 2, null); }
@Test() public void testLastSeenDaysSixOrMore() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?last_seen_days=6-", 0, null, 0, null); }
@Test() public void testContactSteven() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?contact=Steven", 1, null, 0, null); }
@Test() public void testContactStevenMurdoch() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?contact=Steven Murdoch", 1, null, 0, null); }
@Test() public void testContactMurdochSteven() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?contact=Murdoch Steven", 1, null, 0, null); }
@Test() public void testContactStevenDotMurdoch() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?contact=Steven.Murdoch", 1, null, 0, null); }
@Test() public void testContactFbTokenFive() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?contact=fb-token:5sR_K_zs2wM=", 1, null, 0, null); }
@Test() public void testContactFbToken() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?contact=<fb-token:", 2, null, 0, null); }
@Test() public void testContactDash() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?contact=-", 2, null, 0, null); }
@Test() public void testOrderConsensusWeightAscending() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?order=consensus_weight", 3, new String[] { "TorkaZ", "TimMayTribute", "Ferrari458" }, 3, null); @@ -1053,7 +1039,7 @@ public class ResourceServletTest {
@Test() public void testOrderConsensusWeightDescending() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?order=-consensus_weight", 3, new String[] { "Ferrari458", "TimMayTribute", "TorkaZ" }, 3, null); @@ -1061,25 +1047,25 @@ public class ResourceServletTest {
@Test() public void testOrderConsensusWeightAscendingTwice() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?order=consensus_weight,consensus_weight", 400); }
@Test() public void testOrderConsensusWeightAscendingThenDescending() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?order=consensus_weight,-consensus_weight", 400); }
@Test() public void testOrderConsensusWeightThenNickname() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?order=consensus_weight,nickname", 400); }
@Test() public void testOrderCONSENSUS_WEIGHT() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?order=CONSENSUS_WEIGHT", 3, new String[] { "TorkaZ", "TimMayTribute", "Ferrari458" }, 3, null); @@ -1087,111 +1073,111 @@ public class ResourceServletTest {
@Test() public void testOrderConsensusWeightAscendingLimit1() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?order=consensus_weight&limit=1", 1, new String[] { "TorkaZ" }, 0, null); }
@Test() public void testOrderConsensusWeightDecendingLimit1() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?order=-consensus_weight&limit=1", 1, new String[] { "Ferrari458" }, 0, null); }
@Test() public void testOffsetOne() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?offset=1", 2, null, 3, null); }
@Test() public void testOffsetAllRelays() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?offset=3", 0, null, 3, null); }
@Test() public void testOffsetAllRelaysAndOneBridge() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?offset=4", 0, null, 2, null); }
@Test() public void testOffsetAllRelaysAndAllBridges() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?offset=6", 0, null, 0, null); }
@Test() public void testOffsetMoreThanAllRelaysAndAllBridges() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?offset=7", 0, null, 0, null); }
@Test() public void testOffsetZero() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?offset=0", 3, null, 3, null); }
@Test() public void testOffsetMinusOne() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?offset=-1", 3, null, 3, null); }
@Test() public void testOffsetOneWord() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?offset=one", 400); }
@Test() public void testLimitOne() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?limit=1", 1, null, 0, null); }
@Test() public void testLimitAllRelays() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?limit=3", 3, null, 0, null); }
@Test() public void testLimitAllRelaysAndOneBridge() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?limit=4", 3, null, 1, null); }
@Test() public void testLimitAllRelaysAndAllBridges() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?limit=6", 3, null, 3, null); }
@Test() public void testLimitMoreThanAllRelaysAndAllBridges() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?limit=7", 3, null, 3, null); }
@Test() public void testLimitZero() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?limit=0", 0, null, 0, null); }
@Test() public void testLimitMinusOne() { - ResourceServletTestHelper.assertSummaryDocument(this.tempOutDir, + this.assertSummaryDocument( "/summary?limit=-1", 0, null, 0, null); }
@Test() public void testLimitOneWord() { - ResourceServletTestHelper.assertErrorStatusCode(this.tempOutDir, + this.assertErrorStatusCode( "/summary?limit=one", 400); } }
tor-commits@lists.torproject.org