Skip to content

Commit

Permalink
Add deletion check to test
Browse files Browse the repository at this point in the history
* adds test if deleted files really don't exist anymore afterwards
* adds boolean isDeleted(String path) function to Deleter interface
* other Uploaders must implement this method, otherwise
NotImplementedException is thrown when running this test
  • Loading branch information
frauzufall committed Feb 8, 2019
1 parent 7ccc8e3 commit ee32efc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -141,5 +141,11 @@ Institute of Molecular Cell Biology and Genetics.</license.copyrightOwners>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
30 changes: 16 additions & 14 deletions src/test/java/net/imagej/updater/AbstractUploaderTestBase.java
Expand Up @@ -31,24 +31,21 @@

package net.imagej.updater;

import static net.imagej.updater.UpdaterTestUtils.cleanup;
import static net.imagej.updater.UpdaterTestUtils.initialize;
import static net.imagej.updater.UpdaterTestUtils.writeFile;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import net.imagej.updater.util.StderrProgress;
import net.imagej.updater.util.UpdaterUtil;
import org.apache.commons.lang.NotImplementedException;
import org.junit.After;

import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import net.imagej.updater.FilesCollection;
import net.imagej.updater.util.StderrProgress;
import net.imagej.updater.util.UpdaterUtil;

import org.junit.After;
import static net.imagej.updater.UpdaterTestUtils.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;

/**
* An abstract base class for testing uploader backends.
Expand Down Expand Up @@ -87,6 +84,8 @@ public void test(final Deleter deleter, final String host, final String uploadDi
assertTrue(deleter.login());
deleter.delete(UpdaterUtil.XML_COMPRESSED);
deleter.delete("plugins/");
assertTrue(deleter.isDeleted(UpdaterUtil.XML_COMPRESSED));
assertTrue(deleter.isDeleted("plugins/"));
deleter.logout();
}

Expand Down Expand Up @@ -144,8 +143,11 @@ public boolean isUpdateSiteEmpty() throws MalformedURLException, IOException {
}

public interface Deleter {
public abstract boolean login();
public abstract void delete(final String path) throws IOException;
public abstract void logout();
boolean login();
void delete(final String path) throws IOException;
void logout();
default boolean isDeleted(String path) throws IOException {
throw new NotImplementedException();
}
}
}

0 comments on commit ee32efc

Please sign in to comment.