diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-02-26 12:15:38 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-02-26 12:15:59 +0100 |
commit | 40f8b2e97602948cec51fb7c21f2c261c85e9a68 (patch) | |
tree | 188846c997155fe7082f99a111b2fb3bcc2ff4eb /sonar-batch/src/test/java/org/sonar/batch/scan | |
parent | ffff70267607aed5f93a01c8f995934e51e0d473 (diff) | |
download | sonarqube-40f8b2e97602948cec51fb7c21f2c261c85e9a68.tar.gz sonarqube-40f8b2e97602948cec51fb7c21f2c261c85e9a68.zip |
SONAR-926 remove ModuleLanguages from API. Replaced by FileSystem#languages()
Diffstat (limited to 'sonar-batch/src/test/java/org/sonar/batch/scan')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java | 69 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java | 13 |
2 files changed, 75 insertions, 7 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java new file mode 100644 index 00000000000..0ef69de6f4d --- /dev/null +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java @@ -0,0 +1,69 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.batch.scan; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.config.Settings; +import org.sonar.api.resources.Java; +import org.sonar.api.resources.Languages; +import org.sonar.api.utils.MessageException; + +public class LanguageVerifierTest { + + Settings settings = new Settings(); + Languages languages = new Languages(Java.INSTANCE); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void language_is_not_set() throws Exception { + LanguageVerifier verifier = new LanguageVerifier(settings, languages); + verifier.start(); + + // no failure + + verifier.stop(); + } + + @Test + public void language_is_valid() throws Exception { + settings.setProperty("sonar.language", "java"); + + LanguageVerifier verifier = new LanguageVerifier(settings, languages); + verifier.start(); + + // no failure + + verifier.stop(); + } + + @Test + public void language_is_not_valid() throws Exception { + thrown.expect(MessageException.class); + thrown.expectMessage("You must install a plugin that supports the language 'php'"); + + settings.setProperty("sonar.language", "php"); + LanguageVerifier verifier = new LanguageVerifier(settings, languages); + verifier.start(); + } +} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java index aef24d43e0b..ceff337ce0e 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java @@ -36,7 +36,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.config.Settings; import org.sonar.api.resources.*; import org.sonar.batch.index.ResourceKeyMigration; -import org.sonar.batch.scan.language.DefaultModuleLanguages; +import org.sonar.batch.scan.LanguageVerifier; import java.io.File; import java.io.IOException; @@ -84,8 +84,7 @@ public class ComponentIndexerTest { fs.add(newInputFile("src/main/java2/foo/bar/Foo.java", "", "foo/bar/Foo.java", "java", false)); fs.add(newInputFile("src/test/java/foo/bar/FooTest.java", "", "foo/bar/FooTest.java", "java", true)); Languages languages = new Languages(Java.INSTANCE); - ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), new DefaultModuleLanguages(settings, languages), - mock(InputFileCache.class)); + ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), mock(InputFileCache.class)); indexer.execute(fs); verify(sonarIndex).index(org.sonar.api.resources.File.create("src/main/java/foo/bar/Foo.java", "foo/bar/Foo.java", Java.INSTANCE, false)); @@ -108,7 +107,7 @@ public class ComponentIndexerTest { fs.add(newInputFile("src/test/foo/bar/FooTest.cbl", "", "foo/bar/FooTest.cbl", "cobol", true)); Languages languages = new Languages(cobolLanguage); - ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), new DefaultModuleLanguages(settings, languages), + ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), mock(InputFileCache.class)); indexer.execute(fs); @@ -123,7 +122,7 @@ public class ComponentIndexerTest { fs.add(newInputFile("src/main/java/foo/bar/Foo.java", "sample code", "foo/bar/Foo.java", "java", false)); Languages languages = new Languages(Java.INSTANCE); - ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), new DefaultModuleLanguages(settings, languages), + ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), mock(InputFileCache.class)); indexer.execute(fs); @@ -163,7 +162,7 @@ public class ComponentIndexerTest { .setPathRelativeToSourceDir("foo/bar/Foo.java") .setLanguage("java")); Languages languages = new Languages(Java.INSTANCE); - ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), new DefaultModuleLanguages(settings, languages), + ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), mock(InputFileCache.class)); indexer.execute(fs); @@ -189,7 +188,7 @@ public class ComponentIndexerTest { .setPathRelativeToSourceDir("foo/bar/Foo.java") .setLanguage("java")); Languages languages = new Languages(Java.INSTANCE); - ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), new DefaultModuleLanguages(settings, languages), + ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, settings, mock(ResourceKeyMigration.class), mock(InputFileCache.class)); indexer.execute(fs); |