test/jdk/java/net/httpclient/whitebox/java.net.http/java/net/http/internal/common/MinimalFutureTest.java
author chegar
Wed, 07 Feb 2018 14:17:24 +0000
branchhttp-client-branch
changeset 56089 42208b2f224e
parent 56035 test/jdk/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/internal/common/MinimalFutureTest.java@2f3f5da13c4c
permissions -rw-r--r--
http-client-branch: move to standard package and module name
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56035
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     1
/*
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     4
 *
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     8
 *
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    13
 * accompanied this code).
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    14
 *
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    18
 *
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    21
 * questions.
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    22
 */
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    23
56089
42208b2f224e http-client-branch: move to standard package and module name
chegar
parents: 56035
diff changeset
    24
package java.net.http.internal.common;
56035
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    25
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    26
import org.testng.annotations.DataProvider;
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    27
import org.testng.annotations.Test;
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    28
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    29
import java.util.concurrent.CompletableFuture;
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    30
import java.util.concurrent.CompletionException;
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    31
import java.util.concurrent.ExecutorService;
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    32
import java.util.concurrent.Executors;
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    33
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    34
import static org.testng.Assert.assertThrows;
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    35
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    36
public class MinimalFutureTest {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    37
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    38
    @Test(dataProvider = "futures")
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    39
    public void test(CompletableFuture<Object> mf) {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    40
        ExecutorService executor = Executors.newSingleThreadExecutor();
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    41
        try {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    42
            assertNoObtrusion(mf.thenApply(MinimalFutureTest::apply));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    43
            assertNoObtrusion(mf.thenApplyAsync(MinimalFutureTest::apply));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    44
            assertNoObtrusion(mf.thenApplyAsync(MinimalFutureTest::apply, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    45
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    46
            assertNoObtrusion(mf.thenAccept(MinimalFutureTest::accept));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    47
            assertNoObtrusion(mf.thenAcceptAsync(MinimalFutureTest::accept));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    48
            assertNoObtrusion(mf.thenAcceptAsync(MinimalFutureTest::accept, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    49
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    50
            assertNoObtrusion(mf.thenRun(MinimalFutureTest::run));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    51
            assertNoObtrusion(mf.thenRunAsync(MinimalFutureTest::run));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    52
            assertNoObtrusion(mf.thenRunAsync(MinimalFutureTest::run, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    53
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    54
            assertNoObtrusion(mf.thenCombine(otherFuture(), MinimalFutureTest::apply));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    55
            assertNoObtrusion(mf.thenCombineAsync(otherFuture(), MinimalFutureTest::apply));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    56
            assertNoObtrusion(mf.thenCombineAsync(otherFuture(), MinimalFutureTest::apply, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    57
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    58
            assertNoObtrusion(mf.thenAcceptBoth(otherFuture(), MinimalFutureTest::accept));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    59
            assertNoObtrusion(mf.thenAcceptBothAsync(otherFuture(), MinimalFutureTest::accept));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    60
            assertNoObtrusion(mf.thenAcceptBothAsync(otherFuture(), MinimalFutureTest::accept, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    61
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    62
            assertNoObtrusion(mf.runAfterBoth(otherFuture(), MinimalFutureTest::run));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    63
            assertNoObtrusion(mf.runAfterBothAsync(otherFuture(), MinimalFutureTest::run));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    64
            assertNoObtrusion(mf.runAfterBothAsync(otherFuture(), MinimalFutureTest::run, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    65
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    66
            // "either" methods may return something else if otherFuture() is
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    67
            // not MinimalFuture
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    68
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    69
            assertNoObtrusion(mf.applyToEither(otherFuture(), MinimalFutureTest::apply));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    70
            assertNoObtrusion(mf.applyToEitherAsync(otherFuture(), MinimalFutureTest::apply));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    71
            assertNoObtrusion(mf.applyToEitherAsync(otherFuture(), MinimalFutureTest::apply, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    72
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    73
            assertNoObtrusion(mf.acceptEither(otherFuture(), MinimalFutureTest::accept));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    74
            assertNoObtrusion(mf.acceptEitherAsync(otherFuture(), MinimalFutureTest::accept));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    75
            assertNoObtrusion(mf.acceptEitherAsync(otherFuture(), MinimalFutureTest::accept, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    76
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    77
            assertNoObtrusion(mf.runAfterEither(otherFuture(), MinimalFutureTest::run));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    78
            assertNoObtrusion(mf.runAfterEitherAsync(otherFuture(), MinimalFutureTest::run));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    79
            assertNoObtrusion(mf.runAfterEitherAsync(otherFuture(), MinimalFutureTest::run, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    80
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    81
            assertNoObtrusion(mf.thenCompose(MinimalFutureTest::completionStageOf));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    82
            assertNoObtrusion(mf.thenComposeAsync(MinimalFutureTest::completionStageOf));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    83
            assertNoObtrusion(mf.thenComposeAsync(MinimalFutureTest::completionStageOf, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    84
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    85
            assertNoObtrusion(mf.handle(MinimalFutureTest::relay));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    86
            assertNoObtrusion(mf.handleAsync(MinimalFutureTest::relay));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    87
            assertNoObtrusion(mf.handleAsync(MinimalFutureTest::relay, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    88
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    89
            assertNoObtrusion(mf.whenComplete(MinimalFutureTest::accept));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    90
            assertNoObtrusion(mf.whenCompleteAsync(MinimalFutureTest::accept));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    91
            assertNoObtrusion(mf.whenCompleteAsync(MinimalFutureTest::accept, executor));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    92
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    93
            assertNoObtrusion(mf.toCompletableFuture());
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    94
            assertNoObtrusion(mf.exceptionally(t -> null));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    95
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    96
            assertNoObtrusion(mf);
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    97
            assertNoObtrusion(mf.copy());
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    98
            assertNoObtrusion(mf.newIncompleteFuture());
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
    99
        } finally {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   100
            executor.shutdownNow();
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   101
        }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   102
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   103
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   104
    private static CompletableFuture<Object> otherFuture() {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   105
        return MinimalFuture.completedFuture(new Object());
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   106
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   107
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   108
    private static Object relay(Object r, Throwable e) {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   109
        if (e != null)
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   110
            throw new CompletionException(e);
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   111
        else
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   112
            return r;
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   113
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   114
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   115
    private static CompletableFuture<?> completionStageOf(Object r) {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   116
        return new CompletableFuture<>();
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   117
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   118
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   119
    private static void accept(Object arg) {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   120
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   121
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   122
    private static void accept(Object arg1, Object arg2) {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   123
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   124
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   125
    private static void run() {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   126
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   127
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   128
    private static Object apply(Object arg) {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   129
        return new Object();
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   130
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   131
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   132
    private static Object apply(Object arg1, Object arg2) {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   133
        return new Object();
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   134
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   135
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   136
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   137
    @DataProvider(name = "futures")
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   138
    public Object[][] futures() {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   139
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   140
        MinimalFuture<Object> mf = new MinimalFuture<>();
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   141
        mf.completeExceptionally(new Throwable());
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   142
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   143
        MinimalFuture<Object> mf1 = new MinimalFuture<>();
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   144
        mf1.complete(new Object());
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   145
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   146
        return new Object[][]{
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   147
                new Object[]{new MinimalFuture<>()},
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   148
                new Object[]{MinimalFuture.failedFuture(new Throwable())},
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   149
                new Object[]{MinimalFuture.completedFuture(new Object())},
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   150
                new Object[]{mf},
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   151
                new Object[]{mf1},
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   152
        };
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   153
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   154
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   155
    private void assertNoObtrusion(CompletableFuture<?> cf) {
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   156
        assertThrows(UnsupportedOperationException.class,
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   157
                     () -> cf.obtrudeValue(null));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   158
        assertThrows(UnsupportedOperationException.class,
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   159
                     () -> cf.obtrudeException(new RuntimeException()));
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   160
    }
2f3f5da13c4c http-client-branch: MinimalFuture deep obtrusion
prappo
parents:
diff changeset
   161
}