本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}