mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +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.apache.shiro.subject.Subject;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import sonia.scm.HandlerEvent;
|
import sonia.scm.HandlerEvent;
|
||||||
@@ -66,6 +65,16 @@ public abstract class RepositoryManagerTestBase
|
|||||||
extends ManagerTestBase<Repository, RepositoryException>
|
extends ManagerTestBase<Repository, RepositoryException>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract HookContext createHookContext(Repository repository);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -346,7 +355,6 @@ public abstract class RepositoryManagerTestBase
|
|||||||
* @throws RepositoryException
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void testRepositoryHook() throws RepositoryException, IOException
|
public void testRepositoryHook() throws RepositoryException, IOException
|
||||||
{
|
{
|
||||||
CountingReceiveHook hook = new CountingReceiveHook();
|
CountingReceiveHook hook = new CountingReceiveHook();
|
||||||
@@ -357,9 +365,7 @@ public abstract class RepositoryManagerTestBase
|
|||||||
assertEquals(0, hook.eventsReceived);
|
assertEquals(0, hook.eventsReceived);
|
||||||
|
|
||||||
Repository repository = createTestRepository();
|
Repository repository = createTestRepository();
|
||||||
|
HookContext ctx = createHookContext(repository);
|
||||||
// TODO
|
|
||||||
HookContext ctx = null;
|
|
||||||
|
|
||||||
repoManager.fireHookEvent(new RepositoryHookEvent(ctx, repository,
|
repoManager.fireHookEvent(new RepositoryHookEvent(ctx, repository,
|
||||||
RepositoryHookType.POST_RECEIVE));
|
RepositoryHookType.POST_RECEIVE));
|
||||||
@@ -508,12 +514,24 @@ public abstract class RepositoryManagerTestBase
|
|||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@Subscribe
|
@Subscribe(async = false)
|
||||||
public void onEvent(PostReceiveRepositoryHookEvent event)
|
public void onEvent(PostReceiveRepositoryHookEvent event)
|
||||||
{
|
{
|
||||||
eventsReceived++;
|
eventsReceived++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@Subscribe(async = false)
|
||||||
|
public void onEvent(PreReceiveRepositoryHookEvent event)
|
||||||
|
{
|
||||||
|
eventsReceived++;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields -------------------------------------------------------------
|
//~--- fields -------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
@@ -36,9 +36,15 @@ package sonia.scm.repository;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import org.junit.Test;
|
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.Type;
|
||||||
import sonia.scm.config.ScmConfiguration;
|
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.repository.xml.XmlRepositoryDAO;
|
||||||
import sonia.scm.security.DefaultKeyGenerator;
|
import sonia.scm.security.DefaultKeyGenerator;
|
||||||
import sonia.scm.store.JAXBStoreFactory;
|
import sonia.scm.store.JAXBStoreFactory;
|
||||||
@@ -46,6 +52,8 @@ import sonia.scm.store.StoreFactory;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -57,9 +65,32 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
|
@RunWith(PowerMockRunner.class)
|
||||||
|
@PrepareForTest(HookContext.class)
|
||||||
public class DefaultRepositoryManagerTest extends RepositoryManagerTestBase
|
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
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user