File tree Expand file tree Collapse file tree
main/java/com/baeldung/aspect
test/java/com/baeldung/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9999 <artifactId >joda-time</artifactId >
100100 <version >${joda.version} </version >
101101 </dependency >
102+ <dependency >
103+ <groupId >org.aspectj</groupId >
104+ <artifactId >aspectjrt</artifactId >
105+ <version >${asspectj.version} </version >
106+ </dependency >
107+ <dependency >
108+ <groupId >org.aspectj</groupId >
109+ <artifactId >aspectjweaver</artifactId >
110+ <version >${asspectj.version} </version >
111+ </dependency >
102112 </dependencies >
103113
104114 <build >
170180 <joda .version>2.10</joda .version>
171181 <!-- testing -->
172182 <assertj .version>3.6.1</assertj .version>
183+ <asspectj .version>1.8.9</asspectj .version>
173184 <avaitility .version>1.7.0</avaitility .version>
174185 <jmh-core .version>1.19</jmh-core .version>
175186 <jmh-generator .version>1.19</jmh-generator .version>
Original file line number Diff line number Diff line change 1+ package com.baeldung.aspect ;
2+
3+ public aspect ChangeCallsToCurrentTimeInMillisMethod {
4+ long around ():
5+ call (public static native long java.lang. System . currentTimeMillis())
6+ && within (user. code. base. pckg. * ) {
7+ return 0 ;
8+ }
9+ }
Original file line number Diff line number Diff line change 11package com .baeldung .util ;
22
33import static org .junit .Assert .assertEquals ;
4+ import static org .junit .Assert .assertTrue ;
45
56import java .time .Clock ;
67import java .time .Instant ;
910import java .time .ZoneId ;
1011import java .time .temporal .ChronoField ;
1112
13+ import org .joda .time .DateTime ;
14+ import org .joda .time .DateTimeUtils ;
1215import org .junit .Test ;
1316
1417public class CurrentDateTimeUnitTest {
@@ -39,5 +42,4 @@ public void shouldReturnCurrentTimestamp() {
3942
4043 assertEquals (clock .instant ().getEpochSecond (), now .getEpochSecond ());
4144 }
42-
4345}
You can’t perform that action at this time.
0 commit comments