RestServer implements Server { @Override public void start() { if (started) { return; } synchronized (this) { if (started) { return; } try { httpServer.start(); if (LOGGER.isInfoEnabled()) { LOGGER.info("Start the http rest server at port {}", serverConfig.getPort()); } } catch (SofaRpcRuntimeException e) { throw e; } catch (Exception e) { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_START_SERVER_WITH_PORT, "rest", serverConfig.getPort()), e); } started = true; } }  @Override void init(ServerConfig serverConfig); @Override void start(); @Override boolean isStarted(); @Override boolean hasNoEntry(); @Override void stop(); @Override void registerProcessor(ProviderConfig providerConfig, Invoker instance); @Override void unRegisterProcessor(ProviderConfig providerConfig, boolean closeIfNoEntry); @Override void destroy(); @Override void destroy(DestroyHook hook);  }
@Test public void start() { String host = "127.0.0.1"; int port = 18801; ServerConfig serverConfig = new ServerConfig(); serverConfig.setBoundHost(host); serverConfig.setPort(port); serverConfig.setProtocol(RpcConstants.PROTOCOL_TYPE_REST); RestServer server = new RestServer(); server.init(serverConfig); server.start(); Assert.assertTrue(server.started); Assert.assertTrue(NetUtils.canTelnet(host, port, 1000)); server.start(); server.stop(); Assert.assertFalse(server.started); Assert.assertFalse(NetUtils.canTelnet(host, port, 1000)); server.stop(); server.init(serverConfig); server.start(); Assert.assertTrue(server.started); Assert.assertTrue(NetUtils.canTelnet(host, port, 1000)); server.destroy(null); server.init(serverConfig); server.start(); Assert.assertTrue(server.started); Assert.assertTrue(NetUtils.canTelnet(host, port, 1000)); server.destroy(new Destroyable.DestroyHook() { @Override public void preDestroy() { } @Override public void postDestroy() { } }); }