mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-05-12 17:04:48 +00:00
[ACS-4460] MtlsTestUtils simplify methods
This commit is contained in:
parent
3706bef72b
commit
ad0d4c68f0
@ -62,4 +62,13 @@ public class MtlsTestUtils {
|
||||
}
|
||||
return new RestTemplate(requestFactory);
|
||||
}
|
||||
|
||||
public static RestTemplate getRestTemplate()
|
||||
{
|
||||
return MtlsTestUtils.isMtlsEnabled() ? MtlsTestUtils.restTemplateWithMtls() : new RestTemplate();
|
||||
}
|
||||
|
||||
public static CloseableHttpClient getHttpClient() throws UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, KeyManagementException {
|
||||
return MtlsTestUtils.isMtlsEnabled() ? MtlsTestUtils.httpClientWithMtls() : HttpClients.createDefault();
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
*/
|
||||
public class HttpClient
|
||||
{
|
||||
private static final RestTemplate REST_TEMPLATE = MtlsTestUtils.isMtlsEnabled() ? MtlsTestUtils.restTemplateWithMtls() : new RestTemplate();
|
||||
private static final RestTemplate REST_TEMPLATE = MtlsTestUtils.getRestTemplate();
|
||||
|
||||
public static ResponseEntity<Resource> sendTRequest(
|
||||
final String engineUrl, final String sourceFile,
|
||||
|
@ -32,7 +32,6 @@ import org.apache.http.entity.mime.HttpMultipartMode;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.entity.mime.content.FileBody;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -76,7 +75,7 @@ public class SfsClient
|
||||
.addPart("file", new FileBody(file, ContentType.DEFAULT_BINARY))
|
||||
.build());
|
||||
|
||||
try (CloseableHttpClient client = MtlsTestUtils.isMtlsEnabled() ? MtlsTestUtils.httpClientWithMtls() : HttpClients.createDefault())
|
||||
try (CloseableHttpClient client = MtlsTestUtils.getHttpClient())
|
||||
{
|
||||
final HttpResponse response = client.execute(post);
|
||||
int status = response.getStatusLine().getStatusCode();
|
||||
@ -135,8 +134,7 @@ public class SfsClient
|
||||
sfsBaseUrl+"/alfresco/api/-default-/private/sfs/versions/1/file/{0}",
|
||||
uuid));
|
||||
|
||||
try (CloseableHttpClient client = MtlsTestUtils.isMtlsEnabled() ?
|
||||
MtlsTestUtils.httpClientWithMtls() : HttpClients.createDefault())
|
||||
try (CloseableHttpClient client = MtlsTestUtils.getHttpClient())
|
||||
{
|
||||
final HttpResponse response = client.execute(head);
|
||||
final int status = response.getStatusLine().getStatusCode();
|
||||
@ -155,7 +153,7 @@ public class SfsClient
|
||||
sfsBaseUrl+"/alfresco/api/-default-/private/sfs/versions/1/file/{0}",
|
||||
uuid));
|
||||
|
||||
try (CloseableHttpClient client = HttpClients.createDefault())
|
||||
try (CloseableHttpClient client = MtlsTestUtils.getHttpClient())
|
||||
{
|
||||
final HttpResponse response = client.execute(get);
|
||||
final int status = response.getStatusLine().getStatusCode();
|
||||
|
Loading…
x
Reference in New Issue
Block a user