diff --git a/patches/api/Build-system-changes.patch b/patches/api/Build-system-changes.patch index 58539e82d1..35b6fa6d1e 100644 --- a/patches/api/Build-system-changes.patch +++ b/patches/api/Build-system-changes.patch @@ -52,8 +52,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 options.tags("apiNote:a:API Note:") @@ -0,0 +0,0 @@ tasks.withType { - } - } + tasks.test { + useJUnitPlatform() } + +// Paper start diff --git a/patches/api/Convert-project-to-Gradle.patch b/patches/api/Convert-project-to-Gradle.patch index 5ee7d1a521..64f13bc073 100644 --- a/patches/api/Convert-project-to-Gradle.patch +++ b/patches/api/Convert-project-to-Gradle.patch @@ -118,6 +118,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } +} ++ ++tasks.test { ++ useJUnitPlatform() ++} diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/api/Test-changes.patch b/patches/api/Test-changes.patch index bef542d982..cfb9a2dd9f 100644 --- a/patches/api/Test-changes.patch +++ b/patches/api/Test-changes.patch @@ -3,7 +3,6 @@ From: Shane Freeder Date: Sun, 17 Mar 2019 23:04:30 +0000 Subject: [PATCH] Test changes -- convert to mockito for mocking of types - Allow use of TYPE_USE annotations - Ignore package-private methods for nullability annotations - Add excludes for classes which don't pass @@ -12,6 +11,23 @@ Subject: [PATCH] Test changes Co-authored-by: Riley Park Co-authored-by: Jake Potrebic +diff --git a/build.gradle.kts b/build.gradle.kts +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -0,0 +0,0 @@ tasks.test { + useJUnitPlatform() + } + ++// Paper start - compile tests with -parameters for better junit parameterized test names ++tasks.compileTestJava { ++ options.compilerArgs.add("-parameters") ++} ++// Paper end ++ + // Paper start + val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) { + badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;") diff --git a/src/test/java/io/papermc/paper/testing/EmptyTag.java b/src/test/java/io/papermc/paper/testing/EmptyTag.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -208,14 +224,43 @@ diff --git a/src/test/java/org/bukkit/BukkitMirrorTest.java b/src/test/java/org/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/BukkitMirrorTest.java +++ b/src/test/java/org/bukkit/BukkitMirrorTest.java -@@ -0,0 +0,0 @@ import org.junit.jupiter.params.provider.MethodSource; - public class BukkitMirrorTest { +@@ -0,0 +0,0 @@ public class BukkitMirrorTest { - public static Stream data() { -+ if (true) return Stream.of(); // Paper - return Stream.of(Server.class.getDeclaredMethods()) - .map(method -> { - try { + @ParameterizedTest + @MethodSource("data") ++ @org.junit.jupiter.api.Disabled // Paper + public void isStatic(Method server, String name, Method bukkit) throws Throwable { + assertThat(Modifier.isStatic(bukkit.getModifiers()), is(true)); + } + + @ParameterizedTest + @MethodSource("data") ++ @org.junit.jupiter.api.Disabled // Paper + public void isDeprecated(Method server, String name, Method bukkit) throws Throwable { + assertThat(bukkit.isAnnotationPresent(Deprecated.class), is(server.isAnnotationPresent(Deprecated.class))); + } + + @ParameterizedTest + @MethodSource("data") ++ @org.junit.jupiter.api.Disabled // Paper + public void returnType(Method server, String name, Method bukkit) throws Throwable { + assertThat(bukkit.getReturnType(), is((Object) server.getReturnType())); + // assertThat(bukkit.getGenericReturnType(), is(server.getGenericReturnType())); // too strict on type generics +@@ -0,0 +0,0 @@ public class BukkitMirrorTest { + + @ParameterizedTest + @MethodSource("data") ++ @org.junit.jupiter.api.Disabled // Paper + public void parameterTypes(Method server, String name, Method bukkit) throws Throwable { + // assertThat(bukkit.getGenericParameterTypes(), is(server.getGenericParameterTypes())); // too strict on type generics + } + + @ParameterizedTest + @MethodSource("data") ++ @org.junit.jupiter.api.Disabled // Paper + public void declaredException(Method server, String name, Method bukkit) throws Throwable { + assertThat(bukkit.getGenericExceptionTypes(), is(server.getGenericExceptionTypes())); + } diff --git a/src/test/java/org/bukkit/support/TestServer.java b/src/test/java/org/bukkit/support/TestServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/support/TestServer.java diff --git a/patches/server/Add-PlayerArmorChangeEvent.patch b/patches/server/Add-PlayerArmorChangeEvent.patch index 22f3a9c6c7..d70a0bdb25 100644 --- a/patches/server/Add-PlayerArmorChangeEvent.patch +++ b/patches/server/Add-PlayerArmorChangeEvent.patch @@ -29,11 +29,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -diff --git a/src/test/java/io/papermc/paper/inventory/item/ExtraArmorSlotTypeMaterialTest.java b/src/test/java/io/papermc/paper/inventory/item/ExtraArmorSlotTypeMaterialTest.java +diff --git a/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java b/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 --- /dev/null -+++ b/src/test/java/io/papermc/paper/inventory/item/ExtraArmorSlotTypeMaterialTest.java ++++ b/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java @@ -0,0 +0,0 @@ +package io.papermc.paper.inventory.item; + @@ -53,11 +53,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; ++import static org.junit.jupiter.api.Assertions.assertTrue; + -+public class ExtraArmorSlotTypeMaterialTest extends AbstractTestingBase { ++public class ArmorSlotTypeMaterialTest extends AbstractTestingBase { + -+ @MethodSource("parameters") -+ public static Stream parameters() { ++ public static Stream slotTypeParams() { + final List parameters = new ArrayList<>(); + for (final PlayerArmorChangeEvent.SlotType slotType : PlayerArmorChangeEvent.SlotType.values()) { + for (final Material item : slotType.getTypes()) { @@ -67,9 +67,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return parameters.stream(); + } + -+ @ParameterizedTest -+ @MethodSource("parameters") -+ public void test(PlayerArmorChangeEvent.SlotType slotType, Material item) { ++ @ParameterizedTest(name = "{argumentsWithNames}") ++ @MethodSource("slotTypeParams") ++ public void testSlotType(PlayerArmorChangeEvent.SlotType slotType, Material item) { + final Item nmsItem = CraftMagicNumbers.getItem(item); + final Equipable equipable = Equipable.get(new ItemStack(nmsItem)); + assertNotNull(equipable, item + " isn't equipable"); @@ -81,40 +81,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + }; + assertEquals(equipable.getEquipmentSlot(), slot, item + " isn't set to the right slot"); + } -+} -diff --git a/src/test/java/io/papermc/paper/inventory/item/MissingArmorSlotTypeMaterialTest.java b/src/test/java/io/papermc/paper/inventory/item/MissingArmorSlotTypeMaterialTest.java -new file mode 100644 -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 ---- /dev/null -+++ b/src/test/java/io/papermc/paper/inventory/item/MissingArmorSlotTypeMaterialTest.java -@@ -0,0 +0,0 @@ -+package io.papermc.paper.inventory.item; + -+import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; -+import java.util.ArrayList; -+import java.util.List; -+import java.util.stream.Stream; -+import net.minecraft.core.registries.BuiltInRegistries; -+import net.minecraft.world.entity.EquipmentSlot; -+import net.minecraft.world.item.Equipable; -+import net.minecraft.world.item.Item; -+import net.minecraft.world.item.ItemStack; -+import org.bukkit.craftbukkit.util.CraftMagicNumbers; -+import org.bukkit.support.AbstractTestingBase; -+import org.junit.jupiter.params.ParameterizedTest; -+import org.junit.jupiter.params.provider.MethodSource; -+ -+import static org.junit.jupiter.api.Assertions.assertTrue; -+ -+/** -+ * Test for {@link com.destroystokyo.paper.event.player.PlayerArmorChangeEvent.SlotType} -+ */ -+public class MissingArmorSlotTypeMaterialTest extends AbstractTestingBase { -+ -+ @MethodSource("parameters") -+ public static Stream parameters() { ++ public static Stream equipableParams() { + final List parameters = new ArrayList<>(); -+ for (final Item item : BuiltInRegistries.ITEM) { ++ for (final Item item : net.minecraft.core.registries.BuiltInRegistries.ITEM) { + final Equipable equipable = Equipable.get(new ItemStack(item)); + if (equipable != null) { + parameters.add(new Object[]{equipable, item}); @@ -123,9 +93,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return parameters.stream(); + } + -+ @ParameterizedTest -+ @MethodSource("parameters") -+ public void test(Equipable equipable, Item item) { ++ @ParameterizedTest(name = "{argumentsWithNames}") ++ @MethodSource("equipableParams") ++ public void testEquipable(Equipable equipable, Item item) { + final EquipmentSlot equipmentSlot = equipable.getEquipmentSlot(); + PlayerArmorChangeEvent.SlotType slotType = switch (equipmentSlot) { + case HEAD -> PlayerArmorChangeEvent.SlotType.HEAD; diff --git a/patches/server/Add-StructuresLocateEvent.patch b/patches/server/Add-StructuresLocateEvent.patch index d379cbfb76..6276eee8ee 100644 --- a/patches/server/Add-StructuresLocateEvent.patch +++ b/patches/server/Add-StructuresLocateEvent.patch @@ -193,3 +193,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + System.setOut(out); + } +} +diff --git a/src/test/java/org/bukkit/PerRegistryTest.java b/src/test/java/org/bukkit/PerRegistryTest.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/org/bukkit/PerRegistryTest.java ++++ b/src/test/java/org/bukkit/PerRegistryTest.java +@@ -0,0 +0,0 @@ public class PerRegistryTest extends AbstractTestingBase { + if (!(object instanceof CraftRegistry registry)) { + continue; + } ++ if (object instanceof io.papermc.paper.world.structure.PaperConfiguredStructure.LegacyRegistry) continue; // Paper - skip + + data.add(Arguments.of(registry)); + } catch (ReflectiveOperationException e) { diff --git a/patches/server/Add-methods-to-get-translation-keys.patch b/patches/server/Add-methods-to-get-translation-keys.patch index 38fb028ab0..b8a901faf7 100644 --- a/patches/server/Add-methods-to-get-translation-keys.patch +++ b/patches/server/Add-methods-to-get-translation-keys.patch @@ -74,35 +74,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Test public void testChatVisibilityKeys() { @@ -0,0 +0,0 @@ public class TranslationKeyTest { - Assertions.assertEquals(chatVisibility + "'s translation key doesn't match", ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey()); + Assertions.assertEquals(ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey(), chatVisibility + "'s translation key doesn't match"); } } + + @Test + public void testDifficultyKeys() { + for (Difficulty bukkitDifficulty : Difficulty.values()) { -+ Assertions.assertEquals(bukkitDifficulty + "'s translation key doesn't match", ((TranslatableContents) net.minecraft.world.Difficulty.byId(bukkitDifficulty.ordinal()).getDisplayName().getContents()).getKey(), bukkitDifficulty.translationKey()); ++ Assertions.assertEquals(((TranslatableContents) net.minecraft.world.Difficulty.byId(bukkitDifficulty.ordinal()).getDisplayName().getContents()).getKey(), bukkitDifficulty.translationKey(), bukkitDifficulty + "'s translation key doesn't match"); + } + } + + @Test + public void testGameruleKeys() { + for (GameRule rule : GameRule.values()) { -+ Assertions.assertEquals(rule.getName() + "'s translation doesn't match", org.bukkit.craftbukkit.CraftWorld.getGameRulesNMS().get(rule.getName()).getDescriptionId(), rule.translationKey()); ++ Assertions.assertEquals(org.bukkit.craftbukkit.CraftWorld.getGameRulesNMS().get(rule.getName()).getDescriptionId(), rule.translationKey(), rule.getName() + "'s translation doesn't match"); + } + } + + @Test + public void testAttributeKeys() { + for (Attribute attribute : Attribute.values()) { -+ Assertions.assertEquals("translation key mismatch for " + attribute, org.bukkit.craftbukkit.attribute.CraftAttribute.bukkitToMinecraft(attribute).getDescriptionId(), attribute.translationKey()); ++ Assertions.assertEquals(org.bukkit.craftbukkit.attribute.CraftAttribute.bukkitToMinecraft(attribute).getDescriptionId(), attribute.translationKey(), "translation key mismatch for " + attribute); + } + } + + @Test + public void testFireworkEffectType() { + for (FireworkEffect.Type type : FireworkEffect.Type.values()) { -+ Assertions.assertEquals("translation key mismatch for " + type, net.minecraft.world.item.FireworkRocketItem.Shape.byId(org.bukkit.craftbukkit.inventory.CraftMetaFirework.getNBT(type)).getName(), org.bukkit.FireworkEffect.Type.NAMES.key(type)); ++ Assertions.assertEquals(net.minecraft.world.item.FireworkRocketItem.Shape.byId(org.bukkit.craftbukkit.inventory.CraftMetaFirework.getNBT(type)).getName(), org.bukkit.FireworkEffect.Type.NAMES.key(type), "translation key mismatch for " + type); + } + } + @@ -120,7 +120,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for (GameType nms : GameType.values()) { + GameMode bukkit = GameMode.getByValue(nms.getId()); + Assertions.assertNotNull(bukkit); -+ Assertions.assertEquals("translation key mismatch for " + bukkit, ((TranslatableContents) nms.getLongDisplayName().getContents()).getKey(), bukkit.translationKey()); ++ Assertions.assertEquals(((TranslatableContents) nms.getLongDisplayName().getContents()).getKey(), bukkit.translationKey(), "translation key mismatch for " + bukkit); + } + } + @@ -128,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void testBiome() { + for (Map.Entry, Biome> nms : AbstractTestingBase.BIOMES.entrySet()) { + org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().location().getPath().toUpperCase()); -+ Assertions.assertEquals("translation key mismatch for " + bukkit, nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey()); ++ Assertions.assertEquals(nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey(), "translation key mismatch for " + bukkit); + } + } + @@ -137,7 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for (final ResourceLocation nms : BuiltInRegistries.INSTRUMENT.keySet()) { + final MusicInstrument bukkit = MusicInstrument.getByKey(CraftNamespacedKey.fromMinecraft(nms)); + Assertions.assertNotNull(bukkit, "Missing bukkit instrument for " + nms); -+ Assertions.assertEquals("translation key mismatch for " + bukkit, nms.toLanguageKey("instrument"), bukkit.translationKey()); ++ Assertions.assertEquals(nms.toLanguageKey("instrument"), bukkit.translationKey(), "translation key mismatch for " + bukkit); + } + } } diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch index 141f76dbf1..cf61aa93a8 100644 --- a/patches/server/Build-system-changes.patch +++ b/patches/server/Build-system-changes.patch @@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + tasks.test { exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") - } + useJUnitPlatform() @@ -0,0 +0,0 @@ tasks.registerRunTask("runReobf") { classpath(runtimeClasspathWithoutVanillaServer) } diff --git a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 77069f5f66..cd4b00b3c3 100644 --- a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + tasks.test { exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") - } + useJUnitPlatform() diff --git a/src/log4jPlugins/java/io/papermc/paper/logging/StacktraceDeobfuscatingRewritePolicy.java b/src/log4jPlugins/java/io/papermc/paper/logging/StacktraceDeobfuscatingRewritePolicy.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server/Fix-silent-equipment-change-for-mobs.patch b/patches/server/Fix-silent-equipment-change-for-mobs.patch index 835510c9af..87c0c6f145 100644 --- a/patches/server/Fix-silent-equipment-change-for-mobs.patch +++ b/patches/server/Fix-silent-equipment-change-for-mobs.patch @@ -87,7 +87,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +public class EntitySetItemSlotSilentOverrideTest extends AbstractTestingBase { + -+ @MethodSource("parameters") + public static Stream parameters() { + final List classInfo = new ArrayList<>(); + try (ScanResult scanResult = new ClassGraph() diff --git a/patches/server/Implement-Player-Client-Options-API.patch b/patches/server/Implement-Player-Client-Options-API.patch index cd06414464..cf003f653f 100644 --- a/patches/server/Implement-Player-Client-Options-API.patch +++ b/patches/server/Implement-Player-Client-Options-API.patch @@ -167,7 +167,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void testChatVisibilityKeys() { + for (ClientOption.ChatVisibility chatVisibility : ClientOption.ChatVisibility.values()) { + if (chatVisibility == ClientOption.ChatVisibility.UNKNOWN) continue; -+ Assertions.assertEquals(chatVisibility + "'s translation key doesn't match", ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey()); ++ Assertions.assertEquals(ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey(), chatVisibility + "'s translation key doesn't match"); + } + } +} diff --git a/patches/server/Implement-ensureServerConversions-API.patch b/patches/server/Implement-ensureServerConversions-API.patch index 029161eabf..10af69a257 100644 --- a/patches/server/Implement-ensureServerConversions-API.patch +++ b/patches/server/Implement-ensureServerConversions-API.patch @@ -6,6 +6,19 @@ Subject: [PATCH] Implement ensureServerConversions API This will take a Bukkit ItemStack and run it through any conversions a server process would perform on it, to ensure it meets latest minecraft expectations. +diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -0,0 +0,0 @@ public final class ItemStack { + + // Called to run this stack through the data converter to handle older storage methods and serialized items + public void convertStack(int version) { +- if (0 < version && version < CraftMagicNumbers.INSTANCE.getDataVersion()) { ++ if (0 < version && version < CraftMagicNumbers.INSTANCE.getDataVersion() && MinecraftServer.getServer() != null) { // Paper - skip conversion if the server doesn't exist (for tests) + CompoundTag savedStack = new CompoundTag(); + this.save(savedStack); + savedStack = (CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ITEM_STACK, new Dynamic(NbtOps.INSTANCE, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue(); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index 43f152434b..9a8891abd2 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -7896,7 +7896,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/test/java/io/papermc/paper/testing/DummyServer.java +++ b/src/test/java/io/papermc/paper/testing/DummyServer.java @@ -0,0 +0,0 @@ public final class DummyServer { - return new LazyRegistry(() -> CraftRegistry.createRegistry(invocation.getArgument(0, Class.class), AbstractTestingBase.REGISTRY_CUSTOM)); + return CraftRegistry.createRegistry(invocation.getArgument(0), org.bukkit.support.AbstractTestingBase.REGISTRY_CUSTOM); }); - final PluginManager pluginManager = new SimplePluginManager(dummyServer, new SimpleCommandMap(dummyServer)); diff --git a/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch b/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch index 1effedf53a..d3bc19e749 100644 --- a/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch +++ b/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch @@ -131,7 +131,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +public class BlockPlayerDestroyOverrideTest extends AbstractTestingBase { + -+ @MethodSource("parameters") + public static Stream parameters() { + final List classInfo = new ArrayList<>(); + try (ScanResult scanResult = new ClassGraph() @@ -157,6 +156,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + assertEquals(1, playerDestroy.size(), overridesPlayerDestroy.getName() + " has multiple playerDestroy methods"); + final MethodInfo next = playerDestroy.iterator().next(); + final MethodParameterInfo[] parameterInfo = next.getParameterInfo(); -+ assertEquals(overridesPlayerDestroy.getName() + " needs to change its override of playerDestroy", "boolean", parameterInfo[parameterInfo.length - 1].getTypeDescriptor().toStringWithSimpleNames()); ++ assertEquals("boolean", parameterInfo[parameterInfo.length - 1].getTypeDescriptor().toStringWithSimpleNames(), overridesPlayerDestroy.getName() + " needs to change its override of playerDestroy"); + } +} diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch index 0330582c8d..f1e95b0143 100644 --- a/patches/server/Setup-Gradle-project.patch +++ b/patches/server/Setup-Gradle-project.patch @@ -111,6 +111,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +tasks.test { + exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") ++ useJUnitPlatform() +} + +fun TaskContainer.registerRunTask( diff --git a/patches/server/Test-changes.patch b/patches/server/Test-changes.patch index 94fa7ba1bd..c2c65998b0 100644 --- a/patches/server/Test-changes.patch +++ b/patches/server/Test-changes.patch @@ -16,6 +16,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 implementation("commons-lang:commons-lang:2.6") runtimeOnly("org.xerial:sqlite-jdbc:3.43.0.0") runtimeOnly("com.mysql:mysql-connector-j:8.1.0") +@@ -0,0 +0,0 @@ tasks.compileJava { + options.setIncremental(false) + } + ++// Paper start - compile tests with -parameters for better junit parameterized test names ++tasks.compileTestJava { ++ options.compilerArgs.add("-parameters") ++} ++// Paper end ++ + publishing { + publications.create("maven") { + artifact(tasks.shadowJar) diff --git a/src/test/java/io/papermc/paper/testing/DummyServer.java b/src/test/java/io/papermc/paper/testing/DummyServer.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -78,8 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + }); + + when(dummyServer.getRegistry(any())).thenAnswer(invocation -> { -+ // LazyRegistry because the vanilla data hasn't been bootstrapped yet. -+ return new LazyRegistry(() -> CraftRegistry.createRegistry(invocation.getArgument(0, Class.class), AbstractTestingBase.REGISTRY_CUSTOM)); ++ return CraftRegistry.createRegistry(invocation.getArgument(0), org.bukkit.support.AbstractTestingBase.REGISTRY_CUSTOM); + }); + + final PluginManager pluginManager = new SimplePluginManager(dummyServer, new SimpleCommandMap(dummyServer)); @@ -89,42 +101,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + } +} -diff --git a/src/test/java/io/papermc/paper/testing/LazyRegistry.java b/src/test/java/io/papermc/paper/testing/LazyRegistry.java -new file mode 100644 -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 ---- /dev/null -+++ b/src/test/java/io/papermc/paper/testing/LazyRegistry.java -@@ -0,0 +0,0 @@ -+package io.papermc.paper.testing; -+ -+import java.util.Iterator; -+import java.util.function.Supplier; -+import java.util.stream.Stream; -+import java.util.stream.StreamSupport; -+import org.bukkit.Keyed; -+import org.bukkit.NamespacedKey; -+import org.bukkit.Registry; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+public record LazyRegistry(Supplier> supplier) implements Registry { -+ -+ @NotNull -+ @Override -+ public Iterator iterator() { -+ return this.supplier().get().iterator(); -+ } -+ -+ @Override -+ public @Nullable Keyed get(@NotNull final NamespacedKey key) { -+ return this.supplier().get().get(key); -+ } -+ -+ @Override -+ public @NotNull Stream stream() { -+ return StreamSupport.stream(this.supplier.get().spliterator(), false); -+ } -+} diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java