diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-10-10 17:34:35 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-10-10 17:34:35 +0200 |
commit | 7cc177f8e0868eadbd592d9f4f3d98283729a912 (patch) | |
tree | 2e30da23e12c9a791fe8cce2bbc799a34d816239 /sonar-core | |
parent | cc5f83f1feed5013d16fc32890765925948c3d1b (diff) | |
download | sonarqube-7cc177f8e0868eadbd592d9f4f3d98283729a912.tar.gz sonarqube-7cc177f8e0868eadbd592d9f4f3d98283729a912.zip |
Revert "SONAR-4151 Index packages/folders names to allow to get them"
This reverts commit eaac0cad4e8646b2a4ec2c4e1c1abaf2416561f8.
Diffstat (limited to 'sonar-core')
5 files changed, 66 insertions, 22 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java index 2513f02c616..cce1141aaec 100644 --- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java +++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java @@ -34,10 +34,11 @@ public class ResourceIndexerDao { public static final int SINGLE_INDEX_SIZE = 2; // The scopes and qualifiers that are not in the following constants are not indexed at all. + // Directories and packages are explicitly excluded. private static final String[] RENAMABLE_QUALIFIERS = {Qualifiers.PROJECT, Qualifiers.MODULE, Qualifiers.VIEW, Qualifiers.SUBVIEW}; private static final String[] RENAMABLE_SCOPES = {Scopes.PROJECT}; - private static final String[] NOT_RENAMABLE_QUALIFIERS = {Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE, Qualifiers.CLASS, Qualifiers.DIRECTORY, Qualifiers.PACKAGE}; - private static final String[] NOT_RENAMABLE_SCOPES = {Scopes.FILE, Scopes.DIRECTORY}; + private static final String[] NOT_RENAMABLE_QUALIFIERS = {Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE, Qualifiers.CLASS}; + private static final String[] NOT_RENAMABLE_SCOPES = {Scopes.FILE}; private final MyBatis mybatis; diff --git a/sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java b/sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java index ab94c9d8865..e57b1433a48 100644 --- a/sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java @@ -19,11 +19,19 @@ */ package org.sonar.core.resource; +import org.hamcrest.core.Is; import org.junit.Before; import org.junit.Test; import org.sonar.api.resources.Qualifiers; import org.sonar.core.persistence.AbstractDaoTestCase; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; + +import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.junit.Assert.assertThat; + public class ResourceIndexerDaoTest extends AbstractDaoTestCase { private static ResourceIndexerDao dao; @@ -70,6 +78,37 @@ public class ResourceIndexerDaoTest extends AbstractDaoTestCase { } @Test + public void shouldNotIndexPackages() throws SQLException { + setupData("shouldNotIndexPackages"); + + dao.indexProject(1); + + Connection connection = getConnection(); + ResultSet rs = null; + try { + // project + rs = connection.createStatement().executeQuery("select count(resource_id) from resource_index where resource_id=1"); + rs.next(); + assertThat(rs.getInt(1), greaterThan(0)); + + // directory + rs = connection.createStatement().executeQuery("select count(resource_id) from resource_index where resource_id=2"); + rs.next(); + assertThat(rs.getInt(1), Is.is(0)); + + // file + rs = connection.createStatement().executeQuery("select count(resource_id) from resource_index where resource_id=3"); + rs.next(); + assertThat(rs.getInt(1), greaterThan(0)); + } finally { + if (null != rs) { + rs.close(); + } + connection.close(); + } + } + + @Test public void shouldIndexTwoLettersLongResources() { setupData("shouldIndexTwoLettersLongResource"); diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexMultiModulesProject-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexMultiModulesProject-result.xml index 3b5c9e600f4..7210c845707 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexMultiModulesProject-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexMultiModulesProject-result.xml @@ -30,16 +30,6 @@ <!-- The major goal is to test root_project_id --> - <!-- org.struts --> - <resource_index kee="org.struts" position="0" name_size="10" resource_id="3" root_project_id="1" qualifier="PAC"/> - <resource_index kee="rg.struts" position="1" name_size="10" resource_id="3" root_project_id="1" qualifier="PAC"/> - <resource_index kee="g.struts" position="2" name_size="10" resource_id="3" root_project_id="1" qualifier="PAC"/> - <resource_index kee=".struts" position="3" name_size="10" resource_id="3" root_project_id="1" qualifier="PAC"/> - <resource_index kee="struts" position="4" name_size="10" resource_id="3" root_project_id="1" qualifier="PAC"/> - <resource_index kee="truts" position="5" name_size="10" resource_id="3" root_project_id="1" qualifier="PAC"/> - <resource_index kee="ruts" position="6" name_size="10" resource_id="3" root_project_id="1" qualifier="PAC"/> - <resource_index kee="uts" position="7" name_size="10" resource_id="3" root_project_id="1" qualifier="PAC"/> - <!-- RequestContext --> <resource_index kee="requestcontext" position="0" name_size="14" resource_id="4" root_project_id="1" qualifier="CLA"/> <resource_index kee="equestcontext" position="1" name_size="14" resource_id="4" root_project_id="1" qualifier="CLA"/> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexProjects-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexProjects-result.xml index 6789f1680cd..c7484ec4a2a 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexProjects-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexProjects-result.xml @@ -23,16 +23,6 @@ <snapshots purge_status="[null]" id="2" islast="[true]" root_project_id="1" project_id="2" scope="DIR" qualifier="PAC"/> <snapshots purge_status="[null]" id="3" islast="[true]" root_project_id="1" project_id="3" scope="CLA" qualifier="CLA"/> - <!-- org.struts --> - <resource_index kee="org.struts" position="0" name_size="10" resource_id="2" root_project_id="1" qualifier="PAC"/> - <resource_index kee="rg.struts" position="1" name_size="10" resource_id="2" root_project_id="1" qualifier="PAC"/> - <resource_index kee="g.struts" position="2" name_size="10" resource_id="2" root_project_id="1" qualifier="PAC"/> - <resource_index kee=".struts" position="3" name_size="10" resource_id="2" root_project_id="1" qualifier="PAC"/> - <resource_index kee="struts" position="4" name_size="10" resource_id="2" root_project_id="1" qualifier="PAC"/> - <resource_index kee="truts" position="5" name_size="10" resource_id="2" root_project_id="1" qualifier="PAC"/> - <resource_index kee="ruts" position="6" name_size="10" resource_id="2" root_project_id="1" qualifier="PAC"/> - <resource_index kee="uts" position="7" name_size="10" resource_id="2" root_project_id="1" qualifier="PAC"/> - <!-- RequestContext --> <resource_index kee="requestcontext" position="0" name_size="14" resource_id="3" root_project_id="1" qualifier="CLA"/> <resource_index kee="equestcontext" position="1" name_size="14" resource_id="3" root_project_id="1" qualifier="CLA"/> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldNotIndexPackages.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldNotIndexPackages.xml new file mode 100644 index 00000000000..7e7124733f3 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldNotIndexPackages.xml @@ -0,0 +1,24 @@ +<dataset> + + <!-- project --> + <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" + root_id="[null]" + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + + <!-- directory --> + <projects long_name="org.struts" id="2" scope="DIR" qualifier="PAC" kee="org.struts:struts:org.struts" + name="org.struts" root_id="1" + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + + <!-- file --> + <projects long_name="org.struts.RequestContext" id="3" scope="FIL" qualifier="CLA" kee="org.struts:struts:org.struts.RequestContext" + name="RequestContext" root_id="1" + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + + <snapshots purge_status="[null]" id="1" islast="[true]" root_project_id="1" project_id="1" scope="PRJ" qualifier="TRK"/> + <snapshots purge_status="[null]" id="2" islast="[true]" root_project_id="1" project_id="2" scope="DIR" qualifier="PAC"/> + <snapshots purge_status="[null]" id="3" islast="[true]" root_project_id="1" project_id="3" scope="FIL" qualifier="CLA"/> +</dataset> |