From aaf0b053d38127d232066dc78f653ae37b45a501 Mon Sep 17 00:00:00 2001 From: jensp Date: Sat, 19 Dec 2015 09:18:05 +0000 Subject: [PATCH] CCM NG: One test in CategoryManagerTest failed when executed after other tests because the hibernate_sequence sequence in the database was not reset between tests. git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3778 8810af33-2d31-482b-a856-94f89814c4df --- .../categorization/CategoryManagerTest.java | 80 +++++++++---------- .../src/test/resources/scripts/h2-cleanup.sql | 4 +- .../test/resources/scripts/pgsql-cleanup.sql | 4 +- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/ccm-core/src/test/java/org/libreccm/categorization/CategoryManagerTest.java b/ccm-core/src/test/java/org/libreccm/categorization/CategoryManagerTest.java index 54110e64c..84d16cb60 100644 --- a/ccm-core/src/test/java/org/libreccm/categorization/CategoryManagerTest.java +++ b/ccm-core/src/test/java/org/libreccm/categorization/CategoryManagerTest.java @@ -237,46 +237,44 @@ public class CategoryManagerTest { categoryManager.removeSubCategoryFromCategory(bar, foo); } - // Fails for unknown reasons when executed after the other tests in this - // Test suite, but works when executed stand alone. To be investigated. -// @Test -// @UsingDataSet( -// "datasets/org/libreccm/categorization/CategoryManagerTest/data.yml") -// @ShouldMatchDataSet( -// value = "datasets/org/libreccm/categorization/CategoryManagerTest/" -// + "after-create-multiple-categories.yml") -// @InSequence(3100) -// public void createMultipleCategories() { -// final Domain domain = domainRepo.findByDomainKey("test"); -// final Category root = domain.getRoot(); -// -// final Category com = new Category(); -// com.setName("com"); -// com.setDisplayName("com"); -// com.setUniqueId("com"); -// categoryRepo.save(com); -// categoryManager.addSubCategoryToCategory(com, root); -// -// final Category example = new Category(); -// example.setName("example"); -// example.setDisplayName("example"); -// example.setUniqueId("example"); -// categoryRepo.save(example); -// categoryManager.addSubCategoryToCategory(example, com); -// -// final Category categories = new Category(); -// categories.setName("categories"); -// categories.setDisplayName("categories"); -// categories.setUniqueId("categories"); -// categoryRepo.save(categories); -// categoryManager.addSubCategoryToCategory(categories, example); -// -// final Category test = new Category(); -// test.setName("test"); -// test.setDisplayName("test"); -// test.setUniqueId("test"); -// categoryRepo.save(test); -// categoryManager.addSubCategoryToCategory(test, categories); -// } + @Test + @UsingDataSet( + "datasets/org/libreccm/categorization/CategoryManagerTest/data.yml") + @ShouldMatchDataSet( + value = "datasets/org/libreccm/categorization/CategoryManagerTest/" + + "after-create-multiple-categories.yml") + @InSequence(3100) + public void createMultipleCategories() { + final Domain domain = domainRepo.findByDomainKey("test"); + final Category root = domain.getRoot(); + + final Category com = new Category(); + com.setName("com"); + com.setDisplayName("com"); + com.setUniqueId("com"); + categoryRepo.save(com); + categoryManager.addSubCategoryToCategory(com, root); + + final Category example = new Category(); + example.setName("example"); + example.setDisplayName("example"); + example.setUniqueId("example"); + categoryRepo.save(example); + categoryManager.addSubCategoryToCategory(example, com); + + final Category categories = new Category(); + categories.setName("categories"); + categories.setDisplayName("categories"); + categories.setUniqueId("categories"); + categoryRepo.save(categories); + categoryManager.addSubCategoryToCategory(categories, example); + + final Category test = new Category(); + test.setName("test"); + test.setDisplayName("test"); + test.setUniqueId("test"); + categoryRepo.save(test); + categoryManager.addSubCategoryToCategory(test, categories); + } } diff --git a/ccm-core/src/test/resources/scripts/h2-cleanup.sql b/ccm-core/src/test/resources/scripts/h2-cleanup.sql index ae96b9b81..4a9045c62 100644 --- a/ccm-core/src/test/resources/scripts/h2-cleanup.sql +++ b/ccm-core/src/test/resources/scripts/h2-cleanup.sql @@ -40,4 +40,6 @@ DELETE FROM ccm_core.user_email_addresses; DELETE FROM ccm_core.parties; -DELETE FROM ccm_core.ccm_roles; \ No newline at end of file +DELETE FROM ccm_core.ccm_roles; + +ALTER SEQUENCE hibernate_sequence RESTART WITH 1; \ No newline at end of file diff --git a/ccm-core/src/test/resources/scripts/pgsql-cleanup.sql b/ccm-core/src/test/resources/scripts/pgsql-cleanup.sql index ae96b9b81..31b2125db 100644 --- a/ccm-core/src/test/resources/scripts/pgsql-cleanup.sql +++ b/ccm-core/src/test/resources/scripts/pgsql-cleanup.sql @@ -40,4 +40,6 @@ DELETE FROM ccm_core.user_email_addresses; DELETE FROM ccm_core.parties; -DELETE FROM ccm_core.ccm_roles; \ No newline at end of file +DELETE FROM ccm_core.ccm_roles; + +ALTER SEQUENCE hibernate_sequence RESTART; \ No newline at end of file