From 436ddc308f1fe46f8225aefd8923433254d99ea2 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 5 Jun 2013 11:52:38 +0200 Subject: [PATCH] Fix some JDBC connection pbs in unit tests --- .../java/org/sonar/core/issue/db/ActionPlanDaoTest.java | 2 +- .../org/sonar/core/issue/db/ActionPlanStatsDaoTest.java | 2 +- .../java/org/sonar/core/issue/db/IssueChangeDaoTest.java | 3 ++- .../org/sonar/core/issue/db/IssueChangeMapperTest.java | 7 +++++++ .../java/org/sonar/core/issue/db/IssueMapperTest.java | 9 +++++++-- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanDaoTest.java index 37fb16915ff..aba46152c54 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanDaoTest.java @@ -31,7 +31,7 @@ import static org.fest.assertions.Assertions.assertThat; public class ActionPlanDaoTest extends AbstractDaoTestCase { - private ActionPlanDao dao; + ActionPlanDao dao; @Before public void createDao() { diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanStatsDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanStatsDaoTest.java index 3be5466a397..cb27fa0c5e3 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanStatsDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanStatsDaoTest.java @@ -30,7 +30,7 @@ import static org.fest.assertions.Assertions.assertThat; public class ActionPlanStatsDaoTest extends AbstractDaoTestCase { - private ActionPlanStatsDao dao; + ActionPlanStatsDao dao; @Before public void createDao() { diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDaoTest.java index 9c3bf875728..239168c3cc1 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDaoTest.java @@ -26,6 +26,7 @@ import org.sonar.api.issue.internal.DefaultIssueComment; import org.sonar.api.issue.internal.FieldDiffs; import org.sonar.api.utils.DateUtils; import org.sonar.core.persistence.AbstractDaoTestCase; +import org.sonar.core.persistence.MyBatis; import java.util.Arrays; import java.util.Collections; @@ -49,7 +50,7 @@ public class IssueChangeDaoTest extends AbstractDaoTestCase { SqlSession session = getMyBatis().openSession(); List comments = dao.selectCommentsByIssues(session, Arrays.asList("1000")); - session.close(); + MyBatis.closeQuietly(session); assertThat(comments).hasSize(2); // chronological order diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeMapperTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeMapperTest.java index 363445e918f..5a38ae37236 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeMapperTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeMapperTest.java @@ -20,10 +20,12 @@ package org.sonar.core.issue.db; import org.apache.ibatis.session.SqlSession; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.sonar.api.utils.DateUtils; import org.sonar.core.persistence.AbstractDaoTestCase; +import org.sonar.core.persistence.MyBatis; import java.util.Date; @@ -37,6 +39,11 @@ public class IssueChangeMapperTest extends AbstractDaoTestCase { mapper = session.getMapper(IssueChangeMapper.class); } + @After + public void tearDown() { + MyBatis.closeQuietly(session); + } + @Test public void insert_diff() throws Exception { IssueChangeDto dto = new IssueChangeDto(); diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java index 7476d5b98fc..199c198737b 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java @@ -20,12 +20,12 @@ package org.sonar.core.issue.db; import org.apache.ibatis.session.SqlSession; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.sonar.api.utils.DateUtils; import org.sonar.core.persistence.AbstractDaoTestCase; - -import java.util.Date; +import org.sonar.core.persistence.MyBatis; import static org.fest.assertions.Assertions.assertThat; @@ -40,6 +40,11 @@ public class IssueMapperTest extends AbstractDaoTestCase { mapper = session.getMapper(IssueMapper.class); } + @After + public void tearDown() { + MyBatis.closeQuietly(session); + } + @Test public void testInsert() throws Exception { IssueDto dto = new IssueDto(); -- 2.39.5