Skip to content

Commit a3d4ed5

Browse files
Vladimir Kotalahornace
authored andcommitted
simplify the tests by using BeforeEach
1 parent ae2eaa0 commit a3d4ed5

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/history/MercurialRepositoryTest.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
package org.opengrok.indexer.history;
2525

2626
import org.junit.jupiter.api.AfterEach;
27+
import org.junit.jupiter.api.BeforeEach;
2728
import org.junit.jupiter.api.Test;
2829
import org.opengrok.indexer.condition.EnabledForRepository;
2930
import org.opengrok.indexer.util.Executor;
@@ -85,6 +86,11 @@ private void setUpTestRepository() throws IOException {
8586
repository.create(getClass().getResourceAsStream("repositories.zip"));
8687
}
8788

89+
@BeforeEach
90+
public void setup() throws IOException {
91+
setUpTestRepository();
92+
}
93+
8894
@AfterEach
8995
public void tearDown() {
9096
if (repository != null) {
@@ -95,7 +101,6 @@ public void tearDown() {
95101

96102
@Test
97103
public void testGetHistory() throws Exception {
98-
setUpTestRepository();
99104
File root = new File(repository.getSourceRoot(), "mercurial");
100105
MercurialRepository mr
101106
= (MercurialRepository) RepositoryFactory.getRepository(root);
@@ -114,7 +119,6 @@ public void testGetHistory() throws Exception {
114119

115120
@Test
116121
public void testGetHistorySubdir() throws Exception {
117-
setUpTestRepository();
118122
File root = new File(repository.getSourceRoot(), "mercurial");
119123

120124
// Add a subdirectory with some history.
@@ -135,10 +139,8 @@ public void testGetHistorySubdir() throws Exception {
135139
*/
136140
@Test
137141
public void testGetHistoryPartial() throws Exception {
138-
setUpTestRepository();
139142
File root = new File(repository.getSourceRoot(), "mercurial");
140-
MercurialRepository mr
141-
= (MercurialRepository) RepositoryFactory.getRepository(root);
143+
MercurialRepository mr = (MercurialRepository) RepositoryFactory.getRepository(root);
142144
// Get all but the oldest revision.
143145
History hist = mr.getHistory(root, REVISIONS[REVISIONS.length - 1]);
144146
List<HistoryEntry> entries = hist.getHistoryEntries();
@@ -180,7 +182,6 @@ public static void runHgCommand(File reposRoot, String... args) {
180182
*/
181183
@Test
182184
public void testGetHistoryBranch() throws Exception {
183-
setUpTestRepository();
184185
File root = new File(repository.getSourceRoot(), "mercurial");
185186

186187
// Branch the repo and add one changeset.
@@ -228,7 +229,6 @@ public void testGetHistoryBranch() throws Exception {
228229
*/
229230
@Test
230231
public void testGetHistoryGet() throws Exception {
231-
setUpTestRepository();
232232
File root = new File(repository.getSourceRoot(), "mercurial");
233233
MercurialRepository mr
234234
= (MercurialRepository) RepositoryFactory.getRepository(root);
@@ -260,7 +260,6 @@ public void testGetHistoryGet() throws Exception {
260260
*/
261261
@Test
262262
public void testgetHistoryGetForAll() throws Exception {
263-
setUpTestRepository();
264263
File root = new File(repository.getSourceRoot(), "mercurial");
265264
MercurialRepository mr
266265
= (MercurialRepository) RepositoryFactory.getRepository(root);
@@ -279,7 +278,6 @@ public void testgetHistoryGetForAll() throws Exception {
279278
*/
280279
@Test
281280
public void testGetHistoryGetRenamed() throws Exception {
282-
setUpTestRepository();
283281
File root = new File(repository.getSourceRoot(), "mercurial");
284282
MercurialRepository mr
285283
= (MercurialRepository) RepositoryFactory.getRepository(root);
@@ -306,7 +304,6 @@ public void testGetHistoryGetRenamed() throws Exception {
306304
*/
307305
@Test
308306
public void testGetHistoryWithNoSuchRevision() throws Exception {
309-
setUpTestRepository();
310307
File root = new File(repository.getSourceRoot(), "mercurial");
311308
MercurialRepository mr = (MercurialRepository) RepositoryFactory.getRepository(root);
312309

0 commit comments

Comments
 (0)