From fa337c7571edf97800fc47cdb404160f7da97c8b Mon Sep 17 00:00:00 2001 From: "dave.adams (da490c)" Date: Tue, 12 Sep 2017 12:14:02 -0400 Subject: Expose ssl protocol config Issue-ID: AAI-127 Change-Id: I657144887df8ec36b73d0506902ca4d324dd794a Signed-off-by: dave.adams (da490c) --- .../aai/restclient/client/RestfulClientTest.java | 26 ++++++++++++++++++++++ .../aai/restclient/rest/RestClientBuilderTest.java | 10 +++++++++ 2 files changed, 36 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/org/onap/aai/restclient/client/RestfulClientTest.java b/src/test/java/org/onap/aai/restclient/client/RestfulClientTest.java index 0e5c84e..1f528ae 100644 --- a/src/test/java/org/onap/aai/restclient/client/RestfulClientTest.java +++ b/src/test/java/org/onap/aai/restclient/client/RestfulClientTest.java @@ -28,6 +28,7 @@ import javax.ws.rs.core.Response.Status; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.onap.aai.restclient.client.OperationResult; import org.onap.aai.restclient.client.RestClient; @@ -167,6 +168,31 @@ public class RestfulClientTest { assertNull(result.getResult()); assertNull(result.getFailureCause()); } + + @Test + public void validateSuccessfulPost_withMultivaluedHeader() throws Exception { + RestClient restClient = buildClient(); + + MultivaluedMapImpl headerMap = new MultivaluedMapImpl(); + + headerMap.add("txnId", "123"); + headerMap.add("txnId", "456"); + headerMap.add("txnId", "789"); + + OperationResult result = restClient.post(TEST_URL, "", headerMap, MediaType.APPLICATION_JSON_TYPE, + MediaType.APPLICATION_JSON_TYPE); + + // capture the txnId header from the outgoing request + ArgumentCaptor txnIdHeaderName = ArgumentCaptor.forClass(String.class); + ArgumentCaptor txnIdHeaderValue = ArgumentCaptor.forClass(String.class); + + Mockito.verify(mockedBuilder, Mockito.atLeast(1)).header(txnIdHeaderName.capture(), txnIdHeaderValue.capture()); + assertEquals("123;456;789", txnIdHeaderValue.getValue()); + + assertEquals(Response.Status.OK.getStatusCode(), result.getResultCode()); + assertNotNull(result.getResult()); + assertNull(result.getFailureCause()); + } @Test public void validateSuccessfulGet() throws Exception { diff --git a/src/test/java/org/onap/aai/restclient/rest/RestClientBuilderTest.java b/src/test/java/org/onap/aai/restclient/rest/RestClientBuilderTest.java index 013f817..5e7d8c1 100644 --- a/src/test/java/org/onap/aai/restclient/rest/RestClientBuilderTest.java +++ b/src/test/java/org/onap/aai/restclient/rest/RestClientBuilderTest.java @@ -269,5 +269,15 @@ public class RestClientBuilderTest { } + @Test + public void validateSslProtocolConfiguration() throws Exception { + + RestClientBuilder restClientBuilder = new RestClientBuilder(); + assertEquals(RestClientBuilder.DEFAULT_SSL_PROTOCOL, restClientBuilder.getSslProtocol()); + + restClientBuilder.setSslProtocol("TLSv1.2"); + assertEquals("TLSv1.2", restClientBuilder.getSslProtocol()); + + } } -- cgit 1.2.3-korg