2020
2121import java .util .Collections ;
2222
23- import org .junit .Test ;
24- import org .junit .runner . RunWith ;
23+ import org .junit .jupiter . api . Test ;
24+ import org .junit .jupiter . api . extension . ExtendWith ;
2525import org .mockito .Mock ;
26- import org .mockito .junit .MockitoJUnitRunner ;
27-
26+ import org .mockito .junit .jupiter .MockitoExtension ;
2827import org .springframework .cache .Cache ;
2928import org .springframework .cache .transaction .TransactionAwareCacheDecorator ;
3029import org .springframework .data .redis .cache .RedisCacheManager .RedisCacheManagerBuilder ;
3635 * @author Christoph Strobl
3736 * @author Mark Paluch
3837 */
39- @ RunWith ( MockitoJUnitRunner .class )
40- public class RedisCacheManagerUnitTests {
38+ @ ExtendWith ( MockitoExtension .class )
39+ class RedisCacheManagerUnitTests {
4140
4241@ Mock RedisCacheWriter cacheWriter ;
4342
4443@ Test // DATAREDIS-481
45- public void missingCacheShouldBeCreatedWithDefaultConfiguration () {
44+ void missingCacheShouldBeCreatedWithDefaultConfiguration () {
4645
4746RedisCacheConfiguration configuration = RedisCacheConfiguration .defaultCacheConfig ().disableKeyPrefix ();
4847
@@ -53,7 +52,7 @@ public void missingCacheShouldBeCreatedWithDefaultConfiguration() {
5352}
5453
5554@ Test // DATAREDIS-481
56- public void appliesDefaultConfigurationToInitialCache () {
55+ void appliesDefaultConfigurationToInitialCache () {
5756
5857RedisCacheConfiguration withPrefix = RedisCacheConfiguration .defaultCacheConfig ().disableKeyPrefix ();
5958RedisCacheConfiguration withoutPrefix = RedisCacheConfiguration .defaultCacheConfig ().disableKeyPrefix ();
@@ -72,7 +71,7 @@ public void appliesDefaultConfigurationToInitialCache() {
7271}
7372
7473@ Test // DATAREDIS-481, DATAREDIS-728
75- public void predefinedCacheShouldBeCreatedWithSpecificConfig () {
74+ void predefinedCacheShouldBeCreatedWithSpecificConfig () {
7675
7776RedisCacheConfiguration configuration = RedisCacheConfiguration .defaultCacheConfig ().disableKeyPrefix ();
7877
@@ -87,7 +86,7 @@ public void predefinedCacheShouldBeCreatedWithSpecificConfig() {
8786}
8887
8988@ Test // DATAREDIS-481
90- public void transactionAwareCacheManagerShouldDecoracteCache () {
89+ void transactionAwareCacheManagerShouldDecoracteCache () {
9190
9291Cache cache = RedisCacheManager .builder (cacheWriter ).transactionAware ().build ().getCache ("decoracted-cache" );
9392
@@ -96,7 +95,7 @@ public void transactionAwareCacheManagerShouldDecoracteCache() {
9695}
9796
9897@ Test // DATAREDIS-767
99- public void lockedCacheManagerShouldPreventInFlightCacheCreation () {
98+ void lockedCacheManagerShouldPreventInFlightCacheCreation () {
10099
101100RedisCacheManager cacheManager = RedisCacheManager .builder (cacheWriter ).disableCreateOnMissingCache ().build ();
102101cacheManager .afterPropertiesSet ();
@@ -105,7 +104,7 @@ public void lockedCacheManagerShouldPreventInFlightCacheCreation() {
105104}
106105
107106@ Test // DATAREDIS-767
108- public void lockedCacheManagerShouldStillReturnPreconfiguredCaches () {
107+ void lockedCacheManagerShouldStillReturnPreconfiguredCaches () {
109108
110109RedisCacheManager cacheManager = RedisCacheManager .builder (cacheWriter )
111110.initialCacheNames (Collections .singleton ("configured" )).disableCreateOnMissingCache ().build ();
@@ -115,7 +114,7 @@ public void lockedCacheManagerShouldStillReturnPreconfiguredCaches() {
115114}
116115
117116@ Test // DATAREDIS-935
118- public void cacheManagerBuilderReturnsConfiguredCaches () {
117+ void cacheManagerBuilderReturnsConfiguredCaches () {
119118
120119RedisCacheManagerBuilder cmb = RedisCacheManager .builder (cacheWriter )
121120.initialCacheNames (Collections .singleton ("configured" )).disableCreateOnMissingCache ();
@@ -126,7 +125,7 @@ public void cacheManagerBuilderReturnsConfiguredCaches() {
126125}
127126
128127@ Test // DATAREDIS-935
129- public void cacheManagerBuilderDoesNotAllowSneakingInConfiguration () {
128+ void cacheManagerBuilderDoesNotAllowSneakingInConfiguration () {
130129
131130RedisCacheManagerBuilder cmb = RedisCacheManager .builder (cacheWriter )
132131.initialCacheNames (Collections .singleton ("configured" )).disableCreateOnMissingCache ();
@@ -136,7 +135,7 @@ public void cacheManagerBuilderDoesNotAllowSneakingInConfiguration() {
136135}
137136
138137@ Test // DATAREDIS-935
139- public void cacheManagerBuilderReturnsConfigurationForKnownCache () {
138+ void cacheManagerBuilderReturnsConfigurationForKnownCache () {
140139
141140RedisCacheManagerBuilder cmb = RedisCacheManager .builder (cacheWriter )
142141.initialCacheNames (Collections .singleton ("configured" )).disableCreateOnMissingCache ();
@@ -145,7 +144,7 @@ public void cacheManagerBuilderReturnsConfigurationForKnownCache() {
145144}
146145
147146@ Test // DATAREDIS-935
148- public void cacheManagerBuilderReturnsEmptyOptionalForUnknownCache () {
147+ void cacheManagerBuilderReturnsEmptyOptionalForUnknownCache () {
149148
150149RedisCacheManagerBuilder cmb = RedisCacheManager .builder (cacheWriter )
151150.initialCacheNames (Collections .singleton ("configured" )).disableCreateOnMissingCache ();
@@ -154,7 +153,7 @@ public void cacheManagerBuilderReturnsEmptyOptionalForUnknownCache() {
154153}
155154
156155@ Test // DATAREDIS-1118
157- public void shouldConfigureRedisCacheWriter () {
156+ void shouldConfigureRedisCacheWriter () {
158157
159158RedisCacheWriter writerMock = mock (RedisCacheWriter .class );
160159
@@ -164,7 +163,12 @@ public void shouldConfigureRedisCacheWriter() {
164163}
165164
166165@ Test // DATAREDIS-1118
167- public void builderShouldRequireCacheWriter () {
168- assertThatIllegalArgumentException ().isThrownBy (() -> RedisCacheManager .builder ().build ());
166+ void cacheWriterMustNotBeNull () {
167+ assertThatIllegalArgumentException ().isThrownBy (() -> RedisCacheManager .builder ().cacheWriter (null ));
168+ }
169+
170+ @ Test // DATAREDIS-1118
171+ void builderShouldRequireCacheWriter () {
172+ assertThatIllegalStateException ().isThrownBy (() -> RedisCacheManager .builder ().build ());
169173}
170174}
0 commit comments