I am trying to change the behavior of the System.currentTimeMillis() method for testing purposes. I found the method below, but I can not use the aspect keyword in code. I do not really understand how this method can be used. Any suggestions?
public aspect CurrentTimeInMillisMethodCallChanger {
long around():
call(public static native long java.lang.System.currentTimeMillis())
&& within(user.code.base.pckg.*) {
return 0; // provide your own implementation returning a long
}
}
See the related answer containing the source of the above code for more details