Search in sources :

Example 56 with GwtIncompatible

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

the class ObjectArraysTest method testNullPointerExceptions.

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

Example 57 with GwtIncompatible

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

the class BaseEncodingTest method testStreamingEncodes.

// Writer
@GwtIncompatible
private static void testStreamingEncodes(BaseEncoding encoding, String decoded, String encoded) throws IOException {
    StringWriter writer = new StringWriter();
    OutputStream encodingStream = encoding.encodingStream(writer);
    encodingStream.write(decoded.getBytes(UTF_8));
    encodingStream.close();
    assertThat(writer.toString()).isEqualTo(encoded);
}
Also used : StringWriter(java.io.StringWriter) OutputStream(java.io.OutputStream) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 58 with GwtIncompatible

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

the class BaseEncodingTest method testStreamingDecodes.

// Reader
@GwtIncompatible
private static void testStreamingDecodes(BaseEncoding encoding, String encoded, String decoded) throws IOException {
    byte[] bytes = decoded.getBytes(UTF_8);
    InputStream decodingStream = encoding.decodingStream(new StringReader(encoded));
    for (int i = 0; i < bytes.length; i++) {
        assertThat(decodingStream.read()).isEqualTo(bytes[i] & 0xFF);
    }
    assertThat(decodingStream.read()).isEqualTo(-1);
    decodingStream.close();
}
Also used : InputStream(java.io.InputStream) StringReader(java.io.StringReader) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 59 with GwtIncompatible

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

the class TreeMultisetTest method suite.

// suite
@GwtIncompatible
public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(SortedMultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {

        @Override
        protected Multiset<String> create(String[] elements) {
            return TreeMultiset.create(Arrays.asList(elements));
        }

        @Override
        public List<String> order(List<String> insertionOrder) {
            return Ordering.natural().sortedCopy(insertionOrder);
        }
    }).withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES, MultisetFeature.ENTRIES_ARE_VIEWS).named("TreeMultiset, Ordering.natural").createTestSuite());
    suite.addTest(SortedMultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {

        @Override
        protected Multiset<String> create(String[] elements) {
            Multiset<String> result = TreeMultiset.create(NullsBeforeB.INSTANCE);
            Collections.addAll(result, elements);
            return result;
        }

        @Override
        public List<String> order(List<String> insertionOrder) {
            sort(insertionOrder, NullsBeforeB.INSTANCE);
            return insertionOrder;
        }
    }).withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES, MultisetFeature.ENTRIES_ARE_VIEWS).named("TreeMultiset, NullsBeforeB").createTestSuite());
    suite.addTest(NavigableSetTestSuiteBuilder.using(new TestStringSetGenerator() {

        @Override
        protected Set<String> create(String[] elements) {
            return TreeMultiset.create(Arrays.asList(elements)).elementSet();
        }

        @Override
        public List<String> order(List<String> insertionOrder) {
            return Lists.newArrayList(Sets.newTreeSet(insertionOrder));
        }
    }).named("TreeMultiset[Ordering.natural].elementSet").withFeatures(CollectionSize.ANY, CollectionFeature.REMOVE_OPERATIONS, CollectionFeature.ALLOWS_NULL_QUERIES).createTestSuite());
    suite.addTestSuite(TreeMultisetTest.class);
    return suite;
}
Also used : TestStringSetGenerator(com.google.common.collect.testing.TestStringSetGenerator) SortedSet(java.util.SortedSet) Set(java.util.Set) TestSuite(junit.framework.TestSuite) TestStringMultisetGenerator(com.google.common.collect.testing.google.TestStringMultisetGenerator) List(java.util.List) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 60 with GwtIncompatible

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

the class FuturesTest method testScheduleAsync_asyncCallable_error.

// threads
@GwtIncompatible
public void testScheduleAsync_asyncCallable_error() throws InterruptedException {
    final Error error = new Error("deliberate");
    AsyncCallable<Integer> callable = new AsyncCallable<Integer>() {

        @Override
        public ListenableFuture<Integer> call() {
            throw error;
        }
    };
    SettableFuture<String> inputFuture = SettableFuture.create();
    ListenableFuture<Integer> outputFuture = submitAsync(callable, directExecutor());
    inputFuture.set("value");
    try {
        getDone(outputFuture);
        fail();
    } catch (ExecutionException expected) {
        assertSame(error, expected.getCause());
    }
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) 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