ben-manes commented on PR #300:
URL: 
https://github.com/apache/commons-collections/pull/300#issuecomment-1107935459

   Checking and I accidentally attached the wrong version of `ApacheMapTest`. 😦 
   
   The flag `allowNulls` should have been false for `ReferenceMap`, and was 
there just because every collection author does this differently so I had to 
experiment to find Apache's setting. The corrected test case is below.
   
   ```java
   import java.util.Map;
   import java.util.function.Supplier;
   
   import org.apache.commons.collections4.map.HashedMap;
   import org.apache.commons.collections4.map.LRUMap;
   import org.apache.commons.collections4.map.LinkedMap;
   import org.apache.commons.collections4.map.ReferenceMap;
   
   import com.google.common.collect.testing.MapTestSuiteBuilder;
   import com.google.common.collect.testing.TestStringMapGenerator;
   import com.google.common.collect.testing.features.CollectionFeature;
   import com.google.common.collect.testing.features.CollectionSize;
   import com.google.common.collect.testing.features.MapFeature;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
   public final class ApacheMapTest extends TestCase {
   
     public static Test suite() {
       var test = new TestSuite();
       test.addTest(suite("HashedMap", HashedMap::new));
       test.addTest(suite("LinkedMap", LinkedMap::new));
       test.addTest(suite("LRUMap", LRUMap::new));
       test.addTest(suite("ReferenceMap", ReferenceMap::new));
       return test;
     }
   
     public static Test suite(String name, Supplier<Map<String, String>> 
factory) {
       return MapTestSuiteBuilder
           .using(new TestStringMapGenerator() {
             @Override protected Map<String, String> create(Map.Entry<String, 
String>[] entries) {
               var map = factory.get();
               for (var entry : entries) {
                 map.put(entry.getKey(), entry.getValue());
               }
               return map;
             }
           })
           .named(name)
           .withFeatures(
               CollectionSize.ANY,
               MapFeature.GENERAL_PURPOSE,
               MapFeature.ALLOWS_ANY_NULL_QUERIES,
               CollectionFeature.SUPPORTS_ITERATOR_REMOVE)
           .createTestSuite();
     }
   }
   ```
   <img width="1792" alt="Screen Shot 2022-04-24 at 4 04 37 PM" 
src="https://user-images.githubusercontent.com/378614/165000396-a85c13ea-9b0e-4206-88f7-8c115cf66985.png";>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to