public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SafeTreeMapTest.class); suite.addTest( NavigableMapTestSuiteBuilder.using( new TestStringSortedMapGenerator() { @Override protected SortedMap<String, String> create(Entry<String, String>[] entries) { NavigableMap<String, String> map = new SafeTreeMap<String, String>(Ordering.natural()); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return map; } }) .withFeatures( CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE) .named("SafeTreeMap with natural comparator") .createTestSuite()); suite.addTest( NavigableMapTestSuiteBuilder.using( new TestStringSortedMapGenerator() { @Override protected SortedMap<String, String> create(Entry<String, String>[] entries) { NavigableMap<String, String> map = new SafeTreeMap<String, String>(NullsBeforeTwo.INSTANCE); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return map; } @Override public Iterable<Entry<String, String>> order( List<Entry<String, String>> insertionOrder) { sort( insertionOrder, Helpers.<String, String>entryComparator(NullsBeforeTwo.INSTANCE)); return insertionOrder; } }) .withFeatures( CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, MapFeature.ALLOWS_NULL_KEYS, MapFeature.ALLOWS_NULL_VALUES, MapFeature.GENERAL_PURPOSE) .named("SafeTreeMap with null-friendly comparator") .createTestSuite()); return suite; }
public static TestSuite suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SynchronizedNavigableMapTest.class); suite.addTest( NavigableMapTestSuiteBuilder.using( new TestStringSortedMapGenerator() { private final Object mutex = new Integer(1); @Override protected SortedMap<String, String> create(Entry<String, String>[] entries) { NavigableMap<String, String> innermost = new SafeTreeMap<String, String>(); for (Entry<String, String> entry : entries) { innermost.put(entry.getKey(), entry.getValue()); } TestMap<String, String> inner = new TestMap<String, String>(innermost, mutex); NavigableMap<String, String> outer = Synchronized.navigableMap(inner, mutex); return outer; } }) .named("Maps.synchronizedNavigableMap[SafeTreeMap]") .withFeatures( CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE) .createTestSuite()); return suite; }
public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ForwardingNavigableMapTest.class); suite.addTest( NavigableMapTestSuiteBuilder.using( new TestStringSortedMapGenerator() { @Override protected SortedMap<String, String> create(Entry<String, String>[] entries) { NavigableMap<String, String> map = new SafeTreeMap<String, String>(); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return new StandardImplForwardingNavigableMap<String, String>(map); } }) .named( "ForwardingNavigableMap[SafeTreeMap] with no comparator and standard " + "implementations") .withFeatures( CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, MapFeature.GENERAL_PURPOSE) .createTestSuite()); // TODO(lowasser): add forwarding-to-ImmutableSortedMap test return suite; }
public static <K, V> NavigableMapTestSuiteBuilder<K, V> using( TestSortedMapGenerator<K, V> generator) { NavigableMapTestSuiteBuilder<K, V> result = new NavigableMapTestSuiteBuilder<K, V>(); result.usingGenerator(generator); return result; }