Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +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.
Dieser Commit ist enthalten in:
Ursprung
ea39ca187b
Commit
f481c9ee07
@ -6,13 +6,13 @@ import static org.hamcrest.Matchers.*;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import net.minecraft.server.CommandAbstract;
|
import net.minecraft.server.CommandAbstract;
|
||||||
import net.minecraft.server.IAttribute;
|
import net.minecraft.server.IAttribute;
|
||||||
|
|
||||||
import org.bukkit.support.AbstractTestingBase;
|
import org.bukkit.support.AbstractTestingBase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -20,9 +20,9 @@ public class ItemFactoryTest extends AbstractTestingBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKnownAttributes() throws Throwable {
|
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>();
|
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();
|
final String entryName = clazzEntry.getName();
|
||||||
if (!(entryName.endsWith(".class") && entryName.startsWith("net/minecraft/server/"))) {
|
if (!(entryName.endsWith(".class") && entryName.startsWith("net/minecraft/server/"))) {
|
||||||
continue;
|
continue;
|
||||||
@ -40,6 +40,8 @@ public class ItemFactoryTest extends AbstractTestingBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nmsZipStream.close();
|
||||||
|
|
||||||
assertThat("Extra values detected", CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES, is(names));
|
assertThat("Extra values detected", CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES, is(names));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren