mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
fix integration tests
This commit is contained in:
@@ -39,7 +39,6 @@ import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
@@ -70,14 +69,12 @@ import com.sun.jersey.api.client.WebResource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Ignore
|
||||
@RunWith(Parameterized.class)
|
||||
public class AnonymousAccessITCase
|
||||
{
|
||||
@@ -187,31 +184,6 @@ public class AnonymousAccessITCase
|
||||
logoutClient(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue 97
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAllowedAnonymousPush()
|
||||
throws IOException, RepositoryClientException
|
||||
{
|
||||
Client client = createAdminClient();
|
||||
WebResource resource = createResource(client,
|
||||
"repository/".concat(repository.getId()));
|
||||
|
||||
repository.setPermissions(Arrays.asList(PERMISSION_ANONYMOUS_WRITE));
|
||||
resource.post(ClientResponse.class, repository);
|
||||
|
||||
RepositoryClient repositoryClient = createAnonymousRepositoryClient();
|
||||
|
||||
createRandomFile(repositoryClient);
|
||||
repositoryClient.commit("added test files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -236,10 +208,9 @@ public class AnonymousAccessITCase
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Ignore
|
||||
@Test(expected = RepositoryClientException.class)
|
||||
public void testDeniedAnonymousPush()
|
||||
throws IOException, RepositoryClientException
|
||||
throws IOException, RepositoryClientException
|
||||
{
|
||||
RepositoryClient repositoryClient = createAnonymousRepositoryClient();
|
||||
|
||||
@@ -256,7 +227,7 @@ public class AnonymousAccessITCase
|
||||
*/
|
||||
@Test
|
||||
public void testSimpleAdminPush()
|
||||
throws RepositoryClientException, IOException
|
||||
throws RepositoryClientException, IOException
|
||||
{
|
||||
RepositoryClient client = createAdminRepositoryClient();
|
||||
|
||||
@@ -274,7 +245,7 @@ public class AnonymousAccessITCase
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private RepositoryClient createAdminRepositoryClient()
|
||||
throws IOException, RepositoryClientException
|
||||
throws IOException, RepositoryClientException
|
||||
{
|
||||
return createRepositoryClient(ADMIN_USERNAME, ADMIN_PASSWORD);
|
||||
}
|
||||
@@ -289,7 +260,7 @@ public class AnonymousAccessITCase
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private RepositoryClient createAnonymousRepositoryClient()
|
||||
throws IOException, RepositoryClientException
|
||||
throws IOException, RepositoryClientException
|
||||
{
|
||||
return createRepositoryClient(null, null);
|
||||
}
|
||||
@@ -307,23 +278,23 @@ public class AnonymousAccessITCase
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private RepositoryClient createRepositoryClient(String username,
|
||||
String password)
|
||||
throws IOException, RepositoryClientException
|
||||
String password)
|
||||
throws IOException, RepositoryClientException
|
||||
{
|
||||
File directory = temporaryFolder.newFolder();
|
||||
RepositoryClient client = null;
|
||||
|
||||
// TODO create repository url
|
||||
|
||||
String url = repository.createUrl(URL);
|
||||
|
||||
if ((username != null) && (password != null))
|
||||
{
|
||||
client = RepositoryClientFactory.createClient(repositoryType, directory,
|
||||
null, username, password);
|
||||
url, username, password);
|
||||
}
|
||||
else
|
||||
{
|
||||
client = RepositoryClientFactory.createClient(repositoryType, directory,
|
||||
null);
|
||||
url);
|
||||
}
|
||||
|
||||
client.init();
|
||||
|
||||
@@ -77,7 +77,6 @@ import java.util.Random;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Ignore
|
||||
@RunWith(Parameterized.class)
|
||||
public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
{
|
||||
@@ -116,9 +115,8 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void cachingTest()
|
||||
throws RepositoryClientException, IOException, InterruptedException
|
||||
throws RepositoryClientException, IOException, InterruptedException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient();
|
||||
|
||||
@@ -166,7 +164,7 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
*/
|
||||
@Test
|
||||
public void simpleTest()
|
||||
throws RepositoryClientException, IOException, InterruptedException
|
||||
throws RepositoryClientException, IOException, InterruptedException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient();
|
||||
|
||||
@@ -188,8 +186,8 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private void addTestFile(RepositoryClient rc, String name, int count,
|
||||
boolean sleep)
|
||||
throws IOException, RepositoryClientException, InterruptedException
|
||||
boolean sleep)
|
||||
throws IOException, RepositoryClientException, InterruptedException
|
||||
{
|
||||
File file = new File(localDirectory, name.concat(".txt"));
|
||||
|
||||
@@ -263,12 +261,11 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private RepositoryClient createRepositoryClient()
|
||||
throws RepositoryClientException
|
||||
throws RepositoryClientException
|
||||
{
|
||||
// TODO create repository url
|
||||
return RepositoryClientFactory.createClient(repositoryType, localDirectory,
|
||||
null, IntegrationTestUtil.ADMIN_USERNAME,
|
||||
IntegrationTestUtil.ADMIN_PASSWORD);
|
||||
repository.createUrl(URL), IntegrationTestUtil.ADMIN_USERNAME,
|
||||
IntegrationTestUtil.ADMIN_PASSWORD);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,6 +77,8 @@ public final class IntegrationTestUtil
|
||||
/** Field description */
|
||||
public static final String ADMIN_USERNAME = "scmadmin";
|
||||
|
||||
public static final String URL = "http://localhost:8081/scm";
|
||||
|
||||
/** Field description */
|
||||
public static final String BASE_URL = "http://localhost:8081/scm/api/rest/";
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ package sonia.scm.it;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
@@ -46,6 +45,7 @@ import sonia.scm.repository.Permission;
|
||||
import sonia.scm.repository.PermissionType;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryTestData;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -87,9 +87,32 @@ public class RepositoryITCase extends AbstractAdminITCaseBase
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@AfterClass
|
||||
public static void cleanup()
|
||||
@Parameters
|
||||
public static Collection<String[]> createParameters()
|
||||
{
|
||||
Collection<String[]> params = new ArrayList<String[]>();
|
||||
|
||||
params.add(new String[] { "git" });
|
||||
|
||||
params.add(new String[] { "svn" });
|
||||
|
||||
if (IOUtil.search("hg") != null)
|
||||
{
|
||||
params.add(new String[] { "hg" });
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@After
|
||||
public void cleanup()
|
||||
{
|
||||
Client client = createClient();
|
||||
|
||||
@@ -111,37 +134,11 @@ public class RepositoryITCase extends AbstractAdminITCaseBase
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Parameters
|
||||
public static Collection<String[]> createParameters()
|
||||
{
|
||||
Collection<String[]> params = new ArrayList<String[]>();
|
||||
|
||||
params.add(new String[] { "git" });
|
||||
|
||||
/*
|
||||
* params.add(new String[] { "svn" });
|
||||
*
|
||||
* if (IOUtil.search("hg") != null)
|
||||
* {
|
||||
* params.add(new String[] { "hg" });
|
||||
* }
|
||||
*/
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void create()
|
||||
{
|
||||
Repository repository =
|
||||
@@ -155,7 +152,6 @@ public class RepositoryITCase extends AbstractAdminITCaseBase
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void delete()
|
||||
{
|
||||
Repository repository =
|
||||
@@ -170,14 +166,20 @@ public class RepositoryITCase extends AbstractAdminITCaseBase
|
||||
*
|
||||
*/
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void doubleCreate()
|
||||
{
|
||||
Repository repository = RepositoryTestData.create42Puzzle(repositoryType);
|
||||
|
||||
repository = createRepository(client, repository);
|
||||
|
||||
// repository = createRepository(repository);
|
||||
WebResource wr = createResource(client, "repositories");
|
||||
ClientResponse response = wr.post(ClientResponse.class, repository);
|
||||
|
||||
assertNotNull(response);
|
||||
|
||||
// TODO should be 409?
|
||||
assertEquals(500, response.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +187,6 @@ public class RepositoryITCase extends AbstractAdminITCaseBase
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void modify()
|
||||
{
|
||||
Repository repository =
|
||||
@@ -206,7 +207,6 @@ public class RepositoryITCase extends AbstractAdminITCaseBase
|
||||
Repository other = getRepositoryById(client, repository.getId());
|
||||
|
||||
assertRepositoriesEquals(repository, other);
|
||||
deleteRepository(client, repository.getId());
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -259,5 +259,5 @@ public class RepositoryITCase extends AbstractAdminITCaseBase
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String repositoryType;
|
||||
private final String repositoryType;
|
||||
}
|
||||
|
||||
@@ -68,13 +68,11 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Ignore
|
||||
public class RepositoryITCaseBase
|
||||
{
|
||||
|
||||
@@ -142,10 +140,9 @@ public class RepositoryITCaseBase
|
||||
|
||||
try
|
||||
{
|
||||
// TODO create repository url
|
||||
RepositoryClient rc =
|
||||
RepositoryClientFactory.createClient(repository.getType(), directory,
|
||||
null, username, password);
|
||||
repository.createUrl(URL), username, password);
|
||||
|
||||
rc.init();
|
||||
addTestFiles(rc);
|
||||
@@ -345,9 +342,8 @@ public class RepositoryITCaseBase
|
||||
protected RepositoryClient createRepositoryClient(User user, File directory)
|
||||
throws RepositoryClientException
|
||||
{
|
||||
// TODO create repository url
|
||||
return RepositoryClientFactory.createClient(repository.getType(),
|
||||
directory, null, user.getName(), password);
|
||||
directory, repository.createUrl(URL), user.getName(), password);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user