From 1f1ecb6f9b167788fd08e5376205d29fde84c7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Mon, 6 Aug 2018 11:27:56 +0200 Subject: [PATCH] Delete cache integration tests --- .../sonia/scm/it/HttpCacheITCaseBase.java | 244 ------------------ .../scm/it/RepositoryExtendedITCase.java | 183 ------------- 2 files changed, 427 deletions(-) delete mode 100644 scm-webapp/src/test/java/sonia/scm/it/HttpCacheITCaseBase.java delete mode 100644 scm-webapp/src/test/java/sonia/scm/it/RepositoryExtendedITCase.java diff --git a/scm-webapp/src/test/java/sonia/scm/it/HttpCacheITCaseBase.java b/scm-webapp/src/test/java/sonia/scm/it/HttpCacheITCaseBase.java deleted file mode 100644 index c2b43465c3..0000000000 --- a/scm-webapp/src/test/java/sonia/scm/it/HttpCacheITCaseBase.java +++ /dev/null @@ -1,244 +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 com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import org.junit.After; -import org.junit.Test; - -import javax.ws.rs.core.EntityTag; -import java.util.Date; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static sonia.scm.it.IntegrationTestUtil.createAdminClient; -import static sonia.scm.it.IntegrationTestUtil.createResource; - -//~--- JDK imports ------------------------------------------------------------ - -/** - * - * @author Sebastian Sdorra - * - * @param - */ -public abstract class HttpCacheITCaseBase -{ - - /** - * Method description - * - * - * @return - */ - protected abstract T createSampleItem(); - - /** - * Method description - * - * - * @param item - */ - protected abstract void destroy(T item); - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - protected abstract String getCollectionUrlPart(); - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - */ - @Test - public void changingCollectionETagTest() - { - ClientResponse response = getCollectionResponse(); - String etag = getETag(response); - - item = createSampleItem(); - response = getCollectionResponse(); - - String otherEtag = getETag(response); - - assertThat(etag, not(equalTo(otherEtag))); - } - - /** - * Method description - * - * - * @throws InterruptedException - */ - @Test - public void changingCollectionLastModifiedTest() throws InterruptedException - { - ClientResponse response = getCollectionResponse(); - long lastModified = getLastModified(response); - - // wait 1 second because http date is not millisecond precision - Thread.sleep(1000l); - item = createSampleItem(); - response = getCollectionResponse(); - - long otherLastModified = getLastModified(response); - - assertNotEquals(lastModified, otherLastModified); - } - - /** - * Method description - * - */ - @After - public void cleanup() - { - if (item != null) - { - destroy(item); - } - } - - /** - * Method description - * - */ - @Test - public void simpleCollectionETagTest() - { - ClientResponse response = getCollectionResponse(); - String etag = getETag(response); - - response = getCollectionResponse(); - - String otherEtag = getETag(response); - - assertEquals(etag, otherEtag); - } - - /** - * Method description - * - */ - @Test - public void simpleCollectionLastModifiedTest() - { - ClientResponse response = getCollectionResponse(); - long lastModified = getLastModified(response); - - response = getCollectionResponse(); - - long otherLastModified = getLastModified(response); - - assertEquals(lastModified, otherLastModified); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - private ClientResponse getCollectionResponse() - { - ScmClient client = createAdminClient(); - WebResource.Builder resource = createResource(client, getCollectionUrlPart()); - ClientResponse response = resource.get(ClientResponse.class); - - assertEquals(200, response.getStatus()); - - return response; - } - - /** - * Method description - * - * - * @param response - * - * @return - */ - private String getETag(ClientResponse response) - { - EntityTag e = response.getEntityTag(); - - assertNotNull(e); - - String value = e.getValue(); - - assertNotNull(value); - assertTrue(value.length() > 0); - - return value; - } - - /** - * Method description - * - * - * @param response - * - * @return - */ - private long getLastModified(ClientResponse response) - { - Date lastModified = response.getLastModified(); - - assertNotNull(lastModified); - - return lastModified.getTime(); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private T item; -} diff --git a/scm-webapp/src/test/java/sonia/scm/it/RepositoryExtendedITCase.java b/scm-webapp/src/test/java/sonia/scm/it/RepositoryExtendedITCase.java deleted file mode 100644 index 7ddaf8d7b1..0000000000 --- a/scm-webapp/src/test/java/sonia/scm/it/RepositoryExtendedITCase.java +++ /dev/null @@ -1,183 +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.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import sonia.scm.api.v2.resources.RepositoryDto; -import sonia.scm.repository.client.api.RepositoryClient; -import sonia.scm.repository.client.api.RepositoryClientException; -import sonia.scm.user.User; -import sonia.scm.util.IOUtil; - -import java.io.File; -import java.io.IOException; - -import static org.junit.Assert.fail; -import static sonia.scm.it.IntegrationTestUtil.createTempDirectory; - -//~--- JDK imports ------------------------------------------------------------ - -/** - * - * @author Sebastian Sdorra - */ -@RunWith(Parameterized.class) -@Ignore("permissions not yet implemented -- see RepositoryITCaseBase#createTestRepository") -public class RepositoryExtendedITCase extends RepositoryITCaseBase -{ - - /** - * Constructs ... - * - * - * @param repository - * @param owner - * @param write - * @param read - * @param noperm - * @param password - */ - public RepositoryExtendedITCase(RepositoryDto repository, User owner, - User write, User read, User noperm, - String password, String ignore_testCaseName) - { - super(repository, owner, write, read, noperm, password); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @throws IOException - */ - @After - public void cleanupTest() throws IOException - { - IOUtil.delete(directory); - } - - /** - * Method description - * - * - * @throws IOException - */ - @Test(expected = RepositoryClientException.class) - public void readFailed() throws IOException - { - RepositoryClient rc = createRepositoryClient(nopermUser, directory); - - // rc.checkout(); - - // ugly workaround - if (repository.getType().equals("git")) - { - for (File f : directory.listFiles()) - { - if (!".git".equals(f.getName())) - { - fail("checkout works"); - } - } - - throw new IOException("checkout failed"); - } - } - - /** - * Method description - * - */ - @Before - public void setupTest() - { - directory = createTempDirectory(); - } - - /** - * Method description - * - * - * @throws IOException - */ - @Test - public void simpleRead() throws IOException - { - RepositoryClient rc = createRepositoryClient(readUser, directory); - - // rc.checkout(); - } - - /** - * Method description - * - * @throws IOException - */ - @Test - public void simpleWrite() throws IOException - { - RepositoryClient rc = createRepositoryClient(writeUser, directory); - - // rc.checkout(); - addTestFiles(rc); - } - - /** - * Method description - * - * @throws IOException - */ - @Test(expected = IOException.class) - public void writeFailed() throws IOException - { - RepositoryClient rc = createRepositoryClient(readUser, directory); - - // rc.checkout(); - addTestFiles(rc); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private File directory; -}