AbstractTemplateController extends AbstractBaseController { protected SVNConnection createConnection(final RepositoryConfiguration configuration, final UserRepositoryContext userRepositoryContext) throws SventonException { final SVNConnection connection; final RepositoryName repositoryName = configuration.getName(); final SVNURL svnurl = configuration.getSVNURL(); if (configuration.isAccessControlEnabled()) { connection = connectionFactory.createConnection(repositoryName, svnurl, userRepositoryContext.getCredentials()); } else { connection = connectionFactory.createConnection(repositoryName, svnurl, configuration.getUserCredentials()); } return connection; }  @Override final ModelAndView handle(final HttpServletRequest request, final HttpServletResponse response,
                                   final Object cmd, final BindException errors); final void setCacheGateway(final CacheGateway cacheGateway); final void setMaxRevisionsCount(final int maxRevisionsCount); final void setMaxEntriesCount(final int maxEntriesCount); final void setAvailableCharsets(final AvailableCharsets availableCharsets); void setViewName(final String viewName); String getViewName(); static final String ENTRIES_SEARCH_MODE; static final String LOGMESSAGES_SEARCH_MODE; }
@Test public void testCreateConnection() throws Exception { final AbstractTemplateController ctrl = new TestController(); final MutableBoolean usingSharedAuthSettings = new MutableBoolean(false); ctrl.setConnectionFactory(new SVNConnectionFactory() { public SVNConnection createConnection(RepositoryName repositoryName, SVNURL svnUrl, Credentials credentials) throws SventonException { if ("shared".equals(credentials.getUserName())) { usingSharedAuthSettings.setValue(true); } else if ("user".equals(credentials.getUserName())) { usingSharedAuthSettings.setValue(false); } return null; } }); final RepositoryConfiguration configuration = new RepositoryConfiguration("test"); final UserRepositoryContext context = new UserRepositoryContext(); assertFalse(usingSharedAuthSettings.booleanValue()); configuration.setUserCredentials(new Credentials("shared", "pass")); configuration.setEnableAccessControl(false); ctrl.createConnection(configuration, context); assertTrue(usingSharedAuthSettings.booleanValue()); context.setCredentials(new Credentials("user", "pass")); configuration.setEnableAccessControl(true); ctrl.createConnection(configuration, context); assertFalse(usingSharedAuthSettings.booleanValue()); ctrl.createConnection(configuration, context); assertFalse(usingSharedAuthSettings.booleanValue()); }