Reflect grouping in directory structure

This commit is contained in:
Andy Wilkinson
2022-10-28 14:36:50 +01:00
parent 393e1cb6bf
commit 7112a4b6a4
788 changed files with 9 additions and 100 deletions

View File

@@ -0,0 +1,23 @@
package com.example.cache.simple;
import java.time.Duration;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.springframework.aot.smoketest.support.assertj.AssertableOutput;
import org.springframework.aot.smoketest.support.junit.ApplicationTest;
import static org.assertj.core.api.Assertions.assertThat;
@ApplicationTest
class CacheSimpleApplicationAotTests {
@Test
void methodIsCached(AssertableOutput output) {
Awaitility.await().atMost(Duration.ofSeconds(10)).untilAsserted(() -> {
assertThat(output).hasSingleLineContaining("invoke: 1").hasNoLinesContaining("invoke: 2");
});
}
}

View File

@@ -0,0 +1,21 @@
package com.example.cache.simple;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
class CLR implements CommandLineRunner {
private final TestService testService;
public CLR(TestService testService) {
this.testService = testService;
}
@Override
public void run(String... args) {
this.testService.invoke();
this.testService.invoke();
}
}

View File

@@ -0,0 +1,10 @@
package com.example.cache.simple;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
@EnableCaching
class CacheConfiguration {
}

View File

@@ -0,0 +1,14 @@
package com.example.cache.simple;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class CacheSimpleApplication {
public static void main(String[] args) throws InterruptedException {
SpringApplication.run(CacheSimpleApplication.class, args);
Thread.currentThread().join(); // To be able to measure memory consumption
}
}

View File

@@ -0,0 +1,10 @@
package com.example.cache.simple;
import org.springframework.cache.annotation.Cacheable;
interface TestService {
@Cacheable(cacheNames = "invoke")
void invoke();
}

View File

@@ -0,0 +1,16 @@
package com.example.cache.simple;
import org.springframework.stereotype.Service;
@Service
class TestServiceImpl implements TestService {
private int counter = 1;
@Override
public void invoke() {
System.out.printf("invoke: %d%n", this.counter);
this.counter++;
}
}

View File

@@ -0,0 +1 @@
spring.aop.proxy-target-class=false