improve scm-test

This commit is contained in:
Sebastian Sdorra
2010-12-06 20:05:04 +01:00
parent ef31ec2bab
commit 44c57b8ea6
12 changed files with 659 additions and 129 deletions

View File

@@ -63,7 +63,7 @@ import java.util.UUID;
* @param <E>
*/
public abstract class ManagerTestBase<T extends TypedObject,
E extends Exception>
E extends Exception> extends AbstractTestBase
{
/**
@@ -78,72 +78,29 @@ public abstract class ManagerTestBase<T extends TypedObject,
* Method description
*
*
* @throws IOException
* @throws Exception
*/
@After
public void tearDownTest() throws IOException
@Override
protected void postSetUp() throws Exception
{
try
{
manager.close();
}
finally
{
IOUtil.delete(tempDirectory);
}
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*/
@Before
public void setUpTest()
{
tempDirectory = new File(System.getProperty("java.io.tmpdir"),
UUID.randomUUID().toString());
assertTrue(tempDirectory.mkdirs());
provider = mock(SCMContextProvider.class);
when(provider.getBaseDirectory()).thenReturn(tempDirectory);
manager = createManager();
manager.init(provider);
manager.init(contextProvider);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
* @throws Exception
*/
protected Provider<SecurityContext> getAdminSecurityContextProvider()
@Override
protected void preTearDown() throws Exception
{
User admin = new User("scmadmin", "SCM Admin", "scmadmin@scm.org");
admin.setAdmin(true);
SecurityContext context = mock(SecurityContext.class);
when(context.getUser()).thenReturn(admin);
Provider<SecurityContext> scp = mock(Provider.class);
when(scp.get()).thenReturn(context);
return scp;
manager.close();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
protected Manager<T, E> manager;
/** Field description */
protected SCMContextProvider provider;
/** Field description */
protected File tempDirectory;
}