File tree Expand file tree Collapse file tree 8 files changed +13
-15
lines changed
spring-aop-03-@AfterReturning
spring-aop-04-@AfterThrowing
main/java/c/jbd/saop/at/aspect
src/test/java/com/jbd/saop/after Expand file tree Collapse file tree 8 files changed +13
-15
lines changed Original file line number Diff line number Diff line change 88 <version >1.0-SNAPSHOT</version >
99 </parent >
1010 <modelVersion >4.0.0</modelVersion >
11- <artifactId >spring-aop-01-@ Before</artifactId >
11+ <artifactId >spring-aop-01-Before</artifactId >
1212 <description >Spring AOP - @Before advice example</description >
1313
1414 <dependencies >
Original file line number Diff line number Diff line change 88 <version >1.0-SNAPSHOT</version >
99 </parent >
1010 <modelVersion >4.0.0</modelVersion >
11- <artifactId >spring-aop-03-@ AfterReturning</artifactId >
12- <description >Spring AOP - @AfterReturning advice example</description >
11+ <artifactId >spring-aop-03-AfterReturning</artifactId >
12+ <description >Spring AOP - @AfterReturning aspect example</description >
1313
1414 <dependencies >
1515 <dependency >
Original file line number Diff line number Diff line change 88 <version >1.0-SNAPSHOT</version >
99 </parent >
1010 <modelVersion >4.0.0</modelVersion >
11- <artifactId >spring-aop-04-@ AfterThrowing</artifactId >
11+ <artifactId >spring-aop-04-AfterThrowing</artifactId >
1212 <description >Spring AOP - @AfterThrowing advice example</description >
1313
1414 <dependencies >
Original file line number Diff line number Diff line change 33import org .aspectj .lang .JoinPoint ;
44import org .aspectj .lang .annotation .AfterThrowing ;
55import org .aspectj .lang .annotation .Aspect ;
6- import org .springframework .stereotype . Service ;
6+ import org .springframework .context . annotation . Configuration ;
77
8- @ Service
8+ @ Configuration
99@ Aspect
1010public class ExceptionAspect {
1111
1212 /**
13- *
13+ * Match with all dao methods.
14+ *
1415 * @param joinPoint
1516 * @param exception
1617 */
Original file line number Diff line number Diff line change @@ -19,13 +19,13 @@ public void notNull() {
1919
2020 @ Test
2121 public void testThrows () {
22- //Assert exception
22+ //Assert throws RuntimeException
2323 Assertions .assertThrows (RuntimeException .class , () -> {
2424 userRepository .add (null );
2525 userRepository .delete (null );
2626 });
2727
28- //Assert exception
28+ //Assert does not throw exception
2929 Assertions .assertDoesNotThrow (() -> {
3030 userRepository .delete ("alexa" );
3131 });
Original file line number Diff line number Diff line change 88 <version >1.0-SNAPSHOT</version >
99 </parent >
1010 <modelVersion >4.0.0</modelVersion >
11- <artifactId >spring-aop-05-@ After</artifactId >
11+ <artifactId >spring-aop-05-After</artifactId >
1212 <description >Spring AOP - @After advice example</description >
1313
1414 <dependencies >
Original file line number Diff line number Diff line change 77import org .springframework .test .context .junit .jupiter .SpringJUnitConfig ;
88
99@ SpringJUnitConfig (ApplicationConfig .class )
10- public class TestAfter {
10+ public class TestAfterAdvice {
1111
1212 @ Autowired
1313 private UserRepository userRepository ;
@@ -30,8 +30,5 @@ public void testThrows() {
3030 userRepository .delete ("alexa" );
3131 });
3232 }
33-
34- @ Test
35- public void testAfter (){}
3633
3734}
Original file line number Diff line number Diff line change 88 <version >1.0-SNAPSHOT</version >
99 </parent >
1010 <modelVersion >4.0.0</modelVersion >
11- <artifactId >spring-aop-06-@ Around</artifactId >
11+ <artifactId >spring-aop-06-Around</artifactId >
1212 <description >Spring AOP - @Around aspect example</description >
1313
1414 <dependencies >
You can’t perform that action at this time.
0 commit comments