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