Skip to content

Commit

Permalink
Make nonCancellationPropagating available to GWT.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131285023
  • Loading branch information
cpovirk committed Aug 25, 2016
1 parent 5ebbc98 commit 3208687
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 6 deletions.
108 changes: 108 additions & 0 deletions guava-gwt/test/com/google/common/util/concurrent/FuturesTest_gwt.java
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,114 @@ public void testImmediateFuture() throws Exception {
}
}

public void testNonCancellationPropagating_delegateCancelled() throws Exception {
com.google.common.util.concurrent.FuturesTest testCase = new com.google.common.util.concurrent.FuturesTest();
testCase.setUp();
Throwable failure = null;
try {
testCase.testNonCancellationPropagating_delegateCancelled();
} catch (Throwable t) {
failure = t;
}
try {
testCase.tearDown();
} catch (Throwable t) {
if (failure == null) {
failure = t;
}
}
if (failure instanceof Exception) {
throw (Exception) failure;
}
if (failure instanceof Error) {
throw (Error) failure;
}
if (failure != null) {
throw new RuntimeException(failure);
}
}

public void testNonCancellationPropagating_doesNotPropagate() throws Exception {
com.google.common.util.concurrent.FuturesTest testCase = new com.google.common.util.concurrent.FuturesTest();
testCase.setUp();
Throwable failure = null;
try {
testCase.testNonCancellationPropagating_doesNotPropagate();
} catch (Throwable t) {
failure = t;
}
try {
testCase.tearDown();
} catch (Throwable t) {
if (failure == null) {
failure = t;
}
}
if (failure instanceof Exception) {
throw (Exception) failure;
}
if (failure instanceof Error) {
throw (Error) failure;
}
if (failure != null) {
throw new RuntimeException(failure);
}
}

public void testNonCancellationPropagating_failure() throws Exception {
com.google.common.util.concurrent.FuturesTest testCase = new com.google.common.util.concurrent.FuturesTest();
testCase.setUp();
Throwable failure = null;
try {
testCase.testNonCancellationPropagating_failure();
} catch (Throwable t) {
failure = t;
}
try {
testCase.tearDown();
} catch (Throwable t) {
if (failure == null) {
failure = t;
}
}
if (failure instanceof Exception) {
throw (Exception) failure;
}
if (failure instanceof Error) {
throw (Error) failure;
}
if (failure != null) {
throw new RuntimeException(failure);
}
}

public void testNonCancellationPropagating_successful() throws Exception {
com.google.common.util.concurrent.FuturesTest testCase = new com.google.common.util.concurrent.FuturesTest();
testCase.setUp();
Throwable failure = null;
try {
testCase.testNonCancellationPropagating_successful();
} catch (Throwable t) {
failure = t;
}
try {
testCase.tearDown();
} catch (Throwable t) {
if (failure == null) {
failure = t;
}
}
if (failure instanceof Exception) {
throw (Exception) failure;
}
if (failure instanceof Error) {
throw (Error) failure;
}
if (failure != null) {
throw new RuntimeException(failure);
}
}

public void testSuccessfulAsList() throws Exception {
com.google.common.util.concurrent.FuturesTest testCase = new com.google.common.util.concurrent.FuturesTest();
testCase.setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3002,7 +3002,6 @@ public void testSuccessfulAsList_logging_error() throws Exception {
assertThat(logged.get(0).getThrown()).isInstanceOf(MyError.class);
}

@GwtIncompatible // nonCancellationPropagating
public void testNonCancellationPropagating_successful() throws Exception {
SettableFuture<Foo> input = SettableFuture.create();
ListenableFuture<Foo> wrapper = nonCancellationPropagating(input);
Expand All @@ -3014,7 +3013,6 @@ public void testNonCancellationPropagating_successful() throws Exception {
assertSame(foo, getDone(wrapper));
}

@GwtIncompatible // nonCancellationPropagating
public void testNonCancellationPropagating_failure() throws Exception {
SettableFuture<Foo> input = SettableFuture.create();
ListenableFuture<Foo> wrapper = nonCancellationPropagating(input);
Expand All @@ -3030,7 +3028,6 @@ public void testNonCancellationPropagating_failure() throws Exception {
}
}

@GwtIncompatible // nonCancellationPropagating
public void testNonCancellationPropagating_delegateCancelled() throws Exception {
SettableFuture<Foo> input = SettableFuture.create();
ListenableFuture<Foo> wrapper = nonCancellationPropagating(input);
Expand All @@ -3040,7 +3037,6 @@ public void testNonCancellationPropagating_delegateCancelled() throws Exception
assertTrue(wrapper.isCancelled());
}

@GwtIncompatible // nonCancellationPropagating
public void testNonCancellationPropagating_doesNotPropagate() throws Exception {
SettableFuture<Foo> input = SettableFuture.create();
ListenableFuture<Foo> wrapper = nonCancellationPropagating(input);
Expand Down
2 changes: 0 additions & 2 deletions guava/src/com/google/common/util/concurrent/Futures.java
Original file line number Diff line number Diff line change
Expand Up @@ -929,15 +929,13 @@ public <C> ListenableFuture<C> call(Callable<C> combiner) {
*
* @since 15.0
*/
@GwtIncompatible // TODO
public static <V> ListenableFuture<V> nonCancellationPropagating(ListenableFuture<V> future) {
return new NonCancellationPropagatingFuture<V>(future);
}

/**
* A wrapped future that does not propagate cancellation to its delegate.
*/
@GwtIncompatible // TODO
private static final class NonCancellationPropagatingFuture<V>
extends AbstractFuture.TrustedFuture<V> {
NonCancellationPropagatingFuture(final ListenableFuture<V> delegate) {
Expand Down

0 comments on commit 3208687

Please sign in to comment.