]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4560 Index resources up to the first character in order to support 2 letters...
authorJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>
Wed, 7 Aug 2013 15:22:08 +0000 (17:22 +0200)
committerJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>
Wed, 7 Aug 2013 15:22:08 +0000 (17:22 +0200)
13 files changed:
sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java
sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/empty-result.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/empty.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexMultiModulesProject-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexProjects-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexResource-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexTwoLettersLongResource-result.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexTwoLettersLongResource.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldNotReindexUnchangedResource-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldNotReindexUnchangedResource.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldReindexProjectAfterRenaming-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldReindexResource-result.xml

index a07d48ec505b45a6f9adfaf25c3940365e792917..d516c1948f8f45c5e93343e0c53a71b8bf640355 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.core.persistence.MyBatis;
 
 public class ResourceIndexerDao {
 
-  public static final int MINIMUM_KEY_SIZE = 3;
+  public static final int MINIMUM_KEY_SIZE = 1;
 
   // The scopes and qualifiers that are not in the following constants are not indexed at all.
   // Directories and packages are explicitly excluded.
index 9e39f4fb58bc11e8c22e7cd4e7c19c372aaafec8..4784e2a26bcc9a2a66d655d5b6988d34e5ceb7e2 100644 (file)
@@ -109,12 +109,12 @@ public class ResourceIndexerDaoTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void shouldNotIndexWhenTooShortName() {
-    setupData("empty");
+  public void shouldIndexTwoLettersLongResources() {
+    setupData("shouldIndexTwoLettersLongResource");
 
     dao.indexResource(10, "AB", Qualifiers.FILE, 3);
 
-    checkTables("empty", new String[] {"id"}, "resource_index");
+    checkTables("shouldIndexTwoLettersLongResource", new String[] {"id"}, "resource_index");
   }
 
   @Test
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/empty-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/empty-result.xml
deleted file mode 100644 (file)
index df17d41..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<dataset>
-  <resource_index kee="other" position="0" name_size="5" resource_id="4" root_project_id="1" qualifier="CLA"/>
-</dataset>
\ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/empty.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/empty.xml
deleted file mode 100644 (file)
index 35999df..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<dataset>
-  <resource_index id="1" kee="other" position="0" name_size="5" resource_id="4" root_project_id="1" qualifier="CLA"/>
-</dataset>
\ No newline at end of file
index 7210c845707aacc4df4e5c307989f0cf7e3582d7..657d233a00a3d2b3907042ec359cd85b5e13ff01 100644 (file)
   <resource_index kee="ntext" position="9" name_size="14" resource_id="4" root_project_id="1" qualifier="CLA"/>
   <resource_index kee="text" position="10" name_size="14" resource_id="4" root_project_id="1" qualifier="CLA"/>
   <resource_index kee="ext" position="11" name_size="14" resource_id="4" root_project_id="1" qualifier="CLA"/>
+  <resource_index kee="xt" position="12" name_size="14" resource_id="4" root_project_id="1" qualifier="CLA"/>
+  <resource_index kee="t" position="13" name_size="14" resource_id="4" root_project_id="1" qualifier="CLA"/>
 
   <!-- Struts -->
   <resource_index kee="struts" position="0" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="truts" position="1" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="ruts" position="2" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="uts" position="3" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="ts" position="4" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="s" position="5" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
 
   <!-- Struts Core -->
   <resource_index kee="struts core" position="0" name_size="11" resource_id="2" root_project_id="1" qualifier="BRC"/>
@@ -60,6 +64,8 @@
   <resource_index kee=" core" position="6" name_size="11" resource_id="2" root_project_id="1" qualifier="BRC"/>
   <resource_index kee="core" position="7" name_size="11" resource_id="2" root_project_id="1" qualifier="BRC"/>
   <resource_index kee="ore" position="8" name_size="11" resource_id="2" root_project_id="1" qualifier="BRC"/>
+  <resource_index kee="re" position="9" name_size="11" resource_id="2" root_project_id="1" qualifier="BRC"/>
+  <resource_index kee="e" position="10" name_size="11" resource_id="2" root_project_id="1" qualifier="BRC"/>
 
 
 </dataset>
index c7484ec4a2a4e5ce714cc9b83278ab5960e9f02a..e25372f5746aef93cc5f30b4bfbcb4626fc0e06a 100644 (file)
   <resource_index kee="ntext" position="9" name_size="14" resource_id="3" root_project_id="1" qualifier="CLA"/>
   <resource_index kee="text" position="10" name_size="14" resource_id="3" root_project_id="1" qualifier="CLA"/>
   <resource_index kee="ext" position="11" name_size="14" resource_id="3" root_project_id="1" qualifier="CLA"/>
+  <resource_index kee="xt" position="12" name_size="14" resource_id="3" root_project_id="1" qualifier="CLA"/>
+  <resource_index kee="t" position="13" name_size="14" resource_id="3" root_project_id="1" qualifier="CLA"/>
 
   <!-- Struts -->
   <resource_index kee="struts" position="0" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="truts" position="1" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="ruts" position="2" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="uts" position="3" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="ts" position="4" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="s" position="5" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
 
 </dataset>
index f4cf0805ede43b991b89f0fd7b9a3f3081889aa8..22bca4ad0f468a26eee3169020b0c65412e8dbf1 100644 (file)
@@ -5,4 +5,6 @@
   <resource_index kee="utils" position="3" name_size="8" resource_id="10" root_project_id="8" qualifier="FIL"/>
   <resource_index kee="tils" position="4" name_size="8" resource_id="10" root_project_id="8" qualifier="FIL"/>
   <resource_index kee="ils" position="5" name_size="8" resource_id="10" root_project_id="8" qualifier="FIL"/>
+  <resource_index kee="ls" position="6" name_size="8" resource_id="10" root_project_id="8" qualifier="FIL"/>
+  <resource_index kee="s" position="7" name_size="8" resource_id="10" root_project_id="8" qualifier="FIL"/>
 </dataset>
\ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexTwoLettersLongResource-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexTwoLettersLongResource-result.xml
new file mode 100644 (file)
index 0000000..75e71f7
--- /dev/null
@@ -0,0 +1,4 @@
+<dataset>
+  <resource_index kee="ab" position="0" name_size="2" resource_id="10" root_project_id="3" qualifier="FIL"/>
+  <resource_index kee="b" position="1" name_size="2" resource_id="10" root_project_id="3" qualifier="FIL"/>
+</dataset>
\ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexTwoLettersLongResource.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceIndexerDaoTest/shouldIndexTwoLettersLongResource.xml
new file mode 100644 (file)
index 0000000..5a4a28b
--- /dev/null
@@ -0,0 +1 @@
+<dataset></dataset>
index 4292af5708d44c051557cc66374a35db83e96f2d..65f006f11aeee6510e2c8db4dbe0820b38f8c657 100644 (file)
@@ -3,4 +3,6 @@
   <resource_index kee="truts" position="1" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="ruts" position="2" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="uts" position="3" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="ts" position="4" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="s" position="5" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
 </dataset>
\ No newline at end of file
index 89a3a8c465d60d5bfc2bfbadcb5b8dc0411d2b2d..515ffcc9c08e989a80c2681a59a4c2409cf17cbe 100644 (file)
@@ -3,4 +3,6 @@
   <resource_index id="2" kee="truts" position="1" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index id="3" kee="ruts" position="2" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index id="4" kee="uts" position="3" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index id="5" kee="ts" position="4" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index id="6" kee="s" position="5" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
 </dataset>
\ No newline at end of file
index 4909ab381445870ccd5ce3d54955bfcd80242304..40b02449634de3068cc671554c5b75910797390f 100644 (file)
@@ -18,5 +18,7 @@
   <resource_index kee="truts" position="8" name_size="13" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="ruts" position="9" name_size="13" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="uts" position="10" name_size="13" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="ts" position="11" name_size="13" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="s" position="12" name_size="13" resource_id="1" root_project_id="1" qualifier="TRK"/>
 
 </dataset>
index e6b0836a838c8e99dab639753e9af4b9f6d5dcef..53b68f1782a8852792063d71fedff228a0c67c64 100644 (file)
@@ -7,5 +7,6 @@
   <resource_index kee="truts" position="5" name_size="10" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="ruts" position="6" name_size="10" resource_id="1" root_project_id="1" qualifier="TRK"/>
   <resource_index kee="uts" position="7" name_size="10" resource_id="1" root_project_id="1" qualifier="TRK"/>
-
+  <resource_index kee="ts" position="8" name_size="10" resource_id="1" root_project_id="1" qualifier="TRK"/>
+  <resource_index kee="s" position="9" name_size="10" resource_id="1" root_project_id="1" qualifier="TRK"/>
 </dataset>
\ No newline at end of file