@Test
  public void testChangePipelineFactoryDoesNotAffectRealChannel() {
    ChannelPipelineFactory realPipelineFactory =
        realChannelFactory.createdChannel.getConfig().getPipelineFactory();
    ChannelPipelineFactory virtualPipelineFactory = mockContext.mock(ChannelPipelineFactory.class);
    virtualChannel.getConfig().setPipelineFactory(virtualPipelineFactory);
    assertSame(virtualPipelineFactory, virtualChannel.getConfig().getPipelineFactory());

    // channel pipeline factory is a special case: we do not want it set on
    // the configuration
    // of the underlying factory
    assertSame(
        realPipelineFactory, realChannelFactory.createdChannel.getConfig().getPipelineFactory());
  }
  @Test
  public void testSetChannelPipelineFactoryViaOption() {
    final ServerSocketChannelConfig mockConfig = mockContext.mock(ServerSocketChannelConfig.class);
    realChannelFactory.createdChannel.config = mockConfig;

    mockContext.checking(
        new Expectations() {
          {
            never(mockConfig);
          }
        });

    ChannelPipelineFactory factory = mockContext.mock(ChannelPipelineFactory.class);
    virtualChannel.getConfig().setOption("pipelineFactory", factory);
    assertSame(factory, virtualChannel.getConfig().getPipelineFactory());
  }
 @Test
 public void testChangingPerformancePreferencesAffectsRealChannel() {
   final ServerSocketChannelConfig mockConfig = mockContext.mock(ServerSocketChannelConfig.class);
   realChannelFactory.createdChannel.config = mockConfig;
   mockContext.checking(
       new Expectations() {
         {
           one(mockConfig).setPerformancePreferences(100, 200, 300);
         }
       });
   virtualChannel.getConfig().setPerformancePreferences(100, 200, 300);
   mockContext.assertIsSatisfied();
 }
  @Test
  public void testSetOptionAffectsRealChannel() {
    final ServerSocketChannelConfig mockConfig = mockContext.mock(ServerSocketChannelConfig.class);
    realChannelFactory.createdChannel.config = mockConfig;

    mockContext.checking(
        new Expectations() {
          {
            one(mockConfig).setOption("testOption", "testValue");
          }
        });

    virtualChannel.getConfig().setOption("testOption", "testValue");
  }
 @Test
 public void testGetRemoteAddress_returnsNull() {
   assertNull(virtualChannel.getRemoteAddress());
 }
 @Test
 public void testChangingReuseAddressAffectsRealChannel() {
   virtualChannel.getConfig().setReuseAddress(true);
   assertEquals(true, realChannelFactory.createdChannel.getConfig().isReuseAddress());
 }
 @Test
 public void testChangingReceiveBufferSizeAffectsRealChannel() {
   virtualChannel.getConfig().setReceiveBufferSize(10101);
   assertEquals(10101, realChannelFactory.createdChannel.getConfig().getReceiveBufferSize());
 }
 @Test
 public void testChangingConnectTimeoutMillisAffectsRealChannel() {
   virtualChannel.getConfig().setConnectTimeoutMillis(54321);
   assertEquals(54321, realChannelFactory.createdChannel.getConfig().getConnectTimeoutMillis());
 }
 @Test
 public void testChangingBacklogAffectsRealChannel() {
   virtualChannel.getConfig().setBacklog(1234);
   assertEquals(1234, realChannelFactory.createdChannel.getConfig().getBacklog());
 }
 @Test
 public void testHasConfiguration() {
   assertNotNull(virtualChannel.getConfig());
 }