From 28c9f88fc9ceb6c29d91c8422bbdd4aa71a425ef Mon Sep 17 00:00:00 2001 From: David Gageot Date: Tue, 10 Jul 2012 17:47:04 +0200 Subject: Fix ResourceDao test on Oracle --- .../org/sonar/core/resource/ResourceDaoTest.java | 28 +++++++++++++--------- .../resource/ResourceDaoTest/insert-result.xml | 11 +++++++++ .../sonar/core/resource/ResourceDaoTest/insert.xml | 3 +++ .../ResourceDaoTest/insertOrUpdate-result.xml | 15 ------------ .../resource/ResourceDaoTest/insertOrUpdate.xml | 7 ------ .../resource/ResourceDaoTest/update-result.xml | 7 ++++++ .../sonar/core/resource/ResourceDaoTest/update.xml | 7 ++++++ 7 files changed, 45 insertions(+), 33 deletions(-) create mode 100644 sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml create mode 100644 sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate-result.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate.xml create mode 100644 sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml create mode 100644 sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml (limited to 'sonar-core') diff --git a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java index 503056ee794..9899b31cd2f 100644 --- a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java @@ -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 index 00000000000..f2075f14ddc --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml @@ -0,0 +1,11 @@ + + + + + + + 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 index 00000000000..871dedcb5e9 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert.xml @@ -0,0 +1,3 @@ + + + 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 index a1cae231f15..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate-result.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - 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 index 1a5e2978a07..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insertOrUpdate.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - 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 index 00000000000..a95233b81f6 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml @@ -0,0 +1,7 @@ + + + + + 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 index 00000000000..10fdddc66ff --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml @@ -0,0 +1,7 @@ + + + + + -- cgit v1.2.3