lithium.classloadertest.annotation.ProxyableClasses Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multiverse-test Show documentation
Show all versions of multiverse-test Show documentation
The Multiverse Test Framework for Java
The newest version!
package lithium.classloadertest.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import lithium.classloadertest.FunctionalTestClassLoader;
import lithium.classloadertest.UnfinalizingTestRunner;
/**
* Works in conjunction with {@link UnfinalizingTestRunner} to specify classes that should be proxy-able (e.g. used
* in mock frameworks like EasyMock or the {@link FunctionalTestClassLoader}). For example, it is useful to be able
* to perform an operation on an instance of a class loaded in a FunctionalTestClassLoader and return it to the controlling
* test for comparison with values retrieved from another instance of a FunctionalTestClassLoader.
*
* Example:
*
* @RunWith(UnfinalizingTestRunner.class)
* @ProxyableClasses({NeedToBeUnfinal.class}, classNames={"x.y.z.MyClass$MyInternalHiddenClass"})
* public class MyTest {
*
* public void testFinalClass() {
* IMocksControl control = EasyMock.createStrictControl();
* MyTest.NeedToBeUnfinal c = control.createMock(MyTest.NeedToBeUnfinal.class);
* EasyMock.expect(f.cantOverrideThis()).andReturn("yes we can");
* control.replay();
* Assert.assertEquals("yes we can", f.cantOverrideThis());
* }
* ...
* public final class NeedToBeUnfinal {
* public final void cantOverrideThis() {
* // do some action
* }
* }
*
* @author jeff.collins
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ProxyableClasses {
Class>[] value();
String[] classNames() default {};
}