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


Java ChannelState.OPEN属性代码示例

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


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

示例1: multiple_connected_same_ip

@Test
public void multiple_connected_same_ip() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent openEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);

    verify(ctx, times(2)).sendUpstream(openEvent);
    verify(channel, times(1)).write(argThat(new ArgumentMatcher<Object>() {
        @Override
        public boolean matches(Object argument) {
            return QueryMessages.connectionsExceeded(MAX_CONNECTIONS_PER_IP).equals(argument);
        }
    }));
    verify(channelFuture, times(1)).addListener(ChannelFutureListener.CLOSE);
    verify(whoisLog).logQueryResult(anyString(), eq(0), eq(0), eq(QueryCompletionInfo.REJECTED), eq(0L), (InetAddress) Mockito.anyObject(), Mockito.anyInt(), eq(""));
    verify(ctx, times(2)).sendUpstream(openEvent);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:21,代码来源:ConnectionPerIpLimitHandlerTest.java

示例2: multiple_connected_limit_disabled

@Test
public void multiple_connected_limit_disabled() throws Exception {
    subject.setMaxConnectionsPerIp(0);

    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent openEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);

    final ChannelEvent closeEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.FALSE);
    subject.handleUpstream(ctx, closeEvent);
    subject.handleUpstream(ctx, closeEvent);
    subject.handleUpstream(ctx, closeEvent);

    verify(ctx, times(3)).sendUpstream(openEvent);
    verify(ctx, times(3)).sendUpstream(closeEvent);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:23,代码来源:ConnectionPerIpLimitHandlerTest.java

示例3: multiple_connected_unlimited_allowed

@Test
public void multiple_connected_unlimited_allowed() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);

    when(ipResourceConfiguration.isUnlimitedConnections(any(IpInterval.class))).thenReturn(true);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent event = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);

    verify(ctx, times(3)).sendUpstream(event);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:17,代码来源:ConnectionPerIpLimitHandlerTest.java

示例4: multiple_connected_proxy_allowed

@Test
public void multiple_connected_proxy_allowed() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);

    when(ipResourceConfiguration.isProxy(any(IpInterval.class))).thenReturn(true);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent event = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);

    verify(ctx, times(3)).sendUpstream(event);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:17,代码来源:ConnectionPerIpLimitHandlerTest.java

示例5: multiple_connected_different_ip

@Test
public void multiple_connected_different_ip() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    final InetSocketAddress remoteAddress2 = new InetSocketAddress("10.0.0.1", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress).thenReturn(remoteAddress).thenReturn(remoteAddress2);

    final ChannelEvent event = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);

    final ChannelEvent event2 = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event2);

    verify(ctx, times(2)).sendUpstream(event);
    verify(ctx, times(1)).sendUpstream(event2);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:19,代码来源:ConnectionPerIpLimitHandlerTest.java

示例6: multiple_connected_same_ip_and_closed

@Test
public void multiple_connected_same_ip_and_closed() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent openEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);

    final ChannelEvent closeEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.FALSE);
    subject.handleUpstream(ctx, closeEvent);
    subject.handleUpstream(ctx, closeEvent);

    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);

    verify(ctx, times(4)).sendUpstream(openEvent);
    verify(ctx, times(2)).sendUpstream(closeEvent);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:22,代码来源:ConnectionPerIpLimitHandlerTest.java

示例7: one_connected

@Test
public void one_connected() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent event = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);

    verify(ctx, times(2)).sendUpstream(event);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:14,代码来源:ConnectionPerIpLimitHandlerTest.java


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