aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/HostSelectorTest.java68
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/MRClientBuildersTest.java248
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/MRClientFactoryTest.java252
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java85
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java471
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/MRBatchPublisherTest.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/MRConstantsTest.java143
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/MRConsumerImplTest.java112
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/MRMetaClientTest.java129
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchConsumerTest.java76
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisherTest.java96
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/response/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/response/MRConsumerResponseTest.java94
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/response/MRPublisherResponseTest.java104
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/response/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/dme/client/DefaultLoggingFailoverFaultHandlerTest.java69
-rw-r--r--src/test/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandlerTest.java79
-rw-r--r--src/test/java/org/onap/dmaap/mr/dme/client/JUnitTestSuite.java44
-rw-r--r--src/test/java/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandlerTest.java88
-rw-r--r--src/test/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandlerTest.java74
-rw-r--r--src/test/java/org/onap/dmaap/mr/dme/client/SimpleExamplePublisherTest.java68
-rw-r--r--src/test/java/org/onap/dmaap/mr/dme/client/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/logging/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/logging/MRAppenderTest.java184
-rw-r--r--src/test/java/org/onap/dmaap/mr/logging/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/ConsolePublisherTest.java55
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/JUnitTestSuite.java45
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/ProtocolTypeConstantsTest.java61
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/SampleConsumerTest.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/SamplePublisherTest.java55
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/SimpleExampleConsumerTest.java55
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/SimpleExampleConsumerWithReturnResponseTest.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/SimpleExamplePublisherTest.java80
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/SimpleExamplePublisherWithResponseTest.java68
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/clients/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/support/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/support/MRBatchingPublisherMockTest.java191
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/support/MRConsumerMockTest.java174
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/support/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/ApiKeyCommandTest.java217
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/AuthCommandTest.java113
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/ClusterCommandTest.java106
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/JUnitTestSuite.java44
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/MRCommandContextTest.java165
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/MessageCommandTest.java214
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/ToolsUtilTest.java51
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/TopicCommandTest.java224
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/TraceCommandTest.java102
-rw-r--r--src/test/java/org/onap/dmaap/mr/tools/ValidatorUtilTest.java315
52 files changed, 5440 insertions, 0 deletions
diff --git a/src/test/java/org/onap/dmaap/mr/client/HostSelectorTest.java b/src/test/java/org/onap/dmaap/mr/client/HostSelectorTest.java
new file mode 100644
index 0000000..ecc4b51
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/HostSelectorTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.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/org/onap/dmaap/mr/client/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/client/JUnitTestSuite.java
new file mode 100644
index 0000000..b791b51
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/JUnitTestSuite.java
@@ -0,0 +1,43 @@
+/*-
+ * ============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 org.onap.dmaap.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/org/onap/dmaap/mr/client/MRClientBuildersTest.java b/src/test/java/org/onap/dmaap/mr/client/MRClientBuildersTest.java
new file mode 100644
index 0000000..388a91c
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/MRClientBuildersTest.java
@@ -0,0 +1,248 @@
+/*-
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRClient;
+import org.onap.dmaap.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/org/onap/dmaap/mr/client/MRClientFactoryTest.java b/src/test/java/org/onap/dmaap/mr/client/MRClientFactoryTest.java
new file mode 100644
index 0000000..0d151b9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/MRClientFactoryTest.java
@@ -0,0 +1,252 @@
+/*-
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRClient;
+import org.onap.dmaap.mr.client.MRClientBuilders;
+import org.onap.dmaap.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/org/onap/dmaap/mr/client/TestRunner.java b/src/test/java/org/onap/dmaap/mr/client/TestRunner.java
new file mode 100644
index 0000000..f9b8a86
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/TestRunner.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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 org.onap.dmaap.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/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java
new file mode 100644
index 0000000..6fb31a6
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/DMaapClientUtilTest.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.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/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java
new file mode 100644
index 0000000..6fe0e70
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java
@@ -0,0 +1,471 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.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/org/onap/dmaap/mr/client/impl/MRBatchPublisherTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/MRBatchPublisherTest.java
new file mode 100644
index 0000000..f13e7fa
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/MRBatchPublisherTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.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/org/onap/dmaap/mr/client/impl/MRConstantsTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/MRConstantsTest.java
new file mode 100644
index 0000000..3a427e0
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/MRConstantsTest.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.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/org/onap/dmaap/mr/client/impl/MRConsumerImplTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/MRConsumerImplTest.java
new file mode 100644
index 0000000..5d8dccd
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/MRConsumerImplTest.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.mr.client.impl;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.MRClientFactory;
+import org.onap.dmaap.mr.client.impl.MRConstants;
+import org.onap.dmaap.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/org/onap/dmaap/mr/client/impl/MRMetaClientTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/MRMetaClientTest.java
new file mode 100644
index 0000000..6c2b219
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/MRMetaClientTest.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.mr.client.MRClient.MRApiException;
+import org.onap.dmaap.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/org/onap/dmaap/mr/client/impl/MRSimplerBatchConsumerTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchConsumerTest.java
new file mode 100644
index 0000000..af02c2f
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchConsumerTest.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.mr.client.MRClientFactory;
+import org.onap.dmaap.mr.client.MRConsumer;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.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/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisherTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisherTest.java
new file mode 100644
index 0000000..2f9b519
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisherTest.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.mr.client.MRClientFactory;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.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/org/onap/dmaap/mr/client/response/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/client/response/JUnitTestSuite.java
new file mode 100644
index 0000000..1cfaef4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/response/JUnitTestSuite.java
@@ -0,0 +1,43 @@
+/*-
+ * ============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 org.onap.dmaap.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/org/onap/dmaap/mr/client/response/MRConsumerResponseTest.java b/src/test/java/org/onap/dmaap/mr/client/response/MRConsumerResponseTest.java
new file mode 100644
index 0000000..3f727a4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/response/MRConsumerResponseTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.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/org/onap/dmaap/mr/client/response/MRPublisherResponseTest.java b/src/test/java/org/onap/dmaap/mr/client/response/MRPublisherResponseTest.java
new file mode 100644
index 0000000..f4957db
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/response/MRPublisherResponseTest.java
@@ -0,0 +1,104 @@
+/*-
+ * ============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 org.onap.dmaap.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 org.onap.dmaap.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/org/onap/dmaap/mr/client/response/TestRunner.java b/src/test/java/org/onap/dmaap/mr/client/response/TestRunner.java
new file mode 100644
index 0000000..9bf5880
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/client/response/TestRunner.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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 org.onap.dmaap.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());
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/dme/client/DefaultLoggingFailoverFaultHandlerTest.java b/src/test/java/org/onap/dmaap/mr/dme/client/DefaultLoggingFailoverFaultHandlerTest.java
new file mode 100644
index 0000000..b1c7e15
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/dme/client/DefaultLoggingFailoverFaultHandlerTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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 org.onap.dmaap.mr.dme.client;
+
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Listener;
+
+public class DefaultLoggingFailoverFaultHandlerTest {
+ private DefaultLoggingFailoverFaultHandler handler = null;
+
+ @Before
+ public void setUp() throws Exception {
+ handler = new DefaultLoggingFailoverFaultHandler();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testHandleEndpointFailover() {
+
+ /* handler.handleEndpointFailover(null);
+ assertTrue(true);*/
+
+ }
+
+ @Test
+ public void testHandleRouteOfferFailover() {
+
+ /* handler.handleRouteOfferFailover(null);
+ assertTrue(true);
+*/
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandlerTest.java b/src/test/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandlerTest.java
new file mode 100644
index 0000000..df236c9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandlerTest.java
@@ -0,0 +1,79 @@
+/*-
+ * ============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 org.onap.dmaap.mr.dme.client;
+
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Listener;
+
+public class HeaderReplyHandlerTest {
+ private HeaderReplyHandler handler = null;
+
+ @Before
+ public void setUp() throws Exception {
+ handler = new HeaderReplyHandler();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testHandleFault() {
+
+ handler.handleFault(null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testHandleEndpointFault() {
+
+ handler.handleEndpointFault(null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testHandleReply() {
+
+ handler.handleReply(null);
+ assertTrue(true);
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/dme/client/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/dme/client/JUnitTestSuite.java
new file mode 100644
index 0000000..0d4c69a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/dme/client/JUnitTestSuite.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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 org.onap.dmaap.mr.dme.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({ DefaultLoggingFailoverFaultHandlerTest.class, HeaderReplyHandlerTest.class,PreferredRouteReplyHandlerTest.class,
+ PreferredRouteRequestHandlerTest.class,SimpleExamplePublisherTest.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/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandlerTest.java b/src/test/java/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandlerTest.java
new file mode 100644
index 0000000..5aa3018
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandlerTest.java
@@ -0,0 +1,88 @@
+/*-
+ * ============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 org.onap.dmaap.mr.dme.client;
+
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Listener;
+
+public class PreferredRouteReplyHandlerTest {
+ private PreferredRouteReplyHandler handler = null;
+
+ @Before
+ public void setUp() throws Exception {
+ handler = new PreferredRouteReplyHandler();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testHandleReply() {
+
+// handler.handleReply(null);
+// assertTrue(true);
+
+ }
+
+ @Test
+ public void testHandleFault() {
+/*
+ handler.handleFault(null);
+ assertTrue(true);
+*/
+ }
+
+ @Test
+ public void testHandleEndpointFault() {
+
+/* handler.handleEndpointFault(null);
+ assertTrue(true);*/
+
+ }
+
+ @Test
+ public void testRouteWriter() {
+/*
+ handler.routeWriter("routeKey", "routeValue");
+ assertTrue(true);
+*/
+ }
+
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandlerTest.java b/src/test/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandlerTest.java
new file mode 100644
index 0000000..cf5b607
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandlerTest.java
@@ -0,0 +1,74 @@
+/*-
+ * ============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 org.onap.dmaap.mr.dme.client;
+
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Listener;
+
+public class PreferredRouteRequestHandlerTest {
+ private PreferredRouteRequestHandler handler = null;
+
+ @Before
+ public void setUp() throws Exception {
+ handler = new PreferredRouteRequestHandler();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testHandleRequest() {
+
+ /* handler.handleRequest(null);
+ assertTrue(true);*/
+
+ }
+
+ @Test
+ public void testReadRoute() {
+
+// try {
+// handler.readRoute("routeKey");
+// } catch (NullPointerException e) {
+// assertTrue(true);
+// }
+//
+// assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/dme/client/SimpleExamplePublisherTest.java b/src/test/java/org/onap/dmaap/mr/dme/client/SimpleExamplePublisherTest.java
new file mode 100644
index 0000000..1240d8b
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/dme/client/SimpleExamplePublisherTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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 org.onap.dmaap.mr.dme.client;
+
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Listener;
+
+public class SimpleExamplePublisherTest {
+ private SimpleExamplePublisher pub = null;
+
+ @Before
+ public void setUp() throws Exception {
+ pub = new SimpleExamplePublisher();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testPublishMessage() {
+
+ try {
+ pub.publishMessage("/producer");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/dme/client/TestRunner.java b/src/test/java/org/onap/dmaap/mr/dme/client/TestRunner.java
new file mode 100644
index 0000000..74928c9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/dme/client/TestRunner.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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 org.onap.dmaap.mr.dme.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/org/onap/dmaap/mr/logging/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/logging/JUnitTestSuite.java
new file mode 100644
index 0000000..8828d1c
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/logging/JUnitTestSuite.java
@@ -0,0 +1,43 @@
+/*-
+ * ============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 org.onap.dmaap.mr.logging;
+
+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({ MRAppenderTest.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/org/onap/dmaap/mr/logging/MRAppenderTest.java b/src/test/java/org/onap/dmaap/mr/logging/MRAppenderTest.java
new file mode 100644
index 0000000..8332606
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/logging/MRAppenderTest.java
@@ -0,0 +1,184 @@
+/*-
+ * ============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 org.onap.dmaap.mr.logging;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.HostSelector;
+
+public class MRAppenderTest {
+ private MRAppender appender = null;
+
+ @Before
+ public void setUp() throws Exception {
+ appender = new MRAppender();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testClose() {
+ try {
+ appender.close();
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testRequiresLayout() {
+
+ appender.requiresLayout();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAppend() {
+
+ try {
+ appender.append(null);
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testActivateOptions() {
+
+ appender.activateOptions();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetTopic() {
+
+ appender.getTopic();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetTopic() {
+
+ appender.setTopic("testTopic");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetPartition() {
+
+ appender.getPartition();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetPartition() {
+
+ appender.setPartition("partition");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetHosts() {
+
+ appender.getHosts();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetHosts() {
+
+ appender.setHosts("hosts");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetMaxBatchSize() {
+
+ appender.getMaxBatchSize();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetMaxBatchSize() {
+
+ appender.setMaxBatchSize(20);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetMaxAgeMs() {
+
+ appender.getMaxAgeMs();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetMaxAgeMs() {
+
+ appender.setMaxAgeMs(15);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testIsCompress() {
+
+ appender.isCompress();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetCompress() {
+
+ appender.setCompress(true);
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/logging/TestRunner.java b/src/test/java/org/onap/dmaap/mr/logging/TestRunner.java
new file mode 100644
index 0000000..8e77136
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/logging/TestRunner.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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 org.onap.dmaap.mr.logging;
+
+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/org/onap/dmaap/mr/test/clients/ConsolePublisherTest.java b/src/test/java/org/onap/dmaap/mr/test/clients/ConsolePublisherTest.java
new file mode 100644
index 0000000..218e6c8
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/ConsolePublisherTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ConsolePublisherTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testMain() {
+
+ try {
+ ConsolePublisher.main(null);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/clients/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/test/clients/JUnitTestSuite.java
new file mode 100644
index 0000000..eb0ca3d
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/JUnitTestSuite.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+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({ SimpleExamplePublisherTest.class, ProtocolTypeConstantsTest.class,
+ SampleConsumerTest.class, SamplePublisherTest.class, SimpleExampleConsumerTest.class, ConsolePublisherTest.class,
+ SimpleExamplePublisherWithResponseTest.class, SimpleExampleConsumerWithReturnResponseTest.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/org/onap/dmaap/mr/test/clients/ProtocolTypeConstantsTest.java b/src/test/java/org/onap/dmaap/mr/test/clients/ProtocolTypeConstantsTest.java
new file mode 100644
index 0000000..52310bf
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/ProtocolTypeConstantsTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ProtocolTypeConstantsTest {
+ private ProtocolTypeConstants constants = null;
+
+ @Before
+ public void setUp() throws Exception {
+ // constants = new ProtocolTypeConstants();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testGetValue() {
+
+ try {
+ constants.getValue();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/clients/SampleConsumerTest.java b/src/test/java/org/onap/dmaap/mr/test/clients/SampleConsumerTest.java
new file mode 100644
index 0000000..6c5d93f
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/SampleConsumerTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SampleConsumerTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testMain() {
+
+ try {
+ SampleConsumer.main( new String[0]);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/clients/SamplePublisherTest.java b/src/test/java/org/onap/dmaap/mr/test/clients/SamplePublisherTest.java
new file mode 100644
index 0000000..3a012a7
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/SamplePublisherTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SamplePublisherTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testMain() {
+
+ try {
+ SamplePublisher.main( new String[0]);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExampleConsumerTest.java b/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExampleConsumerTest.java
new file mode 100644
index 0000000..310ea45
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExampleConsumerTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SimpleExampleConsumerTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testMain() {
+
+ try {
+ SimpleExampleConsumer.main(null);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExampleConsumerWithReturnResponseTest.java b/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExampleConsumerWithReturnResponseTest.java
new file mode 100644
index 0000000..3c3b3d7
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExampleConsumerWithReturnResponseTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SimpleExampleConsumerWithReturnResponseTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testMain() {
+
+ try {
+ SimpleExampleConsumerWithReturnResponse.main(null);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExamplePublisherTest.java b/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExamplePublisherTest.java
new file mode 100644
index 0000000..43faf5e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExamplePublisherTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SimpleExamplePublisherTest {
+ private SimpleExamplePublisher pub = null;
+
+ @Before
+ public void setUp() throws Exception {
+ pub = new SimpleExamplePublisher();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testPublishMessage() {
+ try {
+ pub.publishMessage("/producer");
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testMain() {
+
+ try {
+ SimpleExamplePublisher.main(null);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExamplePublisherWithResponseTest.java b/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExamplePublisherWithResponseTest.java
new file mode 100644
index 0000000..44dd7cf
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/SimpleExamplePublisherWithResponseTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SimpleExamplePublisherWithResponseTest {
+
+ private SimpleExamplePublisherWithResponse pub = null;
+
+ @Before
+ public void setUp() throws Exception {
+ pub = new SimpleExamplePublisherWithResponse();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testMain() {
+
+ try {
+ SimpleExamplePublisherWithResponse.main( new String[0]);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testPublishMessage() {
+
+ try {
+ pub.publishMessage("/producer", 100);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/clients/TestRunner.java b/src/test/java/org/onap/dmaap/mr/test/clients/TestRunner.java
new file mode 100644
index 0000000..7e3d724
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/clients/TestRunner.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.clients;
+
+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/org/onap/dmaap/mr/test/support/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/test/support/JUnitTestSuite.java
new file mode 100644
index 0000000..6c2e0fc
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/support/JUnitTestSuite.java
@@ -0,0 +1,43 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.support;
+
+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({ MRBatchingPublisherMockTest.class, MRConsumerMockTest.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/org/onap/dmaap/mr/test/support/MRBatchingPublisherMockTest.java b/src/test/java/org/onap/dmaap/mr/test/support/MRBatchingPublisherMockTest.java
new file mode 100644
index 0000000..1d6bd7c
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/support/MRBatchingPublisherMockTest.java
@@ -0,0 +1,191 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.support;
+
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Listener;
+
+public class MRBatchingPublisherMockTest {
+ private MRBatchingPublisherMock pub = null;
+
+ private MRBatchingPublisherMock.Entry entry = null;
+
+ @Before
+ public void setUp() throws Exception {
+ pub = new MRBatchingPublisherMock();
+ entry = pub.new Entry("partition", "msg");
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testToString() {
+
+ entry.toString();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAddListener() {
+
+ pub.addListener(null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetCaptures() {
+
+ pub.getCaptures();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetCaptures2() {
+
+ pub.getCaptures(null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testReceived() {
+
+ pub.received();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testResend() {
+
+ pub.reset();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSend() {
+
+ pub.send("partition", "msg");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSend2() {
+
+ pub.send("msg");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSend3() {
+ //sending message m obj
+ pub.send(new ArrayList<message>());
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSend4() {
+ //sending collection of message m objects
+ pub.send(new message("partition", "msg"));
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSendBatchWithResponse() {
+
+ pub.sendBatchWithResponse();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testLogTo() {
+
+ pub.logTo(null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testClearApiCredentials() {
+
+ pub.clearApiCredentials();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetApiCredentials() {
+
+ pub.setApiCredentials("apikey", "apisecret");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testClose() {
+
+ pub.close();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testClose2() {
+
+ pub.close(100, null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetPendingMessageCount() {
+
+ pub.getPendingMessageCount();
+ assertTrue(true);
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/support/MRConsumerMockTest.java b/src/test/java/org/onap/dmaap/mr/test/support/MRConsumerMockTest.java
new file mode 100644
index 0000000..9ae49e0
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/support/MRConsumerMockTest.java
@@ -0,0 +1,174 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.support;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Entry;
+
+public class MRConsumerMockTest {
+ private MRConsumerMock cons = null;
+ private MRConsumerMock.Entry entry = null;
+
+ @Before
+ public void setUp() throws Exception {
+ cons = new MRConsumerMock();
+ entry = cons.new Entry(100, 200, "statusMsg");
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testClose() {
+
+ cons.close();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testRun() {
+ try {
+ entry.run();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetApiCredentials() {
+ cons.setApiCredentials("apikey", "apisecret");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testClearApiCredentials() {
+ cons.clearApiCredentials();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAdd() {
+ cons.add(entry);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAddImmediateMsg() {
+ cons.addImmediateMsg("ImmediateMsg");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAddDelayedMsg() {
+ cons.addDelayedMsg(100, "msg");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAddImmediateMsgGroup() {
+ cons.addImmediateMsgGroup(new ArrayList<String>());
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAddDelayedMsgGroup() {
+ cons.addDelayedMsgGroup(100,new ArrayList<String>());
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAddImmediateError() {
+ cons.addImmediateError(200, "OK");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testFetch() {
+ try {
+ cons.fetch();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testFetch2() {
+ try {
+ cons.fetch(100, 200);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testLogTo() {
+ cons.logTo(null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testFetchWithReturnConsumerResponse() {
+ cons.fetchWithReturnConsumerResponse();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetchWithReturnConsumerResponse() {
+ cons.fetchWithReturnConsumerResponse(100,200);
+ assertTrue(true);
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/support/TestRunner.java b/src/test/java/org/onap/dmaap/mr/test/support/TestRunner.java
new file mode 100644
index 0000000..0a09a14
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/support/TestRunner.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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 org.onap.dmaap.mr.test.support;
+
+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/org/onap/dmaap/mr/tools/ApiKeyCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/ApiKeyCommandTest.java
new file mode 100644
index 0000000..e022bf5
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/ApiKeyCommandTest.java
@@ -0,0 +1,217 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.nsa.apiClient.credentials.ApiCredential;
+import com.att.nsa.apiClient.http.HttpException;
+import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
+import com.att.nsa.cmdtool.CommandNotReadyException;
+import org.onap.dmaap.mr.client.MRClient.MRApiException;
+import org.onap.dmaap.mr.client.MRClientFactory;
+import org.onap.dmaap.mr.client.MRIdentityManager;
+import org.onap.dmaap.mr.client.MRIdentityManager.ApiKey;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ MRClientFactory.class })
+public class ApiKeyCommandTest {
+
+ @InjectMocks
+ private ApiKeyCommand command;
+ @Mock
+ private MRIdentityManager tm;
+ @Mock
+ private ApiKey ti;
+ @Mock
+ private ApiKey key;
+ @Mock
+ private ApiCredential ac;
+ @Mock
+ private PrintStream printStream;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(MRClientFactory.class);
+ PowerMockito.when(MRClientFactory.createIdentityManager(Arrays.asList("localhost"), null, null)).thenReturn(tm);
+ PowerMockito.when(tm.getApiKey("testtopic")).thenReturn(key);
+ PowerMockito.when(tm.createApiKey("testtopic", "1")).thenReturn(ac);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testGetMatches() {
+
+ command.getMatches();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckReady() {
+
+ try {
+ command.checkReady(new MRCommandContext());
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute() {
+
+ String[] parts1 = { "create", "testtopic", "1" };
+ String[] parts2 = { "list", "testtopic", "1" };
+ String[] parts3 = { "revoke", "write", "read" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+ }
+
+ @Test
+ public void testExecute_error1() throws HttpObjectNotFoundException, HttpException, MRApiException, IOException {
+ PowerMockito.when(tm.getApiKey("testtopic")).thenThrow(new IOException("error"));
+ String[] parts1 = { "create", "testtopic", "1" };
+ String[] parts2 = { "list", "testtopic", "1" };
+ String[] parts3 = { "revoke", "write", "read" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testExecute_error2() throws HttpObjectNotFoundException, HttpException, MRApiException, IOException {
+ PowerMockito.when(tm.getApiKey("testtopic")).thenThrow(new MRApiException("error"));
+ String[] parts1 = { "create", "testtopic", "1" };
+ String[] parts2 = { "list", "testtopic", "1" };
+ String[] parts3 = { "revoke", "write", "read" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(),printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+ }
+
+ @Test
+ public void testExecute_error3() throws HttpObjectNotFoundException, HttpException, MRApiException, IOException {
+ PowerMockito.when(tm.getApiKey("testtopic")).thenThrow(new HttpException(500, "error"));
+ String[] parts1 = { "create", "testtopic", "1" };
+ String[] parts2 = { "list", "testtopic", "1" };
+ String[] parts3 = { "revoke", "write", "read" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testExecute_error4() throws HttpObjectNotFoundException, HttpException, MRApiException, IOException {
+ PowerMockito.when(tm.getApiKey("testtopic")).thenThrow(new HttpObjectNotFoundException("error"));
+ String[] parts1 = { "create", "testtopic", "1" };
+ String[] parts2 = { "list", "testtopic", "1" };
+ String[] parts3 = { "revoke", "write", "read" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+ }
+
+ @Test
+ public void testDisplayHelp() {
+
+ command.displayHelp(printStream);
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/tools/AuthCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/AuthCommandTest.java
new file mode 100644
index 0000000..9f9011a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/AuthCommandTest.java
@@ -0,0 +1,113 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.PrintStream;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.nsa.cmdtool.CommandNotReadyException;
+
+@RunWith(PowerMockRunner.class)
+public class AuthCommandTest {
+ @InjectMocks
+ private AuthCommand command = null;
+ @Mock
+ private PrintStream printStream;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testGetMatches() {
+
+ command.getMatches();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckReady() {
+
+ try {
+ command.checkReady(new MRCommandContext());
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute() {
+
+ try {
+ String[] parts = new String[5];
+ command.execute(parts, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute1() {
+
+ try {
+ String[] parts = { "userName", "password" };
+ command.execute(parts, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDisplayHelp() {
+
+ command.displayHelp(printStream);
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/tools/ClusterCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/ClusterCommandTest.java
new file mode 100644
index 0000000..0dc2f64
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/ClusterCommandTest.java
@@ -0,0 +1,106 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+import java.util.Arrays;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.nsa.cmdtool.CommandNotReadyException;
+
+@RunWith(PowerMockRunner.class)
+public class ClusterCommandTest {
+ @InjectMocks
+ private ClusterCommand command;
+ @Mock
+ private MRCommandContext context;
+ @Mock
+ private PrintStream printStream;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.when(context.getCluster()).thenReturn(Arrays.asList("localhost"));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testGetMatches() {
+
+ command.getMatches();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckReady() {
+
+ try {
+ command.checkReady(context);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute() throws FileNotFoundException, CommandNotReadyException {
+ String[] parts = { "create", "testtopic", "1", "1" };
+ command.execute(parts, context, printStream);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute1() throws FileNotFoundException, CommandNotReadyException {
+ String[] parts = {};
+ command.execute(parts, context, printStream);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDisplayHelp() {
+
+ command.displayHelp(printStream);
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/tools/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/tools/JUnitTestSuite.java
new file mode 100644
index 0000000..ca79f9b
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/JUnitTestSuite.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+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({ ApiKeyCommandTest.class, AuthCommandTest.class, ClusterCommandTest.class,
+ MessageCommandTest.class, MRCommandContextTest.class, TopicCommandTest.class, TraceCommandTest.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/org/onap/dmaap/mr/tools/MRCommandContextTest.java b/src/test/java/org/onap/dmaap/mr/tools/MRCommandContextTest.java
new file mode 100644
index 0000000..038e321
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/MRCommandContextTest.java
@@ -0,0 +1,165 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.att.nsa.apiClient.http.HttpTracer;
+import com.att.nsa.cmdtool.CommandNotReadyException;
+import org.onap.dmaap.mr.client.HostSelector;
+import org.onap.dmaap.mr.client.MRClient;
+import org.onap.dmaap.mr.client.MRPublisher.message;
+import org.onap.dmaap.mr.test.support.MRBatchingPublisherMock.Entry;
+
+public class MRCommandContextTest {
+ private MRCommandContext command = null;
+ private String[] parts = new String[5];
+
+ @Before
+ public void setUp() throws Exception {
+ command = new MRCommandContext();
+
+ for (int i = 0; i < parts.length; i++) {
+ parts[i] = "String" + (i + 1);
+ }
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testRequestShutdown() {
+
+ command.requestShutdown();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testShouldContinue() {
+
+ command.shouldContinue();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetAuth() {
+
+ command.setAuth("key", "pwd");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testClearAuth() {
+
+ command.clearAuth();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckClusterReady() {
+
+ command.checkClusterReady();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetCluster() {
+
+ command.getCluster();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testClearCluster() {
+
+ command.clearCluster();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAddClusterHost() {
+
+ command.addClusterHost("host");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetApiKey() {
+
+ command.getApiKey();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetApiPwd() {
+
+ command.getApiPwd();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testUseTracer() {
+
+ command.useTracer(null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testNoTracer() {
+
+ command.noTracer();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testApplyTracer() {
+
+ command.applyTracer(null);
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/tools/MessageCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/MessageCommandTest.java
new file mode 100644
index 0000000..f32cb43
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/MessageCommandTest.java
@@ -0,0 +1,214 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.nsa.cmdtool.CommandNotReadyException;
+import org.onap.dmaap.mr.client.MRBatchingPublisher;
+import org.onap.dmaap.mr.client.MRClientFactory;
+import org.onap.dmaap.mr.client.MRConsumer;
+import org.onap.dmaap.mr.client.MRTopicManager.TopicInfo;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ MRClientFactory.class, ToolsUtil.class })
+public class MessageCommandTest {
+ @InjectMocks
+ private MessageCommand command;
+ @Mock
+ private MRConsumer tm;
+ @Mock
+ private TopicInfo ti;
+ @Mock
+ private MRBatchingPublisher pub;
+ @Mock
+ private MRConsumer cc;
+ @Mock
+ private PrintStream printStream;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(MRClientFactory.class);
+ PowerMockito.mockStatic(ToolsUtil.class);
+ PowerMockito.when(MRClientFactory.createConsumer(Arrays.asList("localhost"), "testtopic", "2", "3", -1, -1,
+ null, null, null)).thenReturn(cc);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testGetMatches() {
+
+ command.getMatches();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckReady() {
+
+ try {
+ command.checkReady(new MRCommandContext());
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute() {
+
+ String[] parts1 = { "read", "testtopic", "2", "3" };
+ String[] parts2 = { "write", "testtopic", "2", "3" };
+ List<String[]> parts = Arrays.asList(parts1, parts2);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ MRCommandContext context = new MRCommandContext();
+ PowerMockito.when(ToolsUtil.createBatchPublisher(context, "testtopic")).thenReturn(pub);
+ try {
+ command.execute(part, context, printStream);
+ } catch (CommandNotReadyException e) {
+ assertTrue(true);
+ }
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute_error1() {
+ try {
+ PowerMockito.doThrow(new Exception()).when(cc).fetch();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ String[] parts1 = { "read", "testtopic", "2", "3" };
+ String[] parts2 = { "write", "testtopic", "2", "3" };
+ List<String[]> parts = Arrays.asList(parts1, parts2);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ MRCommandContext context = new MRCommandContext();
+ PowerMockito.when(ToolsUtil.createBatchPublisher(context, "testtopic")).thenReturn(pub);
+ try {
+ command.execute(part, context, printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute_error2() {
+ try {
+ PowerMockito.doThrow(new IOException()).when(pub).close(500, TimeUnit.MILLISECONDS);
+ PowerMockito.doThrow(new IOException()).when(pub).send("2", "3");
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ String[] parts1 = { "read", "testtopic", "2", "3" };
+ String[] parts2 = { "write", "testtopic", "2", "3" };
+ List<String[]> parts = Arrays.asList(parts1, parts2);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ MRCommandContext context = new MRCommandContext();
+ PowerMockito.when(ToolsUtil.createBatchPublisher(context, "testtopic")).thenReturn(pub);
+ try {
+ command.execute(part, context, printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ assertTrue(true);
+
+ }
+
+ /*
+ * @Test public void testExecute_error3() {
+ *
+ * try { PowerMockito.doThrow(new IOException()).when(pub).send("2", "3");
+ * PowerMockito.doThrow(new InterruptedException()).when(pub).close(500,
+ * TimeUnit.MILLISECONDS); } catch (IOException e) { // TODO Auto-generated
+ * catch block e.printStackTrace(); } catch (InterruptedException e) { //
+ * TODO Auto-generated catch block e.printStackTrace(); } String[] parts1 =
+ * { "read", "testtopic", "2", "3" }; String[] parts2 = { "write",
+ * "testtopic", "2", "3" }; List<String[]> parts = Arrays.asList(parts1,
+ * parts2); for (Iterator iterator = parts.iterator(); iterator.hasNext();)
+ * { String[] part = (String[]) iterator.next(); PrintStream printStream =
+ * new PrintStream(System.out);
+ *
+ * MRCommandContext context = new MRCommandContext();
+ * PowerMockito.when(ToolsUtil.createBatchPublisher(context,
+ * "testtopic")).thenReturn(pub); try { command.execute(part, context,
+ * printStream); } catch (CommandNotReadyException e) { // TODO
+ * Auto-generated catch block e.printStackTrace(); } } assertTrue(true);
+ *
+ * }
+ */
+
+ @Test
+ public void testDisplayHelp() {
+
+ command.displayHelp(printStream);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/tools/TestRunner.java b/src/test/java/org/onap/dmaap/mr/tools/TestRunner.java
new file mode 100644
index 0000000..fff3bd7
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/TestRunner.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+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/org/onap/dmaap/mr/tools/ToolsUtilTest.java b/src/test/java/org/onap/dmaap/mr/tools/ToolsUtilTest.java
new file mode 100644
index 0000000..080d6d5
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/ToolsUtilTest.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 Nokia
+ * ================================================================================
+ * 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=========================================================
+ */
+
+/**
+ * @author marcin.migdal@nokia.com
+ */
+package org.onap.dmaap.mr.tools;
+
+import org.onap.dmaap.mr.client.MRBatchingPublisher;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class ToolsUtilTest {
+
+ private final static List<String> clusters = Arrays.asList("Cluster1", "Cluster2");
+ private final static String apiKey = "apiKey";
+ private final static String apiPassword = "apiPassword";
+ private final static String topicName = "topicName";
+
+ @Test
+ public void createBatchPublisher() {
+ MRCommandContext mrCommandContext = Mockito.mock(MRCommandContext.class);
+ Mockito.when(mrCommandContext.getCluster()).thenReturn(clusters);
+ Mockito.when(mrCommandContext.getApiKey()).thenReturn(apiKey);
+ Mockito.when(mrCommandContext.getApiPwd()).thenReturn(apiPassword);
+
+ MRBatchingPublisher mrBatchingPublisher = ToolsUtil.createBatchPublisher(mrCommandContext, topicName);
+
+ Assert.assertNotNull(mrBatchingPublisher);
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/tools/TopicCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/TopicCommandTest.java
new file mode 100644
index 0000000..e8dd073
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/TopicCommandTest.java
@@ -0,0 +1,224 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.nsa.apiClient.http.HttpException;
+import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
+import com.att.nsa.cmdtool.CommandNotReadyException;
+import org.onap.dmaap.mr.client.MRClientFactory;
+import org.onap.dmaap.mr.client.MRTopicManager.TopicInfo;
+import org.onap.dmaap.mr.client.MRTopicManager;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ MRClientFactory.class })
+public class TopicCommandTest {
+ @InjectMocks
+ private TopicCommand command;
+ @Mock
+ private MRTopicManager tm;
+ @Mock
+ private TopicInfo ti;
+ @Mock
+ private PrintStream printStream;
+
+ @Before
+ public void setUp() throws Exception {
+
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(MRClientFactory.class);
+ PowerMockito.when(MRClientFactory.createTopicManager(Arrays.asList("localhost"), null, null)).thenReturn(tm);
+ PowerMockito.when(tm.getTopicMetadata("testtopic")).thenReturn(ti);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testGetMatches() {
+
+ command.getMatches();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckReady() {
+
+ try {
+ command.checkReady(new MRCommandContext());
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute() {
+
+ String[] parts1 = { "create", "testtopic", "1", "1" };
+ String[] parts2 = { "grant", "write", "read", "1" };
+ String[] parts3 = { "revoke", "write", "read", "1" };
+ String[] parts4 = { "list", "testtopic", "1", "1" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3, parts4);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ }
+
+ @Test
+ public void testExecute_error() {
+
+ String[] parts1 = { "create", "testtopic", "1", "1" };
+ String[] parts2 = { "grant", "write", "read", "1" };
+ String[] parts3 = { "revoke", "write", "read", "1" };
+ String[] parts4 = { "list", "testtopic", "1", "1" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3, parts4);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ }
+
+ @Test
+ public void testExecute_error_1() throws com.att.nsa.apiClient.http.HttpException, IOException {
+ PowerMockito.when(tm.getTopicMetadata("testtopic")).thenThrow(new IOException("error"));
+ PowerMockito.doThrow(new IOException()).when(tm).createTopic("testtopic", "", 1, 1);
+ PowerMockito.doThrow(new IOException()).when(tm).revokeProducer("read", "1");
+ String[] parts1 = { "create", "testtopic", "1", "1" };
+ String[] parts2 = { "grant", "read", "read", "1" };
+ String[] parts3 = { "revoke", "write", "read", "1" };
+ String[] parts4 = { "list", "testtopic", "1", "1" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3, parts4);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ }
+
+ @Test
+ public void testExecute_error_2() throws com.att.nsa.apiClient.http.HttpException, IOException {
+ PowerMockito.when(tm.getTopicMetadata("testtopic")).thenThrow(new HttpObjectNotFoundException("error"));
+ PowerMockito.doThrow(new HttpException(500, "error")).when(tm).createTopic("testtopic", "", 1, 1);
+ PowerMockito.doThrow(new HttpException(500, "error")).when(tm).revokeConsumer("read", "1");
+ PowerMockito.doThrow(new HttpException(500, "error")).when(tm).allowConsumer("read", "1");
+ String[] parts1 = { "create", "testtopic", "1", "1" };
+ String[] parts2 = { "grant", "write", "write", "1" };
+ String[] parts3 = { "revoke", "read", "read", "1" };
+ String[] parts4 = { "list", "testtopic", "1", "1" };
+ List<String[]> parts = Arrays.asList(parts1, parts2, parts3, parts4);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ }
+
+ @Test
+ public void testExecute_error_3() throws com.att.nsa.apiClient.http.HttpException, IOException {
+ PowerMockito.doThrow(new HttpException(500, "error")).when(tm).createTopic("testtopic", "", 1, 1);
+ PowerMockito.doThrow(new HttpException(500, "error")).when(tm).allowProducer("read", "1");
+ String[] parts1 = { "create", "testtopic", "1a", "1a" };
+ String[] parts2 = { "grant", "write", "read", "1" };
+ List<String[]> parts = Arrays.asList(parts1, parts2);
+ for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
+ String[] part = (String[]) iterator.next();
+
+ try {
+ command.execute(part, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ }
+
+ @Test
+ public void testDisplayHelp() {
+
+ command.displayHelp(printStream);
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/tools/TraceCommandTest.java b/src/test/java/org/onap/dmaap/mr/tools/TraceCommandTest.java
new file mode 100644
index 0000000..de76acd
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/TraceCommandTest.java
@@ -0,0 +1,102 @@
+/*-
+ * ============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 org.onap.dmaap.mr.tools;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.PrintStream;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.att.nsa.cmdtool.CommandNotReadyException;
+
+@RunWith(PowerMockRunner.class)
+public class TraceCommandTest {
+ @InjectMocks
+ private TraceCommand command;
+ private String[] parts = new String[5];
+ @Mock
+ private PrintStream printStream;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ for (int i = 0; i < parts.length; i++) {
+ parts[i] = "String" + (i + 1);
+ }
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testGetMatches() {
+
+ command.getMatches();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckReady() {
+
+ try {
+ command.checkReady(new MRCommandContext());
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testExecute() {
+
+ try {
+ command.execute(parts, new MRCommandContext(), printStream);
+ } catch (CommandNotReadyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDisplayHelp() {
+
+ command.displayHelp(printStream);
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/tools/ValidatorUtilTest.java b/src/test/java/org/onap/dmaap/mr/tools/ValidatorUtilTest.java
new file mode 100644
index 0000000..1306a30
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/tools/ValidatorUtilTest.java
@@ -0,0 +1,315 @@
+/*******************************************************************************
+ * ============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 org.onap.dmaap.mr.tools;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.junit.Test;
+
+import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
+
+public class ValidatorUtilTest {
+
+ @Test
+ public void testValidateForDME2WithNullServiceName() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue());
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "Servicename is needed");
+ }
+
+ }
+
+ @Test
+ public void testValidateForDME2WithNullTopic() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue());
+ props.setProperty("ServiceName", "ServiceName");
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "topic is needed");
+ }
+
+ }
+
+ @Test
+ public void testValidateForDME2WithNullUserName() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue());
+ props.setProperty("ServiceName", "ServiceName");
+ props.setProperty("topic", "topic");
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "username is needed");
+ }
+
+ }
+
+ @Test
+ public void testValidateForDME2WithNullPassword() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.DME2.getValue());
+ props.setProperty("ServiceName", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "password is needed");
+ }
+
+ }
+
+
+
+
+ @Test
+ public void testValidateForNonDME2WithNullServiceName() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "Servicename is needed");
+ }
+
+ }
+
+ @Test
+ public void testValidateForNonDME2WithNullTopic() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "topic is needed");
+ }
+
+ }
+
+ @Test
+ public void testValidateForNonDME2WithNullContenttype() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "contenttype is needed");
+ }
+
+ }
+
+
+ @Test
+ public void testValidateForNonDME2WithNullUserName() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("contenttype", "contenttype");
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "username is needed");
+ }
+
+ }
+
+ @Test
+ public void testValidateForNonDME2WithNullPassword() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+ props.setProperty("contenttype", "contenttype");
+
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "password is needed");
+ }
+
+ }
+
+ @Test
+ public void testValidateForNonDME2WithAuthKey() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+ props.setProperty("contenttype", "contenttype");
+ props.setProperty("password", "password");
+
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "authKey is needed");
+ }
+
+ }
+
+ @Test
+ public void testValidateForNonDME2WithOutAuthDate() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+ props.setProperty("contenttype", "contenttype");
+ props.setProperty("password", "password");
+ props.setProperty("authKey", "authKey");
+
+
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "authDate is needed");
+ }
+ }
+
+ @Test
+ public void testValidateForNonDME2WithAuthDate() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+ props.setProperty("contenttype", "contenttype");
+ props.setProperty("password", "password");
+ props.setProperty("authKey", "authKey");
+ props.setProperty("authDate", "authDate");
+
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "maxBatchSize is needed");
+ }
+ }
+
+
+ @Test
+ public void testValidateForNonDME2WithMaxAgeMs() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+ props.setProperty("contenttype", "contenttype");
+ props.setProperty("password", "password");
+ props.setProperty("authKey", "authKey");
+ props.setProperty("authDate", "authDate");
+ props.setProperty("maxBatchSize", "maxBatchSize");
+
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "maxAgeMs is needed");
+ }
+
+
+
+ }
+
+ @Test
+ public void testValidateForNonDME2WithMessageSentThreadOccurance() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+ props.setProperty("contenttype", "contenttype");
+ props.setProperty("password", "password");
+ props.setProperty("authKey", "authKey");
+ props.setProperty("authDate", "authDate");
+ props.setProperty("maxBatchSize", "maxBatchSize");
+ props.setProperty("maxAgeMs", "maxAgeMs");
+
+ try{
+ ValidatorUtil.validatePublisher(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "MessageSentThreadOccurance is needed");
+ }
+
+ }
+
+
+ @Test
+ public void testValidateSubscriberWithoutGroup() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+ props.setProperty("contenttype", "contenttype");
+ props.setProperty("password", "password");
+ props.setProperty("authKey", "authKey");
+ props.setProperty("authDate", "authDate");
+ props.setProperty("maxBatchSize", "maxBatchSize");
+ props.setProperty("maxAgeMs", "maxAgeMs");
+
+ try{
+ ValidatorUtil.validateSubscriber(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "group is needed");
+ }
+ }
+
+ @Test
+ public void testValidateSubscriberWithoutCustomer() {
+ Properties props = new Properties();
+ props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+ props.setProperty("host", "ServiceName");
+ props.setProperty("topic", "topic");
+ props.setProperty("username", "username");
+ props.setProperty("contenttype", "contenttype");
+ props.setProperty("password", "password");
+ props.setProperty("authKey", "authKey");
+ props.setProperty("authDate", "authDate");
+ props.setProperty("maxBatchSize", "maxBatchSize");
+ props.setProperty("maxAgeMs", "maxAgeMs");
+ props.setProperty("group", "group");
+
+ try{
+ ValidatorUtil.validateSubscriber(props);
+ } catch(IllegalArgumentException e) {
+ assertEquals(e.getMessage(), "Consumer (Id) is needed");
+ }
+ }
+
+
+
+
+
+}