@Test void bind() throws Exception { final EventLoopGroup bossGroup = new NioEventLoopGroup(); final EventLoopGroup workerGroup = new NioEventLoopGroup(); final ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup); final DssRestChannelProperty property = DssRestChannelProperty .builder() .host("127.0.0.1") .port(8181) .build(); final DssRestChannelInitializer channelInitializer = new DssRestChannelInitializer(Collections.emptyList()); try { final DssRestChannel dssRestChannel = new DssRestChannel(); final Channel channel = dssRestChannel.bind(bootstrap, property, channelInitializer); final Socket socket = new Socket(); socket.connect(new InetSocketAddress("127.0.0.1", 8181)); assertTrue(socket.isConnected()); channel.close().sync(); } finally { assertNotNull(workerGroup); workerGroup.shutdownGracefully(); assertNotNull(bossGroup); bossGroup.shutdownGracefully(); } }
@Override public Channel bind(ServerBootstrap serverBootstrap, DssRestChannelProperty dssRestChannelProperty, DssRestChannelInitializer dssRestChannelInitializer) throws InterruptedException { Objects.requireNonNull(serverBootstrap); Objects.requireNonNull(dssRestChannelProperty); Objects.requireNonNull(dssRestChannelInitializer); return serverBootstrap .channel(NioServerSocketChannel.class) .handler(new LoggingHandler(dssRestChannelProperty.getDssLogLevel().getNettyLogLevel())) .childHandler(dssRestChannelInitializer) .bind(dssRestChannelProperty.getHost(), dssRestChannelProperty.getPort()) .sync() .channel(); }
DssRestChannel implements DssChannel<DssRestChannelProperty, DssRestChannelInitializer> { @Override public Channel bind(ServerBootstrap serverBootstrap, DssRestChannelProperty dssRestChannelProperty, DssRestChannelInitializer dssRestChannelInitializer) throws InterruptedException { Objects.requireNonNull(serverBootstrap); Objects.requireNonNull(dssRestChannelProperty); Objects.requireNonNull(dssRestChannelInitializer); return serverBootstrap .channel(NioServerSocketChannel.class) .handler(new LoggingHandler(dssRestChannelProperty.getDssLogLevel().getNettyLogLevel())) .childHandler(dssRestChannelInitializer) .bind(dssRestChannelProperty.getHost(), dssRestChannelProperty.getPort()) .sync() .channel(); } }
DssRestChannel implements DssChannel<DssRestChannelProperty, DssRestChannelInitializer> { @Override public Channel bind(ServerBootstrap serverBootstrap, DssRestChannelProperty dssRestChannelProperty, DssRestChannelInitializer dssRestChannelInitializer) throws InterruptedException { Objects.requireNonNull(serverBootstrap); Objects.requireNonNull(dssRestChannelProperty); Objects.requireNonNull(dssRestChannelInitializer); return serverBootstrap .channel(NioServerSocketChannel.class) .handler(new LoggingHandler(dssRestChannelProperty.getDssLogLevel().getNettyLogLevel())) .childHandler(dssRestChannelInitializer) .bind(dssRestChannelProperty.getHost(), dssRestChannelProperty.getPort()) .sync() .channel(); }  }
DssRestChannel implements DssChannel<DssRestChannelProperty, DssRestChannelInitializer> { @Override public Channel bind(ServerBootstrap serverBootstrap, DssRestChannelProperty dssRestChannelProperty, DssRestChannelInitializer dssRestChannelInitializer) throws InterruptedException { Objects.requireNonNull(serverBootstrap); Objects.requireNonNull(dssRestChannelProperty); Objects.requireNonNull(dssRestChannelInitializer); return serverBootstrap .channel(NioServerSocketChannel.class) .handler(new LoggingHandler(dssRestChannelProperty.getDssLogLevel().getNettyLogLevel())) .childHandler(dssRestChannelInitializer) .bind(dssRestChannelProperty.getHost(), dssRestChannelProperty.getPort()) .sync() .channel(); }  @Override Channel bind(ServerBootstrap serverBootstrap, DssRestChannelProperty dssRestChannelProperty, DssRestChannelInitializer dssRestChannelInitializer); }
DssRestChannel implements DssChannel<DssRestChannelProperty, DssRestChannelInitializer> { @Override public Channel bind(ServerBootstrap serverBootstrap, DssRestChannelProperty dssRestChannelProperty, DssRestChannelInitializer dssRestChannelInitializer) throws InterruptedException { Objects.requireNonNull(serverBootstrap); Objects.requireNonNull(dssRestChannelProperty); Objects.requireNonNull(dssRestChannelInitializer); return serverBootstrap .channel(NioServerSocketChannel.class) .handler(new LoggingHandler(dssRestChannelProperty.getDssLogLevel().getNettyLogLevel())) .childHandler(dssRestChannelInitializer) .bind(dssRestChannelProperty.getHost(), dssRestChannelProperty.getPort()) .sync() .channel(); }  @Override Channel bind(ServerBootstrap serverBootstrap, DssRestChannelProperty dssRestChannelProperty, DssRestChannelInitializer dssRestChannelInitializer);  }