summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-11-28 16:35:16 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-11-28 16:52:24 +0100
commit5b4d889451703c4e5efdf53edeb5999e8602553b (patch)
treeb1c2934dbb98b55848671c510fc7ad6eb56526c4 /server
parent0b1d1fa7098cbc1705d0e1797461a13b14a1b234 (diff)
downloadsonarqube-5b4d889451703c4e5efdf53edeb5999e8602553b.tar.gz
sonarqube-5b4d889451703c4e5efdf53edeb5999e8602553b.zip
Fix closing of connection in SourceLineResultSetIteratorTest
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineResultSetIteratorTest.java9
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceLineResultSetIteratorTest/empty-file.xml2
2 files changed, 6 insertions, 5 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineResultSetIteratorTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineResultSetIteratorTest.java
index 64071f8dc7c..9460d5cf348 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineResultSetIteratorTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineResultSetIteratorTest.java
@@ -35,7 +35,7 @@ import static org.fest.assertions.Fail.fail;
public class SourceLineResultSetIteratorTest {
@ClassRule
- public static TestDatabase db = new TestDatabase();
+ public static TestDatabase db = new TestDatabase().schema(SourceLineResultSetIteratorTest.class, "schema.sql");
DbClient dbClient;
@@ -44,7 +44,6 @@ public class SourceLineResultSetIteratorTest {
@Before
public void setUp() throws Exception {
dbClient = new DbClient(db.database(), db.myBatis());
- db.schema(this.getClass(), "schema.sql");
connection = db.openConnection();
}
@@ -86,6 +85,7 @@ public class SourceLineResultSetIteratorTest {
assertThat(firstLine.overallLineHits()).isEqualTo(3);
assertThat(firstLine.overallConditions()).isEqualTo(0);
assertThat(firstLine.overallCoveredConditions()).isEqualTo(0);
+ iterator.close();
}
@Test
@@ -94,6 +94,7 @@ public class SourceLineResultSetIteratorTest {
SourceLineResultSetIterator iterator = SourceLineResultSetIterator.create(dbClient, connection, 2000000000000L);
assertThat(iterator.hasNext()).isFalse();
+ iterator.close();
}
@Test
@@ -105,6 +106,7 @@ public class SourceLineResultSetIteratorTest {
SourceLineResultSetIterator.SourceFile file = iterator.next();
assertThat(file.getFileUuid()).isEqualTo("uuid-MyFile.xoo");
assertThat(file.getLines()).isEmpty();
+ iterator.close();
}
@Test
@@ -122,8 +124,7 @@ public class SourceLineResultSetIteratorTest {
fail();
} catch (IllegalStateException e) {
// ok
- } finally {
- iterator.close();
}
+ iterator.close();
}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceLineResultSetIteratorTest/empty-file.xml b/server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceLineResultSetIteratorTest/empty-file.xml
index 83fcc118164..cf6e01583dd 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceLineResultSetIteratorTest/empty-file.xml
+++ b/server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceLineResultSetIteratorTest/empty-file.xml
@@ -1,6 +1,6 @@
<dataset>
<file_sources id="1" project_uuid="uuid-MyProject" file_uuid="uuid-MyFile.xoo" created_at="1416238020000" updated_at="1416239042000"
- data="" data_hash="" line_hashes=""/>
+ data="" data_hash="" />
</dataset>