Search in sources :

Example 31 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class ImmutableMapTest method ignore_testSerializationNoDuplication_jdkBackedImmutableMap.

// TODO: Re-enable this test after moving to new serialization format in ImmutableMap.
// SerializableTester
@GwtIncompatible
@SuppressWarnings("unchecked")
public void ignore_testSerializationNoDuplication_jdkBackedImmutableMap() throws Exception {
    // Tests that searializing a map, its keySet, and values only writes
    // the underlying data once.
    Entry<Integer, Integer>[] entries = (Entry<Integer, Integer>[]) new Entry<?, ?>[1000];
    for (int i = 0; i < 1000; i++) {
        entries[i] = ImmutableMap.entryOf(i, i);
    }
    ImmutableMap<Integer, Integer> map = JdkBackedImmutableMap.create(entries.length, entries, /* throwIfDuplicateKeys= */
    true);
    Set<Integer> keySet = map.keySet();
    Collection<Integer> values = map.values();
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bytes);
    oos.writeObject(map);
    oos.flush();
    int mapSize = bytes.size();
    oos.writeObject(keySet);
    oos.writeObject(values);
    oos.close();
    int finalSize = bytes.size();
    assertThat(finalSize - mapSize).isLessThan(100);
}
Also used : Entry(java.util.Map.Entry) Helpers.mapEntry(com.google.common.collect.testing.Helpers.mapEntry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 32 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class ImmutableMapTest method ignore_testSerializationNoDuplication_regularImmutableMap.

// TODO: Re-enable this test after moving to new serialization format in ImmutableMap.
// SerializableTester
@GwtIncompatible
@SuppressWarnings("unchecked")
public void ignore_testSerializationNoDuplication_regularImmutableMap() throws Exception {
    // Tests that searializing a map, its keySet, and values only writes the underlying data once.
    Entry<Integer, Integer>[] entries = (Entry<Integer, Integer>[]) new Entry<?, ?>[1000];
    for (int i = 0; i < 1000; i++) {
        entries[i] = ImmutableMap.entryOf(i, i);
    }
    ImmutableMap<Integer, Integer> map = RegularImmutableMap.fromEntries(entries);
    Set<Integer> keySet = map.keySet();
    Collection<Integer> values = map.values();
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bytes);
    oos.writeObject(map);
    oos.flush();
    int mapSize = bytes.size();
    oos.writeObject(keySet);
    oos.writeObject(values);
    oos.close();
    int finalSize = bytes.size();
    assertThat(finalSize - mapSize).isLessThan(100);
}
Also used : Entry(java.util.Map.Entry) Helpers.mapEntry(com.google.common.collect.testing.Helpers.mapEntry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 33 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class ImmutableSetTest method suite.

// suite
@GwtIncompatible
public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(SetTestSuiteBuilder.using(new ImmutableSetCopyOfGenerator()).named(ImmutableSetTest.class.getName()).withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTest(SetTestSuiteBuilder.using(new ImmutableSetUnsizedBuilderGenerator()).named(ImmutableSetTest.class.getName() + ", with unsized builder").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {

        @Override
        protected Set<String> create(String[] elements) {
            ImmutableSet.Builder<String> builder = ImmutableSet.builder();
            builder.forceJdk();
            builder.add(elements);
            return builder.build();
        }
    }).named(ImmutableSetTest.class.getName() + ", with JDK builder").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTest(SetTestSuiteBuilder.using(new ImmutableSetSizedBuilderGenerator()).named(ImmutableSetTest.class.getName() + ", with exactly sized builder").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTest(SetTestSuiteBuilder.using(new ImmutableSetTooBigBuilderGenerator()).named(ImmutableSetTest.class.getName() + ", with oversized builder").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTest(SetTestSuiteBuilder.using(new ImmutableSetTooSmallBuilderGenerator()).named(ImmutableSetTest.class.getName() + ", with undersized builder").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTest(SetTestSuiteBuilder.using(new ImmutableSetWithBadHashesGenerator()).named(ImmutableSetTest.class.getName() + ", with bad hashes").withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTest(SetTestSuiteBuilder.using(new DegeneratedImmutableSetGenerator()).named(ImmutableSetTest.class.getName() + ", degenerate").withFeatures(CollectionSize.ONE, CollectionFeature.KNOWN_ORDER, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTest(ListTestSuiteBuilder.using(new ImmutableSetAsListGenerator()).named("ImmutableSet.asList").withFeatures(CollectionSize.ANY, CollectionFeature.REJECTS_DUPLICATES_AT_CREATION, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTestSuite(ImmutableSetTest.class);
    suite.addTestSuite(FloodingTest.class);
    return suite;
}
Also used : ImmutableSetUnsizedBuilderGenerator(com.google.common.collect.testing.google.SetGenerators.ImmutableSetUnsizedBuilderGenerator) Set(java.util.Set) Builder(com.google.common.collect.ImmutableSet.Builder) ListTestSuiteBuilder(com.google.common.collect.testing.ListTestSuiteBuilder) SetTestSuiteBuilder(com.google.common.collect.testing.SetTestSuiteBuilder) ImmutableSetTooBigBuilderGenerator(com.google.common.collect.testing.google.SetGenerators.ImmutableSetTooBigBuilderGenerator) ImmutableSetCopyOfGenerator(com.google.common.collect.testing.google.SetGenerators.ImmutableSetCopyOfGenerator) DegeneratedImmutableSetGenerator(com.google.common.collect.testing.google.SetGenerators.DegeneratedImmutableSetGenerator) ImmutableSetAsListGenerator(com.google.common.collect.testing.google.SetGenerators.ImmutableSetAsListGenerator) TestStringSetGenerator(com.google.common.collect.testing.TestStringSetGenerator) TestSuite(junit.framework.TestSuite) ImmutableSetWithBadHashesGenerator(com.google.common.collect.testing.google.SetGenerators.ImmutableSetWithBadHashesGenerator) ImmutableSetSizedBuilderGenerator(com.google.common.collect.testing.google.SetGenerators.ImmutableSetSizedBuilderGenerator) ImmutableSetTooSmallBuilderGenerator(com.google.common.collect.testing.google.SetGenerators.ImmutableSetTooSmallBuilderGenerator) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 34 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class IteratorsTest method testNullPointerExceptions.

// NullPointerTester
@GwtIncompatible
public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(Iterators.class);
}
Also used : NullPointerTester(com.google.common.testing.NullPointerTester) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 35 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class EvictingQueueTest method testNullPointerExceptions.

// NullPointerTester
@GwtIncompatible
public void testNullPointerExceptions() {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicStaticMethods(EvictingQueue.class);
    tester.testAllPublicConstructors(EvictingQueue.class);
    EvictingQueue<String> queue = EvictingQueue.create(5);
    // The queue must be non-empty so it throws a NPE correctly
    queue.add("one");
    tester.testAllPublicInstanceMethods(queue);
}
Also used : NullPointerTester(com.google.common.testing.NullPointerTester) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Aggregations

GwtIncompatible (com.google.common.annotations.GwtIncompatible)361 NullPointerTester (com.google.common.testing.NullPointerTester)105 TestSuite (junit.framework.TestSuite)54 BigInteger (java.math.BigInteger)40 RoundingMode (java.math.RoundingMode)39 CountDownLatch (java.util.concurrent.CountDownLatch)25 ExecutorService (java.util.concurrent.ExecutorService)18 CancellationException (java.util.concurrent.CancellationException)17 Random (java.util.Random)16 ListTestSuiteBuilder (com.google.common.collect.testing.ListTestSuiteBuilder)15 ExecutionException (java.util.concurrent.ExecutionException)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)15 IOException (java.io.IOException)14 BigDecimal (java.math.BigDecimal)14 TestStringSetGenerator (com.google.common.collect.testing.TestStringSetGenerator)11 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)11 TimeoutException (java.util.concurrent.TimeoutException)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 EqualsTester (com.google.common.testing.EqualsTester)10 List (java.util.List)10