303132333435363738
} @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { IServletManager manager = getManager(req); log.info("Instance: " + manager); manager.manage(req, resp); }
363738394041424344
log.info("Instance: " + manager); manager.manage(req, resp); } IServletManager getManager(HttpServletRequest req) { IServletManager manager = injector.getInstance(Key.get(IServletManager.class, Names.named(req.getServletPath()))); return manager; }
3839404142434445
} @Test public void downloadClass(){ when(request.getServletPath()).thenReturn(DOWNLOAD_PATH); IServletManager manager = fileManager.getManager(request); assertEquals(DownloadImageImpl.class, manager.getClass()); }
454647484950515253
} @Test public void uploadClass(){ when(request.getServletPath()).thenReturn(UPLOAD_PATH); IServletManager manager = fileManager.getManager(request); // Class is enhanced by Guice, because it has AOP assertTrue(manager.getClass().getName().contains(FileUploadImpl.class.getName())); }