All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.aj Maven / Gradle / Ivy

There is a newer version: 6.2.1
Show newest version
package org.springframework.mock.staticmock;

import javax.persistence.Entity;

/**
 * Annotation-based aspect to use in test build to enable mocking static methods
 * on Entity classes, as used by Roo for finders.
 * 
* Mocking will occur in the call stack of any method in a class (typically a test class) * that is annotated with the @MockStaticEntityMethods annotation. *
* Also provides static methods to simplify the programming model for * entering playback mode and setting expected return values. *
* Usage:
    *
  1. Annotate a test class with @MockStaticEntityMethods. *
  2. In each test method, AnnotationDrivenStaticEntityMockingControl will begin in recording mode. * Invoke static methods on Entity classes, with each recording-mode invocation * being followed by an invocation to the static expectReturn() or expectThrow() * method on AnnotationDrivenStaticEntityMockingControl. *
  3. Invoke the static AnnotationDrivenStaticEntityMockingControl() method. *
  4. Call the code you wish to test that uses the static methods. Verification will * occur automatically. *
* * @see MockStaticEntityMethods * * @author Rod Johnson * @author Ramnivas Laddad * */ public aspect AnnotationDrivenStaticEntityMockingControl extends AbstractMethodMockingControl { /** * Stop recording mock calls and enter playback state */ public static void playback() { AnnotationDrivenStaticEntityMockingControl.aspectOf().playbackInternal(); } public static void expectReturn(Object retVal) { AnnotationDrivenStaticEntityMockingControl.aspectOf().expectReturnInternal(retVal); } public static void expectThrow(Throwable throwable) { AnnotationDrivenStaticEntityMockingControl.aspectOf().expectThrowInternal(throwable); } // Only matches directly annotated @Test methods, to allow methods in // @MockStatics classes to invoke each other without resetting the mocking environment protected pointcut mockStaticsTestMethod() : execution(public * (@MockStaticEntityMethods *).*(..)); protected pointcut methodToMock() : execution(public static * (@Entity *).*(..)); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy