diff --git a/scm-clients/scm-client-impl/pom.xml b/scm-clients/scm-client-impl/pom.xml
index ed86180b58..12a84a8d40 100644
--- a/scm-clients/scm-client-impl/pom.xml
+++ b/scm-clients/scm-client-impl/pom.xml
@@ -50,6 +50,13 @@
0.9.28
test
+
+
+ sonia.scm
+ scm-test
+ 1.3-SNAPSHOT
+ test
+
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/AbstractITCaseBase.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/AbstractITCaseBase.java
new file mode 100644
index 0000000000..34196f2875
--- /dev/null
+++ b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/AbstractITCaseBase.java
@@ -0,0 +1,111 @@
+/**
+ * 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.client.it;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import sonia.scm.client.JerseyClientProvider;
+import sonia.scm.client.JerseyClientSession;
+import sonia.scm.client.ScmClientException;
+
+/**
+ *
+ * @author Sebastian Sdorra
+ */
+public class AbstractITCaseBase
+{
+
+ /** Field description */
+ public static final String ADMIN_PASSWORD = "scmadmin";
+
+ /** Field description */
+ public static final String ADMIN_USERNAME = "scmadmin";
+
+ /** Field description */
+ public static final String REPOSITORY_TYPE = "git";
+
+ /** Field description */
+ public static final String URL_BASE = "http://localhost:8081/scm";
+
+ /** Field description */
+ public static final boolean REQUEST_LOGGING = false;
+
+ //~--- methods --------------------------------------------------------------
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ *
+ * @throws ScmClientException
+ */
+ protected JerseyClientSession createAdminSession() throws ScmClientException
+ {
+ return createSession(ADMIN_USERNAME, ADMIN_PASSWORD);
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ *
+ * @throws ScmClientException
+ */
+ protected JerseyClientSession createAnonymousSession()
+ throws ScmClientException
+ {
+ return createSession(null, null);
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @param username
+ * @param password
+ *
+ * @return
+ *
+ * @throws ScmClientException
+ */
+ protected JerseyClientSession createSession(String username, String password)
+ throws ScmClientException
+ {
+ JerseyClientProvider provider = new JerseyClientProvider(REQUEST_LOGGING);
+
+ return provider.createSession(URL_BASE, username, password);
+ }
+}
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientProviderITCase.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientProviderITCase.java
index e0704a4f00..2bf3d204f8 100644
--- a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientProviderITCase.java
+++ b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientProviderITCase.java
@@ -38,7 +38,6 @@ package sonia.scm.client.it;
import org.junit.Test;
import sonia.scm.client.ClientUtil;
-import sonia.scm.client.JerseyClientProvider;
import sonia.scm.client.JerseyClientSession;
import sonia.scm.client.ScmClientException;
import sonia.scm.client.ScmUrlProvider;
@@ -51,33 +50,41 @@ import static org.junit.Assert.*;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
+import java.io.IOException;
+
/**
*
* @author Sebastian Sdorra
*/
-public class JerseyClientProviderITCase
+public class JerseyClientProviderITCase extends AbstractITCaseBase
{
/**
* Method description
*
*
+ *
+ * @throws IOException
* @throws ScmClientException
*/
@Test(expected = ScmClientException.class)
- public void createSessionAnonymousFailedTest() throws ScmClientException
+ public void createSessionAnonymousFailedTest()
+ throws ScmClientException, IOException
{
- createSession(null, null);
+ createAnonymousSession().close();
}
/**
* Method description
*
*
+ *
+ * @throws IOException
* @throws ScmClientException
*/
@Test
- public void createSessionAnonymousTest() throws ScmClientException
+ public void createSessionAnonymousTest()
+ throws ScmClientException, IOException
{
JerseyClientSession adminSession = createSession("scmadmin", "scmadmin");
@@ -85,78 +92,68 @@ public class JerseyClientProviderITCase
ScmUrlProvider up = adminSession.getUrlProvider();
Client client = adminSession.getClient();
WebResource resource = ClientUtil.createResource(client,
- up.getResourceUrl("config"), true);
+ up.getResourceUrl("config"), REQUEST_LOGGING);
ScmConfiguration config = resource.get(ScmConfiguration.class);
config.setAnonymousAccessEnabled(true);
resource.post(config);
// test anonymous access
- createSession(null, null);
+ createAnonymousSession().close();
// disable anonymous access
config.setAnonymousAccessEnabled(false);
resource.post(config);
+ adminSession.close();
}
/**
* Method description
*
*
+ *
+ * @throws IOException
* @throws ScmClientException
*/
@Test
- public void createSessionTest() throws ScmClientException
+ public void createSessionTest() throws ScmClientException, IOException
{
- JerseyClientSession session = createSession("scmadmin", "scmadmin");
+ JerseyClientSession session = createAdminSession();
assertNotNull(session);
assertNotNull(session.getState());
assertNotNull(session.getState().getUser());
assertEquals(session.getState().getUser().getName(), "scmadmin");
+ session.close();
}
/**
* Method description
*
*
+ *
+ * @throws IOException
* @throws ScmClientException
*/
@Test(expected = ScmClientException.class)
- public void createSessionWithUnkownUserTest() throws ScmClientException
+ public void createSessionWithUnkownUserTest()
+ throws ScmClientException, IOException
{
- createSession("dent", "dent123");
+ createSession("dent", "dent123").close();
}
/**
* Method description
*
*
+ *
+ * @throws IOException
* @throws ScmClientException
*/
@Test(expected = ScmClientException.class)
- public void createSessionWithWrongPasswordTest() throws ScmClientException
+ public void createSessionWithWrongPasswordTest()
+ throws ScmClientException, IOException
{
- createSession("scmadmin", "ka123");
- }
-
- /**
- * Method description
- *
- *
- * @param username
- * @param password
- *
- * @return
- *
- * @throws ScmClientException
- */
- private JerseyClientSession createSession(String username, String password)
- throws ScmClientException
- {
- JerseyClientProvider provider = new JerseyClientProvider(true);
-
- return provider.createSession("http://localhost:8081/scm", username,
- password);
+ createSession("scmadmin", "ka123").close();
}
}
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientRepositoryClientHandlerITCase.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientRepositoryClientHandlerITCase.java
new file mode 100644
index 0000000000..8d8561ac68
--- /dev/null
+++ b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientRepositoryClientHandlerITCase.java
@@ -0,0 +1,130 @@
+/**
+ * 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.client.it;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import org.junit.Test;
+
+import sonia.scm.client.JerseyClientSession;
+import sonia.scm.client.RepositoryClientHandler;
+import sonia.scm.client.ScmClientException;
+import sonia.scm.repository.Repository;
+import sonia.scm.repository.RepositoryTestData;
+
+import static org.junit.Assert.*;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.IOException;
+
+/**
+ *
+ * @author Sebastian Sdorra
+ */
+public class JerseyClientRepositoryClientHandlerITCase
+ extends AbstractITCaseBase
+{
+
+ /**
+ * Method description
+ *
+ *
+ * @throws IOException
+ * @throws ScmClientException
+ */
+ @Test
+ public void testCreate() throws ScmClientException, IOException
+ {
+ JerseyClientSession session = createAdminSession();
+ Repository hog = RepositoryTestData.createHeartOfGold(REPOSITORY_TYPE);
+ RepositoryClientHandler handler = session.getRepositoryHandler();
+
+ handler.create(hog);
+ assertNotNull(hog.getId());
+ assertNotNull(hog.getCreationDate());
+
+ String id = hog.getId();
+ Repository r = handler.get(id);
+
+ assertNotNull(r);
+ assertEquals(hog, r);
+ session.close();
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @throws IOException
+ * @throws ScmClientException
+ */
+ @Test(expected = ScmClientException.class)
+ public void testCreateAnonymous() throws ScmClientException, IOException
+ {
+ JerseyClientSession session = createAnonymousSession();
+ Repository p42 = RepositoryTestData.create42Puzzle(REPOSITORY_TYPE);
+
+ session.getRepositoryHandler().create(p42);
+ session.close();
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @throws IOException
+ * @throws ScmClientException
+ */
+ @Test
+ public void testDelete() throws ScmClientException, IOException
+ {
+ JerseyClientSession session = createAdminSession();
+ Repository hvpt =
+ RepositoryTestData.createHappyVerticalPeopleTransporter(REPOSITORY_TYPE);
+ RepositoryClientHandler handler = session.getRepositoryHandler();
+
+ handler.create(hvpt);
+ assertNotNull(hvpt.getId());
+ assertNotNull(hvpt.getCreationDate());
+
+ String id = hvpt.getId();
+
+ handler.delete(hvpt);
+
+ Repository r = handler.get(id);
+
+ assertNull(r);
+ }
+}
diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml
index 0cc085dea0..ee25be977e 100644
--- a/scm-webapp/pom.xml
+++ b/scm-webapp/pom.xml
@@ -273,6 +273,7 @@
60000
+ /scm
${project.build.javaLevel}
${project.build.javaLevel}
${project.build.sourceEncoding}
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 d774827750..92dbbb8362 100644
--- a/scm-webapp/src/test/java/sonia/scm/it/IntegrationTestUtil.java
+++ b/scm-webapp/src/test/java/sonia/scm/it/IntegrationTestUtil.java
@@ -64,7 +64,7 @@ public class IntegrationTestUtil
/** Field description */
public static final String BASE_URL =
- "http://localhost:8081/scm-webapp/api/rest/";
+ "http://localhost:8081/scm/api/rest/";
/** Field description */
public static final String EXTENSION = ".xml";