mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
fix repository manager tests
This commit is contained in:
@@ -40,7 +40,6 @@ import com.github.legman.Subscribe;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.HandlerEvent;
|
||||
@@ -66,6 +65,16 @@ public abstract class RepositoryManagerTestBase
|
||||
extends ManagerTestBase<Repository, RepositoryException>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract HookContext createHookContext(Repository repository);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -346,7 +355,6 @@ public abstract class RepositoryManagerTestBase
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void testRepositoryHook() throws RepositoryException, IOException
|
||||
{
|
||||
CountingReceiveHook hook = new CountingReceiveHook();
|
||||
@@ -357,9 +365,7 @@ public abstract class RepositoryManagerTestBase
|
||||
assertEquals(0, hook.eventsReceived);
|
||||
|
||||
Repository repository = createTestRepository();
|
||||
|
||||
// TODO
|
||||
HookContext ctx = null;
|
||||
HookContext ctx = createHookContext(repository);
|
||||
|
||||
repoManager.fireHookEvent(new RepositoryHookEvent(ctx, repository,
|
||||
RepositoryHookType.POST_RECEIVE));
|
||||
@@ -508,12 +514,24 @@ public abstract class RepositoryManagerTestBase
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe
|
||||
@Subscribe(async = false)
|
||||
public void onEvent(PostReceiveRepositoryHookEvent event)
|
||||
{
|
||||
eventsReceived++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe(async = false)
|
||||
public void onEvent(PreReceiveRepositoryHookEvent event)
|
||||
{
|
||||
eventsReceived++;
|
||||
}
|
||||
|
||||
//~--- fields -------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
@@ -36,9 +36,15 @@ package sonia.scm.repository;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import sonia.scm.Type;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
import sonia.scm.repository.api.HookContext;
|
||||
import sonia.scm.repository.api.HookFeature;
|
||||
import sonia.scm.repository.xml.XmlRepositoryDAO;
|
||||
import sonia.scm.security.DefaultKeyGenerator;
|
||||
import sonia.scm.store.JAXBStoreFactory;
|
||||
@@ -46,6 +52,8 @@ import sonia.scm.store.StoreFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -57,9 +65,32 @@ import java.util.Set;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(HookContext.class)
|
||||
public class DefaultRepositoryManagerTest extends RepositoryManagerTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public HookContext createHookContext(Repository repository)
|
||||
{
|
||||
HookContext ctx = mock(HookContext.class);
|
||||
|
||||
when(ctx.isFeatureSupported(any(HookFeature.class))).thenReturn(
|
||||
Boolean.FALSE);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user