cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [36/50] [abbrv] git commit: updated refs/heads/reporter to 178a938
Date Wed, 04 Mar 2015 10:06:20 GMT
CLOUDSTACK-8294: fix for java 1.8 build

The test testFindSecurityProfileByUuid built an assumptio on the order of the arguments after
transforming through a HashMap.

Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/873649eb
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/873649eb
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/873649eb

Branch: refs/heads/reporter
Commit: 873649eb3b52f2ec25c0e60d2a2465f95c97e428
Parents: ed099c3
Author: Laszlo Hornyak <laszlo.hornyak@gmail.com>
Authored: Sun Mar 1 13:20:51 2015 +0100
Committer: Laszlo Hornyak <laszlo.hornyak@gmail.com>
Committed: Sun Mar 1 13:20:51 2015 +0100

----------------------------------------------------------------------
 .../cloud/network/nicira/NiciraNvpApiTest.java  | 21 ++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/873649eb/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
index 51964bf..1435cc5 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
@@ -20,12 +20,18 @@
 package com.cloud.network.nicira;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Matchers.any;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
@@ -38,10 +44,11 @@ import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.params.HttpClientParams;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
 
 import com.google.gson.Gson;
 import com.google.gson.JsonParseException;
-
 import com.cloud.utils.rest.RESTServiceConnector;
 import com.cloud.utils.rest.RESTValidationStrategy;
 
@@ -144,13 +151,23 @@ public class NiciraNvpApiTest {
                 new NameValuePair("uuid", UUID),
                 new NameValuePair("fields","*")
         };
+        final List<NameValuePair> queryStringNvps = new ArrayList<>();
+        doAnswer(new Answer<Void>() {
+
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                final NameValuePair[] arguments = (NameValuePair[]) invocation.getArguments()[0];
+                queryStringNvps.addAll(Arrays.asList(arguments));
+                return null;
+            }}).when(method).setQueryString(any(NameValuePair[].class));
 
         // Execute
         final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);
 
         // Assert
         verify(method, times(1)).releaseConnection();
-        verify(method, times(1)).setQueryString(queryString);
+        assertTrue(queryStringNvps.containsAll(Arrays.asList(queryString)));
+        assertEquals(queryString.length, queryStringNvps.size());
         assertEquals("Wrong Uuid in the newly created SecurityProfile",
                 UUID, actualProfiles.getResults().get(0).getUuid());
         assertEquals("Wrong Uuid in the newly created SecurityProfile",


Mime
View raw message