geforkt von Mirrors/Paper
Fix tests that broke during the junit 5 update (#9757)
Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Dieser Commit ist enthalten in:
Ursprung
3ebe415f47
Commit
9c0b169922
@ -52,8 +52,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
options.tags("apiNote:a:API Note:")
|
||||
|
||||
@@ -0,0 +0,0 @@ tasks.withType<Javadoc> {
|
||||
}
|
||||
}
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
+
|
||||
+// Paper start
|
||||
|
@ -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
|
||||
|
@ -3,7 +3,6 @@ From: Shane Freeder <theboyetronic@gmail.com>
|
||||
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 <rileysebastianpark@gmail.com>
|
||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
|
||||
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<Arguments> 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 <T> 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 <T> 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
|
||||
|
@ -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<Object[]> parameters() {
|
||||
+ public static Stream<Object[]> slotTypeParams() {
|
||||
+ final List<Object[]> 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<Object[]> parameters() {
|
||||
+ public static Stream<Object[]> equipableParams() {
|
||||
+ final List<Object[]> 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;
|
||||
|
@ -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) {
|
||||
|
@ -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<ResourceKey<Biome>, 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);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -87,7 +87,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+public class EntitySetItemSlotSilentOverrideTest extends AbstractTestingBase {
|
||||
+
|
||||
+ @MethodSource("parameters")
|
||||
+ public static Stream<ClassInfo> parameters() {
|
||||
+ final List<ClassInfo> classInfo = new ArrayList<>();
|
||||
+ try (ScanResult scanResult = new ClassGraph()
|
||||
|
@ -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");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -131,7 +131,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+public class BlockPlayerDestroyOverrideTest extends AbstractTestingBase {
|
||||
+
|
||||
+ @MethodSource("parameters")
|
||||
+ public static Stream<ClassInfo> parameters() {
|
||||
+ final List<ClassInfo> 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");
|
||||
+ }
|
||||
+}
|
||||
|
@ -111,6 +111,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+tasks.test {
|
||||
+ exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class")
|
||||
+ useJUnitPlatform()
|
||||
+}
|
||||
+
|
||||
+fun TaskContainer.registerRunTask(
|
||||
|
@ -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<MavenPublication>("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<Registry<Keyed>> supplier) implements Registry<Keyed> {
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public Iterator<Keyed> 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<Keyed> 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
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren