mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 23:15:43 +01:00
add logs
This commit is contained in:
@@ -3,6 +3,8 @@ package sonia.scm.it;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.Person;
|
||||
import sonia.scm.repository.client.api.ClientCommand;
|
||||
@@ -15,6 +17,8 @@ import java.util.UUID;
|
||||
|
||||
public class RepositoryUtil {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RepositoryUtil.class);
|
||||
|
||||
private static final RepositoryClientFactory REPOSITORY_CLIENT_FACTORY = new RepositoryClientFactory();
|
||||
|
||||
static RepositoryClient createRepositoryClient(String repositoryType, File folder) throws IOException {
|
||||
@@ -58,6 +62,7 @@ public class RepositoryUtil {
|
||||
}
|
||||
|
||||
static Changeset commit(RepositoryClient repositoryClient, String username, String message) throws IOException {
|
||||
LOG.info("user: {} try to commit with message: {}", username, message);
|
||||
Changeset changeset = repositoryClient.getCommitCommand().commit(new Person(username, username + "@scm-manager.org"), message);
|
||||
if (repositoryClient.isCommandSupported(ClientCommand.PUSH)) {
|
||||
repositoryClient.getPushCommand().push();
|
||||
|
||||
@@ -33,6 +33,7 @@ public class TestData {
|
||||
}
|
||||
|
||||
public static void cleanup() {
|
||||
LOG.info("start to clean up to integration tests");
|
||||
cleanupRepositories();
|
||||
cleanupGroups();
|
||||
cleanupUsers();
|
||||
@@ -43,6 +44,7 @@ public class TestData {
|
||||
}
|
||||
|
||||
public static void createUser(String username, String password) {
|
||||
LOG.info("create user with username: {}", username);
|
||||
given(VndMediaType.USER)
|
||||
.when()
|
||||
.content(" {\n" +
|
||||
@@ -64,6 +66,8 @@ public class TestData {
|
||||
|
||||
|
||||
public static void createUserPermission(String name, PermissionType permissionType, String repositoryType) {
|
||||
String defaultPermissionUrl = TestData.getDefaultPermissionUrl(USER_SCM_ADMIN, USER_SCM_ADMIN, repositoryType);
|
||||
LOG.info("create permission with name {} and type: {} using the endpoint: {}", name, permissionType, defaultPermissionUrl);
|
||||
given(VndMediaType.PERMISSION)
|
||||
.when()
|
||||
.content("{\n" +
|
||||
@@ -72,7 +76,7 @@ public class TestData {
|
||||
"\t\"groupPermission\": false\n" +
|
||||
"\t\n" +
|
||||
"}")
|
||||
.post(TestData.getDefaultPermissionUrl(USER_SCM_ADMIN, USER_SCM_ADMIN, repositoryType))
|
||||
.post(defaultPermissionUrl)
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_CREATED)
|
||||
;
|
||||
@@ -114,6 +118,7 @@ public class TestData {
|
||||
|
||||
|
||||
private static void cleanupRepositories() {
|
||||
LOG.info("clean up repository");
|
||||
List<String> repositories = given(VndMediaType.REPOSITORY_COLLECTION)
|
||||
.when()
|
||||
.get(createResourceUrl("repositories"))
|
||||
@@ -160,6 +165,7 @@ public class TestData {
|
||||
}
|
||||
|
||||
private static void createDefaultRepositories() {
|
||||
LOG.info("create default repositories");
|
||||
for (String repositoryType : availableScmTypes()) {
|
||||
String url = given(VndMediaType.REPOSITORY)
|
||||
.body(repositoryJson(repositoryType))
|
||||
@@ -171,6 +177,7 @@ public class TestData {
|
||||
.statusCode(HttpStatus.SC_CREATED)
|
||||
.extract()
|
||||
.header("location");
|
||||
LOG.info("a {} repository is created: {}", repositoryType, url);
|
||||
DEFAULT_REPOSITORIES.put(repositoryType, url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user