16
16
package org .springframework .data .redis .cache ;
17
17
18
18
import static org .assertj .core .api .Assertions .assertThat ;
19
+ import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
19
20
import static org .assertj .core .api .Assertions .assertThatIllegalStateException ;
20
21
import static org .assertj .core .api .Assumptions .assumeThat ;
21
22
import static org .awaitility .Awaitility .await ;
52
53
import org .springframework .data .redis .connection .RedisConnection ;
53
54
import org .springframework .data .redis .connection .RedisConnectionFactory ;
54
55
import org .springframework .data .redis .connection .jedis .JedisConnectionFactory ;
56
+ import org .springframework .data .redis .connection .lettuce .LettuceConnectionFactory ;
55
57
import org .springframework .data .redis .serializer .RedisSerializationContext .SerializationPair ;
56
58
import org .springframework .data .redis .serializer .RedisSerializer ;
57
59
import org .springframework .data .redis .test .condition .EnabledOnCommand ;
60
+ import org .springframework .data .redis .test .condition .EnabledOnRedisDriver ;
61
+ import org .springframework .data .redis .test .condition .RedisDriver ;
58
62
import org .springframework .data .redis .test .extension .parametrized .MethodSource ;
59
63
import org .springframework .data .redis .test .extension .parametrized .ParameterizedRedisTest ;
60
64
import org .springframework .lang .Nullable ;
@@ -568,10 +572,37 @@ void cacheGetWithTimeToIdleExpirationAfterEntryExpiresShouldReturnNull() {
568
572
assertThat (cache .get (this .cacheKey , Person .class )).isNull ();
569
573
}
570
574
575
+ @ ParameterizedRedisTest
576
+ void retrieveCacheValueUsingJedis () {
577
+
578
+ // TODO: Is there a better way to do this? @EnableOnRedisDriver(RedisDriver.JEDIS) does not work!
579
+ assumeThat (this .connectionFactory instanceof JedisConnectionFactory ).isTrue ();
580
+
581
+ assertThatExceptionOfType (UnsupportedOperationException .class )
582
+ .isThrownBy (() -> this .cache .retrieve (this .binaryCacheKey ))
583
+ .withMessageContaining (RedisCache .class .getName ())
584
+ .withNoCause ();
585
+ }
586
+
587
+ @ ParameterizedRedisTest
588
+ void retrieveCacheValueWithLoaderUsingJedis () {
589
+
590
+ // TODO: Is there a better way to do this? @EnableOnRedisDriver(RedisDriver.JEDIS) does not work!
591
+ assumeThat (this .connectionFactory instanceof JedisConnectionFactory ).isTrue ();
592
+
593
+ assertThatExceptionOfType (UnsupportedOperationException .class )
594
+ .isThrownBy (() -> this .cache .retrieve (this .binaryCacheKey , () -> CompletableFuture .completedFuture ("TEST" )))
595
+ .withMessageContaining (RedisCache .class .getName ())
596
+ .withNoCause ();
597
+ }
598
+
571
599
@ ParameterizedRedisTest // GH-2650
572
600
@ SuppressWarnings ("unchecked" )
573
601
void retrieveReturnsCachedValue () throws Exception {
574
602
603
+ // TODO: Is there a better way to do this? @EnableOnRedisDriver(RedisDriver.LETTUCE) does not work!
604
+ assumeThat (this .connectionFactory instanceof LettuceConnectionFactory ).isTrue ();
605
+
575
606
doWithConnection (connection -> connection .stringCommands ().set (this .binaryCacheKey , this .binarySample ));
576
607
577
608
RedisCache cache = new RedisCache ("cache" , usingLockingRedisCacheWriter (), usingRedisCacheConfiguration ());
@@ -587,6 +618,9 @@ void retrieveReturnsCachedValue() throws Exception {
587
618
@ SuppressWarnings ("unchecked" )
588
619
void retrieveReturnsCachedValueWhenLockIsReleased () throws Exception {
589
620
621
+ // TODO: Is there a better way to do this? @EnableOnRedisDriver(RedisDriver.LETTUCE) does not work!
622
+ assumeThat (this .connectionFactory instanceof LettuceConnectionFactory ).isTrue ();
623
+
590
624
String mockValue = "MockValue" ;
591
625
String testValue = "TestValue" ;
592
626
@@ -618,6 +652,9 @@ void retrieveReturnsCachedValueWhenLockIsReleased() throws Exception {
618
652
@ ParameterizedRedisTest // GH-2650
619
653
void retrieveReturnsLoadedValue () throws Exception {
620
654
655
+ // TODO: Is there a better way to do this? @EnableOnRedisDriver(RedisDriver.LETTUCE) does not work!
656
+ assumeThat (this .connectionFactory instanceof LettuceConnectionFactory ).isTrue ();
657
+
621
658
RedisCache cache = new RedisCache ("cache" , usingLockingRedisCacheWriter (), usingRedisCacheConfiguration ());
622
659
623
660
AtomicBoolean loaded = new AtomicBoolean (false );
@@ -646,6 +683,9 @@ void retrieveReturnsLoadedValue() throws Exception {
646
683
@ ParameterizedRedisTest // GH-2650
647
684
void retrieveReturnsNull () throws Exception {
648
685
686
+ // TODO: Is there a better way to do this? @EnableOnRedisDriver(RedisDriver.LETTUCE) does not work!
687
+ assumeThat (this .connectionFactory instanceof LettuceConnectionFactory ).isTrue ();
688
+
649
689
doWithConnection (connection -> connection .stringCommands ().set (this .binaryCacheKey , this .binaryNullValue ));
650
690
651
691
RedisCache cache = new RedisCache ("cache" , usingLockingRedisCacheWriter (), usingRedisCacheConfiguration ());
0 commit comments