diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-10-10 10:37:58 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-10-10 10:38:56 +0200 |
commit | eaac0cad4e8646b2a4ec2c4e1c1abaf2416561f8 (patch) | |
tree | c3465a76cbc0fe6e21a95478a749a950a0189e45 | |
parent | 50cc1a900148b8de597fc78641b97e92da49aacd (diff) | |
download | sonarqube-eaac0cad4e8646b2a4ec2c4e1c1abaf2416561f8.tar.gz sonarqube-eaac0cad4e8646b2a4ec2c4e1c1abaf2416561f8.zip |
SONAR-4151 Index packages/folders names to allow to get them
in measure filters
5 files changed, 22 insertions, 66 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 cce1141aaec..2513f02c616 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,11 +34,10 @@ 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}; - private static final String[] NOT_RENAMABLE_SCOPES = {Scopes.FILE}; + 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 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 e57b1433a48..ab94c9d8865 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,19 +19,11 @@ */ 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; @@ -78,37 +70,6 @@ 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 7210c845707..3b5c9e600f4 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,6 +30,16 @@ <!-- 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 c7484ec4a2a..6789f1680cd 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,6 +23,16 @@ <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 deleted file mode 100644 index 7e7124733f3..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldNotIndexPackages.xml +++ /dev/null @@ -1,24 +0,0 @@ -<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> |