You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.4 KiB
Java
48 lines
1.4 KiB
Java
10 years ago
|
/*
|
||
6 years ago
|
* Copyright 2012-2019 the original author or authors.
|
||
10 years ago
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
6 years ago
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||
10 years ago
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
5 years ago
|
package smoketest.cache;
|
||
10 years ago
|
|
||
6 years ago
|
import org.junit.jupiter.api.Test;
|
||
9 years ago
|
|
||
10 years ago
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
9 years ago
|
import org.springframework.boot.test.context.SpringBootTest;
|
||
10 years ago
|
import org.springframework.cache.Cache;
|
||
10 years ago
|
import org.springframework.cache.CacheManager;
|
||
|
|
||
9 years ago
|
import static org.assertj.core.api.Assertions.assertThat;
|
||
10 years ago
|
|
||
9 years ago
|
@SpringBootTest
|
||
6 years ago
|
class SampleCacheApplicationTests {
|
||
10 years ago
|
|
||
10 years ago
|
@Autowired
|
||
|
private CacheManager cacheManager;
|
||
|
|
||
|
@Autowired
|
||
10 years ago
|
private CountryRepository countryRepository;
|
||
10 years ago
|
|
||
|
@Test
|
||
6 years ago
|
void validateCache() {
|
||
10 years ago
|
Cache countries = this.cacheManager.getCache("countries");
|
||
9 years ago
|
assertThat(countries).isNotNull();
|
||
10 years ago
|
countries.clear(); // Simple test assuming the cache is empty
|
||
9 years ago
|
assertThat(countries.get("BE")).isNull();
|
||
10 years ago
|
Country be = this.countryRepository.findByCode("BE");
|
||
9 years ago
|
assertThat((Country) countries.get("BE").get()).isEqualTo(be);
|
||
10 years ago
|
}
|
||
|
|
||
|
}
|