Skip to content

Commit

Permalink
Merge branch '3.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjbaxter committed Oct 16, 2024
2 parents 0fd98fd + d2f8834 commit d5574d6
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import io.github.resilience4j.timelimiter.TimeLimiterConfig;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;

import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -61,6 +61,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.internal.verification.VerificationModeFactory.times;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
Expand All @@ -74,16 +76,12 @@
@DirtiesContext
public class Resilience4JBulkheadIntegrationTest {

@Mock
static EventConsumer<CircuitBreakerOnErrorEvent> slowErrorConsumer;

@Mock
static EventConsumer<CircuitBreakerOnSuccessEvent> slowSuccessConsumer;

@Mock
static EventConsumer<CircuitBreakerOnErrorEvent> normalErrorConsumer;

@Mock
static EventConsumer<CircuitBreakerOnSuccessEvent> normalSuccessConsumer;

@Autowired
Expand All @@ -92,6 +90,11 @@ public class Resilience4JBulkheadIntegrationTest {
@Autowired
private TestRestTemplate rest;

@After
public void reset() {
Mockito.clearInvocations(slowErrorConsumer, slowSuccessConsumer, normalErrorConsumer, normalSuccessConsumer);
}

@Test
public void testSlow() {
assertThat(service.slow()).isEqualTo("fallback");
Expand Down Expand Up @@ -201,6 +204,10 @@ public String slowThreadPoolBulkhead() throws InterruptedException {

@Bean
public Customizer<Resilience4JCircuitBreakerFactory> slowCustomizer() {
slowErrorConsumer = mock(EventConsumer.class);
slowSuccessConsumer = mock(EventConsumer.class);
normalErrorConsumer = mock(EventConsumer.class);
normalSuccessConsumer = mock(EventConsumer.class);
lenient().doAnswer(invocation -> {
CircuitBreakerOnErrorEvent event = invocation.getArgument(0, CircuitBreakerOnErrorEvent.class);
LOG.info(event.getCircuitBreakerName() + " error: " + event.getEventType() + " duration: "
Expand Down Expand Up @@ -242,8 +249,8 @@ public Customizer<Resilience4JCircuitBreakerFactory> slowCustomizer() {
};
}

static EventConsumer<BulkheadOnCallRejectedEvent> slowRejectedConsumer = Mockito.mock(EventConsumer.class);
static EventConsumer<BulkheadOnCallFinishedEvent> slowFinishedConsumer = Mockito.mock(EventConsumer.class);
static EventConsumer<BulkheadOnCallRejectedEvent> slowRejectedConsumer = mock(EventConsumer.class);
static EventConsumer<BulkheadOnCallFinishedEvent> slowFinishedConsumer = mock(EventConsumer.class);

@Bean
public Customizer<Resilience4jBulkheadProvider> slowBulkheadProviderCustomizer() {
Expand All @@ -267,10 +274,8 @@ public Customizer<Resilience4jBulkheadProvider> slowBulkheadProviderCustomizer()
};
}

static EventConsumer<BulkheadOnCallRejectedEvent> slowThreadPoolRejectedConsumer = Mockito
.mock(EventConsumer.class);
static EventConsumer<BulkheadOnCallFinishedEvent> slowThreadPoolFinishedConsumer = Mockito
.mock(EventConsumer.class);
static EventConsumer<BulkheadOnCallRejectedEvent> slowThreadPoolRejectedConsumer = mock(EventConsumer.class);
static EventConsumer<BulkheadOnCallFinishedEvent> slowThreadPoolFinishedConsumer = mock(EventConsumer.class);

@Bean
Customizer<Resilience4jBulkheadProvider> slowBulkheadThreadPoolProviderCustomizer() {
Expand Down

0 comments on commit d5574d6

Please sign in to comment.