mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
fix mercurial environment for push and pull commands
This commit is contained in:
@@ -41,12 +41,14 @@ import sonia.scm.SCMContext;
|
||||
import sonia.scm.io.FileSystem;
|
||||
import sonia.scm.store.MemoryStoreFactory;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -110,4 +112,23 @@ public final class HgTestUtil
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static HgHookManager createHookManager()
|
||||
{
|
||||
HgHookManager hookManager = mock(HgHookManager.class);
|
||||
|
||||
when(hookManager.getChallenge()).thenReturn("challenge");
|
||||
when(hookManager.createUrl()).thenReturn(
|
||||
"http://localhost:8081/scm/hook/hg/");
|
||||
when(hookManager.createUrl(any(HttpServletRequest.class))).thenReturn(
|
||||
"http://localhost:8081/scm/hook/hg/");
|
||||
|
||||
return hookManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,20 +38,13 @@ package sonia.scm.repository.spi;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import sonia.scm.SCMContext;
|
||||
import sonia.scm.io.FileSystem;
|
||||
import sonia.scm.repository.HgContextProvider;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.HgTestUtil;
|
||||
import sonia.scm.repository.RepositoryTestData;
|
||||
import sonia.scm.repository.TempSCMContextProvider;
|
||||
import sonia.scm.store.MemoryStoreFactory;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import sonia.scm.util.MockUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -89,10 +82,22 @@ public class AbstractHgCommandTestBase extends ZippedRepositoryTestBase
|
||||
|
||||
HgTestUtil.checkForSkip(handler);
|
||||
|
||||
cmdContext = new HgCommandContext(handler.getConfig(),
|
||||
cmdContext = new HgCommandContext(HgTestUtil.createHookManager(), handler,
|
||||
RepositoryTestData.createHeartOfGold(), repositoryDirectory);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
setSubject(MockUtil.createAdminSubject());
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.aragost.javahg.Changeset;
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.HgTestUtil;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -145,7 +146,9 @@ public class HgIncomingCommandTest extends IncomingOutgoingTestBase
|
||||
*/
|
||||
private HgIncomingCommand createIncomingCommand()
|
||||
{
|
||||
return new HgIncomingCommand(new HgCommandContext(handler.getConfig(),
|
||||
incomingRepository, incomingDirectory), incomingRepository, handler);
|
||||
return new HgIncomingCommand(
|
||||
new HgCommandContext(
|
||||
HgTestUtil.createHookManager(), handler, incomingRepository,
|
||||
incomingDirectory), incomingRepository, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.aragost.javahg.Changeset;
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.HgTestUtil;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -148,7 +149,9 @@ public class HgOutgoingCommandTest extends IncomingOutgoingTestBase
|
||||
*/
|
||||
private HgOutgoingCommand createOutgoingCommand()
|
||||
{
|
||||
return new HgOutgoingCommand(new HgCommandContext(handler.getConfig(),
|
||||
outgoingRepository, outgoingDirectory), outgoingRepository, handler);
|
||||
return new HgOutgoingCommand(
|
||||
new HgCommandContext(
|
||||
HgTestUtil.createHookManager(), handler, outgoingRepository,
|
||||
outgoingDirectory), outgoingRepository, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,43 +26,52 @@
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.aragost.javahg.BaseRepository;
|
||||
import com.aragost.javahg.Changeset;
|
||||
import com.aragost.javahg.Repository;
|
||||
import com.aragost.javahg.RepositoryConfiguration;
|
||||
import com.aragost.javahg.commands.AddCommand;
|
||||
import com.aragost.javahg.commands.CommitCommand;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import sonia.scm.AbstractTestBase;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.HgTestUtil;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.UserTestData;
|
||||
import sonia.scm.util.MockUtil;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class IncomingOutgoingTestBase
|
||||
public abstract class IncomingOutgoingTestBase extends AbstractTestBase
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
@Rule
|
||||
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
@@ -96,6 +105,20 @@ public abstract class IncomingOutgoingTestBase
|
||||
when(handler.getConfig()).thenReturn(temp.getConfig());
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
setSubject(MockUtil.createAdminSubject());
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -130,26 +153,6 @@ public abstract class IncomingOutgoingTestBase
|
||||
return c.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @return
|
||||
*/
|
||||
private RepositoryConfiguration createConfig(HgRepositoryHandler handler)
|
||||
{
|
||||
HgConfig cfg = handler.getConfig();
|
||||
RepositoryConfiguration configuration = RepositoryConfiguration.DEFAULT;
|
||||
|
||||
configuration.setHgBin(cfg.getHgBinary());
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -185,8 +188,30 @@ public abstract class IncomingOutgoingTestBase
|
||||
AddCommand.on(repository).execute(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @return
|
||||
*/
|
||||
private RepositoryConfiguration createConfig(HgRepositoryHandler handler)
|
||||
{
|
||||
HgConfig cfg = handler.getConfig();
|
||||
RepositoryConfiguration configuration = RepositoryConfiguration.DEFAULT;
|
||||
|
||||
configuration.setHgBin(cfg.getHgBinary());
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@Rule
|
||||
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||
|
||||
/** Field description */
|
||||
protected HgRepositoryHandler handler;
|
||||
|
||||
@@ -206,5 +231,5 @@ public abstract class IncomingOutgoingTestBase
|
||||
protected File outgoingDirectory;
|
||||
|
||||
/** Field description */
|
||||
protected sonia.scm.repository.Repository outgoingRepository;
|
||||
protected sonia.scm.repository.Repository outgoingRepository;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user