diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-08-21 17:26:04 +0200 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-08-24 09:54:39 +0200 |
commit | 1dd1cd5c6517ffe91ae9b0b003d65c126d54b4b4 (patch) | |
tree | c6dee9cbf1f0599c5e7c19747dc7d762b5859c14 /sonar-batch/src/test/java | |
parent | a805e4796f8826acc73f2078e7374f1956402dfd (diff) | |
download | sonarqube-1dd1cd5c6517ffe91ae9b0b003d65c126d54b4b4.tar.gz sonarqube-1dd1cd5c6517ffe91ae9b0b003d65c126d54b4b4.zip |
SONAR-6658 Drop validation on sonar.libraries and sonar.binaries
Diffstat (limited to 'sonar-batch/src/test/java')
4 files changed, 44 insertions, 107 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java index 0aaf6e2dfd2..f42cdc208d5 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java @@ -52,12 +52,11 @@ public class DeprecatedProjectReactorBuilderTest { assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project"); // root project must not contain some properties - even if they are defined in the root properties file - assertThat(rootProject.getSourceDirs().contains("sources")).isFalse(); - assertThat(rootProject.getTestDirs().contains("tests")).isFalse(); - assertThat(rootProject.getBinaries().contains("target/classes")).isFalse(); + assertThat(rootProject.sources().contains("sources")).isFalse(); + assertThat(rootProject.tests().contains("tests")).isFalse(); // and module properties must have been cleaned - assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull(); - assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull(); + assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull(); + assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull(); // CHECK MODULES List<ProjectDefinition> modules = rootProject.getSubProjects(); @@ -71,12 +70,11 @@ public class DeprecatedProjectReactorBuilderTest { assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT"); // Description should not be inherited from parent if not set assertThat(module1.getDescription()).isEqualTo("Description of Module 1"); - assertThat(module1.getSourceDirs()).contains("sources"); - assertThat(module1.getTestDirs()).contains("tests"); - assertThat(module1.getBinaries()).contains("target/classes"); + assertThat(module1.sources()).contains("sources"); + assertThat(module1.tests()).contains("tests"); // and module properties must have been cleaned - assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull(); - assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull(); + assertThat(module1.properties().get("module1.sonar.projectKey")).isNull(); + assertThat(module1.properties().get("module2.sonar.projectKey")).isNull(); // Module 2 ProjectDefinition module2 = modules.get(1); @@ -85,12 +83,11 @@ public class DeprecatedProjectReactorBuilderTest { assertThat(module2.getName()).isEqualTo("Foo Module 2"); assertThat(module2.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(module2.getDescription()).isEqualTo("Description of Module 2"); - assertThat(module2.getSourceDirs()).contains("src"); - assertThat(module2.getTestDirs()).contains("tests"); - assertThat(module2.getBinaries()).contains("target/classes"); + assertThat(module2.sources()).contains("src"); + assertThat(module2.tests()).contains("tests"); // and module properties must have been cleaned - assertThat(module2.getProperties().getProperty("module1.sonar.projectKey")).isNull(); - assertThat(module2.getProperties().getProperty("module2.sonar.projectKey")).isNull(); + assertThat(module2.properties().get("module1.sonar.projectKey")).isNull(); + assertThat(module2.properties().get("module2.sonar.projectKey")).isNull(); } @Test @@ -103,12 +100,11 @@ public class DeprecatedProjectReactorBuilderTest { assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project"); // root project must not contain some properties - even if they are defined in the root properties file - assertThat(rootProject.getSourceDirs().contains("sources")).isFalse(); - assertThat(rootProject.getTestDirs().contains("tests")).isFalse(); - assertThat(rootProject.getBinaries().contains("target/classes")).isFalse(); + assertThat(rootProject.sources().contains("sources")).isFalse(); + assertThat(rootProject.tests().contains("tests")).isFalse(); // and module properties must have been cleaned - assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull(); - assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull(); + assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull(); + assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull(); // CHECK MODULES List<ProjectDefinition> modules = rootProject.getSubProjects(); @@ -122,12 +118,11 @@ public class DeprecatedProjectReactorBuilderTest { assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT"); // Description should not be inherited from parent if not set assertThat(module1.getDescription()).isNull(); - assertThat(module1.getSourceDirs()).contains("sources"); - assertThat(module1.getTestDirs()).contains("tests"); - assertThat(module1.getBinaries()).contains("target/classes"); + assertThat(module1.sources()).contains("sources"); + assertThat(module1.tests()).contains("tests"); // and module properties must have been cleaned - assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull(); - assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull(); + assertThat(module1.properties().get("module1.sonar.projectKey")).isNull(); + assertThat(module1.properties().get("module2.sonar.projectKey")).isNull(); // Module 2 ProjectDefinition module2 = modules.get(1); @@ -136,12 +131,11 @@ public class DeprecatedProjectReactorBuilderTest { assertThat(module2.getName()).isEqualTo("Foo Module 2"); assertThat(module2.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(module2.getDescription()).isEqualTo("Description of Module 2"); - assertThat(module2.getSourceDirs()).contains("src"); - assertThat(module2.getTestDirs()).contains("tests"); - assertThat(module2.getBinaries()).contains("target/classes"); + assertThat(module2.sources()).contains("src"); + assertThat(module2.tests()).contains("tests"); // and module properties must have been cleaned - assertThat(module2.getProperties().getProperty("module1.sonar.projectKey")).isNull(); - assertThat(module2.getProperties().getProperty("module2.sonar.projectKey")).isNull(); + assertThat(module2.properties().get("module1.sonar.projectKey")).isNull(); + assertThat(module2.properties().get("module2.sonar.projectKey")).isNull(); } @Test diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java index b4bdeb07877..8db640586d8 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java @@ -52,9 +52,7 @@ public class ProjectReactorBuilderTest { assertThat(projectDefinition.getName()).isEqualTo("Foo Project"); assertThat(projectDefinition.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(projectDefinition.getDescription()).isEqualTo("Description of Foo Project"); - assertThat(projectDefinition.getSourceDirs()).contains("sources"); - assertThat(projectDefinition.getLibraries()).contains(TestUtils.getResource(this.getClass(), "simple-project/libs/lib2.txt").getAbsolutePath(), - TestUtils.getResource(this.getClass(), "simple-project/libs/lib2.txt").getAbsolutePath()); + assertThat(projectDefinition.sources()).contains("sources"); } @Test @@ -96,9 +94,8 @@ public class ProjectReactorBuilderTest { assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project"); // root project must not contain some properties - even if they are defined in the root properties file - assertThat(rootProject.getSourceDirs().contains("sources")).isFalse(); - assertThat(rootProject.getTestDirs().contains("tests")).isFalse(); - assertThat(rootProject.getBinaries().contains("target/classes")).isFalse(); + assertThat(rootProject.sources().contains("sources")).isFalse(); + assertThat(rootProject.tests().contains("tests")).isFalse(); // and module properties must have been cleaned assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull(); assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull(); @@ -120,9 +117,8 @@ public class ProjectReactorBuilderTest { assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT"); // Description should not be inherited from parent if not set assertThat(module1.getDescription()).isNull(); - assertThat(module1.getSourceDirs()).contains("sources"); - assertThat(module1.getTestDirs()).contains("tests"); - assertThat(module1.getBinaries()).contains("target/classes"); + assertThat(module1.sources()).contains("sources"); + assertThat(module1.tests()).contains("tests"); // and module properties must have been cleaned assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull(); assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull(); @@ -139,9 +135,8 @@ public class ProjectReactorBuilderTest { assertThat(module2.getName()).isEqualTo("Foo Module 2"); assertThat(module2.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(module2.getDescription()).isEqualTo("Description of Module 2"); - assertThat(module2.getSourceDirs()).contains("src"); - assertThat(module2.getTestDirs()).contains("tests"); - assertThat(module2.getBinaries()).contains("target/classes"); + assertThat(module2.sources()).contains("src"); + assertThat(module2.tests()).contains("tests"); // and module properties must have been cleaned assertThat(module2.getProperties().getProperty("module1.sonar.projectKey")).isNull(); assertThat(module2.getProperties().getProperty("module2.sonar.projectKey")).isNull(); @@ -188,7 +183,7 @@ public class ProjectReactorBuilderTest { // Module 1 ProjectDefinition module1 = modules.get(0); assertThat(module1.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root")); - assertThat(module1.getSourceDirs()).contains("src/main/java"); + assertThat(module1.sources()).contains("src/main/java"); // and module properties must have been cleaned assertThat(module1.getWorkDir().getCanonicalFile()) .isEqualTo(new File(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_java-module")); @@ -196,7 +191,7 @@ public class ProjectReactorBuilderTest { // Module 2 ProjectDefinition module2 = modules.get(1); assertThat(module2.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root")); - assertThat(module2.getSourceDirs()).contains("src/main/groovy"); + assertThat(module2.sources()).contains("src/main/groovy"); // and module properties must have been cleaned assertThat(module2.getWorkDir().getCanonicalFile()) .isEqualTo(new File(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_groovy-module")); @@ -243,33 +238,6 @@ public class ProjectReactorBuilderTest { } @Test - public void shouldFailIfExplicitUnexistingBinaryFolder() { - thrown.expect(IllegalStateException.class); - thrown.expectMessage("The folder 'bin' does not exist for 'com.foo.project' (base directory = " - + TestUtils.getResource(this.getClass(), "simple-project-with-unexisting-binary").getAbsolutePath()); - - loadProjectDefinition("simple-project-with-unexisting-binary"); - } - - @Test - public void shouldFailIfExplicitUnmatchingLibFolder() { - thrown.expect(IllegalStateException.class); - thrown.expectMessage("No files nor directories matching 'libs/*.txt' in directory " - + TestUtils.getResource(this.getClass(), "simple-project-with-unexisting-lib").getAbsolutePath()); - - loadProjectDefinition("simple-project-with-unexisting-lib"); - } - - @Test - public void shouldGetLibDirectory() { - ProjectDefinition def = loadProjectDefinition("simple-project-with-lib-dir"); - assertThat(def.getLibraries()).hasSize(1); - File libDir = new File(def.getLibraries().get(0)); - assertThat(libDir).isDirectory().exists(); - assertThat(libDir.getName()).isEqualTo("lib"); - } - - @Test public void shouldFailIfExplicitUnexistingTestFolderOnModule() { thrown.expect(IllegalStateException.class); thrown.expectMessage("The folder 'tests' does not exist for 'module1' (base directory = " @@ -279,24 +247,6 @@ public class ProjectReactorBuilderTest { } @Test - public void shouldFailIfExplicitUnexistingBinaryFolderOnModule() { - thrown.expect(IllegalStateException.class); - thrown.expectMessage("The folder 'bin' does not exist for 'module1' (base directory = " - + TestUtils.getResource(this.getClass(), "multi-module-with-explicit-unexisting-binary-dir").getAbsolutePath() + File.separator + "module1)"); - - loadProjectDefinition("multi-module-with-explicit-unexisting-binary-dir"); - } - - @Test - public void shouldFailIfExplicitUnmatchingLibFolderOnModule() { - thrown.expect(IllegalStateException.class); - thrown.expectMessage("No files nor directories matching 'lib/*.jar' in directory " - + TestUtils.getResource(this.getClass(), "multi-module-with-explicit-unexisting-lib").getAbsolutePath() + File.separator + "module1"); - - loadProjectDefinition("multi-module-with-explicit-unexisting-lib"); - } - - @Test public void multiModuleProperties() { ProjectDefinition projectDefinition = loadProjectDefinition("big-multi-module-definitions-all-in-root"); @@ -583,9 +533,8 @@ public class ProjectReactorBuilderTest { assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project"); // root project must not contain some properties - even if they are defined in the root properties file - assertThat(rootProject.getSourceDirs().contains("sources")).isFalse(); - assertThat(rootProject.getTestDirs().contains("tests")).isFalse(); - assertThat(rootProject.getBinaries().contains("target/classes")).isFalse(); + assertThat(rootProject.sources().contains("sources")).isFalse(); + assertThat(rootProject.tests().contains("tests")).isFalse(); // and module properties must have been cleaned assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull(); assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull(); @@ -607,9 +556,8 @@ public class ProjectReactorBuilderTest { assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT"); // Description should not be inherited from parent if not set assertThat(module1.getDescription()).isNull(); - assertThat(module1.getSourceDirs()).contains("sources"); - assertThat(module1.getTestDirs()).contains("tests"); - assertThat(module1.getBinaries()).contains("target/classes"); + assertThat(module1.sources()).contains("sources"); + assertThat(module1.tests()).contains("tests"); // and module properties must have been cleaned assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull(); assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull(); @@ -626,9 +574,8 @@ public class ProjectReactorBuilderTest { assertThat(module1Feature.getName()).isEqualTo("Foo Module 1 Feature"); assertThat(module1Feature.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(module1Feature.getDescription()).isEqualTo("Description of Module 1 Feature"); - assertThat(module1Feature.getSourceDirs()).contains("src"); - assertThat(module1Feature.getTestDirs()).contains("tests"); - assertThat(module1Feature.getBinaries()).contains("target/classes"); + assertThat(module1Feature.sources()).contains("src"); + assertThat(module1Feature.tests()).contains("tests"); // and module properties must have been cleaned assertThat(module1Feature.getProperties().getProperty("module1.sonar.projectKey")).isNull(); assertThat(module1Feature.getProperties().getProperty("module2.sonar.projectKey")).isNull(); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java index 4a5e04b4a8e..1486b1b5482 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java @@ -82,7 +82,7 @@ public class DefaultModuleFileSystemTest { DefaultModuleFileSystem fs = new DefaultModuleFileSystem(moduleInputFileCache, new Project("foo"), settings, fileIndexer, initializer, componentIndexer); - assertThat(fs.sourceCharset()).isEqualTo(Charset.defaultCharset()); + assertThat(fs.encoding()).isEqualTo(Charset.defaultCharset()); assertThat(fs.isDefaultJvmEncoding()).isTrue(); } @@ -93,7 +93,7 @@ public class DefaultModuleFileSystemTest { new Project("foo"), settings, fileIndexer, initializer, componentIndexer); assertThat(fs.encoding()).isEqualTo(Charset.forName("Cp1124")); - assertThat(fs.sourceCharset()).isEqualTo(Charset.forName("Cp1124")); + assertThat(fs.encoding()).isEqualTo(Charset.forName("Cp1124")); // This test fails when default Java encoding is "IBM AIX Ukraine". Sorry for that. assertThat(fs.isDefaultJvmEncoding()).isFalse(); @@ -109,7 +109,6 @@ public class DefaultModuleFileSystemTest { when(initializer.baseDir()).thenReturn(basedir); when(initializer.buildDir()).thenReturn(buildDir); when(initializer.workingDir()).thenReturn(workingDir); - when(initializer.binaryDirs()).thenReturn(Arrays.asList(new File(basedir, "target/classes"))); File javaSrc = new File(basedir, "src/main/java"); javaSrc.mkdirs(); File groovySrc = new File(basedir, "src/main/groovy"); @@ -127,7 +126,7 @@ public class DefaultModuleFileSystemTest { assertThat(fs.buildDir().getCanonicalPath()).isEqualTo(buildDir.getCanonicalPath()); assertThat(fs.sourceDirs()).hasSize(2); assertThat(fs.testDirs()).hasSize(1); - assertThat(fs.binaryDirs()).hasSize(1); + assertThat(fs.binaryDirs()).hasSize(0); } @Test diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java index 53ee455adfb..815ead7e5bd 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java @@ -69,9 +69,8 @@ public class ModuleFileSystemInitializerTest { ProjectDefinition project = ProjectDefinition.create() .setBaseDir(baseDir) .setBuildDir(buildDir) - .addSourceDirs("src/main/java", "src/main/unknown") - .addTestDirs("src/test/java", "src/test/unknown") - .addBinaryDir("target/classes"); + .addSources("src/main/java", "src/main/unknown") + .addTests("src/test/java", "src/test/unknown"); ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(project, mock(TempFolder.class), pathResolver); @@ -81,8 +80,6 @@ public class ModuleFileSystemInitializerTest { assertThat(path(initializer.sources().get(0))).endsWith("src/main/java"); assertThat(initializer.tests()).hasSize(1); assertThat(path(initializer.tests().get(0))).endsWith("src/test/java"); - assertThat(initializer.binaryDirs()).hasSize(1); - assertThat(path(initializer.binaryDirs().get(0))).endsWith("target/classes"); } private String path(File f) throws IOException { |