summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2013-08-14 02:31:18 -0500
committerWesley Wolfe <weswolf@aol.com>2013-08-14 02:37:24 -0500
commitf481c9ee07220e30a3c016ba06782807be7a9200 (patch)
tree546c9de81e16384b3995987bba7afe31fc47c516 /src/test/java/org
parentea39ca187bb369f5e2872d9ba8c670449d901c58 (diff)
downloadcraftbukkit-f481c9ee07220e30a3c016ba06782807be7a9200.tar
craftbukkit-f481c9ee07220e30a3c016ba06782807be7a9200.tar.gz
craftbukkit-f481c9ee07220e30a3c016ba06782807be7a9200.tar.lz
craftbukkit-f481c9ee07220e30a3c016ba06782807be7a9200.tar.xz
craftbukkit-f481c9ee07220e30a3c016ba06782807be7a9200.zip
Make ItemFactoryTest.java platform agnostic. Fixes BUKKIT-4695
Maven paths that include spaces (and possible other characters) get improperly translated when using a file handle from a URL. This changes the unit test to open a stream directly from the URL, providing proper file resolution on multiple platforms.
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java
index 6e3690e2..610293f1 100644
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java
+++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java
@@ -6,13 +6,13 @@ import static org.hamcrest.Matchers.*;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
import net.minecraft.server.CommandAbstract;
import net.minecraft.server.IAttribute;
+
import org.bukkit.support.AbstractTestingBase;
import org.junit.Test;
@@ -20,9 +20,9 @@ public class ItemFactoryTest extends AbstractTestingBase {
@Test
public void testKnownAttributes() throws Throwable {
- final ZipFile nmsZipFile = new ZipFile(CommandAbstract.class /* Magic class that isn't imported! */.getProtectionDomain().getCodeSource().getLocation().getFile());
+ final ZipInputStream nmsZipStream = new ZipInputStream(CommandAbstract.class/* Magic class that isn't imported! */.getProtectionDomain().getCodeSource().getLocation().openStream());
final Collection<String> names = new HashSet<String>();
- for (final ZipEntry clazzEntry : Collections.list(nmsZipFile.entries())) {
+ for (ZipEntry clazzEntry; (clazzEntry = nmsZipStream.getNextEntry()) != null; ) {
final String entryName = clazzEntry.getName();
if (!(entryName.endsWith(".class") && entryName.startsWith("net/minecraft/server/"))) {
continue;
@@ -40,6 +40,8 @@ public class ItemFactoryTest extends AbstractTestingBase {
}
}
+ nmsZipStream.close();
+
assertThat("Extra values detected", CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES, is(names));
}
}