ListDirectoryContentsController extends AbstractTemplateController { @Override protected ModelAndView svnHandle(final SVNConnection connection, final BaseCommand command, final long headRevision, final UserRepositoryContext userRepositoryContext, final HttpServletRequest request, final HttpServletResponse response, final BindException exception) throws Exception { logger.debug("Getting directory contents for: " + command.getPath()); final String path = command.getPathWithTrailingSlash(); final long revision = command.getRevisionNumber(); final DirList dirList = getRepositoryService().list(connection, path, revision); logger.debug("Directory entries in " + path + ": " + dirList.getEntriesCount()); logger.debug("Properties for " + path + ": " + dirList.getPropertiesCount()); final Map<String, Object> model = new HashMap<String, Object>(); model.put("dirEntries", dirList.getEntries()); model.put("properties", dirList.getProperties()); final ModelAndView modelAndView = new ModelAndView(); modelAndView.addAllObjects(model); return modelAndView; }    }
@Test public void testSvnHandle() throws Exception { final RepositoryService mockService = EasyMock.createMock(RepositoryService.class); final MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("rowNumber", "12"); final List<DirEntry> entries = TestUtils.getFileEntriesDirectoryList(); final BaseCommand command = new BaseCommand(); command.setName(new RepositoryName("test")); command.setRevision(Revision.create(12)); final ListDirectoryContentsController ctrl = new ListDirectoryContentsController(); ctrl.setRepositoryService(mockService); expect(mockService.list(null, command.getPath(), command.getRevisionNumber())).andStubReturn( new DirList(entries, new Properties())); replay(mockService); final ModelAndView modelAndView = ctrl.svnHandle(null, command, 100, null, request, null, null); final Map model = modelAndView.getModel(); verify(mockService); assertEquals(2, model.size()); assertEquals(entries.get(0), ((List<DirEntry>) model.get("dirEntries")).get(0)); assertNull(modelAndView.getViewName()); }