From c970c318f4ecf5f23e3f17aa3a22979a483f9dab Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 7 Dec 2020 22:08:01 +0100 Subject: [PATCH] Polishing --- .../autoproxy/AtAspectJAfterThrowingTests.java | 14 ++++++++------ .../autoproxy/AtAspectJAnnotationBindingTests.java | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java index 13bd4d38c0e..1c6dd13a16a 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,24 +36,26 @@ import static org.assertj.core.api.Assertions.assertThat; public class AtAspectJAfterThrowingTests { @Test - public void testAccessThrowable() throws Exception { + public void testAccessThrowable() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); ITestBean bean = (ITestBean) ctx.getBean("testBean"); ExceptionHandlingAspect aspect = (ExceptionHandlingAspect) ctx.getBean("aspect"); assertThat(AopUtils.isAopProxy(bean)).isTrue(); + IOException exceptionThrown = null; try { bean.unreliableFileOperation(); } - catch (IOException e) { - // + catch (IOException ex) { + exceptionThrown = ex; } assertThat(aspect.handled).isEqualTo(1); - assertThat(aspect.lastException).isNotNull(); + assertThat(aspect.lastException).isSameAs(exceptionThrown); } + } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java index f6fdf729ab6..679a4ceff94 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class AtAspectJAnnotationBindingTests { private AnnotatedTestBean testBean; + private ClassPathXmlApplicationContext ctx; @@ -70,8 +71,7 @@ public class AtAspectJAnnotationBindingTests { class AtAspectJAnnotationBindingTestAspect { @Around("execution(* *(..)) && @annotation(testAnn)") - public Object doWithAnnotation(ProceedingJoinPoint pjp, TestAnnotation testAnn) - throws Throwable { + public Object doWithAnnotation(ProceedingJoinPoint pjp, TestAnnotation testAnn) throws Throwable { String annValue = testAnn.value(); Object result = pjp.proceed(); return (result instanceof String ? annValue + " " + result : result);