-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Tests if caching with ConcurrentHashMap works |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' | ||
id 'org.springframework.aot.smoke-test' | ||
id 'org.graalvm.buildtools.native' | ||
} | ||
|
||
dependencies { | ||
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)) | ||
implementation("org.springframework.boot:spring-boot-starter-cache") | ||
|
||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
|
||
aotTestImplementation(project(":aot-smoke-test-support")) | ||
aotTestImplementation("org.awaitility:awaitility:4.2.0") | ||
} |
23 changes: 23 additions & 0 deletions
23
cache-simple/src/aotTest/java/com/example/cache/simple/CacheSimpleApplicationAotTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.AotSmokeTest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@AotSmokeTest | ||
class CacheSimpleApplicationAotTests { | ||
|
||
@Test | ||
void methodIsCached(AssertableOutput output) { | ||
Awaitility.await().atMost(Duration.ofSeconds(10)).untilAsserted(() -> { | ||
assertThat(output).hasSingleLineContaining("invoke: 1").hasNoLinesContaining("invoke: 2"); | ||
}); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
cache-simple/src/main/java/com/example/cache/simple/CLR.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
cache-simple/src/main/java/com/example/cache/simple/CacheConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
cache-simple/src/main/java/com/example/cache/simple/CacheSimpleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
cache-simple/src/main/java/com/example/cache/simple/TestService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.cache.simple; | ||
|
||
import org.springframework.cache.annotation.Cacheable; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
class TestService { | ||
|
||
private int counter = 1; | ||
|
||
@Cacheable(cacheNames = "invoke") | ||
public void invoke() { | ||
System.out.printf("invoke: %d%n", this.counter); | ||
this.counter++; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
cache-simple/src/test/java/com/example/cache/simple/CacheSimpleApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example.cache.simple; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class CacheSimpleApplicationTests { | ||
|
||
@Test | ||
void contextLoads() { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters