aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/com/att/nsa/mr/client/impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/att/nsa/mr/client/impl')
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/DMaapClientUtilTest.java85
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java471
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/MRBatchPublisherTest.java54
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/MRConstantsTest.java143
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/MRConsumerImplTest.java112
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/MRMetaClientTest.java129
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/MRSimplerBatchConsumerTest.java76
-rw-r--r--src/test/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisherTest.java96
8 files changed, 0 insertions, 1166 deletions
diff --git a/src/test/java/com/att/nsa/mr/client/impl/DMaapClientUtilTest.java b/src/test/java/com/att/nsa/mr/client/impl/DMaapClientUtilTest.java
deleted file mode 100644
index 9841adb..0000000
--- a/src/test/java/com/att/nsa/mr/client/impl/DMaapClientUtilTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2018 IBM Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * 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 the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-package com.att.nsa.mr.client.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import com.att.aft.dme2.internal.jersey.core.spi.factory.ResponseImpl;
-
-public class DMaapClientUtilTest {
-
- Builder builder;
-
- Response response;
-
- WebTarget target;
-
- @Before
- public void setup(){
- Mockito.mock(HttpServletRequest.class);
- builder = Mockito.mock(Invocation.Builder.class);
- response = Mockito.mock(Response.class);
- target = Mockito.mock(WebTarget.class);
-
- }
-
- @Test
- public void testGetTarget() throws IOException{
- WebTarget actual = DmaapClientUtil.getTarget("testpath");
-
- assertEquals("testpath", actual.getUri().getPath());
- }
-
- @Test
- public void testGetTargetWithParams() throws IOException{
- WebTarget actual = DmaapClientUtil.getTarget("testpath", "testuser", "testpassword");
-
- assertEquals("testpath", actual.getUri().getPath());
- }
-
- @Test
- public void testGetResponsewtCambriaAuth() {
- Mockito.when(target.request()).thenReturn(builder);
- Mockito.when(builder.header("X-CambriaAuth", "testuser")).thenReturn(builder);
- Mockito.when(builder.header("X-CambriaDate", "testpassword")).thenReturn(builder);
- Mockito.when(builder.get()).thenReturn(response);
-
- Response actual = DmaapClientUtil.getResponsewtCambriaAuth(target, "testuser", "testpassword");
-
- assertEquals(response, actual);
- }
-
-
-
-}
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
deleted file mode 100644
index 055c94f..0000000
--- a/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * 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 the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-package com.att.nsa.mr.client.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.net.MalformedURLException;
-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;
-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 })
-public class MRBaseClientTest {
-
- // @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);
- PowerMockito.mockStatic(DmaapClientUtil.class);
- }
-
- @Test
- public void testGet() throws JSONException, HttpException {
-
- 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);
-
- }
-
- @Test
- public void testGet_403() throws JSONException, HttpException {
- ResponseBuilder responseBuilder = Response.status(403);
- PowerMockito
- .when(DmaapClientUtil.getResponsewtCambriaAuth(DmaapClientUtil.getTarget("/path"), "username",
- "password"))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
- mrBaseClient.get("/path", "username", "password", "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test
- public void testGet_basicauth() throws JSONException, HttpException {
-
- 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);
-
- }
-
- @Test(expected = HttpException.class)
- public void testGet_error() 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());
-
- mrBaseClient.get("/path", null, null, "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test
- public void testGet_wrongjson() throws JSONException, HttpException {
-
- 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);
- }
-
- @Test
- public void testGetResponse() throws JSONException, HttpException {
-
- 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);
-
- }
-
- @Test
- public void testGetResponse_aaf() throws JSONException, HttpException {
-
- 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);
-
- }
-
- @Test(expected = HttpException.class)
- public void testGetResponse_error() 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());
-
- mrBaseClient.getResponse("/path", null, null, "HTTPAUTH");
-
- }
-
- @Test
- public void testAuthResponse() throws JSONException, HttpException {
-
- 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);
-
- }
-
- @Test(expected = HttpException.class)
- public void testAuthResponsee_error() 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());
-
- mrBaseClient.getAuthResponse("/path", null, null, null, null, "HTTPAUTH");
-
- }
-
- @Test
- public void testPostAuth() throws JSONException, HttpException {
-
- 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(response);
-
- mrBaseClient.postAuth("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", "username",
- "password", "username", "password", "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test(expected = HttpException.class)
- public void testPostAuth_error() throws JSONException, HttpException {
-
- ResponseBuilder responseBuilder = Response.ok();
- 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());
-
- mrBaseClient.postAuth("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", null, null,
- null, null, "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test
- public void testGetNoAuthResponse() throws JSONException, HttpException {
-
- 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);
-
- }
-
- @Test
- public void testPost() throws JSONException, HttpException {
-
- 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.postResponsewtBasicAuth(DmaapClientUtil.getTarget("/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",
- "password", "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test(expected = HttpException.class)
- public void testPost_error() 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());
-
- mrBaseClient.post("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", null, null,
- "HTTPAUTH");
-
- }
-
- @Test
- public void testPostAuthwithResponse() throws JSONException, HttpException {
-
- 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(response);
-
- mrBaseClient.postAuthwithResponse("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json",
- "username", "password", "username", "password", "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test(expected = HttpException.class)
- public void testPostAuthwithResponse_error() throws JSONException, HttpException {
-
- ResponseBuilder responseBuilder = Response.ok();
- 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());
-
- mrBaseClient.postAuthwithResponse("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json",
- null, null, null, null, "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test
- public void testPostWithResponse() throws JSONException, HttpException {
-
- 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.postResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"),
- Base64.encodeAsString("username:password"), new String("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response);
-
- mrBaseClient.postWithResponse("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json",
- "username", "password", "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test(expected = HttpException.class)
- public void testPostWithResponse_error() 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());
-
- mrBaseClient.postWithResponse("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", null,
- null, "HTTPAUTH");
-
- }
-
- @Test
- public void testGetAuth() throws JSONException, HttpException {
-
- 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);
-
- }
-
- @Test(expected = HttpException.class)
- public void testGetAuth_error() throws JSONException, HttpException {
-
- ResponseBuilder responseBuilder = Response.ok();
- 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());
-
- mrBaseClient.getAuth("/path", null, null, null, null, "HTTPAUTH");
- assertTrue(true);
-
- }
-
- @Test
- public void testGetNoAuth() throws JSONException, HttpException {
-
- 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");
- assertTrue(true);
-
- }
-
-
- @Test
- public void testGetHTTPErrorResponseMessage() {
-
- assertEquals(mrBaseClient.getHTTPErrorResponseMessage("<body>testtest</body>"), "testtest");
-
- }
-
- @Test
- public void getGTTPErrorResponseCode() {
-
- assertEquals(mrBaseClient.getHTTPErrorResponseMessage("<body>testtest</body>"), "testtest");
-
- }
-
-}
diff --git a/src/test/java/com/att/nsa/mr/client/impl/MRBatchPublisherTest.java b/src/test/java/com/att/nsa/mr/client/impl/MRBatchPublisherTest.java
deleted file mode 100644
index 19b58e9..0000000
--- a/src/test/java/com/att/nsa/mr/client/impl/MRBatchPublisherTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * 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 the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-package com.att.nsa.mr.client.impl;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class MRBatchPublisherTest {
-
- private Collection<String> hosts=new HashSet<>(Arrays.asList("/test"));
- private MRBatchPublisher mrBatchPublisher=new MRBatchPublisher(hosts, "topic", 2, 20, true);
-
-
- @Before
- public void setup(){
-
-
- }
-
- @Test
- public void testSend() throws IOException{
- mrBatchPublisher.send("testmessage");
- }
-
- @Test
- public void testClose() throws IOException{
- mrBatchPublisher.close();
- }
-
-}
diff --git a/src/test/java/com/att/nsa/mr/client/impl/MRConstantsTest.java b/src/test/java/com/att/nsa/mr/client/impl/MRConstantsTest.java
deleted file mode 100644
index ed918b5..0000000
--- a/src/test/java/com/att/nsa/mr/client/impl/MRConstantsTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * 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 the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-package com.att.nsa.mr.client.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.apache.http.HttpHost;
-import org.junit.Test;
-
-import com.att.nsa.mr.client.impl.MRConstants;
-
-public class MRConstantsTest extends TestCase
-{
- @Test
- public void testPlainHost () throws IOException
- {
- final String rawTopic = "bar";
- final String result = MRConstants.makeUrl ( rawTopic );
- assertEquals ( "/events/" + "bar", result );
- }
-
- @Test
- public void testHostWithProtocol () throws IOException
- {
- final String rawTopic = "bar";
- final String result = MRConstants.makeUrl ( rawTopic );
- assertEquals ( "/events/" + "bar", result );
- }
-
- @Test
- public void testHostWithProtocolAndPort () throws IOException
- {
- final String rawTopic = "bar";
- final String result = MRConstants.makeUrl ( rawTopic );
- assertEquals ( "/events/" + "bar", result );
- }
-
- @Test
- public void testHostWithPort () throws IOException
- {
- final String rawTopic = "bar";
- final String result = MRConstants.makeUrl ( rawTopic );
- assertEquals ( "/events/" + "bar", result );
- }
-
- @Test
- public void testHostWithPortAndEscapedTopic () throws IOException
- {
- final String rawTopic = "bar?bell";
- final String result = MRConstants.makeUrl ( rawTopic );
- assertEquals ( "/events/" + "bar%3Fbell", result );
- }
-
- @Test
- public void testConsumerPlainHost () throws IOException
- {
- final String rawTopic = "bar";
- final String rawGroup = "group";
- final String rawId = "id";
- final String result = MRConstants.makeConsumerUrl ( rawTopic, rawGroup, rawId );
- assertEquals ( "/events/" + "bar/group/id", result );
- }
-
- @Test
- public void testCreateHostList ()
- {
- final ArrayList<String> in = new ArrayList<String> ();
- in.add ( "foo" );
- in.add ( "bar" );
- in.add ( "baz:80" );
-
- final Collection<HttpHost> hosts = MRConstants.createHostsList ( in );
- assertEquals ( 3, hosts.size () );
-
- final Iterator<HttpHost> it = hosts.iterator ();
- final HttpHost first = it.next ();
- assertEquals ( MRConstants.kStdMRServicePort, first.getPort () );
- assertEquals ( "foo", first.getHostName () );
-
- final HttpHost second = it.next ();
- assertEquals ( MRConstants.kStdMRServicePort, second.getPort () );
- assertEquals ( "bar", second.getHostName () );
-
- final HttpHost third = it.next ();
- assertEquals ( 80, third.getPort () );
- assertEquals ( "baz", third.getHostName () );
- }
-
- private static final String[][] hostTests =
- {
- { "host", "host", "" + MRConstants.kStdMRServicePort },
- { ":oops", null, "-1" },
- { "host:1.3", null, "-1" },
- { "host:13", "host", "13" },
- { "host:", "host", "" + MRConstants.kStdMRServicePort },
- };
-
- @Test
- public void testHostParse ()
- {
- for ( String[] test : hostTests )
- {
- final String hostIn = test[0];
- final String hostOut = test[1];
- final int portOut = Integer.parseInt ( test[2] );
-
- try
- {
- final HttpHost hh = MRConstants.hostForString ( hostIn );
- assertEquals ( hostOut, hh.getHostName () );
- assertEquals ( portOut, hh.getPort () );
- }
- catch ( IllegalArgumentException x )
- {
- assertEquals ( -1, portOut );
- }
- }
- }
-}
diff --git a/src/test/java/com/att/nsa/mr/client/impl/MRConsumerImplTest.java b/src/test/java/com/att/nsa/mr/client/impl/MRConsumerImplTest.java
deleted file mode 100644
index bfac947..0000000
--- a/src/test/java/com/att/nsa/mr/client/impl/MRConsumerImplTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * 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 the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-package com.att.nsa.mr.client.impl;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-import com.att.nsa.mr.client.MRClientFactory;
-import com.att.nsa.mr.client.impl.MRConstants;
-import com.att.nsa.mr.client.impl.MRConsumerImpl;
-
-public class MRConsumerImplTest extends TestCase
-{
- @Test
- public void testNullFilter () throws IOException
- {
- final LinkedList<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:8080" );
- final MRConsumerImpl c = new MRConsumerImpl ( hosts, "topic", "cg", "cid", -1, -1, null, null, null );
- final String url = c.createUrlPath (MRConstants.makeConsumerUrl ( "localhost:8080", "topic", "cg", "cid","http" ), -1, -1 );
- assertEquals ("http://localhost:8080/events/" + "topic/cg/cid", url );
- }
-
- @Test
- public void testFilterWithNoTimeoutOrLimit () throws IOException
- {
- final LinkedList<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:8080" );
- final MRConsumerImpl c = new MRConsumerImpl ( hosts, "topic", "cg", "cid", -1, -1, "filter", null, null );
- final String url = c.createUrlPath ( MRConstants.makeConsumerUrl ( "localhost:8080", "topic", "cg", "cid" ,"http"),-1, -1 );
- assertEquals ("http://localhost:8080/events/" + "topic/cg/cid?filter=filter", url );
- }
-
- @Test
- public void testTimeoutNoLimitNoFilter () throws IOException
- {
- final LinkedList<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:8080" );
- final MRConsumerImpl c = new MRConsumerImpl ( hosts, "topic", "cg", "cid", 30000, -1, null, null, null );
- final String url = c.createUrlPath (MRConstants.makeConsumerUrl ( "localhost:8080", "topic", "cg", "cid","http" ), 30000, -1 );
- assertEquals ( "http://localhost:8080/events/" + "topic/cg/cid?timeout=30000", url );
- }
-
- @Test
- public void testNoTimeoutWithLimitNoFilter () throws IOException
- {
- final LinkedList<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:8080" );
- final MRConsumerImpl c = new MRConsumerImpl ( hosts, "topic", "cg", "cid", -1, 100, null, null, null );
- final String url = c.createUrlPath (MRConstants.makeConsumerUrl ( "localhost:8080", "topic", "cg", "cid","http" ), -1, 100 );
- assertEquals ( "http://localhost:8080/events/" + "topic/cg/cid?limit=100", url );
- }
-
- @Test
- public void testWithTimeoutWithLimitWithFilter () throws IOException
- {
- final LinkedList<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:8080" );
- final MRConsumerImpl c = new MRConsumerImpl ( hosts, "topic", "cg", "cid", 1000, 400, "f", null, null );
- final String url = c.createUrlPath (MRConstants.makeConsumerUrl ( "localhost:8080", "topic", "cg", "cid" ,"http"), 1000, 400 );
- assertEquals ("http://localhost:8080/events/" + "topic/cg/cid?timeout=1000&limit=400&filter=f", url );
- }
-
- @Test
- public void testFilterEncoding () throws IOException
- {
- final LinkedList<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:8080" );
- final MRConsumerImpl c = new MRConsumerImpl ( hosts, "topic", "cg", "cid", -1, -1, "{ \"foo\"=\"bar\"bar\" }", null, null );
- final String url = c.createUrlPath (MRConstants.makeConsumerUrl ( "localhost:8080", "topic", "cg", "cid","http" ), -1, -1 );
- assertEquals ( "http://localhost:8080/events/" + "topic/cg/cid?filter=%7B+%22foo%22%3D%22bar%22bar%22+%7D", url );
- }
-
- @Test
- public void testFetchWithReturnConsumerResponse () throws IOException
- {
- final LinkedList<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:8080" );
- Properties properties = new Properties();
- properties.load(MRSimplerBatchConsumerTest.class.getClassLoader().getResourceAsStream("dme2/consumer.properties"));
-
- final MRConsumerImpl c = new MRConsumerImpl ( hosts, "topic", "cg", "cid", -1, -1, "{ \"foo\"=\"bar\"bar\" }", null, null );
- c.fetchWithReturnConsumerResponse();
- c.setProtocolFlag("HTTPAAF");
- c.fetchWithReturnConsumerResponse();
- assertTrue(true);
- }
-}
diff --git a/src/test/java/com/att/nsa/mr/client/impl/MRMetaClientTest.java b/src/test/java/com/att/nsa/mr/client/impl/MRMetaClientTest.java
deleted file mode 100644
index 4a3650f..0000000
--- a/src/test/java/com/att/nsa/mr/client/impl/MRMetaClientTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * 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 the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-package com.att.nsa.mr.client.impl;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static org.junit.Assert.assertTrue;
-
-import com.att.nsa.apiClient.http.HttpException;
-import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
-import com.att.nsa.mr.client.MRClient.MRApiException;
-import com.att.nsa.mr.client.MRTopicManager.TopicInfo;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-
-public class MRMetaClientTest {
-
- @Rule public WireMockRule wireMock = new WireMockRule();
-
- @Before
- public void setUp(){
- wireMock.stubFor(get(urlEqualTo("/topics"))
- .willReturn(aResponse().withBody("{\"topics\":[\"topic1\",\"topic2\"]}").withHeader("Content-Type", "application/json")));
- wireMock.stubFor(get(urlEqualTo("/topics/topic1"))
- .willReturn(aResponse().withBody("{\"topics\":[\"topic1\",\"topic2\"]}").withHeader("Content-Type", "application/json")));
- wireMock.stubFor(post(urlEqualTo("/topics/create"))
- .willReturn(aResponse().withStatus(200)));
- }
-
- @Test
- public void getTopicsTest()
- {
- final Collection<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:" + wireMock.port() );
-
- MRMetaClient c;
- try {
- c = new MRMetaClient(hosts);
- Set<String> setString=c.getTopics();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
-
- // assertEquals ("http://localhost:8080/events/" + "topic/cg/cid", url );
-
- }
-
- @Test
- public void getTopicMetadataTest() {
- final Collection<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:" + wireMock.port() );
-
- final String topic ="topic1";
-
- MRMetaClient c;
- try {
- c = new MRMetaClient(hosts);
- TopicInfo topicInfo=c.getTopicMetadata(topic);
- } catch (IOException | HttpObjectNotFoundException e) {
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testcreateTopic(){
- final Collection<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:" + wireMock.port() );
-
- MRMetaClient c;
- try {
- c = new MRMetaClient(hosts);
- c.createTopic("topic1", "testTopic", 1, 1);
- } catch (IOException | HttpException e) {
- e.printStackTrace();
- }
- }
- @Test
- public void testupdateApiKey(){
- final Collection<String> hosts = new LinkedList<String> ();
- hosts.add ( "localhost:" + wireMock.port() );
-
- MRMetaClient c;
- try {
- c = new MRMetaClient(hosts);
- c.updateCurrentApiKey("test@onap.com", "test email");
- }catch (HttpException e) {
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
-
-}
diff --git a/src/test/java/com/att/nsa/mr/client/impl/MRSimplerBatchConsumerTest.java b/src/test/java/com/att/nsa/mr/client/impl/MRSimplerBatchConsumerTest.java
deleted file mode 100644
index 506d277..0000000
--- a/src/test/java/com/att/nsa/mr/client/impl/MRSimplerBatchConsumerTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * 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 the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-
-package com.att.nsa.mr.client.impl;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.json.JSONObject;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.att.nsa.mr.client.MRClientFactory;
-import com.att.nsa.mr.client.MRConsumer;
-import com.att.nsa.mr.client.MRPublisher.message;
-import com.att.nsa.mr.client.response.MRPublisherResponse;
-
-public class MRSimplerBatchConsumerTest {
-
- File outFile;
- @Before
- public void setUp() throws Exception {
- Properties properties = new Properties();
- properties.load(MRSimplerBatchConsumerTest.class.getClassLoader().getResourceAsStream("dme2/consumer.properties"));
-
- String routeFilePath="dme2/preferredRoute.txt";
-
- File file = new File(MRSimplerBatchConsumerTest.class.getClassLoader().getResource(routeFilePath).getFile());
- properties.put("DME2preferredRouterFilePath", MRSimplerBatchConsumerTest.class.getClassLoader().getResource(routeFilePath).getFile());
-
- outFile = new File(file.getParent() + "/consumer_tmp.properties");
- properties.store(new FileOutputStream(outFile), "");
- }
-
- @Test
- public void testSend() throws IOException, InterruptedException {
-
- final MRConsumer cc = MRClientFactory.createConsumer(outFile.getPath());
-
- try {
- for(String msg : cc.fetch()){
- System.out.println(msg);
- }
- } catch (Exception e) {
- System.err.println ( e.getClass().getName () + ": " + e.getMessage () );
- }
-
- }
-
-
-}
diff --git a/src/test/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisherTest.java b/src/test/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisherTest.java
deleted file mode 100644
index 5b8d580..0000000
--- a/src/test/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisherTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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
- *
- * 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 the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-
-package com.att.nsa.mr.client.impl;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.json.JSONObject;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.att.nsa.mr.client.MRClientFactory;
-import com.att.nsa.mr.client.MRPublisher.message;
-import com.att.nsa.mr.client.response.MRPublisherResponse;
-
-public class MRSimplerBatchPublisherTest {
-
- File outFile;
- @Before
- public void setUp() throws Exception {
- Properties properties = new Properties();
- properties.load(MRSimplerBatchPublisherTest.class.getClassLoader().getResourceAsStream("dme2/producer.properties"));
-
- String routeFilePath="dme2/preferredRoute.txt";
-
- File file = new File(MRSimplerBatchPublisherTest.class.getClassLoader().getResource(routeFilePath).getFile());
- properties.put("DME2preferredRouterFilePath", MRSimplerBatchPublisherTest.class.getClassLoader().getResource(routeFilePath).getFile());
-
- outFile = new File(file.getParent() + "/producer_tmp.properties");
- properties.store(new FileOutputStream(outFile), "");
- }
-
- @Test
- public void testSend() throws IOException, InterruptedException {
-
- final MRSimplerBatchPublisher pub = (MRSimplerBatchPublisher)MRClientFactory.createBatchingPublisher(outFile.getPath());
-
- //publish some messages
- final JSONObject msg1 = new JSONObject ();
- pub.send ( "MyPartitionKey", msg1.toString () );
-
- final List<message> stuck = pub.close ( 1, TimeUnit.SECONDS );
- if ( stuck.size () > 0 ) {
- System.out.println( stuck.size() + " messages unsent" );
- }
- else
- {
- System.out.println ( "Clean exit; all messages sent." );
- }
-
-
- }
-
- @Test
- public void testSendBatchWithResponse() throws IOException, InterruptedException {
-
- final MRSimplerBatchPublisher pub = (MRSimplerBatchPublisher)MRClientFactory.createBatchingPublisher(outFile.getPath(), true);
-
- //publish some messages
- final JSONObject msg1 = new JSONObject ();
- pub.send ( "MyPartitionKey", msg1.toString () );
- MRPublisherResponse pubResponse = new MRPublisherResponse();
- pub.setPubResponse(pubResponse);
-
- MRPublisherResponse mrPublisherResponse = pub.sendBatchWithResponse();
- Assert.assertEquals(1, mrPublisherResponse.getPendingMsgs());
-
- }
-
-}