close repository after each unit test

This commit is contained in:
Sebastian Sdorra
2012-07-04 09:10:10 +02:00
parent d2b93ded12
commit d53449945e
4 changed files with 30 additions and 12 deletions

View File

@@ -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
* *
@@ -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;
} }

View File

@@ -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);
} }
} }

View File

@@ -106,8 +106,7 @@ public class HgCatCommandTest extends AbstractHgCommandTestBase
try try
{ {
new HgCatCommand(new HgCommandContext(handler.getConfig(), new HgCatCommand(cmdContext, repository).getCatResult(request, baos);
repositoryDirectory), repository).getCatResult(request, baos);
} }
finally finally
{ {

View File

@@ -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);
} }
} }