From eaac0cad4e8646b2a4ec2c4e1c1abaf2416561f8 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 10 Oct 2013 10:37:58 +0200 Subject: SONAR-4151 Index packages/folders names to allow to get them in measure filters --- .../sonar/core/resource/ResourceIndexerDao.java | 5 ++- .../core/resource/ResourceIndexerDaoTest.java | 39 ---------------------- .../shouldIndexMultiModulesProject-result.xml | 10 ++++++ .../shouldIndexProjects-result.xml | 10 ++++++ .../shouldNotIndexPackages.xml | 24 ------------- 5 files changed, 22 insertions(+), 66 deletions(-) delete mode 100644 sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldNotIndexPackages.xml 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; @@ -77,37 +69,6 @@ public class ResourceIndexerDaoTest extends AbstractDaoTestCase { checkTables("shouldReindexProjectAfterRenaming", new String[] {"id"}, "resource_index"); } - @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 @@ + + + + + + + + + + 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 @@ + + + + + + + + + + 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 @@ - - - - - - - - - - - - - - - -- cgit v1.2.3