use of org.sonar.server.platform.ServerFileSystem in project sonarqube by SonarSource.
the class PluginDownloaderTest method before.
@Before
public void before() throws Exception {
updateCenterMatrixFactory = mock(UpdateCenterMatrixFactory.class);
updateCenter = mock(UpdateCenter.class);
when(updateCenterMatrixFactory.getUpdateCenter(anyBoolean())).thenReturn(Optional.of(updateCenter));
httpDownloader = mock(HttpDownloader.class);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock inv) throws Throwable {
File toFile = (File) inv.getArguments()[1];
touch(toFile);
return null;
}
}).when(httpDownloader).download(any(URI.class), any(File.class));
ServerFileSystem fs = mock(ServerFileSystem.class);
downloadDir = testFolder.newFolder("downloads");
when(fs.getDownloadedPluginsDir()).thenReturn(downloadDir);
pluginDownloader = new PluginDownloader(updateCenterMatrixFactory, httpDownloader, fs);
}
use of org.sonar.server.platform.ServerFileSystem in project sonarqube by SonarSource.
the class PluginDownloaderTest method throw_exception_if_download_dir_is_invalid.
@Test
public void throw_exception_if_download_dir_is_invalid() throws Exception {
ServerFileSystem fs = mock(ServerFileSystem.class);
// download dir is a file instead of being a directory
File downloadDir = testFolder.newFile();
when(fs.getDownloadedPluginsDir()).thenReturn(downloadDir);
pluginDownloader = new PluginDownloader(updateCenterMatrixFactory, httpDownloader, fs);
try {
pluginDownloader.start();
fail();
} catch (IllegalStateException e) {
// ok
}
}
Aggregations