当前位置: 首页>>代码示例>>Java>>正文


Java SubmissionPublisher.closeExceptionally方法代码示例

本文整理汇总了Java中java.util.concurrent.SubmissionPublisher.closeExceptionally方法的典型用法代码示例。如果您正苦于以下问题:Java SubmissionPublisher.closeExceptionally方法的具体用法?Java SubmissionPublisher.closeExceptionally怎么用?Java SubmissionPublisher.closeExceptionally使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.SubmissionPublisher的用法示例。


在下文中一共展示了SubmissionPublisher.closeExceptionally方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClose

import java.util.concurrent.SubmissionPublisher; //导入方法依赖的package包/类
/**
 * A closed publisher reports isClosed with no closedException and
 * throws IllegalStateException upon attempted submission; a
 * subsequent close or closeExceptionally has no additional
 * effect.
 */
public void testClose() {
    SubmissionPublisher<Integer> p = basicPublisher();
    checkInitialState(p);
    p.close();
    assertTrue(p.isClosed());
    assertNull(p.getClosedException());
    try {
        p.submit(1);
        shouldThrow();
    } catch (IllegalStateException success) {}
    Throwable ex = new SPException();
    p.closeExceptionally(ex);
    assertTrue(p.isClosed());
    assertNull(p.getClosedException());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SubmissionPublisherTest.java

示例2: testCloseExceptionally

import java.util.concurrent.SubmissionPublisher; //导入方法依赖的package包/类
/**
 * A publisher closedExceptionally reports isClosed with the
 * closedException and throws IllegalStateException upon attempted
 * submission; a subsequent close or closeExceptionally has no
 * additional effect.
 */
public void testCloseExceptionally() {
    SubmissionPublisher<Integer> p = basicPublisher();
    checkInitialState(p);
    Throwable ex = new SPException();
    p.closeExceptionally(ex);
    assertTrue(p.isClosed());
    assertSame(p.getClosedException(), ex);
    try {
        p.submit(1);
        shouldThrow();
    } catch (IllegalStateException success) {}
    p.close();
    assertTrue(p.isClosed());
    assertSame(p.getClosedException(), ex);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SubmissionPublisherTest.java

示例3: testCloseExceptionallyError

import java.util.concurrent.SubmissionPublisher; //导入方法依赖的package包/类
/**
 * Closing a publisher exceptionally causes onError to subscribers
 * after they are subscribed
 */
public void testCloseExceptionallyError() {
    SubmissionPublisher<Integer> p = basicPublisher();
    TestSubscriber s1 = new TestSubscriber();
    TestSubscriber s2 = new TestSubscriber();
    p.subscribe(s1);
    p.subscribe(s2);
    p.submit(1);
    p.closeExceptionally(new SPException());
    assertTrue(p.isClosed());
    s1.awaitSubscribe();
    s1.awaitError();
    assertTrue(s1.nexts <= 1);
    assertEquals(1, s1.errors);
    s2.awaitSubscribe();
    s2.awaitError();
    assertTrue(s2.nexts <= 1);
    assertEquals(1, s2.errors);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:SubmissionPublisherTest.java

示例4: testClose

import java.util.concurrent.SubmissionPublisher; //导入方法依赖的package包/类
/**
 * A closed publisher reports isClosed with no closedException and
 * throws ISE upon attempted submission; a subsequent close or
 * closeExceptionally has no additional effect.
 */
public void testClose() {
    SubmissionPublisher<Integer> p = basicPublisher();
    checkInitialState(p);
    p.close();
    assertTrue(p.isClosed());
    assertNull(p.getClosedException());
    try {
        p.submit(1);
        shouldThrow();
    } catch (IllegalStateException success) {}
    Throwable ex = new SPException();
    p.closeExceptionally(ex);
    assertTrue(p.isClosed());
    assertNull(p.getClosedException());
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:21,代码来源:SubmissionPublisherTest.java

示例5: testCloseExceptionally

import java.util.concurrent.SubmissionPublisher; //导入方法依赖的package包/类
/**
 * A publisher closedExceptionally reports isClosed with the
 * closedException and throws ISE upon attempted submission; a
 * subsequent close or closeExceptionally has no additional
 * effect.
 */
public void testCloseExceptionally() {
    SubmissionPublisher<Integer> p = basicPublisher();
    checkInitialState(p);
    Throwable ex = new SPException();
    p.closeExceptionally(ex);
    assertTrue(p.isClosed());
    assertSame(p.getClosedException(), ex);
    try {
        p.submit(1);
        shouldThrow();
    } catch (IllegalStateException success) {}
    p.close();
    assertTrue(p.isClosed());
    assertSame(p.getClosedException(), ex);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:22,代码来源:SubmissionPublisherTest.java

示例6: testCloseExceptionallyError

import java.util.concurrent.SubmissionPublisher; //导入方法依赖的package包/类
/**
 * Closing a publisher exceptionally causes onError to subscribers
 */
public void testCloseExceptionallyError() {
    SubmissionPublisher<Integer> p = basicPublisher();
    TestSubscriber s1 = new TestSubscriber();
    TestSubscriber s2 = new TestSubscriber();
    p.subscribe(s1);
    p.subscribe(s2);
    p.submit(1);
    p.closeExceptionally(new SPException());
    assertTrue(p.isClosed());
    s1.awaitError();
    assertTrue(s1.nexts <= 1);
    assertEquals(1, s1.errors);
    s2.awaitError();
    assertTrue(s2.nexts <= 1);
    assertEquals(1, s2.errors);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:20,代码来源:SubmissionPublisherTest.java

示例7: testSubscribe3

import java.util.concurrent.SubmissionPublisher; //导入方法依赖的package包/类
/**
 * If closedExceptionally, upon subscription, the subscriber's
 * onError method is invoked
 */
public void testSubscribe3() {
    TestSubscriber s = new TestSubscriber();
    SubmissionPublisher<Integer> p = basicPublisher();
    Throwable ex = new SPException();
    p.closeExceptionally(ex);
    assertTrue(p.isClosed());
    assertSame(p.getClosedException(), ex);
    p.subscribe(s);
    s.awaitError();
    assertEquals(0, s.nexts);
    assertEquals(1, s.errors);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SubmissionPublisherTest.java

示例8: flowToFlowableError

import java.util.concurrent.SubmissionPublisher; //导入方法依赖的package包/类
@Test
public void flowToFlowableError() throws Exception {

    SubmissionPublisher<Integer> sp = new SubmissionPublisher<>();

    TestSubscriber<Integer> ts = FlowInterop.fromFlowPublisher(sp)
            .test();

    sp.submit(1);
    sp.submit(2);
    sp.submit(3);
    sp.submit(4);
    sp.submit(5);

    Thread.sleep(1000); // JDK bug workaround, otherwise no onSubscribe is called

    sp.closeExceptionally(new IOException());


    ts.awaitDone(5, TimeUnit.SECONDS)
            .assertFailure(IOException.class, 1, 2, 3, 4, 5);
}
 
开发者ID:akarnokd,项目名称:RxJava2Jdk9Interop,代码行数:23,代码来源:FlowInteropTest.java


注:本文中的java.util.concurrent.SubmissionPublisher.closeExceptionally方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。