本文整理汇总了Java中com.google.common.collect.testing.MapTestSuiteBuilder类的典型用法代码示例。如果您正苦于以下问题:Java MapTestSuiteBuilder类的具体用法?Java MapTestSuiteBuilder怎么用?Java MapTestSuiteBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapTestSuiteBuilder类属于com.google.common.collect.testing包,在下文中一共展示了MapTestSuiteBuilder类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testsForPatriciaTrie
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
public Test testsForPatriciaTrie() {
return MapTestSuiteBuilder
.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(
final Entry<String, String>[] entries) {
return populate(new PatriciaTrie<String>(), entries);
}
})
.named("PatriciaTrie")
.withFeatures(
MapFeature.GENERAL_PURPOSE,
MapFeature.ALLOWS_NULL_ENTRY_QUERIES,
MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
// Assumes Insertion Order if you don't implement SortedMap
// CollectionFeature.KNOWN_ORDER,
CollectionFeature.SERIALIZABLE,
CollectionSize.ANY)
.suppressing(suppressForPatriciaTrie())
.createTestSuite();
}
示例2: suite
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
public static TestSuite suite() throws Exception {
return MapTestSuiteBuilder.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Map.Entry<String, String>[] entries) {
ParetoHashMap m = new ParetoHashMap();
//
for (Map.Entry<String, String> entry : entries) {
if (entry == null)
m.put(null, null);
else
m.put(entry.getKey(), entry.getValue());
}
return m;
}
}
).named("ParetoHashMap"
).withFeatures(MapFeature.GENERAL_PURPOSE, CollectionSize.ANY, MapFeature.ALLOWS_NULL_VALUES, MapFeature.ALLOWS_NULL_KEYS
).createTestSuite();
}
示例3: suite
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
public static Test suite() {
MapTestSuiteBuilder<String, String> chmSuite = using(new CHMTestGenerator());
configureSuite(chmSuite);
TestSuite chmTests = chmSuite.named("Guava tests of Chronicle Map").createTestSuite();
MapTestSuiteBuilder<String, String> backed = using(new BackedUpMapGenerator());
configureSuite(backed);
TestSuite backedTests = backed
.named("Guava tests tests of Chronicle Map, backed with HashMap")
.createTestSuite();
TestSuite tests = new TestSuite();
tests.addTest(chmTests);
// TODO
//tests.addTest(backedTests);
return tests;
}
示例4: testsForPauselessHashMap
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
public Test testsForPauselessHashMap() {
return MapTestSuiteBuilder
.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(
Map.Entry<String, String>[] entries) {
return toHashMap(entries);
}
})
.named("HashMap")
.withFeatures(
MapFeature.GENERAL_PURPOSE,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
MapFeature.ALLOWS_ANY_NULL_QUERIES,
MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionFeature.SERIALIZABLE,
CollectionSize.ANY)
.suppressing(suppressForHashMap())
.createTestSuite();
}
示例5: createDerivedSuites
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
@Override
protected List<TestSuite> createDerivedSuites(
FeatureSpecificTestSuiteBuilder<
?, ? extends OneSizeTestContainerGenerator<M, Map.Entry<K, V>>>
parentBuilder) {
// TODO: Once invariant support is added, supply invariants to each of the
// derived suites, to check that mutations to the derived collections are
// reflected in the underlying map.
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
derivedSuites.add(
MultimapTestSuiteBuilder.using(
new ReserializedMultimapGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
.suppressing(parentBuilder.getSuppressedTests())
.createTestSuite());
}
derivedSuites.add(
MapTestSuiteBuilder.using(new AsMapGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeAsMapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".asMap")
.suppressing(parentBuilder.getSuppressedTests())
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
示例6: suite
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
public static TestSuite suite() {
return MapTestSuiteBuilder
.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Map.Entry<String, String>[] entries) {
MapBox<String, String> inner = new MapBox<String, String>(MapBoxTest.class, "map").init();
for (Map.Entry<String, String> entry : entries) {
if (entry != null) {
inner.put(entry.getKey(), entry.getValue());
}
}
MapBox<String, String> outer = new MapBox<String, String>(
BoxFamily.getInstance(MapBoxTest.class, "map"));
outer.set(inner);
return outer;
}
})
.named("MapBox")
.withFeatures(
CollectionFeature.ALLOWS_NULL_QUERIES,
CollectionFeature.DESCENDING_VIEW,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.SUBSET_VIEW,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionFeature.SUPPORTS_REMOVE,
CollectionSize.ANY,
MapFeature.ALLOWS_ANY_NULL_QUERIES,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
MapFeature.GENERAL_PURPOSE,
MapFeature.SUPPORTS_PUT,
MapFeature.SUPPORTS_REMOVE
).createTestSuite();
}
示例7: suite
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
public static TestSuite suite() {
return MapTestSuiteBuilder
.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Map.Entry<String, String>[] entries) {
BoxesMap<String, String> map = new BoxesMap<String, String>().allowBoxlessKeys();
for (Map.Entry<String, String> entry : entries) {
if (entry != null) {
map.put(entry.getKey(), entry.getValue());
}
}
return map;
}
})
.named("BoxesMap")
.withFeatures(
CollectionFeature.ALLOWS_NULL_QUERIES,
CollectionFeature.DESCENDING_VIEW,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.SUBSET_VIEW,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionFeature.SUPPORTS_REMOVE,
CollectionSize.ANY,
MapFeature.ALLOWS_ANY_NULL_QUERIES,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
MapFeature.GENERAL_PURPOSE,
MapFeature.SUPPORTS_PUT,
MapFeature.SUPPORTS_REMOVE
).createTestSuite();
}
示例8: createDerivedSuites
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
createDerivedSuites(
FeatureSpecificTestSuiteBuilder<?,
? extends OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>>> parentBuilder) {
List<TestSuite> derived = super.createDerivedSuites(parentBuilder);
// TODO(cpovirk): consider using this approach (derived suites instead of extension) in
// ListTestSuiteBuilder, etc.?
derived.add(MapTestSuiteBuilder
.using(new MapGenerator<K, V>(parentBuilder.getSubjectGenerator()))
.withFeatures(parentBuilder.getFeatures())
.named(parentBuilder.getName() + " [Map]")
.suppressing(parentBuilder.getSuppressedTests())
.suppressing(SetCreationTester.class.getMethods())
// BiMap.entrySet() duplicate-handling behavior is too confusing for SetCreationTester
.createTestSuite());
/*
* TODO(cpovirk): the Map tests duplicate most of this effort by using a
* CollectionTestSuiteBuilder on values(). It would be nice to avoid that
*/
derived.add(SetTestSuiteBuilder
.using(new BiMapValueSetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeValuesSetFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " values [Set]")
.suppressing(parentBuilder.getSuppressedTests())
.suppressing(SetCreationTester.class.getMethods())
// BiMap.values() duplicate-handling behavior is too confusing for SetCreationTester
.createTestSuite());
if (!parentBuilder.getFeatures().contains(NoRecurse.INVERSE)) {
derived.add(BiMapTestSuiteBuilder
.using(new InverseBiMapGenerator<K, V>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeInverseFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " inverse")
.suppressing(parentBuilder.getSuppressedTests())
.createTestSuite());
}
return derived;
}
示例9: createDerivedSuites
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
@Override
protected List<TestSuite> createDerivedSuites(
FeatureSpecificTestSuiteBuilder<
?,
? extends OneSizeTestContainerGenerator<M, Map.Entry<K, V>>>
parentBuilder) {
// TODO: Once invariant support is added, supply invariants to each of the
// derived suites, to check that mutations to the derived collections are
// reflected in the underlying map.
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
derivedSuites.add(MultimapTestSuiteBuilder.using(
new ReserializedMultimapGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
.suppressing(parentBuilder.getSuppressedTests())
.createTestSuite());
}
derivedSuites.add(MapTestSuiteBuilder.using(
new AsMapGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeAsMapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".asMap")
.suppressing(parentBuilder.getSuppressedTests())
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
示例10: suite
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
public static TestSuite suite() throws Exception {
return MapTestSuiteBuilder.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Map.Entry<String, String>[] entries) {
ParetoLinkedHashMap m = new ParetoLinkedHashMap();
//
for (Map.Entry<String, String> entry : entries) {
m.put(entry.getKey(), entry.getValue());
}
return m;
}
}).named("ParetoHashMap")
.withFeatures(MapFeature.GENERAL_PURPOSE, CollectionSize.ANY, MapFeature.ALLOWS_NULL_KEYS, MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_VALUES)
.createTestSuite();
}
示例11: createDerivedSuites
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
@Override
protected List<TestSuite> createDerivedSuites(
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<M, Entry<K, V>>>
parentBuilder) {
// TODO: Once invariant support is added, supply invariants to each of the
// derived suites, to check that mutations to the derived collections are
// reflected in the underlying map.
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
derivedSuites.add(
MultimapTestSuiteBuilder.using(
new ReserializedMultimapGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
.suppressing(parentBuilder.getSuppressedTests())
.createTestSuite());
}
derivedSuites.add(
MapTestSuiteBuilder.using(new AsMapGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeAsMapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".asMap")
.suppressing(parentBuilder.getSuppressedTests())
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
derivedSuites.add(computeKeysTestSuite(parentBuilder));
derivedSuites.add(computeValuesTestSuite(parentBuilder));
return derivedSuites;
}
示例12: createDerivedSuites
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
@Override
protected List<TestSuite> createDerivedSuites(
FeatureSpecificTestSuiteBuilder<
?, ? extends OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>>>
parentBuilder) {
List<TestSuite> derived = super.createDerivedSuites(parentBuilder);
// TODO(cpovirk): consider using this approach (derived suites instead of extension) in
// ListTestSuiteBuilder, etc.?
derived.add(
MapTestSuiteBuilder.using(new MapGenerator<K, V>(parentBuilder.getSubjectGenerator()))
.withFeatures(parentBuilder.getFeatures())
.named(parentBuilder.getName() + " [Map]")
.suppressing(parentBuilder.getSuppressedTests())
.suppressing(SetCreationTester.class.getMethods())
// BiMap.entrySet() duplicate-handling behavior is too confusing for SetCreationTester
.createTestSuite());
/*
* TODO(cpovirk): the Map tests duplicate most of this effort by using a
* CollectionTestSuiteBuilder on values(). It would be nice to avoid that
*/
derived.add(
SetTestSuiteBuilder.using(
new BiMapValueSetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeValuesSetFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " values [Set]")
.suppressing(parentBuilder.getSuppressedTests())
.suppressing(SetCreationTester.class.getMethods())
// BiMap.values() duplicate-handling behavior is too confusing for SetCreationTester
.createTestSuite());
if (!parentBuilder.getFeatures().contains(NoRecurse.INVERSE)) {
derived.add(
BiMapTestSuiteBuilder.using(
new InverseBiMapGenerator<K, V>(parentBuilder.getSubjectGenerator()))
.withFeatures(computeInverseFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " inverse")
.suppressing(parentBuilder.getSuppressedTests())
.createTestSuite());
}
return derived;
}
示例13: computeCommonDerivedCollectionFeatures
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
private static Set<Feature<?>> computeCommonDerivedCollectionFeatures(
Set<Feature<?>> mapFeatures) {
return MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
}
示例14: configureSuite
import com.google.common.collect.testing.MapTestSuiteBuilder; //导入依赖的package包/类
private static void configureSuite(MapTestSuiteBuilder<String, String> suite) {
suite.withFeatures(GENERAL_PURPOSE)
.withFeatures(CollectionSize.ANY)
.withFeatures(CollectionFeature.REMOVE_OPERATIONS)
.withFeatures(RESTRICTS_KEYS, RESTRICTS_VALUES);
}