diff --git a/scm-it/pom.xml b/scm-it/pom.xml
index fa4c0b1295..7fe464ccf5 100644
--- a/scm-it/pom.xml
+++ b/scm-it/pom.xml
@@ -21,6 +21,52 @@
scm-core
2.0.0-SNAPSHOT
+
+ sonia.scm
+ scm-test
+ 2.0.0-SNAPSHOT
+
+
+
+ sonia.scm.plugins
+ scm-git-plugin
+ 2.0.0-SNAPSHOT
+ test
+
+
+ sonia.scm.plugins
+ scm-git-plugin
+ 2.0.0-SNAPSHOT
+ tests
+ test
+
+
+ sonia.scm.plugins
+ scm-hg-plugin
+ 2.0.0-SNAPSHOT
+ test
+
+
+ sonia.scm.plugins
+ scm-hg-plugin
+ 2.0.0-SNAPSHOT
+ tests
+ test
+
+
+ sonia.scm.plugins
+ scm-svn-plugin
+ 2.0.0-SNAPSHOT
+ test
+
+
+ sonia.scm.plugins
+ scm-svn-plugin
+ 2.0.0-SNAPSHOT
+ tests
+ test
+
+
io.rest-assured
rest-assured
diff --git a/scm-it/src/test/java/sonia/scm/it/RepositoriesITCase.java b/scm-it/src/test/java/sonia/scm/it/RepositoriesITCase.java
index 4b8d3924a3..a6efc64c3f 100644
--- a/scm-it/src/test/java/sonia/scm/it/RepositoriesITCase.java
+++ b/scm-it/src/test/java/sonia/scm/it/RepositoriesITCase.java
@@ -36,19 +36,29 @@ package sonia.scm.it;
import org.apache.http.HttpStatus;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+import sonia.scm.repository.Person;
+import sonia.scm.repository.client.api.ClientCommand;
+import sonia.scm.repository.client.api.RepositoryClient;
+import sonia.scm.repository.client.api.RepositoryClientFactory;
import sonia.scm.web.VndMediaType;
import javax.json.Json;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Collection;
+import java.util.UUID;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertEquals;
import static sonia.scm.it.RegExMatcher.matchesPattern;
import static sonia.scm.it.RestUtil.createResourceUrl;
import static sonia.scm.it.RestUtil.given;
@@ -56,6 +66,11 @@ import static sonia.scm.it.RestUtil.given;
@RunWith(Parameterized.class)
public class RepositoriesITCase {
+ public static final Person AUTHOR = new Person("SCM Administrator", "scmadmin@scm-manager.org");
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
private final String repositoryType;
private String repositoryUrl;
@@ -138,6 +153,47 @@ public class RepositoriesITCase {
.statusCode(HttpStatus.SC_CONFLICT);
}
+ @Test
+ public void shouldCloneRepository() throws IOException {
+ RepositoryClient rc = createRepositoryClient();
+ assertEquals(1, rc.getWorkingCopy().list().length);
+ }
+
+ @Test
+ public void shouldCommitFiles() throws IOException {
+ RepositoryClient rc = createRepositoryClient();
+
+ for (int i = 0; i < 5; i++) {
+ createRandomFile(rc);
+ }
+
+ commit(rc, "added some test files");
+ }
+
+ public static void createRandomFile(RepositoryClient client) throws IOException {
+ String uuid = UUID.randomUUID().toString();
+ String name = "file-" + uuid + ".uuid";
+
+ File file = new File(client.getWorkingCopy(), name);
+ try (FileOutputStream out = new FileOutputStream(file)) {
+ out.write(uuid.getBytes());
+ }
+
+ client.getAddCommand().add(name);
+ }
+
+ public static void commit(RepositoryClient repositoryClient, String message) throws IOException {
+ repositoryClient.getCommitCommand().commit(AUTHOR, message);
+ if ( repositoryClient.isCommandSupported(ClientCommand.PUSH) ) {
+ repositoryClient.getPushCommand().push();
+ }
+ }
+
+ private RepositoryClient createRepositoryClient() throws IOException {
+ RepositoryClientFactory clientFactory = new RepositoryClientFactory();
+ return clientFactory.create(repositoryType, "http://localhost:8081/scm/" + repositoryType + "/scmadmin/HeartOfGold-" + repositoryType, "scmadmin", "scmadmin", temporaryFolder.newFolder());
+ }
+
private String repositoryJson() {
return Json.createObjectBuilder()
.add("contact", "zaphod.beeblebrox@hitchhiker.com")
diff --git a/scm-webapp/src/test/java/sonia/scm/it/IntegrationTestUtil.java b/scm-webapp/src/test/java/sonia/scm/it/IntegrationTestUtil.java
index 1f75f93d48..98e2e7db04 100644
--- a/scm-webapp/src/test/java/sonia/scm/it/IntegrationTestUtil.java
+++ b/scm-webapp/src/test/java/sonia/scm/it/IntegrationTestUtil.java
@@ -48,19 +48,14 @@ import de.otto.edison.hal.HalRepresentation;
import sonia.scm.api.rest.JSONContextResolver;
import sonia.scm.api.rest.ObjectMapperProvider;
import sonia.scm.repository.Person;
-import sonia.scm.repository.client.api.ClientCommand;
-import sonia.scm.repository.client.api.RepositoryClient;
import sonia.scm.util.IOUtil;
-import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.UUID;
//~--- JDK imports ------------------------------------------------------------
@@ -125,43 +120,6 @@ public final class IntegrationTestUtil
}
}
- /**
- * 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
- */
- public static void createRandomFile(RepositoryClient client) throws IOException
- {
- String uuid = UUID.randomUUID().toString();
- String name = "file-" + uuid + ".uuid";
-
- File file = new File(client.getWorkingCopy(), name);
- try (FileOutputStream out = new FileOutputStream(file)) {
- out.write(uuid.getBytes());
- }
-
- client.getAddCommand().add(name);
- }
-
public static Collection createRepositoryTypeParameters() {
Collection params = new ArrayList<>();
@@ -206,20 +164,6 @@ public final class IntegrationTestUtil
return URI.create(REST_BASE_URL).resolve(url);
}
- /**
- * Method description
- *
- *
- * @return
- */
- public static File createTempDirectory() {
- File directory = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
-
- IOUtil.mkdirs(directory);
-
- return directory;
- }
-
public static String readJson(String jsonFileName) {
URL url = Resources.getResource(jsonFileName);
try {
diff --git a/scm-webapp/src/test/java/sonia/scm/it/RepositoryITCaseBase.java b/scm-webapp/src/test/java/sonia/scm/it/RepositoryITCaseBase.java
deleted file mode 100644
index 06d1f1be8e..0000000000
--- a/scm-webapp/src/test/java/sonia/scm/it/RepositoryITCaseBase.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.it;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.junit.AfterClass;
-import org.junit.runners.Parameterized.Parameters;
-import sonia.scm.api.v2.resources.RepositoryDto;
-import sonia.scm.repository.client.api.RepositoryClient;
-import sonia.scm.repository.client.api.RepositoryClientFactory;
-import sonia.scm.user.User;
-import sonia.scm.user.UserTestData;
-import sonia.scm.util.IOUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import static sonia.scm.it.IntegrationTestUtil.ADMIN_PASSWORD;
-import static sonia.scm.it.IntegrationTestUtil.ADMIN_USERNAME;
-import static sonia.scm.it.IntegrationTestUtil.commit;
-import static sonia.scm.it.IntegrationTestUtil.createAdminClient;
-import static sonia.scm.it.IntegrationTestUtil.createRandomFile;
-import static sonia.scm.it.IntegrationTestUtil.createRepositoryTypeParameters;
-import static sonia.scm.it.IntegrationTestUtil.createResource;
-import static sonia.scm.it.IntegrationTestUtil.createTempDirectory;
-import static sonia.scm.it.IntegrationTestUtil.readJson;
-import static sonia.scm.it.RepositoryITUtil.createUrl;
-import static sonia.scm.it.UserITUtil.postUser;
-
-//~--- JDK imports ------------------------------------------------------------
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class RepositoryITCaseBase
-{
-
- private static final Collection CREATED_REPOSITORIES = new ArrayList<>();
-
- protected User nopermUser;
- protected User ownerUser;
- protected String password;
- protected User readUser;
- protected RepositoryDto repository;
- protected User writeUser;
-
- /**
- * Constructs ...
- *
- *
- * @param repository
- * @param owner
- * @param write
- * @param read
- * @param noperm
- * @param password
- */
- public RepositoryITCaseBase(RepositoryDto repository, User owner, User write,
- User read, User noperm, String password)
- {
- this.repository = repository;
- this.ownerUser = owner;
- this.writeUser = write;
- this.readUser = read;
- this.nopermUser = noperm;
- this.password = password;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param client
- *
- * @throws IOException
- */
- public static void addTestFiles(RepositoryClient client) throws IOException
- {
- for (int i = 0; i < 5; i++)
- {
- createRandomFile(client);
- }
-
- commit(client, "added some test files");
- }
-
- /**
- * Method description
- *
- * @param repository
- * @param username
- * @param password
- *
- * @throws IOException
- */
- public static void addTestFiles(RepositoryDto repository, String username,
- String password)
- {
- File directory = createTempDirectory();
-
- try {
- RepositoryClientFactory clientFactory = new RepositoryClientFactory();
- RepositoryClient client = clientFactory.create(
- repository.getType(), createUrl(repository),
- username, password, directory
- );
-
- addTestFiles(client);
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- try {
- IOUtil.delete(directory);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Method description
- *
- */
- @AfterClass
- public static void cleanup()
- {
- ScmClient client = createAdminClient();
-
- deleteUser(client, UserTestData.createTrillian());
- deleteUser(client, UserTestData.createZaphod());
- deleteUser(client, UserTestData.createMarvin());
- deleteUser(client, UserTestData.createPerfect());
-
- for (RepositoryDto r : CREATED_REPOSITORIES)
- {
- createResource(client, "repositories/" + r.getNamespace() + "/" + r.getName()).delete();
- }
- }
-
- /**
- * Method description
- *
- *
- * @return
- *
- * @throws IOException
- */
- @Parameters(name = "{6}")
- public static Collection