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


Java DefaultChannelPromise.setSuccess方法代码示例

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


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

示例1: testDestroysClosesChannelAndDestroysTheWindow

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testDestroysClosesChannelAndDestroysTheWindow() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.isActive()).thenReturn(false);
    when(channel.close()).thenReturn(promise);

    WindowFuture windowFuture = clientSession.getWindow().offer(UUID.randomUUID(), new Sms(), 5000);
    clientSession.destroy();

    verify(channel, times(0)).close();
    assertNull("Session handler must be null after destruction", clientSession.getSessionHandler());
    assertTrue("The outstanding requests should be canceled", windowFuture.isCancelled());

}
 
开发者ID:spapageo,项目名称:jannel,代码行数:17,代码来源:ClientSessionTest.java

示例2: testSendSmsReturnsFailedFutureWhenOfferToWindowFails

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test(expected = DuplicateKeyException.class)
public void testSendSmsReturnsFailedFutureWhenOfferToWindowFails() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.writeAndFlush(any())).thenReturn(promise);

    Sms sms = new Sms();
    sms.setId(UUID.randomUUID());
    sms.setBoxId("test box");

    //add the sms so the next offer fails
    clientSession.getWindow().offer(sms.getId(), sms, 5000);

    WindowFuture<Sms, Ack> future = clientSession.sendSms(sms, 5000);
    assertFalse(future.isCancelled());

    assertSame(sms, future.getRequest());

    Futures.getChecked(future, DuplicateKeyException.class);
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:22,代码来源:ClientSessionTest.java

示例3: testSendSmsAndWaitReturnsCorrectResponse

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testSendSmsAndWaitReturnsCorrectResponse() throws Exception {
    final DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.writeAndFlush(any())).thenReturn(promise);

    final Sms sms = new Sms();
    sms.setId(UUID.randomUUID());
    sms.setBoxId("test box");

    final Ack expectedResponse = new Ack();

    scheduledExecutorService.schedule(new Runnable() {
        @Override
        public void run() {
            clientSession.getWindow().complete(sms.getId(), expectedResponse);
        }
    }, 100, TimeUnit.MILLISECONDS);

    final Ack response = clientSession.sendSmsAndWait(sms, 5000);
    assertSame(expectedResponse, response);
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:24,代码来源:ClientSessionTest.java

示例4: testSendSmsAndWaitThrowsWhenOfferToWindowFails

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testSendSmsAndWaitThrowsWhenOfferToWindowFails() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.writeAndFlush(any())).thenReturn(promise);

    Sms sms = new Sms();
    sms.setId(UUID.randomUUID());
    sms.setBoxId("test box");

    //add the sms so the next offer fails
    clientSession.getWindow().offer(sms.getId(), sms, 5000);

    try {
        clientSession.sendSmsAndWait(sms, 5000);
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof DuplicateKeyException);
    }
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:21,代码来源:ClientSessionTest.java

示例5: itClosesTheUnderlyingChannel

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void itClosesTheUnderlyingChannel() {
  DefaultChannelPromise channelPromise = new DefaultChannelPromise(channel, ImmediateEventExecutor.INSTANCE);
  when(channel.close()).thenReturn(channelPromise);

  CompletableFuture<Void> f = session.close();
  channelPromise.setSuccess();

  assertThat(f.isDone());
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:11,代码来源:SmtpSessionTest.java

示例6: testSendAck

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testSendAck() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.writeAndFlush(any())).thenReturn(promise);

    Ack ack = mock(Ack.class);
    assertSame(promise, clientSession.sendAck(ack));

    verify(channel).writeAndFlush(ack);
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:13,代码来源:ClientSessionTest.java

示例7: testIdentifyWhenCommandIsNotIdentifyThrows

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testIdentifyWhenCommandIsNotIdentifyThrows() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.writeAndFlush(any())).thenReturn(promise);

    Admin admin = new Admin();
    admin.setBoxId("test");
    admin.setAdminCommand(AdminCommand.RESTART);

    clientSession.identify(admin);
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:14,代码来源:ClientSessionTest.java

示例8: testCloseWhenChannelIsActiveClosesChannel

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testCloseWhenChannelIsActiveClosesChannel() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.isActive()).thenReturn(true);
    when(channel.close()).thenReturn(promise);

    clientSession.close();

    verify(channel).close();
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:13,代码来源:ClientSessionTest.java

示例9: testCloseWhenChannelIsInactiveClosesChannel

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testCloseWhenChannelIsInactiveClosesChannel() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.isActive()).thenReturn(false);
    when(channel.close()).thenReturn(promise);

    clientSession.close();

    verify(channel, times(0)).close();
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:13,代码来源:ClientSessionTest.java

示例10: testSendSmsSetsUUIDAndBoxIdWhenNull

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testSendSmsSetsUUIDAndBoxIdWhenNull() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.writeAndFlush(any())).thenReturn(promise);

    Sms sms = new Sms("from", "to", "date", SmsType.MOBILE_TERMINATED_PUSH, DataCoding.DC_8BIT);

    clientSession.sendSms(sms, 5000);

    assertNotNull(sms.getId());
    assertSame(clientSessionConfiguration.getClientId(), sms.getBoxId());
    verify(channel).writeAndFlush(sms);
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:16,代码来源:ClientSessionTest.java

示例11: testSendHeartBeat

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testSendHeartBeat() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();

    when(channel.writeAndFlush(any())).thenReturn(promise);

    HeartBeat heartBeat = new HeartBeat();

    assertSame(promise, clientSession.sendHeartBeat(heartBeat));
    verify(channel).writeAndFlush(heartBeat);
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:13,代码来源:ClientSessionTest.java

示例12: testIdentifyWhenCommandIsIdentifyWritesToChannel

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Test
public void testIdentifyWhenCommandIsIdentifyWritesToChannel() throws Exception {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel, eventExecutors.next());
    promise.setSuccess();


    when(channel.writeAndFlush(any())).thenReturn(promise);

    Admin admin = new Admin();
    admin.setBoxId("test");
    admin.setAdminCommand(AdminCommand.IDENTIFY);

    clientSession.identify(admin);

    verify(channel).writeAndFlush(admin);
    verify(sessionHandler).fireSessionInitialized(clientSession);

    assertTrue(clientSession.isIdentified());
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:20,代码来源:ClientSessionTest.java

示例13: bind

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Override
public ChannelFuture bind(SocketAddress localAddress) {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel);
    promise.setSuccess();
    return promise;
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:7,代码来源:MockChannelHandlerContext.java

示例14: connect

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Override
public ChannelFuture connect(SocketAddress remoteAddress) {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel);
    promise.setSuccess();
    return promise;
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:7,代码来源:MockChannelHandlerContext.java

示例15: disconnect

import io.netty.channel.DefaultChannelPromise; //导入方法依赖的package包/类
@Override
public ChannelFuture disconnect() {
    DefaultChannelPromise promise = new DefaultChannelPromise(channel);
    promise.setSuccess();
    return promise;
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:7,代码来源:MockChannelHandlerContext.java


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