summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java5
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java42
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java41
-rw-r--r--src/main/java/com/att/nsa/mr/test/clients/SimpleExamplePublisherWithResponse.java2
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java203
-rw-r--r--version.properties2
7 files changed, 220 insertions, 77 deletions
diff --git a/pom.xml b/pom.xml
index f2b7d58..9d7e3d2 100644
--- 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.3-SNAPSHOT</version>
+ <version>1.1.5-SNAPSHOT</version>
<name>dmaap-messagerouter-dmaapclient</name>
<description>Client library for MR event routing API</description>
<url>https://github.com/att/dmaap-framework</url>
diff --git a/src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java b/src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java
index 6adf236..17a37d9 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java
@@ -70,5 +70,10 @@ 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));
+
+ }
}
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java b/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java
index 0cffa7d..c3d1c26 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java
@@ -109,6 +109,20 @@ 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;
+ Response response = null;
+ if (contentType == null) {
+ contentType = "text/pain";
+ }
+ target = DmaapClientUtil.getTarget(path);
+
+ response = DmaapClientUtil.postResponsewtNoAuth(target, data, contentType);
+
+ return getResponseDataInJson(response);
+ }
public String postWithResponse(final String path, final byte[] data, final String contentType,
final String username, final String password, final String protocolFlag)
@@ -122,13 +136,29 @@ public class MRBaseClient extends HttpClient implements MRClient {
response = DmaapClientUtil.getResponsewtBasicAuth(target, encoding);
- responseData = (String)response.getEntity();
+ 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 {
+
+ String responseData = null;
+ WebTarget target = null;
+ Response response = null;
+ if (contentType == null) {
+ contentType = "text/pain";
+ }
+ target = DmaapClientUtil.getTarget(path);
+
+ response = DmaapClientUtil.postResponsewtNoAuth(target, data, contentType);
+ responseData = (String) response.readEntity(String.class);
+ return responseData;
+ }
public JSONObject postAuth(final String path, final byte[] data, final String contentType, final String authKey,
final String authDate, final String username, final String password, final String protocolFlag)
@@ -154,7 +184,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
Response response=null;
target = DmaapClientUtil.getTarget(path, username, password);
response = DmaapClientUtil.postResponsewtCambriaAuth(target, authKey, authDate, data, contentType);
- responseData = (String)response.getEntity();
+ responseData = (String)response.readEntity(String.class);
return responseData;
} else {
@@ -208,7 +238,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
fLog.info("TransactionId : " + transactionid);
}
- responseData = (String)response.getEntity();
+ responseData = (String)response.readEntity(String.class);
return responseData;
} else {
throw new HttpException(
@@ -262,7 +292,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
fLog.info("TransactionId : " + transactionid);
}
- responseData = (String)response.getEntity();
+ responseData = (String)response.readEntity(String.class);
return responseData;
} else {
throw new HttpException(
@@ -285,7 +315,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
fLog.info("TransactionId : " + transactionid);
}
- responseData = (String)response.getEntity();
+ responseData = (String)response.readEntity(String.class);
return responseData;
}
@@ -325,7 +355,7 @@ public class MRBaseClient extends HttpClient implements MRClient {
jsonObject.put("status", response.getStatus());
return jsonObject;
}
- String responseData = (String)response.getEntity();
+ String responseData = (String)response.readEntity(String.class);
JSONTokener jsonTokener = new JSONTokener(responseData);
JSONObject jsonObject = null;
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java b/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java
index c234678..2f7680b 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java
@@ -378,6 +378,23 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
fPending.clear();
return true;
}
+
+ if (ProtocolTypeConstants.HTTPNOAUTH.getValue().equalsIgnoreCase(protocolFlag)) {
+ getLog().info("sending " + fPending.size() + " msgs to " + httpurl + ". Oldest: "
+ + (nowMs - fPending.peek().timestamp) + " ms");
+ final JSONObject result = postNoAuth(httpurl, baseStream.toByteArray(), contentType);
+
+ // Here we are checking for error response. If HTTP status
+ // code is not within the http success response code
+ // then we consider this as error and return false
+ if (result.getInt("status") < 200 || result.getInt("status") > 299) {
+ return false;
+ }
+ final String logLine = "MR reply ok (" + (Clock.now() - startMs) + " ms):" + result.toString();
+ getLog().info(logLine);
+ fPending.clear();
+ return true;
+ }
} catch (IllegalArgumentException x) {
getLog().warn(x.getMessage(), x);
} catch (IOException x) {
@@ -531,6 +548,28 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
fPending.clear();
return pubResponse;
}
+
+ if (ProtocolTypeConstants.HTTPNOAUTH.getValue().equalsIgnoreCase(protocolFlag)) {
+ getLog().info("sending " + fPending.size() + " msgs to " + httpurl + ". Oldest: "
+ + (nowMs - fPending.peek().timestamp) + " ms");
+ final String result = postNoAuthWithResponse(httpurl, baseStream.toByteArray(), contentType);
+
+ // Here we are checking for error response. If HTTP status
+ // code is not within the http success response code
+ // then we consider this as error and return false
+ pubResponse = createMRPublisherResponse(result, pubResponse);
+
+ if (Integer.valueOf(pubResponse.getResponseCode()) < 200
+ || Integer.valueOf(pubResponse.getResponseCode()) > 299) {
+
+ return pubResponse;
+ }
+
+ final String logLine = String.valueOf((Clock.now() - startMs));
+ getLog().info(logLine);
+ fPending.clear();
+ return pubResponse;
+ }
} catch (IllegalArgumentException x) {
getLog().warn(x.getMessage(), x);
pubResponse.setResponseCode(String.valueOf(HttpStatus.SC_BAD_REQUEST));
@@ -573,7 +612,7 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
return pubResponse;
}
- private MRPublisherResponse createMRPublisherResponse(String reply, MRPublisherResponse mrPubResponse) {
+ public MRPublisherResponse createMRPublisherResponse(String reply, MRPublisherResponse mrPubResponse) {
if (reply.isEmpty()) {
diff --git a/src/main/java/com/att/nsa/mr/test/clients/SimpleExamplePublisherWithResponse.java b/src/main/java/com/att/nsa/mr/test/clients/SimpleExamplePublisherWithResponse.java
index 4914688..9d179b2 100644
--- a/src/main/java/com/att/nsa/mr/test/clients/SimpleExamplePublisherWithResponse.java
+++ b/src/main/java/com/att/nsa/mr/test/clients/SimpleExamplePublisherWithResponse.java
@@ -61,7 +61,7 @@ import com.att.nsa.mr.client.response.MRPublisherResponse;
}
}
- public void publishMessage ( String producerFilePath , int count ) throws IOException, InterruptedException, Exception
+ public void publishMessage ( String producerFilePath , int count ) throws IOException, InterruptedException
{
// create our publisher
final MRBatchingPublisher pub = MRClientFactory.createBatchingPublisher (producerFilePath,true);
diff --git a/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java b/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java
index 1c291b9..b05cc7f 100644
--- a/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java
+++ b/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java
@@ -29,17 +29,20 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import org.apache.http.HttpException;
import org.glassfish.jersey.internal.util.Base64;
+import org.glassfish.jersey.internal.util.collection.StringKeyIgnoreCaseMultivaluedMap;
import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
@@ -51,26 +54,31 @@ import org.powermock.modules.junit4.PowerMockRunner;
@PrepareForTest({ DmaapClientUtil.class })
public class MRBaseClientTest {
- //@InjectMocks
+ // @InjectMocks
private MRBaseClient mrBaseClient;
private Collection<String> hosts = new HashSet<>(Arrays.asList("localhost:8080"));
private String clientSignature = "topic" + "::" + "cg" + "::" + "cid";
@Before
public void setup() throws MalformedURLException {
- mrBaseClient=new MRBaseClient(hosts, clientSignature);
+ mrBaseClient = new MRBaseClient(hosts, clientSignature);
PowerMockito.mockStatic(DmaapClientUtil.class);
}
@Test
public void testGet() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
- "password"))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(
+ DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+ .thenReturn(response);
mrBaseClient.get("/path", "username", "password", "HTTPAUTH");
assertTrue(true);
@@ -93,12 +101,16 @@ public class MRBaseClientTest {
@Test
public void testGet_basicauth() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
- Base64.encodeAsString("username:password")))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+ Base64.encodeAsString("username:password"))).thenReturn(response);
mrBaseClient.get("/path", "username", "password", "HTTPAAF");
assertTrue(true);
@@ -123,11 +135,17 @@ public class MRBaseClientTest {
@Test
public void testGet_wrongjson() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
- "password"))
- .thenReturn(responseBuilder.header("transactionid", "transactionid").entity("[[").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("[[");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(
+ DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+ .thenReturn(response);
mrBaseClient.get("/path", "username", "password", "HTTPAUTH");
assertTrue(true);
@@ -136,12 +154,17 @@ public class MRBaseClientTest {
@Test
public void testGetResponse() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
- "password"))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(
+ DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+ .thenReturn(response);
mrBaseClient.getResponse("/path", "username", "password", "HTTPAUTH");
assertTrue(true);
@@ -151,12 +174,16 @@ public class MRBaseClientTest {
@Test
public void testGetResponse_aaf() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
- Base64.encodeAsString("username:password")))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+ Base64.encodeAsString("username:password"))).thenReturn(response);
mrBaseClient.getResponse("/path", "username", "password", "HTTPAAF");
assertTrue(true);
@@ -180,12 +207,17 @@ public class MRBaseClientTest {
@Test
public void testAuthResponse() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
- "password"))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(
+ DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+ .thenReturn(response);
mrBaseClient.getAuthResponse("/path", "username", "password", "username", "password", "HTTPAUTH");
assertTrue(true);
@@ -209,12 +241,18 @@ public class MRBaseClientTest {
@Test
public void testPostAuth() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
PowerMockito
.when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
"password", new String("{\"test\":\"test\"}").getBytes(), "application/json"))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ .thenReturn(response);
mrBaseClient.postAuth("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", "username",
"password", "username", "password", "HTTPAUTH");
@@ -241,9 +279,15 @@ public class MRBaseClientTest {
@Test
public void testGetNoAuthResponse() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito.when(DmaapClientUtil.getResponsewtNoAuth(DmaapClientUtil.getTarget("/path"))).thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(DmaapClientUtil.getResponsewtNoAuth(DmaapClientUtil.getTarget("/path"))).thenReturn(response);
mrBaseClient.getNoAuthResponse("/path", "username", "password", "HTTPAUTH");
assertTrue(true);
@@ -253,12 +297,16 @@ public class MRBaseClientTest {
@Test
public void testPost() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
- Base64.encodeAsString("username:password")))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+ Base64.encodeAsString("username:password"))).thenReturn(response);
mrBaseClient.post("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", "username",
"password", "HTTPAUTH");
@@ -284,12 +332,18 @@ public class MRBaseClientTest {
@Test
public void testPostAuthwithResponse() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
PowerMockito
.when(DmaapClientUtil.postResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
"password", new String("{\"test\":\"test\"}").getBytes(), "application/json"))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ .thenReturn(response);
mrBaseClient.postAuthwithResponse("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json",
"username", "password", "username", "password", "HTTPAUTH");
@@ -316,12 +370,16 @@ public class MRBaseClientTest {
@Test
public void testPostWithResponse() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
- Base64.encodeAsString("username:password")))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
+ Base64.encodeAsString("username:password"))).thenReturn(response);
mrBaseClient.postWithResponse("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json",
"username", "password", "HTTPAUTH");
@@ -347,12 +405,17 @@ public class MRBaseClientTest {
@Test
public void testGetAuth() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito
- .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
- "password"))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(
+ DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username", "password"))
+ .thenReturn(response);
mrBaseClient.getAuth("/path", "username", "password", "username", "password", "HTTPAUTH");
assertTrue(true);
@@ -376,9 +439,15 @@ public class MRBaseClientTest {
@Test
public void testGetNoAuth() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.ok();
- PowerMockito.when(DmaapClientUtil.getResponsewtNoAuth(DmaapClientUtil.getTarget("/path"))).thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Response response = Mockito.mock(Response.class);
+ MultivaluedMap<String, Object> map = new StringKeyIgnoreCaseMultivaluedMap<>();
+ map.add("transactionid", "transactionid");
+
+ PowerMockito.when(response.getStatus()).thenReturn(200);
+ PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
+ PowerMockito.when(response.getHeaders()).thenReturn(map);
+
+ PowerMockito.when(DmaapClientUtil.getResponsewtNoAuth(DmaapClientUtil.getTarget("/path"))).thenReturn(response);
mrBaseClient.getNoAuth("/path", "username", "password", "HTTPAUTH");
assertTrue(true);
diff --git a/version.properties b/version.properties
index 05dc9e5..7809677 100644
--- a/version.properties
+++ b/version.properties
@@ -27,7 +27,7 @@
major=1
minor=1
-patch=3
+patch=5
base_version=${major}.${minor}.${patch}