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