From: Simon Brandhof Date: Mon, 16 Jul 2012 07:50:56 +0000 (+0200) Subject: Try to fix postgresql unit test X-Git-Tag: 3.2~73 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9bf3be187a4893ad424eb09e3cd3c8e7c54f06d6;p=sonarqube.git Try to fix postgresql unit test --- diff --git a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java index 7dfab47df1e..a496d826fc6 100644 --- a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java +++ b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java @@ -122,7 +122,6 @@ public class PropertiesDao implements BatchComponent, ServerComponent { for (Map.Entry entry : properties.entrySet()) { mapper.deleteGlobalProperty(entry.getKey()); } - session.commit();//required for postgresql bulk inserts (?) for (Map.Entry entry : properties.entrySet()) { mapper.insert(new PropertyDto().setKey(entry.getKey()).setValue(entry.getValue())); } diff --git a/sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java b/sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java index 6fef82d9fd7..6e7ad7fffa7 100644 --- a/sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/properties/PropertiesDaoTest.java @@ -19,13 +19,12 @@ */ package org.sonar.core.properties; -import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap; import org.junit.Before; import org.junit.Test; import org.sonar.core.persistence.AbstractDaoTestCase; import java.util.List; -import java.util.TreeMap; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.is; @@ -116,15 +115,21 @@ public class PropertiesDaoTest extends AbstractDaoTestCase { } @Test - public void saveGlobalProperties() { - setupData("saveGlobalProperties"); + public void insertGlobalProperties() { + setupData("insertGlobalProperties"); - TreeMap props = Maps.newTreeMap(); - props.put("to_be_inserted", "inserted"); - props.put("to_be_updated", "updated"); - dao.saveGlobalProperties(props); + dao.saveGlobalProperties(ImmutableMap.of("to_be_inserted", "inserted")); - checkTable("saveGlobalProperties", "properties", "prop_key", "text_value", "resource_id", "user_id"); + checkTable("insertGlobalProperties", "properties", "prop_key", "text_value", "resource_id", "user_id"); + } + + @Test + public void updateGlobalProperties() { + setupData("updateGlobalProperties"); + + dao.saveGlobalProperties(ImmutableMap.of("to_be_updated", "updated")); + + checkTable("updateGlobalProperties", "properties", "prop_key", "text_value", "resource_id", "user_id"); } private PropertyDto findById(List properties, int id) { diff --git a/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/insertGlobalProperties-result.xml b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/insertGlobalProperties-result.xml new file mode 100644 index 00000000000..5594180c370 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/insertGlobalProperties-result.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/insertGlobalProperties.xml b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/insertGlobalProperties.xml new file mode 100644 index 00000000000..871dedcb5e9 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/insertGlobalProperties.xml @@ -0,0 +1,3 @@ + + + diff --git a/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/saveGlobalProperties-result.xml b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/saveGlobalProperties-result.xml deleted file mode 100644 index f12984a944b..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/saveGlobalProperties-result.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/saveGlobalProperties.xml b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/saveGlobalProperties.xml deleted file mode 100644 index b0fa0be6deb..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/saveGlobalProperties.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/updateGlobalProperties-result.xml b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/updateGlobalProperties-result.xml new file mode 100644 index 00000000000..c873ec3bd76 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/updateGlobalProperties-result.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/updateGlobalProperties.xml b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/updateGlobalProperties.xml new file mode 100644 index 00000000000..43cdd8c7d10 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/properties/PropertiesDaoTest/updateGlobalProperties.xml @@ -0,0 +1,10 @@ + + + + + + + + + +