Search in sources :

Example 6 with MapRetryContextCache

use of cn.taketoday.retry.policy.MapRetryContextCache in project today-framework by TAKETODAY.

the class CircuitBreakerStatisticsTests method init.

@Before
public void init() {
    this.callback = new MockRetryCallback();
    this.recovery = new RecoveryCallback<Object>() {

        @Override
        public Object recover(RetryContext context) throws Exception {
            return RECOVERED;
        }
    };
    this.retryTemplate = new RetryTemplate();
    this.cache = new MapRetryContextCache();
    this.retryTemplate.setRetryContextCache(this.cache);
    retryTemplate.setListeners(new RetryListener[] { listener });
    this.callback.setAttemptsBeforeSuccess(1);
    // No rollback by default (so exceptions are not rethrown)
    this.state = new DefaultRetryState("retry", new BinaryExceptionClassifier(false));
}
Also used : MapRetryContextCache(cn.taketoday.retry.policy.MapRetryContextCache) RetryTemplate(cn.taketoday.retry.support.RetryTemplate) BinaryExceptionClassifier(cn.taketoday.classify.BinaryExceptionClassifier) DefaultRetryState(cn.taketoday.retry.support.DefaultRetryState) RetryContext(cn.taketoday.retry.RetryContext) ExhaustedRetryException(cn.taketoday.retry.ExhaustedRetryException) Before(org.junit.Before)

Aggregations

ExhaustedRetryException (cn.taketoday.retry.ExhaustedRetryException)6 RetryContext (cn.taketoday.retry.RetryContext)6 MapRetryContextCache (cn.taketoday.retry.policy.MapRetryContextCache)6 BinaryExceptionClassifier (cn.taketoday.classify.BinaryExceptionClassifier)4 DataAccessException (cn.taketoday.dao.DataAccessException)4 RecoveryCallback (cn.taketoday.retry.RecoveryCallback)4 RetryCallback (cn.taketoday.retry.RetryCallback)4 RetryException (cn.taketoday.retry.RetryException)4 RetryState (cn.taketoday.retry.RetryState)4 SimpleRetryPolicy (cn.taketoday.retry.policy.SimpleRetryPolicy)4 Test (org.junit.Test)4 RetryPolicy (cn.taketoday.retry.RetryPolicy)2 NeverRetryPolicy (cn.taketoday.retry.policy.NeverRetryPolicy)2 DefaultRetryState (cn.taketoday.retry.support.DefaultRetryState)2 RetryTemplate (cn.taketoday.retry.support.RetryTemplate)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertFalse (org.junit.Assert.assertFalse)2