Skip to content

Commit

Permalink
CAMEL-11845: Migrate easymock and powermock to mockito
Browse files Browse the repository at this point in the history
Migrate camel-aws SqsEndpointTest from easymock to mockito.
  • Loading branch information
PascalSchumacher committed Sep 28, 2017
1 parent cbc025d commit 7b39fa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
5 changes: 0 additions & 5 deletions components/camel-aws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@
<artifactId>camel-test-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import com.amazonaws.services.sqs.model.ListQueuesResult;

import org.apache.camel.impl.DefaultCamelContext;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;


public class SqsEndpointTest {
Expand All @@ -34,7 +34,7 @@ public class SqsEndpointTest {

@Before
public void setUp() throws Exception {
amazonSQSClient = EasyMock.createMock(AmazonSQSClient.class);
amazonSQSClient = Mockito.mock(AmazonSQSClient.class);

SqsConfiguration config = new SqsConfiguration();
config.setQueueName("test-queue");
Expand All @@ -46,30 +46,27 @@ public void setUp() throws Exception {

@Test
public void doStartShouldNotCallUpdateQueueAttributesIfQueueExistAndNoOptionIsSpecified() throws Exception {
EasyMock.expect(amazonSQSClient.listQueues())
.andReturn(new ListQueuesResult().withQueueUrls("https://sqs.us-east-1.amazonaws.com/ID/dummy-queue", "https://sqs.us-east-1.amazonaws.com/ID/test-queue"));

EasyMock.replay(amazonSQSClient);
Mockito.when(amazonSQSClient.listQueues())
.thenReturn(new ListQueuesResult().withQueueUrls("https://sqs.us-east-1.amazonaws.com/ID/dummy-queue", "https://sqs.us-east-1.amazonaws.com/ID/test-queue"));

endpoint.doStart();

EasyMock.verify(amazonSQSClient);
Mockito.verify(amazonSQSClient).listQueues();
}

@Test
public void doStartWithDifferentQueueOwner() throws Exception {

EasyMock.expect(amazonSQSClient.getQueueUrl(new GetQueueUrlRequest("test-queue")
.withQueueOwnerAWSAccountId("111222333")))
.andReturn(new GetQueueUrlResult()
GetQueueUrlRequest expectedGetQueueUrlRequest = new GetQueueUrlRequest("test-queue")
.withQueueOwnerAWSAccountId("111222333");
Mockito.when(amazonSQSClient.getQueueUrl(expectedGetQueueUrlRequest))
.thenReturn(new GetQueueUrlResult()
.withQueueUrl("https://sqs.us-east-1.amazonaws.com/111222333/test-queue"));

EasyMock.replay(amazonSQSClient);

endpoint.getConfiguration().setQueueOwnerAWSAccountId("111222333");
endpoint.doStart();

EasyMock.verify(amazonSQSClient);
Mockito.verify(amazonSQSClient).getQueueUrl(expectedGetQueueUrlRequest);

}
}

0 comments on commit 7b39fa9

Please sign in to comment.