diff options
author | Shiwei Tian <tian.shiwei@zte.com.cn> | 2018-04-09 09:32:39 +0800 |
---|---|---|
committer | Shiwei Tian <tian.shiwei@zte.com.cn> | 2018-04-09 09:32:39 +0800 |
commit | 37b3bb9b015069ba5e9ad1845de30467decb61d4 (patch) | |
tree | 2ddfa4adfb99e78353dc5a402131b03dce60a82d /rulemgt/src/test | |
parent | 1985d463e60ab79a2fadc4065a9ea19861933692 (diff) |
fix https bug
Issue-ID: HOLMES-104
Change-Id: I6922584f94aa0ec79fda1e2b3dcc7da6c874c9da
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
Diffstat (limited to 'rulemgt/src/test')
-rw-r--r-- | rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java index b3cb93d..836b210 100644 --- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java +++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java @@ -18,19 +18,31 @@ package org.onap.holmes.rulemgt.bolt.enginebolt;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.any;
+import static org.hamcrest.Matchers.equalTo;
+
+import java.util.HashMap;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
+import org.easymock.EasyMock;
+import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Rule;
+import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.holmes.common.utils.HttpsUtils;
import org.onap.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
+import org.powermock.reflect.Whitebox;
-@PrepareForTest({HttpClients.class, CloseableHttpClient.class})
+@PrepareForTest({HttpClients.class, CloseableHttpClient.class, HttpsUtils.class})
+@PowerMockIgnore("javax.net.ssl.*")
public class EngineServiceTest {
@Rule
@@ -53,4 +65,21 @@ public class EngineServiceTest { correlationDeployRule4Engine.setContent("{\"package\":\"test\"}");
correlationDeployRule4Engine.setEngineId("engine_id");
}
+
+ @Test
+ public void testEngineService_createHeaders_ok() throws Exception {
+ PowerMock.resetAll();
+ HashMap<String, String> headers = Whitebox.invokeMethod(engineService, "createHeaders");
+ assertThat(headers.get("Content-Type"), equalTo("application/json"));
+ assertThat(headers.get("Accept"), equalTo("application/json"));
+ }
+
+ @Test
+ public void testEngineService_closeHttpClient_ok() throws Exception {
+ PowerMock.resetAll();
+ CloseableHttpClient closeableHttpClient = HttpsUtils
+ .getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ Whitebox.invokeMethod(engineService, "closeHttpClient", closeableHttpClient);
+ }
+
}
\ No newline at end of file |