aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java
index 5ddfa9f151b..735c21c7130 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java
@@ -28,21 +28,24 @@ import static org.mockito.Mockito.when;
import java.util.Collections;
import java.util.HashMap;
-import org.sonar.batch.DefaultProfileLoader;
-
import org.apache.commons.configuration.MapConfiguration;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.sonar.api.profiles.Alert;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Java;
import org.sonar.api.resources.Project;
import org.sonar.api.rules.ActiveRule;
-import org.sonar.batch.ProfileLoader;
+import org.sonar.api.utils.SonarException;
import org.sonar.jpa.dao.ProfilesDao;
public class DefaultProfileLoaderTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
private ProfilesDao dao;
private ProfileLoader loader;
@@ -88,7 +91,7 @@ public class DefaultProfileLoaderTest {
verify(dao, never()).getActiveProfile(Java.KEY, "project");
}
- @Test(expected = RuntimeException.class)
+ @Test
public void shouldFailIfProfileIsNotFound() {
Project project = new Project("project").setLanguageKey(Java.KEY);
@@ -98,6 +101,21 @@ public class DefaultProfileLoaderTest {
when(dao.getProfile(Java.KEY, "profile1")).thenReturn(null);
+ thrown.expect(SonarException.class);
+ thrown.expectMessage("Quality profile not found : unknown, language java");
+ loader.load(project);
+ }
+
+ /**
+ * SONAR-3125
+ */
+ @Test
+ public void shouldGiveExplicitMessageIfNoProfileFound() {
+ Project project = new Project("foo:project").setLanguageKey("unknown-language");
+ when(dao.getProfile(Java.KEY, "profile1")).thenReturn(null);
+
+ thrown.expect(SonarException.class);
+ thrown.expectMessage("You must intall a Sonar plugin that supports language 'unknown-language' in order to analyse the following project: foo:project");
loader.load(project);
}