mirror of https://github.com/apache/jclouds.git
Merge pull request #869 from andrewgaul/filesystem-image-resource
Use Iterator for IMAGE_RESOUCE
This commit is contained in:
commit
418097d4e6
|
@ -23,10 +23,14 @@ import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Iterators;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,20 +41,17 @@ import org.apache.commons.io.FileUtils;
|
||||||
public class TestUtils {
|
public class TestUtils {
|
||||||
|
|
||||||
private static final String TARGET_RESOURCE_DIR = "." + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator;
|
private static final String TARGET_RESOURCE_DIR = "." + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator;
|
||||||
|
|
||||||
/** All the files available for the tests */
|
/** All the files available for the tests */
|
||||||
private static String[] imageResource = new String[]{
|
private static final Iterator<File> IMAGE_RESOURCES =
|
||||||
TARGET_RESOURCE_DIR + "image1.jpg",
|
Iterators.cycle(ImmutableList.of(
|
||||||
TARGET_RESOURCE_DIR + "image2.jpg",
|
new File(TARGET_RESOURCE_DIR + "image1.jpg"),
|
||||||
TARGET_RESOURCE_DIR + "image3.jpg",
|
new File(TARGET_RESOURCE_DIR + "image2.jpg"),
|
||||||
TARGET_RESOURCE_DIR + "image4.jpg"
|
new File(TARGET_RESOURCE_DIR + "image3.jpg"),
|
||||||
};
|
new File(TARGET_RESOURCE_DIR + "image4.jpg")));
|
||||||
private static int imageResourceIndex = 0;
|
|
||||||
|
|
||||||
public static final String TARGET_BASE_DIR = "." + File.separator + "target" + File.separator + "basedir" + File.separator;
|
public static final String TARGET_BASE_DIR = "." + File.separator + "target" + File.separator + "basedir" + File.separator;
|
||||||
|
|
||||||
public static final Object[][] NO_INVOCATIONS = new Object[0][0];
|
|
||||||
public static final Object[][] SINGLE_NO_ARG_INVOCATION = new Object[][] { new Object[0] };
|
|
||||||
|
|
||||||
public static boolean isWindowsOs() {
|
public static boolean isWindowsOs() {
|
||||||
return System.getProperty("os.name", "").toLowerCase().contains("windows");
|
return System.getProperty("os.name", "").toLowerCase().contains("windows");
|
||||||
}
|
}
|
||||||
|
@ -194,8 +195,6 @@ public class TestUtils {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static File getImageForBlobPayload() {
|
public static File getImageForBlobPayload() {
|
||||||
String fileName = imageResource[imageResourceIndex++];
|
return IMAGE_RESOURCES.next();
|
||||||
if (imageResourceIndex >= imageResource.length) imageResourceIndex = 0;
|
|
||||||
return new File(fileName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue