Class MockClassLoader


  • public class MockClassLoader
    extends DeferSupportingClassLoader
    Mock all classes except system classes.

    Notice that there are two different types of classes that are not mocked:

    1. system classes are deferred to another classloader
    2. testing framework classes are loaded, but not modified
    Author:
    Johan Haleby, Jan Kronquist
    • Field Detail

      • MODIFY_ALL_CLASSES

        public static final String MODIFY_ALL_CLASSES
        Pass this string to the constructor to indicate that all classes should be modified.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MockClassLoader

        public MockClassLoader​(String[] classesToMock,
                               String[] packagesToDefer,
                               UseClassPathAdjuster useClassPathAdjuster)
        Creates a new instance of the MockClassLoader based on the following parameters:
        Parameters:
        classesToMock - The classes that must be modified to prepare for testability.
        packagesToDefer - Classes in these packages will be defered to the system class-loader.
      • MockClassLoader

        public MockClassLoader​(String[] classesToMock,
                               String[] packagesToDefer)
        Creates a new instance of the MockClassLoader based on the following parameters:
        Parameters:
        classesToMock - The classes that must be modified to prepare for testability.
        packagesToDefer - Classes in these packages will be defered to the system class-loader.
      • MockClassLoader

        public MockClassLoader​(String[] classesToMock,
                               UseClassPathAdjuster useClassPathAdjuster)
        Creates a new instance of the MockClassLoader based on the following parameters:
        Parameters:
        classesToMock - The classes that must be modified to prepare for testability.
      • MockClassLoader

        public MockClassLoader​(String[] classesToMock)
        Creates a new instance of the MockClassLoader based on the following parameters:
        Parameters:
        classesToMock - The classes that must be modified to prepare for testability.