From 37b3bb9b015069ba5e9ad1845de30467decb61d4 Mon Sep 17 00:00:00 2001 From: Shiwei Tian Date: Mon, 9 Apr 2018 09:32:39 +0800 Subject: fix https bug Issue-ID: HOLMES-104 Change-Id: I6922584f94aa0ec79fda1e2b3dcc7da6c874c9da Signed-off-by: Shiwei Tian --- .../rulemgt/bolt/enginebolt/EngineServiceTest.java | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'rulemgt/src/test') 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 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 -- cgit 1.2.3-korg