mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
fix unit tests for git commands
This commit is contained in:
@@ -37,11 +37,14 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import sonia.scm.repository.BrowserResult;
|
import sonia.scm.repository.BrowserResult;
|
||||||
import sonia.scm.repository.FileObject;
|
import sonia.scm.repository.FileObject;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,9 +57,12 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
|||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testBrowse()
|
public void testBrowse() throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
BrowserResult result = new GitBrowseCommand(
|
BrowserResult result = new GitBrowseCommand(
|
||||||
repository,
|
repository,
|
||||||
@@ -98,21 +104,23 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
|||||||
assertEquals("c", c.getName());
|
assertEquals("c", c.getName());
|
||||||
assertEquals("c", c.getPath());
|
assertEquals("c", c.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testBrowseSubDirectory()
|
public void testBrowseSubDirectory() throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||||
|
|
||||||
request.setPath("c");
|
request.setPath("c");
|
||||||
|
|
||||||
BrowserResult result = new GitBrowseCommand(
|
BrowserResult result = new GitBrowseCommand(repository,
|
||||||
repository,
|
repositoryDirectory).getBrowserResult(request);
|
||||||
repositoryDirectory).getBrowserResult(
|
|
||||||
request);
|
|
||||||
|
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
|
|
||||||
@@ -134,7 +142,7 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
|||||||
else if ("e.txt".equals(f.getName()))
|
else if ("e.txt".equals(f.getName()))
|
||||||
{
|
{
|
||||||
e = f;
|
e = f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNotNull(d);
|
assertNotNull(d);
|
||||||
@@ -144,7 +152,6 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
|||||||
assertEquals("added file d and e in folder c", d.getDescription());
|
assertEquals("added file d and e in folder c", d.getDescription());
|
||||||
assertTrue(d.getLength() > 0);
|
assertTrue(d.getLength() > 0);
|
||||||
checkDate(d.getLastModified());
|
checkDate(d.getLastModified());
|
||||||
|
|
||||||
assertNotNull(e);
|
assertNotNull(e);
|
||||||
assertFalse(e.isDirectory());
|
assertFalse(e.isDirectory());
|
||||||
assertEquals("e.txt", e.getName());
|
assertEquals("e.txt", e.getName());
|
||||||
@@ -153,5 +160,4 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
|||||||
assertTrue(e.getLength() > 0);
|
assertTrue(e.getLength() > 0);
|
||||||
checkDate(e.getLastModified());
|
checkDate(e.getLastModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,14 @@ package sonia.scm.repository.spi;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO add not found test
|
* TODO add not found test
|
||||||
@@ -52,9 +55,12 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase
|
|||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCat()
|
public void testCat() throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
CatCommandRequest request = new CatCommandRequest();
|
CatCommandRequest request = new CatCommandRequest();
|
||||||
|
|
||||||
@@ -66,9 +72,12 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase
|
|||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleCat()
|
public void testSimpleCat() throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
CatCommandRequest request = new CatCommandRequest();
|
CatCommandRequest request = new CatCommandRequest();
|
||||||
|
|
||||||
@@ -83,8 +92,12 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase
|
|||||||
* @param request
|
* @param request
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
private String execute(CatCommandRequest request)
|
private String execute(CatCommandRequest request)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
String content = null;
|
String content = null;
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ import static org.hamcrest.Matchers.*;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
@@ -53,9 +57,11 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
|||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetAll()
|
public void testGetAll() throws IOException
|
||||||
{
|
{
|
||||||
ChangesetPagingResult result = new GitLogCommand(
|
ChangesetPagingResult result = new GitLogCommand(
|
||||||
repository,
|
repository,
|
||||||
@@ -70,9 +76,11 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
|||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllByPath()
|
public void testGetAllByPath() throws IOException
|
||||||
{
|
{
|
||||||
LogCommandRequest request = new LogCommandRequest();
|
LogCommandRequest request = new LogCommandRequest();
|
||||||
|
|
||||||
@@ -92,9 +100,11 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
|||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllWithLimit()
|
public void testGetAllWithLimit() throws IOException
|
||||||
{
|
{
|
||||||
LogCommandRequest request = new LogCommandRequest();
|
LogCommandRequest request = new LogCommandRequest();
|
||||||
|
|
||||||
@@ -149,9 +159,11 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
|||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetRange()
|
public void testGetRange() throws IOException
|
||||||
{
|
{
|
||||||
LogCommandRequest request = new LogCommandRequest();
|
LogCommandRequest request = new LogCommandRequest();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user