mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
improve performance of subversion repository api
This commit is contained in:
@@ -31,6 +31,14 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.After;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -38,6 +46,39 @@ package sonia.scm.repository.spi;
|
||||
public class AbstractSvnCommandTestBase extends ZippedRepositoryTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@After
|
||||
public void close() throws IOException
|
||||
{
|
||||
if (context != null)
|
||||
{
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SvnContext createContext()
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
context = new SvnContext(repositoryDirectory);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -61,4 +102,9 @@ public class AbstractSvnCommandTestBase extends ZippedRepositoryTestBase
|
||||
{
|
||||
return "sonia/scm/repository/spi/scm-svn-spi-test.zip";
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private SvnContext context;
|
||||
}
|
||||
|
||||
@@ -66,8 +66,7 @@ public class SvnBlameCommandTest extends AbstractSvnCommandTestBase
|
||||
|
||||
request.setPath("a.txt");
|
||||
|
||||
BlameResult result = new SvnBlameCommand(repository,
|
||||
repositoryDirectory).getBlameResult(request);
|
||||
BlameResult result = createCommand().getBlameResult(request);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(2, result.getTotal());
|
||||
@@ -101,8 +100,7 @@ public class SvnBlameCommandTest extends AbstractSvnCommandTestBase
|
||||
request.setPath("a.txt");
|
||||
request.setRevision("3");
|
||||
|
||||
BlameResult result = new SvnBlameCommand(repository,
|
||||
repositoryDirectory).getBlameResult(request);
|
||||
BlameResult result = createCommand().getBlameResult(request);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.getTotal());
|
||||
@@ -128,4 +126,15 @@ public class SvnBlameCommandTest extends AbstractSvnCommandTestBase
|
||||
assertEquals("perfect", line.getAuthor().getName());
|
||||
assertNull(line.getAuthor().getMail());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private SvnBlameCommand createCommand()
|
||||
{
|
||||
return new SvnBlameCommand(createContext(), repository);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,23 +26,34 @@
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -53,10 +64,8 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
|
||||
@Test
|
||||
public void testBrowse() throws IOException, RepositoryException
|
||||
{
|
||||
BrowserResult result = new SvnBrowseCommand(
|
||||
repository,
|
||||
repositoryDirectory).getBrowserResult(
|
||||
new BrowseCommandRequest());
|
||||
BrowserResult result =
|
||||
createCommand().getBrowserResult(new BrowseCommandRequest());
|
||||
|
||||
assertNotNull(result);
|
||||
|
||||
@@ -108,8 +117,7 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
|
||||
|
||||
request.setPath("c");
|
||||
|
||||
BrowserResult result = new SvnBrowseCommand(repository,
|
||||
repositoryDirectory).getBrowserResult(request);
|
||||
BrowserResult result = createCommand().getBrowserResult(request);
|
||||
|
||||
assertNotNull(result);
|
||||
|
||||
@@ -149,4 +157,15 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
|
||||
assertTrue(e.getLength() > 0);
|
||||
checkDate(e.getLastModified());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private SvnBrowseCommand createCommand()
|
||||
{
|
||||
return new SvnBrowseCommand(createContext(), repository);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,23 +26,32 @@
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class SvnCatCommandTest extends AbstractSvnCommandTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
@@ -94,7 +103,7 @@ public class SvnCatCommandTest extends AbstractSvnCommandTestBase
|
||||
|
||||
try
|
||||
{
|
||||
new SvnCatCommand(repository, repositoryDirectory).getCatResult(request,
|
||||
new SvnCatCommand(createContext(), repository).getCatResult(request,
|
||||
baos);
|
||||
}
|
||||
finally
|
||||
@@ -104,5 +113,4 @@ public class SvnCatCommandTest extends AbstractSvnCommandTestBase
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,9 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.Modifications;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -43,8 +45,6 @@ import static org.junit.Assert.*;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.Modifications;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -55,29 +55,28 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAll() throws IOException, RepositoryException
|
||||
{
|
||||
ChangesetPagingResult result = new SvnLogCommand(
|
||||
repository,
|
||||
repositoryDirectory).getChangesets(
|
||||
new LogCommandRequest());
|
||||
ChangesetPagingResult result =
|
||||
createCommand().getChangesets(new LogCommandRequest());
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(6, result.getTotal());
|
||||
assertEquals(6, result.getChangesets().size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllByPath() throws IOException, RepositoryException
|
||||
@@ -86,8 +85,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
|
||||
request.setPath("a.txt");
|
||||
|
||||
ChangesetPagingResult result =
|
||||
new SvnLogCommand(repository, repositoryDirectory).getChangesets(request);
|
||||
ChangesetPagingResult result = createCommand().getChangesets(request);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(3, result.getTotal());
|
||||
@@ -96,12 +94,13 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
assertEquals("3", result.getChangesets().get(1).getId());
|
||||
assertEquals("1", result.getChangesets().get(2).getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllWithLimit() throws IOException, RepositoryException
|
||||
@@ -110,8 +109,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
|
||||
request.setPagingLimit(2);
|
||||
|
||||
ChangesetPagingResult result =
|
||||
new SvnLogCommand(repository, repositoryDirectory).getChangesets(request);
|
||||
ChangesetPagingResult result = createCommand().getChangesets(request);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(6, result.getTotal());
|
||||
@@ -127,12 +125,13 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
assertNotNull(c2);
|
||||
assertEquals("4", c2.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllWithPaging() throws IOException, RepositoryException
|
||||
@@ -142,8 +141,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
request.setPagingStart(1);
|
||||
request.setPagingLimit(2);
|
||||
|
||||
ChangesetPagingResult result =
|
||||
new SvnLogCommand(repository, repositoryDirectory).getChangesets(request);
|
||||
ChangesetPagingResult result = createCommand().getChangesets(request);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(6, result.getTotal());
|
||||
@@ -159,16 +157,18 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
assertNotNull(c2);
|
||||
assertEquals("3", c2.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetCommit() throws IOException, RepositoryException
|
||||
{
|
||||
SvnLogCommand command = new SvnLogCommand(repository, repositoryDirectory);
|
||||
Changeset c = command.getChangeset("3");
|
||||
Changeset c = createCommand().getChangeset("3");
|
||||
|
||||
assertNotNull(c);
|
||||
assertEquals("3", c.getId());
|
||||
@@ -186,12 +186,13 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
assertEquals("a.txt", mods.getModified().get(0));
|
||||
assertEquals("b.txt", mods.getRemoved().get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetRange() throws IOException, RepositoryException
|
||||
@@ -201,8 +202,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
request.setStartChangeset("2");
|
||||
request.setEndChangeset("1");
|
||||
|
||||
ChangesetPagingResult result =
|
||||
new SvnLogCommand(repository, repositoryDirectory).getChangesets(request);
|
||||
ChangesetPagingResult result = createCommand().getChangesets(request);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(2, result.getTotal());
|
||||
@@ -216,4 +216,15 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
|
||||
assertNotNull(c2);
|
||||
assertEquals("1", c2.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private SvnLogCommand createCommand()
|
||||
{
|
||||
return new SvnLogCommand(createContext(), repository);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user