CAMEL-11845: Migrate easymock and powermock to mockito

Migrate camel-aws SqsEndpointTest from easymock to mockito.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7b39fa9b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7b39fa9b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7b39fa9b

Branch: refs/heads/master
Commit: 7b39fa9bd01f8a8abd94f59ee92439ad5fda7bed
Parents: cbc025d
Author: Pascal Schumacher <pascalschumac...@gmx.net>
Authored: Thu Sep 28 19:26:09 2017 +0200
Committer: Pascal Schumacher <pascalschumac...@gmx.net>
Committed: Thu Sep 28 19:26:09 2017 +0200

----------------------------------------------------------------------
 components/camel-aws/pom.xml                    |  5 -----
 .../component/aws/sqs/SqsEndpointTest.java      | 23 +++++++++-----------
 2 files changed, 10 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7b39fa9b/components/camel-aws/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-aws/pom.xml b/components/camel-aws/pom.xml
index 6125dbe..7b7a714 100644
--- a/components/camel-aws/pom.xml
+++ b/components/camel-aws/pom.xml
@@ -132,11 +132,6 @@
             <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>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/camel/blob/7b39fa9b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java
 
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java
index aa08de6..3052e48 100644
--- 
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java
+++ 
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java
@@ -22,9 +22,9 @@ import com.amazonaws.services.sqs.model.GetQueueUrlResult;
 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 {
@@ -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");
@@ -46,30 +46,27 @@ public class SqsEndpointTest {
 
     @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);
 
     }
 }
\ No newline at end of file

Reply via email to