public class ArtifactClassLoaderRunner
extends org.junit.runner.Runner
implements org.junit.runner.manipulation.Filterable
Runner that mimics the class loading model used in a Mule Standalone distribution. In order to
detect early issues related to isolation when building plugins these runner allows you to run your functional test cases using
an isolated class loader.
org.mule.functional.junit4.ArtifactFunctionalTestCase should be extended in order to use this runner, it has already
annotated the runner and also has the logic to register Extension to a
MuleContext.
See RunnerDelegateTo for those scenarios where another JUnit runner needs to be used but still the test has to be
executed within an isolated class loading model. ArtifactClassLoaderRunnerConfig allows to define the plugins in order
to create the class loaders for them, for each one a plugin class loader would be created. PluginClassLoadersAware
allows the test to be injected with the list of ClassLoaders that were created for each plugin, mostly used in
org.mule.functional.junit4.ArtifactFunctionalTestCase in order to enable plugins into a
MuleContext.
The class loading model is built by doing a classification of the class path URLs loaded by IDEs or Maven.
ClassPathClassifier defines the strategy of classification to be used in order to define the
ArtifactClassLoaderHolder, classification would define three levels of URLs that would be used for creating a
container ArtifactClassLoader, list of plugins ArtifactClassLoader and an application
ArtifactClassLoader.
The classification bases its logic by resolving Maven dependency graphs using Eclipse Aether. See
AetherClassPathClassifier for more details about this. In order to allow the classification to resolve Maven artifact
from the local Maven repository, if the default location is not used $USER_HOME/.m2/repository, the following system
property has to be to the local Maven repository location when running a test from IDE:
System.getProperty("localRepository")
Only one instance of the ClassLoader is created and used to run all the tests that are marked to run with this
Runner due to creating the ClassLoader requires time and has impact when running tests.
A best practice is to a base abstract class for your module tests that extends
org.mule.functional.junit4.ArtifactFunctionalTestCase and defines if needed anything related to the configuration with
this annotation that will be applied to all the tests that are being executed for the same VM.| Constructor and Description |
|---|
ArtifactClassLoaderRunner(Class<?> clazz,
org.junit.runners.model.RunnerBuilder builder)
Creates a Runner to run
klass |
| Modifier and Type | Method and Description |
|---|---|
void |
filter(org.junit.runner.manipulation.Filter filter)
Delegates to the inner runner to filter.
|
org.junit.runner.Description |
getDescription() |
void |
run(org.junit.runner.notification.RunNotifier notifier)
When the test is about to be executed the ThreadContextClassLoader is changed to use the application class loader that was
created so the execution of the test will be done using an isolated class loader that mimics the standalone container.
|
public org.junit.runner.Description getDescription()
getDescription in interface org.junit.runner.DescribablegetDescription in class org.junit.runner.Runnerpublic void run(org.junit.runner.notification.RunNotifier notifier)
run in class org.junit.runner.Runnernotifier - the RunNotifier from JUnit that will be notified about the results of the test methods invoked.public void filter(org.junit.runner.manipulation.Filter filter)
throws org.junit.runner.manipulation.NoTestsRemainException
filter in interface org.junit.runner.manipulation.Filterablefilter - the Filter from JUnit to select a single test.org.junit.runner.manipulation.NoTestsRemainExceptionCopyright © 2003–2019 MuleSoft, Inc.. All rights reserved.