|
20 | 20 | import static org.mockito.Matchers.*; |
21 | 21 | import static org.mockito.Mockito.*; |
22 | 22 |
|
23 | | -import java.util.Arrays; |
24 | | -import java.util.concurrent.TimeUnit; |
25 | | - |
26 | 23 | import org.junit.Before; |
27 | 24 | import org.junit.Test; |
28 | 25 | import org.junit.runner.RunWith; |
|
34 | 31 | import org.springframework.data.redis.connection.RedisServerCommands.ShutdownOption; |
35 | 32 | import org.springframework.data.redis.connection.jedis.JedisConnectionUnitTestSuite.JedisConnectionPipelineUnitTests; |
36 | 33 | import org.springframework.data.redis.connection.jedis.JedisConnectionUnitTestSuite.JedisConnectionUnitTests; |
37 | | -import org.springframework.data.redis.core.TimeoutUtils; |
38 | 34 |
|
39 | 35 | import redis.clients.jedis.Client; |
40 | 36 | import redis.clients.jedis.Jedis; |
@@ -97,24 +93,6 @@ public void shutdownSaveShouldBeSentCorrectlyUsingLuaScript() { |
97 | 93 | assertThat(captor.getValue(), equalTo("return redis.call('SHUTDOWN','SAVE')".getBytes())); |
98 | 94 | } |
99 | 95 |
|
100 | | -/** |
101 | | - * @see DATAREDIS-286 |
102 | | - */ |
103 | | -@Test |
104 | | -public void pExpireHavingIntOverflowShouldUseRedisServerTimeAsReferenceForPExpireAt() { |
105 | | - |
106 | | -long msec = Long.valueOf((long) Integer.MAX_VALUE + 1); |
107 | | -long expected = msec + TimeoutUtils.toMillis(1, TimeUnit.SECONDS); |
108 | | - |
109 | | -/* redis time as list containing [0] = seconds, [1] = microseconds |
110 | | - * @see http://redis.io/commands/time |
111 | | - */ |
112 | | -when(jedisSpy.time()).thenReturn(Arrays.asList("1", "0")); |
113 | | - |
114 | | -connection.pExpire("foo".getBytes(), msec); |
115 | | -verifyNativeConnectionInvocation().pexpireAt(any(byte[].class), eq(expected)); |
116 | | -} |
117 | | - |
118 | 96 | /** |
119 | 97 | * @see DATAREDIS-267 |
120 | 98 | */ |
@@ -171,6 +149,62 @@ public void shouldThrowExceptionWhenAccessingRedisSentinelsCommandsWhenNoSentine |
171 | 149 | connection.getSentinelConnection(); |
172 | 150 | } |
173 | 151 |
|
| 152 | +/** |
| 153 | + * @see DATAREDIS-472 |
| 154 | + */ |
| 155 | +@Test(expected = IllegalArgumentException.class) |
| 156 | +public void restoreShouldThrowExceptionWhenTtlInMillisExceedsIntegerRange() { |
| 157 | +connection.restore("foo".getBytes(), new Long(Integer.MAX_VALUE) + 1L, "bar".getBytes()); |
| 158 | +} |
| 159 | + |
| 160 | +/** |
| 161 | + * @see DATAREDIS-472 |
| 162 | + */ |
| 163 | +@Test(expected = IllegalArgumentException.class) |
| 164 | +public void setExShouldThrowExceptionWhenTimeExceedsIntegerRange() { |
| 165 | +connection.setEx("foo".getBytes(), new Long(Integer.MAX_VALUE) + 1L, "bar".getBytes()); |
| 166 | +} |
| 167 | + |
| 168 | +/** |
| 169 | + * @see DATAREDIS-472 |
| 170 | + */ |
| 171 | +@Test(expected = IllegalArgumentException.class) |
| 172 | +public void getRangeShouldThrowExceptionWhenStartExceedsIntegerRange() { |
| 173 | +connection.getRange("foo".getBytes(), new Long(Integer.MAX_VALUE) + 1L, Integer.MAX_VALUE); |
| 174 | +} |
| 175 | + |
| 176 | +/** |
| 177 | + * @see DATAREDIS-472 |
| 178 | + */ |
| 179 | +@Test(expected = IllegalArgumentException.class) |
| 180 | +public void getRangeShouldThrowExceptionWhenEndExceedsIntegerRange() { |
| 181 | +connection.getRange("foo".getBytes(), Integer.MAX_VALUE, new Long(Integer.MAX_VALUE) + 1L); |
| 182 | +} |
| 183 | + |
| 184 | +/** |
| 185 | + * @see DATAREDIS-472 |
| 186 | + */ |
| 187 | +@Test(expected = IllegalArgumentException.class) |
| 188 | +public void sRandMemberShouldThrowExceptionWhenCountExceedsIntegerRange() { |
| 189 | +connection.sRandMember("foo".getBytes(), new Long(Integer.MAX_VALUE) + 1L); |
| 190 | +} |
| 191 | + |
| 192 | +/** |
| 193 | + * @see DATAREDIS-472 |
| 194 | + */ |
| 195 | +@Test(expected = IllegalArgumentException.class) |
| 196 | +public void zRangeByScoreShouldThrowExceptionWhenOffsetExceedsIntegerRange() { |
| 197 | +connection.zRangeByScore("foo".getBytes(), "foo", "bar", new Long(Integer.MAX_VALUE) + 1L, Integer.MAX_VALUE); |
| 198 | +} |
| 199 | + |
| 200 | +/** |
| 201 | + * @see DATAREDIS-472 |
| 202 | + */ |
| 203 | +@Test(expected = IllegalArgumentException.class) |
| 204 | +public void zRangeByScoreShouldThrowExceptionWhenCountExceedsIntegerRange() { |
| 205 | +connection.zRangeByScore("foo".getBytes(), "foo", "bar", Integer.MAX_VALUE, new Long(Integer.MAX_VALUE) + 1L); |
| 206 | +} |
| 207 | + |
174 | 208 | } |
175 | 209 |
|
176 | 210 | public static class JedisConnectionPipelineUnitTests extends JedisConnectionUnitTests { |
|
0 commit comments