use of org.sonar.api.utils.SonarException in project sonarqube by SonarSource.
the class SecurityRealmFactory method start.
@Override
public void start() {
if (realm != null) {
Logger logger = Loggers.get("org.sonar.INFO");
try {
logger.info("Security realm: " + realm.getName());
realm.init();
logger.info("Security realm started");
} catch (RuntimeException e) {
if (ignoreStartupFailure) {
logger.error("IGNORED - Security realm fails to start: " + e.getMessage());
} else {
throw new SonarException("Security realm fails to start: " + e.getMessage(), e);
}
}
}
}
use of org.sonar.api.utils.SonarException in project sonarqube by SonarSource.
the class UpdateCenterClientTest method ignore_connection_errors.
@Test
public void ignore_connection_errors() {
when(reader.readString(any(URI.class), eq(StandardCharsets.UTF_8))).thenThrow(new SonarException());
assertThat(underTest.getUpdateCenter()).isAbsent();
}
use of org.sonar.api.utils.SonarException in project sonarqube by SonarSource.
the class PluginDownloaderTest method throw_exception_if_could_not_download.
@Test
public void throw_exception_if_could_not_download() {
Plugin test = Plugin.factory("test");
Release test10 = new Release(test, "1.0").setDownloadUrl("file://not_found");
test.addRelease(test10);
when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
pluginDownloader.start();
try {
pluginDownloader.download("foo", create("1.0"));
fail();
} catch (SonarException e) {
// ok
}
}
use of org.sonar.api.utils.SonarException in project sonarqube by SonarSource.
the class PluginDownloaderTest method throw_exception_if_download_fail.
@Test
public void throw_exception_if_download_fail() {
Plugin test = Plugin.factory("test");
Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.jar");
test.addRelease(test10);
when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
doThrow(new RuntimeException()).when(httpDownloader).download(any(URI.class), any(File.class));
pluginDownloader.start();
try {
pluginDownloader.download("foo", create("1.0"));
fail();
} catch (SonarException e) {
// ok
}
}
use of org.sonar.api.utils.SonarException in project sonarqube by SonarSource.
the class DefaultHttpDownloaderTest method readStringWithTimeout.
@Test
public void readStringWithTimeout() throws URISyntaxException {
thrown.expect(new BaseMatcher<Exception>() {
@Override
public boolean matches(Object ex) {
return ex instanceof SonarException && ((SonarException) ex).getCause() instanceof SocketTimeoutException;
}
@Override
public void describeTo(Description arg0) {
}
});
new DefaultHttpDownloader(new MapSettings(), 50).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
}
Aggregations