BlameController 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("Blaming: " + command.getPath() + ", revision: " + command.getRevisionNumber()); final String charset = userRepositoryContext.getCharset(); logger.debug("Using charset encoding: " + charset); final AnnotatedTextFile annotatedFile = getRepositoryService().blame(connection, command.getPath(), command.getRevisionNumber(), charset, colorer); final Map<String, Object> model = new HashMap<String, Object>(); model.put("annotatedFile", annotatedFile); return new ModelAndView(getViewName(), model); } BlameController(final Colorer colorer);   }
@Test public void testSvnHandle() throws Exception { final RepositoryService mockService = EasyMock.createMock(RepositoryService.class); final Colorer colorer = new Colorer() { public String getColorizedContent(String content, String fileExtension, String encoding) throws IOException { return content; } }; final AnnotatedTextFile annotatedFile = new AnnotatedTextFile(); final UserRepositoryContext context = new UserRepositoryContext(); context.setCharset("UTF-8"); final BaseCommand command = new BaseCommand(); command.setPath("trunk/test"); command.setName(new RepositoryName("test")); command.setRevision(Revision.create(12)); final BlameController ctrl = new BlameController(colorer); ctrl.setRepositoryService(mockService); expect(mockService.blame(null, command.getPath(), command.getRevisionNumber(), context.getCharset(), colorer)).andStubReturn(annotatedFile); replay(mockService); final ModelAndView modelAndView = ctrl.svnHandle(null, command, 100, context, null, null, null); final Map model = modelAndView.getModel(); verify(mockService); assertEquals(1, model.size()); assertEquals(annotatedFile, model.get("annotatedFile")); }