@Test
	@SuppressWarnings("unchecked")
	public void shouldRetryAndRecoverAfter2FailedAttempts() {
		RetryTemplate retry = new RetryTemplate();
		retry.setListeners(new RetryListener[] {retryListenerMock});
		template.setRetryOperations(retry);
		// 1st call
		doThrow(new JedisException("dummy"))
				// 2nd call
				.doThrow(new JedisException("dummy"))
						// 3rd call
				.doNothing().when(redisConnectionMock).set((byte[]) any(), (byte[]) any());
		template.opsForValue().set("a", "b");
		verify(retryListenerMock, times(2))
				.onError(any(RetryContext.class), any(RetryCallback.class), any(Throwable.class));
	}
@author Christoph Strobl
@author Thomas Darimont
spring-xd-analytics/src/test/java/org/springframework/xd/analytics/metrics/redis/RedisRetryTemplateTests.java