mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
close repository after each unit test
This commit is contained in:
@@ -30,10 +30,12 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
|
||||
@@ -58,6 +60,21 @@ import java.io.IOException;
|
||||
public class AbstractHgCommandTestBase extends ZippedRepositoryTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@After
|
||||
public void close() throws IOException
|
||||
{
|
||||
if (cmdContext != null)
|
||||
{
|
||||
cmdContext.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -76,7 +93,7 @@ public class AbstractHgCommandTestBase extends ZippedRepositoryTestBase
|
||||
FileSystem fileSystem = mock(FileSystem.class);
|
||||
|
||||
this.handler = new HgRepositoryHandler(new MemoryStoreFactory(),
|
||||
fileSystem, new HgContextProvider());
|
||||
fileSystem, new HgContextProvider());
|
||||
this.handler.init(context);
|
||||
|
||||
// skip tests if hg not in path
|
||||
@@ -85,6 +102,8 @@ public class AbstractHgCommandTestBase extends ZippedRepositoryTestBase
|
||||
System.out.println("WARNING could not find hg, skipping test");
|
||||
Assume.assumeTrue(false);
|
||||
}
|
||||
|
||||
cmdContext = new HgCommandContext(handler.getConfig(), repositoryDirectory);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -115,6 +134,9 @@ public class AbstractHgCommandTestBase extends ZippedRepositoryTestBase
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
protected HgCommandContext cmdContext;
|
||||
|
||||
/** Field description */
|
||||
protected HgRepositoryHandler handler;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.BlameLine;
|
||||
import sonia.scm.repository.BlameResult;
|
||||
import sonia.scm.repository.HgContext;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -139,7 +138,6 @@ public class HgBlameCommandTest extends AbstractHgCommandTestBase
|
||||
*/
|
||||
private BlameCommand createCommand()
|
||||
{
|
||||
return new HgBlameCommand(new HgCommandContext(handler.getConfig(),
|
||||
repositoryDirectory), repository);
|
||||
return new HgBlameCommand(cmdContext, repository);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,15 +99,14 @@ public class HgCatCommandTest extends AbstractHgCommandTestBase
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private String execute(CatCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
String content = null;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
try
|
||||
{
|
||||
new HgCatCommand(new HgCommandContext(handler.getConfig(),
|
||||
repositoryDirectory), repository).getCatResult(request, baos);
|
||||
new HgCatCommand(cmdContext, repository).getCatResult(request, baos);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -95,11 +95,11 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
assertEquals(3, result.getTotal());
|
||||
assertEquals(3, result.getChangesets().size());
|
||||
assertEquals("2baab8e80280ef05a9aa76c49c76feca2872afb7",
|
||||
result.getChangesets().get(0).getId());
|
||||
result.getChangesets().get(0).getId());
|
||||
assertEquals("79b6baf49711ae675568e0698d730b97ef13e84a",
|
||||
result.getChangesets().get(1).getId());
|
||||
result.getChangesets().get(1).getId());
|
||||
assertEquals("a9bacaf1b7fa0cebfca71fed4e59ed69a6319427",
|
||||
result.getChangesets().get(2).getId());
|
||||
result.getChangesets().get(2).getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,7 +235,6 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
*/
|
||||
private HgLogCommand createComamnd()
|
||||
{
|
||||
return new HgLogCommand(new HgCommandContext(handler.getConfig(),
|
||||
repositoryDirectory), repository);
|
||||
return new HgLogCommand(cmdContext, repository);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user