List of usage examples for io.netty.channel DefaultChannelPromise cancel
@Override boolean cancel(boolean mayInterruptIfRunning);
From source file:com.github.milenkovicm.kafka.KafkaTopic.java
License:Apache License
private DefaultChannelPromise getDefaultChannelPromise() { final DefaultChannelPromise channelPromise = new DefaultChannelPromise(null, GlobalEventExecutor.INSTANCE); channelPromise.cancel(true); return channelPromise; }
From source file:com.github.spapageo.jannel.client.ClientSessionTest.java
License:Open Source License
@Test(expected = CancellationException.class) public void testSendSmsReturnsFailedFutureWhenWriteIsCancelled() throws Exception { DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next()); promise.cancel(true); when(channel.writeAndFlush(any())).thenReturn(promise); Sms sms = new Sms(); sms.setId(UUID.randomUUID()); sms.setBoxId("test box"); WindowFuture<Sms, Ack> future = clientSession.sendSms(sms, 5000); Futures.getUnchecked(future);/* www .j a va2 s. co m*/ }
From source file:com.github.spapageo.jannel.client.ClientSessionTest.java
License:Open Source License
@Test(expected = CancellationException.class) public void testSendSmsAndWaitThrowsWhenWriteIsCancelled() throws Exception { DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next()); promise.cancel(true); when(channel.writeAndFlush(any())).thenReturn(promise); Sms sms = new Sms(); sms.setId(UUID.randomUUID()); sms.setBoxId("test box"); clientSession.sendSmsAndWait(sms, 5000); }