@Test public void testFormFileProgress() throws Exception { final List<Integer> progressList = new ArrayList<>(); HttpDaemon.registerServlet("/", new HttpServlet() { @Override public HttpResponse doGet(HttpRequest request) { return null; } @Override public HttpResponse doPost(HttpRequest request) { ProgressListener listener = new ProgressListener() { private int mProgress; @Override public void update(String fileUri, long pBytesRead, long pContentLength) { int progress = (int) (pBytesRead * 100.0 / pContentLength); if (progress > mProgress) { mProgress = progress; progressList.add(mProgress); } } }; request.parseMultipartBody(repository, listener); return HttpResponse.newResponse(request.form().get(FILE_URI)); } }); Request request = formWithFileAndUriRequest(); Response response = new OkHttpClient().newCall(request).execute(); System.out.println(progressList); assertThat(progressList, hasItem(100)); }
public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); }
HttpDaemon { public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); } }
HttpDaemon { public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); } HttpDaemon(int port);  HttpDaemon(); }
HttpDaemon { public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); } HttpDaemon(int port);  HttpDaemon(); static void registerServlet(String urlPattern, HttpServlet servlet); static int getPort(); static HttpDaemon getSingleton(); void start(); void stop(); boolean isAlive(); boolean isStarted(); int aliveRequests(); }
HttpDaemon { public static void registerServlet(String urlPattern, HttpServlet servlet) { sServletMap.put(urlPattern, servlet); } HttpDaemon(int port);  HttpDaemon(); static void registerServlet(String urlPattern, HttpServlet servlet); static int getPort(); static HttpDaemon getSingleton(); void start(); void stop(); boolean isAlive(); boolean isStarted(); int aliveRequests(); static int sPort; }