@@ -54,10 +54,8 @@ public void testCachesAndEvictsResults_maxBytes() {
5454 String ip2 = "127.0.0.2" ;
5555 String databasePath2 = "path/to/db" ;
5656 FakeResponse response2 = new FakeResponse (222 );
57- long totalSize = GeoIpCache .keySizeInBytes (ip1 , databasePath1 ) + response1 .sizeInBytes () + GeoIpCache .keySizeInBytes (
58- ip2 ,
59- databasePath2
60- ) + response2 .sizeInBytes ();
57+ long totalSize = GeoIpCache .keySizeInBytes (ip1 , databasePath1 ) + GeoIpCache .keySizeInBytes (ip2 , databasePath2 ) + response1
58+ .sizeInBytes () + response2 .sizeInBytes ();
6159
6260 GeoIpCache justBigEnoughCache = GeoIpCache .createGeoIpCacheWithMaxBytes (ByteSizeValue .ofBytes (totalSize ));
6361 justBigEnoughCache .putIfAbsent (projectId , ip1 , databasePath1 , ip -> response1 );
@@ -129,11 +127,19 @@ public void testThrowsFunctionsException() {
129127 assertEquals ("bad" , ex .getMessage ());
130128 }
131129
132- public void testInvalidInit () {
130+ public void testInvalidInit_maxCount () {
133131 IllegalArgumentException ex = expectThrows (IllegalArgumentException .class , () -> GeoIpCache .createGeoIpCacheWithMaxCount (-1 ));
134132 assertEquals ("geoip max cache size must be 0 or greater" , ex .getMessage ());
135133 }
136134
135+ public void testInvalidInit_maxBytes () {
136+ IllegalArgumentException ex = expectThrows (
137+ IllegalArgumentException .class ,
138+ () -> GeoIpCache .createGeoIpCacheWithMaxBytes (ByteSizeValue .MINUS_ONE )
139+ );
140+ assertEquals ("geoip max cache size in bytes must be 0 or greater" , ex .getMessage ());
141+ }
142+
137143 public void testGetCacheStats () {
138144 final long maxCacheSize = 2 ;
139145 final AtomicLong testNanoTime = new AtomicLong (0 );
0 commit comments