private void startServer() throws Exception {
    final Xnio xnio = Xnio.getInstance();
    endpoint = Remoting.createEndpoint("RemoteNaming", xnio, OptionMap.EMPTY);
    endpoint.addConnectionProvider(
        "remote", new RemoteConnectionProviderFactory(), OptionMap.EMPTY);
    final NetworkServerProvider nsp =
        endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SocketAddress bindAddress = new InetSocketAddress("localhost", 7999);
    final OptionMap serverOptions = TestUtils.createOptionMap();

    server =
        nsp.createServer(
            bindAddress, serverOptions, new TestUtils.DefaultAuthenticationHandler(), null);
    remoteNamingService = new RemoteNamingService(localContext, Executors.newFixedThreadPool(10));
    remoteNamingService.start(endpoint);

    serverStopped = false;
  }
 private void stopServer() throws IOException {
   remoteNamingService.stop();
   server.close();
   endpoint.close();
   serverStopped = true;
 }