Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace EasyMock with Mockito #287

Merged
merged 1 commit into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@
<version>1.9.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>4.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.Test;

import org.springframework.classify.BinaryExceptionClassifier;
import org.springframework.retry.RecoveryCallback;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryContext;
import org.springframework.retry.TerminatedRetryException;
Expand All @@ -33,20 +32,20 @@
import org.springframework.retry.policy.NeverRetryPolicy;
import org.springframework.retry.policy.SimpleRetryPolicy;

import static org.easymock.EasyMock.createStrictMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

/**
* @author Rob Harrop
* @author Dave Syer
* @author Gary Russell
*/
public class RetryTemplateTests {

Expand Down Expand Up @@ -320,14 +319,13 @@ public void testNoBackOffForRethrownException() {
RetryTemplate tested = new RetryTemplate();
tested.setRetryPolicy(new SimpleRetryPolicy(1));

BackOffPolicy bop = createStrictMock(BackOffPolicy.class);
BackOffPolicy bop = mock(BackOffPolicy.class);
@SuppressWarnings("serial")
BackOffContext backOffContext = new BackOffContext() {
};
tested.setBackOffPolicy(bop);

expect(bop.start(isA(RetryContext.class))).andReturn(backOffContext);
replay(bop);
given(bop.start(any())).willReturn(backOffContext);

try {
tested.execute(context -> {
Expand All @@ -345,8 +343,7 @@ public boolean rollbackFor(Throwable exception) {
catch (Exception expected) {
assertEquals("maybe next time!", expected.getMessage());
}

verify(bop);
verify(bop).start(any());
}

private static class MockRetryCallback implements RetryCallback<Object, Exception> {
Expand Down