read and set the jersey client properties 76/109076/1
authorsu622b <su622b@att.com>
Thu, 11 Jun 2020 21:20:09 +0000 (17:20 -0400)
committersu622b <su622b@att.com>
Thu, 11 Jun 2020 21:28:53 +0000 (17:28 -0400)
Issue-ID: DMAAP-1443
Change-Id: I0f92536fa88c2d21a1467f6c92e162cbe46db85f
Signed-off-by: su622b <su622b@att.com>
pom.xml
src/main/java/org/onap/dmaap/mr/client/impl/DmaapClientUtil.java
src/main/java/org/onap/dmaap/mr/client/impl/MRBaseClient.java
src/main/java/org/onap/dmaap/mr/client/impl/MRConsumerImpl.java
src/main/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisher.java
src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java
src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java
version.properties

diff --git a/pom.xml b/pom.xml
index bb1f83b..63ed6d8 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
        <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>
        <artifactId>dmaapClient</artifactId>
        <packaging>jar</packaging>
-       <version>1.1.11-SNAPSHOT</version>
+       <version>1.1.12-SNAPSHOT</version>
        <name>dmaap-messagerouter-dmaapclient</name>
        <description>Client library for MR event routing API</description>
        <url>https://gerrit.onap.org/r/gitweb?p=dmaap/messagerouter/dmaapclient.git</url>
index b06290a..4c50596 100644 (file)
  *******************************************************************************/
 package org.onap.dmaap.mr.client.impl;
 
+import java.util.Properties;
+
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Response;
 
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
 import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 
 public class DmaapClientUtil {
 
        private static final String MR_AUTH_CONSTANT = "X-CambriaAuth";
        private static final String MR_DATE_CONSTANT = "X-CambriaDate";
+       private static final String[] httpClientProperties = { ClientProperties.CONNECT_TIMEOUT,
+                       ClientProperties.READ_TIMEOUT, ClientProperties.PROXY_USERNAME, ClientProperties.PROXY_PASSWORD,
+                       ClientProperties.PROXY_URI };
+
+       public static ClientConfig getClientConfig(Properties properties) {
+               ClientConfig config = new ClientConfig();
+               if (properties != null && !properties.isEmpty()) {
+                       setHttpClientProperties(config, properties);
+               }
+               return config;
+       }
 
-       public static WebTarget getTarget(final String path, final String username, final String password) {
+       private static void setHttpClientProperties(ClientConfig config, Properties properties) {
+               for (int i = 0; i < httpClientProperties.length; i++) {
+                       if ((properties.getProperty(httpClientProperties[i]) != null)) {
+                               config.property(httpClientProperties[i], properties.getProperty(httpClientProperties[i]));
+                       }
+               }
+
+       }
 
-               Client client = ClientBuilder.newClient();
+       public static WebTarget getTarget(ClientConfig config, final String path, final String username,
+                       final String password) {
+               Client client = null;
+               if (config != null) {
+                       client = ClientBuilder.newClient(config);
+               } else {
+                       client = ClientBuilder.newClient();
+               }
                HttpAuthenticationFeature feature = HttpAuthenticationFeature.universal(username, password);
                client.register(feature);
 
                return client.target(path);
        }
 
-       public static WebTarget getTarget(final String path) {
+       public static WebTarget getTarget(ClientConfig config, final String path) {
 
-               Client client = ClientBuilder.newClient();
+               Client client = null;
+               if (config != null&&config.getProperties().size()>0) {
+                       client = ClientBuilder.newClient(config);
+               } else {
+                       client = ClientBuilder.newClient();
+               }
                return client.target(path);
        }
 
@@ -53,9 +87,11 @@ public class DmaapClientUtil {
                return target.request().header(MR_AUTH_CONSTANT, username).header(MR_DATE_CONSTANT, password).get();
 
        }
-       
-       public static Response postResponsewtCambriaAuth(WebTarget target, String username, String password,byte[] data,  String contentType) {
-               return target.request().header(MR_AUTH_CONSTANT, username).header(MR_DATE_CONSTANT, password).post(Entity.entity(data, contentType));
+
+       public static Response postResponsewtCambriaAuth(WebTarget target, String username, String password, byte[] data,
+                       String contentType) {
+               return target.request().header(MR_AUTH_CONSTANT, username).header(MR_DATE_CONSTANT, password)
+                               .post(Entity.entity(data, contentType));
 
        }
 
@@ -64,8 +100,9 @@ public class DmaapClientUtil {
                return target.request().header("Authorization", "Basic " + authHeader).get();
 
        }
-       
-       public static Response postResponsewtBasicAuth(WebTarget target, String authHeader,byte[] data,String contentType) {
+
+       public static Response postResponsewtBasicAuth(WebTarget target, String authHeader, byte[] data,
+                       String contentType) {
 
                return target.request().header("Authorization", "Basic " + authHeader).post(Entity.entity(data, contentType));
 
@@ -76,7 +113,7 @@ public class DmaapClientUtil {
                return target.request().get();
 
        }
-       
+
        public static Response postResponsewtNoAuth(WebTarget target, byte[] data, String contentType) {
                return target.request().post(Entity.entity(data, contentType));
 
index 4c6d74e..b29c100 100644 (file)
@@ -31,6 +31,7 @@ import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Response;
 
 import org.apache.http.HttpException;
+import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.internal.util.Base64;
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -47,6 +48,7 @@ import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
 
 public class MRBaseClient extends HttpClient implements MRClient {
 
+       private ClientConfig clientConfig = null;
 
        protected MRBaseClient(Collection<String> hosts) throws MalformedURLException {
                super(ConnectionType.HTTP, hosts, MRConstants.kStdMRServicePort);
@@ -67,6 +69,14 @@ public class MRBaseClient extends HttpClient implements MRClient {
                fLog = LoggerFactory.getLogger(this.getClass().getName());
        }
 
+       public ClientConfig getClientConfig1() {
+               return clientConfig;
+       }
+
+       public void setClientConfig(ClientConfig config) {
+               this.clientConfig = config;
+       }
+
        @Override
        public void close() {
        }
@@ -96,12 +106,12 @@ public class MRBaseClient extends HttpClient implements MRClient {
        public JSONObject post(final String path, final byte[] data, final String contentType, final String username,
                        final String password, final String protocalFlag) throws HttpException, JSONException {
                if ((null != username && null != password)) {
-                       WebTarget target=null;
-                       Response response=null;
-                       target = DmaapClientUtil.getTarget(path, username, password);
+                       WebTarget target = null;
+                       Response response = null;
+                       target = DmaapClientUtil.getTarget(clientConfig,path, username, password);
                        String encoding = Base64.encodeAsString(username + ":" + password);
 
-                       response = DmaapClientUtil.postResponsewtBasicAuth(target, encoding,data, contentType);
+                       response = DmaapClientUtil.postResponsewtBasicAuth(target, encoding, data, contentType);
 
                        return getResponseDataInJson(response);
                } else {
@@ -109,7 +119,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
                                        "Authentication Failed: Username/password/AuthKey/AuthDate parameter(s) cannot be null or empty.");
                }
        }
-       
+
        public JSONObject postNoAuth(final String path, final byte[] data, String contentType)
                        throws HttpException, JSONException {
                WebTarget target = null;
@@ -117,7 +127,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
                if (contentType == null) {
                        contentType = "text/pain";
                }
-               target = DmaapClientUtil.getTarget(path);
+               target = DmaapClientUtil.getTarget(clientConfig,path);
 
                response = DmaapClientUtil.postResponsewtNoAuth(target, data, contentType);
 
@@ -129,21 +139,21 @@ public class MRBaseClient extends HttpClient implements MRClient {
                        throws HttpException, JSONException {
                String responseData = null;
                if ((null != username && null != password)) {
-                       WebTarget target=null;
-                       Response response=null;
-                       target = DmaapClientUtil.getTarget(path, username, password);
+                       WebTarget target = null;
+                       Response response = null;
+                       target = DmaapClientUtil.getTarget(clientConfig,path, username, password);
                        String encoding = Base64.encodeAsString(username + ":" + password);
 
-                       response = DmaapClientUtil.postResponsewtBasicAuth(target, encoding,data, contentType);
+                       response = DmaapClientUtil.postResponsewtBasicAuth(target, encoding, data, contentType);
 
-                       responseData = (String)response.readEntity(String.class);
+                       responseData = (String) response.readEntity(String.class);
                        return responseData;
                } else {
                        throw new HttpException(
                                        "Authentication Failed: Username/password/AuthKey/AuthDate parameter(s) cannot be null or empty.");
                }
        }
-       
+
        public String postNoAuthWithResponse(final String path, final byte[] data, String contentType)
                        throws HttpException, JSONException {
 
@@ -153,24 +163,23 @@ public class MRBaseClient extends HttpClient implements MRClient {
                if (contentType == null) {
                        contentType = "text/pain";
                }
-               target = DmaapClientUtil.getTarget(path);
+               target = DmaapClientUtil.getTarget(clientConfig,path);
 
                response = DmaapClientUtil.postResponsewtNoAuth(target, data, contentType);
                responseData = (String) response.readEntity(String.class);
                return responseData;
        }
 
-       public JSONObject postAuth(PostAuthDataObject postAuthDO)
-                       throws HttpException, JSONException {
-        if ((null != postAuthDO.getUsername() && null != postAuthDO.getPassword())) {
-            WebTarget target = null;
-            Response response = null;
-            target = DmaapClientUtil.getTarget(postAuthDO.getPath(), postAuthDO.getUsername(),
-                    postAuthDO.getPassword());
-            response = DmaapClientUtil.postResponsewtCambriaAuth(target, postAuthDO.getAuthKey(),
-                    postAuthDO.getAuthDate(), postAuthDO.getData(), postAuthDO.getContentType());
-            return getResponseDataInJson(response);
-        } else {
+       public JSONObject postAuth(PostAuthDataObject postAuthDO) throws HttpException, JSONException {
+               if ((null != postAuthDO.getUsername() && null != postAuthDO.getPassword())) {
+                       WebTarget target = null;
+                       Response response = null;
+                       target = DmaapClientUtil.getTarget(clientConfig,postAuthDO.getPath(), postAuthDO.getUsername(),
+                                       postAuthDO.getPassword());
+                       response = DmaapClientUtil.postResponsewtCambriaAuth(target, postAuthDO.getAuthKey(),
+                                       postAuthDO.getAuthDate(), postAuthDO.getData(), postAuthDO.getContentType());
+                       return getResponseDataInJson(response);
+               } else {
                        throw new HttpException(
                                        "Authentication Failed: Username/password/AuthKey/AuthDate parameter(s) cannot be null or empty.");
                }
@@ -181,11 +190,11 @@ public class MRBaseClient extends HttpClient implements MRClient {
                        final String protocolFlag) throws HttpException, JSONException {
                String responseData = null;
                if ((null != username && null != password)) {
-                       WebTarget target=null;
-                       Response response=null;
-                       target = DmaapClientUtil.getTarget(path, username, password);
+                       WebTarget target = null;
+                       Response response = null;
+                       target = DmaapClientUtil.getTarget(clientConfig,path, username, password);
                        response = DmaapClientUtil.postResponsewtCambriaAuth(target, authKey, authDate, data, contentType);
-                       responseData = (String)response.readEntity(String.class);
+                       responseData = (String) response.readEntity(String.class);
                        return responseData;
 
                } else {
@@ -198,14 +207,14 @@ public class MRBaseClient extends HttpClient implements MRClient {
                        throws HttpException, JSONException {
                if (null != username && null != password) {
 
-                        WebTarget target=null;
-                        Response response=null;
-                        
+                       WebTarget target = null;
+                       Response response = null;
+
                        if (ProtocolTypeConstants.AUTH_KEY.getValue().equalsIgnoreCase(protocolFlag)) {
-                               target = DmaapClientUtil.getTarget(path);
+                               target = DmaapClientUtil.getTarget(clientConfig,path);
                                response = DmaapClientUtil.getResponsewtCambriaAuth(target, username, password);
                        } else {
-                               target = DmaapClientUtil.getTarget(path, username, password);
+                               target = DmaapClientUtil.getTarget(clientConfig,path, username, password);
                                String encoding = Base64.encodeAsString(username + ":" + password);
 
                                response = DmaapClientUtil.getResponsewtBasicAuth(target, encoding);
@@ -222,13 +231,13 @@ public class MRBaseClient extends HttpClient implements MRClient {
                        final String protocolFlag) throws HttpException, JSONException {
                String responseData = null;
                if (null != username && null != password) {
-                       WebTarget target=null;
-                       Response response=null;
+                       WebTarget target = null;
+                       Response response = null;
                        if (ProtocolTypeConstants.AUTH_KEY.getValue().equalsIgnoreCase(protocolFlag)) {
-                               target = DmaapClientUtil.getTarget(path);
+                               target = DmaapClientUtil.getTarget(clientConfig,path);
                                response = DmaapClientUtil.getResponsewtCambriaAuth(target, username, password);
                        } else {
-                               target = DmaapClientUtil.getTarget(path, username, password);
+                               target = DmaapClientUtil.getTarget(clientConfig,path, username, password);
                                String encoding = Base64.encodeAsString(username + ":" + password);
                                response = DmaapClientUtil.getResponsewtBasicAuth(target, encoding);
                        }
@@ -239,7 +248,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
                                fLog.info("TransactionId : " + transactionid);
                        }
 
-                       responseData = (String)response.readEntity(String.class);
+                       responseData = (String) response.readEntity(String.class);
                        return responseData;
                } else {
                        throw new HttpException(
@@ -250,9 +259,9 @@ public class MRBaseClient extends HttpClient implements MRClient {
        public JSONObject getAuth(final String path, final String authKey, final String authDate, final String username,
                        final String password, final String protocolFlag) throws HttpException, JSONException {
                if (null != username && null != password) {
-                       WebTarget target=null;
-                       Response response=null;
-                       target = DmaapClientUtil.getTarget(path, username, password);
+                       WebTarget target = null;
+                       Response response = null;
+                       target = DmaapClientUtil.getTarget(clientConfig,path, username, password);
                        response = DmaapClientUtil.getResponsewtCambriaAuth(target, authKey, authDate);
 
                        return getResponseDataInJson(response);
@@ -266,7 +275,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
 
                WebTarget target = null;
                Response response = null;
-               target = DmaapClientUtil.getTarget(path);
+               target = DmaapClientUtil.getTarget(clientConfig,path);
                response = DmaapClientUtil.getResponsewtNoAuth(target);
 
                return getResponseDataInJson(response);
@@ -276,9 +285,9 @@ public class MRBaseClient extends HttpClient implements MRClient {
                        final String password, final String protocolFlag) throws HttpException, JSONException {
                String responseData = null;
                if (null != username && null != password) {
-                       WebTarget target=null;
-                       Response response=null;
-                       target = DmaapClientUtil.getTarget(path, username, password);
+                       WebTarget target = null;
+                       Response response = null;
+                       target = DmaapClientUtil.getTarget(clientConfig,path, username, password);
                        response = DmaapClientUtil.getResponsewtCambriaAuth(target, authKey, authDate);
 
                        MRClientFactory.HTTPHeadersMap = response.getHeaders();
@@ -288,7 +297,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
                                fLog.info("TransactionId : " + transactionid);
                        }
 
-                       responseData = (String)response.readEntity(String.class);
+                       responseData = (String) response.readEntity(String.class);
                        return responseData;
                } else {
                        throw new HttpException(
@@ -299,9 +308,9 @@ public class MRBaseClient extends HttpClient implements MRClient {
        public String getNoAuthResponse(String path, final String username, final String password,
                        final String protocolFlag) throws HttpException, JSONException {
                String responseData = null;
-               WebTarget target=null;
-               Response response=null;
-               target = DmaapClientUtil.getTarget(path, username, password);
+               WebTarget target = null;
+               Response response = null;
+               target = DmaapClientUtil.getTarget(clientConfig,path, username, password);
                response = DmaapClientUtil.getResponsewtNoAuth(target);
 
                MRClientFactory.HTTPHeadersMap = response.getHeaders();
@@ -311,16 +320,14 @@ public class MRBaseClient extends HttpClient implements MRClient {
                        fLog.info("TransactionId : " + transactionid);
                }
 
-               responseData = (String)response.readEntity(String.class);
+               responseData = (String) response.readEntity(String.class);
                return responseData;
 
        }
 
-
        private JSONObject getResponseDataInJson(Response response) throws JSONException {
                try {
                        MRClientFactory.HTTPHeadersMap = response.getHeaders();
-                       
 
                        // MultivaluedMap<String, Object> headersMap =
                        // for(String key : headersMap.keySet()) {
@@ -329,7 +336,6 @@ public class MRBaseClient extends HttpClient implements MRClient {
                                fLog.info("TransactionId : " + transactionid);
                        }
 
-
                        if (response.getStatus() == 403) {
                                JSONObject jsonObject = null;
                                jsonObject = new JSONObject();
@@ -339,7 +345,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
                                jsonObject.put("status", response.getStatus());
                                return jsonObject;
                        }
-                       String responseData = (String)response.readEntity(String.class);
+                       String responseData = (String) response.readEntity(String.class);
 
                        JSONTokener jsonTokener = new JSONTokener(responseData);
                        JSONObject jsonObject = null;
index 73840be..0b06f77 100644 (file)
@@ -694,6 +694,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
 
     public void setProps(Properties props) {
         this.props = props;
+        setClientConfig(DmaapClientUtil.getClientConfig(props));
     }
 
     public String getUsername() {
index 8f2a66e..9b969a6 100644 (file)
@@ -707,6 +707,7 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
 
        public void setProps(Properties props) {
                this.props = props;
+               setClientConfig(DmaapClientUtil.getClientConfig(props));
        }
 
        public String getProtocolFlag() {
index a845572..4378942 100644 (file)
@@ -23,13 +23,14 @@ package org.onap.dmaap.mr.client.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
 import javax.ws.rs.client.Invocation.Builder;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.client.ClientConfig;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -43,6 +44,7 @@ public class DMaapClientUtilTest {
     Builder builder;
     @Mock
     WebTarget target;
+    private ClientConfig config=null;
 
     @Before
     public void setup(){
@@ -51,14 +53,14 @@ public class DMaapClientUtilTest {
     
     @Test
     public void testGetTarget() {
-       WebTarget actual = DmaapClientUtil.getTarget("testpath");
+       WebTarget actual = DmaapClientUtil.getTarget(getClientConfig(),"testpath");
         
         assertEquals("testpath", actual.getUri().getPath());
     }
     
     @Test
     public void testGetTargetWithParams() {
-        WebTarget actual = DmaapClientUtil.getTarget("testpath", "testuser", "testpassword");
+        WebTarget actual = DmaapClientUtil.getTarget(getClientConfig(),"testpath", "testuser", "testpassword");
         
         assertEquals("testpath", actual.getUri().getPath());
     }
@@ -77,6 +79,12 @@ public class DMaapClientUtilTest {
         verify(builder, times(2)).header((String) any(), any());
     }
 
-    
+       private ClientConfig getClientConfig(){
+               if(config==null){
+                       config=DmaapClientUtil.getClientConfig(null);
+               }
+               return config;
+               
+       }  
 
 }
index a02691c..235a83b 100644 (file)
@@ -36,6 +36,7 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 
 import org.apache.http.HttpException;
+import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.internal.util.Base64;
 import org.glassfish.jersey.internal.util.collection.StringKeyIgnoreCaseMultivaluedMap;
 import org.json.JSONException;
@@ -49,6 +50,7 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
+
 @RunWith(PowerMockRunner.class)
 @PowerMockIgnore("org.apache.http.conn.ssl.*")
 @PrepareForTest({ DmaapClientUtil.class })
@@ -58,6 +60,7 @@ public class MRBaseClientTest {
        private MRBaseClient mrBaseClient;
        private Collection<String> hosts = new HashSet<>(Arrays.asList("localhost:8080"));
        private String clientSignature = "topic" + "::" + "cg" + "::" + "cid";
+       private ClientConfig config=null;
 
        @Before
        public void setup() throws MalformedURLException {
@@ -77,7 +80,7 @@ public class MRBaseClientTest {
                Mockito.when(response.getHeaders()).thenReturn(map);
 
                Mockito.when(
-                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username", "password"))
                                .thenReturn(response);
 
                JSONObject result = mrBaseClient.get("/path", "username", "password", "HTTPAUTH");
@@ -92,7 +95,7 @@ public class MRBaseClientTest {
        public void testGet_403() throws JSONException, HttpException {
                ResponseBuilder responseBuilder = Response.status(403);
                Mockito
-                               .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+                               .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password"))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -111,7 +114,7 @@ public class MRBaseClientTest {
                Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
                Mockito.when(response.getHeaders()).thenReturn(map);
 
-               Mockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+               Mockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"),
                                Base64.encodeAsString("username:password"))).thenReturn(response);
 
                JSONObject result = mrBaseClient.get("/path", "username", "password", "HTTPAAF");
@@ -126,7 +129,7 @@ public class MRBaseClientTest {
        public void testGet_error() throws JSONException, HttpException {
 
                ResponseBuilder responseBuilder = Response.ok();
-               Mockito.when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+               Mockito.when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password"))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -146,7 +149,7 @@ public class MRBaseClientTest {
                Mockito.when(response.getHeaders()).thenReturn(map);
 
                Mockito.when(
-                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username", "password"))
                                .thenReturn(response);
 
                mrBaseClient.get("/path", "username", "password", "HTTPAUTH");
@@ -167,7 +170,7 @@ public class MRBaseClientTest {
                Mockito.when(response.getHeaders()).thenReturn(map);
 
                Mockito.when(
-                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username", "password"))
                                .thenReturn(response);
 
                mrBaseClient.getResponse("/path", "username", "password", "HTTPAUTH");
@@ -186,7 +189,7 @@ public class MRBaseClientTest {
                Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
                Mockito.when(response.getHeaders()).thenReturn(map);
 
-               Mockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+               Mockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"),
                                Base64.encodeAsString("username:password"))).thenReturn(response);
 
                mrBaseClient.getResponse("/path", "username", "password", "HTTPAAF");
@@ -199,7 +202,7 @@ public class MRBaseClientTest {
 
                ResponseBuilder responseBuilder = Response.ok();
                Mockito
-                               .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+                               .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password"))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -219,7 +222,7 @@ public class MRBaseClientTest {
                Mockito.when(response.getHeaders()).thenReturn(map);
 
                Mockito.when(
-                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username", "password"))
                                .thenReturn(response);
 
                mrBaseClient.getAuthResponse("/path", "username", "password", "username", "password", "HTTPAUTH");
@@ -232,7 +235,7 @@ public class MRBaseClientTest {
 
                ResponseBuilder responseBuilder = Response.ok();
                Mockito
-                               .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+                               .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password"))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -253,7 +256,7 @@ public class MRBaseClientTest {
                Mockito.when(response.getHeaders()).thenReturn(map);
 
                Mockito
-                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password", new String("{\"test\":\"test\"}").getBytes(), "application/json"))
                                .thenReturn(response);
 
@@ -274,7 +277,7 @@ public class MRBaseClientTest {
 
                ResponseBuilder responseBuilder = Response.ok();
                Mockito
-                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password", new String("{\"test\":\"test\"}").getBytes(), "application/json"))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -300,7 +303,7 @@ public class MRBaseClientTest {
                Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
                Mockito.when(response.getHeaders()).thenReturn(map);
 
-               Mockito.when(DmaapClientUtil.getResponsewtNoAuth(DmaapClientUtil.getTarget("/path"))).thenReturn(response);
+               Mockito.when(DmaapClientUtil.getResponsewtNoAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"))).thenReturn(response);
 
                mrBaseClient.getNoAuthResponse("/path", "username", "password", "HTTPAUTH");
                assertTrue(true);
@@ -318,7 +321,7 @@ public class MRBaseClientTest {
                Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
                Mockito.when(response.getHeaders()).thenReturn(map);
 
-               Mockito.when(DmaapClientUtil.postResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+               Mockito.when(DmaapClientUtil.postResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"),
                                Base64.encodeAsString("username:password"), new String("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response);
 
                mrBaseClient.post("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", "username",
@@ -334,7 +337,7 @@ public class MRBaseClientTest {
 
                ResponseBuilder responseBuilder = Response.ok();
                Mockito
-                               .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+                               .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"),
                                                Base64.encodeAsString("username:password")))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -356,7 +359,7 @@ public class MRBaseClientTest {
                Mockito.when(response.getHeaders()).thenReturn(map);
 
                Mockito
-                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password", new String("{\"test\":\"test\"}").getBytes(), "application/json"))
                                .thenReturn(response);
 
@@ -371,7 +374,7 @@ public class MRBaseClientTest {
 
                ResponseBuilder responseBuilder = Response.ok();
                Mockito
-                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password", new String("{\"test\":\"test\"}").getBytes(), "application/json"))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -393,7 +396,7 @@ public class MRBaseClientTest {
                Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
                Mockito.when(response.getHeaders()).thenReturn(map);
 
-               Mockito.when(DmaapClientUtil.postResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+               Mockito.when(DmaapClientUtil.postResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"),
                                Base64.encodeAsString("username:password"), new String("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response);
 
                mrBaseClient.postWithResponse("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json",
@@ -407,7 +410,7 @@ public class MRBaseClientTest {
 
                ResponseBuilder responseBuilder = Response.ok();
                Mockito
-                               .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+                               .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"),
                                                Base64.encodeAsString("username:password")))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -429,7 +432,7 @@ public class MRBaseClientTest {
                Mockito.when(response.getHeaders()).thenReturn(map);
 
                Mockito.when(
-                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+                               DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username", "password"))
                                .thenReturn(response);
                mrBaseClient.getAuth("/path", "username", "password", "username", "password", "HTTPAUTH");
                assertTrue(true);
@@ -441,7 +444,7 @@ public class MRBaseClientTest {
 
                ResponseBuilder responseBuilder = Response.ok();
                Mockito
-                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
+                               .when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"), "username",
                                                "password", new String("{\"test\":\"test\"}").getBytes(), "application/json"))
                                .thenReturn(
                                                responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
@@ -462,7 +465,7 @@ public class MRBaseClientTest {
                Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
                Mockito.when(response.getHeaders()).thenReturn(map);
 
-               Mockito.when(DmaapClientUtil.getResponsewtNoAuth(DmaapClientUtil.getTarget("/path"))).thenReturn(response);
+               Mockito.when(DmaapClientUtil.getResponsewtNoAuth(DmaapClientUtil.getTarget(getClientConfig(),"/path"))).thenReturn(response);
                mrBaseClient.getNoAuth("/path");
                assertTrue(true);
 
@@ -479,5 +482,15 @@ public class MRBaseClientTest {
        public void getGTTPErrorResponseCode() {
                assertEquals("500", mrBaseClient.getHTTPErrorResponseCode("<title>500</title>"));
        }
+       
+       
+       
+       private ClientConfig getClientConfig(){
+               if(config==null){
+                       config=DmaapClientUtil.getClientConfig(null);
+               }
+               return config;
+               
+       }
 
 }
index 8a7c886..cecd737 100644 (file)
@@ -27,7 +27,7 @@
 
 major=1
 minor=1
-patch=11
+patch=12
 
 base_version=${major}.${minor}.${patch}