### Question:
ServerBootstrap extends Bootstrap { @Override public void setFactory(ChannelFactory factory) { if (factory == null) { throw new NullPointerException("factory"); } if (!(factory instanceof ServerChannelFactory)) { throw new IllegalArgumentException( "factory must be a " + ServerChannelFactory.class.getSimpleName() + ": " + factory.getClass()); } super.setFactory(factory); } ServerBootstrap();  ServerBootstrap(ChannelFactory channelFactory); @Override void setFactory(ChannelFactory factory); ChannelHandler getParentHandler(); void setParentHandler(ChannelHandler parentHandler); Channel bind(); Channel bind(final SocketAddress localAddress); ChannelFuture bindAsync(); ChannelFuture bindAsync(final SocketAddress localAddress);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void shouldOnlyAllowServerChannelFactory() { ServerBootstrap bootstrap = newBootstrap(); bootstrap.setFactory(createMock(ChannelFactory.class)); }
@Test @Override public void shouldNotAllowFactoryToChangeMoreThanOnce() { Bootstrap b = newBootstrap(); ChannelFactory f = createMock(ServerChannelFactory.class); b.setFactory(f); assertSame(f, b.getFactory()); try { b.setFactory(createMock(ServerChannelFactory.class)); fail(); } catch (IllegalStateException e) { } b.releaseExternalResources(); }