use of org.tmatesoft.svn.core.wc.SVNClientManager in project sonarqube by SonarSource.
the class SvnBlameCommandTest method blame_givenCredentialsSupplied_doNotlogWarning.
@Test
public void blame_givenCredentialsSupplied_doNotlogWarning() throws Exception {
BlameOutput output = mock(BlameOutput.class);
InputFile inputFile = mock(InputFile.class);
SvnConfiguration properties = mock(SvnConfiguration.class);
SvnBlameCommand svnBlameCommand = new SvnBlameCommand(properties);
SVNClientManager clientManager = mock(SVNClientManager.class);
SVNLogClient logClient = mock(SVNLogClient.class);
SVNStatusClient statusClient = mock(SVNStatusClient.class);
SVNStatus status = mock(SVNStatus.class);
when(properties.isEmpty()).thenReturn(true);
when(clientManager.getLogClient()).thenReturn(logClient);
when(clientManager.getStatusClient()).thenReturn(statusClient);
when(status.getContentsStatus()).thenReturn(SVNStatusType.STATUS_NORMAL);
when(inputFile.file()).thenReturn(mock(File.class));
when(statusClient.doStatus(any(File.class), anyBoolean())).thenReturn(status);
doThrow(SVNAuthenticationException.class).when(logClient).doAnnotate(any(File.class), any(SVNRevision.class), any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class), eq(null));
assertThrows(IllegalStateException.class, () -> {
svnBlameCommand.blame(clientManager, inputFile, output);
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
});
}
use of org.tmatesoft.svn.core.wc.SVNClientManager in project sonarqube by SonarSource.
the class SvnBlameCommandTest method blame_givenNoCredentials_logWarning.
@Test
public void blame_givenNoCredentials_logWarning() throws Exception {
BlameOutput output = mock(BlameOutput.class);
InputFile inputFile = mock(InputFile.class);
SvnBlameCommand svnBlameCommand = newSvnBlameCommand();
SVNClientManager clientManager = mock(SVNClientManager.class);
SVNLogClient logClient = mock(SVNLogClient.class);
SVNStatusClient statusClient = mock(SVNStatusClient.class);
SVNStatus status = mock(SVNStatus.class);
when(clientManager.getLogClient()).thenReturn(logClient);
when(clientManager.getStatusClient()).thenReturn(statusClient);
when(status.getContentsStatus()).thenReturn(SVNStatusType.STATUS_NORMAL);
when(inputFile.file()).thenReturn(mock(File.class));
when(statusClient.doStatus(any(File.class), anyBoolean())).thenReturn(status);
doThrow(SVNAuthenticationException.class).when(logClient).doAnnotate(any(File.class), any(SVNRevision.class), any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class), eq(null));
assertThrows(IllegalStateException.class, () -> {
svnBlameCommand.blame(clientManager, inputFile, output);
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Authentication to SVN server is required but no " + "authentication data was passed to the scanner");
});
}
use of org.tmatesoft.svn.core.wc.SVNClientManager in project sling by apache.
the class SvnChangeLogFinder method getChanges.
public List<String> getChanges(String first, String second) throws SVNException {
SVNURL svnUrl = SVNURL.parseURIEncoded(SLING_SVN_REPO_BASE);
List<String> changes = new ArrayList<>();
SVNClientManager manager = SVNClientManager.newInstance();
SVNRepository repo = manager.getRepositoryPool().createRepository(svnUrl, true);
SVNRevision from = SVNRevision.create(getRevision(first, repo));
SVNRevision to = SVNRevision.create(getRevision(second, repo));
repo.log(new String[] { "tags/" + second }, from.getNumber(), to.getNumber(), false, false, (e) -> changes.add(e.getMessage()));
return changes;
}
use of org.tmatesoft.svn.core.wc.SVNClientManager in project sonarqube by SonarSource.
the class SvnBlameCommandTest method checkout.
private File checkout(String scmUrl) throws Exception {
ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
ISVNAuthenticationManager isvnAuthenticationManager = SVNWCUtil.createDefaultAuthenticationManager(null, null, (char[]) null, false);
SVNClientManager svnClientManager = SVNClientManager.newInstance(options, isvnAuthenticationManager);
File out = temp.newFolder();
SVNUpdateClient updateClient = svnClientManager.getUpdateClient();
SvnCheckout co = updateClient.getOperationsFactory().createCheckout();
co.setUpdateLocksOnDemand(updateClient.isUpdateLocksOnDemand());
co.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(scmUrl), SVNRevision.HEAD));
co.setSingleTarget(SvnTarget.fromFile(out));
co.setRevision(SVNRevision.HEAD);
co.setDepth(SVNDepth.INFINITY);
co.setAllowUnversionedObstructions(false);
co.setIgnoreExternals(updateClient.isIgnoreExternals());
co.setExternalsHandler(SvnCodec.externalsHandler(updateClient.getExternalsHandler()));
co.setTargetWorkingCopyFormat(wcVersion);
co.run();
return out;
}
use of org.tmatesoft.svn.core.wc.SVNClientManager in project sonarqube by SonarSource.
the class SvnScmProviderTest method computeChangedPaths_should_not_crash_when_getRepositoryRootURL_getPath_is_empty.
@Test
public void computeChangedPaths_should_not_crash_when_getRepositoryRootURL_getPath_is_empty() throws SVNException {
// verify assumptions about what SVNKit returns as svn root path for urls like http://svnserver/
assertThat(SVNURL.parseURIEncoded("http://svnserver/").getPath()).isEmpty();
assertThat(SVNURL.parseURIEncoded("http://svnserver").getPath()).isEmpty();
SVNClientManager svnClientManagerMock = mock(SVNClientManager.class);
SVNWCClient svnwcClientMock = mock(SVNWCClient.class);
when(svnClientManagerMock.getWCClient()).thenReturn(svnwcClientMock);
SVNLogClient svnLogClient = mock(SVNLogClient.class);
when(svnClientManagerMock.getLogClient()).thenReturn(svnLogClient);
SVNInfo svnInfoMock = mock(SVNInfo.class);
when(svnwcClientMock.doInfo(any(), any())).thenReturn(svnInfoMock);
// Simulate repository root on /, SVNKIT then returns an repository root url WITHOUT / at the end.
when(svnInfoMock.getRepositoryRootURL()).thenReturn(SVNURL.parseURIEncoded("http://svnserver"));
when(svnInfoMock.getURL()).thenReturn(SVNURL.parseURIEncoded("http://svnserver/myproject/trunk/"));
assertThat(SvnScmProvider.computeChangedPaths(Paths.get("/"), svnClientManagerMock)).isEmpty();
}
Aggregations