diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-01-08 17:38:52 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-01-08 17:51:06 +0100 |
commit | e054dc1c096dfd7593d6cf9ff36ce0faa021525d (patch) | |
tree | 310fac534d4f682db2c6196d6262a037eea80ad8 /sonar-batch | |
parent | b8f14b0c67995f3372af529772d91ee9c1af8874 (diff) | |
download | sonarqube-e054dc1c096dfd7593d6cf9ff36ce0faa021525d.tar.gz sonarqube-e054dc1c096dfd7593d6cf9ff36ce0faa021525d.zip |
SONAR-3024 Introduce a path attribute on resource to allow distinguish files
that would have the same key with old key pattern
Diffstat (limited to 'sonar-batch')
18 files changed, 344 insertions, 59 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java index 5efdabe3da9..b0ef29a709e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java @@ -28,12 +28,23 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.batch.Event; import org.sonar.api.batch.SonarIndex; +import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.database.model.Snapshot; import org.sonar.api.design.Dependency; -import org.sonar.api.measures.*; -import org.sonar.api.resources.*; +import org.sonar.api.measures.Measure; +import org.sonar.api.measures.MeasuresFilter; +import org.sonar.api.measures.MeasuresFilters; +import org.sonar.api.measures.Metric; +import org.sonar.api.measures.MetricFinder; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.ProjectLink; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.resources.Resource; +import org.sonar.api.resources.ResourceUtils; +import org.sonar.api.resources.Scopes; import org.sonar.api.rules.Rule; import org.sonar.api.rules.Violation; +import org.sonar.api.scan.filesystem.PathResolver; import org.sonar.api.utils.SonarException; import org.sonar.api.violations.ViolationQuery; import org.sonar.batch.DefaultResourceCreationLock; @@ -44,7 +55,14 @@ import org.sonar.batch.issue.ModuleIssues; import org.sonar.core.component.ComponentKeys; import org.sonar.core.component.ScanGraph; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; public class DefaultIndex extends SonarIndex { @@ -69,7 +87,7 @@ public class DefaultIndex extends SonarIndex { private ModuleIssues moduleIssues; public DefaultIndex(PersistenceManager persistence, DefaultResourceCreationLock lock, ProjectTree projectTree, MetricFinder metricFinder, - ScanGraph graph, DeprecatedViolations deprecatedViolations) { + ScanGraph graph, DeprecatedViolations deprecatedViolations) { this.persistence = persistence; this.lock = lock; this.projectTree = projectTree; @@ -91,15 +109,20 @@ public class DefaultIndex extends SonarIndex { persistence.saveProject(rootProject, null); currentProject = rootProject; - for (Project project : rootProject.getModules()) { - addProject(project); + for (Project module : rootProject.getModules()) { + addModule(rootProject, module); } } - private void addProject(Project project) { - addResource(project); - for (Project module : project.getModules()) { - addProject(module); + private void addModule(Project parent, Project module) { + ProjectDefinition parentDefinition = projectTree.getProjectDefinition(parent); + java.io.File parentBaseDir = parentDefinition.getBaseDir(); + ProjectDefinition moduleDefinition = projectTree.getProjectDefinition(module); + java.io.File moduleBaseDir = moduleDefinition.getBaseDir(); + module.setPath(new PathResolver().relativePath(parentBaseDir, moduleBaseDir)); + addResource(module); + for (Project submodule : module.getModules()) { + addModule(module, submodule); } } @@ -371,7 +394,6 @@ public class DefaultIndex extends SonarIndex { moduleIssues.initAndAddViolation(violation); } - // // // diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java index ac2ad1c546c..abe1e4915ef 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java @@ -25,10 +25,16 @@ import org.apache.commons.lang.StringUtils; import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.model.ResourceModel; import org.sonar.api.database.model.Snapshot; -import org.sonar.api.resources.*; +import org.sonar.api.resources.Library; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.resources.Resource; +import org.sonar.api.resources.ResourceUtils; +import org.sonar.api.resources.Scopes; import org.sonar.api.security.ResourcePermissions; import org.sonar.api.utils.SonarException; +import javax.annotation.Nullable; import javax.persistence.NonUniqueResultException; import javax.persistence.Query; @@ -79,7 +85,7 @@ public final class DefaultResourcePersister implements ResourcePersister { // temporary hack project.setEffectiveKey(project.getKey()); - ResourceModel model = findOrCreateModel(project); + ResourceModel model = findOrCreateModel(null, project); // ugly, only for projects model.setLanguageKey(project.getLanguageKey()); @@ -162,7 +168,7 @@ public final class DefaultResourcePersister implements ResourcePersister { } private Snapshot persistLibrary(Project project, Library library) { - ResourceModel model = findOrCreateModel(library); + ResourceModel model = findOrCreateModel(null, library); model = session.save(model); // TODO to be removed library.setId(model.getId()); @@ -204,13 +210,14 @@ public final class DefaultResourcePersister implements ResourcePersister { * Everything except project and library */ private Snapshot persistFileOrDirectory(Project project, Resource resource, Resource parentReference) { - ResourceModel model = findOrCreateModel(resource); - Snapshot projectSnapshot = snapshotsByResource.get(project); - model.setRootId(projectSnapshot.getResourceId()); + Snapshot moduleSnapshot = snapshotsByResource.get(project); + Integer moduleId = moduleSnapshot.getResourceId(); + ResourceModel model = findOrCreateModel(moduleId, resource); + model.setRootId(moduleId); model = session.save(model); resource.setId(model.getId()); - Snapshot parentSnapshot = (Snapshot) ObjectUtils.defaultIfNull(getSnapshot(parentReference), projectSnapshot); + Snapshot parentSnapshot = (Snapshot) ObjectUtils.defaultIfNull(getSnapshot(parentReference), moduleSnapshot); Snapshot snapshot = new Snapshot(model, parentSnapshot); snapshot.setBuildDate(new Date()); snapshot = session.save(snapshot); @@ -242,10 +249,17 @@ public final class DefaultResourcePersister implements ResourcePersister { } } - private ResourceModel findOrCreateModel(Resource resource) { + /** + * @param rootModuleId can be null and in this case resource will be searched using deprecated key instead of path + */ + private ResourceModel findOrCreateModel(@Nullable Integer rootModuleId, Resource resource) { ResourceModel model; try { - model = session.getSingleResult(ResourceModel.class, "key", resource.getEffectiveKey()); + if (rootModuleId != null && StringUtils.isNotBlank(resource.getPath())) { + model = session.getSingleResult(ResourceModel.class, "rootId", rootModuleId, "path", resource.getPath()); + } else { + model = session.getSingleResult(ResourceModel.class, "key", resource.getEffectiveKey()); + } if (model == null) { model = createModel(resource); @@ -264,6 +278,7 @@ public final class DefaultResourcePersister implements ResourcePersister { model.setEnabled(Boolean.TRUE); model.setDescription(resource.getDescription()); model.setKey(resource.getEffectiveKey()); + model.setPath(resource.getPath()); if (resource.getLanguage() != null) { model.setLanguageKey(resource.getLanguage().getKey()); } @@ -295,9 +310,9 @@ public final class DefaultResourcePersister implements ResourcePersister { Qualifiers.MODULE.equals(resource.getQualifier()) && Qualifiers.PROJECT.equals(model.getQualifier())) { throw new SonarException( - String.format("The project '%s' is already defined in SonarQube but not as a module of project '%s'. " - + "If you really want to stop directly analysing project '%s', please first delete it from SonarQube and then relaunch the analysis of project '%s'.", - resource.getKey(), resource.getParent().getKey(), resource.getKey(), resource.getParent().getKey())); + String.format("The project '%s' is already defined in SonarQube but not as a module of project '%s'. " + + "If you really want to stop directly analysing project '%s', please first delete it from SonarQube and then relaunch the analysis of project '%s'.", + resource.getKey(), resource.getParent().getKey(), resource.getKey(), resource.getParent().getKey())); } model.setScope(resource.getScope()); model.setQualifier(resource.getQualifier()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/FileIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/phases/FileIndexer.java new file mode 100644 index 00000000000..ebcf828930e --- /dev/null +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/FileIndexer.java @@ -0,0 +1,73 @@ +/* + * 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.phases; + +import org.sonar.api.BatchComponent; +import org.sonar.api.batch.InstantiationStrategy; +import org.sonar.api.batch.SensorContext; +import org.sonar.api.resources.Java; +import org.sonar.api.resources.JavaFile; +import org.sonar.api.resources.Languages; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.Resource; +import org.sonar.api.scan.filesystem.FileQuery; +import org.sonar.api.scan.filesystem.internal.InputFile; +import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; + +/** + * Index all files/directories of the module in SQ database. + * @since 4.2 + */ +@InstantiationStrategy(InstantiationStrategy.PER_PROJECT) +public class FileIndexer implements BatchComponent { + + private Project module; + private DefaultModuleFileSystem fs; + + private Languages languages; + + public FileIndexer(Project module, DefaultModuleFileSystem fs, Languages languages) { + this.module = module; + this.fs = fs; + this.languages = languages; + } + + public void execute(SensorContext context) { + String languageKey = module.getLanguageKey(); + indexFiles(fs.inputFiles(FileQuery.onSource().onLanguage(languageKey)), false, context, languageKey); + indexFiles(fs.inputFiles(FileQuery.onTest().onLanguage(languageKey)), true, context, languageKey); + } + + private void indexFiles(Iterable<InputFile> files, boolean unitTest, SensorContext context, String languageKey) { + for (InputFile inputFile : files) { + Resource sonarFile; + if (Java.KEY.equals(languageKey)) { + sonarFile = JavaFile.fromRelativePath(inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), unitTest); + } else { + sonarFile = new org.sonar.api.resources.File(languages.get(languageKey), + inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH)); + } + if (sonarFile != null) { + sonarFile.setPath(inputFile.path()); + context.index(sonarFile); + } + } + } +} diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java index c4c4fcb09d2..f337007fe7f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java @@ -47,9 +47,10 @@ public class SensorsExecutor implements BatchComponent { private BatchExtensionDictionnary selector; private final DatabaseSession session; private final SensorMatcher sensorMatcher; + private final FileIndexer fileIndexer; public SensorsExecutor(BatchExtensionDictionnary selector, Project project, DefaultModuleFileSystem fs, MavenPluginExecutor mavenExecutor, EventBus eventBus, - DatabaseSession session, SensorMatcher sensorMatcher) { + DatabaseSession session, SensorMatcher sensorMatcher, FileIndexer fileIndexer) { this.selector = selector; this.mavenExecutor = mavenExecutor; this.eventBus = eventBus; @@ -57,12 +58,15 @@ public class SensorsExecutor implements BatchComponent { this.fs = fs; this.session = session; this.sensorMatcher = sensorMatcher; + this.fileIndexer = fileIndexer; } public void execute(SensorContext context) { Collection<Sensor> sensors = selector.select(Sensor.class, project, true, sensorMatcher); eventBus.fireEvent(new SensorsPhaseEvent(Lists.newArrayList(sensors), true)); + fileIndexer.execute(context); + for (Sensor sensor : sensors) { // SONAR-2965 In case the sensor takes too much time we close the session to not face a timeout session.commitAndClose(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java index 293ad2c065f..e2699fe0572 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java @@ -28,7 +28,13 @@ import org.sonar.api.platform.ComponentContainer; import org.sonar.api.resources.Languages; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.FileExclusions; -import org.sonar.batch.*; +import org.sonar.batch.DefaultProjectClasspath; +import org.sonar.batch.DefaultSensorContext; +import org.sonar.batch.DefaultTimeMachine; +import org.sonar.batch.ProfileProvider; +import org.sonar.batch.ProjectTree; +import org.sonar.batch.ResourceFilters; +import org.sonar.batch.ViolationFilters; import org.sonar.batch.bootstrap.BatchExtensionDictionnary; import org.sonar.batch.bootstrap.ExtensionInstaller; import org.sonar.batch.bootstrap.ExtensionMatcher; @@ -40,9 +46,19 @@ import org.sonar.batch.index.ResourcePersister; import org.sonar.batch.issue.IssuableFactory; import org.sonar.batch.issue.IssueFilters; import org.sonar.batch.issue.ModuleIssues; +import org.sonar.batch.phases.FileIndexer; import org.sonar.batch.phases.PhaseExecutor; import org.sonar.batch.phases.PhasesTimeProfiler; -import org.sonar.batch.scan.filesystem.*; +import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; +import org.sonar.batch.scan.filesystem.DeprecatedFileFilters; +import org.sonar.batch.scan.filesystem.ExclusionFilters; +import org.sonar.batch.scan.filesystem.FileHashes; +import org.sonar.batch.scan.filesystem.FileIndex; +import org.sonar.batch.scan.filesystem.FileSystemLogger; +import org.sonar.batch.scan.filesystem.LanguageRecognizer; +import org.sonar.batch.scan.filesystem.ModuleFileSystemInitializer; +import org.sonar.batch.scan.filesystem.ProjectFileSystemAdapter; +import org.sonar.batch.scan.filesystem.RemoteFileHashes; import org.sonar.batch.scan.report.ComponentSelectorFactory; import org.sonar.batch.scan.report.JsonReport; import org.sonar.core.component.ScanPerspectives; @@ -93,6 +109,7 @@ public class ModuleScanContainer extends ComponentContainer { FileHashes.class, RemoteFileHashes.class, FileIndex.class, + FileIndexer.class, LanguageRecognizer.class, FileSystemLogger.class, DefaultProjectClasspath.class, 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 cd039e17d9a..2b31f72d2a8 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 @@ -22,14 +22,22 @@ package org.sonar.batch.index; import org.apache.commons.lang.StringUtils; import org.junit.Before; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.ResourceFilter; +import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.config.Settings; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Measure; import org.sonar.api.measures.MeasuresFilters; import org.sonar.api.measures.MetricFinder; import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.resources.*; +import org.sonar.api.resources.Directory; +import org.sonar.api.resources.File; +import org.sonar.api.resources.Java; +import org.sonar.api.resources.Library; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.resources.Resource; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.rules.Violation; @@ -42,6 +50,8 @@ import org.sonar.batch.issue.DeprecatedViolations; import org.sonar.batch.issue.ModuleIssues; import org.sonar.core.component.ScanGraph; +import java.io.IOException; + import static com.google.common.collect.Lists.newArrayList; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Matchers.anyString; @@ -50,22 +60,43 @@ import static org.mockito.Mockito.when; public class DefaultIndexTest { + @org.junit.Rule + public TemporaryFolder temp = new TemporaryFolder(); + private DefaultIndex index = null; private DeprecatedViolations deprecatedViolations; private DefaultResourceCreationLock lock; private Rule rule; private RuleFinder ruleFinder; + private Project project; + + private Project moduleA; + + private Project moduleB; + + private Project moduleB1; + @Before - public void createIndex() { + public void createIndex() throws IOException { deprecatedViolations = mock(DeprecatedViolations.class); lock = new DefaultResourceCreationLock(new Settings()); MetricFinder metricFinder = mock(MetricFinder.class); when(metricFinder.findByKey("ncloc")).thenReturn(CoreMetrics.NCLOC); ruleFinder = mock(RuleFinder.class); - index = new DefaultIndex(mock(PersistenceManager.class), lock, mock(ProjectTree.class), metricFinder, mock(ScanGraph.class), deprecatedViolations); - Project project = new Project("project"); + ProjectTree projectTree = mock(ProjectTree.class); + index = new DefaultIndex(mock(PersistenceManager.class), lock, projectTree, metricFinder, mock(ScanGraph.class), deprecatedViolations); + + java.io.File baseDir = temp.newFolder(); + project = new Project("project"); + when(projectTree.getProjectDefinition(project)).thenReturn(ProjectDefinition.create().setBaseDir(baseDir)); + moduleA = new Project("moduleA").setParent(project); + when(projectTree.getProjectDefinition(moduleA)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleA"))); + moduleB = new Project("moduleB").setParent(project); + when(projectTree.getProjectDefinition(moduleB)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB"))); + moduleB1 = new Project("moduleB1").setParent(moduleB); + when(projectTree.getProjectDefinition(moduleB1)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1"))); ResourceFilter filter = new ResourceFilter() { @@ -77,7 +108,7 @@ public class DefaultIndexTest { rule = Rule.create("repoKey", "ruleKey", "Rule"); rule.setId(1); rulesProfile.activateRule(rule, null); - index.setCurrentProject(project, new ResourceFilters(new ResourceFilter[]{filter}), mock(ModuleIssues.class)); + index.setCurrentProject(project, new ResourceFilters(new ResourceFilter[] {filter}), mock(ModuleIssues.class)); index.doStart(project); } @@ -241,6 +272,14 @@ public class DefaultIndexTest { assertThat(index.getViolations(ViolationQuery.create().forResource(file).setSwitchMode(ViolationQuery.SwitchMode.ON))).hasSize(1); } + @Test + public void shouldComputePathOfIndexedModules() { + assertThat(index.getResource(project).getPath()).isNull(); + assertThat(index.getResource(moduleA).getPath()).isEqualTo("/moduleA"); + assertThat(index.getResource(moduleB).getPath()).isEqualTo("/moduleB"); + assertThat(index.getResource(moduleB1).getPath()).isEqualTo("/moduleB1"); + } + @Test(expected = IllegalArgumentException.class) public void testGetViolationsWithQueryWithNoResource() { index.getViolations(ViolationQuery.create()); diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java index 68cba62d50b..6bf3829f442 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java @@ -72,14 +72,17 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { moduleA = newProject("a", "java"); moduleA.setName("A").setAnalysisDate(format.parse("25/12/2010")); moduleA.setParent(multiModuleProject); + moduleA.setPath("/moduleA"); moduleB = newProject("b", "java"); moduleB.setName("B").setAnalysisDate(format.parse("25/12/2010")); moduleB.setParent(multiModuleProject); + moduleB.setPath("/moduleB"); moduleB1 = newProject("b1", "java"); moduleB1.setName("B1").setAnalysisDate(format.parse("25/12/2010")); moduleB1.setParent(moduleB); + moduleB1.setPath("/moduleB1"); } @Test @@ -141,7 +144,19 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), snapshotCache, resourceCache); persister.saveProject(singleProject, null); - persister.saveResource(singleProject, new JavaPackage("org.foo").setEffectiveKey("foo:org.foo")); + persister.saveResource(singleProject, new JavaPackage("org.foo").setEffectiveKey("foo:org.foo").setPath("/src/main/java/org/foo")); + + // check that the directory is attached to the project + checkTables("shouldSaveNewDirectory", new String[] {"build_date", "created_at"}, "projects", "snapshots"); + } + + @Test + public void shouldSaveNewDirectoryAndNormalizePath() { + setupData("shared"); + + ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), snapshotCache, resourceCache); + persister.saveProject(singleProject, null); + persister.saveResource(singleProject, new JavaPackage("org.foo").setEffectiveKey("foo:org.foo").setPath("src/main/java/org/foo/")); // check that the directory is attached to the project checkTables("shouldSaveNewDirectory", new String[] {"build_date", "created_at"}, "projects", "snapshots"); diff --git a/sonar-batch/src/test/java/org/sonar/batch/phases/FileIndexerTest.java b/sonar-batch/src/test/java/org/sonar/batch/phases/FileIndexerTest.java new file mode 100644 index 00000000000..09282526597 --- /dev/null +++ b/sonar-batch/src/test/java/org/sonar/batch/phases/FileIndexerTest.java @@ -0,0 +1,100 @@ +/* + * 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.phases; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.sonar.api.batch.SensorContext; +import org.sonar.api.resources.AbstractLanguage; +import org.sonar.api.resources.Java; +import org.sonar.api.resources.JavaFile; +import org.sonar.api.resources.Languages; +import org.sonar.api.resources.Project; +import org.sonar.api.scan.filesystem.FileQuery; +import org.sonar.api.scan.filesystem.internal.InputFile; +import org.sonar.api.scan.filesystem.internal.InputFileBuilder; +import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class FileIndexerTest { + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + @Test + public void should_index_java_files() throws IOException { + File baseDir = temp.newFolder(); + DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class); + File javaFile1 = new File(baseDir, "src/main/java/foo/bar/Foo.java"); + File javaFile2 = new File(baseDir, "src/main/java2/foo/bar/Foo.java"); + when(fs.inputFiles(FileQuery.onSource().onLanguage(Java.KEY))).thenReturn((Iterable) Arrays.asList( + new InputFileBuilder(javaFile1, "src/main/java/foo/bar/Foo.java").attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/Foo.java").build(), + new InputFileBuilder(javaFile2, "src/main/java2/foo/bar/Foo.java").attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/Foo.java").build())); + File javaTestFile1 = new File(baseDir, "src/test/java/foo/bar/FooTest.java"); + when(fs.inputFiles(FileQuery.onTest().onLanguage(Java.KEY))).thenReturn((Iterable) Arrays.asList( + new InputFileBuilder(javaTestFile1, "src/test/java/foo/bar/FooTest.java").attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/FooTest.java").build())); + Project project = mock(Project.class); + when(project.getLanguageKey()).thenReturn(Java.KEY); + FileIndexer indexer = new FileIndexer(project, fs, new Languages(Java.INSTANCE)); + SensorContext sensorContext = mock(SensorContext.class); + indexer.execute(sensorContext); + + verify(sensorContext).index(new JavaFile("foo.bar.Foo", false).setPath("/src/main/java/foo/bar/Foo.java")); + verify(sensorContext).index(new JavaFile("foo.bar.Foo", false).setPath("/src/main/java2/foo/bar/Foo.java")); + verify(sensorContext).index(new JavaFile("foo.bar.FooTest", true).setPath("/src/test/java/foo/bar/FooTest.java")); + } + + @Test + public void should_index_cobol_files() throws IOException { + File baseDir = temp.newFolder(); + DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class); + File cobolFile1 = new File(baseDir, "src/foo/bar/Foo.cbl"); + File cobolFile2 = new File(baseDir, "src2/foo/bar/Foo.cbl"); + when(fs.inputFiles(FileQuery.onSource().onLanguage("cobol"))).thenReturn((Iterable) Arrays.asList( + new InputFileBuilder(cobolFile1, "src/foo/bar/Foo.cbl").attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/Foo.cbl").build(), + new InputFileBuilder(cobolFile2, "src2/foo/bar/Foo.cbl").attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/Foo.cbl").build())); + File cobolTestFile1 = new File(baseDir, "src/test/foo/bar/FooTest.cbl"); + when(fs.inputFiles(FileQuery.onTest().onLanguage("cobol"))).thenReturn((Iterable) Arrays.asList( + new InputFileBuilder(cobolTestFile1, "src/test/foo/bar/FooTest.cbl").attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, "foo/bar/FooTest.cbl").build())); + Project project = mock(Project.class); + when(project.getLanguageKey()).thenReturn("cobol"); + FileIndexer indexer = new FileIndexer(project, fs, new Languages(new AbstractLanguage("cobol") { + @Override + public String[] getFileSuffixes() { + return new String[] {"cbl"}; + } + })); + SensorContext sensorContext = mock(SensorContext.class); + indexer.execute(sensorContext); + + verify(sensorContext).index(new org.sonar.api.resources.File("foo/bar/Foo.cbl").setPath("/src/foo/bar/Foo.cbl")); + verify(sensorContext).index(new org.sonar.api.resources.File("foo/bar/Foo.cbl").setPath("/src2/foo/bar/Foo.cbl")); + verify(sensorContext).index(new org.sonar.api.resources.File("foo/bar/FooTest.cbl").setPath("/src/test/foo/bar/FooTest.cbl")); + } + +} diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml index 813a604bf6e..2c2a08fa2d0 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" path="[null]"/> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml index bc7fc1c6f0a..36c622aec03 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml @@ -2,7 +2,7 @@ <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" path="[null]"/> <!-- old snapshot --> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" @@ -14,4 +14,4 @@ scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="" status="U" islast="false" depth="0" /> -</dataset>
\ No newline at end of file +</dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml index 8b4092b1e96..1f6a485baa5 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml @@ -3,10 +3,10 @@ <!-- This project has a root_id which should be set to NULL (SONAR-1700) --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="12345" name="name" long_name="long name" description="description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" path="[null]"/> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" status="U" islast="false" depth="0" /> -</dataset>
\ No newline at end of file +</dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveCopyProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveCopyProject-result.xml index e5169508831..c4cc6d2ff4a 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveCopyProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveCopyProject-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,7 +13,7 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="10" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="10" person_id="[null]" path="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml index bfa0198e5b9..9fc216c25c0 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,11 +13,11 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <projects id="1002" scope="DIR" qualifier="PAC" kee="foo:org.foo" root_id="1001" name="org.foo" long_name="org.foo" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="/src/main/java/org/foo" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="" @@ -27,4 +27,4 @@ scope="DIR" qualifier="PAC" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="3001." status="U" islast="false" depth="1"/> -</dataset>
\ No newline at end of file +</dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml index 7c4ab1f4008..52fb16bf0b9 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,7 +13,7 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <projects id="1002" scope="PRJ" qualifier="LIB" kee="junit:junit" root_id="[null]" name="junit:junit" long_name="junit:junit" description="[null]" @@ -31,4 +31,4 @@ scope="PRJ" qualifier="LIB" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="3.2" path="" status="P" islast="false" depth="0" /> -</dataset>
\ No newline at end of file +</dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml index a36b177dafb..7a122621b18 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,19 +13,19 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="root" root_id="[null]" name="Root" long_name="Root" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <projects id="1002" scope="PRJ" qualifier="BRC" kee="a" root_id="1001" name="A" long_name="A" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="/moduleA" /> <projects id="1003" scope="PRJ" qualifier="BRC" kee="b" root_id="1001" name="B" long_name="B" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="/moduleB" /> <projects id="1004" scope="PRJ" qualifier="BRC" kee="b1" root_id="1001" name="B1" long_name="B1" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="/moduleB1" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" root_project_id="1001" parent_snapshot_id="[null]" root_snapshot_id="[null]" @@ -45,4 +45,4 @@ status="U" islast="false" depth="2" /> -</dataset>
\ No newline at end of file +</dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml index 9f7c802b57e..518d992a4a8 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,10 +13,10 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="" status="U" islast="false" depth="0" /> -</dataset>
\ No newline at end of file +</dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml index 4fe4bcf5894..a668b5f3457 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml @@ -2,7 +2,7 @@ <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="new name" long_name="new name" description="new description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <!-- old snapshot --> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" @@ -14,4 +14,4 @@ scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="" status="U" islast="false" depth="0" /> -</dataset>
\ No newline at end of file +</dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml index 23570debd77..9146bc2749e 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml @@ -2,10 +2,10 @@ <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="old name" long_name="old name" description="old description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" status="U" islast="false" depth="0" /> -</dataset>
\ No newline at end of file +</dataset> |