From f481c9ee07220e30a3c016ba06782807be7a9200 Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Wed, 14 Aug 2013 02:31:18 -0500 Subject: 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. --- .../java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/test') 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 names = new HashSet(); - 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)); } } -- cgit v1.2.3