// Path: src/test/java/io/termd/core/telnet/TelnetServerRule.java
// public class TelnetServerRule extends ExternalResource {
// 
//   public static final Function<Supplier<TelnetHandler>, Closeable> NETTY_SERVER = handlerFactory -> {
//     EventLoopGroup bossGroup = new NioEventLoopGroup(1);
//     EventLoopGroup workerGroup = new NioEventLoopGroup();
//     ServerBootstrap b = new ServerBootstrap();
//     b.group(bossGroup, workerGroup)
//         .channel(NioServerSocketChannel.class)
//         .option(ChannelOption.SO_BACKLOG, 100)
//         .handler(new LoggingHandler(LogLevel.INFO))
//         .childHandler(new ChannelInitializer<SocketChannel>() {
//           @Override
//           public void initChannel(SocketChannel ch) throws Exception {
//             ChannelPipeline p = ch.pipeline();
//             TelnetChannelHandler handler = new TelnetChannelHandler(handlerFactory);
//             p.addLast(handler);
//           }
//         });
//     try {
//       b.bind("localhost", 4000).sync();
//       return () -> {
//         bossGroup.shutdownGracefully();
//       };
//     } catch (InterruptedException e) {
//       throw TestBase.failure(e);
//     }
//   };
// 
//   private final Function<Supplier<TelnetHandler>, Closeable> serverFactory;
//   protected Closeable server;
// 
//   public TelnetServerRule(Function<Supplier<TelnetHandler>, Closeable> serverFactory) {
//     this.serverFactory = serverFactory;
//   }
// 
//   @Override
//   protected void before() throws Throwable {
//     server = null;
//   }
// 
//   @Override
//   protected void after() {
//     if (server != null) {
//       try {
//         server.close();
//       } catch (IOException e) {
//         e.printStackTrace();
//       }
//     }
//   }
// 
//   public final void start(Supplier<TelnetHandler> telnetFactory) {
//     if (server != null) {
//       throw TestBase.failure("Already a server");
//     }
//     server = serverFactory.apply(telnetFactory);
//   }
// }


import io.termd.core.telnet.TelnetHandler;
import io.termd.core.telnet.TelnetServerRule;
import java.io.Closeable;
import java.util.function.Function;
import java.util.function.Supplier;
/*
 * Copyright 2015 Julien Viet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.termd.core.tty;



/**
 * @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
 */
public class NettyAsciiTelnetTtyTest extends TelnetTtyTestBase {

  public NettyAsciiTelnetTtyTest() {
    binary = false;
  }

  @Override
  protected Function<Supplier<TelnetHandler>, Closeable> serverFactory() {
// Path: src/test/java/io/termd/core/telnet/TelnetServerRule.java
// public class TelnetServerRule extends ExternalResource {
// 
//   public static final Function<Supplier<TelnetHandler>, Closeable> NETTY_SERVER = handlerFactory -> {
//     EventLoopGroup bossGroup = new NioEventLoopGroup(1);
//     EventLoopGroup workerGroup = new NioEventLoopGroup();
//     ServerBootstrap b = new ServerBootstrap();
//     b.group(bossGroup, workerGroup)
//         .channel(NioServerSocketChannel.class)
//         .option(ChannelOption.SO_BACKLOG, 100)
//         .handler(new LoggingHandler(LogLevel.INFO))
//         .childHandler(new ChannelInitializer<SocketChannel>() {
//           @Override
//           public void initChannel(SocketChannel ch) throws Exception {
//             ChannelPipeline p = ch.pipeline();
//             TelnetChannelHandler handler = new TelnetChannelHandler(handlerFactory);
//             p.addLast(handler);
//           }
//         });
//     try {
//       b.bind("localhost", 4000).sync();
//       return () -> {
//         bossGroup.shutdownGracefully();
//       };
//     } catch (InterruptedException e) {
//       throw TestBase.failure(e);
//     }
//   };
// 
//   private final Function<Supplier<TelnetHandler>, Closeable> serverFactory;
//   protected Closeable server;
// 
//   public TelnetServerRule(Function<Supplier<TelnetHandler>, Closeable> serverFactory) {
//     this.serverFactory = serverFactory;
//   }
// 
//   @Override
//   protected void before() throws Throwable {
//     server = null;
//   }
// 
//   @Override
//   protected void after() {
//     if (server != null) {
//       try {
//         server.close();
//       } catch (IOException e) {
//         e.printStackTrace();
//       }
//     }
//   }
// 
//   public final void start(Supplier<TelnetHandler> telnetFactory) {
//     if (server != null) {
//       throw TestBase.failure("Already a server");
//     }
//     server = serverFactory.apply(telnetFactory);
//   }
// }


// Path: src/test/java/io/termd/core/tty/NettyAsciiTelnetTtyTest.java
import io.termd.core.telnet.TelnetHandler;
import io.termd.core.telnet.TelnetServerRule;
import java.io.Closeable;
import java.util.function.Function;
import java.util.function.Supplier;

/*
 * Copyright 2015 Julien Viet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.termd.core.tty;



/**
 * @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
 */
public class NettyAsciiTelnetTtyTest extends TelnetTtyTestBase {

  public NettyAsciiTelnetTtyTest() {
    binary = false;
  }

  @Override
  protected Function<Supplier<TelnetHandler>, Closeable> serverFactory() {
    return TelnetServerRule.NETTY_SERVER;