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