mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
use newer repository client api
This commit is contained in:
@@ -52,9 +52,6 @@ import sonia.scm.repository.Permission;
|
||||
import sonia.scm.repository.PermissionType;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryTestData;
|
||||
import sonia.scm.repository.client.RepositoryClient;
|
||||
import sonia.scm.repository.client.RepositoryClientException;
|
||||
import sonia.scm.repository.client.RepositoryClientFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -73,6 +70,9 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import sonia.scm.repository.client.api.RepositoryClient;
|
||||
import sonia.scm.repository.client.api.RepositoryClientFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -189,14 +189,11 @@ public class AnonymousAccessITCase
|
||||
/**
|
||||
* Issue 97
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAllowedAnonymousPush()
|
||||
throws IOException, RepositoryClientException
|
||||
public void testAllowedAnonymousPush() throws IOException
|
||||
{
|
||||
Client client = createAdminClient();
|
||||
WebResource resource = createResource(client,
|
||||
@@ -208,7 +205,7 @@ public class AnonymousAccessITCase
|
||||
RepositoryClient repositoryClient = createAnonymousRepositoryClient();
|
||||
|
||||
createRandomFile(repositoryClient);
|
||||
repositoryClient.commit("added test files");
|
||||
commit(repositoryClient, "added test files");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,34 +213,30 @@ public class AnonymousAccessITCase
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
public void testAnonymousClone() throws RepositoryClientException, IOException
|
||||
public void testAnonymousClone() throws IOException
|
||||
{
|
||||
testSimpleAdminPush();
|
||||
|
||||
RepositoryClient client = createAnonymousRepositoryClient();
|
||||
|
||||
client.checkout();
|
||||
// client.checkout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Ignore
|
||||
@Test(expected = RepositoryClientException.class)
|
||||
public void testDeniedAnonymousPush()
|
||||
throws IOException, RepositoryClientException
|
||||
@Test(expected = IOException.class)
|
||||
public void testDeniedAnonymousPush() throws IOException
|
||||
{
|
||||
RepositoryClient repositoryClient = createAnonymousRepositoryClient();
|
||||
|
||||
createRandomFile(repositoryClient);
|
||||
repositoryClient.commit("added anonymous test file");
|
||||
commit(repositoryClient, "added anonymous test file");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,81 +244,30 @@ public class AnonymousAccessITCase
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
public void testSimpleAdminPush()
|
||||
throws RepositoryClientException, IOException
|
||||
public void testSimpleAdminPush() throws IOException
|
||||
{
|
||||
RepositoryClient client = createAdminRepositoryClient();
|
||||
RepositoryClient repositoryClient = createAdminRepositoryClient();
|
||||
|
||||
createRandomFile(client);
|
||||
client.commit("added random file");
|
||||
createRandomFile(repositoryClient);
|
||||
commit(repositoryClient, "added random file");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private RepositoryClient createAdminRepositoryClient()
|
||||
throws IOException, RepositoryClientException
|
||||
{
|
||||
private RepositoryClient createAdminRepositoryClient() throws IOException {
|
||||
return createRepositoryClient(ADMIN_USERNAME, ADMIN_PASSWORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private RepositoryClient createAnonymousRepositoryClient()
|
||||
throws IOException, RepositoryClientException
|
||||
{
|
||||
private RepositoryClient createAnonymousRepositoryClient() throws IOException {
|
||||
return createRepositoryClient(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private RepositoryClient createRepositoryClient(String username,
|
||||
String password)
|
||||
throws IOException, RepositoryClientException
|
||||
{
|
||||
private RepositoryClient createRepositoryClient(String username, String password) throws IOException {
|
||||
File directory = temporaryFolder.newFolder();
|
||||
RepositoryClient client = null;
|
||||
String remoteUrl = repository.createUrl(BASE_URL);
|
||||
|
||||
if ((username != null) && (password != null))
|
||||
{
|
||||
client = RepositoryClientFactory.createClient(repositoryType, directory,
|
||||
repository.getUrl(), username, password);
|
||||
}
|
||||
else
|
||||
{
|
||||
client = RepositoryClientFactory.createClient(repositoryType, directory,
|
||||
repository.getUrl());
|
||||
}
|
||||
|
||||
client.init();
|
||||
|
||||
return client;
|
||||
RepositoryClientFactory factory = new RepositoryClientFactory();
|
||||
return factory.create(repositoryType, remoteUrl, username, password, directory);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
@@ -338,5 +280,5 @@ public class AnonymousAccessITCase
|
||||
private Repository repository;
|
||||
|
||||
/** Field description */
|
||||
private String repositoryType;
|
||||
private final String repositoryType;
|
||||
}
|
||||
|
||||
@@ -48,9 +48,7 @@ import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.Modifications;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryTestData;
|
||||
import sonia.scm.repository.client.RepositoryClient;
|
||||
import sonia.scm.repository.client.RepositoryClientException;
|
||||
import sonia.scm.repository.client.RepositoryClientFactory;
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
@@ -72,6 +70,10 @@ import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import sonia.scm.repository.client.api.ClientCommand;
|
||||
|
||||
import sonia.scm.repository.client.api.RepositoryClient;
|
||||
import sonia.scm.repository.client.api.RepositoryClientFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -112,16 +114,14 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws InterruptedException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void cachingTest()
|
||||
throws RepositoryClientException, IOException, InterruptedException
|
||||
public void cachingTest() throws IOException, InterruptedException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient();
|
||||
|
||||
rc.checkout();
|
||||
// rc.checkout();
|
||||
addTestFile(rc, "a", 1, false);
|
||||
addTestFile(rc, "b", 2, true);
|
||||
}
|
||||
@@ -161,15 +161,13 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws InterruptedException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
public void simpleTest()
|
||||
throws RepositoryClientException, IOException, InterruptedException
|
||||
public void simpleTest() throws IOException, InterruptedException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient();
|
||||
|
||||
rc.init();
|
||||
// rc.init();
|
||||
addTestFile(rc, "a", 1, false);
|
||||
}
|
||||
|
||||
@@ -188,29 +186,24 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
*/
|
||||
private void addTestFile(RepositoryClient rc, String name, int count,
|
||||
boolean sleep)
|
||||
throws IOException, RepositoryClientException, InterruptedException
|
||||
throws IOException, InterruptedException
|
||||
{
|
||||
File file = new File(localDirectory, name.concat(".txt"));
|
||||
|
||||
writeRandomContent(file);
|
||||
rc.add(name.concat(".txt"));
|
||||
rc.commit("added-".concat(name).concat(".txt"));
|
||||
|
||||
if (sleep)
|
||||
{
|
||||
rc.getAddCommand().add(name.concat(".txt"));
|
||||
IntegrationTestUtil.commit(rc, "added-".concat(name).concat(".txt"));
|
||||
|
||||
if (sleep) {
|
||||
// cache clear is async
|
||||
Thread.sleep(500l);
|
||||
}
|
||||
|
||||
ChangesetPagingResult cpr = getChangesets(repository);
|
||||
|
||||
if ("svn".equals(repositoryType))
|
||||
{
|
||||
if ("svn".equals(repositoryType)) {
|
||||
assertEquals((count + 1), cpr.getTotal());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
assertEquals(count, cpr.getTotal());
|
||||
}
|
||||
|
||||
@@ -218,12 +211,9 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
|
||||
assertNotNull(changesets);
|
||||
|
||||
if ("svn".equals(repositoryType))
|
||||
{
|
||||
if ("svn".equals(repositoryType)) {
|
||||
assertEquals((count + 1), changesets.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
assertEquals(count, changesets.size());
|
||||
}
|
||||
|
||||
@@ -253,75 +243,32 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
//J+
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private RepositoryClient createRepositoryClient()
|
||||
throws RepositoryClientException
|
||||
{
|
||||
return RepositoryClientFactory.createClient(repositoryType, localDirectory,
|
||||
repository.getUrl(), IntegrationTestUtil.ADMIN_USERNAME,
|
||||
IntegrationTestUtil.ADMIN_PASSWORD);
|
||||
private RepositoryClient createRepositoryClient() throws IOException {
|
||||
RepositoryClientFactory factory = new RepositoryClientFactory();
|
||||
return factory.create(
|
||||
repositoryType, repository.createUrl(BASE_URL),
|
||||
IntegrationTestUtil.ADMIN_USERNAME, IntegrationTestUtil.ADMIN_PASSWORD,
|
||||
localDirectory
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param file
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void writeRandomContent(File file) throws IOException
|
||||
{
|
||||
FileOutputStream output = null;
|
||||
|
||||
try
|
||||
{
|
||||
output = new FileOutputStream(file);
|
||||
|
||||
Random random = new Random();
|
||||
byte[] data = new byte[random.nextInt(1024)];
|
||||
|
||||
private void writeRandomContent(File file) throws IOException {
|
||||
Random random = new Random();
|
||||
byte[] data = new byte[random.nextInt(1024)];
|
||||
|
||||
try (FileOutputStream output = new FileOutputStream(file)) {
|
||||
random.nextBytes(data);
|
||||
output.write(data);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(output);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getChangesetViewerUri(Repository repository)
|
||||
{
|
||||
private String getChangesetViewerUri(Repository repository) {
|
||||
return "repositories/".concat(repository.getId()).concat("/changesets");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ChangesetPagingResult getChangesets(Repository repository)
|
||||
{
|
||||
private ChangesetPagingResult getChangesets(Repository repository) {
|
||||
WebResource resource = createResource(client,
|
||||
getChangesetViewerUri(repository));
|
||||
|
||||
@@ -348,5 +295,5 @@ public class ChangesetViewerITCase extends AbstractAdminITCaseBase
|
||||
private Repository repository;
|
||||
|
||||
/** Field description */
|
||||
private String repositoryType;
|
||||
private final String repositoryType;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ package sonia.scm.it;
|
||||
|
||||
import sonia.scm.ScmState;
|
||||
import sonia.scm.Type;
|
||||
import sonia.scm.repository.client.RepositoryClient;
|
||||
import sonia.scm.repository.client.RepositoryClientException;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
@@ -63,6 +61,9 @@ import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import sonia.scm.repository.Person;
|
||||
import sonia.scm.repository.client.api.ClientCommand;
|
||||
import sonia.scm.repository.client.api.RepositoryClient;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -70,6 +71,8 @@ import javax.ws.rs.core.MultivaluedMap;
|
||||
*/
|
||||
public final class IntegrationTestUtil
|
||||
{
|
||||
|
||||
public static final Person AUTHOR = new Person("SCM Administrator", "scmadmin@scm-manager.org");
|
||||
|
||||
/** Field description */
|
||||
public static final String ADMIN_PASSWORD = "scmadmin";
|
||||
@@ -181,34 +184,41 @@ public final class IntegrationTestUtil
|
||||
return ApacheHttpClient.create(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit and push changes.
|
||||
*
|
||||
* @param repositoryClient repository client
|
||||
* @param message commit message
|
||||
*
|
||||
* @throws IOException
|
||||
*
|
||||
* @since 1.51
|
||||
*/
|
||||
public static void commit(RepositoryClient repositoryClient, String message) throws IOException {
|
||||
repositoryClient.getCommitCommand().commit(IntegrationTestUtil.AUTHOR, message);
|
||||
if ( repositoryClient.isCommandSupported(ClientCommand.PUSH) ) {
|
||||
repositoryClient.getPushCommand().push();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param client
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
public static void createRandomFile(RepositoryClient client)
|
||||
throws IOException, RepositoryClientException
|
||||
public static void createRandomFile(RepositoryClient client) throws IOException
|
||||
{
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String name = "file-" + uuid + ".uuid";
|
||||
FileOutputStream out = null;
|
||||
|
||||
try
|
||||
{
|
||||
out = new FileOutputStream(new File(client.getLocalRepository(), name));
|
||||
File file = new File(client.getWorkingCopy(), name);
|
||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||
out.write(uuid.getBytes());
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(out);
|
||||
}
|
||||
|
||||
client.add(name);
|
||||
client.getAddCommand().add(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,7 +229,7 @@ public final class IntegrationTestUtil
|
||||
*/
|
||||
public static Collection<String[]> createRepositoryTypeParameters()
|
||||
{
|
||||
Collection<String[]> params = new ArrayList<String[]>();
|
||||
Collection<String[]> params = new ArrayList<>();
|
||||
|
||||
params.add(new String[] { "git" });
|
||||
params.add(new String[] { "svn" });
|
||||
@@ -258,7 +268,7 @@ public final class IntegrationTestUtil
|
||||
{
|
||||
return REST_BASE_URL.concat(url).concat(EXTENSION);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -42,8 +42,6 @@ import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.client.RepositoryClient;
|
||||
import sonia.scm.repository.client.RepositoryClientException;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
@@ -56,6 +54,9 @@ import static sonia.scm.it.IntegrationTestUtil.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import sonia.scm.repository.client.api.RepositoryClient;
|
||||
import sonia.scm.repository.client.api.RepositoryClientException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -100,14 +101,14 @@ public class RepositoryExtendedITCase extends RepositoryITCaseBase
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws RepositoryClientException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test(expected = RepositoryClientException.class)
|
||||
public void readFailed() throws RepositoryClientException
|
||||
public void readFailed() throws IOException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient(nopermUser, directory);
|
||||
|
||||
rc.checkout();
|
||||
// rc.checkout();
|
||||
|
||||
// ugly workaround
|
||||
if (repository.getType().equals("git"))
|
||||
@@ -120,7 +121,7 @@ public class RepositoryExtendedITCase extends RepositoryITCaseBase
|
||||
}
|
||||
}
|
||||
|
||||
throw new RepositoryClientException("checkout failed");
|
||||
throw new IOException("checkout failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,47 +140,40 @@ public class RepositoryExtendedITCase extends RepositoryITCaseBase
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
public void simpleRead() throws RepositoryClientException, IOException
|
||||
public void simpleRead() throws IOException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient(readUser, directory);
|
||||
|
||||
rc.checkout();
|
||||
// rc.checkout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test
|
||||
public void simpleWrite() throws RepositoryClientException, IOException
|
||||
public void simpleWrite() throws IOException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient(writeUser, directory);
|
||||
|
||||
rc.checkout();
|
||||
// rc.checkout();
|
||||
addTestFiles(rc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test(expected = RepositoryClientException.class)
|
||||
public void writeFailed() throws RepositoryClientException, IOException
|
||||
@Test(expected = IOException.class)
|
||||
public void writeFailed() throws IOException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient(readUser, directory);
|
||||
|
||||
rc.checkout();
|
||||
// rc.checkout();
|
||||
addTestFiles(rc);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,6 @@ import sonia.scm.repository.Permission;
|
||||
import sonia.scm.repository.PermissionType;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryTestData;
|
||||
import sonia.scm.repository.client.RepositoryClient;
|
||||
import sonia.scm.repository.client.RepositoryClientException;
|
||||
import sonia.scm.repository.client.RepositoryClientFactory;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.UserTestData;
|
||||
import sonia.scm.util.IOUtil;
|
||||
@@ -69,6 +66,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import sonia.scm.repository.client.api.RepositoryClient;
|
||||
import sonia.scm.repository.client.api.RepositoryClientFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -107,45 +107,40 @@ public class RepositoryITCaseBase
|
||||
* @param client
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
public static void addTestFiles(RepositoryClient client)
|
||||
throws RepositoryClientException, IOException
|
||||
public static void addTestFiles(RepositoryClient client) throws IOException
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
createRandomFile(client);
|
||||
}
|
||||
|
||||
client.commit("added some test files");
|
||||
commit(client, "added some test files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param username
|
||||
* @param password
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
public static void addTestFiles(Repository repository, String username,
|
||||
String password)
|
||||
throws RepositoryClientException, IOException
|
||||
throws IOException
|
||||
{
|
||||
File directory = createTempDirectory();
|
||||
|
||||
try
|
||||
{
|
||||
RepositoryClient rc =
|
||||
RepositoryClientFactory.createClient(repository.getType(), directory,
|
||||
repository.getUrl(), username, password);
|
||||
|
||||
rc.init();
|
||||
addTestFiles(rc);
|
||||
RepositoryClientFactory clientFactory = new RepositoryClientFactory();
|
||||
RepositoryClient client = clientFactory.create(
|
||||
repository.getType(), repository.createUrl(BASE_URL), username, password, directory
|
||||
);
|
||||
|
||||
addTestFiles(client);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -190,11 +185,9 @@ public class RepositoryITCaseBase
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Parameters
|
||||
public static Collection<Object[]> createParameters()
|
||||
throws RepositoryClientException, IOException
|
||||
public static Collection<Object[]> createParameters() throws IOException
|
||||
{
|
||||
Client client = createClient();
|
||||
ScmState state = authenticateAdmin(client);
|
||||
@@ -202,7 +195,7 @@ public class RepositoryITCaseBase
|
||||
assertNotNull(state);
|
||||
assertTrue(state.isSuccess());
|
||||
|
||||
Collection<Object[]> params = new ArrayList<Object[]>();
|
||||
Collection<Object[]> params = new ArrayList<>();
|
||||
User owner = UserTestData.createTrillian();
|
||||
|
||||
createUser(owner);
|
||||
@@ -242,16 +235,14 @@ public class RepositoryITCaseBase
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private static void appendTestParemeter(Collection<Object[]> params,
|
||||
String type, User owner, User write, User read, User noperm)
|
||||
throws RepositoryClientException, IOException
|
||||
String type, User owner, User write, User read, User noperm) throws IOException
|
||||
{
|
||||
Repository repository = createTestRepository(null, type, owner, write,
|
||||
read);
|
||||
|
||||
Repository repository = createTestRepository(null, type, owner, write, read);
|
||||
params.add(new Object[]
|
||||
{
|
||||
repository, owner, write, read, noperm, "secret"
|
||||
});
|
||||
|
||||
repository = createTestRepository("test", type, owner, write, read);
|
||||
params.add(new Object[]
|
||||
{
|
||||
@@ -276,8 +267,7 @@ public class RepositoryITCaseBase
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
private static Repository createTestRepository(String prefix, String type,
|
||||
User owner, User write, User read)
|
||||
throws RepositoryClientException, IOException
|
||||
User owner, User write, User read) throws IOException
|
||||
{
|
||||
Client client = createAdminClient();
|
||||
Repository repository = RepositoryTestData.createHeartOfGold(type);
|
||||
@@ -296,6 +286,7 @@ public class RepositoryITCaseBase
|
||||
//J+
|
||||
repository = createRepository(client, repository);
|
||||
client.destroy();
|
||||
|
||||
addTestFiles(repository, ADMIN_USERNAME, ADMIN_PASSWORD);
|
||||
|
||||
return repository;
|
||||
@@ -336,14 +327,14 @@ public class RepositoryITCaseBase
|
||||
* @param directory
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryClientException
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected RepositoryClient createRepositoryClient(User user, File directory)
|
||||
throws RepositoryClientException
|
||||
protected RepositoryClient createRepositoryClient(User user, File directory) throws IOException
|
||||
{
|
||||
return RepositoryClientFactory.createClient(repository.getType(),
|
||||
directory, repository.getUrl(), user.getName(), password);
|
||||
RepositoryClientFactory clientFactory = new RepositoryClientFactory();
|
||||
return clientFactory.create(repository.getType(), repository.createUrl(BASE_URL),
|
||||
user.getName(), password, directory);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
@@ -65,12 +65,10 @@ public final class RepositoryITUtil
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param other
|
||||
*/
|
||||
public static void assertRepositoriesEquals(Repository repository,
|
||||
Repository other)
|
||||
public static void assertRepositoriesEquals(Repository repository, Repository other)
|
||||
{
|
||||
assertEquals(repository.getName(), other.getName());
|
||||
assertEquals(repository.getDescription(), other.getDescription());
|
||||
@@ -82,8 +80,6 @@ public final class RepositoryITUtil
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param client
|
||||
* @param repository
|
||||
*
|
||||
@@ -116,8 +112,6 @@ public final class RepositoryITUtil
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param client
|
||||
* @param id
|
||||
*/
|
||||
@@ -141,10 +135,6 @@ public final class RepositoryITUtil
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param client
|
||||
* @param url
|
||||
*
|
||||
@@ -168,11 +158,6 @@ public final class RepositoryITUtil
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param client
|
||||
* @param id
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user