mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
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.
This commit is contained in:
parent
ea39ca187b
commit
f481c9ee07
1 changed files with 6 additions and 4 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue