diff --git a/testing/src/main/java/net/minestom/testing/EnvTest.java b/testing/src/main/java/net/minestom/testing/EnvTest.java deleted file mode 100644 index 556d7b43200..00000000000 --- a/testing/src/main/java/net/minestom/testing/EnvTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.minestom.testing; - -import net.minestom.server.MinecraftServer; -import org.jetbrains.annotations.ApiStatus; -import org.junit.jupiter.api.extension.*; -import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Method; - -/** - * @deprecated As of Microtus 1.4.2, because this version doesn't support Non Env tests and env tests at the same time. - * Use {@link net.minestom.testing.extension.MicrotusExtension MicrotusExtension} instead of the {@code @EnvTest} annotation: - * {@code @ExtendWith(MicrotusExtension.class)} - */ -@ExtendWith(EnvTest.EnvParameterResolver.class) -@ExtendWith(EnvTest.EnvBefore.class) -@ExtendWith(EnvTest.EnvCleaner.class) -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Deprecated(forRemoval = true, since = "1.4.2") -@ApiStatus.ScheduledForRemoval(inVersion = "1.6.0") -public @interface EnvTest { - - final class EnvBefore implements BeforeEachCallback { - @Override - public void beforeEach(ExtensionContext context) { - System.setProperty("minestom.viewable-packet", "false"); - } - } - - final class EnvCleaner implements InvocationInterceptor { - @Override - public void interceptTestMethod(Invocation invocation, ReflectiveInvocationContext invocationContext, ExtensionContext extensionContext) throws Throwable { - invocation.proceed(); - Env env = null; - for (Object arg : invocationContext.getArguments()) { - if (arg instanceof Env) { - env = (Env) arg; - break; - } - } - if (env instanceof EnvImpl envImpl) envImpl.cleanup(); - } - } - - final class EnvParameterResolver extends TypeBasedParameterResolver { - @Override - public Env resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - return new EnvImpl(MinecraftServer.updateProcess()); - } - } -} diff --git a/testing/src/main/java/net/minestom/testing/annotations/EnvironmentTest.java b/testing/src/main/java/net/minestom/testing/annotations/EnvironmentTest.java deleted file mode 100644 index 5f6f83db3c6..00000000000 --- a/testing/src/main/java/net/minestom/testing/annotations/EnvironmentTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.minestom.testing.annotations; - -import net.minestom.testing.extension.MicrotusExtension; -import org.jetbrains.annotations.ApiStatus; -import org.junit.jupiter.api.extension.ExtendWith; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Creates a fake environment for Microtus - * @since 1.4.2 - * @deprecated As of Microtus 1.5.0, because better and deeper integration of JUnit5 testing use - * {@link net.minestom.testing.extension.MicrotusExtension} instead. - */ -@ExtendWith(MicrotusExtension.class) -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Deprecated(forRemoval = true, since = "1.5.0") -@ApiStatus.ScheduledForRemoval(inVersion = "1.6.0") -public @interface EnvironmentTest { -} diff --git a/testing/src/main/java/net/minestom/testing/environment/TestEnvironmentCleaner.java b/testing/src/main/java/net/minestom/testing/environment/TestEnvironmentCleaner.java deleted file mode 100644 index 94f404ebcd4..00000000000 --- a/testing/src/main/java/net/minestom/testing/environment/TestEnvironmentCleaner.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.minestom.testing.environment; - -import net.minestom.testing.Env; -import org.jetbrains.annotations.ApiStatus; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.InvocationInterceptor; -import org.junit.jupiter.api.extension.ReflectiveInvocationContext; - -import java.lang.reflect.Method; -import java.util.List; - -/** - * Handles {@link Env} to clean the Test Environment after usage - * @since 1.4.2 - */ -@Deprecated(forRemoval = true, since = "1.5.0") -@ApiStatus.ScheduledForRemoval(inVersion = "1.6.0") -public final class TestEnvironmentCleaner implements InvocationInterceptor { - @Override - public void interceptTestMethod(Invocation invocation, ReflectiveInvocationContext invocationContext, ExtensionContext extensionContext) throws Throwable { - invocation.proceed(); - List arguments = invocationContext.getArguments(); - arguments.stream().filter(Env.class::isInstance).findFirst().ifPresent(o -> { - Env env = (Env) o; - env.cleanup(); - }); - } -} diff --git a/testing/src/main/java/net/minestom/testing/environment/TestEnvironmentParameterResolver.java b/testing/src/main/java/net/minestom/testing/environment/TestEnvironmentParameterResolver.java deleted file mode 100644 index 6980f22bc0d..00000000000 --- a/testing/src/main/java/net/minestom/testing/environment/TestEnvironmentParameterResolver.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.minestom.testing.environment; - -import net.minestom.server.MinecraftServer; -import net.minestom.testing.Env; -import org.jetbrains.annotations.ApiStatus; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; -import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver; - -/** - * Handles {@link Env} parameter for JUnit Tests to inject the TestEnvironment - * @since 1.4.1 - */ -@Deprecated(forRemoval = true, since = "1.5.0") -@ApiStatus.ScheduledForRemoval(inVersion = "1.6.0") -public final class TestEnvironmentParameterResolver extends TypeBasedParameterResolver { - @Override - public Env resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - return Env.createInstance(MinecraftServer.updateProcess()); - } -}