mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 05:11:34 +02:00
Add failing test for #3705
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package uk.ac.ic.wlgitbridge.util;
|
||||
|
||||
/**
|
||||
* BiConsumer interface that allows checked exceptions.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface BiConsumerT<T, U, E extends Throwable> {
|
||||
|
||||
void accept(T t, U u) throws E;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package uk.ac.ic.wlgitbridge.util;
|
||||
|
||||
/**
|
||||
* Function interface that allows checked exceptions.
|
||||
* @param <T>
|
||||
* @param <R>
|
||||
* @param <E>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface FunctionT<T, R, E extends Throwable> {
|
||||
|
||||
R apply(T t) throws E;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package uk.ac.ic.wlgitbridge.util;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ResourceUtil {
|
||||
|
||||
/**
|
||||
* Creates a copy of a resource folder. Mainly used for testing to prevent
|
||||
* the original folder from being mangled.
|
||||
*
|
||||
* It will have the same name as the original.
|
||||
* @param resource the resource name, e.g. "/uk/ac/ic/wlgitbridge/file.txt"
|
||||
* @param folderProvider function used to create the folder.
|
||||
* E.g. TemporaryFolder from junit
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static File copyOfFolderResource(
|
||||
String resource,
|
||||
FunctionT<String, File, IOException> folderProvider
|
||||
) throws IOException {
|
||||
File original
|
||||
= new File(ResourceUtil.class.getResource(resource).getFile());
|
||||
File tmp = folderProvider.apply(original.getName());
|
||||
FileUtils.copyDirectory(original, tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user