|
49 | 49 | * Transactional integration tests for {@link StringRedisTemplate}. |
50 | 50 | * |
51 | 51 | * @author Christoph Strobl |
| 52 | + * @author LeeHyungGeol |
52 | 53 | */ |
53 | 54 | @ParameterizedClass |
54 | 55 | @MethodSource("argumentsStream") |
@@ -116,6 +117,35 @@ void visibilityDuringManagedTransaction() throws SQLException { |
116 | 117 | .containsEntry("isMember(inside)", false); |
117 | 118 | } |
118 | 119 |
|
| 120 | + @Test // GH-3187 |
| 121 | + void allRangeWithScoresMethodsInTransactionShouldNotReturnNull() throws SQLException { |
| 122 | + |
| 123 | + DataSource ds = mock(DataSource.class); |
| 124 | + when(ds.getConnection()).thenReturn(mock(Connection.class)); |
| 125 | + |
| 126 | + DataSourceTransactionManager txMgr = new DataSourceTransactionManager(ds); |
| 127 | + TransactionTemplate txTemplate = new TransactionTemplate(txMgr); |
| 128 | + txTemplate.afterPropertiesSet(); |
| 129 | + |
| 130 | + stringTemplate.opsForZSet().add("testzset", "member1", 1.0); |
| 131 | + stringTemplate.opsForZSet().add("testzset", "member2", 2.0); |
| 132 | + |
| 133 | + Map<String, Object> result = txTemplate.execute(x -> { |
| 134 | + Map<String, Object> ops = new LinkedHashMap<>(); |
| 135 | + ops.put("rangeWithScores", stringTemplate.opsForZSet().rangeWithScores("testzset", 0, -1)); |
| 136 | + ops.put("reverseRangeWithScores", stringTemplate.opsForZSet().reverseRangeWithScores("testzset", 0, -1)); |
| 137 | + ops.put("rangeByScoreWithScores", stringTemplate.opsForZSet().rangeByScoreWithScores("testzset", 1.0, 2.0)); |
| 138 | + ops.put("reverseRangeByScoreWithScores", stringTemplate.opsForZSet().reverseRangeByScoreWithScores("testzset", 1.0, 2.0)); |
| 139 | + return ops; |
| 140 | + }); |
| 141 | + |
| 142 | + // Issue #3187: All should return data, not null |
| 143 | + assertThat(result.get("rangeWithScores")).isNotNull(); |
| 144 | + assertThat(result.get("reverseRangeWithScores")).isNotNull(); |
| 145 | + assertThat(result.get("rangeByScoreWithScores")).isNotNull(); |
| 146 | + assertThat(result.get("reverseRangeByScoreWithScores")).isNotNull(); |
| 147 | + } |
| 148 | + |
119 | 149 | static Stream<Arguments> argumentsStream() { |
120 | 150 |
|
121 | 151 | LettuceConnectionFactory lcf = new LettuceConnectionFactory(SettingsUtils.standaloneConfiguration()); |
|
0 commit comments