]> source.dussan.org Git - sonarqube.git/commitdiff
Fix ResourceDao test on Oracle
authorDavid Gageot <david@gageot.net>
Tue, 10 Jul 2012 15:47:04 +0000 (17:47 +0200)
committerDavid Gageot <david@gageot.net>
Tue, 10 Jul 2012 16:20:20 +0000 (18:20 +0200)
sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate-result.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml [new file with mode: 0644]

index 503056ee7946877237dd805a2fff18e4b6f03551..9899b31cd2f30d3335ad31c142e0768e8ba539ce 100644 (file)
@@ -141,16 +141,24 @@ public class ResourceDaoTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void insertOrUpdate() {
-    setupData("insertOrUpdate");
+  public void should_update() {
+    setupData("update");
 
-    // to be updated
     ResourceDto project = new ResourceDto()
-      .setKey("org.struts:struts").setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT)
-      .setName("Struts").setLongName("Apache Struts").setLanguage("java").setDescription("MVC Framework")
-      .setId(100L);
+        .setKey("org.struts:struts").setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT)
+        .setName("Struts").setLongName("Apache Struts").setLanguage("java").setDescription("MVC Framework")
+        .setId(1L);
+
+    dao.insertOrUpdate(project);
+
+    assertThat(project.getId()).isNotNull();
+    checkTables("update", "projects");
+  }
+
+  @Test
+  public void should_insert() {
+    setupData("insert");
 
-    // to be inserted
     ResourceDto file1 = new ResourceDto()
       .setKey("org.struts:struts:org.struts.Action").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE)
       .setLanguage("java").setName("Action").setLongName("org.struts.Action");
@@ -158,13 +166,11 @@ public class ResourceDaoTest extends AbstractDaoTestCase {
           .setKey("org.struts:struts:org.struts.Filter").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE)
           .setLanguage("java").setName("Filter").setLongName("org.struts.Filter");
 
-    dao.insertOrUpdate(project, file1, file2);
+    dao.insertOrUpdate(file1, file2);
 
-    assertThat(project.getId()).isNotNull();
     assertThat(file1.getId()).isNotNull();
     assertThat(file2.getId()).isNotNull();
-    checkTables("insertOrUpdate", new String[]{"id"}, "projects");
+    checkTables("insert", "projects");
   }
-
 }
 
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml
new file mode 100644 (file)
index 0000000..f2075f1
--- /dev/null
@@ -0,0 +1,11 @@
+<dataset>
+
+  <projects id="1" root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Action" name="Action"
+            description="[null]" long_name="org.struts.Action"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+
+  <projects id="2" root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Filter" name="Filter"
+            description="[null]" long_name="org.struts.Filter"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert.xml
new file mode 100644 (file)
index 0000000..871dedc
--- /dev/null
@@ -0,0 +1,3 @@
+<dataset>
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate-result.xml
deleted file mode 100644 (file)
index a1cae23..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<dataset>
-
-  <projects root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
-            description="MVC Framework" long_name="Apache Struts"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
-
-  <projects root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Action" name="Action"
-            description="[null]" long_name="org.struts.Action"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
-
-  <projects root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Filter" name="Filter"
-            description="[null]" long_name="org.struts.Filter"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
-
-</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate.xml
deleted file mode 100644 (file)
index 1a5e297..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<dataset>
-
-  <projects id="100" root_id="200" scope="PRJ" qualifier="TRK" kee="old key" name="old name"
-            description="old name" long_name="old long name"
-            enabled="[false]" language="old" copy_resource_id="2" person_id="3" profile_id="4"/>
-
-</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml
new file mode 100644 (file)
index 0000000..a95233b
--- /dev/null
@@ -0,0 +1,7 @@
+<dataset>
+
+  <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
+            description="MVC Framework" long_name="Apache Struts"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml
new file mode 100644 (file)
index 0000000..10fdddc
--- /dev/null
@@ -0,0 +1,7 @@
+<dataset>
+
+  <projects id="1" root_id="200" scope="PRJ" qualifier="TRK" kee="old key" name="old name"
+            description="old name" long_name="old long name"
+            enabled="[false]" language="old" copy_resource_id="2" person_id="3" profile_id="4"/>
+
+</dataset>