aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src/test/java/org')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java70
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java72
3 files changed, 2 insertions, 143 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
index c18ce10a540..eccd889ff7e 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
@@ -35,6 +35,7 @@ import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
+import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.sensor.DefaultSensorStorage;
@@ -64,7 +65,7 @@ public class DefaultIndexTest {
DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
BatchComponentCache resourceCache = new BatchComponentCache();
- index = new DefaultIndex(resourceCache, projectTree, mock(MeasureCache.class));
+ index = new DefaultIndex(resourceCache, projectTree, mock(MeasureCache.class), new PathResolver());
baseDir = temp.newFolder();
project = new Project("project");
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 d199bce50c9..0aea951a706 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
@@ -68,8 +68,6 @@ public class ProjectReactorBuilderTest {
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());
}
@Test
@@ -130,7 +128,6 @@ public class ProjectReactorBuilderTest {
// 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();
// and module properties must have been cleaned
assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull();
assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull();
@@ -261,11 +258,6 @@ public class ProjectReactorBuilderTest {
}
@Test
- public void shouldNotFailIfUnexistingTestBinLibFolderInheritedInMultimodule() {
- loadProjectDefinition("multi-module-with-unexisting-test-bin-lib-dir");
- }
-
- @Test
public void shouldFailIfExplicitUnexistingTestFolder() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("The folder 'tests' does not exist for 'com.foo.project' (base directory = "
@@ -275,33 +267,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 = "
@@ -311,24 +276,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");
@@ -416,22 +363,6 @@ public class ProjectReactorBuilderTest {
}
@Test
- public void shouldFilterFiles() {
- File baseDir = TestUtils.getResource(this.getClass(), "shouldFilterFiles");
- assertThat(ProjectReactorBuilder.getLibraries(baseDir, "in*.txt")).hasSize(1);
- assertThat(ProjectReactorBuilder.getLibraries(baseDir, "*.txt")).hasSize(2);
- assertThat(ProjectReactorBuilder.getLibraries(baseDir.getParentFile(), "shouldFilterFiles/in*.txt")).hasSize(1);
- assertThat(ProjectReactorBuilder.getLibraries(baseDir.getParentFile(), "shouldFilterFiles/*.txt")).hasSize(2);
- }
-
- @Test
- public void shouldWorkWithAbsolutePath() {
- File baseDir = new File("not-exists");
- String absolutePattern = TestUtils.getResource(this.getClass(), "shouldFilterFiles").getAbsolutePath() + "/in*.txt";
- assertThat(ProjectReactorBuilder.getLibraries(baseDir.getParentFile(), absolutePattern)).hasSize(1);
- }
-
- @Test
public void shouldGetRelativeFile() {
assertThat(ProjectReactorBuilder.resolvePath(TestUtils.getResource(this.getClass(), "/"), "shouldGetFile/foo.properties"))
.isEqualTo(TestUtils.getResource(this.getClass(), "shouldGetFile/foo.properties"));
@@ -639,7 +570,6 @@ public class ProjectReactorBuilderTest {
// 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();
// and module properties must have been cleaned
assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull();
assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java
deleted file mode 100644
index c75ad09cc0b..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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.filesystem;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.mockito.Mockito;
-import org.sonar.api.resources.Project;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ProjectFileSystemAdapterTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Test
- public void should_wrap_module_file_system() {
- DefaultModuleFileSystem target = mock(DefaultModuleFileSystem.class, Mockito.RETURNS_SMART_NULLS);
- ProjectFileSystemAdapter adapter = new ProjectFileSystemAdapter(target, new Project("my-project"));
-
- assertThat(adapter.getBasedir()).isNotNull();
- verify(target).baseDir();
-
- assertThat(adapter.getSourceDirs()).isNotNull();
- verify(target).sourceDirs();
-
- assertThat(adapter.getTestDirs()).isNotNull();
- verify(target).testDirs();
-
- assertThat(adapter.getSourceCharset()).isNotNull();
- verify(target).sourceCharset();
-
- assertThat(adapter.getBuildDir()).isNotNull();
- verify(target).buildDir();
- }
-
- @Test
- public void should_create_default_build_dir() throws IOException {
- File workingDir = temp.newFile("work");
- DefaultModuleFileSystem target = mock(DefaultModuleFileSystem.class);
- when(target.workDir()).thenReturn(workingDir);
- ProjectFileSystemAdapter adapter = new ProjectFileSystemAdapter(target, new Project("my-project"));
-
- File buildDir = adapter.getBuildDir();
- assertThat(buildDir.getParentFile().getCanonicalPath()).isEqualTo(workingDir.getCanonicalPath());
- }
-}