public void testPrimitiveChannelCloseException() throws Exception {
assumeThat(mailboxSize, not(equalTo(0)));
final IntChannel ch = Channels.newIntChannel(mailboxSize, policy);
Fiber fib = new Fiber("fiber", scheduler, new SuspendableRunnable() {
@Override
public void run() throws SuspendExecution, InterruptedException {
try {
for (int i = 1; i <= 5; i++) {
int m = ch.receiveInt();
assertThat(m, is(i));
}
} catch (QueueChannel.EOFException e) {
fail();
}
try {
int m = ch.receiveInt();
fail("m = " + m);
} catch (ProducerException e) {
assertThat(e.getCause().getMessage(), equalTo("foo"));
} catch(ReceivePort.EOFException e) {
fail();
}
assertTrue(ch.isClosed());
}
}).start();
Thread.sleep(50);
ch.send(1);
ch.send(2);
ch.send(3);
ch.send(4);
ch.send(5);
ch.close(new Exception("foo"));
ch.send(6);
ch.send(7);
fib.join();
}