mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
improve scm-test
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user