summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/dmaap/DMaaPWebExceptionMapperTest.java6
-rw-r--r--src/test/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImplTest.java117
-rw-r--r--src/test/java/org/onap/dmaap/dmf/mr/service/impl/EventsServiceImplTest.java582
-rw-r--r--src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java673
-rw-r--r--src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/DMaaPMetricsSenderTest.java128
-rw-r--r--src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/JUnitTestSuite.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/CambriaApiExceptionTest.java71
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/CambriaApiTestCase.java50
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/CambriaApiVersionInfoTest.java52
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/CambriaRateLimiterTest.java74
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/CuratorFrameworkImpl.java278
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/Kafka011ConsumerTest.java91
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaConsumerCacheTest.java250
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaLiveLockAvoider2Test.java109
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaPublisherTest.java74
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/MetricsSetImpl.java122
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/memory/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryConsumerFactoryTest.java80
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryMetaBrokerTest.java90
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryQueuePublisherTest.java101
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryQueueTest.java93
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MessageLoggerTest.java104
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/backends/memory/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest.java65
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest2.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest3.java55
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest4.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest5.java55
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest6.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java97
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.java69
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest2.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest3.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest4.java58
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest5.java55
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest6.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaConsumerFactoryTest.java55
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java262
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/JUnitTestSuite.java53
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest.java85
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest10.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest11.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest12.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest13.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest14.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest15.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest16.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest17.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest18.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest2.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest3.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest4.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest5.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest6.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest7.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest8.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest9.java54
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest.java75
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest10.java53
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest2.java53
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest3.java53
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest4.java52
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest5.java52
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest6.java52
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest7.java53
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest8.java53
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest9.java52
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/embed/EmbedConfigurationReader.java167
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/embed/KafkaLocal.java58
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/embed/ZooKeeperLocal.java59
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPCambriaExceptionMapperTest.java58
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPErrorMessagesTest.java370
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPWebExceptionMapperTest.java58
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/exception/ErrorResponseTest.java144
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/exception/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/exception/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/listener/CambriaServletContextListenerTest.java76
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/listener/DME2EndPointLoaderTest.java76
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/listener/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/listener/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metabroker/BrokerImpl.java71
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metabroker/BrokerImplTest.java108
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metabroker/JUnitTestSuite.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metabroker/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplTest.java25
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplem.java140
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplemTest.java176
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/CambriaPublisherUtilityTest.java93
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/DMaaPCambriaClientFactoryTest.java166
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/JUnitTestSuite.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/CambriaBaseClientTest.java95
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/ClockTest.java84
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/DMaaPCambriaConsumerImplTest.java93
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/DMaaPCambriaSimplerBatchPublisherTest.java86
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaEventSetTest.java73
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java129
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/JUnitTestSuite.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaJsonStreamReaderTest.java69
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaRawStreamReaderTest.java71
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaStreamReaderTest.java72
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaTextStreamReaderTest.java69
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/security/DMaaPAuthenticatorImplTest.java123
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/security/JUnitTestSuite.java44
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/security/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/security/impl/DMaaPMechIdAuthenticatorTest.java100
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/security/impl/DMaaPOriginalUebAuthenticatorTest.java110
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/security/impl/JUnitTestSuite.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/security/impl/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/AdminServiceImplemTest.java183
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/ApiKeysServiceImplTest.java333
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/BaseTransactionDbImplTest.java147
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/JUnitTestSuite.java47
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/MMServiceImplTest.java382
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/MessageTest.java64
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/MetricsServiceImplTest.java95
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/ShowConsumerCacheTest.java93
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/TransactionServiceImplTest.java95
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/service/impl/UIServiceImplTest.java297
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/transaction/JUnitTestSuite.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/transaction/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/transaction/TransactionObjTest.java175
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/transaction/TrnRequestTest.java185
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/DMaaPSimpleTransactionFactoryTest.java66
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/JUnitTestSuite.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/utils/ConfigurationReaderTest.java56
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/utils/DMaaPCuratorFactoryTest.java67
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/utils/DMaaPResponseBuilderTest.java178
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/utils/EMailerTest.java43
-rw-r--r--src/test/java/org/onap/dmaap/mr/cambria/utils/UtilsTest.java136
-rw-r--r--src/test/java/org/onap/dmaap/mr/filter/ContentLengthFilterTest.java86
-rw-r--r--src/test/java/org/onap/dmaap/mr/filter/DefaultLengthTest.java62
-rw-r--r--src/test/java/org/onap/dmaap/mr/filter/JUnitTestSuite.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/filter/TestRunner.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/ApiKeyBean.java72
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/DMaapPubSubTest.java121
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/DMaapTopicTest.java147
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapAdminTest.java60
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapApiKeyTest.java73
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapMetricsTest.java64
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/JUnitTestSuite.java41
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/LoadPropertyFile.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/TestRunner.java37
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dmaap/TopicBean.java72
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/ApiKeyBean.java72
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/DME2AdminTest.java141
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/DME2ApiKeyTest.java122
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/DME2ConsumerFilterTest.java91
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/DME2ConsumerTest.java90
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/DME2MetricsTest.java130
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/DME2ProducerTest.java101
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/DME2TopicTest.java441
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/JUnitTestSuite.java44
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/LoadPropertyFile.java69
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/TestRunner.java42
-rw-r--r--src/test/java/org/onap/dmaap/mr/test/dme2/TopicBeanDME2.java94
-rw-r--r--src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java34
-rw-r--r--src/test/resources/DMaaPErrorMesaages.properties59
-rw-r--r--src/test/resources/MsgRtrApi.properties169
-rw-r--r--src/test/resources/spring-context.xml120
173 files changed, 15613 insertions, 24 deletions
diff --git a/src/test/java/org/onap/dmaap/DMaaPWebExceptionMapperTest.java b/src/test/java/org/onap/dmaap/DMaaPWebExceptionMapperTest.java
index 4b1fb74..a8c976f 100644
--- a/src/test/java/org/onap/dmaap/DMaaPWebExceptionMapperTest.java
+++ b/src/test/java/org/onap/dmaap/DMaaPWebExceptionMapperTest.java
@@ -20,7 +20,7 @@
package org.onap.dmaap;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.InternalServerErrorException;
@@ -28,19 +28,17 @@ import javax.ws.rs.NotAllowedException;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.ServiceUnavailableException;
-
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.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
-
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("jdk.internal.reflect.*")
public class DMaaPWebExceptionMapperTest {
diff --git a/src/test/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImplTest.java b/src/test/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImplTest.java
new file mode 100644
index 0000000..aa1620e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImplTest.java
@@ -0,0 +1,117 @@
+/*-
+ * ============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.dmf.mr.security;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.BDDMockito.given;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+@RunWith(MockitoJUnitRunner.class)
+public class DMaaPAAFAuthenticatorImplTest {
+
+ private MockHttpServletRequest request;
+ @Spy
+ private DMaaPAAFAuthenticatorImpl aafAuthorizer;
+
+ @Before
+ public void setUp() throws Exception {
+ request = new MockHttpServletRequest();
+ }
+
+
+ @Test
+ public void aafAuthentication_shouldSuccess_whenRequestIsConfiguredWithProperUserRole() {
+ //given
+ String userRole = "org.onap.dmaap.mr.topic|:topic.org.onap.dmaap.mr.aSimpleTopic|sub";
+ request.addUserRole(userRole);
+
+ //when
+ boolean isAuthorized = aafAuthorizer.aafAuthentication(request, userRole);
+
+ //then
+ assertTrue(isAuthorized);
+ }
+
+ @Test
+ public void aafAuthentication_shouldFail_whenRequestIsConfiguredWithProperUserRole() {
+ //given
+ String userRole = "org.onap.dmaap.mr.topic|:topic.org.onap.dmaap.mr.aSimpleTopic|pub";
+
+ //when
+ boolean isAuthorized = aafAuthorizer.aafAuthentication(request, userRole);
+
+ //then
+ assertFalse(isAuthorized);
+ }
+
+ @Test
+ public void getPermissionAsString_shouldReturnValidTopicPermission_whenTopicWithNamespace() throws Exception {
+ //given
+ String topicPermission = "org.onap.dmaap.mr.topic|:topic.org.onap.dmaap.mr.aSimpleTopic|pub";
+ String topicName = "org.onap.dmaap.mr.aSimpleTopic";
+ String operation = "pub";
+
+ //when
+ String resultPem = aafAuthorizer.aafPermissionString(topicName, operation);
+
+ //then
+ assertEquals(topicPermission, resultPem);
+ }
+
+ @Test
+ public void getPermissionAsString_shouldReturnValidTopicPermission_whenTopicWithoutNamespace() throws Exception {
+ //given
+ String topicPermission = "org.onap.dmaap.mr.topic|:topic.topicName|pub";
+ String topicName = "topicName";
+ String operation = "pub";
+
+ //when
+ String resultPem = aafAuthorizer.aafPermissionString(topicName, operation);
+
+ //then
+ assertEquals(topicPermission, resultPem);
+ }
+
+ @Test
+ public void getPermissionAsString_shouldReturnValidTopicPermission_whenNamespaceReadFromProperty() throws Exception {
+ //given
+ String topicPermission = "com.custom.ns.topic|:topic.topicName|pub";
+ String topicName = "topicName";
+ String operation = "pub";
+ String customNamespace = "com.custom.ns";
+ given(aafAuthorizer.readNamespaceFromProperties()).willReturn(customNamespace);
+
+ //when
+ String resultPem = aafAuthorizer.aafPermissionString(topicName, operation);
+
+ //then
+ assertEquals(topicPermission, resultPem);
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/dmf/mr/service/impl/EventsServiceImplTest.java b/src/test/java/org/onap/dmaap/dmf/mr/service/impl/EventsServiceImplTest.java
new file mode 100644
index 0000000..068e9f9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/dmf/mr/service/impl/EventsServiceImplTest.java
@@ -0,0 +1,582 @@
+/*-
+ * ============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.dmf.mr.service.impl;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.att.nsa.limits.Blacklist;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.ConcurrentModificationException;
+import javax.servlet.http.HttpServletRequest;
+import joptsimple.internal.Strings;
+import org.apache.http.HttpStatus;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.backends.Consumer;
+import org.onap.dmaap.dmf.mr.backends.ConsumerFactory;
+import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;
+import org.onap.dmaap.dmf.mr.backends.MetricsSet;
+import org.onap.dmaap.dmf.mr.backends.Publisher;
+import org.onap.dmaap.dmf.mr.beans.DMaaPCambriaLimiter;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;
+import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EventsServiceImplTest {
+
+ private InputStream iStream = null;
+ private DMaaPContext dMaapContext = new DMaaPContext();
+ private DMaaPErrorMessages pErrorMessages = new DMaaPErrorMessages();
+ @Mock
+ private ConfigurationReader configurationReader;
+ @Mock
+ private Blacklist blacklist;
+ @Mock
+ private DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
+ @Mock
+ private NsaSimpleApiKey nsaSimpleApiKey;
+ @Mock
+ private DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;
+ @Mock
+ private Topic createdTopic;
+ @Mock
+ private ConsumerFactory factory;
+ @Mock
+ private Consumer consumer;
+ @Mock
+ private Publisher publisher;
+ @Mock
+ private DMaaPCambriaLimiter limiter;
+ @Mock
+ private MetricsSet metrics;
+ @Spy
+ private EventsServiceImpl eventsService;
+
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private MockHttpServletRequest request;
+
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ String source = "source of my InputStream";
+ iStream = new ByteArrayInputStream(source.getBytes("UTF-8"));
+
+ request = new MockHttpServletRequest();
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ dMaapContext.setRequest(request);
+ dMaapContext.setResponse(response);
+ when(blacklist.contains(anyString())).thenReturn(false);
+ when(configurationReader.getfIpBlackList()).thenReturn(blacklist);
+ when(configurationReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
+ dMaapContext.setConfigReader(configurationReader);
+ eventsService.setErrorMessages(pErrorMessages);
+ doReturn("100").when(eventsService).getPropertyFromAJSCmap("timeout");
+ }
+
+ @Test
+ public void getEvents_shouldFailOnAafAuthorization() throws Exception {
+ String topicPrefix = "org.onap.aaf.enforced";
+ String topicName = topicPrefix + ".topicName";
+ when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(createdTopic);
+ when(eventsService.getPropertyFromAJSCmap("enforced.topic.name.AAF")).thenReturn(topicPrefix);
+ when(eventsService.isCadiEnabled()).thenReturn(true);
+
+ thrown.expect(DMaaPAccessDeniedException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_UNAUTHORIZED)));
+
+ eventsService.getEvents(dMaapContext, topicName, "CG1", "23");
+ }
+
+ @Test
+ public void getEvents_shouldFail_whenRemoteAddressIsBlacklisted() throws Exception {
+ String remoteIp = "10.154.17.115";
+ request.setRemoteAddr(remoteIp);
+ when(blacklist.contains(remoteIp)).thenReturn(true);
+ when(configurationReader.getfIpBlackList()).thenReturn(blacklist);
+
+ thrown.expect(CambriaApiException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_FORBIDDEN)));
+
+ eventsService.getEvents(dMaapContext, "testTopic", "CG1", "23");
+ }
+
+ @Test
+ public void getEvents_shouldFail_whenRequestedTopicNotExists() throws Exception {
+ when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+ when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(null);
+
+ thrown.expect(CambriaApiException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_NOT_FOUND)));
+
+ eventsService.getEvents(dMaapContext, "testTopic", "CG1", "23");
+ }
+
+ @Test
+ public void getEvents_shouldFail_whenConsumerLockCannotBeAcquired() throws Exception {
+ //given
+ String topicName = "testTopic345";
+ String consumerGroup = "CG5";
+ String clientId = "13";
+ when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+ when(configurationReader.getfRateLimiter()).thenReturn(limiter);
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(createdTopic);
+ when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+ doThrow(new UnavailableException("Could not acquire consumer lock")).when(factory)
+ .getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString());
+
+ thrown.expect(CambriaApiException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_SERVICE_UNAVAILABLE)));
+
+ //when
+ eventsService.getEvents(dMaapContext, topicName, consumerGroup, clientId);
+
+ //then
+ verify(factory).getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString());
+
+ }
+
+ @Test
+ public void getEvents_shouldFail_whenBrokerServicesAreUnavailable() throws Exception {
+ String topicName = "testTopic";
+ String consumerGroup = "CG1";
+ String clientId = "23";
+ when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(createdTopic);
+ when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+
+ givenUserAuthorizedWithAAF(request, topicName, "sub");
+
+ thrown.expect(CambriaApiException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_SERVICE_UNAVAILABLE)));
+
+ //when
+ eventsService.getEvents(dMaapContext, topicName, consumerGroup, clientId);
+
+ //then
+ verify(factory).destroyConsumer(topicName, consumerGroup, clientId);
+ }
+
+ private void givenUserAuthorizedWithAAF(MockHttpServletRequest request, String topicName, String operation) {
+ String permission = "org.onap.dmaap.mr.topic|:topic." + topicName + "|" + operation;
+ request.addUserRole(permission);
+ }
+
+ @Test
+ public void getEvents_shouldHandleConcurrentModificationError() throws Exception {
+ String testTopic = "testTopic";
+ when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+ when(dmaapKafkaMetaBroker.getTopic(testTopic)).thenReturn(createdTopic);
+ when(configurationReader.getfRateLimiter()).thenThrow(new ConcurrentModificationException("Error occurred"));
+ givenUserAuthorizedWithAAF(request, testTopic, "sub");
+
+ thrown.expect(CambriaApiException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_CONFLICT)));
+
+ eventsService.getEvents(dMaapContext, "testTopic", "CG1", "23");
+ }
+
+ @Test
+ public void getEvents_shouldNotAuthorizeClient_whenSubscribingToMetricsTopic() throws Exception {
+ //given
+ HttpServletRequest permittedRequest = mock(HttpServletRequest.class);
+ when(permittedRequest.getHeaders(anyString())).thenReturn(Collections.<String>emptyEnumeration());
+ dMaapContext.setRequest(permittedRequest);
+ String metricsTopicName = "msgrtr.apinode.metrics.dmaap";
+ String consumerGroup = "CG5";
+ String clientId = "7";
+ givenConfiguredWithMocks(metricsTopicName);
+ when(factory.getConsumerFor(eq(metricsTopicName), eq(consumerGroup), eq(clientId), anyInt(), any()))
+ .thenReturn(consumer);
+ doNothing().when(eventsService).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
+
+ //when
+ eventsService.getEvents(dMaapContext, metricsTopicName, consumerGroup, clientId);
+
+ //then
+ verify(eventsService).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
+ verify(dmaaPAuthenticator, never()).authenticate(dMaapContext);
+ verify(permittedRequest, never()).isUserInRole(anyString());
+ }
+
+ @Test
+ public void getEvents_shouldNotAuthorizeClient_whenTopicNoteEnforcedWithAaf_andTopicHasNoOwnerSet()
+ throws Exception {
+ //given
+ String topicName = "someSimpleTopicName";
+ String consumerGroup = "CG5";
+ String clientId = "7";
+ HttpServletRequest permittedRequest = mock(HttpServletRequest.class);
+ when(permittedRequest.getHeaders(anyString())).thenReturn(Collections.<String>emptyEnumeration());
+ dMaapContext.setRequest(permittedRequest);
+ givenConfiguredWithMocks(topicName);
+ when(factory.getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), any()))
+ .thenReturn(consumer);
+ doNothing().when(eventsService).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
+ when(createdTopic.getOwner()).thenReturn(Strings.EMPTY);
+
+ //when
+ eventsService.getEvents(dMaapContext, topicName, consumerGroup, clientId);
+
+ //then
+ verify(eventsService).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
+ verify(dmaaPAuthenticator, never()).authenticate(dMaapContext);
+ verify(permittedRequest, never()).isUserInRole(anyString());
+ }
+
+ @Test
+ public void getEvents_shouldFailDmaapAuthorization_whenTopicOwnerIsSet_andUserHasNoReadPermissionToTopic()
+ throws Exception {
+ //given
+ String topicName = "someSimpleTopicName";
+ String consumerGroup = "CG5";
+ String clientId = "7";
+ HttpServletRequest permittedRequest = mock(HttpServletRequest.class);
+ when(permittedRequest.getHeaders(anyString())).thenReturn(Collections.<String>emptyEnumeration());
+ dMaapContext.setRequest(permittedRequest);
+ givenConfiguredWithMocks(topicName);
+ when(createdTopic.getOwner()).thenReturn("SimpleTopicOwner");
+ when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+ doThrow(new AccessDeniedException("userName")).when(createdTopic).checkUserRead(nsaSimpleApiKey);
+
+ thrown.expect(AccessDeniedException.class);
+
+ //when
+ eventsService.getEvents(dMaapContext, topicName, consumerGroup, clientId);
+
+ //then
+ verify(createdTopic).checkUserRead(nsaSimpleApiKey);
+ verify(eventsService, never()).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
+ verify(permittedRequest, never()).isUserInRole(anyString());
+ }
+
+
+ @Test
+ public void getEvents_shouldSuccessfullyRegisterConsumerToEventsStream_withAafAuthorization() throws Exception {
+ //given
+ String topicName = "testTopic";
+ String consumerGroup = "CG2";
+ String clientId = "6";
+ String messageLimit = "10";
+ String timeout = "25";
+ String meta = "yes";
+ String pretty = "on";
+ String cacheEnabled = "false";
+
+ givenConfiguredWithMocks(topicName);
+ givenConfiguredWithProperties(messageLimit, timeout, meta, pretty, cacheEnabled);
+ when(factory.getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString()))
+ .thenReturn(consumer);
+ givenUserAuthorizedWithAAF(request, topicName, "sub");
+
+ //when
+ eventsService.getEvents(dMaapContext, topicName, consumerGroup, clientId);
+
+ //then
+ ArgumentCaptor<CambriaOutboundEventStream> osWriter = ArgumentCaptor.forClass(CambriaOutboundEventStream.class);
+ verifyInvocationOrderForSuccessCase(topicName, consumerGroup, clientId, osWriter);
+ assertEventStreamProperties(osWriter.getValue(), messageLimit, timeout);
+ }
+
+ private void assertEventStreamProperties(CambriaOutboundEventStream stream, String messageLimit, String timeout) {
+ assertEquals(Integer.valueOf(messageLimit).intValue(), stream.getfLimit());
+ assertEquals(Integer.valueOf(timeout).intValue(), stream.getfTimeoutMs());
+ assertTrue(stream.isfWithMeta());
+ assertTrue(stream.isfPretty());
+ }
+
+ private void givenConfiguredWithProperties(String messageLimit, String timeout, String meta, String pretty,
+ String cacheEnabled) {
+ when(eventsService.getPropertyFromAJSCmap("meta")).thenReturn(meta);
+ when(eventsService.getPropertyFromAJSCmap("pretty")).thenReturn(pretty);
+ when(eventsService.getPropertyFromAJSCmap(ConsumerFactory.kSetting_EnableCache)).thenReturn(cacheEnabled);
+ request.addParameter("timeout", timeout);
+ request.addParameter("limit", messageLimit);
+ }
+
+ private void givenConfiguredWithMocks(String topicName) throws Exception {
+ when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+ when(configurationReader.getfRateLimiter()).thenReturn(limiter);
+ when(configurationReader.getfMetrics()).thenReturn(metrics);
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(createdTopic);
+ when(configurationReader.getfConsumerFactory()).thenReturn(factory);
+ when(configurationReader.getfPublisher()).thenReturn(publisher);
+ }
+
+ private void verifyInvocationOrderForSuccessCase(String topicName, String consumerGroup, String clientId,
+ ArgumentCaptor<CambriaOutboundEventStream> osWriter) throws Exception {
+
+ InOrder inOrder = Mockito.inOrder(configurationReader, factory, metrics, limiter, consumer, eventsService);
+ inOrder.verify(configurationReader).getfMetrics();
+ inOrder.verify(configurationReader).getfRateLimiter();
+ inOrder.verify(limiter).onCall(eq(topicName), eq(consumerGroup), eq(clientId), anyString());
+ inOrder.verify(factory).getConsumerFor(eq(topicName), eq(consumerGroup), eq(clientId), anyInt(), anyString());
+ inOrder.verify(eventsService).respondOkWithStream(eq(dMaapContext), osWriter.capture());
+ inOrder.verify(consumer).commitOffsets();
+ inOrder.verify(metrics).consumeTick(anyInt());
+ inOrder.verify(limiter).onSend(eq(topicName), eq(consumerGroup), eq(clientId), anyLong());
+ inOrder.verify(consumer).close();
+ inOrder.verifyNoMoreInteractions();
+ }
+
+ @Test
+ public void pushEvents_shouldFail_whenRemoteAddressIsBlacklisted() throws Exception {
+ String remoteIp = "10.132.64.112";
+ request.setRemoteAddr(remoteIp);
+ when(configurationReader.getfIpBlackList()).thenReturn(blacklist);
+ when(blacklist.contains(anyString())).thenReturn(true);
+
+ thrown.expect(CambriaApiException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_FORBIDDEN)));
+
+ eventsService.pushEvents(dMaapContext, "testTopic", iStream, "3", "12:00:00");
+ }
+
+
+
+
+ @Test
+ public void pushEvents_shouldFailDmaapAuthorization_whenTopicOwnerIsSet_andUserHasNoWritePermissionToTopic()
+ throws Exception {
+ //given
+ String topicName = "someSimpleTopicName";
+
+ HttpServletRequest permittedRequest = mock(HttpServletRequest.class);
+ when(permittedRequest.getHeaders(anyString())).thenReturn(Collections.<String>emptyEnumeration());
+ dMaapContext.setRequest(permittedRequest);
+ givenConfiguredWithMocks(topicName);
+ when(createdTopic.getOwner()).thenReturn("SimpleTopicOwner");
+ when(dmaaPAuthenticator.authenticate(dMaapContext)).thenReturn(nsaSimpleApiKey);
+ doThrow(new AccessDeniedException("userName")).when(createdTopic).checkUserWrite(nsaSimpleApiKey);
+
+ thrown.expect(AccessDeniedException.class);
+
+ //when
+ eventsService.pushEvents(dMaapContext, topicName, iStream, "5", "13:00:00");
+
+ //then
+ verify(createdTopic).checkUserWrite(nsaSimpleApiKey);
+ verify(eventsService, never()).respondOkWithStream(eq(dMaapContext), any(CambriaOutboundEventStream.class));
+ verify(permittedRequest, never()).isUserInRole(anyString());
+ }
+
+ @Test
+ public void pushEvents_shouldFailOnAafAuthorization_whenCadiIsEnabled_topicNameEnforced_andUserHasNoPermission()
+ throws Exception {
+ //given
+ String topicPrefix = "org.onap.aaf.enforced";
+ String topicName = topicPrefix + ".topicName";
+ String permission = "org.onap.dmaap.mr.topic|:topic." + topicName + "|pub";
+ HttpServletRequest deniedRequest = mock(HttpServletRequest.class);
+ when(deniedRequest.getHeaders(anyString())).thenReturn(Collections.<String>emptyEnumeration());
+ when(configurationReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(createdTopic);
+ when(eventsService.getPropertyFromAJSCmap("enforced.topic.name.AAF")).thenReturn(topicPrefix);
+ when(eventsService.isCadiEnabled()).thenReturn(true);
+ dMaapContext.setRequest(deniedRequest);
+
+ thrown.expect(DMaaPAccessDeniedException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_UNAUTHORIZED)));
+
+ //when
+ eventsService.pushEvents(dMaapContext, topicName, iStream, "5", "13:00:00");
+
+ //then
+ verify(deniedRequest).isUserInRole(permission);
+ }
+
+
+ @Test
+ public void pushEvents_shouldPublishMessagesWithoutTransaction() throws Exception {
+ //given
+ String topicName = "topicWithoutTransaction";
+ givenConfiguredWithMocks(topicName);
+ doNothing().when(eventsService).respondOk(eq(dMaapContext), any(JSONObject.class));
+
+ //when
+ eventsService.pushEvents(dMaapContext, topicName, iStream, "5", "13:00:00");
+
+ //then
+ verify(publisher).sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ ArgumentCaptor<JSONObject> captor = ArgumentCaptor.forClass(JSONObject.class);
+ verify(eventsService).respondOk(eq(dMaapContext), captor.capture());
+ assertEquals(1, captor.getValue().getLong("count"));
+ }
+
+ @Test
+ public void pushEvents_shouldHandlePublisherError_whenPushWithoutTransaction() throws Exception {
+ //given
+ String topicName = "topicWithoutTransaction";
+ givenConfiguredWithMocks(topicName);
+ doThrow(new IOException()).when(publisher)
+ .sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+
+ thrown.expect(CambriaApiException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_NOT_FOUND)));
+
+ //when
+ eventsService.pushEvents(dMaapContext, topicName, iStream, "5", "13:00:00");
+
+ //then
+ verify(publisher).sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ verify(eventsService, never()).respondOk(any(DMaaPContext.class), any(JSONObject.class));
+ }
+
+
+ @Test
+ public void pushEvents_shouldPublishMessagesWithTransaction() throws Exception {
+ //given
+ String topicPrefix = "org.onap.dmaap.mr";
+ String topicName = topicPrefix + ".topicWithTransaction";
+ givenConfiguredWithMocks(topicName);
+ when(eventsService.getPropertyFromAJSCmap("enforced.topic.name.AAF")).thenReturn(topicPrefix);
+ when(eventsService.isCadiEnabled()).thenReturn(true);
+ doNothing().when(eventsService).respondOk(eq(dMaapContext), any(JSONObject.class));
+
+ request.addUserRole("org.onap.dmaap.mr.topic|:topic." + topicName + "|pub");
+
+ //when
+ eventsService.pushEvents(dMaapContext, topicName, iStream, "5", "13:00:00");
+
+ //then
+ verify(publisher).sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ ArgumentCaptor<JSONObject> captor = ArgumentCaptor.forClass(JSONObject.class);
+ verify(eventsService).respondOk(eq(dMaapContext), captor.capture());
+ assertEquals(1, captor.getValue().getLong("count"));
+ assertFalse(captor.getValue().getString("transactionId").isEmpty());
+ }
+
+ @Test
+ public void pushEvents_shouldHandlePublisherError_whenPushWithTransaction() throws Exception {
+ //given
+ String topicPrefix = "org.onap.dmaap.mr";
+ String topicName = topicPrefix + ".topicWithTransaction";
+ givenConfiguredWithMocks(topicName);
+ when(eventsService.getPropertyFromAJSCmap("enforced.topic.name.AAF")).thenReturn(topicPrefix);
+ when(eventsService.isCadiEnabled()).thenReturn(true);
+ request.addUserRole("org.onap.dmaap.mr.topic|:topic." + topicName + "|pub");
+ doThrow(new IOException()).when(publisher)
+ .sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+
+ thrown.expect(CambriaApiException.class);
+ thrown.expectMessage(containsString(String.valueOf(HttpStatus.SC_NOT_FOUND)));
+
+ //when
+ eventsService.pushEvents(dMaapContext, topicName, iStream, "5", "13:00:00");
+
+ //then
+ verify(publisher).sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ verify(eventsService, never()).respondOk(any(DMaaPContext.class), any(JSONObject.class));
+ }
+
+ @Test
+ public void pushEvents_shouldNotPerformAnyAuthorization_whenPublishToMetricTopic() throws Exception {
+ //given
+ HttpServletRequest permittedRequest = mock(HttpServletRequest.class);
+ when(permittedRequest.getHeaders(anyString())).thenReturn(Collections.<String>emptyEnumeration());
+ dMaapContext.setRequest(permittedRequest);
+ String metricsTopicName = "msgrtr.apinode.metrics.dmaap";
+ givenConfiguredWithMocks(metricsTopicName);
+ doNothing().when(eventsService).respondOk(eq(dMaapContext), any(JSONObject.class));
+
+ //when
+ eventsService.pushEvents(dMaapContext, metricsTopicName, iStream, "5", "13:00:00");
+
+ //then
+ ArgumentCaptor<JSONObject> captor = ArgumentCaptor.forClass(JSONObject.class);
+ verify(publisher)
+ .sendBatchMessageNew(eq(metricsTopicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ verify(eventsService).respondOk(eq(dMaapContext), captor.capture());
+ verify(permittedRequest, never()).isUserInRole(anyString());
+ verify(createdTopic, never()).checkUserWrite(any(NsaSimpleApiKey.class));
+ assertEquals(1, captor.getValue().getLong("count"));
+ }
+
+ @Test
+ public void pushEvents_shouldNotPerformAnyAuthorization_whenTopicHasNoOwner() throws Exception {
+ //given
+ HttpServletRequest permittedRequest = mock(HttpServletRequest.class);
+ when(permittedRequest.getHeaders(anyString())).thenReturn(Collections.<String>emptyEnumeration());
+ dMaapContext.setRequest(permittedRequest);
+ String topicName = "notEnforcedAafTopic";
+ givenConfiguredWithMocks(topicName);
+ doNothing().when(eventsService).respondOk(eq(dMaapContext), any(JSONObject.class));
+ when(createdTopic.getOwner()).thenReturn(null);
+
+ //when
+ eventsService.pushEvents(dMaapContext, topicName, iStream, "5", "13:00:00");
+
+ //then
+ ArgumentCaptor<JSONObject> captor = ArgumentCaptor.forClass(JSONObject.class);
+ verify(publisher).sendBatchMessageNew(eq(topicName), Mockito.<ArrayList<ProducerRecord<String, String>>>any());
+ verify(eventsService).respondOk(eq(dMaapContext), captor.capture());
+ verify(permittedRequest, never()).isUserInRole(anyString());
+ verify(createdTopic, never()).checkUserWrite(any(NsaSimpleApiKey.class));
+ assertEquals(1, captor.getValue().getLong("count"));
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java b/src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java
new file mode 100644
index 0000000..4424aa9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java
@@ -0,0 +1,673 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.dmf.mr.service.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.contains;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.NsaAcl;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+import java.io.IOException;
+import java.nio.file.attribute.UserPrincipal;
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.HashSet;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;
+import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
+import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
+import org.onap.dmaap.dmf.mr.metabroker.Broker1;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+
+
+@RunWith(MockitoJUnitRunner.class)
+public class TopicServiceImplTest {
+
+ private static final String TOPIC_CREATE_PEM = "org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:org.onap.dmaap.mr|create";
+ private static final String TOPIC_DELETE_PEM = "org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:org.onap.dmaap.mr|destroy";
+ private NsaSimpleApiKey user = new NsaSimpleApiKey("admin", "password");
+ private TopicBean topicBean;
+
+ @Spy
+ private TopicServiceImpl topicService;
+
+ @Mock
+ private DMaaPErrorMessages errorMessages;
+
+ @Mock
+ private DMaaPContext dmaapContext;
+
+ @Mock
+ private ConfigurationReader configReader;
+
+ @Mock
+ private ServletOutputStream oStream;
+
+ @Mock
+ private DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
+
+ @Mock
+ private HttpServletRequest httpServReq;
+
+ @Mock
+ private HttpServletResponse httpServRes;
+
+ @Mock
+ private DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;
+
+ @Mock
+ private Topic createdTopic;
+
+ @Mock
+ private NsaAcl nsaAcl;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void setUp() throws Exception {
+ configureSpyInstance();
+ topicService.setErrorMessages(errorMessages);
+
+ when(dmaapContext.getRequest()).thenReturn(httpServReq);
+ }
+
+ private void configureSpyInstance() throws Exception {
+ doReturn(user).when(topicService).getDmaapAuthenticatedUser(any(DMaaPContext.class));
+ doReturn(dmaapKafkaMetaBroker).when(topicService).getMetaBroker(any(DMaaPContext.class));
+ doNothing().when(topicService).respondOk(any(DMaaPContext.class),anyString());
+ doNothing().when(topicService).respondOk(any(DMaaPContext.class),any(JSONObject.class));
+ when(topicService.getPropertyFromAJSCbean("enforced.topic.name.AAF"))
+ .thenReturn("org.onap.dmaap.mr");
+ when(topicService.getPropertyFromAJSCmap("msgRtr.topicfactory.aaf"))
+ .thenReturn("org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:");
+ }
+
+ private void givenTopicBean(String topicName) {
+ topicBean = new TopicBean();
+ topicBean.setTopicName(topicName);
+ }
+
+
+ @Test
+ public void createTopic_shouldSkipAAFAuthorization_whenCadiIsEnabled_andTopicNameNotEnforced() throws Exception {
+ //given
+ String topicName = "UNAUTHENTICATED.PRH.REGISTRATION";
+
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(), anyBoolean()))
+ .thenReturn(createdTopic);
+
+ givenTopicBean(topicName);
+
+ //when
+ topicService.createTopic(dmaapContext, topicBean);
+
+ //then
+ verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(),
+ anyBoolean());
+ verify(topicService).respondOk(eq(dmaapContext), any(JSONObject.class));
+ verify(httpServReq, never()).isUserInRole(TOPIC_CREATE_PEM);
+ }
+
+ @Test
+ public void createTopic_shouldSkipAAFAuthorization_whenCADIdisabled() throws Exception {
+ //given
+ String topicName = "org.onap.dmaap.mr.topic-2";
+ givenTopicBean(topicName);
+
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(), anyBoolean()))
+ .thenReturn(createdTopic);
+
+ //when
+ topicService.createTopic(dmaapContext, topicBean);
+
+ //then
+ verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(),
+ anyBoolean());
+ verify(topicService).respondOk(eq(dmaapContext), any(JSONObject.class));
+ verify(httpServReq, never()).isUserInRole(TOPIC_CREATE_PEM);
+ }
+
+ @Test
+ public void createTopic_shouldPass_whenCADIisDisabled_andNoUserInDmaapContext() throws Exception {
+ //given
+ String topicName = "org.onap.dmaap.mr.topic-3";
+ givenTopicBean(topicName);
+
+ doReturn(null).when(topicService).getDmaapAuthenticatedUser(dmaapContext);
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(), anyBoolean()))
+ .thenReturn(createdTopic);
+
+ //when
+ topicService.createTopic(dmaapContext, topicBean);
+
+ //then
+ verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(),
+ anyBoolean());
+ verify(topicService).respondOk(eq(dmaapContext), any(JSONObject.class));
+ }
+
+ @Test
+ public void createTopic_shouldPassWithAAFauthorization_whenCadiIsEnabled_andTopicNameWithEnforcedPrefix() throws Exception {
+ //given
+ String topicName = "org.onap.dmaap.mr.topic-4";
+ givenTopicBean(topicName);
+
+ Principal user = new UserPrincipal(){
+ @Override
+ public String getName(){
+ return "user";
+ }
+ };
+ when(topicService.isCadiEnabled()).thenReturn(true);
+ when(httpServReq.isUserInRole(TOPIC_CREATE_PEM)).thenReturn(true);
+ when(httpServReq.getUserPrincipal()).thenReturn(user);
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), eq("user"), anyInt(), anyInt(), anyBoolean()))
+ .thenReturn(createdTopic);
+
+ //when
+ topicService.createTopic(dmaapContext, topicBean);
+
+ //then
+ verify(httpServReq).isUserInRole(TOPIC_CREATE_PEM);
+ verify(dmaapKafkaMetaBroker).createTopic(eq(topicName), any(), eq("user"), anyInt(), anyInt(), anyBoolean());
+ verify(topicService).respondOk(eq(dmaapContext), any(JSONObject.class));
+ verify(topicService, never()).getDmaapAuthenticatedUser(dmaapContext);
+ }
+
+ @Test
+ public void createTopic_shouldFailWithAAFauthorization_whenCadiIsEnabled_andTopicNameWithEnforcedPrefix() throws Exception {
+ //given
+ thrown.expect(DMaaPAccessDeniedException.class);
+
+ String topicName = "org.onap.dmaap.mr.topic-5";
+ givenTopicBean(topicName);
+
+ Principal user = new Principal(){
+ @Override
+ public String getName(){
+ return "user";
+ }
+ };
+ when(topicService.isCadiEnabled()).thenReturn(true);
+ when(httpServReq.isUserInRole(TOPIC_CREATE_PEM)).thenReturn(false);
+ when(httpServReq.getUserPrincipal()).thenReturn(user);
+
+ //when
+ topicService.createTopic(dmaapContext, topicBean);
+
+ //then
+ verify(httpServReq).isUserInRole(TOPIC_CREATE_PEM);
+ verify(topicService, never()).getDmaapAuthenticatedUser(dmaapContext);
+ verifyZeroInteractions(dmaapKafkaMetaBroker);
+ verifyZeroInteractions(createdTopic);
+ }
+
+ @Test
+ public void createTopic_shouldThrowApiException_whenBrokerThrowsConfigDbException() throws Exception {
+ //given
+ thrown.expect(CambriaApiException.class);
+
+ String topicName = "org.onap.dmaap.mr.topic-6";
+ givenTopicBean(topicName);
+
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), any(), anyInt(), anyInt(), anyBoolean()))
+ .thenThrow(new ConfigDbException("fail"));
+
+ //when
+ topicService.createTopic(dmaapContext, topicBean);
+
+ //then
+ verifyZeroInteractions(createdTopic);
+ }
+
+ @Test
+ public void createTopic_shouldFailGracefully_whenTopicExistsExceptionOccurs() throws Exception {
+ //given
+ String topicName = "org.onap.dmaap.mr.topic-7";
+ givenTopicBean(topicName);
+
+ when(dmaapKafkaMetaBroker.createTopic(eq(topicName), any(), anyString(), anyInt(), anyInt(), anyBoolean()))
+ .thenThrow(new Broker1.TopicExistsException("enfTopicNamePlusExtra"));
+
+ //when
+ topicService.createTopic(dmaapContext, topicBean);
+
+ //then
+ verifyZeroInteractions(createdTopic);
+ }
+
+ @Test
+ public void getValueOrDefault_shouldParseDeafultAndReturnIt_whenGivenValueIsZero() {
+ //given
+ int value = 0;
+ String defaultPropertyName = "propertyName";
+ when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("6");
+
+ //when
+ int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
+
+ //then
+ assertEquals(6, extracted);
+ }
+
+ @Test
+ public void getValueOrDefault_shouldReturnGivenValue_whenGreaterThanZero() {
+ //given
+ int value = 3;
+ String defaultPropertyName = "propertyName";
+
+ //when
+ int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
+
+ //then
+ assertEquals(value, extracted);
+ verify(topicService, never()).getPropertyFromAJSCmap(defaultPropertyName);
+ }
+
+ @Test
+ public void getValueOrDefault_shouldParseDeafultAndReturnIt_whenGivenValueIsNegative() {
+ //given
+ int value = -3;
+ String defaultPropertyName = "propertyName";
+ when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("6");
+
+ //when
+ int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
+
+ //then
+ assertEquals(6, extracted);
+ }
+
+ @Test
+ public void getValueOrDefault_shouldReturnOne_whenGivenValueIsZero_andDefaultNotProvided() {
+ //given
+ int value = 0;
+ String defaultPropertyName = "propertyName";
+ when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("");
+
+ //when
+ int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
+
+ //then
+ assertEquals(1, extracted);
+ }
+
+ @Test
+ public void getValueOrDefault_shouldReturnOne_whenGivenValueIsZero_andDefaultNaN() {
+ //given
+ int value = 0;
+ String defaultPropertyName = "propertyName";
+ when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("a");
+
+ //when
+ int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
+
+ //then
+ assertEquals(1, extracted);
+ }
+
+ @Test(expected = TopicExistsException.class)
+ public void testGetTopics_null_topic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException {
+
+ Assert.assertNotNull(topicService);
+ when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);
+
+ topicService.getTopic(dmaapContext, "topicName");
+ }
+
+ @Test
+ public void testGetTopics_NonNull_topic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(createdTopic);
+
+ when(createdTopic.getName()).thenReturn("topicName");
+ when(createdTopic.getDescription()).thenReturn("topicDescription");
+ when(createdTopic.getOwners()).thenReturn(new HashSet<>(Arrays.asList("user1,user2".split(","))));
+
+ when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);
+ when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);
+
+ topicService.getTopic(dmaapContext, "topicName");
+ }
+
+ @Test(expected = TopicExistsException.class)
+ public void testGetPublishersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
+ IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);
+
+ topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");
+
+ }
+
+ @Test
+ public void testGetPublishersByTopicName_nonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
+ IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);
+ when(createdTopic.getWriterAcl()).thenReturn(nsaAcl);
+ topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");
+ }
+
+ @Test(expected = TopicExistsException.class)
+ public void testGetConsumersByTopicName_nullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
+ IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);
+
+ topicService.getConsumersByTopicName(dmaapContext, "topicNamespace.name");
+
+ }
+
+ @Test
+ public void testGetConsumersByTopicName_nonNullTopic() throws DMaaPAccessDeniedException, CambriaApiException,
+ IOException, TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);
+
+ when(createdTopic.getReaderAcl()).thenReturn(nsaAcl);
+
+ topicService.getConsumersByTopicName(dmaapContext, "topicNamespace.name");
+ }
+
+ @Test
+ public void testGetPublishersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(createdTopic);
+
+ topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");
+ }
+
+ @Test(expected = TopicExistsException.class)
+ public void testGetPublishersByTopicNameError() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.name")).thenReturn(null);
+
+ topicService.getPublishersByTopicName(dmaapContext, "topicNamespace.name");
+ }
+
+ @Test
+ public void deleteTopic_shouldDeleteTopic_whenUserAuthorizedWithAAF_andTopicExists() throws Exception {
+ //given
+ String topicName = "org.onap.dmaap.mr.topic-9";
+ when(topicService.isCadiEnabled()).thenReturn(true);
+ when(httpServReq.isUserInRole(TOPIC_DELETE_PEM)).thenReturn(true);
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(createdTopic);
+
+ //when
+ topicService.deleteTopic(dmaapContext, topicName);
+
+ //then
+ verify(httpServReq).isUserInRole(TOPIC_DELETE_PEM);
+ verify(topicService).respondOk(eq(dmaapContext), contains(topicName));
+ verify(topicService, never()).getDmaapAuthenticatedUser(dmaapContext);
+ }
+
+ @Test
+ public void deleteTopic_shouldSkipAAFauthorization_whenTopicNameNotEnforced() throws Exception {
+ //given
+ String topicName = "UNAUTHENTICATED.PRH.READY";
+ when(topicService.isCadiEnabled()).thenReturn(true);
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(createdTopic);
+
+ //when
+ topicService.deleteTopic(dmaapContext, topicName);
+
+ //then
+ verify(httpServReq, never()).isUserInRole(TOPIC_DELETE_PEM);
+ verify(topicService).respondOk(eq(dmaapContext), contains(topicName));
+ }
+
+ @Test
+ public void deleteTopic_shouldDeleteTopic_whenUserAuthorizedInContext_andTopicExists() throws Exception {
+ //given
+ String topicName = "org.onap.dmaap.mr.topic-10";
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(createdTopic);
+
+ //when
+ topicService.deleteTopic(dmaapContext, topicName);
+
+ //then
+ verify(httpServReq, never()).isUserInRole(TOPIC_DELETE_PEM);
+ verify(topicService).respondOk(eq(dmaapContext), contains(topicName));
+ }
+
+ @Test
+ public void deleteTopic_shouldNotDeleteTopic_whenUserNotAuthorizedByAAF() throws Exception {
+ //given
+ String topicName = "org.onap.dmaap.mr.topic-10";
+ thrown.expect(DMaaPAccessDeniedException.class);
+
+ when(topicService.isCadiEnabled()).thenReturn(true);
+ when(httpServReq.isUserInRole(TOPIC_DELETE_PEM)).thenReturn(false);
+
+ //when
+ topicService.deleteTopic(dmaapContext, topicName);
+
+ //then
+ verify(httpServReq).isUserInRole(TOPIC_DELETE_PEM);
+ verify(topicService, never()).respondOk(eq(dmaapContext), anyString());
+ verify(topicService, never()).getDmaapAuthenticatedUser(dmaapContext);
+ }
+
+ @Test
+ public void deleteTopic_shouldNotDeleteTopic_whenTopicDoesNotExist() throws Exception {
+ //given
+ String topicName = "org.onap.dmaap.mr.topic-10";
+ thrown.expect(TopicExistsException.class);
+
+ when(dmaapKafkaMetaBroker.getTopic(topicName)).thenReturn(null);
+
+ //when
+ topicService.deleteTopic(dmaapContext, topicName);
+
+ //then
+ verify(topicService, never()).respondOk(eq(dmaapContext), anyString());
+ }
+
+ @Test
+ public void testPermitConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");
+ }
+
+ @Test(expected = TopicExistsException.class)
+ public void testPermitConsumerForTopic_nulltopic()
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.permitConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");
+ }
+
+ @Test
+ public void testdenyConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");
+ }
+
+ @Test(expected = TopicExistsException.class)
+ public void testdenyConsumerForTopic_nulltopic()
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.denyConsumerForTopic(dmaapContext, "topicNamespace.topic", "admin");
+ }
+
+
+ @Test
+ public void testPermitPublisherForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");
+ }
+
+ @Test(expected = TopicExistsException.class)
+ public void testPermitPublisherForTopic_nulltopic()
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.permitPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");
+ }
+
+ @Test
+ public void testDenyPublisherForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(createdTopic);
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.denyPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");
+ ;
+ }
+
+ @Test(expected = TopicExistsException.class)
+ public void testDenyPublisherForTopic_nulltopic()
+ throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.denyPublisherForTopic(dmaapContext, "topicNamespace.topic", "admin");
+ ;
+ }
+
+ @Test
+ public void testGetAllTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.getAllTopics(dmaapContext);
+ }
+
+ @Test
+ public void testGetTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
+ TopicExistsException, JSONException, ConfigDbException, AccessDeniedException {
+
+ Assert.assertNotNull(topicService);
+
+ TopicBean topicBean = new TopicBean();
+ topicBean.setTopicName("enfTopicNamePlusExtra");
+
+ topicService.getTopics(dmaapContext);
+ }
+
+
+}
+
diff --git a/src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/DMaaPMetricsSenderTest.java b/src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/DMaaPMetricsSenderTest.java
new file mode 100644
index 0000000..3753722
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/DMaaPMetricsSenderTest.java
@@ -0,0 +1,128 @@
+/*-
+ * ============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.apiServer.metrics.cambria;
+
+
+import static org.junit.Assert.assertTrue;
+
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import java.io.File;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DMaaPMetricsSenderTest {
+
+ @Before
+ public void setUp() throws Exception {
+ ClassLoader classLoader = getClass().getClassLoader();
+ AJSCPropertiesMap.refresh(new File(classLoader.getResource("MsgRtrApi.properties").getFile()));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSendPeriodically() {
+
+ DMaaPMetricsSender sender = new DMaaPMetricsSender(null, "url", "testTopic");
+ try {
+ sender.sendPeriodically(null, null, "testTopic");
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (NoClassDefFoundError e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testSendPeriodically2() {
+
+ DMaaPMetricsSender sender = new DMaaPMetricsSender(null, "url", "testTopic");
+ try {
+ sender.sendPeriodically(null, null, "url", "testTopic", 2);
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testSend() {
+
+ DMaaPMetricsSender sender = new DMaaPMetricsSender(null, "url", "testTopic");
+ try {
+ sender.send();
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testRun() {
+
+ DMaaPMetricsSender sender = new DMaaPMetricsSender(null, "url", "testTopic");
+ try {
+ sender.run();
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/JUnitTestSuite.java
new file mode 100644
index 0000000..9758383
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/JUnitTestSuite.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.apiServer.metrics.cambria;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DMaaPMetricsSenderTest.class})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/apiServer/metrics/cambria/TestRunner.java b/src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/TestRunner.java
new file mode 100644
index 0000000..c1150e9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/apiServer/metrics/cambria/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.apiServer.metrics.cambria;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/CambriaApiExceptionTest.java b/src/test/java/org/onap/dmaap/mr/cambria/CambriaApiExceptionTest.java
new file mode 100644
index 0000000..cb37071
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/CambriaApiExceptionTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============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.cambria;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.exception.ErrorResponse;
+
+import static org.junit.Assert.assertTrue;
+
+public class CambriaApiExceptionTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetErrRes() {
+
+ int status = 1;
+ String msg = "helloWorld";
+ CambriaApiException cambria = new CambriaApiException(status, msg);
+
+ cambria.getErrRes();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testSetErrRes() {
+
+ int status = 1;
+ String msg = "helloWorld";
+ CambriaApiException cambria = new CambriaApiException(status, msg);
+
+ cambria.setErrRes(new ErrorResponse(200, 0, "OK"));
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/CambriaApiTestCase.java b/src/test/java/org/onap/dmaap/mr/cambria/CambriaApiTestCase.java
new file mode 100644
index 0000000..0a1af90
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/CambriaApiTestCase.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * ============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.cambria;
+
+import junit.framework.TestCase;
+import org.junit.Ignore;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Ignore
+public class CambriaApiTestCase extends TestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ final Map<String, String> argMap = new HashMap<String, String> ();
+
+ argMap.put("broker.type", "memory");
+ argMap.put("accounts.dao.class", "com.att.nsa.fe3c.dao.memory.MemoryDAOFactory");
+ argMap.put("topic.dao.class", "com.att.nsa.fe3c.dao.memory.MemoryDAOFactory");
+
+ //CambriaApiServer.start(argMap);
+ System.out.println("setUp() complete");
+ }
+
+ public void tearDown() throws Exception {
+ System.out.println("tearDown() started");
+ //CambriaApiServer.stop();
+ System.out.println("tearDown() complete");
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/CambriaApiVersionInfoTest.java b/src/test/java/org/onap/dmaap/mr/cambria/CambriaApiVersionInfoTest.java
new file mode 100644
index 0000000..39bcac0
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/CambriaApiVersionInfoTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.cambria;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.CambriaApiVersionInfo;
+
+import static org.junit.Assert.assertTrue;
+
+public class CambriaApiVersionInfoTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetVersion() {
+ CambriaApiVersionInfo.getVersion();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/CambriaRateLimiterTest.java b/src/test/java/org/onap/dmaap/mr/cambria/CambriaRateLimiterTest.java
new file mode 100644
index 0000000..51b617b
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/CambriaRateLimiterTest.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * ============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.cambria;
+
+import org.junit.Test;
+
+public class CambriaRateLimiterTest
+{
+ @Test
+ public void testRateLimiter ()
+ {
+ /*final NsaTestClock clock = new NsaTestClock(1, false);
+
+ final String topic = "topic";
+ final String consumerGroup = "group";
+ final String clientId = "id";
+
+ final int window = 5;
+
+ // rate limit: 1 empty call/min avg over 5 minutes, with 10ms delay
+ final CambriaRateLimiter rater = new CambriaRateLimiter ( 1.0, window, 10 );
+ try
+ {
+ // prime with a call to start rate window
+ rater.onCall ( topic, consumerGroup, clientId );
+ rater.onSend ( topic, consumerGroup, clientId, 1 );
+ clock.addMs ( 1000*60*window );
+
+ // rate should now be 0, with a good window
+ for ( int i=0; i<4; i++ )
+ {
+ clock.addMs ( 1000*15 );
+ rater.onCall ( topic, consumerGroup, clientId );
+ rater.onSend ( topic, consumerGroup, clientId, 0 );
+ }
+ // rate is now 0.8 = 4 calls in last 5 minutes = 4/5 = 0.8
+
+ clock.addMs ( 1000*15 );
+ rater.onCall ( topic, consumerGroup, clientId );
+ rater.onSend ( topic, consumerGroup, clientId, 0 );
+ // rate = 1.0 = 5 calls in last 5 mins
+
+ clock.addMs ( 1000 );
+ rater.onCall ( topic, consumerGroup, clientId );
+ rater.onSend ( topic, consumerGroup, clientId, 0 );
+ // rate = 1.2 = 6 calls in last 5 mins, should fire
+
+ fail ( "Should have thrown rate limit exception." );
+ }
+ catch ( CambriaApiException x )
+ {
+ // good
+ }*/
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/JUnitTestSuite.java
new file mode 100644
index 0000000..bcac8d9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/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.cambria;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({CambriaApiExceptionTest.class, CambriaApiVersionInfoTest.class,
+ CambriaApiTestCase.class, CambriaRateLimiterTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/TestRunner.java
new file mode 100644
index 0000000..8465cbe
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/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.cambria;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/backends/kafka/CuratorFrameworkImpl.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/CuratorFrameworkImpl.java
new file mode 100644
index 0000000..2f57abf
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/CuratorFrameworkImpl.java
@@ -0,0 +1,278 @@
+/*-
+ * ============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.cambria.backends.kafka;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.curator.CuratorZookeeperClient;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.WatcherRemoveCuratorFramework;
+import org.apache.curator.framework.api.CreateBuilder;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.DeleteBuilder;
+import org.apache.curator.framework.api.ExistsBuilder;
+import org.apache.curator.framework.api.GetACLBuilder;
+import org.apache.curator.framework.api.GetChildrenBuilder;
+import org.apache.curator.framework.api.GetConfigBuilder;
+import org.apache.curator.framework.api.GetDataBuilder;
+import org.apache.curator.framework.api.ReconfigBuilder;
+import org.apache.curator.framework.api.RemoveWatchesBuilder;
+import org.apache.curator.framework.api.SetACLBuilder;
+import org.apache.curator.framework.api.SetDataBuilder;
+import org.apache.curator.framework.api.SyncBuilder;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.api.transaction.CuratorMultiTransaction;
+import org.apache.curator.framework.api.transaction.CuratorTransaction;
+import org.apache.curator.framework.api.transaction.TransactionOp;
+import org.apache.curator.framework.imps.CuratorFrameworkState;
+import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
+import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.EnsurePath;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
+
+public class CuratorFrameworkImpl implements CuratorFramework {
+
+ @Override
+ public void blockUntilConnected() throws InterruptedException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean blockUntilConnected(int arg0, TimeUnit arg1) throws InterruptedException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public ExistsBuilder checkExists() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void clearWatcherReferences(Watcher arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void close() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public CreateBuilder create() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public DeleteBuilder delete() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public GetACLBuilder getACL() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public GetChildrenBuilder getChildren() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Listenable<ConnectionStateListener> getConnectionStateListenable() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Listenable<CuratorListener> getCuratorListenable() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public GetDataBuilder getData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getNamespace() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CuratorFrameworkState getState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CuratorZookeeperClient getZookeeperClient() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CuratorTransaction inTransaction() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isStarted() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public EnsurePath newNamespaceAwareEnsurePath(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CuratorFramework nonNamespaceView() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SetACLBuilder setACL() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SetDataBuilder setData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public SyncBuilder sync() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void sync(String arg0, Object arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public CuratorFramework usingNamespace(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ReconfigBuilder reconfig() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public GetConfigBuilder getConfig() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CuratorMultiTransaction transaction() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public TransactionOp transactionOp() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void createContainers(String path) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public RemoveWatchesBuilder watches() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public WatcherRemoveCuratorFramework newWatcherRemoveCuratorFramework() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ConnectionStateErrorPolicy getConnectionStateErrorPolicy() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public QuorumVerifier getCurrentConfig() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SchemaSet getSchemaSet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isZk34CompatibilityMode() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/JUnitTestSuite.java
new file mode 100644
index 0000000..d299fdd
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/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.cambria.backends.kafka;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({KafkaConsumerCacheTest.class, KafkaPublisherTest.class, Kafka011ConsumerTest.class,
+ KafkaLiveLockAvoider2Test.class})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/backends/kafka/Kafka011ConsumerTest.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/Kafka011ConsumerTest.java
new file mode 100644
index 0000000..10526c5
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/Kafka011ConsumerTest.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * ============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.cambria.backends.kafka;
+
+import static org.junit.Assert.assertNotNull;
+
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.dmaap.dmf.mr.backends.kafka.Kafka011Consumer;
+import org.onap.dmaap.dmf.mr.backends.kafka.KafkaLiveLockAvoider2;
+import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
+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;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ AJSCPropertiesMap.class })
+public class Kafka011ConsumerTest {
+
+
+ @Mock
+ private KafkaConsumer<String, String> cc;
+ @Mock
+ private KafkaLiveLockAvoider2 klla;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testKafka011Consumer() {
+ PowerMockito.mockStatic(AJSCPropertiesMap.class);
+ PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "consumer.timeout")).thenReturn("10");
+ Kafka011Consumer consumer=null;
+ try {
+ consumer= new Kafka011Consumer("topic", "group", "id", cc, klla) ;
+ consumer.commitOffsets();
+ consumer.touch();
+ consumer.setOffset(10);
+ } catch (Exception e) {
+
+ }
+ assertNotNull(consumer);
+ assertNotNull(consumer.getConsumer());
+ assertNotNull(consumer.getConsumerGroup());
+ assertNotNull(consumer.getConsumerId());
+ assertNotNull(consumer.getConsumerId());
+ assertNotNull(consumer.getCreateTimeMs());
+ assertNotNull(consumer.getLastAccessMs());
+ assertNotNull(consumer.getName());
+ assertNotNull(consumer.getOffset());
+ assertNotNull(consumer.getLastTouch());
+
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaConsumerCacheTest.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaConsumerCacheTest.java
new file mode 100644
index 0000000..457fff4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaConsumerCacheTest.java
@@ -0,0 +1,250 @@
+/*-
+ * ============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.cambria.backends.kafka;
+
+import static org.junit.Assert.*;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+
+import org.onap.dmaap.dmf.mr.backends.MetricsSet;
+import org.onap.dmaap.dmf.mr.backends.kafka.Kafka011Consumer;
+import org.onap.dmaap.dmf.mr.backends.kafka.KafkaConsumerCache;
+import org.onap.dmaap.dmf.mr.backends.kafka.KafkaConsumerCache.KafkaConsumerCacheException;
+import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ AJSCPropertiesMap.class })
+public class KafkaConsumerCacheTest {
+ private KafkaConsumerCache kafkaConsumerCache =null;
+ @Mock
+ private ConcurrentHashMap<String, Kafka011Consumer> fConsumers;
+ @Mock
+ private MetricsSet fMetrics;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+ @Test
+ public void testSweep() {
+ kafkaConsumerCache = new KafkaConsumerCache();
+ PowerMockito.mockStatic(AJSCPropertiesMap.class);
+ PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "kSetting_TouchEveryMs")).thenReturn("100");
+ kafkaConsumerCache.sweep();
+
+ }
+
+
+ // DOES NOT WORK
+ @Test
+ public void testStartCache() {
+
+ /*
+ * KafkaConsumerCache kafka = null;
+ *
+ * try { kafka = new KafkaConsumerCache("123", null);
+ *
+ * } catch (NoClassDefFoundError e) { try { kafka.startCache("DMAAP",
+ * null); } catch (NullPointerException e1) { // TODO Auto-generated
+ * catch block assertTrue(true); } catch (KafkaConsumerCacheException
+ * e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
+ */
+
+
+ new CuratorFrameworkImpl();
+ new MetricsSetImpl();
+ KafkaConsumerCache kafka=null;
+ try {
+ kafka = new KafkaConsumerCache();
+ kafka.setfApiId("1");
+ kafka.startCache("DMAAP", null);
+ } catch (NoClassDefFoundError e) {
+
+ } catch (KafkaConsumerCacheException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testGetCuratorFramework() {
+
+ CuratorFramework curator = new CuratorFrameworkImpl();
+ new MetricsSetImpl();
+ try {
+
+ } catch (NoClassDefFoundError e) {
+
+ KafkaConsumerCache.getCuratorFramework(curator);
+ }
+
+ }
+
+ /*
+ * @Test public void testStopCache() {
+ *
+ * KafkaConsumerCache kafka = null; new CuratorFrameworkImpl(); new
+ * MetricsSetImpl(); try { kafka = new KafkaConsumerCache("123", null);
+ * kafka.stopCache(); } catch (NoClassDefFoundError e) {
+ *
+ * }
+ *
+ * }
+ */
+
+ @Test
+ public void testGetConsumerFor() {
+
+ KafkaConsumerCache kafka = null;
+
+ try {
+ kafka = new KafkaConsumerCache();
+ kafka.getConsumerFor("testTopic", "CG1", "23");
+ } catch (NoClassDefFoundError e) {
+
+ } catch (KafkaConsumerCacheException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testPutConsumerFor() {
+
+ Kafka011Consumer consumer = null;
+ KafkaConsumerCache kafka = null;
+
+ try {
+ kafka = new KafkaConsumerCache();
+
+ } catch (NoClassDefFoundError e) {
+ try {
+ kafka.putConsumerFor("testTopic", "CG1", "23", consumer);
+ } catch (NullPointerException e1) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ } catch (KafkaConsumerCacheException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+
+ }
+
+ @Test
+ public void testGetConsumers() {
+
+ KafkaConsumerCache kafka = null;
+
+ try {
+ kafka = new KafkaConsumerCache();
+
+ } catch (NoClassDefFoundError e) {
+ try {
+ kafka.getConsumers();
+ } catch (NullPointerException e1) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+ }
+
+ }
+
+ @Test
+ public void testDropAllConsumers() {
+
+ KafkaConsumerCache kafka = null;
+ try {
+ kafka = new KafkaConsumerCache();
+
+ } catch (NoClassDefFoundError e) {
+ try {
+ kafka.dropAllConsumers();
+ } catch (NullPointerException e1) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+ }
+
+ }
+
+ @Test
+ public void testSignalOwnership() {
+
+ KafkaConsumerCache kafka = null;
+
+ try {
+ kafka = new KafkaConsumerCache();
+ try {
+ kafka.signalOwnership("testTopic", "CG1", "23");
+ } catch (KafkaConsumerCacheException e) {
+ assertTrue(true);
+ }
+ } catch (NoClassDefFoundError e) {}
+
+ //
+ }
+
+ @Test
+ public void testDropConsumer() {
+
+ KafkaConsumerCache kafka = null;
+
+ try {
+ kafka = new KafkaConsumerCache();
+ // kafka.dropConsumer("testTopic", "CG1", "23");
+ } catch (NoClassDefFoundError e) {
+ try {
+ kafka.dropConsumer("testTopic", "CG1", "23");
+ } catch (NullPointerException e1) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+ }
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaLiveLockAvoider2Test.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaLiveLockAvoider2Test.java
new file mode 100644
index 0000000..7f81641
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaLiveLockAvoider2Test.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * ============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.cambria.backends.kafka;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CreateBuilder;
+import org.apache.curator.framework.api.ExistsBuilder;
+import org.apache.curator.framework.api.GetChildrenBuilder;
+import org.apache.curator.framework.api.ProtectACLCreateModeStatPathAndBytesable;
+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.onap.dmaap.dmf.mr.backends.kafka.KafkaLiveLockAvoider2;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+public class KafkaLiveLockAvoider2Test {
+
+ @Mock
+ private CuratorFramework curatorFramework;
+ @Mock
+ private ExistsBuilder existsBuilder;
+ @Mock
+ private CreateBuilder createBuilder;
+ @Mock
+ private GetChildrenBuilder childrenBuilder;
+ @Mock
+ ProtectACLCreateModeStatPathAndBytesable<String> acl;
+ @InjectMocks
+ private KafkaLiveLockAvoider2 liveLockAvoider;
+
+ public static final String ZNODE_ROOT = "/live-lock-avoid";
+ public static final String ZNODE_LOCKS = "/locks";
+ public static final String ZNODE_UNSTICK_TASKS ="/unstick-tasks";
+
+ private static String locksPath = ZNODE_ROOT+ZNODE_LOCKS;
+ private static String tasksPath = ZNODE_ROOT+ZNODE_UNSTICK_TASKS;
+
+
+ @Before
+ public void setUp() throws Exception {
+ List<String> taskNodes= new ArrayList<String>();
+ taskNodes.add("appId");
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.when(acl.forPath(locksPath)).thenReturn(locksPath);
+ PowerMockito.when(acl.forPath(tasksPath)).thenReturn(tasksPath);
+ PowerMockito.when(createBuilder.creatingParentsIfNeeded()).thenReturn(acl);
+ PowerMockito.when(curatorFramework.create()).thenReturn(createBuilder);
+ PowerMockito.when(curatorFramework.checkExists()).thenReturn(existsBuilder);
+ PowerMockito.when(childrenBuilder.forPath(tasksPath)).thenReturn(taskNodes);
+ PowerMockito.when(curatorFramework.getChildren()).thenReturn(childrenBuilder);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testUnlock(){
+ liveLockAvoider.init();
+ try {
+ liveLockAvoider.unlockConsumerGroup("appId", "groupName");
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testWatcher(){
+ try {
+ liveLockAvoider.startNewWatcherForServer("appId", null);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaPublisherTest.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaPublisherTest.java
new file mode 100644
index 0000000..7a0fe78
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/KafkaPublisherTest.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.cambria.backends.kafka;
+
+import static org.junit.Assert.assertTrue;
+
+import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.onap.dmaap.dmf.mr.backends.kafka.KafkaPublisher;
+import org.onap.dmaap.dmf.mr.utils.Utils;
+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;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ Utils.class })
+public class KafkaPublisherTest {
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(Utils.class);
+ PowerMockito.when(Utils.isCadiEnabled()).thenReturn(true);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testPublisherInit() {
+
+
+
+ try {
+ try {
+ KafkaPublisher kafkaPublisher = new KafkaPublisher(null);
+ } catch (missingReqdSetting e) {
+ assertTrue(true);
+ }
+ } catch (LinkageError e) {
+ assertTrue(true);
+ }
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/MetricsSetImpl.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/MetricsSetImpl.java
new file mode 100644
index 0000000..ea36d86
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/MetricsSetImpl.java
@@ -0,0 +1,122 @@
+/*-
+ * ============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.cambria.backends.kafka;
+
+import com.att.nsa.metrics.CdmMeasuredItem;
+import org.json.JSONObject;
+import org.onap.dmaap.dmf.mr.backends.MetricsSet;
+
+import java.util.List;
+import java.util.Map;
+
+public class MetricsSetImpl implements MetricsSet {
+
+ @Override
+ public List<? extends CdmMetricEntry> getEntries() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CdmMeasuredItem getItem(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Map<String, CdmMeasuredItem> getItems() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void putItem(String arg0, CdmMeasuredItem arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeItem(String arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int size() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setupCambriaSender() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onRouteComplete(String name, long durationMs) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void publishTick(int amount) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void consumeTick(int amount) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onKafkaConsumerCacheMiss() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onKafkaConsumerCacheHit() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onKafkaConsumerClaimed() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onKafkaConsumerTimeout() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/TestRunner.java
new file mode 100644
index 0000000..38261e1
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/kafka/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.cambria.backends.kafka;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/backends/memory/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/JUnitTestSuite.java
new file mode 100644
index 0000000..c38be64
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/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.cambria.backends.memory;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({MemoryConsumerFactoryTest.class, MemoryMetaBrokerTest.class, MemoryQueueTest.class,
+ MemoryQueuePublisherTest.class, MessageLoggerTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/backends/memory/MemoryConsumerFactoryTest.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryConsumerFactoryTest.java
new file mode 100644
index 0000000..ac07506
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryConsumerFactoryTest.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.cambria.backends.memory;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.backends.memory.MemoryConsumerFactory;
+
+public class MemoryConsumerFactoryTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetConsumerFor() {
+ MemoryConsumerFactory factory = new MemoryConsumerFactory(null);
+
+
+ String topic = "testTopic";
+ String consumerGroupId = "CG1";
+ String clientId = "C1";
+ String remoteHost="remoteHost";
+ int timeoutMs = 1000;
+ factory.getConsumerFor(topic, consumerGroupId, clientId, timeoutMs,remoteHost);
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testDropCache() {
+ MemoryConsumerFactory factory = new MemoryConsumerFactory(null);
+
+ factory.dropCache();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGetConsumers() {
+ MemoryConsumerFactory factory = new MemoryConsumerFactory(null);
+
+ factory.getConsumers();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryMetaBrokerTest.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryMetaBrokerTest.java
new file mode 100644
index 0000000..c4715cd
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryMetaBrokerTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============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.cambria.backends.memory;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.backends.memory.MemoryMetaBroker;
+import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
+
+public class MemoryMetaBrokerTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetAllTopics() {
+ MemoryMetaBroker broker = new MemoryMetaBroker(null, null);
+
+ broker.getAllTopics();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGeTopic() {
+ MemoryMetaBroker broker = new MemoryMetaBroker(null, null);
+
+ broker.getTopic("testTopic");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testCreateTopic() {
+
+ //uncommenting this gives a Null Pointer Exception
+
+ MemoryMetaBroker broker = new MemoryMetaBroker(null, null);
+
+ int timeoutMs = 1000;
+ try {
+ broker.createTopic("testTopic","topic for testing", "ABCD123", 1,3, true);
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryQueuePublisherTest.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryQueuePublisherTest.java
new file mode 100644
index 0000000..ff9bd9e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryQueuePublisherTest.java
@@ -0,0 +1,101 @@
+/*-
+ * ============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.cambria.backends.memory;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.backends.memory.MemoryQueuePublisher;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class MemoryQueuePublisherTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSendBatchMessage() {
+ MemoryQueuePublisher publisher = new MemoryQueuePublisher(null, null);
+
+ try {
+ publisher.sendBatchMessageNew("testTopic", null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testSendMessage() {
+ MemoryQueuePublisher publisher = new MemoryQueuePublisher(null, null);
+
+ try {
+ publisher.sendMessage("testTopic", null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testSendMessages() {
+ MemoryQueuePublisher publisher = new MemoryQueuePublisher(null, null);
+
+
+ try {
+ publisher.sendMessages("testTopic", null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryQueueTest.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryQueueTest.java
new file mode 100644
index 0000000..c5afa6d
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MemoryQueueTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.cambria.backends.memory;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.backends.memory.MemoryQueue;
+
+
+public class MemoryQueueTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testCreateTopic() {
+ MemoryQueue queue = new MemoryQueue();
+
+ queue.createTopic("testTopic");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+ @Test
+ public void testRemoveTopic() {
+ MemoryQueue queue = new MemoryQueue();
+
+ queue.removeTopic("testTopic");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testPut() {
+ MemoryQueue queue = new MemoryQueue();
+
+ try {
+ queue.put("testTopic", null);
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGet() {
+ MemoryQueue queue = new MemoryQueue();
+
+ queue.get("testTopic", "consumer");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MessageLoggerTest.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MessageLoggerTest.java
new file mode 100644
index 0000000..bc2025a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/MessageLoggerTest.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.cambria.backends.memory;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.backends.memory.MessageLogger;
+
+
+public class MessageLoggerTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSendMessage() {
+ MessageLogger dropper = new MessageLogger();
+
+ try {
+ dropper.sendMessage("testTopic", null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testSendMessages() {
+ MessageLogger dropper = new MessageLogger();
+
+ try {
+ dropper.sendMessages("testTopic", null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testSendBatchMessage() {
+ MessageLogger dropper = new MessageLogger();
+
+ try {
+ dropper.sendBatchMessageNew("testTopic", null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
+
+
+
+
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/TestRunner.java
new file mode 100644
index 0000000..2f0a215
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/backends/memory/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.cambria.backends.memory;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/beans/ApiKeyBeanTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest.java
new file mode 100644
index 0000000..e711107
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class ApiKeyBeanTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetEmail() {
+
+ ApiKeyBean bean = new ApiKeyBean("user@onap.com", "testing bean");
+
+ bean.getEmail();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testApiKeyBean(){
+ ApiKeyBean bean = new ApiKeyBean();
+ bean.setDescription("description");
+ bean.setEmail("email");
+ assertEquals("description", bean.getDescription());
+ assertEquals("email", bean.getEmail());
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest2.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest2.java
new file mode 100644
index 0000000..0a36e1a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest2.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
+
+import static org.junit.Assert.assertTrue;
+
+public class ApiKeyBeanTest2 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSetEmail() {
+
+ ApiKeyBean bean = new ApiKeyBean("user@onap.com", "testing bean");
+
+ bean.setEmail("user@onap.com");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest3.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest3.java
new file mode 100644
index 0000000..7cc6164
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest3.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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ApiKeyBeanTest3 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetDescription() {
+
+ ApiKeyBean bean = new ApiKeyBean("user@onap.com", "testing bean");
+
+ bean.getDescription();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest4.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest4.java
new file mode 100644
index 0000000..6f3a2f6
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest4.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
+
+import static org.junit.Assert.assertTrue;
+
+public class ApiKeyBeanTest4 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSetDescription() {
+
+ ApiKeyBean bean = new ApiKeyBean("user@onap.com", "testing bean");
+
+ bean.setDescription("new testing description");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest5.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest5.java
new file mode 100644
index 0000000..e11ffde
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest5.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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ApiKeyBeanTest5 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetSharedSecret() {
+
+ ApiKeyBean bean = new ApiKeyBean("user@onap.com", "testing bean");
+
+ bean.getSharedSecret();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest6.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest6.java
new file mode 100644
index 0000000..a847efa
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/ApiKeyBeanTest6.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
+
+import static org.junit.Assert.assertTrue;
+
+public class ApiKeyBeanTest6 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetKey() {
+
+ ApiKeyBean bean = new ApiKeyBean("user@onap.com", "testing bean");
+
+ bean.getKey();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java
new file mode 100644
index 0000000..f389ab1
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPCambriaLimiterTest.java
@@ -0,0 +1,97 @@
+/*-
+ * ============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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.beans.DMaaPCambriaLimiter;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class DMaaPCambriaLimiterTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetSleepMsForRate() {
+
+ assertEquals(1000, DMaaPCambriaLimiter.getSleepMsForRate(100));
+ assertEquals(0, DMaaPCambriaLimiter.getSleepMsForRate(0));
+
+ }
+
+ @Test
+ public void testOnCall() {
+
+ DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(1, 2, 3);
+ try {
+ limiter.onCall("testTopic", "ConsumerGroup1", "client2", "remoteHost");
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testOnCallError2() {
+
+ DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(0, 2, 3, 1, 1);
+ try {
+ limiter.onCall("testTopic", "ConsumerGroup1", "client2", "remoteHost");
+ } catch (CambriaApiException e) {
+ assertTrue(false);
+ }
+
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testOnCallError() throws CambriaApiException {
+
+ DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(0.9, 2, 3, 1, 1);
+ limiter.onCall("testTopic", "ConsumerGroup1", "client2", "remoteHost");
+
+ }
+
+ @Test
+ public void testOnSend() {
+
+ DMaaPCambriaLimiter limiter = new DMaaPCambriaLimiter(3, 3, 3);
+ limiter.onSend("testTopic", "consumerGroup1", "client1", 100);
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.java
new file mode 100644
index 0000000..adbc064
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpSession;
+
+import static org.junit.Assert.*;
+
+public class DMaaPContextTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetBatchID() {
+
+ DMaaPContext.getBatchID();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testDMaaPContext(){
+
+ DMaaPContext context=new DMaaPContext();
+ context.setConsumerRequestTime("consumerRequestTime");
+ assertEquals("consumerRequestTime", context.getConsumerRequestTime());
+ MockHttpServletRequest request= new MockHttpServletRequest();
+ MockHttpSession session=new MockHttpSession();
+ request.setSession(session);
+ context.setRequest(request);
+ assertNotNull(context.getSession());
+
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest2.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest2.java
new file mode 100644
index 0000000..5bb4567
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest2.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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+
+public class DMaaPContextTest2 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetRequest() {
+
+ DMaaPContext context = new DMaaPContext();
+
+ context.getRequest();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest3.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest3.java
new file mode 100644
index 0000000..90867a3
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest3.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+
+import static org.junit.Assert.assertTrue;
+
+public class DMaaPContextTest3 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetResponse() {
+
+ DMaaPContext context = new DMaaPContext();
+
+ context.getResponse();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest4.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest4.java
new file mode 100644
index 0000000..d84a19c
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest4.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+
+public class DMaaPContextTest4 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetSession() {
+
+ DMaaPContext context = new DMaaPContext();
+ MockHttpServletRequest request = new MockHttpServletRequest();
+ context.setRequest(request);
+
+ context.getSession();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest5.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest5.java
new file mode 100644
index 0000000..565ef36
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest5.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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+
+public class DMaaPContextTest5 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetConfigReader() {
+
+ DMaaPContext context = new DMaaPContext();
+
+ context.getConfigReader();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest6.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest6.java
new file mode 100644
index 0000000..b7f6e18
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPContextTest6.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+
+import static org.junit.Assert.assertTrue;
+
+public class DMaaPContextTest6 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetConsumerRequestTime() {
+
+ DMaaPContext context = new DMaaPContext();
+
+ context.getConsumerRequestTime();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaConsumerFactoryTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaConsumerFactoryTest.java
new file mode 100644
index 0000000..fd30359
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaConsumerFactoryTest.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaConsumerFactory;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.onap.dmaap.mr.cambria.embed.EmbedConfigurationReader;
+
+
+public class DMaaPKafkaConsumerFactoryTest {
+
+ EmbedConfigurationReader embedConfigurationReader = new EmbedConfigurationReader();
+
+ @After
+ public void tearDown() throws Exception {
+ embedConfigurationReader.tearDown();
+ }
+
+@Test
+public void testConsumerFactory(){
+
+ try {
+ ConfigurationReader configurationReader = embedConfigurationReader.buildConfigurationReader();
+ DMaaPKafkaConsumerFactory consumerFactory=(DMaaPKafkaConsumerFactory) configurationReader.getfConsumerFactory();
+ consumerFactory.getConsumerFor("topic", "consumerGroupName", "consumerId", 10, "remotehost");
+ } catch (Exception e) {
+ assertTrue(false);
+ }
+ assertTrue(true);
+}
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java
new file mode 100644
index 0000000..d59c839
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/DMaaPKafkaMetaBrokerTest.java
@@ -0,0 +1,262 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.assertTrue;
+
+import com.att.nsa.configs.ConfigDb;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.configs.ConfigPath;
+import org.I0Itec.zkclient.ZkClient;
+import org.apache.kafka.clients.admin.AdminClient;
+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.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker.KafkaTopic;
+import org.onap.dmaap.dmf.mr.metabroker.Broker1.TopicExistsException;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+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;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ AdminClient.class })
+public class DMaaPKafkaMetaBrokerTest {
+
+ @InjectMocks
+ private DMaaPKafkaMetaBroker dMaaPKafkaMetaBroker;
+ @Mock
+ private ZkClient fZk;
+ @Mock
+ private AdminClient fKafkaAdminClient;
+ @Mock
+ private AdminClient client;
+ @Mock
+ private ConfigDb configDb;
+ @Mock
+ ConfigPath fBaseTopicData;
+ @Mock
+ private ZkClient zkClient;
+ @Mock
+ Topic mockTopic;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(AdminClient.class);
+ // PowerMockito.when(AdminClient.create (any(Properties.class)
+ // )).thenReturn(fKafkaAdminClient);
+
+ // PowerMockito.mockStatic(AdminUtils.class);
+ PowerMockito.when(configDb.parse("/topics")).thenReturn(fBaseTopicData);
+
+ }
+
+ @Test
+ public void testBrokercreate() {
+ DMaaPKafkaMetaBroker broker = new DMaaPKafkaMetaBroker();
+
+ }
+
+ @Test
+ public void testcreateTopicEntry() {
+ try {
+ KafkaTopic kafkaTopic = new KafkaTopic("topics", configDb, fBaseTopicData);
+ dMaaPKafkaMetaBroker.createTopicEntry("name", "desc", "owner", true);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testGetAlltopics() {
+ try {
+ dMaaPKafkaMetaBroker.getAllTopics();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testcreateTopic() {
+ try {
+ dMaaPKafkaMetaBroker.createTopic("testtopic", "testtopic", "admin", 1, 1, true);
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generatee.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testcreateTopic_wrongPartition() {
+ try {
+
+ dMaaPKafkaMetaBroker.createTopic("testtopic", "testtopic", "admin", 0, 1, true);
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generatee.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testcreateTopic_wrongReplica() {
+ try {
+
+ dMaaPKafkaMetaBroker.createTopic("testtopic", "testtopic", "admin", 1, 0, true);
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generatee.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testcreateTopic_error1() {
+ try {
+ dMaaPKafkaMetaBroker.createTopic("testtopic", "testtopic", "admin", 1, 1, true);
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testcreateTopic_error2() {
+ try {
+ dMaaPKafkaMetaBroker.createTopic("testtopic", "testtopic", "admin", 1, 1, true);
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testcreateTopic_error3() {
+ try {
+ dMaaPKafkaMetaBroker.createTopic("testtopic", "testtopic", "admin", 1, 1, true);
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ assertTrue(true);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testDeleteTopic() {
+ try {
+ dMaaPKafkaMetaBroker.deleteTopic("testtopic");
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDeleteTopic_error1() {
+ try {
+ dMaaPKafkaMetaBroker.deleteTopic("testtopic");
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testDeleteTopic_error2() {
+ try {
+ dMaaPKafkaMetaBroker.deleteTopic("testtopic");
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testDeleteTopic_error3() {
+ try {
+ dMaaPKafkaMetaBroker.deleteTopic("testtopic");
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ assertTrue(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/JUnitTestSuite.java
new file mode 100644
index 0000000..cf48007
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/JUnitTestSuite.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.cambria.beans;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({ApiKeyBeanTest.class, ApiKeyBeanTest2.class, ApiKeyBeanTest3.class,
+ ApiKeyBeanTest4.class, ApiKeyBeanTest5.class, ApiKeyBeanTest6.class,
+ DMaaPCambriaLimiterTest.class, DMaaPContextTest.class, DMaaPContextTest2.class,
+ DMaaPContextTest3.class, DMaaPContextTest4.class, DMaaPContextTest5.class,
+ DMaaPContextTest6.class, LogDetailsTest.class, LogDetailsTest2.class,
+ LogDetailsTest3.class, LogDetailsTest4.class, LogDetailsTest5.class, LogDetailsTest6.class,
+ LogDetailsTest7.class, LogDetailsTest8.class, LogDetailsTest9.class, LogDetailsTest10.class,
+ LogDetailsTest11.class, LogDetailsTest12.class, LogDetailsTest13.class, LogDetailsTest14.class,
+ LogDetailsTest15.class, LogDetailsTest16.class, TopicBeanTest.class, TopicBeanTest2.class,
+ TopicBeanTest3.class, TopicBeanTest4.class, TopicBeanTest5.class, TopicBeanTest6.class,
+ TopicBeanTest7.class, TopicBeanTest8.class, TopicBeanTest9.class, TopicBeanTest10.class,})
+
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/beans/LogDetailsTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest.java
new file mode 100644
index 0000000..41a4c94
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest.java
@@ -0,0 +1,85 @@
+/*-
+ * ============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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.*;
+
+public class LogDetailsTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetPublisherId() {
+
+ LogDetails details = new LogDetails();
+
+ details.getPublisherId();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGetPublisherLogDetails(){
+
+ LogDetails details = new LogDetails();
+ details.setTotalMessageCount(1);
+ details.setConsumeTimestamp("02-27-1018");
+ details.setSubscriberGroupId("1");
+ details.setSubscriberId("1");
+ assertEquals(details.getTotalMessageCount(),1);
+ assertEquals(details.getConsumeTimestamp(),"02-27-1018");
+ assertEquals(details.getSubscriberId(),"1");
+ assertEquals(details.getSubscriberGroupId(),"1");
+ }
+
+ @Test
+ public void testPublisherdetails(){
+ LogDetails details = new LogDetails();
+ assertNotNull(details.getPublisherLogDetails());
+ assertNull(details.getTransactionIdTs());
+ assertFalse(details.isTransactionEnabled());
+ assertEquals(details.getMessageLengthInBytes(),0);
+ assertNotNull(details.getPublishTimestamp());
+ assertNull(details.getMessageTimestamp());
+ assertNull(details.getMessageSequence());
+ assertNull(details.getMessageBatchId());
+ assertNull(details.getPublisherIp());
+ assertNull(details.getTopicId());
+
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest10.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest10.java
new file mode 100644
index 0000000..c80062f
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest10.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class LogDetailsTest10 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetPublishTimestamp() {
+
+ LogDetails details = new LogDetails();
+
+ details.getPublishTimestamp();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest11.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest11.java
new file mode 100644
index 0000000..83b91cb
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest11.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class LogDetailsTest11 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetMessageLengthInBytes() {
+
+ LogDetails details = new LogDetails();
+
+ details.getMessageLengthInBytes();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest12.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest12.java
new file mode 100644
index 0000000..54f1fe5
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest12.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest12 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetConsumeTimestamp() {
+
+ LogDetails details = new LogDetails();
+
+ details.getConsumeTimestamp();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest13.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest13.java
new file mode 100644
index 0000000..7e9ea3e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest13.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest13 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetTotalMessageCount() {
+
+ LogDetails details = new LogDetails();
+
+ details.getTotalMessageCount();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest14.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest14.java
new file mode 100644
index 0000000..b3dd6b8
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest14.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class LogDetailsTest14 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testIsTransactionEnabled() {
+
+ LogDetails details = new LogDetails();
+
+ details.isTransactionEnabled();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest15.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest15.java
new file mode 100644
index 0000000..65d92da
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest15.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest15 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetTransactionIdTs() {
+
+ LogDetails details = new LogDetails();
+
+ details.getTransactionIdTs();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest16.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest16.java
new file mode 100644
index 0000000..95cee27
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest16.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class LogDetailsTest16 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetServerIp() {
+
+ LogDetails details = new LogDetails();
+
+ details.getServerIp();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest17.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest17.java
new file mode 100644
index 0000000..39104be
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest17.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class LogDetailsTest17 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetPublisherLogDetails() {
+
+ LogDetails details = new LogDetails();
+
+ details.getPublisherLogDetails();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest18.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest18.java
new file mode 100644
index 0000000..2fc6825
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest18.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest18 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetPublisherLogDetails() {
+
+ LogDetails details = new LogDetails();
+
+ details.getPublisherLogDetails();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest2.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest2.java
new file mode 100644
index 0000000..a0912b9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest2.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest2 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetTransactionId() {
+
+ LogDetails details = new LogDetails();
+
+ details.getTransactionId();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest3.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest3.java
new file mode 100644
index 0000000..c04a7d7
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest3.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest3 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetTopicId() {
+
+ LogDetails details = new LogDetails();
+
+ details.getTopicId();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest4.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest4.java
new file mode 100644
index 0000000..c73c47a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest4.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest4 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetSubscriberGroupId() {
+
+ LogDetails details = new LogDetails();
+
+ details.getSubscriberGroupId();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest5.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest5.java
new file mode 100644
index 0000000..36136e4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest5.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class LogDetailsTest5 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetSubscriberId() {
+
+ LogDetails details = new LogDetails();
+
+ details.getSubscriberId();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest6.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest6.java
new file mode 100644
index 0000000..ca583f9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest6.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class LogDetailsTest6 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetPublisherIp() {
+
+ LogDetails details = new LogDetails();
+
+ details.getPublisherIp();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest7.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest7.java
new file mode 100644
index 0000000..da03335
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest7.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.beans;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class LogDetailsTest7 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetMessageBatchId() {
+
+ LogDetails details = new LogDetails();
+
+ details.getMessageBatchId();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest8.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest8.java
new file mode 100644
index 0000000..81e550f
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest8.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest8 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetMessageTimestamp() {
+
+ LogDetails details = new LogDetails();
+
+ details.getMessageTimestamp();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest9.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest9.java
new file mode 100644
index 0000000..376548d
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/LogDetailsTest9.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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+import static org.junit.Assert.assertTrue;
+
+public class LogDetailsTest9 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetMessageSequence() {
+
+ LogDetails details = new LogDetails();
+
+ details.getMessageSequence();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TestRunner.java
new file mode 100644
index 0000000..dc024b4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/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.cambria.beans;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/beans/TopicBeanTest.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest.java
new file mode 100644
index 0000000..fa0a9ed
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *
+ * ================================================================================
+ * 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.cambria.beans;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+public class TopicBeanTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetTopicName() {
+
+ TopicBean bean = new TopicBean();
+
+ bean.getTopicName();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testTopicBean() {
+
+ TopicBean bean = new TopicBean("topicName", "topicDescription", 1,1,true);
+ assertNotNull(bean);
+
+ }
+
+ @Test
+ public void testTopicBeanStter() {
+
+ TopicBean bean = new TopicBean();
+ bean.setPartitionCount(1);
+ bean.setReplicationCount(1);
+ bean.setTopicDescription("topicDescription");
+ bean.setTopicName("topicName");
+ bean.setTransactionEnabled(true);
+ assertNotNull(bean);
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest10.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest10.java
new file mode 100644
index 0000000..de4fa7a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest10.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.cambria.beans;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+public class TopicBeanTest10 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSetTransactionEnabled() {
+
+ TopicBean bean = new TopicBean();
+ bean.setTransactionEnabled(true);
+
+ /* String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));*/
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest2.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest2.java
new file mode 100644
index 0000000..a1bbf7c
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest2.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+import static org.junit.Assert.assertTrue;
+
+public class TopicBeanTest2 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSetTopicName() {
+
+ TopicBean bean = new TopicBean();
+ bean.setTopicName("testTopic");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest3.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest3.java
new file mode 100644
index 0000000..3227767
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest3.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.cambria.beans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+import static org.junit.Assert.assertTrue;
+
+public class TopicBeanTest3 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetPartitionCount() {
+
+ TopicBean bean = new TopicBean();
+ bean.getPartitionCount();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest4.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest4.java
new file mode 100644
index 0000000..3f5977a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest4.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.cambria.beans;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+public class TopicBeanTest4 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSetPartitionCount() {
+
+ TopicBean bean = new TopicBean();
+ bean.setPartitionCount(8);
+
+ /* String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));*/
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest5.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest5.java
new file mode 100644
index 0000000..8a172e8
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest5.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.cambria.beans;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+public class TopicBeanTest5 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetReplicationCount() {
+
+ TopicBean bean = new TopicBean();
+ bean.getReplicationCount();
+
+ /* String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));*/
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest6.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest6.java
new file mode 100644
index 0000000..edc6d39
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest6.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.cambria.beans;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+public class TopicBeanTest6 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSetReplicationCount() {
+
+ TopicBean bean = new TopicBean();
+ bean.setReplicationCount(3);
+
+ /* String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));*/
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest7.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest7.java
new file mode 100644
index 0000000..9c3ab9d
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest7.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.cambria.beans;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+public class TopicBeanTest7 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testIsTransactionEnabled() {
+
+ TopicBean bean = new TopicBean();
+ bean.isTransactionEnabled();
+
+ /* String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));*/
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest8.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest8.java
new file mode 100644
index 0000000..bb5f6da
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest8.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.cambria.beans;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+public class TopicBeanTest8 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetTopicDescription() {
+
+ TopicBean bean = new TopicBean();
+ bean.getTopicDescription();
+
+ /* String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));*/
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest9.java b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest9.java
new file mode 100644
index 0000000..3be66e4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/beans/TopicBeanTest9.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.cambria.beans;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.TopicBean;
+
+public class TopicBeanTest9 {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSetTopicDescription() {
+
+ TopicBean bean = new TopicBean();
+ bean.setTopicDescription("testing topic");
+
+ /* String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));*/
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/embed/EmbedConfigurationReader.java b/src/test/java/org/onap/dmaap/mr/cambria/embed/EmbedConfigurationReader.java
new file mode 100644
index 0000000..3e3fd28
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/embed/EmbedConfigurationReader.java
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * ============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.cambria.embed;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.curator.framework.CuratorFramework;
+
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import org.onap.dmaap.dmf.mr.backends.kafka.KafkaPublisher;
+import org.onap.dmaap.dmf.mr.backends.memory.MemoryMetaBroker;
+import org.onap.dmaap.dmf.mr.backends.memory.MemoryQueue;
+import org.apache.kafka.clients.admin.AdminClient;
+import org.apache.kafka.clients.admin.AdminClientConfig;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaConsumerFactory;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.beans.DMaaPMetricsSet;
+import org.onap.dmaap.dmf.mr.beans.DMaaPZkClient;
+import org.onap.dmaap.dmf.mr.beans.DMaaPZkConfigDb;
+import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticatorImpl;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.onap.dmaap.dmf.mr.utils.DMaaPCuratorFactory;
+import org.onap.dmaap.dmf.mr.utils.PropertyReader;
+import com.att.nsa.security.db.BaseNsaApiDbImpl;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+import com.att.nsa.security.db.simple.NsaSimpleApiKeyFactory;
+
+
+public class EmbedConfigurationReader {
+ private static final String DEFAULT_KAFKA_LOG_DIR = "/kafka_embedded";
+ public static final String TEST_TOPIC = "testTopic";
+ private static final int BROKER_ID = 0;
+ private static final int BROKER_PORT = 5000;
+ private static final String LOCALHOST_BROKER = String.format("localhost:%d", BROKER_PORT);
+
+ private static final String DEFAULT_ZOOKEEPER_LOG_DIR = "/zookeeper";
+ private static final int ZOOKEEPER_PORT = 2000;
+ private static final String ZOOKEEPER_HOST = String.format("localhost:%d", ZOOKEEPER_PORT);
+
+ private static final String groupId = "groupID";
+ String dir;
+ private AdminClient fKafkaAdminClient;
+ KafkaLocal kafkaLocal;
+
+ public void setUp() throws Exception {
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ AJSCPropertiesMap.refresh(new File(classLoader.getResource(CambriaConstants.msgRtr_prop).getFile()));
+
+ Properties kafkaProperties;
+ Properties zkProperties;
+
+ try {
+ //load properties
+ dir = new File(classLoader.getResource(CambriaConstants.msgRtr_prop).getFile()).getParent();
+ kafkaProperties = getKafkaProperties(dir + DEFAULT_KAFKA_LOG_DIR, BROKER_PORT, BROKER_ID);
+ zkProperties = getZookeeperProperties(ZOOKEEPER_PORT,dir + DEFAULT_ZOOKEEPER_LOG_DIR);
+
+ //start kafkaLocalServer
+ kafkaLocal = new KafkaLocal(kafkaProperties, zkProperties);
+
+ Map<String, String> map = AJSCPropertiesMap.getProperties(CambriaConstants.msgRtr_prop);
+ map.put(CambriaConstants.kSetting_ZkConfigDbServers, ZOOKEEPER_HOST);
+ map.put("kafka.client.zookeeper", ZOOKEEPER_HOST);
+ map.put("kafka.metadata.broker.list", LOCALHOST_BROKER);
+
+ DMaaPZkClient dMaaPZkClient = new DMaaPZkClient(new PropertyReader());
+
+ final Properties props = new Properties ();
+ props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092" );
+ props.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username='admin' password='admin_secret'");
+ props.put(AdminClientConfig.SECURITY_PROTOCOL_CONFIG, "SASL_PLAINTEXT");
+ props.put("sasl.mechanism", "PLAIN");
+ fKafkaAdminClient = AdminClient.create ( props );
+
+ // if(!AdminUtils.topicExists(dMaaPZkClient, TEST_TOPIC))
+ // AdminUtils.createTopic(dMaaPZkClient, TEST_TOPIC, 3, 1, new Properties());
+ final NewTopic topicRequest = new NewTopic ( TEST_TOPIC, 3, new Integer(1).shortValue () );
+ fKafkaAdminClient.createTopics ( Arrays.asList ( topicRequest ) );
+ Thread.sleep(5000);
+ } catch (Exception e){
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private static Properties getKafkaProperties(String logDir, int port, int brokerId) {
+ Properties properties = new Properties();
+ properties.put("port", port + "");
+ properties.put("broker.id", brokerId + "");
+ properties.put("log.dir", logDir);
+ properties.put("zookeeper.connect", ZOOKEEPER_HOST);
+ properties.put("default.replication.factor", "1");
+ properties.put("delete.topic.enable", "true");
+ properties.put("consumer.timeout.ms", -1);
+ return properties;
+ }
+
+ private static Properties getZookeeperProperties(int port, String zookeeperDir) {
+ Properties properties = new Properties();
+ properties.put("clientPort", port + "");
+ properties.put("dataDir", zookeeperDir);
+ return properties;
+ }
+
+ public void tearDown() throws Exception {
+ DMaaPZkClient dMaaPZkClient = new DMaaPZkClient(new PropertyReader());
+ if(fKafkaAdminClient!=null)
+ fKafkaAdminClient.deleteTopics(Arrays.asList(TEST_TOPIC));
+ //AdminUtils.deleteTopic(dMaaPZkClient, TEST_TOPIC);
+ //dMaaPZkClient.delete(dir + DEFAULT_KAFKA_LOG_DIR);
+ //dMaaPZkClient.delete(dir + DEFAULT_ZOOKEEPER_LOG_DIR);
+ kafkaLocal.stop();
+ FileUtils.cleanDirectory(new File(dir + DEFAULT_KAFKA_LOG_DIR));
+ }
+
+
+ public ConfigurationReader buildConfigurationReader() throws Exception {
+
+ setUp();
+
+ PropertyReader propertyReader = new PropertyReader();
+ DMaaPMetricsSet dMaaPMetricsSet = new DMaaPMetricsSet(propertyReader);
+ DMaaPZkClient dMaaPZkClient = new DMaaPZkClient(propertyReader);
+ DMaaPZkConfigDb dMaaPZkConfigDb = new DMaaPZkConfigDb(dMaaPZkClient, propertyReader);
+ CuratorFramework curatorFramework = DMaaPCuratorFactory.getCurator(new PropertyReader());
+ DMaaPKafkaConsumerFactory dMaaPKafkaConsumerFactory = new DMaaPKafkaConsumerFactory(dMaaPMetricsSet, curatorFramework,null);
+ MemoryQueue memoryQueue = new MemoryQueue();
+ MemoryMetaBroker memoryMetaBroker = new MemoryMetaBroker(memoryQueue, dMaaPZkConfigDb);
+ BaseNsaApiDbImpl<NsaSimpleApiKey> baseNsaApiDbImpl = new BaseNsaApiDbImpl<>(dMaaPZkConfigDb, new NsaSimpleApiKeyFactory());
+ DMaaPAuthenticator<NsaSimpleApiKey> dMaaPAuthenticator = new DMaaPAuthenticatorImpl<>(baseNsaApiDbImpl);
+ KafkaPublisher kafkaPublisher = new KafkaPublisher(propertyReader);
+ DMaaPKafkaMetaBroker dMaaPKafkaMetaBroker = new DMaaPKafkaMetaBroker(propertyReader, dMaaPZkClient, dMaaPZkConfigDb);
+
+ return new ConfigurationReader(propertyReader,
+ dMaaPMetricsSet, dMaaPZkClient, dMaaPZkConfigDb, kafkaPublisher,
+ curatorFramework, dMaaPKafkaConsumerFactory, dMaaPKafkaMetaBroker,
+ memoryQueue, memoryMetaBroker, baseNsaApiDbImpl, dMaaPAuthenticator);
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/embed/KafkaLocal.java b/src/test/java/org/onap/dmaap/mr/cambria/embed/KafkaLocal.java
new file mode 100644
index 0000000..9f3c05a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/embed/KafkaLocal.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.cambria.embed;
+
+import kafka.server.KafkaConfig;
+import kafka.server.KafkaServerStartable;
+
+import java.io.IOException;
+import java.util.Properties;
+
+
+public class KafkaLocal {
+
+ public KafkaServerStartable kafka;
+ public ZooKeeperLocal zookeeper;
+
+ public KafkaLocal(Properties kafkaProperties, Properties zkProperties) throws IOException, InterruptedException{
+ KafkaConfig kafkaConfig = new KafkaConfig(kafkaProperties);
+
+ //start local zookeeper
+ System.out.println("starting local zookeeper...");
+ zookeeper = new ZooKeeperLocal(zkProperties);
+ System.out.println("done");
+
+ //start local kafka broker
+ kafka = new KafkaServerStartable(kafkaConfig);
+ System.out.println("starting local kafka broker...");
+ kafka.startup();
+ System.out.println("done");
+ }
+
+
+ public void stop(){
+ //stop kafka broker
+ System.out.println("stopping kafka...");
+ kafka.shutdown();
+ System.out.println("done");
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/embed/ZooKeeperLocal.java b/src/test/java/org/onap/dmaap/mr/cambria/embed/ZooKeeperLocal.java
new file mode 100644
index 0000000..3209845
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/embed/ZooKeeperLocal.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.cambria.embed;
+
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+public class ZooKeeperLocal {
+
+ ZooKeeperServerMain zooKeeperServer;
+
+ public ZooKeeperLocal(Properties zkProperties) throws FileNotFoundException, IOException{
+ QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
+ try {
+ quorumConfiguration.parseProperties(zkProperties);
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ zooKeeperServer = new ZooKeeperServerMain();
+ final ServerConfig configuration = new ServerConfig();
+ configuration.readFrom(quorumConfiguration);
+
+
+ new Thread() {
+ public void run() {
+ try {
+ zooKeeperServer.runFromConfig(configuration);
+ } catch (IOException e) {
+ System.out.println("ZooKeeper Failed");
+ e.printStackTrace(System.err);
+ }
+ }
+ }.start();
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPCambriaExceptionMapperTest.java b/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPCambriaExceptionMapperTest.java
new file mode 100644
index 0000000..6e4f75e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPCambriaExceptionMapperTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.cambria.exception;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.exception.DMaaPCambriaExceptionMapper;
+
+import static org.junit.Assert.assertTrue;
+
+public class DMaaPCambriaExceptionMapperTest {
+
+ @Before
+ public void setUp() throws Exception {
+ DMaaPCambriaExceptionMapper exception = new DMaaPCambriaExceptionMapper();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+
+ @Test
+ public void testToResponse() {
+
+ DMaaPCambriaExceptionMapper mapper = new DMaaPCambriaExceptionMapper();
+
+ try {
+ mapper.toResponse(null);
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+
+
+
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPErrorMessagesTest.java b/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPErrorMessagesTest.java
new file mode 100644
index 0000000..a01ce90
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPErrorMessagesTest.java
@@ -0,0 +1,370 @@
+/*-
+ * ============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.cambria.exception;
+
+import static org.junit.Assert.*;
+import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DMaaPErrorMessagesTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+
+ @Test
+ public void testGetMsgSizeExceeds() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getMsgSizeExceeds();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetMsgSizeExceeds() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setMsgSizeExceeds("200");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetNotFound() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getNotFound();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetNotFound() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setNotFound("not found");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetServerUnav() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getServerUnav();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetServerUnav() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setServerUnav("server1");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetMethodNotAllowed() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getMethodNotAllowed();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetMethodNotAllowed() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setMethodNotAllowed("server2");
+ assertTrue(true);
+
+ }
+
+
+ @Test
+ public void testGetBadRequest() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getBadRequest();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetBadRequest() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setBadRequest("badRequest");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetNwTimeout() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getNwTimeout();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetNwTimeout() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setNwTimeout("12:00:00");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetNotPermitted1() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getNotPermitted1();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetNotPermitted1() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setNotPermitted1("not permitted");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetNotPermitted2() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getNotPermitted2();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetNotPermitted2() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setNotPermitted2("not permitted2");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetTopicsfailure() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getTopicsfailure();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetTopicsfailure() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setTopicsfailure("failure");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetTopicDetailsFail() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getTopicDetailsFail();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetTopicDetailsFail() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setTopicDetailsFail("topic details fail");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetCreateTopicFail() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getCreateTopicFail();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetCreateTopicFail() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setCreateTopicFail("topic details fail");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetIncorrectJson() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getIncorrectJson();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetIncorrectJson() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setIncorrectJson("incorrect Json");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetDeleteTopicFail() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getDeleteTopicFail();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetDeleteTopicFail() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setDeleteTopicFail("delete tpic fail");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetConsumeMsgError() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getConsumeMsgError();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetConsumeMsgError() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setConsumeMsgError("consume message error");
+ assertTrue(true);
+
+ }
+
+
+ @Test
+ public void testGetPublishMsgError() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getPublishMsgError();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetPublishMsgError() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setPublishMsgError("publish message error");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetPublishMsgCount() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getPublishMsgCount();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetPublishMsgCount() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setPublishMsgCount("200");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetAuthFailure() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getAuthFailure();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetAuthFailure() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setAuthFailure("auth failure");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetTopicNotExist() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.getTopicNotExist();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetTopicNotExist() {
+
+ DMaaPErrorMessages msg = new DMaaPErrorMessages();
+ msg.setTopicNotExist("toopic doesn't exist");
+ assertTrue(true);
+
+ }
+
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPWebExceptionMapperTest.java b/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPWebExceptionMapperTest.java
new file mode 100644
index 0000000..dfb8517
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/exception/DMaaPWebExceptionMapperTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.cambria.exception;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.exception.DMaaPWebExceptionMapper;
+
+import static org.junit.Assert.assertTrue;
+
+public class DMaaPWebExceptionMapperTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+
+ @Test
+ public void testToResponse() {
+
+ DMaaPWebExceptionMapper msg = new DMaaPWebExceptionMapper();
+
+ try {
+ msg.toResponse(null);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+
+
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/exception/ErrorResponseTest.java b/src/test/java/org/onap/dmaap/mr/cambria/exception/ErrorResponseTest.java
new file mode 100644
index 0000000..b5aa75a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/exception/ErrorResponseTest.java
@@ -0,0 +1,144 @@
+/*-
+ * ============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.cambria.exception;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.exception.ErrorResponse;
+
+import static org.junit.Assert.assertTrue;
+
+public class ErrorResponseTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+
+ @Test
+ public void testGetHttpStatusCode() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.getHttpStatusCode();
+ assertTrue(true);
+
+
+ }
+
+ @Test
+ public void tesSGetHttpStatusCode() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.setHttpStatusCode(200);
+ assertTrue(true);
+
+
+ }
+
+ @Test
+ public void testGetMrErrorCode() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.getMrErrorCode();
+ assertTrue(true);
+
+
+ }
+
+ @Test
+ public void testSetMrErrorCode() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.setMrErrorCode(500);
+ assertTrue(true);
+
+
+ }
+
+ @Test
+ public void testGetErrorMessage() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.getErrorMessage();
+ assertTrue(true);
+
+
+ }
+
+ @Test
+ public void testSetErrorMessage() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.setErrorMessage("no error");
+ assertTrue(true);
+
+
+ }
+
+ @Test
+ public void testToString() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.toString();
+ assertTrue(true);
+
+
+ }
+
+ @Test
+ public void testGetErrMapperStr1() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.setHelpURL("/help");
+ assertTrue(true);
+
+
+ }
+
+ @Test
+ public void testGetErrMapperStr() {
+
+ ErrorResponse resp = new ErrorResponse(200, 500, "no error");
+
+ resp.getHelpURL();
+ assertTrue(true);
+
+
+ }
+
+
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/exception/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/exception/JUnitTestSuite.java
new file mode 100644
index 0000000..dc0cf50
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/exception/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.cambria.exception;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DMaaPCambriaExceptionMapperTest.class,
+ DMaaPErrorMessagesTest.class, DMaaPWebExceptionMapperTest.class, ErrorResponseTest.class})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/exception/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/exception/TestRunner.java
new file mode 100644
index 0000000..77920c8
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/exception/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.cambria.exception;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/listener/CambriaServletContextListenerTest.java b/src/test/java/org/onap/dmaap/mr/cambria/listener/CambriaServletContextListenerTest.java
new file mode 100644
index 0000000..c97030e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/listener/CambriaServletContextListenerTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============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.cambria.listener;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.listener.CambriaServletContextListener;
+
+import static org.junit.Assert.assertTrue;
+
+public class CambriaServletContextListenerTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testContextDestroyed() {
+ CambriaServletContextListener listener = new CambriaServletContextListener();
+ try {
+ listener.contextDestroyed(null);
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testContextInitialized() {
+ CambriaServletContextListener listener = new CambriaServletContextListener();
+
+ try {
+ listener.contextInitialized(null);
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/listener/DME2EndPointLoaderTest.java b/src/test/java/org/onap/dmaap/mr/cambria/listener/DME2EndPointLoaderTest.java
new file mode 100644
index 0000000..ffc2535
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/listener/DME2EndPointLoaderTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============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.cambria.listener;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.listener.DME2EndPointLoader;
+
+import static org.junit.Assert.assertTrue;
+
+public class DME2EndPointLoaderTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testPublishEndPoints() {
+ DME2EndPointLoader loader = DME2EndPointLoader.getInstance();
+
+
+ try {
+ loader.publishEndPoints();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testUnPublishEndPoints() {
+ DME2EndPointLoader loader = DME2EndPointLoader.getInstance();
+
+
+ try {
+ loader.unPublishEndPoints();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/listener/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/listener/JUnitTestSuite.java
new file mode 100644
index 0000000..0dd7db5
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/listener/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.cambria.listener;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DME2EndPointLoaderTest.class, CambriaServletContextListenerTest.class})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/listener/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/listener/TestRunner.java
new file mode 100644
index 0000000..82078c6
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/listener/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.cambria.listener;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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());
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metabroker/BrokerImpl.java b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/BrokerImpl.java
new file mode 100644
index 0000000..94fdb6b
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/BrokerImpl.java
@@ -0,0 +1,71 @@
+/*-
+ * ============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.cambria.metabroker;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.metabroker.Broker;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+
+public class BrokerImpl implements Broker {
+
+ @Override
+ public List<Topic> getAllTopics() throws ConfigDbException {
+ // TODO Auto-generated method stub
+ Topic top = new TopicImplem();
+
+ List<Topic> list = new ArrayList<Topic>();
+
+ for (int i = 0; i < 5; i++) {
+ top = new TopicImplem();
+ list.add(top);
+
+ }
+
+ return null;
+
+ }
+
+ @Override
+ public Topic getTopic(String topic) throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return new TopicImplem();
+ }
+
+ @Override
+ public Topic createTopic(String topic, String description, String ownerApiKey, int partitions, int replicas,
+ boolean transactionEnabled) throws TopicExistsException, CambriaApiException {
+ // TODO Auto-generated method stub
+ return new TopicImplem(topic, description, ownerApiKey, transactionEnabled);
+ }
+
+ @Override
+ public void deleteTopic(String topic) throws AccessDeniedException, CambriaApiException, TopicExistsException {
+ // TODO Auto-generated method stub
+ Topic top = new TopicImplem();
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metabroker/BrokerImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/BrokerImplTest.java
new file mode 100644
index 0000000..19487df
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/BrokerImplTest.java
@@ -0,0 +1,108 @@
+/*-
+ * ============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.cambria.metabroker;
+
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
+
+import static org.junit.Assert.assertTrue;
+
+public class BrokerImplTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetOwners() {
+
+ try {
+ new BrokerImpl().getAllTopics();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+ }
+
+ @Test
+ public void testGetTopic() {
+
+ try {
+ new BrokerImpl().getTopic("topicName");
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateTopic() {
+
+ try {
+ new BrokerImpl().createTopic("topicName", "testing topic", "owner123", 3, 3, true);
+
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDeleteTopic() {
+
+ try {
+ new BrokerImpl().deleteTopic("topicName");
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metabroker/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/JUnitTestSuite.java
new file mode 100644
index 0000000..b321af5
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/JUnitTestSuite.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.cambria.metabroker;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({BrokerImplTest.class, TopicImplemTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/metabroker/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TestRunner.java
new file mode 100644
index 0000000..acf2184
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/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.cambria.metabroker;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/metabroker/TopicImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplTest.java
new file mode 100644
index 0000000..fabe91c
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplTest.java
@@ -0,0 +1,25 @@
+/*-
+ * ============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.cambria.metabroker;
+
+public class TopicImplTest {
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplem.java b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplem.java
new file mode 100644
index 0000000..5aea70a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplem.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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.cambria.metabroker;
+
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.NsaAcl;
+import com.att.nsa.security.NsaApiKey;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+
+import java.util.Set;
+
+public class TopicImplem implements Topic {
+ private String name, owner, description;
+ boolean isTransactionEnabled;
+ private Set<String> set = null;
+ private NsaAcl readerAcl, writerAcl;
+
+ public TopicImplem() {
+ name = getName();
+ owner = getOwner();
+ description = getDescription();
+ isTransactionEnabled = true;
+ readerAcl = getReaderAcl();
+ writerAcl = getWriterAcl();
+ }
+
+ public TopicImplem(String topic, String description, String ownerApiKey, boolean transactionEnabled) {
+
+ this.name = topic;
+ this.owner = ownerApiKey;
+ this.description = description;
+ isTransactionEnabled = transactionEnabled;
+
+
+ }
+ @Override
+ public Set<String> getOwners() {
+ // TODO Auto-generated method stub
+ for (int i = 0; i < 5; i++) {
+ set.add("string" + (i + 1));
+ }
+ return set;
+ }
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return "testTopic";
+ }
+
+ @Override
+ public String getOwner() {
+ // TODO Auto-generated method stub
+ return "owner";
+ }
+
+ @Override
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return "topic for testing purposes";
+ }
+
+ @Override
+ public boolean isTransactionEnabled() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @Override
+ public NsaAcl getReaderAcl() {
+ // TODO Auto-generated method stub
+ return new NsaAcl();
+ }
+
+ @Override
+ public NsaAcl getWriterAcl() {
+ // TODO Auto-generated method stub
+ return new NsaAcl();
+ }
+
+ @Override
+ public void checkUserRead(NsaApiKey user) throws AccessDeniedException {
+ // TODO Auto-generated method stub
+ NsaApiKey u = user;
+ }
+
+ @Override
+ public void checkUserWrite(NsaApiKey user) throws AccessDeniedException {
+ // TODO Auto-generated method stub
+
+ NsaApiKey u = user;
+ }
+
+ @Override
+ public void permitWritesFromUser(String publisherId, NsaApiKey asUser)
+ throws AccessDeniedException, ConfigDbException {
+ // TODO Auto-generated method stub
+ String id = publisherId;
+
+ }
+
+ @Override
+ public void denyWritesFromUser(String publisherId, NsaApiKey asUser)
+ throws AccessDeniedException, ConfigDbException {
+ // TODO Auto-generated method stub
+ String id = publisherId;
+
+ }
+
+ @Override
+ public void permitReadsByUser(String consumerId, NsaApiKey asUser) throws AccessDeniedException, ConfigDbException {
+ // TODO Auto-generated method stub
+ String id = consumerId;
+ }
+
+ @Override
+ public void denyReadsByUser(String consumerId, NsaApiKey asUser) throws AccessDeniedException, ConfigDbException {
+ // TODO Auto-generated method stub
+ String id = consumerId;
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplemTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplemTest.java
new file mode 100644
index 0000000..c1c9489
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metabroker/TopicImplemTest.java
@@ -0,0 +1,176 @@
+/*-
+ * ============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.cambria.metabroker;
+
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TopicImplemTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+ @Test
+ public void testGetOwners() {
+
+ assertNotNull(new TopicImplem().getOwner());
+
+ }
+
+ @Test
+ public void testGetName() {
+
+ assertNotNull(new TopicImplem().getName());
+
+ }
+
+ @Test
+ public void testGetOwner() {
+
+ assertNotNull(new TopicImplem().getOwner());
+
+ }
+
+ @Test
+ public void testGetDescription() {
+
+ assertNotNull(new TopicImplem().getDescription());
+
+ }
+
+ @Test
+ public void testIsTransactionEnabled() {
+
+ assertTrue(new TopicImplem().isTransactionEnabled());
+
+ }
+
+ @Test
+ public void testGetReaderAcl() {
+ new TopicImplem().getReaderAcl();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetWriterAcl() {
+ new TopicImplem().getReaderAcl();
+ assertTrue(true);
+
+ }
+
+
+ @Test
+ public void testCheckUserRead() {
+ try {
+ new TopicImplem().checkUserRead(null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckUserWrite() {
+ try {
+ new TopicImplem().checkUserWrite(null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testPermitWritesFromUser() {
+ try {
+ new TopicImplem().permitWritesFromUser("publisherId", null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDenyWritesFromUser() {
+ try {
+ new TopicImplem().denyWritesFromUser("publisherId", null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testPermitReadsByUser() {
+ try {
+ new TopicImplem().permitReadsByUser("consumerId", null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDenyReadsByUser() {
+ try {
+ new TopicImplem().denyReadsByUser("consumerId", null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/CambriaPublisherUtilityTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/CambriaPublisherUtilityTest.java
new file mode 100644
index 0000000..490c161
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/CambriaPublisherUtilityTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.cambria.metrics.publisher;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.metrics.publisher.CambriaPublisherUtility;
+
+import static org.junit.Assert.assertTrue;
+
+public class CambriaPublisherUtilityTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testEscape() {
+
+ CambriaPublisherUtility utility = new CambriaPublisherUtility();
+
+ utility.escape("testTopic");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testMakeUrl() {
+
+ CambriaPublisherUtility utility = new CambriaPublisherUtility();
+
+ utility.makeUrl("testTopic");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testMakeConsumerUrl() {
+
+ CambriaPublisherUtility utility = new CambriaPublisherUtility();
+
+ utility.makeConsumerUrl("testTopic", "CG1", "23");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateHostsList() {
+
+ CambriaPublisherUtility utility = new CambriaPublisherUtility();
+
+ try {
+ utility.createHostsList(null);
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+
+
+ }
+
+ @Test
+ public void testHostForString() {
+
+ CambriaPublisherUtility utility = new CambriaPublisherUtility();
+
+ utility.hostForString("hello");
+ assertTrue(true);
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/DMaaPCambriaClientFactoryTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/DMaaPCambriaClientFactoryTest.java
new file mode 100644
index 0000000..13e97e4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/DMaaPCambriaClientFactoryTest.java
@@ -0,0 +1,166 @@
+/*-
+ * ============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.cambria.metrics.publisher;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.metrics.publisher.DMaaPCambriaClientFactory;
+
+public class DMaaPCambriaClientFactoryTest {
+
+ private Collection<String> hostSet;
+
+ private String[] hostSetArray;
+ @Before
+ public void setUp() throws Exception {
+ hostSet = new ArrayList<String>();
+
+ hostSetArray = new String[10];
+
+ for (int i = 0; i < 10; i++) {
+ hostSet.add("host" + (i+1));
+ hostSetArray[i] = "host" + (i+1);
+ }
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testCreateConsumer() {
+
+
+
+ DMaaPCambriaClientFactory.createConsumer("hostList", "testTopic");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateConsumer2() {
+
+
+ try {
+ DMaaPCambriaClientFactory.createConsumer(hostSet, "testTopic");
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+
+
+ }
+
+ @Test
+ public void testCreateConsumer3() {
+
+ DMaaPCambriaClientFactory.createConsumer(hostSet, "testTopic", "filter");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateConsumer4() {
+ DMaaPCambriaClientFactory.createConsumer(hostSet, "testTopic", "CG1", "23");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateConsumer5() {
+
+ DMaaPCambriaClientFactory.createConsumer(hostSet, "testTopic", "CG1", "23", 100, 20);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateConsumer6() {
+
+
+ DMaaPCambriaClientFactory.createConsumer("hostList", "testTopic", "CG1", "23", 100, 20, "filter", "apikey", "apisecret");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateConsumer7() {
+
+ DMaaPCambriaClientFactory.createConsumer(hostSet, "testTopic", "CG1", "23", 100, 20, "filter", "apikey", "apisecret");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateSimplePublisher() {
+
+ DMaaPCambriaClientFactory.createSimplePublisher("hostList", "testTopic");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateBatchingPublisher() {
+
+ DMaaPCambriaClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 50);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateBatchingPublisher2() {
+
+ DMaaPCambriaClientFactory.createBatchingPublisher("hostList", "testTopic", 100, 50, true);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateBatchingPublisher3() {
+
+ DMaaPCambriaClientFactory.createBatchingPublisher(hostSetArray, "testTopic", 100, 50, true);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateBatchingPublisher4() {
+
+ DMaaPCambriaClientFactory.createBatchingPublisher(hostSet, "testTopic", 100, 50, true);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void $testInject() {
+
+ DMaaPCambriaClientFactory factory = new DMaaPCambriaClientFactory();
+ factory.$testInject(null);
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/JUnitTestSuite.java
new file mode 100644
index 0000000..8dbcf12
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/JUnitTestSuite.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.cambria.metrics.publisher;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DMaaPCambriaClientFactoryTest.class, CambriaPublisherUtilityTest.class})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/metrics/publisher/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/TestRunner.java
new file mode 100644
index 0000000..92e9f7d
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/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.cambria.metrics.publisher;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/metrics/publisher/impl/CambriaBaseClientTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/CambriaBaseClientTest.java
new file mode 100644
index 0000000..8127b42
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/CambriaBaseClientTest.java
@@ -0,0 +1,95 @@
+/*-
+ * ============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.cambria.metrics.publisher.impl;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.onap.dmaap.dmf.mr.metrics.publisher.impl.CambriaBaseClient;
+
+import org.json.JSONArray;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CambriaBaseClientTest {
+
+ private CambriaBaseClient client = null;
+ @Before
+ public void setUp() throws Exception {
+
+ Collection<String> hosts = new ArrayList<String>();
+
+ for (int i = 0; i < 5; i++) {
+ hosts.add("host"+(i+1));
+ }
+
+
+ client = new CambriaBaseClient(hosts, "client1");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testClose() {
+ client.close();
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGetLog() {
+ client.getLog();
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testLogTo() {
+ client.logTo(null);
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ public JSONArray getJSONArray() {
+
+ String[] data = {"stringone", "stringtwo"};
+ JSONArray array = new JSONArray(Arrays.asList(data));
+
+ return array;
+ }
+
+ @Test
+ public void testJsonArrayToSet() {
+ client.jsonArrayToSet(getJSONArray());
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/ClockTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/ClockTest.java
new file mode 100644
index 0000000..241c5f6
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/ClockTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.cambria.metrics.publisher.impl;
+
+import static org.junit.Assert.*;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.metrics.publisher.impl.Clock;
+
+public class ClockTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetIt() {
+
+ Clock.getIt();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testNow() {
+
+ Clock.now();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testNowImpl() {
+
+ Clock clock = new Clock();
+ clock.nowImpl();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testRegister() {
+
+ Clock clock = new Clock();
+ Clock.register(clock);
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/DMaaPCambriaConsumerImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/DMaaPCambriaConsumerImplTest.java
new file mode 100644
index 0000000..2bc2a7f
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/DMaaPCambriaConsumerImplTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.cambria.metrics.publisher.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.metrics.publisher.impl.DMaaPCambriaConsumerImpl;
+
+public class DMaaPCambriaConsumerImplTest {
+
+ private DMaaPCambriaConsumerImpl consumer = null;
+ @Before
+ public void setUp() throws Exception {
+
+ Collection<String> hosts = new ArrayList<String>();
+
+ for (int i = 0; i < 5; i++) {
+ hosts.add("host"+(i+1));
+ }
+ consumer = new DMaaPCambriaConsumerImpl(hosts, "testTopic", "consumerGroup1", "1", 2000, 200, "hi",
+ "9AMFFNIZpusO54oG","6BY86UQcio2LJdgyU7Cwg5oQ");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testStringToList() {
+
+ List<String> response = DMaaPCambriaConsumerImpl.stringToList("Hello world, this is a test string");
+ assertNotNull(response);
+
+
+ }
+
+ @Test
+ public void testFetch() {
+
+ Iterable<String> response = null;
+ boolean flag = true;
+ try {
+ response = consumer.fetch(200, 20);
+ } catch (IOException e) {
+ flag = false;
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if(flag) {
+ assertNotNull(response);
+ } else {
+ assertTrue(true);
+ }
+
+ }
+
+
+ @Test
+ public void testCreateUrlPath() {
+
+ String response = consumer.createUrlPath(200, 20);
+ assertNotNull(response);
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/DMaaPCambriaSimplerBatchPublisherTest.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/DMaaPCambriaSimplerBatchPublisherTest.java
new file mode 100644
index 0000000..f936de5
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/DMaaPCambriaSimplerBatchPublisherTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============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.cambria.metrics.publisher.impl;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.metrics.publisher.impl.DMaaPCambriaSimplerBatchPublisher;
+
+
+public class DMaaPCambriaSimplerBatchPublisherTest {
+
+ private DMaaPCambriaSimplerBatchPublisher publisher = null;
+ @Before
+ public void setUp() throws Exception {
+
+ Collection<String> hosts = new ArrayList<String>();
+
+ for (int i = 0; i < 5; i++) {
+ hosts.add("host"+(i+1));
+ }
+
+ publisher = new DMaaPCambriaSimplerBatchPublisher.Builder().againstUrls(hosts).onTopic("testTopic")
+ .batchTo(200, 100).compress(true).build();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSend() {
+
+ publisher.send("hello", "test message");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testClose() {
+
+ publisher.close();
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+ @Test
+ public void testGetPendingMEssageCount() {
+
+ publisher.getPendingMessageCount();
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/JUnitTestSuite.java
new file mode 100644
index 0000000..4bb1d15
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/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.cambria.metrics.publisher.impl;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DMaaPCambriaSimplerBatchPublisherTest.class, ClockTest.class,
+ CambriaBaseClientTest.class, DMaaPCambriaConsumerImplTest.class})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/metrics/publisher/impl/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/TestRunner.java
new file mode 100644
index 0000000..451be9e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/metrics/publisher/impl/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.cambria.metrics.publisher.impl;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/resources/CambriaEventSetTest.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaEventSetTest.java
new file mode 100644
index 0000000..48405e8
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaEventSetTest.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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.cambria.resources;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.resources.CambriaEventSet;
+import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class CambriaEventSetTest {
+
+ private CambriaOutboundEventStream coes = null;
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testNext() {
+ CambriaEventSet event = null;
+ String str = "contains text to be converted to InputStream";
+
+ InputStream stream = new ByteArrayInputStream(str.getBytes());
+ try {
+ event = new CambriaEventSet("application/cambria", stream, true, "hi");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ event.next();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java
new file mode 100644
index 0000000..9dfbcad
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/CambriaOutboundEventStreamTest.java
@@ -0,0 +1,129 @@
+/*-
+ * ============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.cambria.resources;
+
+import org.json.JSONException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
+import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream;
+import org.onap.dmaap.dmf.mr.resources.CambriaOutboundEventStream.operation;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class CambriaOutboundEventStreamTest {
+
+ private CambriaOutboundEventStream coes = null;
+
+ @Before
+ public void setUp() throws Exception {
+ coes = new CambriaOutboundEventStream.Builder(null).timeout(10).limit(1).filter(CambriaConstants.kNoFilter)
+ .pretty(false).withMeta(true).build();
+ DMaaPContext ctx = new DMaaPContext();
+ //ctx.set...
+ coes.setDmaapContext(ctx);
+ coes.setTopic(null);
+ coes.setTransEnabled(true);
+ coes.setTopicStyle(true);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetSentCount() {
+ int sentCount = coes.getSentCount();
+ assertTrue("Doesn't match, got " + sentCount, sentCount==0);;
+ }
+
+ @Test
+ public void testWrite() {
+ //fail("Not yet implemented");
+ }
+
+ @Test
+ public void testForEachMessage() {
+ try {
+ coes.forEachMessage(new operation(){
+
+ @Override
+ public void onWait() throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onMessage(int count, String msg, String transId, long offSet)
+ throws IOException, JSONException {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ }
+ }
+
+ @Test
+ public void testGetDmaapContext() {
+ DMaaPContext ctx = coes.getDmaapContext();
+
+ assertNotNull(ctx);
+ }
+
+ @Test
+ public void testSetDmaapContext() {
+ DMaaPContext ctx = new DMaaPContext();
+ coes.setDmaapContext(ctx);
+ assertTrue(ctx.equals(coes.getDmaapContext()));
+ }
+
+ @Test
+ public void testGetTopic() {
+ coes.getTopic();
+ assertTrue(true);
+ }
+
+ @Test
+ public void testSetTopic() {
+ //fail("Not yet implemented");
+ }
+
+ @Test
+ public void testSetTopicStyle() {
+ coes.setTopicStyle(true);
+ assertTrue(true);
+ }
+
+ @Test
+ public void testSetTransEnabled() {
+ coes.setTransEnabled(true);
+ assertTrue(true);
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/resources/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/JUnitTestSuite.java
new file mode 100644
index 0000000..5fd3143
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/JUnitTestSuite.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.cambria.resources;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({CambriaEventSetTest.class, CambriaOutboundEventStreamTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/resources/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/TestRunner.java
new file mode 100644
index 0000000..c701f10
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/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.cambria.resources;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/resources/streamReaders/CambriaJsonStreamReaderTest.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaJsonStreamReaderTest.java
new file mode 100644
index 0000000..ddfc435
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaJsonStreamReaderTest.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.cambria.resources.streamReaders;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.resources.streamReaders.CambriaJsonStreamReader;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertTrue;
+
+public class CambriaJsonStreamReaderTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+ @Test
+ public void testNext() {
+
+ CambriaJsonStreamReader test = null;
+
+ String source = "{'name': 'tester', 'id': '2'}";
+ InputStream stream = null;
+ try {
+ stream = IOUtils.toInputStream(source, "UTF-8");
+ test = new CambriaJsonStreamReader(stream,"hello");
+ test.next();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (CambriaApiException e1) {
+ e1.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaRawStreamReaderTest.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaRawStreamReaderTest.java
new file mode 100644
index 0000000..ab58082
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaRawStreamReaderTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============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.cambria.resources.streamReaders;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.backends.Publisher.message;
+import org.onap.dmaap.dmf.mr.resources.streamReaders.CambriaRawStreamReader;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertNotNull;
+
+public class CambriaRawStreamReaderTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testNext() {
+
+ CambriaRawStreamReader test = null;
+ message msg = null;
+
+ String source = "{'name': 'tester', 'id': '2'}";
+ InputStream stream = null;
+ try {
+ stream = IOUtils.toInputStream(source, "UTF-8");
+ test = new CambriaRawStreamReader(stream,"hello");
+ msg = test.next();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (CambriaApiException e1) {
+ e1.printStackTrace();
+ }
+
+ assertNotNull(msg);
+
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaStreamReaderTest.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaStreamReaderTest.java
new file mode 100644
index 0000000..6f54ac0
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaStreamReaderTest.java
@@ -0,0 +1,72 @@
+/*-
+ * ============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.cambria.resources.streamReaders;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.onap.dmaap.dmf.mr.resources.streamReaders.CambriaStreamReader;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+
+public class CambriaStreamReaderTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testNext() {
+
+ CambriaStreamReader test = null;
+
+
+ String source = "{'name': 'tester', 'id': '2', 'message': 'hello'}";
+ InputStream stream = null;
+ try {
+ stream = IOUtils.toInputStream(source, "UTF-8");
+ test = new CambriaStreamReader(stream);
+ test.next();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (CambriaApiException e1) {
+ e1.printStackTrace();
+ }
+
+ assertTrue(true);
+
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaTextStreamReaderTest.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaTextStreamReaderTest.java
new file mode 100644
index 0000000..a8a4886
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/CambriaTextStreamReaderTest.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.cambria.resources.streamReaders;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.resources.streamReaders.CambriaStreamReader;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertTrue;
+
+public class CambriaTextStreamReaderTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testNext() {
+
+ CambriaStreamReader test = null;
+
+ String source = "{'name': 'tester', 'id': '2', 'message': 'hello'}";
+ InputStream stream = null;
+ try {
+ stream = IOUtils.toInputStream(source, "UTF-8");
+ test = new CambriaStreamReader(stream);
+ test.next();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (CambriaApiException e1) {
+ e1.printStackTrace();
+ }
+
+ assertTrue(true);
+
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/JUnitTestSuite.java
new file mode 100644
index 0000000..da7626b
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/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.cambria.resources.streamReaders;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({CambriaJsonStreamReaderTest.class, CambriaRawStreamReaderTest.class,
+ CambriaStreamReaderTest.class, CambriaTextStreamReaderTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/resources/streamReaders/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/TestRunner.java
new file mode 100644
index 0000000..22f7656
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/resources/streamReaders/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.cambria.resources.streamReaders;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/security/DMaaPAuthenticatorImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/security/DMaaPAuthenticatorImplTest.java
new file mode 100644
index 0000000..dd607cb
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/security/DMaaPAuthenticatorImplTest.java
@@ -0,0 +1,123 @@
+/*-
+ * ============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.cambria.security;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticatorImpl;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class DMaaPAuthenticatorImplTest {
+
+ private MockHttpServletRequest request = null;
+ @Before
+ public void setUp() throws Exception {
+ //creating servlet object
+ request = new MockHttpServletRequest();
+ request.setServerName("www.example.com");
+ request.setRequestURI("/foo");
+ request.setQueryString("param1=value1&param");
+ String url = request.getRequestURL() + "?" + request.getQueryString();
+
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /*@Test
+ public void testAuthenticate() {
+
+ DMaaPAuthenticatorImpl<?> authenticator = new DMaaPAuthenticatorImpl(null);
+
+ DMaaPContext ctx = new DMaaPContext();
+ authenticator.authenticate(ctx);
+ assertTrue(true);
+
+ }*/
+
+
+
+ /*@Test
+ public void testAafPermissionString() {
+
+ DMaaPAAFAuthenticatorImpl authenticator = new DMaaPAAFAuthenticatorImpl();
+ try {
+ authenticator.aafPermissionString("testTopic", "admin");
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }*/
+
+ @Test
+ public void testIsAuthentic() {
+
+ DMaaPAuthenticatorImpl<?> authenticator = new DMaaPAuthenticatorImpl(null);
+
+ authenticator.isAuthentic(request);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testQualify() {
+
+ DMaaPAuthenticatorImpl<?> authenticator = new DMaaPAuthenticatorImpl(null);
+
+ authenticator.qualify(request);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAddAuthenticator() {
+
+ DMaaPAuthenticatorImpl authenticator = new DMaaPAuthenticatorImpl(null);
+ DMaaPAuthenticator authenticator2 = new DMaaPAuthenticatorImpl(null);
+
+ authenticator.addAuthenticator(authenticator2);
+ assertTrue(true);
+
+ }
+
+ /*@Test
+ public void testGetAuthenticatedUser() {
+
+
+ DMaaPContext ctx = new DMaaPContext();
+ DMaaPAuthenticatorImpl.getAuthenticatedUser(ctx);
+ assertTrue(true);
+
+ }
+ */
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/security/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/security/JUnitTestSuite.java
new file mode 100644
index 0000000..667ee04
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/security/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.cambria.security;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticatorImplTest;
+
+@RunWith(Suite.class)
+@SuiteClasses({DMaaPAAFAuthenticatorImplTest.class, DMaaPAuthenticatorImplTest.class,
+})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/security/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/security/TestRunner.java
new file mode 100644
index 0000000..30a6387
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/security/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.cambria.security;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/security/impl/DMaaPMechIdAuthenticatorTest.java b/src/test/java/org/onap/dmaap/mr/cambria/security/impl/DMaaPMechIdAuthenticatorTest.java
new file mode 100644
index 0000000..8612fca
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/security/impl/DMaaPMechIdAuthenticatorTest.java
@@ -0,0 +1,100 @@
+/*-
+ * ============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.cambria.security.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.security.impl.DMaaPMechIdAuthenticator;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class DMaaPMechIdAuthenticatorTest {
+
+ private MockHttpServletRequest request = null;
+ @Before
+ public void setUp() throws Exception {
+ //creating servlet object
+ request = new MockHttpServletRequest();
+ request.setServerName("www.example.com");
+ request.setRequestURI("/foo");
+ request.setQueryString("param1=value1&param");
+ String url = request.getRequestURL() + "?" + request.getQueryString();
+
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+ @Test
+ public void testQualify() {
+
+ DMaaPMechIdAuthenticator authenticator = new DMaaPMechIdAuthenticator();
+
+ authenticator.qualify(request);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAuthenticate() {
+
+ DMaaPMechIdAuthenticator authenticator = new DMaaPMechIdAuthenticator();
+
+ DMaaPContext ctx = new DMaaPContext();
+ authenticator.authenticate(ctx);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testIsAuthentic() {
+ DMaaPMechIdAuthenticator authenticator = new DMaaPMechIdAuthenticator();
+
+ authenticator.isAuthentic(request);
+ assertTrue(true);
+
+ }
+
+
+
+ @Test
+ public void testAddAuthenticator() {
+
+ DMaaPMechIdAuthenticator authenticator = new DMaaPMechIdAuthenticator();
+ DMaaPMechIdAuthenticator authenticator2 = new DMaaPMechIdAuthenticator();
+
+ authenticator.addAuthenticator(authenticator2);
+ assertTrue(true);
+
+ }
+
+
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/security/impl/DMaaPOriginalUebAuthenticatorTest.java b/src/test/java/org/onap/dmaap/mr/cambria/security/impl/DMaaPOriginalUebAuthenticatorTest.java
new file mode 100644
index 0000000..be3f5a2
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/security/impl/DMaaPOriginalUebAuthenticatorTest.java
@@ -0,0 +1,110 @@
+/*-
+ * ============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.cambria.security.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.security.impl.DMaaPOriginalUebAuthenticator;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class DMaaPOriginalUebAuthenticatorTest {
+
+ private MockHttpServletRequest request = null;
+ @Before
+ public void setUp() throws Exception {
+ //creating servlet object
+ request = new MockHttpServletRequest();
+ request.setServerName("www.example.com");
+ request.setRequestURI("/foo");
+ request.setQueryString("param1=value1&param");
+ String url = request.getRequestURL() + "?" + request.getQueryString();
+
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+ @Test
+ public void testQualify() {
+
+ DMaaPOriginalUebAuthenticator authenticator = new DMaaPOriginalUebAuthenticator(null, 100);
+
+ authenticator.qualify(request);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAuthenticate() {
+
+ DMaaPOriginalUebAuthenticator authenticator = new DMaaPOriginalUebAuthenticator(null, 100);
+
+ DMaaPContext ctx = new DMaaPContext();
+ authenticator.authenticate(ctx);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testAuthenticate2() {
+
+ DMaaPOriginalUebAuthenticator authenticator = new DMaaPOriginalUebAuthenticator(null, 100);
+ DMaaPContext ctx = new DMaaPContext();
+ authenticator.authenticate("google.com", "xHMDwk25kwkkyi26JH","Dec 16, 2016", "Dec/16/2016","123");
+
+
+ }
+
+ @Test
+ public void testIsAuthentic() {
+ DMaaPOriginalUebAuthenticator authenticator = new DMaaPOriginalUebAuthenticator(null, 100);
+
+ authenticator.isAuthentic(request);
+ assertTrue(true);
+
+ }
+
+
+
+ @Test
+ public void testAddAuthenticator() {
+
+ DMaaPOriginalUebAuthenticator authenticator = new DMaaPOriginalUebAuthenticator(null, 100);
+ DMaaPOriginalUebAuthenticator authenticator2 = new DMaaPOriginalUebAuthenticator(null, 100);
+
+ authenticator.addAuthenticator(authenticator2);
+ assertTrue(true);
+
+ }
+
+
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/security/impl/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/security/impl/JUnitTestSuite.java
new file mode 100644
index 0000000..48cf300
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/security/impl/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.cambria.security.impl;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DMaaPMechIdAuthenticatorTest.class, DMaaPOriginalUebAuthenticatorTest.class,
+})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/security/impl/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/security/impl/TestRunner.java
new file mode 100644
index 0000000..57285f6
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/security/impl/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.cambria.security.impl;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/service/impl/AdminServiceImplemTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/AdminServiceImplemTest.java
new file mode 100644
index 0000000..22db674
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/AdminServiceImplemTest.java
@@ -0,0 +1,183 @@
+/*-
+/*-
+ * ============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.cambria.service.impl;
+
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.limits.Blacklist;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+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.onap.dmaap.dmf.mr.backends.ConsumerFactory;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticatorImpl;
+import org.onap.dmaap.dmf.mr.service.impl.AdminServiceImpl;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;
+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;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ DMaaPAuthenticatorImpl.class, DMaaPResponseBuilder.class })
+public class AdminServiceImplemTest {
+
+ @InjectMocks
+ AdminServiceImpl adminServiceImpl;
+
+ @Mock
+ DMaaPContext dmaapContext;
+ @Mock
+ ConsumerFactory factory;
+
+ @Mock
+ ConfigurationReader configReader;
+ @Mock
+ Blacklist Blacklist;
+
+ @Before
+ public void setUp() throws Exception {
+
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(DMaaPAuthenticatorImpl.class);
+ NsaSimpleApiKey user = new NsaSimpleApiKey("admin", "password");
+
+ PowerMockito.when(dmaapContext.getConfigReader()).thenReturn(configReader);
+ PowerMockito.when(configReader.getfConsumerFactory()).thenReturn(factory);
+ PowerMockito.when(configReader.getfIpBlackList()).thenReturn(Blacklist);
+
+ PowerMockito.when(DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext)).thenReturn(user);
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ // ISSUES WITH AUTHENTICATION
+ @Test
+ public void testShowConsumerCache() {
+
+ try {
+ adminServiceImpl.showConsumerCache(dmaapContext);
+ } catch (IOException | AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testDropConsumerCache() {
+
+ try {
+ adminServiceImpl.dropConsumerCache(dmaapContext);
+ } catch (IOException | AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGetBlacklist() {
+
+ try {
+ adminServiceImpl.getBlacklist(dmaapContext);
+ } catch (IOException | AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testAddToBlacklist() {
+
+ try {
+ adminServiceImpl.addToBlacklist(dmaapContext, "120.120.120.120");
+ } catch (IOException | AccessDeniedException | ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testRemoveFromBlacklist() {
+
+ try {
+ adminServiceImpl.removeFromBlacklist(dmaapContext, "120.120.120.120");
+ } catch (IOException | AccessDeniedException | ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/service/impl/ApiKeysServiceImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/ApiKeysServiceImplTest.java
new file mode 100644
index 0000000..b218185
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/ApiKeysServiceImplTest.java
@@ -0,0 +1,333 @@
+/*-
+ * ============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.cambria.service.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.onap.dmaap.dmf.mr.backends.ConsumerFactory;
+import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticatorImpl;
+import org.onap.dmaap.dmf.mr.service.impl.ApiKeysServiceImpl;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;
+import org.onap.dmaap.dmf.mr.utils.Emailer;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.limits.Blacklist;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import com.att.nsa.security.db.NsaApiDb;
+import com.att.nsa.security.db.NsaApiDb.KeyExistsException;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+
+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.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ DMaaPAuthenticatorImpl.class, DMaaPResponseBuilder.class })
+public class ApiKeysServiceImplTest {
+
+ @InjectMocks
+ ApiKeysServiceImpl service;
+
+ @Mock
+ DMaaPContext dmaapContext;
+ @Mock
+ ConsumerFactory factory;
+
+ @Mock
+ ConfigurationReader configReader;
+ @Mock
+ Blacklist Blacklist;
+ @Mock
+ Emailer emailer;
+
+ @Before
+ public void setUp() throws Exception {
+
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(DMaaPAuthenticatorImpl.class);
+ NsaSimpleApiKey user = new NsaSimpleApiKey("admin", "password");
+
+ PowerMockito.when(dmaapContext.getConfigReader()).thenReturn(configReader);
+ PowerMockito.when(configReader.getfConsumerFactory()).thenReturn(factory);
+ PowerMockito.when(configReader.getfIpBlackList()).thenReturn(Blacklist);
+
+ PowerMockito.when(configReader.getfApiKeyDb()).thenReturn(fApiKeyDb);
+ PowerMockito.when(configReader.getSystemEmailer()).thenReturn(emailer);
+ PowerMockito.when(DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext)).thenReturn(user);
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+ @Test
+ public void testGetAllApiKeys() {
+
+ service = new ApiKeysServiceImpl();
+ try {
+ service.getAllApiKeys(dmaapContext);
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetApiKey() {
+
+ ApiKeysServiceImpl service = new ApiKeysServiceImpl();
+ try {
+ service.getApiKey(dmaapContext, "testkey");
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetApiKey_error() {
+
+ ApiKeysServiceImpl service = new ApiKeysServiceImpl();
+ try {
+ service.getApiKey(dmaapContext, "k35Hdw6Sde");
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testCreateApiKey() {
+
+ ApiKeysServiceImpl service = new ApiKeysServiceImpl();
+ try {
+ service.createApiKey(dmaapContext, new ApiKeyBean("test@onap.com", "testing apikey bean"));
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (KeyExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch(NoClassDefFoundError e) {
+
+ }
+ assertTrue(true);
+ }
+
+ @Test
+ public void testUpdateApiKey() {
+
+ ApiKeysServiceImpl service = new ApiKeysServiceImpl();
+ try {
+
+ service.updateApiKey(dmaapContext, "admin", new ApiKeyBean("test@onapt.com", "testing apikey bean"));
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+ @Test
+ public void testUpdateApiKey_error() {
+
+ ApiKeysServiceImpl service = new ApiKeysServiceImpl();
+ try {
+
+ service.updateApiKey(dmaapContext, null, new ApiKeyBean("test@onapt.com", "testing apikey bean"));
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testDeleteApiKey() {
+
+ ApiKeysServiceImpl service = new ApiKeysServiceImpl();
+ try {
+
+ service.deleteApiKey(dmaapContext, null);
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testDeleteApiKey_error() {
+
+ ApiKeysServiceImpl service = new ApiKeysServiceImpl();
+ try {
+
+ service.deleteApiKey(dmaapContext, "admin");
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ NsaApiDb<NsaSimpleApiKey> fApiKeyDb= new NsaApiDb<NsaSimpleApiKey>() {
+
+
+ Set<String> keys = new HashSet<>(Arrays.asList("testkey","admin"));
+
+
+ @Override
+ public NsaSimpleApiKey createApiKey(String arg0, String arg1)
+ throws KeyExistsException, ConfigDbException {
+ // TODO Auto-generated method stub
+ return new NsaSimpleApiKey(arg0, arg1);
+ }
+
+ @Override
+ public boolean deleteApiKey(NsaSimpleApiKey arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean deleteApiKey(String arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Map<String, NsaSimpleApiKey> loadAllKeyRecords() throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<String> loadAllKeys() throws ConfigDbException {
+ // TODO Auto-generated method stub
+
+ return keys ;
+ }
+
+ @Override
+ public NsaSimpleApiKey loadApiKey(String arg0) throws ConfigDbException {
+ if(!keys.contains(arg0)){
+ return null;
+ }
+ return new NsaSimpleApiKey(arg0, "password");
+ }
+
+ @Override
+ public void saveApiKey(NsaSimpleApiKey arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+
+ }
+ };
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/service/impl/BaseTransactionDbImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/BaseTransactionDbImplTest.java
new file mode 100644
index 0000000..81a5cf7
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/BaseTransactionDbImplTest.java
@@ -0,0 +1,147 @@
+/*-
+ * ============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.cambria.service.impl;
+
+import com.att.nsa.configs.ConfigDbException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.service.impl.BaseTransactionDbImpl;
+import org.onap.dmaap.dmf.mr.transaction.DMaaPTransactionObjDB.KeyExistsException;
+
+import static org.junit.Assert.assertTrue;
+
+public class BaseTransactionDbImplTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testCreateTransactionObj() {
+
+
+ try {
+
+ BaseTransactionDbImpl service = new BaseTransactionDbImpl(null, null);
+ service.createTransactionObj("transition");
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (KeyExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testSaveTransactionObj() {
+
+
+ try {
+
+ BaseTransactionDbImpl service = new BaseTransactionDbImpl(null, null);
+ service.saveTransactionObj(null);
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testLoadTransactionObj() {
+
+ try {
+
+ BaseTransactionDbImpl service = new BaseTransactionDbImpl(null, null);
+ service.loadTransactionObj("34");
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+ @Test
+ public void testLoadAllTransactionObjs() {
+
+ try {
+
+ BaseTransactionDbImpl service = new BaseTransactionDbImpl(null, null);
+ service.loadAllTransactionObjs();
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/service/impl/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/JUnitTestSuite.java
new file mode 100644
index 0000000..5ba8ec2
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/JUnitTestSuite.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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.cambria.service.impl;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+import org.onap.dmaap.dmf.mr.service.impl.EventsServiceImplTest;
+import org.onap.dmaap.dmf.mr.service.impl.TopicServiceImplTest;
+
+@RunWith(Suite.class)
+@SuiteClasses({UIServiceImplTest.class, AdminServiceImplemTest.class, ApiKeysServiceImplTest.class,
+ ShowConsumerCacheTest.class, TopicServiceImplTest.class, TransactionServiceImplTest.class,
+ MMServiceImplTest.class,
+ BaseTransactionDbImplTest.class, MetricsServiceImplTest.class, EventsServiceImplTest.class})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/service/impl/MMServiceImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/MMServiceImplTest.java
new file mode 100644
index 0000000..0f3015f
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/MMServiceImplTest.java
@@ -0,0 +1,382 @@
+/*-
+ * ============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.cambria.service.impl;
+
+import static org.junit.Assert.assertTrue;
+
+import com.att.ajsc.beans.PropertiesMapBean;
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;
+import com.att.nsa.limits.Blacklist;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import com.att.nsa.security.db.NsaApiDb;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.ConcurrentModificationException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.backends.ConsumerFactory;
+import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
+import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
+import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticatorImpl;
+import org.onap.dmaap.dmf.mr.service.impl.MMServiceImpl;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;
+import org.onap.dmaap.dmf.mr.utils.Emailer;
+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;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ DMaaPAuthenticatorImpl.class, DMaaPResponseBuilder.class, PropertiesMapBean.class,
+ AJSCPropertiesMap.class })
+public class MMServiceImplTest {
+
+ @InjectMocks
+ MMServiceImpl service;
+
+ @Mock
+ DMaaPContext dmaapContext;
+ @Mock
+ ConsumerFactory factory;
+ @Mock
+ private DMaaPErrorMessages errorMessages;
+ @Mock
+ ConfigurationReader configReader;
+ @Mock
+ Blacklist Blacklist;
+ @Mock
+ Emailer emailer;
+ @Mock
+ DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;
+ @Mock
+ Topic metatopic;
+
+ @Before
+ public void setUp() throws Exception {
+
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(DMaaPAuthenticatorImpl.class);
+ NsaSimpleApiKey user = new NsaSimpleApiKey("admin", "password");
+
+ PowerMockito.when(dmaapContext.getConfigReader()).thenReturn(configReader);
+ PowerMockito.when(configReader.getfConsumerFactory()).thenReturn(factory);
+ PowerMockito.when(configReader.getfIpBlackList()).thenReturn(Blacklist);
+
+ PowerMockito.when(configReader.getfApiKeyDb()).thenReturn(fApiKeyDb);
+ PowerMockito.when(configReader.getSystemEmailer()).thenReturn(emailer);
+ PowerMockito.when(DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext)).thenReturn(user);
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+
+ MockHttpServletRequest request = new MockHttpServletRequest();
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ PowerMockito.when(dmaapContext.getRequest()).thenReturn(request);
+ PowerMockito.when(dmaapContext.getResponse()).thenReturn(response);
+
+ PowerMockito.mockStatic(AJSCPropertiesMap.class);
+ PowerMockito.mockStatic(PropertiesMapBean.class);
+ PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "timeout")).thenReturn("1000");
+ PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "pretty")).thenReturn("true");
+ PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "meta")).thenReturn("true");
+ PowerMockito.when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSubscribe_Blacklistip() {
+
+ try {
+ PowerMockito.when(Blacklist.contains("127.0.0.1")).thenReturn(true);
+ service.subscribe(dmaapContext, "testTopic", "CG1", "23");
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (UnavailableException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testSubscribe_NullTopic() {
+
+ try {
+ PowerMockito.when(dmaapKafkaMetaBroker.getTopic(Matchers.anyString())).thenReturn(null);
+ service.subscribe(dmaapContext, "testTopic", "CG1", "23");
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (UnavailableException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testSubscribe_NullTopic_Error() throws ConfigDbException, TopicExistsException, AccessDeniedException, UnavailableException,
+ CambriaApiException, IOException {
+
+ PowerMockito.when(configReader.getfMetrics()).thenThrow(new ConcurrentModificationException("Error occurred"));
+ PowerMockito.when(dmaapKafkaMetaBroker.getTopic(Matchers.anyString())).thenReturn(metatopic);
+ service.subscribe(dmaapContext, "testTopic", "CG1", "23");
+ }
+
+ @Test
+ public void testPushEvents_wttransaction() {
+
+ String source = "source of my InputStream";
+
+ try {
+ InputStream iStream = new ByteArrayInputStream(source.getBytes("UTF-8"));
+ service.pushEvents(dmaapContext, "msgrtr.apinode.metrics.dmaap", iStream, "3", "12:00:00");
+
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (missingReqdSetting e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test(expected = CambriaApiException.class)
+ public void testPushEvents_wttransaction_error() throws Exception {
+
+ String source = "source of my InputStream";
+
+ InputStream iStream = new ByteArrayInputStream(source.getBytes("UTF-8"));
+ PowerMockito.mockStatic(AJSCPropertiesMap.class);
+ PowerMockito.mockStatic(PropertiesMapBean.class);
+ PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "event.batch.length")).thenReturn("-5");
+ PowerMockito.when(configReader.getfPublisher()).thenThrow(new ConcurrentModificationException("Error occurred"));
+ service.pushEvents(dmaapContext, "msgrtr.apinode.metrics.dmaap1", iStream, "3", "12:00:00");
+
+ }
+
+ @Test
+ public void testPushEvents() {
+
+ String source = "source of my InputStream";
+
+ try {
+ InputStream iStream = new ByteArrayInputStream(source.getBytes("UTF-8"));
+ service.pushEvents(dmaapContext, "testTopic", iStream, "3", "12:00:00");
+
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (missingReqdSetting e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testPushEvents_blacklistip() {
+
+ String source = "source of my InputStream";
+
+ try {
+ PowerMockito.when(Blacklist.contains("127.0.0.1")).thenReturn(true);
+ InputStream iStream = new ByteArrayInputStream(source.getBytes("UTF-8"));
+ service.pushEvents(dmaapContext, "testTopic", iStream, "3", "12:00:00");
+
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ } catch (CambriaApiException e) {
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (missingReqdSetting e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ NsaApiDb<NsaSimpleApiKey> fApiKeyDb = new NsaApiDb<NsaSimpleApiKey>() {
+
+ Set<String> keys = new HashSet<>(Arrays.asList("testkey", "admin"));
+
+ @Override
+ public NsaSimpleApiKey createApiKey(String arg0, String arg1)
+ throws KeyExistsException, ConfigDbException {
+ // TODO Auto-generated method stub
+ return new NsaSimpleApiKey(arg0, arg1);
+ }
+
+ @Override
+ public boolean deleteApiKey(NsaSimpleApiKey arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean deleteApiKey(String arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Map<String, NsaSimpleApiKey> loadAllKeyRecords() throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<String> loadAllKeys() throws ConfigDbException {
+ // TODO Auto-generated method stub
+
+ return keys;
+ }
+
+ @Override
+ public NsaSimpleApiKey loadApiKey(String arg0) throws ConfigDbException {
+ if (!keys.contains(arg0)) {
+ return null;
+ }
+ return new NsaSimpleApiKey(arg0, "password");
+ }
+
+ @Override
+ public void saveApiKey(NsaSimpleApiKey arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/service/impl/MessageTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/MessageTest.java
new file mode 100644
index 0000000..e946b66
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/MessageTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============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.cambria.service.impl;
+
+import org.onap.dmaap.dmf.mr.backends.Publisher.message;
+import org.onap.dmaap.dmf.mr.beans.LogDetails;
+
+public class MessageTest implements message {
+
+ @Override
+ public String getKey() {
+ // TODO Auto-generated method stub
+ return "123";
+ }
+
+ @Override
+ public String getMessage() {
+ // TODO Auto-generated method stub
+ return "Msg";
+ }
+
+ @Override
+ public void setLogDetails(LogDetails logDetails) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public LogDetails getLogDetails() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isTransactionEnabled() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setTransactionEnabled(boolean transactionEnabled) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/service/impl/MetricsServiceImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/MetricsServiceImplTest.java
new file mode 100644
index 0000000..51ee4d4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/MetricsServiceImplTest.java
@@ -0,0 +1,95 @@
+/*-
+ * ============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.cambria.service.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.CambriaApiException;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.service.impl.MetricsServiceImpl;
+
+public class MetricsServiceImplTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGet() {
+
+ MetricsServiceImpl service = new MetricsServiceImpl();
+ try {
+ service.get(new DMaaPContext());
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+ @Test
+ public void testGetMetricByName() {
+
+ MetricsServiceImpl service = new MetricsServiceImpl();
+ try {
+ service.getMetricByName(new DMaaPContext(), "uptime");
+ } catch (org.json.JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ assertTrue(true);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/service/impl/ShowConsumerCacheTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/ShowConsumerCacheTest.java
new file mode 100644
index 0000000..36500d6
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/ShowConsumerCacheTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.cambria.service.impl;
+
+//@RunWith(MockitoJUnitRunner.class)
+//@RunWith(PowerMockRunner.class)
+//@PrepareForTest(PropertiesMapBean.class)
+public class ShowConsumerCacheTest {
+/*
+@InjectMocks
+TopicServiceImpl topicService;
+
+@Mock
+private DMaaPErrorMessages errorMessages;
+
+@Mock
+DMaaPContext dmaapContext;
+
+@Mock
+ConfigurationReader configReader;
+
+
+@Mock
+JSONObject consumers;
+
+@Mock
+JSONObject consumerObject;
+
+@Mock
+JSONArray jsonConsumersList;
+
+@Mock
+DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
+
+@Mock
+NsaApiKey user;
+
+@Mock
+NsaSimpleApiKey nsaSimpleApiKey;
+
+@Mock
+HttpServletRequest httpServReq;
+
+
+@Before
+public void setUp(){
+MockitoAnnotations.initMocks(this);
+}
+
+
+//@Test(expected = DMaaPAccessDeniedException.class)
+@Test
+public void testShowConsmerCache()throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException, JSONException{
+Assert.assertNotNull(topicService);
+
+String myName = "Brian";
+Object created = null;
+Object accessed = null;
+Object log = null;
+Object info = null;
+
+when(consumerObject.put("name", myName)).thenReturn(consumerObject);
+when(consumerObject.put("created", created)).thenReturn(consumerObject);
+when(consumerObject.put("accessed", accessed)).thenReturn(consumerObject);
+when(consumerObject.put("accessed", Consumer.class)).thenReturn(consumerObject);
+when(jsonConsumersList.put(consumerObject)).thenReturn(null);
+
+when(consumers.put("consumers", jsonConsumersList)).thenReturn(consumerObject);
+
+
+
+}*/
+
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/service/impl/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/TestRunner.java
new file mode 100644
index 0000000..5e296b7
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/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.cambria.service.impl;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/service/impl/TransactionServiceImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/TransactionServiceImplTest.java
new file mode 100644
index 0000000..880fbe9
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/TransactionServiceImplTest.java
@@ -0,0 +1,95 @@
+/*-
+ * ============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.cambria.service.impl;
+
+import com.att.aft.dme2.internal.jettison.json.JSONException;
+import com.att.nsa.configs.ConfigDbException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.service.impl.TransactionServiceImpl;
+import org.onap.dmaap.dmf.mr.transaction.TransactionObj;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+
+public class TransactionServiceImplTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testCheckTransaction() {
+
+ TransactionServiceImpl service = new TransactionServiceImpl();
+ service.checkTransaction(new TransactionObj("23", 1100, 1000, 10));
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGetAllTransactionObjs() {
+
+ TransactionServiceImpl service = new TransactionServiceImpl();
+ try {
+ service.getAllTransactionObjs(new DMaaPContext());
+ } catch (ConfigDbException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGetTransactionObj() {
+
+ TransactionServiceImpl service = new TransactionServiceImpl();
+ try {
+ service.getTransactionObj(new DMaaPContext(), "23");
+ } catch (ConfigDbException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/service/impl/UIServiceImplTest.java b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/UIServiceImplTest.java
new file mode 100644
index 0000000..6981153
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/service/impl/UIServiceImplTest.java
@@ -0,0 +1,297 @@
+/*-
+ * ============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.cambria.service.impl;
+
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.db.NsaApiDb;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+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.onap.dmaap.dmf.mr.backends.ConsumerFactory;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
+import org.onap.dmaap.dmf.mr.metabroker.Topic;
+import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticatorImpl;
+import org.onap.dmaap.dmf.mr.service.impl.UIServiceImpl;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;
+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;
+
+import java.io.IOException;
+import java.util.*;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ DMaaPAuthenticatorImpl.class, DMaaPResponseBuilder.class })
+public class UIServiceImplTest {
+
+ @InjectMocks
+ UIServiceImpl service;
+
+ @Mock
+ DMaaPContext dmaapContext;
+ @Mock
+ ConsumerFactory factory;
+
+ @Mock
+ ConfigurationReader configReader;
+
+ @Mock
+ DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;
+
+ @Mock
+ Topic metatopic;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(DMaaPAuthenticatorImpl.class);
+ NsaSimpleApiKey user = new NsaSimpleApiKey("admin", "password");
+
+ PowerMockito.when(dmaapContext.getConfigReader()).thenReturn(configReader);
+ PowerMockito.when(configReader.getfConsumerFactory()).thenReturn(factory);
+
+ PowerMockito.when(configReader.getfApiKeyDb()).thenReturn(fApiKeyDb);
+ PowerMockito.when(DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext)).thenReturn(user);
+ PowerMockito.mockStatic(DMaaPResponseBuilder.class);
+ PowerMockito.when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testHello() {
+
+ try {
+ service.hello(dmaapContext);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+ @Test
+ public void testGetApiKeysTable() {
+
+ try {
+ service.getApiKeysTable(dmaapContext);
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetApiKey() {
+
+ try {
+ service.getApiKey(dmaapContext, "admin");
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testGetApiKey_invalidkey() {
+
+ try {
+ service.getApiKey(dmaapContext, "k56HmWT72J");
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ assertTrue(true);
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testGetTopicsTable() {
+
+ try {
+ List<Topic> topics = new ArrayList<Topic>();
+ topics.add(metatopic);
+ when(dmaapKafkaMetaBroker.getAllTopics()).thenReturn(topics);
+ service.getTopicsTable(dmaapContext);
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetTopic() {
+
+ try {
+ when(dmaapKafkaMetaBroker.getTopic("testTopic")).thenReturn(metatopic);
+ service.getTopic(dmaapContext, "testTopic");
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+ }
+
+ @Test
+ public void testGetTopic_nulltopic() {
+
+ try {
+ when(dmaapKafkaMetaBroker.getTopic("topicNamespace.topic")).thenReturn(null);
+ service.getTopic(dmaapContext, "testTopic");
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ }
+
+ NsaApiDb<NsaSimpleApiKey> fApiKeyDb = new NsaApiDb<NsaSimpleApiKey>() {
+
+ Set<String> keys = new HashSet<>(Arrays.asList("testkey", "admin"));
+
+ @Override
+ public NsaSimpleApiKey createApiKey(String arg0, String arg1)
+ throws KeyExistsException, ConfigDbException {
+ // TODO Auto-generated method stub
+ return new NsaSimpleApiKey(arg0, arg1);
+ }
+
+ @Override
+ public boolean deleteApiKey(NsaSimpleApiKey arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean deleteApiKey(String arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Map<String, NsaSimpleApiKey> loadAllKeyRecords() throws ConfigDbException {
+ Map<String, NsaSimpleApiKey> map = new HashMap<String, NsaSimpleApiKey>();
+ map.put("testkey", new NsaSimpleApiKey("testkey", "password"));
+ map.put("admin", new NsaSimpleApiKey("admin", "password"));
+
+ return map;
+ }
+
+ @Override
+ public Set<String> loadAllKeys() throws ConfigDbException {
+ // TODO Auto-generated method stub
+
+ return keys;
+ }
+
+ @Override
+ public NsaSimpleApiKey loadApiKey(String arg0) throws ConfigDbException {
+ if (!keys.contains(arg0)) {
+ return null;
+ }
+ return new NsaSimpleApiKey(arg0, "password");
+ }
+
+ @Override
+ public void saveApiKey(NsaSimpleApiKey arg0) throws ConfigDbException {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/transaction/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/transaction/JUnitTestSuite.java
new file mode 100644
index 0000000..1fad8f3
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/transaction/JUnitTestSuite.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.cambria.transaction;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({TransactionObjTest.class, TrnRequestTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/transaction/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/transaction/TestRunner.java
new file mode 100644
index 0000000..7fc990e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/transaction/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.cambria.transaction;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/transaction/TransactionObjTest.java b/src/test/java/org/onap/dmaap/mr/cambria/transaction/TransactionObjTest.java
new file mode 100644
index 0000000..36cdf92
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/transaction/TransactionObjTest.java
@@ -0,0 +1,175 @@
+/*-
+ * ============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.cambria.transaction;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.dmaap.dmf.mr.transaction.TransactionObj;
+
+public class TransactionObjTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testAsJsonObject() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+
+ try {
+ obj.asJsonObject();
+
+ } catch(NullPointerException e) {
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testGetId() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.getId();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetId() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.setId("23");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetCreateTime() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.getCreateTime();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetCreateTime() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.setCreateTime("12:00:00");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSerialize() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.serialize();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetTotalMessageCount() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.getTotalMessageCount();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetTotalMessageCount() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.setTotalMessageCount(200);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetSuccessMessageCount() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.getSuccessMessageCount();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetSuccessMessageCount() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.setSuccessMessageCount(198);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetFailureMessageCount() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.getFailureMessageCount();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetFailureMessageCount() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.setFailureMessageCount(2);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetfData() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.getfData();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetfData() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.setfData(null);
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetTrnRequest() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.getTrnRequest();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetTrnRequest() {
+ TransactionObj obj = new TransactionObj("23", 100, 98, 2);
+ obj.setTrnRequest(null);
+ assertTrue(true);
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/transaction/TrnRequestTest.java b/src/test/java/org/onap/dmaap/mr/cambria/transaction/TrnRequestTest.java
new file mode 100644
index 0000000..f174a32
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/transaction/TrnRequestTest.java
@@ -0,0 +1,185 @@
+/*-
+ * ============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.cambria.transaction;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.transaction.TrnRequest;
+
+import static org.junit.Assert.assertTrue;
+
+public class TrnRequestTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetId() {
+ TrnRequest req = new TrnRequest();
+
+ req.getId();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetId() {
+ TrnRequest req = new TrnRequest();
+
+ req.setId("23");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetRequestCreate() {
+ TrnRequest req = new TrnRequest();
+
+ req.getRequestCreate();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetRequestCreate() {
+ TrnRequest req = new TrnRequest();
+
+ req.setRequestCreate("createRequest");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetRequestHost() {
+ TrnRequest req = new TrnRequest();
+
+ req.getRequestHost();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetRequestHost() {
+ TrnRequest req = new TrnRequest();
+
+ req.setRequestHost("requestHost");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetServerHost() {
+ TrnRequest req = new TrnRequest();
+
+ req.getServerHost();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetServerHost() {
+ TrnRequest req = new TrnRequest();
+
+ req.setServerHost("requestHost");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetMessageProceed() {
+ TrnRequest req = new TrnRequest();
+
+ req.getMessageProceed();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetMessageProceed() {
+ TrnRequest req = new TrnRequest();
+
+ req.setMessageProceed("messageProceed");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetTotalMessage() {
+ TrnRequest req = new TrnRequest();
+
+ req.getTotalMessage();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetTotalMessage() {
+ TrnRequest req = new TrnRequest();
+
+ req.setTotalMessage("200");
+ assertTrue(true);
+
+ }
+
+
+ @Test
+ public void testGetClientType() {
+ TrnRequest req = new TrnRequest();
+
+ req.getClientType();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetClientType() {
+ TrnRequest req = new TrnRequest();
+
+ req.setClientType("admin");
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetUrl() {
+ TrnRequest req = new TrnRequest();
+
+ req.getUrl();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testSetUrl() {
+ TrnRequest req = new TrnRequest();
+
+ req.setUrl("http://google.com");
+ assertTrue(true);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/DMaaPSimpleTransactionFactoryTest.java b/src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/DMaaPSimpleTransactionFactoryTest.java
new file mode 100644
index 0000000..5fc2351
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/DMaaPSimpleTransactionFactoryTest.java
@@ -0,0 +1,66 @@
+/*-
+ * ============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.cambria.transaction.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.transaction.impl.DMaaPSimpleTransactionFactory;
+
+import static org.junit.Assert.assertTrue;
+
+public class DMaaPSimpleTransactionFactoryTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testMakeNewTransactionObj() {
+
+ DMaaPSimpleTransactionFactory factory = new DMaaPSimpleTransactionFactory();
+
+ factory.makeNewTransactionObj("{'transactionId': '123', 'totalMessageCount': '200', "
+ + "'successMessageCount': '200', 'failureMessageCount': '0'}");
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+
+ }
+
+ @Test
+ public void testMakeNewTransactionId() {
+
+ DMaaPSimpleTransactionFactory factory = new DMaaPSimpleTransactionFactory();
+ factory.makeNewTransactionId("123");
+
+ String trueValue = "True";
+ assertTrue(trueValue.equalsIgnoreCase("True"));
+
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/JUnitTestSuite.java
new file mode 100644
index 0000000..f173b57
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/JUnitTestSuite.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.cambria.transaction.impl;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DMaaPSimpleTransactionFactoryTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/cambria/transaction/impl/TestRunner.java b/src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/TestRunner.java
new file mode 100644
index 0000000..212f551
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/transaction/impl/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.cambria.transaction.impl;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/cambria/utils/ConfigurationReaderTest.java b/src/test/java/org/onap/dmaap/mr/cambria/utils/ConfigurationReaderTest.java
new file mode 100644
index 0000000..ae8d167
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/utils/ConfigurationReaderTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.cambria.utils;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.After;
+import org.junit.Test;
+
+import org.onap.dmaap.mr.cambria.embed.EmbedConfigurationReader;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
+
+public class ConfigurationReaderTest {
+
+ EmbedConfigurationReader embedConfigurationReader = new EmbedConfigurationReader();
+
+ @After
+ public void tearDown() throws Exception {
+ embedConfigurationReader.tearDown();
+ }
+
+ @Test
+ public void testConfigurationReader() throws Exception {
+
+ ConfigurationReader configurationReader = embedConfigurationReader.buildConfigurationReader();
+
+ assertNotNull(configurationReader);
+ assertNotNull(configurationReader.getfApiKeyDb());
+ assertNotNull(configurationReader.getfConfigDb());
+ assertNotNull(configurationReader.getfConsumerFactory());
+ assertNotNull(configurationReader.getfIpBlackList());
+ assertNotNull(configurationReader.getfMetaBroker());
+ assertNotNull(configurationReader.getfMetrics());
+ assertNotNull(configurationReader.getfPublisher());
+ assertNotNull(configurationReader.getfSecurityManager());
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/utils/DMaaPCuratorFactoryTest.java b/src/test/java/org/onap/dmaap/mr/cambria/utils/DMaaPCuratorFactoryTest.java
new file mode 100644
index 0000000..fdcb434
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/utils/DMaaPCuratorFactoryTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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.cambria.utils;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.att.ajsc.filemonitor.AJSCPropertiesMap;
+import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
+import org.onap.dmaap.dmf.mr.utils.DMaaPCuratorFactory;
+import org.onap.dmaap.dmf.mr.utils.PropertyReader;
+import com.att.nsa.drumlin.till.nv.rrNvReadable.loadException;
+
+public class DMaaPCuratorFactoryTest {
+
+ @Before
+ public void setUp() throws Exception {
+ ClassLoader classLoader = getClass().getClassLoader();
+ AJSCPropertiesMap.refresh(new File(classLoader.getResource(CambriaConstants.msgRtr_prop).getFile()));
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testgetCurator() throws loadException {
+ CuratorFramework curatorFramework = DMaaPCuratorFactory.getCurator(new PropertyReader());
+ assertNotNull(curatorFramework);
+
+ Map<String, String> map = AJSCPropertiesMap.getProperties(CambriaConstants.msgRtr_prop);
+ map.remove(CambriaConstants.kSetting_ZkConfigDbServers);
+ map.remove(CambriaConstants.kSetting_ZkSessionTimeoutMs);
+
+
+
+ curatorFramework = DMaaPCuratorFactory.getCurator(new PropertyReader());
+ assertNotNull(curatorFramework);
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/utils/DMaaPResponseBuilderTest.java b/src/test/java/org/onap/dmaap/mr/cambria/utils/DMaaPResponseBuilderTest.java
new file mode 100644
index 0000000..326e399
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/utils/DMaaPResponseBuilderTest.java
@@ -0,0 +1,178 @@
+/*-
+ * ============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.cambria.utils;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class DMaaPResponseBuilderTest {
+
+ DMaaPContext dMaapContext;
+ MockHttpServletRequest request;
+ MockHttpServletResponse response;
+
+ @Before
+ public void setUp() throws Exception {
+
+ dMaapContext = new DMaaPContext();
+ request = new MockHttpServletRequest();
+ response = new MockHttpServletResponse();
+ dMaapContext.setRequest(request);
+ dMaapContext.setResponse(response);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testsetNoCacheHeadings(){
+ DMaaPResponseBuilder.setNoCacheHeadings(dMaapContext);
+ assertEquals("no-cache", response.getHeader("Pragma"));
+ }
+
+ @Test
+ public void testrespondOk() throws JSONException, IOException{
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("Name", "Test");
+
+ DMaaPResponseBuilder.respondOk(dMaapContext, jsonObject);
+ assertEquals("application/json", response.getContentType());
+ assertEquals(200, response.getStatus());
+
+ request.setMethod("HEAD");
+
+ DMaaPResponseBuilder.respondOk(dMaapContext, jsonObject);
+ assertEquals("application/json", response.getContentType());
+ assertEquals(200, response.getStatus());
+ }
+
+ @Test
+ public void testrespondOkNoContent(){
+ DMaaPResponseBuilder.respondOkNoContent(dMaapContext);
+ assertEquals(204, response.getStatus());
+ }
+
+ @Test
+ public void testrespondOkNoContentError(){
+ dMaapContext.setResponse(null);
+ DMaaPResponseBuilder.respondOkNoContent(dMaapContext);
+ assertNull(dMaapContext.getResponse());
+ }
+
+ @Test
+ public void testrespondOkWithHtml(){
+ DMaaPResponseBuilder.respondOkWithHtml(dMaapContext, "<head></head>");
+
+ assertEquals("text/html", response.getContentType());
+ DMaaPResponseBuilder.respondOkWithHtml(dMaapContext, "<head></head>");
+ assertEquals(200, response.getStatus());
+ }
+
+ @Test
+ public void testrespondOkWithHtmlError(){
+ dMaapContext.setResponse(null);
+ DMaaPResponseBuilder.respondOkWithHtml(dMaapContext, "<head></head>");
+ assertNull(dMaapContext.getResponse());
+ }
+
+ @Test
+ public void testrespondWithError(){
+ DMaaPResponseBuilder.respondWithError(dMaapContext, 500, "InternalServerError");
+ assertEquals(500, response.getStatus());
+ }
+
+ @Test(expected=NullPointerException.class)
+ public void testInvalidrespondWithError(){
+ dMaapContext.setResponse(null);
+ DMaaPResponseBuilder.respondWithError(dMaapContext, 500, "InternalServerError");
+ }
+
+ @Test
+ public void testrespondWithJsonError(){
+ JSONObject o = new JSONObject();
+ o.put("status", 500);
+ o.put("message", "InternalServerError");
+ DMaaPResponseBuilder.respondWithError(dMaapContext, 500, o);
+ assertEquals(500, response.getStatus());
+ }
+
+ @Test
+ public void testInvalidrespondWithJsonError(){
+ JSONObject o = new JSONObject();
+ o.put("status", 500);
+ o.put("message", "InternalServerError");
+ dMaapContext.setResponse(null);
+ DMaaPResponseBuilder.respondWithError(dMaapContext, 500, o);
+ assertNull(dMaapContext.getResponse());
+ }
+
+ @Test
+ public void testrespondWithErrorInJson(){
+ DMaaPResponseBuilder.respondWithErrorInJson(dMaapContext, 500, "InternalServerError");
+
+ assertEquals("application/json", response.getContentType());
+ assertEquals(500, response.getStatus());
+ }
+
+ @Test
+ public void testsendErrorAndBody(){
+ DMaaPResponseBuilder.sendErrorAndBody(dMaapContext, 500, "InternalServerError", "text/html");
+
+ assertEquals("text/html", response.getContentType());
+ assertEquals(500, response.getStatus());
+
+ request.setMethod("HEAD");
+
+ DMaaPResponseBuilder.sendErrorAndBody(dMaapContext, 500, "InternalServerError", "text/html");
+
+ assertEquals("text/html", response.getContentType());
+ assertEquals(500, response.getStatus());
+
+ }
+
+ @Test
+ public void testgetStreamForBinaryResponse() throws IOException{
+ DMaaPResponseBuilder.getStreamForBinaryResponse(dMaapContext);
+
+ assertEquals("application/octet-stream", response.getContentType());
+ assertEquals(200, response.getStatus());
+ }
+
+ @Test(expected=NullPointerException.class)
+ public void testgetStreamForBinaryResponseError() throws IOException{
+ dMaapContext.setResponse(null);
+ DMaaPResponseBuilder.getStreamForBinaryResponse(dMaapContext);
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/utils/EMailerTest.java b/src/test/java/org/onap/dmaap/mr/cambria/utils/EMailerTest.java
new file mode 100644
index 0000000..45824a1
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/utils/EMailerTest.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.cambria.utils;
+
+import org.junit.Test;
+import org.onap.dmaap.dmf.mr.utils.Emailer;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+
+public class EMailerTest {
+
+ @Test
+ public void testEmailer(){
+
+ Emailer emailer= new Emailer();
+ try {
+ emailer.send("dummy@dummy.com", "subj", "body");
+ } catch (IOException e) {
+ assertTrue(true);
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/cambria/utils/UtilsTest.java b/src/test/java/org/onap/dmaap/mr/cambria/utils/UtilsTest.java
new file mode 100644
index 0000000..8a4009b
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/cambria/utils/UtilsTest.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+/*-
+ * ============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.cambria.utils;
+
+import static org.junit.Assert.*;
+
+import java.security.Principal;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+
+import org.apache.http.auth.BasicUserPrincipal;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.utils.Utils;
+
+public class UtilsTest {
+
+ private static final String DATE_FORMAT = "dd-MM-yyyy::hh:mm:ss:SSS";
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetFormattedDate() {
+ Date now = new Date();
+ String dateStr = Utils.getFormattedDate(now);
+ SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
+ String expectedStr = sdf.format(now);
+ assertNotNull(dateStr);
+ assertTrue("Formatted date does not match - expected [" + expectedStr
+ + "] received [" + dateStr + "]",
+ dateStr.equalsIgnoreCase(expectedStr));
+ }
+
+ @Test
+ public void testgetUserApiKey(){
+ MockHttpServletRequest request = new MockHttpServletRequest();
+ request.addHeader(Utils.CAMBRIA_AUTH_HEADER, "User:Password");
+ assertEquals("User", Utils.getUserApiKey(request));
+
+ MockHttpServletRequest request2 = new MockHttpServletRequest();
+ Principal principal = new BasicUserPrincipal("User@Test");
+ request2.setUserPrincipal(principal);
+ request2.addHeader("Authorization", "test");
+ assertEquals("User", Utils.getUserApiKey(request2));
+
+ MockHttpServletRequest request3 = new MockHttpServletRequest();
+ assertNull(Utils.getUserApiKey(request3));
+ }
+
+ @Test
+ public void testgetFromattedBatchSequenceId(){
+ Long x = new Long(1234);
+ String str = Utils.getFromattedBatchSequenceId(x);
+ assertEquals("001234", str);
+ }
+
+ @Test
+ public void testmessageLengthInBytes(){
+ String str = "TestString";
+ long length = Utils.messageLengthInBytes(str);
+ assertEquals(10, length);
+ assertEquals(0, Utils.messageLengthInBytes(null));
+ }
+
+ @Test
+ public void testgetResponseTransactionId(){
+ String transactionId = "test123::sampleResponseMessage";
+ assertEquals("test123",Utils.getResponseTransactionId(transactionId));
+ assertNull(Utils.getResponseTransactionId(null));
+ assertNull(Utils.getResponseTransactionId(""));
+ }
+
+ @Test
+ public void testgetSleepMsForRate(){
+ long x = Utils.getSleepMsForRate(1024.124);
+ assertEquals(1000, x);
+ assertEquals(0, Utils.getSleepMsForRate(-1));
+ }
+
+ @Test
+ public void testgetRemoteAddress(){
+ DMaaPContext dMaapContext = new DMaaPContext();
+ MockHttpServletRequest request = new MockHttpServletRequest();
+
+ dMaapContext.setRequest(request);
+
+ assertEquals(request.getRemoteAddr(), Utils.getRemoteAddress(dMaapContext));
+
+ request.addHeader("X-Forwarded-For", "XForward");
+ assertEquals("XForward", Utils.getRemoteAddress(dMaapContext));
+
+
+ }
+
+ @Test
+ public void testGetKey(){
+ assertNotNull(Utils.getKafkaproperty());
+
+ }
+
+ @Test
+ public void testCadiEnable(){
+ assertFalse(Utils.isCadiEnabled());
+
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/filter/ContentLengthFilterTest.java b/src/test/java/org/onap/dmaap/mr/filter/ContentLengthFilterTest.java
new file mode 100644
index 0000000..b1dacda
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/filter/ContentLengthFilterTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============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.filter;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ContentLengthFilterTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testDestroy() {
+ ContentLengthFilter filter = new ContentLengthFilter();
+
+ filter.destroy();
+
+ assertTrue(true);
+ }
+
+
+ @Test
+ public void testFilter() {
+ ContentLengthFilter filter = new ContentLengthFilter();
+
+ try {
+ filter.doFilter(null, null, null);
+ } catch (IOException | ServletException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+
+ }
+
+ @Test
+ public void testInit() {
+ ContentLengthFilter filter = new ContentLengthFilter();
+
+ try {
+ filter.init(null);
+ } catch (ServletException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // TODO Auto-generated catch block
+ assertTrue(true);
+ }
+
+ }
+
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/filter/DefaultLengthTest.java b/src/test/java/org/onap/dmaap/mr/filter/DefaultLengthTest.java
new file mode 100644
index 0000000..f634807
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/filter/DefaultLengthTest.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.filter;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class DefaultLengthTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetDefaultLength() {
+ DefaultLength length = new DefaultLength();
+
+ length.getDefaultLength();
+
+ assertTrue(true);
+ }
+
+ @Test
+ public void testSetDefaultLength() {
+ DefaultLength length = new DefaultLength();
+
+ length.setDefaultLength("23");
+
+ assertTrue(true);
+ }
+
+
+
+
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/filter/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/filter/JUnitTestSuite.java
new file mode 100644
index 0000000..7aa0d28
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/filter/JUnitTestSuite.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.filter;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({ContentLengthFilterTest.class, DefaultLengthTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/filter/TestRunner.java b/src/test/java/org/onap/dmaap/mr/filter/TestRunner.java
new file mode 100644
index 0000000..d5b3972
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/filter/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.filter;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/dmaap/ApiKeyBean.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/ApiKeyBean.java
new file mode 100644
index 0000000..7ecc203
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/ApiKeyBean.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+import java.io.Serializable;
+
+public class ApiKeyBean implements Serializable {
+
+ /*private static final long serialVersionUID = -8219849086890567740L;
+
+ // private static final String KEY_CHARS =
+ // "ABCDEFGHJIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+
+ private String email;
+ private String description;
+
+ public ApiKeyBean() {
+ super();
+ }
+
+ public ApiKeyBean(String email, String description) {
+ super();
+ this.email = email;
+ this.description = description;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /*
+ * public String getKey() { return generateKey(16); }
+ *
+ * public String getSharedSecret() { return generateKey(24); }
+ *
+ * private static String generateKey ( int length ) { return
+ * uniqueStringGenerator.createKeyUsingAlphabet ( KEY_CHARS, length ); }
+ */
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dmaap/DMaapPubSubTest.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/DMaapPubSubTest.java
new file mode 100644
index 0000000..ca659f5
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/DMaapPubSubTest.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+public class DMaapPubSubTest {
+/* private static final Logger LOGGER = Logger.getLogger(DMaapTopicTest.class);
+ Client client = ClientBuilder.newClient();
+ String url = LoadPropertyFile.getPropertyFileData().getProperty("url");
+ WebTarget target = client.target(url);
+ String topicapikey;
+ String topicsecretKey;
+ String serverCalculatedSignature;
+ String date = LoadPropertyFile.getPropertyFileData().getProperty("date");
+ // changes by islam
+ String topic_name = LoadPropertyFile.getPropertyFileData().getProperty("topicName");
+ DmaapApiKeyTest keyInstance = new DmaapApiKeyTest();
+
+
+ public void testProduceMessage() {
+ LOGGER.info("test case publish message");
+ // DMaapTopicTest topicCreation = new DMaapTopicTest();
+ DmaapApiKeyTest keyInstance = new DmaapApiKeyTest();
+ // creating topic
+ createTopic(topic_name);
+
+ target = client.target(url);
+ target = target.path("/events/");
+ target = target.path(topic_name);
+ Response response2 = target.request().header("X-CambriaAuth", topicapikey + ":" + serverCalculatedSignature)
+ .header("X-CambriaDate", date).post(Entity.json("{message:producing first message}"));
+ keyInstance.assertStatus(response2);
+ LOGGER.info("successfully published message");
+ }
+
+ public void testConsumeMessage() {
+ LOGGER.info("test case subscribing message");
+ createTopic(topic_name);
+ target = client.target(url);
+ target = target.path("/events/");
+ target = target.path(topic_name);
+ target = target.path("consumGrp");
+ target = target.path(topicapikey);
+ Response response = target.request().get();
+ keyInstance.assertStatus(response);
+ LOGGER.info("successfully consumed messages");
+ InputStream is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ String data = s.next();
+ s.close();
+ LOGGER.info("Consumed Message data: " + data);
+ }
+
+ public void createTopic(String name) {
+ if (!topicExist(name)) {
+ TopicBean topicbean = new TopicBean();
+ topicbean.setDescription("creating topic");
+ topicbean.setPartitionCount(1);
+ topicbean.setReplicationCount(1);
+ topicbean.setTopicName(name);
+ topicbean.setTransactionEnabled(true);
+ target = client.target(url);
+ target = target.path("/topics/create");
+ JSONObject jsonObj = keyInstance.returnKey(new ApiKeyBean("ai039a@att.com", "topic creation"));
+ topicapikey = (String) jsonObj.get("key");
+ topicsecretKey = (String) jsonObj.get("secret");
+ serverCalculatedSignature = sha1HmacSigner.sign(date, topicsecretKey);
+ Response response = target.request().header("X-CambriaAuth", topicapikey + ":" + serverCalculatedSignature)
+ .header("X-CambriaDate", date).post(Entity.json(topicbean));
+ keyInstance.assertStatus(response);
+ }
+ }
+
+ public boolean topicExist(String topicName) {
+ target = target.path("/topics/" + topicName);
+ InputStream is, issecret;
+ Response response = target.request().get();
+ if (response.getStatus() == HttpStatus.SC_OK) {
+ is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ JSONObject dataObj = new JSONObject(s.next());
+ s.close();
+ // get owner of a topic
+ topicapikey = (String) dataObj.get("owner");
+ target = client.target(url);
+ target = target.path("/apiKeys/");
+ target = target.path(topicapikey);
+ Response response2 = target.request().get();
+ issecret = (InputStream) response2.getEntity();
+ Scanner st = new Scanner(issecret);
+ st.useDelimiter("\\A");
+ JSONObject dataObj1 = new JSONObject(st.next());
+ st.close();
+ // get secret key of this topic//
+ topicsecretKey = (String) dataObj1.get("secret");
+ serverCalculatedSignature = sha1HmacSigner.sign(date, topicsecretKey);
+ return true;
+ } else
+ return false;
+ }*/
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dmaap/DMaapTopicTest.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/DMaapTopicTest.java
new file mode 100644
index 0000000..23f9d5b
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/DMaapTopicTest.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+public class DMaapTopicTest {
+ /*private static final Logger LOGGER = Logger.getLogger(DMaapTopicTest.class);
+ Client client = ClientBuilder.newClient();
+ String topicapikey, topicsecretKey, serverCalculatedSignature;
+ Properties prop = LoadPropertyFile.getPropertyFileData();
+ String topicName = prop.getProperty("topicName");
+ String url = prop.getProperty("url");
+ String date = prop.getProperty("date");
+ WebTarget target = client.target(url);
+ DmaapApiKeyTest keyInstance = new DmaapApiKeyTest();
+
+
+
+ public boolean topicExist(String topicName) {
+ target = target.path("/topics/" + topicName);
+ InputStream is, issecret;
+ Response response = target.request().get();
+ if (response.getStatus() == HttpStatus.SC_OK) {
+ is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ JSONObject dataObj = new JSONObject(s.next());
+ s.close();
+ // get owner of a topic
+ topicapikey = (String) dataObj.get("owner");
+ target = client.target(url);
+ target = target.path("/apiKeys/");
+ target = target.path(topicapikey);
+ Response response2 = target.request().get();
+ issecret = (InputStream) response2.getEntity();
+ Scanner st = new Scanner(issecret);
+ st.useDelimiter("\\A");
+ JSONObject dataObj1 = new JSONObject(st.next());
+ st.close();
+ // get secret key of this topic//
+ topicsecretKey = (String) dataObj1.get("secret");
+ serverCalculatedSignature = sha1HmacSigner.sign(date, topicsecretKey);
+ return true;
+ } else
+ return false;
+ }
+
+ public void testCreateTopic() {
+ LOGGER.info("test case create topic");
+ createTopic(topicName);
+ LOGGER.info("Returning after create topic");
+ }
+
+ public void testOneTopic() {
+ LOGGER.info("test case get specific topic name " + topicName);
+ createTopic(topicName);
+ target = client.target(url);
+ target = target.path("/topics/");
+ target = target.path(topicName);
+ Response response = target.request().get();
+ LOGGER.info("Successfully returned after fetching topic" + topicName);
+ keyInstance.assertStatus(response);
+ InputStream is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ JSONObject dataObj = new JSONObject(s.next());
+ LOGGER.info("Details of " + topicName + " : " + dataObj.toString());
+ s.close();
+ }
+
+ public void testdeleteTopic() {
+ LOGGER.info("test case delete topic name " + topicName);
+ createTopic(topicName);
+ target = client.target(url);
+ target = target.path("/topics/");
+ target = target.path(topicName);
+ Response response = target.request().header("X-CambriaAuth", topicapikey + ":" + serverCalculatedSignature)
+ .header("X-CambriaDate", date).delete();
+ keyInstance.assertStatus(response);
+ LOGGER.info("Successfully returned after deleting topic" + topicName);
+ }
+
+ public void testAllTopic() {
+ LOGGER.info("test case fetch all topic");
+ target = client.target(url);
+ target = target.path("/topics");
+ Response response = target.request().get();
+ keyInstance.assertStatus(response);
+ LOGGER.info("successfully returned after fetching all the topic");
+ InputStream is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ JSONObject dataObj = new JSONObject(s.next());
+ s.close();
+ LOGGER.info("List of all topics " + dataObj.toString());
+ }
+
+ public void testPublisherForTopic() {
+ LOGGER.info("test case get all publishers for topic: " + topicName);
+ // creating topic to check
+ createTopic(topicName);
+ target = client.target(url);
+ target = target.path("/topics/");
+ target = target.path(topicName);
+ target = target.path("/producers");
+ // checking all producer for a particular topic
+ Response response = target.request().get();
+ keyInstance.assertStatus(response);
+ LOGGER.info("Successfully returned after getting all the publishers" + topicName);
+ }
+
+
+ public void testConsumerForTopic() {
+ LOGGER.info("test case get all consumers for topic: " + topicName);
+ // creating topic to check
+ createTopic(topicName);
+ target = client.target(url);
+ target = target.path("/topics/");
+ target = target.path(topicName);
+ target = target.path("/consumers");
+ // checking all consumer for a particular topic
+ Response response = target.request().get();
+ keyInstance.assertStatus(response);
+ LOGGER.info("Successfully returned after getting all the consumers" + topicName);
+ }
+
+
+*/
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapAdminTest.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapAdminTest.java
new file mode 100644
index 0000000..f8dc500
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapAdminTest.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+
+
+public class DmaapAdminTest {
+ /*private static final Logger LOGGER = Logger.getLogger(DmaapAdminTest.class);
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(LoadPropertyFile.getPropertyFileData().getProperty("url"));
+
+
+ public void assertStatus(Response response) {
+ assertTrue(response.getStatus() == HttpStatus.SC_OK);
+ }
+
+ // 1.get consumer cache
+ public void testConsumerCache() {
+ LOGGER.info("test case consumer cache");
+ target = target.path("/admin/consumerCache");
+ Response response = target.request().get();
+ assertStatus(response);
+ LOGGER.info("Successfully returned after fetching consumer cache");
+ InputStream is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ String data = s.next();
+ s.close();
+ LOGGER.info("Details of consumer cache :" + data);
+ }
+
+ // 2.drop consumer cache
+ public void testDropConsumerCache() {
+ LOGGER.info("test case drop consumer cache");
+ target = target.path("/admin/dropConsumerCache");
+ Response response = target.request().post(Entity.json(null));
+ assertStatus(response);
+ LOGGER.info("Successfully returned after dropping consumer cache");
+ }
+*/
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapApiKeyTest.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapApiKeyTest.java
new file mode 100644
index 0000000..569f257
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapApiKeyTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+public class DmaapApiKeyTest {
+ /*
+ private static final Logger LOGGER = Logger.getLogger(DmaapApiKeyTest.class);
+ Client client = ClientBuilder.newClient();
+ Properties prop = LoadPropertyFile.getPropertyFileData();
+ String url = prop.getProperty("url");
+ WebTarget target = client.target(url);
+ String date = prop.getProperty("date");
+
+
+ public JSONObject returnKey(ApiKeyBean apikeybean) {
+ LOGGER.info("Call to return newly created key");
+ target = client.target(url);
+ target = target.path("/apiKeys/create");
+ Response response = target.request().post(Entity.json(apikeybean));
+ assertStatus(response);
+ LOGGER.info("successfully created keys");
+ InputStream is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ JSONObject dataObj = new JSONObject(s.next());
+ s.close();
+ LOGGER.info("key details :" + dataObj.toString());
+ return dataObj;
+ }
+
+
+ public void assertStatus(Response response) {
+ assertTrue(response.getStatus() == HttpStatus.SC_OK);
+ }
+
+ // 2. get Allkey details
+ public void testAllKey() {
+ LOGGER.info("test case get all key");
+ target = target.path("/apiKeys");
+ Response response = target.request().get();
+ assertStatus(response);
+ LOGGER.info("successfully returned after get all key");
+ InputStream is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ LOGGER.info("Details of key: " + s.next());
+ s.close();
+
+ }
+
+
+
+*/
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapMetricsTest.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapMetricsTest.java
new file mode 100644
index 0000000..d7e4e4e
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/DmaapMetricsTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+public class DmaapMetricsTest {
+ /*private static final Logger LOGGER = Logger.getLogger(DmaapMetricsTest.class);
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(LoadPropertyFile.getPropertyFileData().getProperty("url"));
+
+ public void assertStatus(Response response) {
+ assertTrue(response.getStatus() == HttpStatus.SC_OK);
+ }
+
+
+ // 1.get metrics
+ public void testMetrics() {
+ LOGGER.info("test case get all metrics");
+ target = target.path("/metrics");
+ Response response = target.request().get();
+ assertStatus(response);
+ LOGGER.info("successfully returned after fetching all metrics");
+ InputStream is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ String data = s.next();
+ s.close();
+ LOGGER.info("DmaapMetricTest Test all metrics" + data);
+ }
+
+ // 2.get metrics by name
+ public void testMetricsByName() {
+ LOGGER.info("test case get metrics by name");
+ target = target.path("/metrics/startTime");
+ Response response = target.request().get();
+ assertStatus(response);
+ LOGGER.info("successfully returned after fetching specific metrics");
+ InputStream is = (InputStream) response.getEntity();
+ Scanner s = new Scanner(is);
+ s.useDelimiter("\\A");
+ String data = s.next();
+ s.close();
+ LOGGER.info("DmaapMetricTest metrics by name" + data);
+ }
+*/
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dmaap/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/JUnitTestSuite.java
new file mode 100644
index 0000000..14f0f5a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/JUnitTestSuite.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({ DMaapPubSubTest.class, DmaapApiKeyTest.class, DMaapTopicTest.class, DmaapMetricsTest.class,
+ DmaapAdminTest.class })
+public class JUnitTestSuite {
+ /*private static final Logger LOGGER = Logger.getLogger(DMaapTopicTest.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/dmaap/LoadPropertyFile.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/LoadPropertyFile.java
new file mode 100644
index 0000000..cdfe80d
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/LoadPropertyFile.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+public class LoadPropertyFile {
+ /*private static final Logger LOGGER = Logger
+ .getLogger(LoadPropertyFile.class);
+
+ static public Properties getPropertyFileData() {
+ Properties prop = new Properties();
+ LOGGER.info("loading the property file");
+
+ try {
+ InputStream inputStream = LoadPropertyFile.class.getClassLoader()
+ .getResourceAsStream("DMaaPUrl.properties");
+ prop.load(inputStream);
+ LOGGER.info("successfully loaded the property file");
+ } catch (IOException e) {
+ LOGGER.error("Error while retrieving API keys: " + e);
+ }
+ return prop;
+ }*/
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dmaap/TestRunner.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/TestRunner.java
new file mode 100644
index 0000000..7b8247a
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/TestRunner.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+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/dmaap/TopicBean.java b/src/test/java/org/onap/dmaap/mr/test/dmaap/TopicBean.java
new file mode 100644
index 0000000..b1950e2
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dmaap/TopicBean.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * ============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.test.dmaap;
+
+import java.io.Serializable;
+
+public class TopicBean implements Serializable {
+
+ /*
+ * private static final long serialVersionUID = -8620390377775457949L;
+ * private String topicName; private String description;
+ *
+ *
+ * private int partitionCount; private int replicationCount; private boolean
+ * transactionEnabled = false;
+ *
+ * public boolean isTransactionEnabled() { return transactionEnabled; }
+ *
+ * public void setTransactionEnabled(boolean transactionEnabled) {
+ * this.transactionEnabled = transactionEnabled; }
+ *
+ * public TopicBean() { super(); }
+ *
+ * public TopicBean(String topicName, String description, int
+ * partitionCount, int replicationCount, boolean transactionEnabled) {
+ * super(); this.topicName = topicName; this.description = description;
+ * this.partitionCount = partitionCount; this.replicationCount =
+ * replicationCount; this.transactionEnabled = transactionEnabled; }
+ *
+ * public String getTopicName() { return topicName; }
+ *
+ * public void setTopicName(String topicName) { this.topicName = topicName;
+ * }
+ *
+ * public String getDescription() { return description; }
+ *
+ * public void setDescription(String description) { this.description =
+ * description; }
+ *
+ * public int getPartitionCount() { return partitionCount; }
+ *
+ * public void setPartitionCount(int partitionCount) { this.partitionCount =
+ * partitionCount; }
+ *
+ * public int getReplicationCount() { return replicationCount; }
+ *
+ * public void setReplicationCount(int replicationCount) {
+ * this.replicationCount = replicationCount; }
+ */
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/ApiKeyBean.java b/src/test/java/org/onap/dmaap/mr/test/dme2/ApiKeyBean.java
new file mode 100644
index 0000000..96c9c78
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/ApiKeyBean.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import java.io.Serializable;
+
+public class ApiKeyBean implements Serializable {
+
+ private static final long serialVersionUID = -8219849086890567740L;
+
+ // private static final String KEY_CHARS =
+ // "ABCDEFGHJIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+
+ private String email;
+ private String description;
+
+ public ApiKeyBean() {
+ super();
+ }
+
+ public ApiKeyBean(String email, String description) {
+ super();
+ this.email = email;
+ this.description = description;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /*
+ * public String getKey() { return generateKey(16); }
+ *
+ * public String getSharedSecret() { return generateKey(24); }
+ *
+ * private static String generateKey ( int length ) { return
+ * uniqueStringGenerator.createKeyUsingAlphabet ( KEY_CHARS, length ); }
+ */
+
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/DME2AdminTest.java b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2AdminTest.java
new file mode 100644
index 0000000..91d897c
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2AdminTest.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import com.att.aft.dme2.api.DME2Client;
+import com.att.aft.dme2.api.DME2Exception;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Properties;
+import junit.framework.TestCase;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class DME2AdminTest extends TestCase {
+
+ private static final Logger LOGGER = LogManager.getLogger(DME2AdminTest.class);
+
+ protected String url;
+
+ protected Properties props;
+
+ protected HashMap<String, String> hm;
+
+ protected String methodType;
+
+ protected String contentType;
+
+ protected String user;
+
+ protected String password;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ System.setProperty("AFT_DME2_CLIENT_SSL_INCLUDE_PROTOCOLS", "SSLv3,TLSv1,TLSv1.1");
+ System.setProperty("AFT_DME2_CLIENT_IGNORE_SSL_CONFIG", "false");
+ System.setProperty("AFT_DME2_CLIENT_KEYSTORE_PASSWORD", "changeit");
+ this.props = LoadPropertyFile.getPropertyFileDataProducer();
+ String latitude = props.getProperty("Latitude");
+ String longitude = props.getProperty("Longitude");
+ String version = props.getProperty("Version");
+ String serviceName = props.getProperty("ServiceName");
+ serviceName = "mr/admin";
+ String env = props.getProperty("Environment");
+ String partner = props.getProperty("Partner");
+ String protocol = props.getProperty("Protocol");
+
+ methodType = props.getProperty("MethodTypeGet");
+ contentType = props.getProperty("contenttype");
+ user = props.getProperty("user");
+ password = props.getProperty("password");
+ this.url =
+ protocol + "://" + serviceName + "?" + "version=" + version + "&" + "envContext=" + env
+ + "&"
+ + "routeOffer=" + partner + "&partner=BOT_R";
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ }
+
+ public void testGetConsumerCache() {
+ LOGGER.info("test case consumer cache started");
+ String subContextPath = props.getProperty("SubContextPathGetAdminConsumerCache");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodType);
+ sender.setSubContext(subContextPath);
+ sender.setPayload("");
+ sender.addHeader("Content-Type", contentType);
+
+ sender.addHeader("X-CambriaAuth", "user1:7J49YriFlyRgebyOsSJhZvY/C60=");
+ sender.addHeader("X-X-CambriaDate", "2016-10-18T09:56:04-05:00");
+
+ //sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+ LOGGER.info("Getting consumer Cache");
+ String reply = sender.sendAndWait(5000L);
+ System.out.println(reply);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ assertNotNull(reply);
+ LOGGER.info("response from consumer cache=" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void ttestDropConsumerCache() {
+ LOGGER.info("Drom consumer cache initiated");
+ String subContextPath = props.getProperty("SubContextPathDropAdminConsumerCache");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodType);
+ sender.setSubContext(subContextPath);
+ sender.setPayload("");
+ sender.addHeader("Content-Type", contentType);
+ sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+
+ LOGGER.info("Dropping consumer cache...........");
+ String reply = sender.sendAndWait(5000L);
+
+ // assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ assertNotNull(reply);
+ LOGGER.info("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ApiKeyTest.java b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ApiKeyTest.java
new file mode 100644
index 0000000..087a7ab
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ApiKeyTest.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import com.att.aft.dme2.api.DME2Client;
+import com.att.aft.dme2.api.DME2Exception;
+import com.att.aft.dme2.internal.jackson.map.ObjectMapper;
+import junit.framework.TestCase;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Properties;
+
+public class DME2ApiKeyTest extends TestCase {
+
+ private static final Logger LOGGER = LogManager.getLogger(DME2ApiKeyTest.class);
+
+ protected String url;
+
+ protected Properties props;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ System.setProperty("AFT_DME2_CLIENT_SSL_INCLUDE_PROTOCOLS", "SSLv3,TLSv1,TLSv1.1");
+ System.setProperty("AFT_DME2_CLIENT_IGNORE_SSL_CONFIG", "false");
+ System.setProperty("AFT_DME2_CLIENT_KEYSTORE_PASSWORD", "changeit");
+ this.props = LoadPropertyFile.getPropertyFileDataProducer();
+ String latitude = props.getProperty("Latitude");
+ String longitude = props.getProperty("Longitude");
+ String version = props.getProperty("Version");
+ String serviceName = props.getProperty("ServiceName");
+ String env = props.getProperty("Environment");
+ String partner = props.getProperty("Partner");
+ String protocol = props.getProperty("Protocol");
+ this.url =
+ protocol + "://" + serviceName + "?" + "version=" + version + "&" + "envContext=" + env
+ + "&"
+ + "routeOffer=" + partner + "&partner=BOT_R";
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ }
+
+ public void testCreateKey() {
+ LOGGER.info("Create Key test case initiated");
+ ApiKeyBean apiKeyBean = new ApiKeyBean("user1@onap.com", "Creating Api Key.m");
+ System.out.println(url);
+ returnKey(apiKeyBean, url, props);
+ }
+
+ public String returnKey(ApiKeyBean apibean, String url, Properties props) {
+ String reply = null;
+ try {
+ LOGGER.info("Call to return key ");
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(props.getProperty("MethodTypePost"));
+ sender.setSubContext(props.getProperty("SubContextPathGetCreateKeys"));
+ String jsonStringApiBean = new ObjectMapper().writeValueAsString(apibean);
+ sender.setPayload(jsonStringApiBean);
+ sender.addHeader("content-type", props.getProperty("contenttype"));
+ sender.setCredentials(props.getProperty("user"), props.getProperty("password"));
+ LOGGER.info("creating ApiKey");
+ reply = sender.sendAndWait(5000L);
+ System.out.println("reply: " + reply);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ LOGGER.info("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return reply;
+ }
+
+ public void testGetAllKey() {
+ LOGGER.info("Test case Get All key initiated....");
+ try {
+ DME2Client sender = new DME2Client(new URI(this.url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(this.props.getProperty("MethodTypeGet"));
+ String subcontextPath = this.props.getProperty("SubContextPathGetApiKeys");
+ // sender.setSubContext(subcontextPath);
+ sender.setPayload("");
+ sender.addHeader("content-type", props.getProperty("contenttype"));
+ sender.setCredentials(props.getProperty("user"), props.getProperty("password"));
+ LOGGER.info("Fetching all keys");
+ String reply = sender.sendAndWait(5000L);
+ System.out.println(reply);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ LOGGER.info("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ConsumerFilterTest.java b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ConsumerFilterTest.java
new file mode 100644
index 0000000..5398cb4
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ConsumerFilterTest.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import com.att.aft.dme2.api.DME2Client;
+import com.att.aft.dme2.api.DME2Exception;
+import junit.framework.TestCase;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Properties;
+
+public class DME2ConsumerFilterTest extends TestCase {
+
+ private static final Logger LOGGER = LogManager.getLogger(DME2ConsumerFilterTest.class);
+
+ public void testConsumerFilter() {
+ LOGGER.info("Test case consumer filter initiated");
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ String latitude = props.getProperty("Latitude");
+ String longitude = props.getProperty("Longitude");
+ String version = props.getProperty("Version");
+ String serviceName = props.getProperty("ServiceName");
+ String env = props.getProperty("Environment");
+ String partner = props.getProperty("Partner");
+ String protocol = props.getProperty("Protocol");
+ String methodType = props.getProperty("MethodTypeGet");
+ String user = props.getProperty("user");
+ String password = props.getProperty("password");
+ String contenttype = props.getProperty("contenttype");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodType);
+ String subContextPathConsumer =
+ props.getProperty("SubContextPathConsumer") + props.getProperty("newTopic")
+ + "/" + props.getProperty("group") + "/" + props.getProperty("id") + "?"
+ + props.getProperty("filterType");
+
+ sender.setSubContext(URLEncoder.encode(subContextPathConsumer, "UTF-8"));
+ sender.setPayload("");
+
+ sender.addHeader("Content-Type", contenttype);
+ sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+ LOGGER.info("Consuming Message for Filter");
+ String reply = sender.sendAndWait(5000L);
+ assertNotNull(reply);
+ LOGGER.info("Message received = " + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ConsumerTest.java b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ConsumerTest.java
new file mode 100644
index 0000000..2322007
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ConsumerTest.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import com.att.aft.dme2.api.DME2Client;
+import com.att.aft.dme2.api.DME2Exception;
+import junit.framework.TestCase;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Properties;
+
+public class DME2ConsumerTest extends TestCase {
+
+ private static final Logger LOGGER = LogManager.getLogger(DME2ConsumerTest.class);
+
+ public void testConsumer() {
+ LOGGER.info("Test case subcribing initiated");
+
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ String latitude = props.getProperty("Latitude");
+ String longitude = props.getProperty("Longitude");
+ String version = props.getProperty("Version");
+ String serviceName = props.getProperty("ServiceName");
+ String env = props.getProperty("Environment");
+ String partner = props.getProperty("Partner");
+ String protocol = props.getProperty("Protocol");
+ String methodType = props.getProperty("MethodTypeGet");
+ String user = props.getProperty("user");
+ String password = props.getProperty("password");
+ String contenttype = props.getProperty("contenttype");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodType);
+ String subContextPathConsumer =
+ props.getProperty("SubContextPathConsumer") + props.getProperty("newTopic")
+ + "/" + props.getProperty("group") + "/" + props.getProperty("id");
+ sender.setSubContext(subContextPathConsumer);
+ sender.setPayload("");
+
+ sender.addHeader("Content-Type", contenttype);
+ sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+
+ LOGGER.info("Consuming Message");
+ String reply = sender.sendAndWait(5000L);
+
+ assertNotNull(reply);
+ LOGGER.info("Message received = " + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/DME2MetricsTest.java b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2MetricsTest.java
new file mode 100644
index 0000000..1b92bda
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2MetricsTest.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import com.att.aft.dme2.api.DME2Client;
+import com.att.aft.dme2.api.DME2Exception;
+import junit.framework.TestCase;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Properties;
+
+public class DME2MetricsTest extends TestCase {
+
+ private static final Logger LOGGER = LogManager.getLogger(DME2MetricsTest.class);
+
+ public void testGetMetrics() {
+ LOGGER.info("Test case get metrics initiated...");
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ String latitude = props.getProperty("Latitude");
+ String longitude = props.getProperty("Longitude");
+ String version = props.getProperty("Version");
+ String serviceName = props.getProperty("ServiceName");
+ String env = props.getProperty("Environment");
+ String partner = props.getProperty("Partner");
+ String subContextPath = props.getProperty("SubContextPathGetMetrics");
+ String protocol = props.getProperty("Protocol");
+ String methodType = props.getProperty("MethodTypeGet");
+ String user = props.getProperty("user");
+ String password = props.getProperty("password");
+ String contenttype = props.getProperty("contenttype");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodType);
+ sender.setSubContext(subContextPath);
+ sender.setPayload("");
+ sender.addHeader("Content-Type", contenttype);
+ sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+ LOGGER.info("Getting Metrics Details");
+ String reply = sender.sendAndWait(5000L);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ LOGGER.info("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testGetMetricsByName() {
+ LOGGER.info("Test case get metrics by name initiated");
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ String latitude = props.getProperty("Latitude");
+ String longitude = props.getProperty("Longitude");
+ String version = props.getProperty("Version");
+ String serviceName = props.getProperty("ServiceName");
+ String env = props.getProperty("Environment");
+ String partner = props.getProperty("Partner");
+ String subContextPath = props.getProperty("SubContextPathGetMetricsByName");
+ String protocol = props.getProperty("Protocol");
+ String methodType = props.getProperty("MethodTypeGet");
+ String user = props.getProperty("user");
+ String password = props.getProperty("password");
+ String contenttype = props.getProperty("contenttype");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodType);
+ sender.setSubContext(subContextPath);
+ sender.setPayload("");
+ sender.addHeader("Content-Type", contenttype);
+ sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+ LOGGER.info("Getting Metrics By name");
+ String reply = sender.sendAndWait(5000L);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ LOGGER.info("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ProducerTest.java b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ProducerTest.java
new file mode 100644
index 0000000..375ced0
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2ProducerTest.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import com.att.aft.dme2.api.DME2Client;
+import com.att.aft.dme2.api.DME2Exception;
+import com.att.aft.dme2.internal.jackson.map.ObjectMapper;
+import junit.framework.TestCase;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Properties;
+
+public class DME2ProducerTest extends TestCase {
+
+ private static final Logger LOGGER = LogManager.getLogger(DME2ProducerTest.class);
+
+ public void testProducer() {
+ DME2TopicTest topicTestObj = new DME2TopicTest();
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ String latitude = props.getProperty("Latitude");
+ String longitude = props.getProperty("Longitude");
+ String version = props.getProperty("Version");
+ String serviceName = props.getProperty("ServiceName");
+ String env = props.getProperty("Environment");
+ String partner = props.getProperty("Partner");
+ String protocol = props.getProperty("Protocol");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ // checking whether topic exist or not
+ if (!topicTestObj.topicExist(url, props, hm)) {
+ // if topic doesn't exist then create the topic
+ topicTestObj.createTopic(url, props, hm);
+ // after creating the topic publish on that topic
+ publishMessage(url, props, hm);
+ } else {
+ // if topic already exist start publishing on the topic
+ publishMessage(url, props, hm);
+ }
+
+ }
+
+ public void publishMessage(String url, Properties props, HashMap<String, String> mapData) {
+ try {
+ LOGGER.info("Call to publish message ");
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(props.getProperty("MethodTypePost"));
+ String subcontextpathPublish =
+ props.getProperty("SubContextPathproducer") + props.getProperty("newTopic");
+ sender.setSubContext(subcontextpathPublish);
+ String jsonStringApiBean = new ObjectMapper()
+ .writeValueAsString(new ApiKeyBean("example@att.com",
+ "description"));
+ sender.setPayload(jsonStringApiBean);
+
+ sender.setCredentials(props.getProperty("user"), props.getProperty("password"));
+ sender.addHeader("content-type", props.getProperty("contenttype"));
+ LOGGER.info("Publishing message");
+ String reply = sender.sendAndWait(5000L);
+ // assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ assertNotNull(reply);
+ LOGGER.info("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/DME2TopicTest.java b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2TopicTest.java
new file mode 100644
index 0000000..ec03d26
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/DME2TopicTest.java
@@ -0,0 +1,441 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import com.att.aft.dme2.api.DME2Client;
+import com.att.aft.dme2.api.DME2Exception;
+import com.att.aft.dme2.internal.jackson.map.ObjectMapper;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Properties;
+import junit.framework.TestCase;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class DME2TopicTest extends TestCase {
+
+ private String latitude;
+ private String longitude;
+ private String version;
+ private String serviceName;
+ private String env;
+ private String partner;
+ private String protocol;
+ private String methodTypeGet;
+ private String methodTypePost;
+ private String methodTypeDelete;
+ private String methodTypePut;
+
+ private String user;
+ private String password;
+ private String contenttype;
+ private String subContextPathGetAllTopic;
+ private String subContextPathGetOneTopic;
+ private String SubContextPathCreateTopic;
+ private String SubContextPathGetPublisherl;
+ private String SubContextPathGetPublisher;
+ private String SubContextPathGetPermitPublisher;
+ private String SubContextPathGetConsumer;
+ private String SubContextPathGetPermitConsumer;
+ private static final Logger LOGGER = LogManager.getLogger(DME2TopicTest.class);
+
+ public void createTopic(String url, Properties props, HashMap<String, String> mapData) {
+ LOGGER.info("create topic method starts");
+ if (!topicExist(url, props, mapData)) {
+ LOGGER.info("creating a new topic");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(props.getProperty("MethodTypePost"));
+ sender.setSubContext(props.getProperty("SubContextPathCreateTopic"));
+ TopicBeanDME2 topicBean = new TopicBeanDME2(props.getProperty("newTopic"),
+ props.getProperty("topicDescription"),
+ Integer.parseInt(props.getProperty("partition")),
+ Integer.parseInt(props.getProperty("replication")), Boolean.valueOf(props
+ .getProperty("txenabled")));
+ String jsonStringApiBean = new ObjectMapper().writeValueAsString(topicBean);
+ sender.setPayload(jsonStringApiBean);
+ sender.addHeader("content-type", props.getProperty("contenttype"));
+ sender.setCredentials(props.getProperty("user"), props.getProperty("password"));
+ LOGGER.info("creating Topic");
+ String reply = sender.sendAndWait(5000L);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ LOGGER.info("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public boolean topicExist(String url, Properties props, HashMap<String, String> mapData) {
+ boolean topicExist = false;
+ try {
+ LOGGER.info("Checking topic exists or not");
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(props.getProperty("MethodTypeGet"));
+ String subcontextPath =
+ props.getProperty("subContextPathGetOneTopic") + props.getProperty("newTopic");
+ sender.setSubContext(subcontextPath);
+ sender.setPayload("");
+ sender.addHeader("content-type", props.getProperty("contenttype"));
+ sender.setCredentials(props.getProperty("user"), props.getProperty("password"));
+ String reply = sender.sendAndWait(5000L);
+ topicExist = LoadPropertyFile.isValidJsonString(reply);
+ LOGGER.info("Topic exist =" + topicExist);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return topicExist;
+ }
+
+ public void testAllTopics() {
+ LOGGER.info("Test case get all topics initiated");
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ latitude = props.getProperty("Latitude");
+ longitude = props.getProperty("Longitude");
+ version = props.getProperty("Version");
+ serviceName = props.getProperty("ServiceName");
+ env = props.getProperty("Environment");
+ partner = props.getProperty("Partner");
+ subContextPathGetAllTopic = props.getProperty("subContextPathGetAllTopic");
+ protocol = props.getProperty("Protocol");
+ methodTypeGet = props.getProperty("MethodTypeGet");
+ user = props.getProperty("user");
+ password = props.getProperty("password");
+ contenttype = props.getProperty("contenttype");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude); // } else {
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodTypeGet);
+ sender.setSubContext(subContextPathGetAllTopic);
+ sender.setPayload("");
+
+ sender.addHeader("Content-Type", contenttype);
+ sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+
+ LOGGER.info("Retrieving all topics");
+ String reply = sender.sendAndWait(5000L);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ LOGGER.info("All Topics details = " + reply);
+
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testOneTopic() {
+ LOGGER.info("Test case get one topic initiated");
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ latitude = props.getProperty("Latitude");
+ longitude = props.getProperty("Longitude");
+ version = props.getProperty("Version");
+ serviceName = props.getProperty("ServiceName");
+ env = props.getProperty("Environment");
+ partner = props.getProperty("Partner");
+ subContextPathGetOneTopic = props.getProperty("subContextPathGetOneTopic");
+ protocol = props.getProperty("Protocol");
+ methodTypeGet = props.getProperty("MethodTypeGet");
+ user = props.getProperty("user");
+ password = props.getProperty("password");
+ contenttype = props.getProperty("contenttype");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ System.out.println("Retrieving topic detail");
+ if (!topicExist(url, props, hm)) {
+ createTopic(url, props, hm);
+ } else {
+ assertTrue(true);
+ }
+ }
+
+ public void createTopicForDeletion(String url, Properties props,
+ HashMap<String, String> mapData) {
+ LOGGER.info("create topic method starts");
+ LOGGER.info("creating a new topic for deletion");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(props.getProperty("MethodTypePost"));
+ sender.setSubContext(props.getProperty("SubContextPathCreateTopic"));
+ TopicBeanDME2 topicBean = new TopicBeanDME2(props.getProperty("deleteTopic"),
+ props.getProperty("topicDescription"),
+ Integer.parseInt(props.getProperty("partition")),
+ Integer.parseInt(props.getProperty("replication")),
+ Boolean.valueOf(props.getProperty("txenabled")));
+ String jsonStringApiBean = new ObjectMapper().writeValueAsString(topicBean);
+ sender.setPayload(jsonStringApiBean);
+ sender.addHeader("content-type", props.getProperty("contenttype"));
+ sender.setCredentials(props.getProperty("user"), props.getProperty("password"));
+
+ LOGGER.info("creating Topic");
+ String reply = sender.sendAndWait(5000L);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ LOGGER.info("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public boolean topicExistForDeletion(String url, Properties props,
+ HashMap<String, String> mapData) {
+ boolean topicExist = false;
+ try {
+ LOGGER.info("Checking topic exists for deletion");
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(props.getProperty("MethodTypeGet"));
+ String subcontextPath =
+ props.getProperty("subContextPathGetOneTopic") + props.getProperty("deleteTopic");
+ sender.setSubContext(subcontextPath);
+ sender.setPayload("");
+ sender.addHeader("content-type", props.getProperty("contenttype"));
+ sender.setCredentials(props.getProperty("user"), props.getProperty("password"));
+ String reply = sender.sendAndWait(5000L);
+ topicExist = LoadPropertyFile.isValidJsonString(reply);
+ LOGGER.info("Topic exist for deletion=" + topicExist);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return topicExist;
+ }
+
+ public void testDeleteTopic() {
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ latitude = props.getProperty("Latitude");
+ longitude = props.getProperty("Longitude");
+ version = props.getProperty("Version");
+ serviceName = props.getProperty("ServiceName");
+ env = props.getProperty("Environment");
+ partner = props.getProperty("Partner");
+ SubContextPathCreateTopic = props.getProperty("SubContextPathCreateTopic");
+ protocol = props.getProperty("Protocol");
+ methodTypePost = props.getProperty("MethodTypeDelete");
+ user = props.getProperty("user");
+ password = props.getProperty("password");
+ contenttype = props.getProperty("contenttypejson");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ System.out.println("deleteing topic");
+ if (!topicExistForDeletion(url, props, hm)) {
+ createTopicForDeletion(url, props, hm);
+ deleteTopic(url, props, hm);
+ } else {
+ deleteTopic(url, props, hm);
+ }
+ }
+
+ public void deleteTopic(String url, Properties props, HashMap<String, String> mapData) {
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(props.getProperty("MethodTypeDelete"));
+ String subsontextPathDelete = props.getProperty("subContextPathGetOneTopic")
+ + props.getProperty("deleteTopic");
+ sender.setSubContext(subsontextPathDelete);
+ sender.setPayload("");
+ sender.addHeader("content-type", props.getProperty("contenttype"));
+ sender.setCredentials(props.getProperty("user"), props.getProperty("password"));
+ System.out.println("Deleting Topic " + props.getProperty("deleteTopic"));
+ String reply = sender.sendAndWait(5000L);
+ assertNotNull(reply);
+ System.out.println("response =" + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testGetProducersTopics() {
+ LOGGER.info("Test case get list of producers on topic");
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ latitude = props.getProperty("Latitude");
+ longitude = props.getProperty("Longitude");
+ version = props.getProperty("Version");
+ serviceName = props.getProperty("ServiceName");
+ env = props.getProperty("Environment");
+ partner = props.getProperty("Partner");
+ SubContextPathGetPublisher = props.getProperty("SubContextPathGetPublisher");
+ protocol = props.getProperty("Protocol");
+ methodTypeGet = props.getProperty("MethodTypeGet");
+ user = props.getProperty("user");
+ password = props.getProperty("password");
+ contenttype = props.getProperty("contenttype");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodTypeGet);
+ sender.setSubContext(SubContextPathGetPublisher);
+ sender.setPayload("");
+
+ sender.addHeader("Content-Type", contenttype);
+ sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+
+ LOGGER.info("Retrieving List of publishers");
+ String reply = sender.sendAndWait(5000L);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ LOGGER.info("All Publishers details = " + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testGetConsumersTopics() {
+ LOGGER.info("Test case get list of consumers on topic ");
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ latitude = props.getProperty("Latitude");
+ longitude = props.getProperty("Longitude");
+ version = props.getProperty("Version");
+ serviceName = props.getProperty("ServiceName");
+ env = props.getProperty("Environment");
+ partner = props.getProperty("Partner");
+ SubContextPathGetConsumer = props.getProperty("SubContextPathGetConsumer");
+ protocol = props.getProperty("Protocol");
+ methodTypeGet = props.getProperty("MethodTypeGet");
+ user = props.getProperty("user");
+ password = props.getProperty("password");
+ contenttype = props.getProperty("contenttype");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ try {
+ DME2Client sender = new DME2Client(new URI(url), 5000L);
+ sender.setAllowAllHttpReturnCodes(true);
+ sender.setMethod(methodTypeGet);
+ sender.setSubContext(SubContextPathGetConsumer);
+ sender.setPayload("");
+
+ sender.addHeader("Content-Type", contenttype);
+ sender.setCredentials(user, password);
+ sender.setHeaders(hm);
+
+ LOGGER.info("Retrieving consumer details on topics");
+ String reply = sender.sendAndWait(5000L);
+ assertTrue(LoadPropertyFile.isValidJsonString(reply));
+ System.out.println("Reply from server = " + reply);
+ } catch (DME2Exception e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testCreateTopic() {
+ LOGGER.info("Test case create topic starts");
+ Properties props = LoadPropertyFile.getPropertyFileDataProducer();
+ latitude = props.getProperty("Latitude");
+ longitude = props.getProperty("Longitude");
+ version = props.getProperty("Version");
+ serviceName = props.getProperty("ServiceName");
+ env = props.getProperty("Environment");
+ partner = props.getProperty("Partner");
+ SubContextPathCreateTopic = props.getProperty("SubContextPathCreateTopic");
+ protocol = props.getProperty("Protocol");
+ methodTypePost = props.getProperty("MethodTypePost");
+ user = props.getProperty("user");
+ password = props.getProperty("password");
+ contenttype = props.getProperty("contenttypejson");
+ String url =
+ protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version
+ + "/"
+ + "envContext=" + env + "/" + "partner=" + partner;
+ LoadPropertyFile.loadAFTProperties(latitude, longitude);
+ HashMap<String, String> hm = new HashMap<String, String>();
+ hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
+ hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
+ hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
+ createTopic(url, props, hm);
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mr/test/dme2/JUnitTestSuite.java
new file mode 100644
index 0000000..bab1be3
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/JUnitTestSuite.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import junit.framework.TestSuite;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DME2AdminTest.class, DME2ApiKeyTest.class, DME2ConsumerTest.class,
+ DME2ConsumerTest.class, DME2MetricsTest.class, DME2ProducerTest.class, DME2TopicTest.class,})
+public class JUnitTestSuite {
+
+ private static final Logger LOGGER = LogManager.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/dme2/LoadPropertyFile.java b/src/test/java/org/onap/dmaap/mr/test/dme2/LoadPropertyFile.java
new file mode 100644
index 0000000..5c95f2f
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/LoadPropertyFile.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.json.JSONObject;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class LoadPropertyFile {
+ //private static final Logger LOGGER = Logger.getLogger(LoadPropertyFile.class);
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(LoadPropertyFile.class);
+
+ static public Properties getPropertyFileDataProducer() {
+ Properties prop = new Properties();
+ LOGGER.info("loading the property file");
+ try {
+ InputStream inputStream = LoadPropertyFile.class.getClassLoader()
+ .getResourceAsStream("dme2testcase.properties");
+
+ prop.load(inputStream);
+ LOGGER.info("successfully loaded the property file");
+ } catch (IOException e) {
+ LOGGER.error("Error while retrieving API keys: " + e);
+ }
+ return prop;
+ }
+
+ static public void loadAFTProperties(String lat, String longi) {
+ System.setProperty("AFT_LATITUDE", lat);
+ System.setProperty("AFT_LONGITUDE", longi);
+ System.setProperty("AFT_ENVIRONMENT", "AFTUAT");
+ // printProperties();
+ System.out.println("Latitude =" + lat);
+ System.out.println("Longitude =" + longi);
+ }
+
+ static public boolean isValidJsonString(String chkString) {
+ boolean isJson = true;
+ try {
+ new JSONObject(chkString);
+ } catch (Exception e) {
+ isJson = false;
+ }
+ return isJson;
+ }
+}
diff --git a/src/test/java/org/onap/dmaap/mr/test/dme2/TestRunner.java b/src/test/java/org/onap/dmaap/mr/test/dme2/TestRunner.java
new file mode 100644
index 0000000..5e6e1c3
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/TestRunner.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+
+public class TestRunner {
+
+ private static final Logger LOGGER = LogManager.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/dme2/TopicBeanDME2.java b/src/test/java/org/onap/dmaap/mr/test/dme2/TopicBeanDME2.java
new file mode 100644
index 0000000..597546b
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/mr/test/dme2/TopicBeanDME2.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * ============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.test.dme2;
+
+import java.io.Serializable;
+
+public class TopicBeanDME2 implements Serializable {
+
+ private static final long serialVersionUID = -8620390377775457949L;
+ private String topicName;
+ private String description;
+
+
+ private int partitionCount;
+ private int replicationCount;
+ private boolean transactionEnabled = false;
+
+ public boolean isTransactionEnabled() {
+ return transactionEnabled;
+ }
+
+ public void setTransactionEnabled(boolean transactionEnabled) {
+ this.transactionEnabled = transactionEnabled;
+ }
+
+ public TopicBeanDME2() {
+ super();
+ }
+
+ public TopicBeanDME2(String topicName, String description, int partitionCount, int replicationCount,
+ boolean transactionEnabled) {
+ super();
+ this.topicName = topicName;
+ this.description = description;
+ this.partitionCount = partitionCount;
+ this.replicationCount = replicationCount;
+ this.transactionEnabled = transactionEnabled;
+ }
+
+ public String getTopicName() {
+ return topicName;
+ }
+
+ public void setTopicName(String topicName) {
+ this.topicName = topicName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getPartitionCount() {
+ return partitionCount;
+ }
+
+ public void setPartitionCount(int partitionCount) {
+ this.partitionCount = partitionCount;
+ }
+
+ public int getReplicationCount() {
+ return replicationCount;
+ }
+
+ public void setReplicationCount(int replicationCount) {
+ this.replicationCount = replicationCount;
+ }
+
+}
diff --git a/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java b/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java
index 2f3098d..a3c123b 100644
--- a/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java
+++ b/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java
@@ -20,37 +20,32 @@
package org.onap.dmaap.service;
-import static org.junit.Assert.*;
-
-import static org.mockito.Matchers.anyString;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
+import com.att.ajsc.beans.PropertiesMapBean;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.NsaAcl;
+import com.att.nsa.security.NsaApiKey;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+import com.att.nsa.security.db.simple.NsaSimpleApiKey;
import java.io.IOException;
-import java.util.ConcurrentModificationException;
-
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
-import org.junit.After;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.junit.After;
import org.junit.Assert;
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.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.att.ajsc.beans.PropertiesMapBean;
import org.onap.dmaap.dmf.mr.CambriaApiException;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
@@ -65,16 +60,15 @@ import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
import org.onap.dmaap.dmf.mr.service.TopicService;
import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.NsaAcl;
-import com.att.nsa.security.NsaApiKey;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;
+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(MockitoJUnitRunner.class)
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("jdk.internal.reflect.*")
-@PrepareForTest({ PropertiesMapBean.class })
+@PrepareForTest({ PropertiesMapBean.class, DMaaPResponseBuilder.class })
public class TopicRestServiceTest {
@InjectMocks
diff --git a/src/test/resources/DMaaPErrorMesaages.properties b/src/test/resources/DMaaPErrorMesaages.properties
new file mode 100644
index 0000000..a3d6ce7
--- /dev/null
+++ b/src/test/resources/DMaaPErrorMesaages.properties
@@ -0,0 +1,59 @@
+###############################################################################
+# ============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.
+#
+###############################################################################
+###############################################################################
+##
+## DMaaP Error Messages
+###############################################################################
+
+##
+# Generic WebApplication Exceptions
+##
+resource.not.found=The requested resource was not found.Please verify the URL and try again.
+server.unavailable=Server is temporarily unavailable or busy.Try again later, or try another server in the cluster.
+http.method.not.allowed=The specified HTTP method is not allowed for the requested resource.Enter a valid HTTP method and try again.
+incorrect.request.json=Incorrect JSON object. Please correct the JSON format and try again.
+network.time.out=Connection to the DMaaP MR was timed out.Please try again.
+
+##
+# AAF Errors
+##
+authentication.failure=Access Denied: Invalid Credentials. Enter a valid MechId and Password and try again.
+not.permitted.access.1=Access Denied.User does not have permission to perform
+not.permitted.access.2=operation on Topic:
+unable.to.authorize=Unable to authorize the user. Please try again later.
+
+
+##
+#Topic
+##
+get.topic.failure=Failed to retrieve list of all topics.
+get.topic.details.failure=Failed to retrieve details of topic:
+create.topic.failure=Failed to create topic:
+delete.topic.failure=Failed to delete topic:
+
+consume.msg.error=Error while reading data from topic.
+publish.msg.error=Error while publishing data to topic.
+msg_size_exceeds=Message size exceeds the default size.
+publish.msg.count=Successfully published number of messages :
+
+incorrect.json=Incorrect JSON object.Could not parse JSON. Please correct the JSON format and try again.
+topic.not.exist=No such topic exists. \ No newline at end of file
diff --git a/src/test/resources/MsgRtrApi.properties b/src/test/resources/MsgRtrApi.properties
new file mode 100644
index 0000000..3aef922
--- /dev/null
+++ b/src/test/resources/MsgRtrApi.properties
@@ -0,0 +1,169 @@
+###############################################################################
+# ============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.
+#
+###############################################################################
+###############################################################################
+##
+## Cambria API Server config
+##
+## - Default values are shown as commented settings.
+##
+
+###############################################################################
+##
+## HTTP service
+##
+## - 3904 is standard as of 7/29/14.
+#
+## Zookeeper Connection
+##
+## Both Cambria and Kafka make use of Zookeeper.
+##
+#config.zk.servers=172.18.1.1
+config.zk.servers=<zookeeper_host>
+#config.zk.root=/fe3c/cambria/config
+
+
+###############################################################################
+##
+## Kafka Connection
+##
+## Items below are passed through to Kafka's producer and consumer
+## configurations (after removing "kafka.")
+## if you want to change request.required.acks it can take this one value
+#kafka.metadata.broker.list=localhost:9092,localhost:9093
+kafka.metadata.broker.list=<kafka_host>:<kafka_port>
+##kafka.request.required.acks=-1
+#kafka.client.zookeeper=${config.zk.servers}
+consumer.timeout.ms=100
+zookeeper.connection.timeout.ms=6000
+zookeeper.session.timeout.ms=20000
+zookeeper.sync.time.ms=2000
+auto.commit.interval.ms=1000
+fetch.message.max.bytes =1000000
+auto.commit.enable=false
+
+#(backoff*retries > zksessiontimeout)
+kafka.rebalance.backoff.ms=10000
+kafka.rebalance.max.retries=6
+
+
+###############################################################################
+##
+## Secured Config
+##
+## Some data stored in the config system is sensitive -- API keys and secrets,
+## for example. to protect it, we use an encryption layer for this section
+## of the config.
+##
+## The key is a base64 encode AES key. This must be created/configured for
+## each installation.
+#cambria.secureConfig.key=
+##
+## The initialization vector is a 16 byte value specific to the secured store.
+## This must be created/configured for each installation.
+#cambria.secureConfig.iv=
+
+## Southfield Sandbox
+cambria.secureConfig.key=b/7ouTn9FfEw2PQwL0ov/Q==
+cambria.secureConfig.iv=wR9xP5k5vbz/xD0LmtqQLw==
+authentication.adminSecret=fe3cCompound
+#cambria.secureConfig.key[pc569h]=YT3XPyxEmKCTLI2NK+Sjbw==
+#cambria.secureConfig.iv[pc569h]=rMm2jhR3yVnU+u2V9Ugu3Q==
+
+
+###############################################################################
+##
+## Consumer Caching
+##
+## Kafka expects live connections from the consumer to the broker, which
+## obviously doesn't work over connectionless HTTP requests. The Cambria
+## server proxies HTTP requests into Kafka consumer sessions that are kept
+## around for later re-use. Not doing so is costly for setup per request,
+## which would substantially impact a high volume consumer's performance.
+##
+## This complicates Cambria server failover, because we often need server
+## A to close its connection before server B brings up the replacement.
+##
+
+## The consumer cache is normally enabled.
+#cambria.consumer.cache.enabled=true
+
+## Cached consumers are cleaned up after a period of disuse. The server inspects
+## consumers every sweepFreqSeconds and will clean up any connections that are
+## dormant for touchFreqMs.
+#cambria.consumer.cache.sweepFreqSeconds=15
+cambria.consumer.cache.touchFreqMs=120000
+##stickforallconsumerrequests=false
+## The cache is managed through ZK. The default value for the ZK connection
+## string is the same as config.zk.servers.
+#cambria.consumer.cache.zkConnect=${config.zk.servers}
+
+##
+## Shared cache information is associated with this node's name. The default
+## name is the hostname plus the HTTP service port this host runs on. (The
+## hostname is determined via InetAddress.getLocalHost ().getCanonicalHostName(),
+## which is not always adequate.) You can set this value explicitly here.
+##
+#cambria.api.node.identifier=<use-something-unique-to-this-instance>
+
+#cambria.rateLimit.maxEmptyPollsPerMinute=30
+#cambria.rateLimitActual.delay.ms=10
+
+###############################################################################
+##
+## Metrics Reporting
+##
+## This server can report its metrics periodically on a topic.
+##
+#metrics.send.cambria.enabled=true
+#metrics.send.cambria.topic=cambria.apinode.metrics #msgrtr.apinode.metrics.dmaap
+#metrics.send.cambria.sendEverySeconds=60
+
+cambria.consumer.cache.zkBasePath=/fe3c/cambria/consumerCache
+consumer.timeout=17
+
+##############################################################################
+#100mb
+maxcontentlength=10000
+
+
+##############################################################################
+#AAF Properties
+msgRtr.namespace.aaf=org.onap.dmaap.mr.topic
+msgRtr.topicfactory.aaf=org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:
+enforced.topic.name.AAF=org.onap.dmaap.mr
+forceAAF=false
+transidUEBtopicreqd=false
+defaultNSforUEB=org.onap.dmaap.mr
+##############################################################################
+#Mirror Maker Agent
+msgRtr.mirrormakeradmin.aaf=org.onap.dmaap.mr.mirrormaker|*|admin
+msgRtr.mirrormakeruser.aaf=org.onap.dmaap.mr.mirrormaker|*|user
+msgRtr.mirrormakeruser.aaf.create=org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:
+msgRtr.mirrormaker.timeout=15000
+msgRtr.mirrormaker.topic=org.onap.dmaap.mr.mmagent
+msgRtr.mirrormaker.consumergroup=mmagentserver
+msgRtr.mirrormaker.consumerid=1
+
+kafka.max.poll.interval.ms=300000
+kafka.heartbeat.interval.ms=60000
+kafka.session.timeout.ms=240000
+kafka.max.poll.records=1000 \ No newline at end of file
diff --git a/src/test/resources/spring-context.xml b/src/test/resources/spring-context.xml
new file mode 100644
index 0000000..717dddf
--- /dev/null
+++ b/src/test/resources/spring-context.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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.
+
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <!-- Dependency Injection with annotations -->
+ <context:component-scan
+ base-package="com.att.nsa.cambria.utils,com.att.nsa.cambria.service.impl,com.att.nsa.cambria.exception" />
+
+ <context:property-placeholder
+ location="classpath:msgRtrApi.properties,classpath:DMaaPErrorMesaages.properties" />
+
+
+ <bean id="propertyReader" class="com.att.nsa.cambria.utils.PropertyReader" />
+ <bean
+ class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+ <!-- Next value is the full qualified name of the static setter including
+ method name -->
+ <property name="staticMethod"
+ value="com.att.nsa.cambria.beans.DMaaPKafkaConsumerFactory.populateKafkaInternalDefaultsMap" />
+ <property name="arguments">
+ <list>
+ <ref bean="propertyReader" />
+ </list>
+ </property>
+ </bean>
+
+ <bean id="drumlinRequestRouter"
+ class="com.att.nsa.drumlin.service.framework.routing.DrumlinRequestRouter" />
+
+ <bean id="dMaaPMetricsSet" class="com.att.nsa.cambria.beans.DMaaPMetricsSet">
+ <constructor-arg ref="propertyReader" />
+ </bean>
+
+ <bean id="dMaaPZkClient" class=" com.att.nsa.cambria.beans.DMaaPZkClient">
+ <constructor-arg ref="propertyReader" />
+ </bean>
+
+ <bean id="dMaaPZkConfigDb" class=" com.att.nsa.cambria.beans.DMaaPZkConfigDb">
+ <constructor-arg ref="dMaaPZkClient" />
+ <constructor-arg ref="propertyReader" />
+ </bean>
+
+ <bean id="kafkaPublisher" class=" com.att.nsa.cambria.backends.kafka.KafkaPublisher">
+ <constructor-arg ref="propertyReader" />
+ </bean>
+
+ <bean id="dMaaPKafkaConsumerFactory" class=" com.att.nsa.cambria.beans.DMaaPKafkaConsumerFactory">
+ <constructor-arg ref="propertyReader" />
+ <constructor-arg ref="dMaaPMetricsSet" />
+ <constructor-arg ref="curator" />
+ </bean>
+
+ <bean id="curator" class="com.att.nsa.cambria.utils.DMaaPCuratorFactory"
+ factory-method="getCurator">
+ <constructor-arg ref="propertyReader" />
+ </bean>
+
+ <bean id="dMaaPKafkaMetaBroker" class=" com.att.nsa.cambria.beans.DMaaPKafkaMetaBroker">
+ <constructor-arg ref="propertyReader" />
+ <constructor-arg ref="dMaaPZkClient" />
+ <constructor-arg ref="dMaaPZkConfigDb" />
+ </bean>
+
+ <!-- <bean id="q" class=" com.att.nsa.cambria.backends.memory.MemoryQueue" />
+
+ <bean id="mmb" class=" com.att.nsa.cambria.backends.memory.MemoryMetaBroker">
+ <constructor-arg ref="q" />
+ <constructor-arg ref="dMaaPZkConfigDb" />
+ <constructor-arg ref="propertyReader" />
+ </bean>
+
+ <bean id="dMaaPNsaApiDb" class="com.att.nsa.cambria.beans.DMaaPNsaApiDb"
+ factory-method="buildApiKeyDb">
+ <constructor-arg ref="propertyReader" />
+ <constructor-arg ref="dMaaPZkConfigDb" />
+ </bean>
+
+ <bean id="dMaaPTranDb" class="com.att.nsa.cambria.transaction.DMaaPTransactionDB"
+ factory-method="buildTransactionDb"> <constructor-arg ref="propertyReader"
+ /> <constructor-arg ref="dMaaPZkConfigDb" /> </bean>
+
+ <bean id="dMaaPAuthenticatorImpl" class="com.att.nsa.cambria.security.DMaaPAuthenticatorImpl">
+ <constructor-arg ref="dMaaPNsaApiDb" />
+ </bean>
+ <bean id="defLength" class="com.att.nsa.filter.DefaultLength">
+ <property name="defaultLength" value="${maxcontentlength}"></property>
+ </bean> -->
+
+ <!-- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="location"> <value>msgRtrApi.properties</value> </property>
+ </bean> -->
+
+</beans> \ No newline at end of file