org.springframework.retry.listener.RetryListenerSupport Java Examples

The following examples show how to use org.springframework.retry.listener.RetryListenerSupport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RetryLoadBalancerInterceptorTest.java    From spring-cloud-commons with Apache License 2.0 6 votes vote down vote up
@Test(expected = TerminatedRetryException.class)
public void retryListenerTestNoRetry() throws Throwable {
	HttpRequest request = mock(HttpRequest.class);
	when(request.getURI()).thenReturn(new URI("http://noRetry"));
	LoadBalancedRetryPolicy policy = mock(LoadBalancedRetryPolicy.class);
	MyBackOffPolicy backOffPolicy = new MyBackOffPolicy();
	this.lbProperties.setEnabled(true);
	RetryListener myRetryListener = new RetryListenerSupport() {
		@Override
		public <T, E extends Throwable> boolean open(RetryContext context,
				RetryCallback<T, E> callback) {
			return false;
		}
	};
	RetryLoadBalancerInterceptor interceptor = new RetryLoadBalancerInterceptor(
			this.client, this.lbProperties, this.lbRequestFactory,
			new MyLoadBalancedRetryFactory(policy, backOffPolicy,
					new RetryListener[] { myRetryListener }));
	ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class);
	interceptor.intercept(request, new byte[] {}, execution);
}