diff options
author | sunil unnava <sunil.unnava@att.com> | 2018-10-23 10:31:46 -0400 |
---|---|---|
committer | sunil unnava <sunil.unnava@att.com> | 2018-10-23 10:33:54 -0400 |
commit | 0cb18b0baa2cf750e557262d821bbf2a03326bbe (patch) | |
tree | 8ca6880c9cc4f3bfc9d76575ef03ca647863415a /src/test/java/com/att/nsa/mr/client | |
parent | 9775bb11c919b0a8d89d81abf1b1a76bb7592f78 (diff) |
update the package name
Issue-ID: DMAAP-858
Change-Id: Ia69621ea6ad2ec2ec525800af2a7d3f73aef82ed
Signed-off-by: sunil unnava <sunil.unnava@att.com>
Diffstat (limited to 'src/test/java/com/att/nsa/mr/client')
17 files changed, 0 insertions, 2100 deletions
diff --git a/src/test/java/com/att/nsa/mr/client/HostSelectorTest.java b/src/test/java/com/att/nsa/mr/client/HostSelectorTest.java deleted file mode 100644 index fd6dee8..0000000 --- a/src/test/java/com/att/nsa/mr/client/HostSelectorTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 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=========================================================
- */
-
-package com.att.nsa.mr.client;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.att.nsa.mr.client.HostSelector;
-
-public class HostSelectorTest {
-
- @Before
- public void setUp() throws Exception {
-
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
-
- @Test
- public void testSelectBaseHost() {
-
- HostSelector selector = new HostSelector("host");
-
- selector.selectBaseHost();
- assertTrue(true);
-
-
- }
-
- @Test
- public void testReportReachabilityProblem() {
-
- HostSelector selector = new HostSelector("host");
-
- selector.reportReachabilityProblem(100, null);
- assertTrue(true);
-
-
- }
-}
-
diff --git a/src/test/java/com/att/nsa/mr/client/JUnitTestSuite.java b/src/test/java/com/att/nsa/mr/client/JUnitTestSuite.java deleted file mode 100644 index 095e1d8..0000000 --- a/src/test/java/com/att/nsa/mr/client/JUnitTestSuite.java +++ /dev/null @@ -1,43 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 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=========================================================
- */
-
-package com.att.nsa.mr.client;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ HostSelectorTest.class, MRClientBuildersTest.class, MRClientFactoryTest.class})
-
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
diff --git a/src/test/java/com/att/nsa/mr/client/MRClientBuildersTest.java b/src/test/java/com/att/nsa/mr/client/MRClientBuildersTest.java deleted file mode 100644 index 9a0a3ce..0000000 --- a/src/test/java/com/att/nsa/mr/client/MRClientBuildersTest.java +++ /dev/null @@ -1,248 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright © 2018 IBM.
- * ================================================================================
- * 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=========================================================
- */
-
-package com.att.nsa.mr.client;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.att.nsa.mr.client.HostSelector;
-import com.att.nsa.mr.client.MRClient;
-import com.att.nsa.mr.client.MRClientBuilders;
-
-public class MRClientBuildersTest {
-
- private Collection<String> hostSet = new ArrayList<String>();
- private MRClientBuilders.ConsumerBuilder builder = null;
- private MRClientBuilders.PublisherBuilder pBuilder = null;
- private String[] hostArray = new String[10];
-
- @Before
- public void setUp() throws Exception {
-
- for (int i = 0; i < 10; i++) {
- hostSet.add("host" + (i + 1));
- hostArray[i] = "host" + (i + 1);
- }
-
- builder = new MRClientBuilders.ConsumerBuilder();
-
- pBuilder = new MRClientBuilders.PublisherBuilder();
-
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void testUsingHosts() {
-
- builder.usingHosts("hostList");
- assertTrue(true);
-
- }
-
- @Test
- public void testUsingHosts2() {
-
- builder.usingHosts(hostSet);
- assertTrue(true);
-
- }
-
- @Test
- public void testOnTopic() {
-
- builder.onTopic("testTopic");
- assertTrue(true);
-
- }
-
- @Test
- public void testKnownAs() {
-
- builder.knownAs("CG1", "23");
- assertTrue(true);
-
- }
-
- @Test
- public void testAuthenticatedBy() {
-
- builder.authenticatedBy("apikey", "apisecret");
- assertTrue(true);
-
- }
-
- @Test
- public void testWaitAtServer() {
-
- builder.waitAtServer(100);
- assertTrue(true);
-
- }
-
- @Test
- public void testReceivingAtMost() {
-
- builder.receivingAtMost(100);
- assertTrue(true);
-
- }
-
- @Test
- public void testWithServerSideFilter() {
-
- builder.withServerSideFilter("filter");
- assertTrue(true);
-
- }
-
- @Test
- public void testBuild() {
-
- try {
-
- builder.build();
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testUsingHosts3() {
-
- pBuilder.usingHosts("testTopic");
- assertTrue(true);
-
- }
-
- @Test
- public void testUsingHosts4() {
-
- pBuilder.usingHosts(hostArray);
- assertTrue(true);
-
- }
-
- @Test
- public void testUsingHosts5() {
-
- pBuilder.usingHosts(hostSet);
- assertTrue(true);
-
- }
-
- @Test
- public void testOnTopic2() {
-
- pBuilder.onTopic("testTopic");
- assertTrue(true);
-
- }
-
- @Test
- public void testLimitBatch() {
-
- pBuilder.limitBatch(100, 10);
- assertTrue(true);
-
- }
-
- @Test
- public void testWithCompresion() {
-
- pBuilder.withCompresion();
- assertTrue(true);
-
- }
-
- @Test
- public void testWithoutCompresion() {
-
- pBuilder.withoutCompresion();
- assertTrue(true);
-
- }
-
- @Test
- public void testEnableCompresion() {
-
- pBuilder.enableCompresion(true);
- assertTrue(true);
-
- }
-
- @Test
- public void testAuthenticatedBy2() {
-
- pBuilder.authenticatedBy("apikey", "apisecret");
- assertTrue(true);
-
- }
-
- @Test
- public void testBuild2() {
-
- try {
-
- pBuilder.build();
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void test$testInject() {
-
- try {
-
- MRClientBuilders.$testInject(builder.build());
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void test$testInject2() {
-
- try {
-
- MRClientBuilders.$testInject(pBuilder.build());
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
-
- }
-}
diff --git a/src/test/java/com/att/nsa/mr/client/MRClientFactoryTest.java b/src/test/java/com/att/nsa/mr/client/MRClientFactoryTest.java deleted file mode 100644 index 7ea091b..0000000 --- a/src/test/java/com/att/nsa/mr/client/MRClientFactoryTest.java +++ /dev/null @@ -1,252 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright © 2018 IBM.
- * ================================================================================
- * 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=========================================================
- */
-
-package com.att.nsa.mr.client;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.att.nsa.mr.client.HostSelector;
-import com.att.nsa.mr.client.MRClient;
-import com.att.nsa.mr.client.MRClientBuilders;
-import com.att.nsa.mr.client.MRClientFactory;
-
-public class MRClientFactoryTest {
-
- private Collection<String> hostSet = new ArrayList<String>();
-
- private String[] hostArray = new String[10];
-
- @Before
- public void setUp() throws Exception {
-
- for (int i = 0; i < 10; i++) {
- hostSet.add("host" + (i + 1));
- hostArray[i] = "host" + (i + 1);
- }
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void testCreateConsumer() {
-
- MRClientFactory.createConsumer("hostList hostList2", "testTopic");
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer2() {
-
- MRClientFactory.createConsumer(hostSet, "testTopic");
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer3() {
-
- MRClientFactory.createConsumer(hostSet, "testTopic", "filter");
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer4() {
-
- MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22");
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer5() {
-
- MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100);
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer6() {
-
- MRClientFactory.createConsumer("hostList", "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer7() {
-
- MRClientFactory.createConsumer(hostSet, "testTopic", "CG1", "22", 100, 100, "filter", "apikey", "apisecret");
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateSimplePublisher() {
-
- MRClientFactory.createSimplePublisher("hostList", "testTopic");
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateBatchingPublisher1() {
-
- MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10);
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateBatchingPublisher2() {
-
- MRClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 10, true);
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateBatchingPublisher3() {
-
- MRClientFactory.createBatchingPublisher(hostArray, "testTopic", 100, 10, true);
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateBatchingPublisher4() {
-
- MRClientFactory.createBatchingPublisher(hostSet, "testTopic", 100, 10, true);
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateBatchingPublisher5() {
-
- MRClientFactory.createBatchingPublisher("host", "testTopic", "username", "password", 100, 10, true,
- "protocolFlag");
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateBatchingPublisher6() {
-
- try {
- MRClientFactory.createBatchingPublisher("/producer");
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateBatchingPublisher7() {
-
- try {
- MRClientFactory.createBatchingPublisher("/producer", true);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateIdentityManager() {
-
- MRClientFactory.createIdentityManager(hostSet, "apikey", "apisecret");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateTopicManager() {
-
- MRClientFactory.createTopicManager(hostSet, "apikey", "apisecret");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer8() {
-
- try {
- MRClientFactory.createConsumer("/consumer");
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer9() {
-
- MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", "protocolFlag",
- "/consumer", 1, 2);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCreateConsumer10() {
-
- MRClientFactory.createConsumer("host", "topic", "username", "password", "group", "23", 1, 2, "protocolFlag",
- "/consumer");
-
- assertTrue(true);
-
- }
-
- @Test
- public void test$testInject() {
-
- MRClientFactory.$testInject(null);
- assertTrue(true);
-
- }
-
-}
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/mr/client/TestRunner.java b/src/test/java/com/att/nsa/mr/client/TestRunner.java deleted file mode 100644 index 814354c..0000000 --- a/src/test/java/com/att/nsa/mr/client/TestRunner.java +++ /dev/null @@ -1,41 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 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=========================================================
- */
-
-package com.att.nsa.mr.client;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}
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());
-
- }
-
-}
diff --git a/src/test/java/com/att/nsa/mr/client/response/JUnitTestSuite.java b/src/test/java/com/att/nsa/mr/client/response/JUnitTestSuite.java deleted file mode 100644 index 90b10a9..0000000 --- a/src/test/java/com/att/nsa/mr/client/response/JUnitTestSuite.java +++ /dev/null @@ -1,43 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 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=========================================================
- */
-
-package com.att.nsa.mr.client.response;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ MRConsumerResponseTest.class, MRPublisherResponseTest.class,})
-
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
diff --git a/src/test/java/com/att/nsa/mr/client/response/MRConsumerResponseTest.java b/src/test/java/com/att/nsa/mr/client/response/MRConsumerResponseTest.java deleted file mode 100644 index 036a216..0000000 --- a/src/test/java/com/att/nsa/mr/client/response/MRConsumerResponseTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 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=========================================================
- */
-
-package com.att.nsa.mr.client.response;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.att.nsa.mr.client.HostSelector;
-
-public class MRConsumerResponseTest {
- private MRConsumerResponse test = null;
-
- @Before
- public void setUp() throws Exception {
- test = new MRConsumerResponse();
-
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void testGetResponseCode() {
-
- test.getResponseCode();
- assertTrue(true);
-
- }
-
- @Test
- public void testSetResponseCode() {
-
- test.setResponseCode("200");
- assertTrue(true);
-
- }
-
- @Test
- public void testGetResponseMessage() {
-
- test.getResponseMessage();
- assertTrue(true);
-
- }
-
- @Test
- public void testSetResponseMessage() {
-
- test.setResponseMessage("responseMessage");
- assertTrue(true);
-
- }
-
- @Test
- public void testGetActualMessages() {
-
- test.getActualMessages();
- assertTrue(true);
-
- }
-
- @Test
- public void testSetActualMessages() {
-
- test.setActualMessages(null);
- assertTrue(true);
-
- }
-}
diff --git a/src/test/java/com/att/nsa/mr/client/response/MRPublisherResponseTest.java b/src/test/java/com/att/nsa/mr/client/response/MRPublisherResponseTest.java deleted file mode 100644 index 60e64ad..0000000 --- a/src/test/java/com/att/nsa/mr/client/response/MRPublisherResponseTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 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=========================================================
- */
-
-package com.att.nsa.mr.client.response;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.att.nsa.mr.client.HostSelector;
-
-public class MRPublisherResponseTest {
- private MRPublisherResponse response = null;
-
- @Before
- public void setUp() throws Exception {
- response = new MRPublisherResponse();
-
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void testGetResponseCode() {
-
- response.getResponseCode();
- assertTrue(true);
-
- }
-
- @Test
- public void testSetResponseCode() {
-
- response.setResponseCode("200");
- assertTrue(true);
-
- }
-
- @Test
- public void testGetResponseMessage() {
-
- response.getResponseMessage();
- assertTrue(true);
-
- }
-
- @Test
- public void testSetResponseMessage() {
-
- response.setResponseMessage("responseMessage");
- assertTrue(true);
-
- }
-
- @Test
- public void testGetPendingMsgs() {
-
- response.getPendingMsgs();
- assertTrue(true);
-
- }
-
- @Test
- public void testSetPendingMsgs() {
-
- response.setPendingMsgs(5);
- assertTrue(true);
-
- }
-
- @Test
- public void testToString() {
-
- response.toString();
- assertTrue(true);
-
- }
-
-
-}
diff --git a/src/test/java/com/att/nsa/mr/client/response/TestRunner.java b/src/test/java/com/att/nsa/mr/client/response/TestRunner.java deleted file mode 100644 index f2abadc..0000000 --- a/src/test/java/com/att/nsa/mr/client/response/TestRunner.java +++ /dev/null @@ -1,41 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 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=========================================================
- */
-
-package com.att.nsa.mr.client.response;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}
|