added unit tests for repository archive

This commit is contained in:
Sebastian Sdorra
2013-01-29 21:02:37 +01:00
parent 65c80b14fb
commit 60da1465d5
2 changed files with 79 additions and 4 deletions

View File

@@ -37,6 +37,7 @@ package sonia.scm.repository;
import org.junit.Test;
import sonia.scm.Manager;
import sonia.scm.ManagerTestBase;
import static org.junit.Assert.*;
@@ -55,6 +56,17 @@ public abstract class RepositoryManagerTestBase
extends ManagerTestBase<Repository, RepositoryException>
{
/**
* Method description
*
*
* @param archiveEnabled
*
* @return
*/
protected abstract RepositoryManager createRepositoryManager(
boolean archiveEnabled);
/**
* Method description
*
@@ -96,11 +108,20 @@ public abstract class RepositoryManagerTestBase
@Test
public void testDelete() throws RepositoryException, IOException
{
Repository heartOfGold = createTestRepository();
String id = heartOfGold.getId();
delete(manager, createTestRepository());
}
manager.delete(heartOfGold);
assertNull(manager.get(id));
/**
* Method description
*
*
* @throws IOException
* @throws RepositoryException
*/
@Test(expected = RepositoryIsNotArchivedException.class)
public void testDeleteNonArchived() throws RepositoryException, IOException
{
delete(createRepositoryManager(true), createTestRepository());
}
/**
@@ -116,6 +137,23 @@ public abstract class RepositoryManagerTestBase
manager.delete(createRepositoryWithId());
}
/**
* Method description
*
*
* @throws IOException
* @throws RepositoryException
*/
@Test
public void testDeleteWithEnabledArchive()
throws RepositoryException, IOException
{
Repository repository = createTestRepository();
repository.setArchived(true);
delete(createRepositoryManager(true), repository);
}
/**
* Method description
*
@@ -336,4 +374,24 @@ public abstract class RepositoryManagerTestBase
{
return createRepository(RepositoryTestData.createHeartOfGold());
}
/**
* Method description
*
*
* @param manager
* @param repository
*
* @throws IOException
* @throws RepositoryException
*/
private void delete(Manager<Repository, RepositoryException> manager,
Repository repository)
throws RepositoryException, IOException
{
String id = repository.getId();
manager.delete(repository);
assertNull(manager.get(id));
}
}