server.start(); } catch (IOException x) { LOGGER.log(Level.WARNING, "cannot start mock update center", x);
public void main(int port) throws Exception { String docRoot = "/tmp"; SocketConfig socketConfig = SocketConfig.custom() .setSoTimeout(15000) .setTcpNoDelay(true) .build(); SSLContext sslcontext = null; server = ServerBootstrap.bootstrap() .setListenerPort(port) .setServerInfo("Test/1.1") .setSocketConfig(socketConfig) .setSslContext(sslcontext) .registerHandler("*", new HttpFileHandler(docRoot)) .create(); try { server.start(); server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); } catch (Exception e) { return; } Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { server.shutdown(5, TimeUnit.SECONDS); } }); }
public TestHttpServer start() { checkNotStarted(); HttpProcessor httpProcessor = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors); int port = Networking.nextAvailablePort(basePort); ServerBootstrap bootstrap = ServerBootstrap.bootstrap() .setListenerPort(port) .setLocalAddress(getLocalAddress()) .setHttpProcessor(httpProcessor); for (HandlerTuple tuple : handlers) { bootstrap.registerHandler(tuple.path, tuple.handler); } server = bootstrap.create(); try { server.start(); } catch (IOException e) { throw Exceptions.propagate(e); } return this; }
@Before public void setUp() throws Exception { localServer = ServerBootstrap.bootstrap() .setHttpProcessor(getHttpProcessor()) .registerHandler("/", new BasicValidationHandler("GET", null, null, null)) .registerHandler("/withPath", new BasicValidationHandler("GET", null, null, null)) .registerHandler("/with/nested/path", new BasicValidationHandler("GET", null, null, null)) .create(); localServer.start(); }