Change-Id: Ia09126b06ad43f05582ae0f3dd8692df223953fe
Issue-ID: HOLMES-207
Signed-off-by: tang peng <tang.peng5@zte.com.cn>
<parent>\r
<groupId>org.onap.holmes.common</groupId>\r
<artifactId>holmes-common-parent</artifactId>\r
<parent>\r
<groupId>org.onap.holmes.common</groupId>\r
<artifactId>holmes-common-parent</artifactId>\r
- <version>1.2.7</version>\r
+ <version>1.2.8</version>\r
</parent>\r
\r
<name>holmes-common-service</name>\r
</parent>\r
\r
<name>holmes-common-service</name>\r
CloseableHttpClient httpClient = null;
HttpGet httpGet = new HttpGet(url);
try {
CloseableHttpClient httpClient = null;
HttpGet httpGet = new HttpGet(url);
try {
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ httpClient = HttpsUtils.getHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
HttpResponse httpResponse = HttpsUtils.get(httpGet, getHeaders(), httpClient);
response = HttpsUtils.extractResponseEntity(httpResponse);
} catch (Exception e) {
HttpResponse httpResponse = HttpsUtils.get(httpGet, getHeaders(), httpClient);
response = HttpsUtils.extractResponseEntity(httpResponse);
} catch (Exception e) {
\r
import java.io.IOException;\r
import lombok.extern.slf4j.Slf4j;\r
\r
import java.io.IOException;\r
import lombok.extern.slf4j.Slf4j;\r
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;\r
import org.apache.http.client.methods.HttpPost;\r
import org.apache.http.impl.client.CloseableHttpClient;\r
import org.onap.holmes.common.dmaap.entity.PolicyMsg;\r
import org.onap.holmes.common.exception.CorrelationException;\r
import org.apache.http.client.methods.HttpPost;\r
import org.apache.http.impl.client.CloseableHttpClient;\r
import org.onap.holmes.common.dmaap.entity.PolicyMsg;\r
import org.onap.holmes.common.exception.CorrelationException;\r
-import com.alibaba.fastjson.JSON;\r
import com.google.gson.Gson;\r
import java.util.HashMap;\r
import javax.ws.rs.core.MediaType;\r
import com.google.gson.Gson;\r
import java.util.HashMap;\r
import javax.ws.rs.core.MediaType;\r
CloseableHttpClient httpClient = null;\r
HttpPost httpPost = new HttpPost(url);\r
try {\r
CloseableHttpClient httpClient = null;\r
HttpPost httpPost = new HttpPost(url);\r
try {\r
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
+ httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);\r
httpResponse = HttpsUtils.post(httpPost, headers, new HashMap<>(), new StringEntity(content, "utf-8"), httpClient);\r
} catch (Exception e) {\r
throw new CorrelationException("Failed to connect to DCAE.", e);\r
httpResponse = HttpsUtils.post(httpPost, headers, new HashMap<>(), new StringEntity(content, "utf-8"), httpClient);\r
} catch (Exception e) {\r
throw new CorrelationException("Failed to connect to DCAE.", e);\r
/**
* Copyright 2017 ZTE Corporation.
/**
* Copyright 2017 ZTE Corporation.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.jvnet.hk2.annotations.Service;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.jvnet.hk2.annotations.Service;
+import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.holmes.common.exception.CorrelationException;
@Slf4j
import org.onap.holmes.common.exception.CorrelationException;
@Slf4j
private static SSLContextBuilder sslContextBuilder = null;
public static final int DEFUALT_TIMEOUT = 30000;
private static SSLContextBuilder sslContextBuilder = null;
public static final int DEFUALT_TIMEOUT = 30000;
try {
sslContextBuilder = new SSLContextBuilder();
sslContextBuilder.loadTrustMaterial(null, new TrustStrategy() {
try {
sslContextBuilder = new SSLContextBuilder();
sslContextBuilder.loadTrustMaterial(null, new TrustStrategy() {
}
public static HttpResponse post(HttpPost httpPost, Map<String, String> header, Map<String, String> param,
}
public static HttpResponse post(HttpPost httpPost, Map<String, String> header, Map<String, String> param,
- HttpEntity entity, CloseableHttpClient httpClient) throws CorrelationException {
+ HttpEntity entity, CloseableHttpClient httpClient) throws CorrelationException {
return getPostAndPutResponse(httpPost, header, param, entity, httpClient);
}
public static HttpResponse put(HttpPut httpPut, Map<String, String> header, Map<String, String> param,
return getPostAndPutResponse(httpPost, header, param, entity, httpClient);
}
public static HttpResponse put(HttpPut httpPut, Map<String, String> header, Map<String, String> param,
- HttpEntity entity, CloseableHttpClient httpClient) throws CorrelationException {
+ HttpEntity entity, CloseableHttpClient httpClient) throws CorrelationException {
return getPostAndPutResponse(httpPut, header, param, entity, httpClient);
}
return getPostAndPutResponse(httpPut, header, param, entity, httpClient);
}
}
private static HttpResponse getPostAndPutResponse(HttpEntityEnclosingRequestBase requestBase,
}
private static HttpResponse getPostAndPutResponse(HttpEntityEnclosingRequestBase requestBase,
- Map<String, String> header, Map<String, String> param, HttpEntity entity,
- CloseableHttpClient httpClient) throws CorrelationException {
+ Map<String, String> header, Map<String, String> param, HttpEntity entity,
+ CloseableHttpClient httpClient) throws CorrelationException {
try {
addHeaders(header, requestBase);
addParams(param, requestBase);
try {
addHeaders(header, requestBase);
addParams(param, requestBase);
}
private static HttpResponse getGetAndDeleteResponse(HttpRequestBase requestBase,
}
private static HttpResponse getGetAndDeleteResponse(HttpRequestBase requestBase,
- Map<String, String> header, CloseableHttpClient httpClient) throws CorrelationException {
+ Map<String, String> header, CloseableHttpClient httpClient) throws CorrelationException {
try {
addHeaders(header, requestBase);
return executeRequest(httpClient, requestBase);
try {
addHeaders(header, requestBase);
return executeRequest(httpClient, requestBase);
try {
httpResponse = httpClient.execute(httpRequest);
} catch (Exception e) {
try {
httpResponse = httpClient.execute(httpRequest);
} catch (Exception e) {
- throw new CorrelationException("Failed to get data from server" ,e);
+ throw new CorrelationException("Failed to get data from server", e);
- public static CloseableHttpClient getHttpClient(int timeout) {
+ public static CloseableHttpClient getConditionalHttpsClient(int timeout) {
+ HttpClientBuilder builder = getHttpClientBuilder(timeout);
+ if (isHttpsEnabled()) {
+ builder.setSSLSocketFactory(sslConnectionSocketFactory);
+ }
+
+ return builder.build();
+ }
+
+ public static CloseableHttpClient getHttpsClient(int timeout) {
+ HttpClientBuilder builder = getHttpClientBuilder(timeout);
+ return builder.setSSLSocketFactory(sslConnectionSocketFactory).build();
+ }
+
+ private static HttpClientBuilder getHttpClientBuilder(int timeout) {
RequestConfig defaultRequestConfig = RequestConfig.custom()
.setSocketTimeout(timeout)
.setConnectTimeout(timeout)
.setConnectionRequestTimeout(timeout)
.build();
RequestConfig defaultRequestConfig = RequestConfig.custom()
.setSocketTimeout(timeout)
.setConnectTimeout(timeout)
.setConnectionRequestTimeout(timeout)
.build();
- CloseableHttpClient httpClient = HttpClients.custom()
+
+ return HttpClients.custom()
.setDefaultRequestConfig(defaultRequestConfig)
.setDefaultRequestConfig(defaultRequestConfig)
- .setSSLSocketFactory(sslConnectionSocketFactory)
.setConnectionManager(connectionManager)
.setConnectionManager(connectionManager)
- .setConnectionManagerShared(true)
- .build();
- return httpClient;
+ .setConnectionManagerShared(true);
+ }
+
+ public static boolean isHttpsEnabled() {
+ return Boolean.valueOf(MicroServiceConfig.getEnv("ENABLE_ENCRYPT"));
package org.onap.holmes.common.aai;
import static org.easymock.EasyMock.anyObject;
package org.onap.holmes.common.aai;
import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.expect;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.easymock.EasyMock;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.easymock.EasyMock;
+import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
private AaiQuery aaiQuery;
private AaiResponseUtil aaiResponseUtil;
private AaiQuery aaiQuery;
private AaiResponseUtil aaiResponseUtil;
+ @BeforeClass
+ static public void before() {
+ System.setProperty("ENABLE_ENCRYPT", "true");
+ }
+
@Test
public void testAaiQuery_getAaiVnfData_ok() throws Exception {
PowerMock.resetAll();
@Test
public void testAaiQuery_getAaiVnfData_ok() throws Exception {
PowerMock.resetAll();
aaiQuery = PowerMock.createPartialMock(AaiQuery.class, "getVmResourceLinks");
aaiResponseUtil = new AaiResponseUtil();
Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil);
aaiQuery = PowerMock.createPartialMock(AaiQuery.class, "getVmResourceLinks");
aaiResponseUtil = new AaiResponseUtil();
Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil);
- PowerMockito.mockStatic(HttpsUtils.class);
+ PowerMock.mockStatic(HttpsUtils.class);
Map<String, String> headers = new HashMap<>();
headers.put("X-TransactionId", AaiConfig.X_TRANSACTION_ID);
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
Map<String, String> headers = new HashMap<>();
headers.put("X-TransactionId", AaiConfig.X_TRANSACTION_ID);
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
String url = "https://aai.onap:8443/aai/v11/cloud-infrastructure";
HttpResponse httpResponse = PowerMock.createMock(HttpResponse.class);
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
String url = "https://aai.onap:8443/aai/v11/cloud-infrastructure";
HttpResponse httpResponse = PowerMock.createMock(HttpResponse.class);
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
- when(HttpsUtils.getHttpClient(30000)).thenReturn(httpClient);
+ expect(HttpsUtils.getHttpsClient(30000)).andReturn(httpClient);
HttpGet httpGet = new HttpGet(url);
PowerMock.expectNew(HttpGet.class, url).andReturn(httpGet);
HttpGet httpGet = new HttpGet(url);
PowerMock.expectNew(HttpGet.class, url).andReturn(httpGet);
- when(HttpsUtils.get(httpGet, headers, httpClient)).thenReturn(httpResponse);
- when(HttpsUtils.extractResponseEntity(httpResponse)).thenReturn("{}");
+ expect(HttpsUtils.get(anyObject(HttpGet.class), anyObject(Map.class),
+ anyObject(CloseableHttpClient.class))).andReturn(httpResponse);
+ expect(HttpsUtils.extractResponseEntity(httpResponse)).andReturn("{}");
PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2")
.andReturn("/aai/v11/cloud-infrastructure");
PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2")
.andReturn("/aai/v11/cloud-infrastructure");
public void testAaiQuery_getAaiVmData_httpsutils_exception() throws Exception {
PowerMock.resetAll();
thrown.expect(CorrelationException.class);
public void testAaiQuery_getAaiVmData_httpsutils_exception() throws Exception {
PowerMock.resetAll();
thrown.expect(CorrelationException.class);
aaiResponseUtil = new AaiResponseUtil();
Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil);
aaiResponseUtil = new AaiResponseUtil();
Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil);
- PowerMockito.mockStatic(HttpsUtils.class);
+ PowerMock.mockStatic(HttpsUtils.class);
Map<String, String> headers = new HashMap<>();
headers.put("X-TransactionId", AaiConfig.X_TRANSACTION_ID);
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
Map<String, String> headers = new HashMap<>();
headers.put("X-TransactionId", AaiConfig.X_TRANSACTION_ID);
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
headers.put("Accept", "application/json");
String url = "https://aai.onap:8443/aai/v11/cloud-infrastructure";
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
headers.put("Accept", "application/json");
String url = "https://aai.onap:8443/aai/v11/cloud-infrastructure";
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
- when(HttpsUtils.getHttpClient(30000)).thenReturn(httpClient);
+ EasyMock.expect(HttpsUtils.getHttpsClient(30000)).andReturn(httpClient);
HttpGet httpGet = new HttpGet(url);
PowerMock.expectNew(HttpGet.class, url).andReturn(httpGet);
HttpGet httpGet = new HttpGet(url);
PowerMock.expectNew(HttpGet.class, url).andReturn(httpGet);
- when(HttpsUtils.get(httpGet, headers, httpClient)).thenThrow(new CorrelationException(""));
- PowerMockito.mockStatic(MicroServiceConfig.class);
+ EasyMock.expect(HttpsUtils.get(anyObject(HttpGet.class), anyObject(Map.class),
+ anyObject(CloseableHttpClient.class))).andThrow(new CorrelationException(""));
+ PowerMock.mockStatic(MicroServiceConfig.class);
PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2")
.andReturn("/aai/v11/cloud-infrastructure");
PowerMock.expectPrivate(httpClient,"close");
PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2")
.andReturn("/aai/v11/cloud-infrastructure");
PowerMock.expectPrivate(httpClient,"close");
public void testAaiQuery_getResponse_ok() throws Exception {
PowerMock.resetAll();
aaiQuery = new AaiQuery();
public void testAaiQuery_getResponse_ok() throws Exception {
PowerMock.resetAll();
aaiQuery = new AaiQuery();
- PowerMockito.mockStatic(HttpsUtils.class);
+ PowerMock.mockStatic(HttpsUtils.class);
Map<String, String> headers = new HashMap<>();
headers.put("X-TransactionId", AaiConfig.X_TRANSACTION_ID);
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
Map<String, String> headers = new HashMap<>();
headers.put("X-TransactionId", AaiConfig.X_TRANSACTION_ID);
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
HttpResponse httpResponse = PowerMock.createMock(HttpResponse.class);
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
HttpResponse httpResponse = PowerMock.createMock(HttpResponse.class);
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
- when(HttpsUtils.getHttpClient(30000)).thenReturn(httpClient);
+ expect(HttpsUtils.getHttpsClient(30000)).andReturn(httpClient);
HttpGet httpGet = new HttpGet(url);
PowerMock.expectNew(HttpGet.class, url).andReturn(httpGet);
HttpGet httpGet = new HttpGet(url);
PowerMock.expectNew(HttpGet.class, url).andReturn(httpGet);
- when(HttpsUtils.get(httpGet, headers, httpClient)).thenReturn(httpResponse);
- when(HttpsUtils.extractResponseEntity(httpResponse)).thenReturn("");
+ expect(HttpsUtils.get(anyObject(HttpGet.class), anyObject(Map.class),
+ anyObject(CloseableHttpClient.class))).andReturn(httpResponse);
+ expect(HttpsUtils.extractResponseEntity(httpResponse)).andReturn("");
PowerMock.expectPrivate(httpClient, "close");
EasyMock.expectLastCall();
PowerMock.expectPrivate(httpClient, "close");
EasyMock.expectLastCall();
thrown.expectMessage("Failed to get data from aai");
aaiQuery = new AaiQuery();
thrown.expectMessage("Failed to get data from aai");
aaiQuery = new AaiQuery();
- PowerMockito.mockStatic(HttpsUtils.class);
+ PowerMock.mockStatic(HttpsUtils.class);
Map<String, String> headers = new HashMap<>();
headers.put("X-TransactionId", AaiConfig.X_TRANSACTION_ID);
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
Map<String, String> headers = new HashMap<>();
headers.put("X-TransactionId", AaiConfig.X_TRANSACTION_ID);
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
headers.put("Accept", "application/json");
String url = "host_url";
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
headers.put("Accept", "application/json");
String url = "host_url";
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
- when(HttpsUtils.getHttpClient(30000)).thenReturn(httpClient);
+ expect(HttpsUtils.getHttpsClient(30000)).andReturn(httpClient);
HttpGet httpGet = new HttpGet(url);
PowerMock.expectNew(HttpGet.class, url).andReturn(httpGet);
HttpGet httpGet = new HttpGet(url);
PowerMock.expectNew(HttpGet.class, url).andReturn(httpGet);
- when(HttpsUtils.get(httpGet, headers, httpClient)).thenThrow(new CorrelationException(""));
+ expect(HttpsUtils.get(httpGet, headers, httpClient)).andThrow(new CorrelationException(""));
PowerMock.expectPrivate(httpClient, "close");
EasyMock.expectLastCall();
PowerMock.replayAll();
PowerMock.expectPrivate(httpClient, "close");
EasyMock.expectLastCall();
PowerMock.replayAll();
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
-import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Rule;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Rule;
String url = "host";
Map<String, String> header = new HashMap<>();
header.put("accept", "application/json");
String url = "host";
Map<String, String> header = new HashMap<>();
header.put("accept", "application/json");
- CloseableHttpClient httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ CloseableHttpClient httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
HttpGet httpRequestBase = new HttpGet(url);
HttpResponse httpResponse = HttpsUtils.get(httpRequestBase, header, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
HttpGet httpRequestBase = new HttpGet(url);
HttpResponse httpResponse = HttpsUtils.get(httpRequestBase, header, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
Map<String, String> header = new HashMap<>();
header.put("accept", "application/json");
HttpDelete httpRequestBase = new HttpDelete(url);
Map<String, String> header = new HashMap<>();
header.put("accept", "application/json");
HttpDelete httpRequestBase = new HttpDelete(url);
- CloseableHttpClient httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ CloseableHttpClient httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
HttpResponse httpResponse = HttpsUtils.delete(httpRequestBase, header, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
assertThat(response, equalTo(""));
HttpResponse httpResponse = HttpsUtils.delete(httpRequestBase, header, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
assertThat(response, equalTo(""));
header.put("accept", "application/json");
Map<String, String> para = new HashMap<>();
para.put("tset", "1111");
header.put("accept", "application/json");
Map<String, String> para = new HashMap<>();
para.put("tset", "1111");
- CloseableHttpClient httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ CloseableHttpClient httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = HttpsUtils.post(httpPost, header, para, null, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = HttpsUtils.post(httpPost, header, para, null, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
header.put("accept", "application/json");
Map<String, String> para = new HashMap<>();
para.put("tset", "1111");
header.put("accept", "application/json");
Map<String, String> para = new HashMap<>();
para.put("tset", "1111");
- CloseableHttpClient httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ CloseableHttpClient httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
HttpPut httpPut = new HttpPut(url);
HttpResponse httpResponse = HttpsUtils.put(httpPut, header, para, null, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
HttpPut httpPut = new HttpPut(url);
HttpResponse httpResponse = HttpsUtils.put(httpPut, header, para, null, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
public void testHttpsUtil_getHttpClient_exception() throws Exception {
PowerMock.resetAll();
thrown.expect(Exception.class);
public void testHttpsUtil_getHttpClient_exception() throws Exception {
PowerMock.resetAll();
thrown.expect(Exception.class);
- Whitebox.invokeMethod(HttpsUtils.class, "getHttpClient");
+ Whitebox.invokeMethod(HttpsUtils.class, "getConditionalHttpsClient");
PowerMock.verifyAll();
}
@Test
public void testHttpsUtil_getHttpClient_ok() throws Exception {
PowerMock.resetAll();
PowerMock.verifyAll();
}
@Test
public void testHttpsUtil_getHttpClient_ok() throws Exception {
PowerMock.resetAll();
- HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
<artifactId>holmes-common-parent</artifactId>\r
<packaging>pom</packaging>\r
\r
<artifactId>holmes-common-parent</artifactId>\r
<packaging>pom</packaging>\r
\r
- <version>1.2.7</version>\r
+ <version>1.2.8</version>\r
<name>holmes-common</name>\r
<modules>\r
<module>holmes-actions</module>\r
<name>holmes-common</name>\r
<modules>\r
<module>holmes-actions</module>\r
\r
base_version=${major}.${minor}.${patch}\r
\r
\r
base_version=${major}.${minor}.${patch}\r
\r