Class ModLauncherExtension

java.lang.Object
org.spongepowered.mij.ModLauncherExtension
All Implemented Interfaces:
org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.InvocationInterceptor, MethodInvocationInterceptor

public abstract class ModLauncherExtension extends Object implements MethodInvocationInterceptor
A JUnit extension booting ModLauncher and executing tests inside the transforming class loader.
  • Constructor Details

    • ModLauncherExtension

      public ModLauncherExtension()
  • Method Details

    • interceptTestClassConstructor

      public <T> T interceptTestClassConstructor(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Constructor<T>> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
      Specified by:
      interceptTestClassConstructor in interface org.junit.jupiter.api.extension.InvocationInterceptor
      Throws:
      Throwable
    • interceptMethod

      public <T> T interceptMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
      Description copied from interface: MethodInvocationInterceptor
      Intercepts the invocation of any method.
      Specified by:
      interceptMethod in interface MethodInvocationInterceptor
      Parameters:
      invocation - The invocation that is being intercepted; never null
      invocationContext - The context of the invocation that is being intercepted; never null
      extensionContext - The current extension context; never null
      Throws:
      Throwable - In case of failures
    • getTransformedInstance

      protected Object getTransformedInstance(Object originalInstance)
    • getTransformedConstructor

      protected Constructor<?> getTransformedConstructor(Constructor<?> originalConstructor)
    • getTransformedMethod

      protected Method getTransformedMethod(Method originalMethod)
    • getTransformedClass

      protected Class<?> getTransformedClass(Class<?> originalClass)
    • getTransformingClassLoader

      protected abstract ClassLoader getTransformingClassLoader()
      Gets the transforming class loader in which tests are executed. A typical implementation of this method will invoke SharedModLauncher.getTransformingClassLoader(String[]) with the launch target set in the arguments.
      Returns:
      The transforming class loader