java-tutorials/spring-aop-2/src/test/java/com/baeldung/selfinvocation/CompileTimeWeavingIntegrationTest.java
Forb Yuan 8c3d581fa9 BAEL-6300: Invoking Spring Cache @Cacheable from Another Method of the Same Bean (#14689)
* BAEL-6300: Problem Reproduction

* BAEL-6300: Internal Invocation with External Reference

* BAEL-6300: compile-time weaving

* BAEL-6300: load-time weaving
2023-09-02 16:23:29 +02:00

24 lines
708 B
Java

package com.baeldung.selfinvocation;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.util.concurrent.atomic.AtomicInteger;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(classes = CompileTimeWeavingApplication.class)
class CompileTimeWeavingIntegrationTest {
@Resource
private MathService mathService;
@Test
void givenCacheableMethod_whenInvokingByInternalCall_thenCacheIsTriggered() {
AtomicInteger counter = mathService.resetCounter();
assertThat(mathService.sumOfSquareOf2()).isEqualTo(8);
assertThat(counter.get()).isEqualTo(1);
}
}