diff options
-rw-r--r-- | ajsc-shared-config/etc/logback.xml | 46 | ||||
-rw-r--r-- | src/main/ajsc/dmaap_v1/dmaap/v1/conf/FileMonitorBeans.xml | 6 | ||||
-rw-r--r-- | src/main/ajsc/dmaap_v1/dmaap/v1/conf/HelloWorldBeans.xml | 2 | ||||
-rw-r--r-- | src/main/ajsc/dmaap_v1/dmaap/v1/conf/jaxrsBeans.groovy | 20 | ||||
-rw-r--r-- | src/main/ajsc/dmaap_v1/dmaap/v1/conf/serviceBeans.xml | 42 | ||||
-rw-r--r-- | src/main/ajsc/dmaap_v1/dmaap/v1/routes/topicService.route | 4 | ||||
-rw-r--r-- | src/main/config/runner-web.xml | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/DMaaPCambriaExceptionMapper.java (renamed from src/main/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapper.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/DMaaPWebExceptionMapper.java (renamed from src/main/java/com/att/nsa/dmaap/DMaaPWebExceptionMapper.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/HelloWorld.java (renamed from src/main/java/com/att/nsa/dmaap/HelloWorld.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/JaxrsEchoService.java (renamed from src/main/java/com/att/nsa/dmaap/JaxrsEchoService.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/JaxrsUserService.java (renamed from src/main/java/com/att/nsa/dmaap/JaxrsUserService.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/filemonitor/ServicePropertiesListener.java (renamed from src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesListener.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/filemonitor/ServicePropertiesMap.java (renamed from src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesMap.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/filemonitor/ServicePropertyService.java (renamed from src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertyService.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/mmagent/CreateMirrorMaker.java (renamed from src/main/java/com/att/nsa/dmaap/mmagent/CreateMirrorMaker.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/mmagent/MMAgentUtil.java (renamed from src/main/java/com/att/nsa/dmaap/mmagent/MMAgentUtil.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/mmagent/MirrorMaker.java (renamed from src/main/java/com/att/nsa/dmaap/mmagent/MirrorMaker.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/mmagent/UpdateMirrorMaker.java (renamed from src/main/java/com/att/nsa/dmaap/mmagent/UpdateMirrorMaker.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/mmagent/UpdateWhiteList.java (renamed from src/main/java/com/att/nsa/dmaap/mmagent/UpdateWhiteList.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/AdminRestService.java (renamed from src/main/java/com/att/nsa/dmaap/service/AdminRestService.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/ApiKeysRestService.java (renamed from src/main/java/com/att/nsa/dmaap/service/ApiKeysRestService.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/EventsRestService.java (renamed from src/main/java/com/att/nsa/dmaap/service/EventsRestService.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/MMRestService.java (renamed from src/main/java/com/att/nsa/dmaap/service/MMRestService.java) | 4 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/MetricsRestService.java (renamed from src/main/java/com/att/nsa/dmaap/service/MetricsRestService.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/ServiceUtil.java (renamed from src/main/java/com/att/nsa/dmaap/service/ServiceUtil.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/TopicRestService.java (renamed from src/main/java/com/att/nsa/dmaap/service/TopicRestService.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/TransactionRestService.java (renamed from src/main/java/com/att/nsa/dmaap/service/TransactionRestService.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/service/UIRestServices.java (renamed from src/main/java/com/att/nsa/dmaap/service/UIRestServices.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/tools/ConfigTool.java (renamed from src/main/java/com/att/nsa/dmaap/tools/ConfigTool.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/tools/ConfigToolContext.java (renamed from src/main/java/com/att/nsa/dmaap/tools/ConfigToolContext.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/util/ContentLengthInterceptor.java (renamed from src/main/java/com/att/nsa/dmaap/util/ContentLengthInterceptor.java) | 222 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/util/DMaaPAuthFilter.java (renamed from src/main/java/com/att/nsa/dmaap/util/DMaaPAuthFilter.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/dmaap/util/ServicePropertiesMapBean.java (renamed from src/main/java/com/att/nsa/dmaap/util/ServicePropertiesMapBean.java) | 4 | ||||
-rw-r--r-- | src/main/test/com/att/nsa/dmaap/DummyTest.java | 2 | ||||
-rw-r--r-- | src/test/java/com/att/nsa/dmaap/filemonitor/TestRunner.java | 41 | ||||
-rw-r--r-- | src/test/java/com/att/nsa/dmaap/mmagent/TestRunner.java | 41 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/DMaaPCambriaExceptionMapperTest.java (renamed from src/test/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapperTest.java) | 170 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/DMaaPWebExceptionMapperTest.java (renamed from src/test/java/com/att/nsa/dmaap/DMaaPWebExceptionMapperTest.java) | 282 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/DummyTest.java (renamed from src/test/java/com/att/nsa/dmaap/DummyTest.java) | 90 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/HelloWorldTest.java (renamed from src/test/java/com/att/nsa/dmaap/HelloWorldTest.java) | 102 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/JUnitTestSuite.java (renamed from src/test/java/com/att/nsa/dmaap/JUnitTestSuite.java) | 86 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/JaxrsEchoServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/JaxrsEchoServiceTest.java) | 118 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/JaxrsUserServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/JaxrsUserServiceTest.java) | 98 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/TestRunner.java (renamed from src/test/java/com/att/nsa/dmaap/TestRunner.java) | 82 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/filemonitor/JUnitTestSuite.java (renamed from src/test/java/com/att/nsa/dmaap/filemonitor/JUnitTestSuite.java) | 86 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/filemonitor/ServicePropertiesListenerTest.java (renamed from src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesListenerTest.java) | 112 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/filemonitor/ServicePropertiesMapTest.java (renamed from src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesMapTest.java) | 254 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/filemonitor/ServicePropertyServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertyServiceTest.java) | 304 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/filemonitor/TestRunner.java (renamed from src/test/java/com/att/nsa/dmaap/util/TestRunner.java) | 82 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/mmagent/CreateMirrorMakerTest.java (renamed from src/test/java/com/att/nsa/dmaap/mmagent/CreateMirrorMakerTest.java) | 162 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/mmagent/JUnitTestSuite.java (renamed from src/test/java/com/att/nsa/dmaap/mmagent/JUnitTestSuite.java) | 86 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/mmagent/MirrorMakerTest.java (renamed from src/test/java/com/att/nsa/dmaap/mmagent/MirrorMakerTest.java) | 282 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/mmagent/TestRunner.java (renamed from src/test/java/com/att/nsa/dmaap/tools/TestRunner.java) | 82 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/mmagent/UpdateMirrorMakerTest.java (renamed from src/test/java/com/att/nsa/dmaap/mmagent/UpdateMirrorMakerTest.java) | 160 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/mmagent/UpdateWhiteListTest.java (renamed from src/test/java/com/att/nsa/dmaap/mmagent/UpdateWhiteListTest.java) | 168 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/AdminRestServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/service/AdminRestServiceTest.java) | 588 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/ApiKeysRestServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/service/ApiKeysRestServiceTest.java) | 462 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/EventsRestServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/service/EventsRestServiceTest.java) | 656 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/JUnitTestSuite.java (renamed from src/test/java/com/att/nsa/dmaap/service/JUnitTestSuite.java) | 88 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/MMRestServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/service/MMRestServiceTest.java) | 768 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/MetricsRestServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/service/MetricsRestServiceTest.java) | 146 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/TestRunner.java (renamed from src/test/java/com/att/nsa/dmaap/service/TestRunner.java) | 82 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/service/TopicRestServiceTest.java) | 1676 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/TransactionRestServiceTest.java (renamed from src/test/java/com/att/nsa/dmaap/service/TransactionRestServiceTest.java) | 244 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/service/UIRestServicesTest.java (renamed from src/test/java/com/att/nsa/dmaap/service/UIRestServicesTest.java) | 282 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/tools/ConfigToolContextTest.java (renamed from src/test/java/com/att/nsa/dmaap/tools/ConfigToolContextTest.java) | 170 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/tools/ConfigToolTest.java (renamed from src/test/java/com/att/nsa/dmaap/tools/ConfigToolTest.java) | 1044 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/tools/JUnitTestSuite.java (renamed from src/test/java/com/att/nsa/dmaap/tools/JUnitTestSuite.java) | 84 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/tools/TestRunner.java | 41 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/util/ContentLengthInterceptorTest.java (renamed from src/test/java/com/att/nsa/dmaap/util/ContentLengthInterceptorTest.java) | 184 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/util/DMaaPAuthFilterTest.java (renamed from src/test/java/com/att/nsa/dmaap/util/DMaaPAuthFilterTest.java) | 198 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/util/JUnitTestSuite.java (renamed from src/test/java/com/att/nsa/dmaap/util/JUnitTestSuite.java) | 84 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/util/ServicePropertiesMapBeanTest.java (renamed from src/test/java/com/att/nsa/dmaap/util/ServicePropertiesMapBeanTest.java) | 104 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/util/TestRunner.java | 41 |
75 files changed, 5119 insertions, 5115 deletions
diff --git a/ajsc-shared-config/etc/logback.xml b/ajsc-shared-config/etc/logback.xml index 4ea6385..ffedde7 100644 --- a/ajsc-shared-config/etc/logback.xml +++ b/ajsc-shared-config/etc/logback.xml @@ -109,48 +109,48 @@ <!-- Msgrtr related loggers --> - <logger name="com.att.dmf.mr.service" level="INFO" /> - <logger name="com.att.dmf.mr.service.impl" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.service" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.service.impl" level="INFO" /> - <logger name="com.att.dmf.mr.resources" level="INFO" /> - <logger name="com.att.dmf.mr.resources.streamReaders" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.resources" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.resources.streamReaders" level="INFO" /> - <logger name="com.att.dmf.mr.backends" level="INFO" /> - <logger name="com.att.dmf.mr.backends.kafka" level="INFO" /> - <logger name="com.att.dmf.mr.backends.memory" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.backends" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.backends.kafka" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.backends.memory" level="INFO" /> - <logger name="com.att.dmf.mr.beans" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.beans" level="INFO" /> - <logger name="com.att.dmf.mr.constants" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.constants" level="INFO" /> - <logger name="com.att.dmf.mr.exception" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.exception" level="INFO" /> - <logger name="com.att.dmf.mr.listener" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.listener" level="INFO" /> - <logger name="com.att.dmf.mr.metabroker" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.metabroker" level="INFO" /> - <logger name="com.att.dmf.mr.metrics.publisher" level="INFO" /> - <logger name="com.att.dmf.mr.metrics.publisher.impl" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.metrics.publisher" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.metrics.publisher.impl" level="INFO" /> - <logger name="com.att.dmf.mr.security" level="INFO" /> - <logger name="com.att.dmf.mr.security.impl" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.security" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.security.impl" level="INFO" /> - <logger name="com.att.dmf.mr.transaction" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.transaction" level="INFO" /> <logger name="com.att.dmf.mr.transaction.impl" level="INFO" /> - <logger name="com.att.dmf.mr.metabroker" level="INFO" /> - <logger name="com.att.dmf.mr.metabroker" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.metabroker" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.metabroker" level="INFO" /> - <logger name="com.att.dmf.mr.utils" level="INFO" /> - <logger name="com.att.mr.filter" level="INFO" /> + <logger name="org.onap.dmaap.dmf.mr.utils" level="INFO" /> + <logger name="org.onap.dmaap.mr.filter" level="INFO" /> <!--<logger name="com.att.nsa.cambria.*" level="INFO" />--> <!-- Msgrtr loggers in ajsc --> - <logger name="com.att.nsa.dmaap.service" level="INFO" /> - <logger name="com.att.nsa.dmaap" level="INFO" /> + <logger name="org.onap.dmaap.service" level="INFO" /> + <logger name="org.onap.dmaap" level="INFO" /> <!-- Spring related loggers --> diff --git a/src/main/ajsc/dmaap_v1/dmaap/v1/conf/FileMonitorBeans.xml b/src/main/ajsc/dmaap_v1/dmaap/v1/conf/FileMonitorBeans.xml index a2c393c..cf25ab5 100644 --- a/src/main/ajsc/dmaap_v1/dmaap/v1/conf/FileMonitorBeans.xml +++ b/src/main/ajsc/dmaap_v1/dmaap/v1/conf/FileMonitorBeans.xml @@ -5,11 +5,11 @@ <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" /> - <bean id="ServicePropertiesListener" class="com.att.nsa.dmaap.filemonitor.ServicePropertiesListener" /> + <bean id="ServicePropertiesListener" class="org.onap.dmaap.filemonitor.ServicePropertiesListener" /> - <bean id="ServicePropertiesMap" class="com.att.nsa.dmaap.filemonitor.ServicePropertiesMap" /> + <bean id="ServicePropertiesMap" class="org.onap.dmaap.filemonitor.ServicePropertiesMap" /> - <bean id="ServicePropertyService" class="com.att.nsa.dmaap.filemonitor.ServicePropertyService"> + <bean id="ServicePropertyService" class="org.onap.dmaap.filemonitor.ServicePropertyService"> <property name="loadOnStartup" value="false" /> <property name="fileChangedListener" ref="ServicePropertiesListener" /> <property name="filePropertiesMap" ref="ServicePropertiesMap" /> diff --git a/src/main/ajsc/dmaap_v1/dmaap/v1/conf/HelloWorldBeans.xml b/src/main/ajsc/dmaap_v1/dmaap/v1/conf/HelloWorldBeans.xml index 9cb67d4..04db236 100644 --- a/src/main/ajsc/dmaap_v1/dmaap/v1/conf/HelloWorldBeans.xml +++ b/src/main/ajsc/dmaap_v1/dmaap/v1/conf/HelloWorldBeans.xml @@ -4,5 +4,5 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="helloWorld" name="helloWorld" - class="com.att.nsa.dmaap.HelloWorld" /> + class="org.onap.dmaap.HelloWorld" /> </beans> diff --git a/src/main/ajsc/dmaap_v1/dmaap/v1/conf/jaxrsBeans.groovy b/src/main/ajsc/dmaap_v1/dmaap/v1/conf/jaxrsBeans.groovy index 430e723..b019fbc 100644 --- a/src/main/ajsc/dmaap_v1/dmaap/v1/conf/jaxrsBeans.groovy +++ b/src/main/ajsc/dmaap_v1/dmaap/v1/conf/jaxrsBeans.groovy @@ -3,16 +3,16 @@ xmlns jaxrs: "http://cxf.apache.org/jaxrs" xmlns util: "http://www.springframework.org/schema/util" - echoService(com.att.nsa.dmaap.JaxrsEchoService) - userService(com.att.nsa.dmaap.JaxrsUserService) - topicService(com.att.nsa.dmaap.service.TopicRestService) - eventService(com.att.nsa.dmaap.service.EventsRestService) - adminService(com.att.nsa.dmaap.service.AdminRestService) - apiKeyService(com.att.nsa.dmaap.service.ApiKeysRestService) - metricsService(com.att.nsa.dmaap.service.MetricsRestService) - transactionService(com.att.nsa.dmaap.service.TransactionRestService) - UIService(com.att.nsa.dmaap.service.UIRestServices) - mirrorService(com.att.nsa.dmaap.service.MMRestService) + echoService(org.onap.dmaap.JaxrsEchoService) + userService(org.onap.dmaap.JaxrsUserService) + topicService(org.onap.dmaap.service.TopicRestService) + eventService(org.onap.dmaap.service.EventsRestService) + adminServiceorg.onap.dmaap.service.AdminRestService) + apiKeyService(org.onap.dmaap.service.ApiKeysRestService) + metricsService(org.onap.dmaap.service.MetricsRestService) + transactionService(org.onap.dmaap.service.TransactionRestService) + UIService(org.onap.dmaap.service.UIRestServices) + mirrorService(org.onap.dmaap.service.MMRestService) util.list(id: 'jaxrsServices') { ref(bean:'echoService') diff --git a/src/main/ajsc/dmaap_v1/dmaap/v1/conf/serviceBeans.xml b/src/main/ajsc/dmaap_v1/dmaap/v1/conf/serviceBeans.xml index 0210d06..090a76b 100644 --- a/src/main/ajsc/dmaap_v1/dmaap/v1/conf/serviceBeans.xml +++ b/src/main/ajsc/dmaap_v1/dmaap/v1/conf/serviceBeans.xml @@ -13,7 +13,11 @@ location="classpath:msgRtrApi.properties,classpath:DMaaPErrorMesaages.properties" /> --> <context:component-scan - base-package="com.att,com.att.dmf.mr.utils, com.att.dmf.mr, com.att.dmf.mr.rest,com.att.dmf.mr.service, + base-package="org.onap.dmaap,org.onap.dmaap.filemonitor,org.onap.dmaap.mmagent,org.onap.dmaap.service,org.onap.dmaap.tools,org.onap.dmaap.util,org.onap.dmaap.filter,org.onap.dmaap.apiServer.metrics.cambria, + org.onap.dmaap.dmf.mr,org.onap.dmaap.dmf.mr.backends,org.onap.dmaap.dmf.mr.backends.kafka,org.onap.dmaap.dmf.mr.backends.memory,org.onap.dmaap.dmf.mr.beans,org.onap.dmaap.dmf.mr.constants,org.onap.dmaap.dmf.mr.exception, + org.onap.dmaap.dmf.mr.listener,org.onap.dmaap.dmf.mr.metabroker,org.onap.dmaap.dmf.mr.metrics.publisher,org.onap.dmaap.dmf.mr.metrics.publisher.impl,org.onap.dmaap.dmf.mr.resources,org.onap.dmaap.dmf.mr.resources.streamReaders,org.onap.dmaap.dmf.mr.security, + org.onap.dmaap.dmf.mr.security.impl,org.onap.dmaap.dmf.mr.service,org.onap.dmaap.dmf.mr.service.impl,org.onap.dmaap.dmf.mr.transaction,org.onap.dmaap.dmf.mr.transaction.impl,org.onap.dmaap.dmf.mr.utils, + com.att,com.att.dmf.mr.utils, com.att.dmf.mr, com.att.dmf.mr.rest,com.att.dmf.mr.service, com.att.dmf.mr.service.impl,com.att.dmf.mr.beans,com.att.dmf.mr.security,com.att.dmf.mr.exception,com.att.dmf.mr.backends,com.att.dmf.mr.backends.kafka, com.att.dmf.mr.transaction,com.att.dmf.mr.exception,com.att.nsa.dmaap,com.att.nsa.dmaap.service,com.att.nsa.dmaap.util,java.lang,java.util,com.att.dmf.mr.exception, com.att.dmf,com.att.nsa.dmaap.mmagent" /> <context:property-placeholder @@ -26,25 +30,25 @@ <bean id="jacksonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider" /> - <bean id="cambriaExMapper" class="com.att.nsa.dmaap.DMaaPCambriaExceptionMapper" /> + <bean id="cambriaExMapper" class="org.onap.dmaap.DMaaPCambriaExceptionMapper" /> - <bean id="webExMapper" class="com.att.nsa.dmaap.DMaaPWebExceptionMapper" /> + <bean id="webExMapper" class="org.onap.dmaap.DMaaPWebExceptionMapper" /> <!-- Your bean definitions goes here --> <!-- <bean id="performanceLog" name="performanceLog" class="com.att.ajsc.csi.logging.PerformanceTracking" /> --> <!-- <bean id="processRestletHeaders" name="processRestletHeaders" class="ajsc.restlet.ProcessRestletHeaders" /> --> <bean id="servicePropsBean" name="servicePropsBean" - class="com.att.nsa.dmaap.util.ServicePropertiesMapBean" /> + class="org.onap.dmaap.util.ServicePropertiesMapBean" /> <!-- Msgrtr beans --> - <bean id="propertyReader" class="com.att.dmf.mr.utils.PropertyReader" /> + <bean id="propertyReader" class="org.onap.dmaap.dmf.mr.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.dmf.mr.beans.DMaaPKafkaConsumerFactory.populateKafkaInternalDefaultsMap" /> + value="org.onap.dmaap.dmf.mr.beans.DMaaPKafkaConsumerFactory.populateKafkaInternalDefaultsMap" /> <!-- <property name="arguments"> <list> <ref bean="propertyReader" /> @@ -55,21 +59,21 @@ <bean id="drumlinRequestRouter" class="com.att.nsa.drumlin.service.framework.routing.DrumlinRequestRouter" /> - <bean id="dMaaPMetricsSet" class="com.att.dmf.mr.beans.DMaaPMetricsSet"> + <bean id="dMaaPMetricsSet" class="org.onap.dmaap.dmf.mr.beans.DMaaPMetricsSet"> <constructor-arg ref="propertyReader" /> </bean> - <bean id="dMaaPZkClient" class=" com.att.dmf.mr.beans.DMaaPZkClient"> + <bean id="dMaaPZkClient" class=" org.onap.dmaap.dmf.mr.beans.DMaaPZkClient"> <constructor-arg ref="propertyReader" /> </bean> - <bean id="dMaaPZkConfigDb" class="com.att.dmf.mr.beans.DMaaPZkConfigDb"> + <bean id="dMaaPZkConfigDb" class="org.onap.dmaap.dmf.mr.beans.DMaaPZkConfigDb"> <constructor-arg ref="dMaaPZkClient" /> <constructor-arg ref="propertyReader" /> </bean> - <bean id="kafkaPublisher" class=" com.att.dmf.mr.backends.kafka.KafkaPublisher"> + <bean id="kafkaPublisher" class="org.onap.dmaap.dmf.mr.backends.kafka.KafkaPublisher"> <constructor-arg ref="propertyReader" /> </bean> @@ -79,33 +83,33 @@ <constructor-arg ref="kafkalockavoid" /> </bean> --> - <bean id="dMaaPKafkaConsumerFactory" class=" com.att.dmf.mr.beans.DMaaPKafkaConsumerFactory"> + <bean id="dMaaPKafkaConsumerFactory" class="org.onap.dmaap.dmf.mr.beans.DMaaPKafkaConsumerFactory"> <constructor-arg ref="dMaaPMetricsSet" /> <constructor-arg ref="curator" /> <constructor-arg ref="kafkalockavoid" /> </bean> - <bean id="curator" class="com.att.dmf.mr.utils.DMaaPCuratorFactory" + <bean id="curator" class="org.onap.dmaap.dmf.mr.utils.DMaaPCuratorFactory" factory-method="getCurator"> <constructor-arg ref="propertyReader" /> </bean> - <bean id="dMaaPKafkaMetaBroker" class=" com.att.dmf.mr.beans.DMaaPKafkaMetaBroker"> + <bean id="dMaaPKafkaMetaBroker" class="org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker"> <constructor-arg ref="propertyReader" /> <constructor-arg ref="dMaaPZkClient" /> <constructor-arg ref="dMaaPZkConfigDb" /> </bean> - <bean id="q" class=" com.att.dmf.mr.backends.memory.MemoryQueue" /> + <bean id="q" class="org.onap.dmaap.dmf.mr.backends.memory.MemoryQueue" /> - <bean id="mmb" class=" com.att.dmf.mr.backends.memory.MemoryMetaBroker"> + <bean id="mmb" class="org.onap.dmaap.dmf.mr.backends.memory.MemoryMetaBroker"> <constructor-arg ref="q" /> <constructor-arg ref="dMaaPZkConfigDb" /> <!-- <constructor-arg ref="propertyReader" />--> </bean> - <bean id="dMaaPNsaApiDb" class="com.att.dmf.mr.beans.DMaaPNsaApiDb" + <bean id="dMaaPNsaApiDb" class="org.onap.dmaap.dmf.mr.beans.DMaaPNsaApiDb" factory-method="buildApiKeyDb"> <constructor-arg ref="propertyReader" /> <constructor-arg ref="dMaaPZkConfigDb" /> @@ -115,14 +119,14 @@ factory-method="buildTransactionDb"> <constructor-arg ref="propertyReader" /> <constructor-arg ref="dMaaPZkConfigDb" /> </bean> --> - <bean id="dMaaPAuthenticatorImpl" class="com.att.dmf.mr.security.DMaaPAuthenticatorImpl"> + <bean id="dMaaPAuthenticatorImpl" class="org.onap.dmaap.dmf.mr.security.DMaaPAuthenticatorImpl"> <constructor-arg ref="dMaaPNsaApiDb" /> </bean> - <bean id="defLength" class="com.att.mr.filter.DefaultLength"> + <bean id="defLength" class="org.onap.dmaap.mr.filter.DefaultLength"> <property name="defaultLength" value="${maxcontentlength}"></property> </bean> - <bean id="kafkalockavoid" class="com.att.dmf.mr.backends.kafka.KafkaLiveLockAvoider2" /> + <bean id="kafkalockavoid" class="org.onap.dmaap.dmf.mr.backends.kafka.KafkaLiveLockAvoider2" /> <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/> diff --git a/src/main/ajsc/dmaap_v1/dmaap/v1/routes/topicService.route b/src/main/ajsc/dmaap_v1/dmaap/v1/routes/topicService.route index 57a8a70..b1073d8 100644 --- a/src/main/ajsc/dmaap_v1/dmaap/v1/routes/topicService.route +++ b/src/main/ajsc/dmaap_v1/dmaap/v1/routes/topicService.route @@ -10,8 +10,8 @@ <removeHeader headerName="exception"/> -<log message="Body= ** ${body}" loggingLevel="DEBUG" logName="com.att.nsa.dmaap"/> -<log message="Body= ** ${body}" loggingLevel="DEBUG" logName="com.att.nsa.dmaap.service"/> +<log message="Body= ** ${body}" loggingLevel="DEBUG" logName="org.onap.dmaap"/> +<log message="Body= ** ${body}" loggingLevel="DEBUG" logName="org.onap.dmaap.service"/> </route> diff --git a/src/main/config/runner-web.xml b/src/main/config/runner-web.xml index 2bcf11d..d86fa5e 100644 --- a/src/main/config/runner-web.xml +++ b/src/main/config/runner-web.xml @@ -69,7 +69,7 @@ <filter> <display-name>DMaaPAuthFilter</display-name> <filter-name>DMaaPAuthFilter</filter-name> - <filter-class>com.att.nsa.dmaap.util.DMaaPAuthFilter</filter-class> + <filter-class>org.onap.dmaap.util.DMaaPAuthFilter</filter-class> <init-param> <param-name>cadi_prop_files</param-name> <param-value>/appl/dmaapMR1/etc/cadi.properties </param-value> diff --git a/src/main/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapper.java b/src/main/java/org/onap/dmaap/DMaaPCambriaExceptionMapper.java index 5408d62..4b9324e 100644 --- a/src/main/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapper.java +++ b/src/main/java/org/onap/dmaap/DMaaPCambriaExceptionMapper.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap; + package org.onap.dmaap; import javax.inject.Singleton; diff --git a/src/main/java/com/att/nsa/dmaap/DMaaPWebExceptionMapper.java b/src/main/java/org/onap/dmaap/DMaaPWebExceptionMapper.java index a59f8ca..389fb5c 100644 --- a/src/main/java/com/att/nsa/dmaap/DMaaPWebExceptionMapper.java +++ b/src/main/java/org/onap/dmaap/DMaaPWebExceptionMapper.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap; + package org.onap.dmaap; import javax.inject.Singleton; diff --git a/src/main/java/com/att/nsa/dmaap/HelloWorld.java b/src/main/java/org/onap/dmaap/HelloWorld.java index a4cccba..5907e7f 100644 --- a/src/main/java/com/att/nsa/dmaap/HelloWorld.java +++ b/src/main/java/org/onap/dmaap/HelloWorld.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap; + package org.onap.dmaap; import org.apache.camel.Exchange; diff --git a/src/main/java/com/att/nsa/dmaap/JaxrsEchoService.java b/src/main/java/org/onap/dmaap/JaxrsEchoService.java index 72416da..1bebaf8 100644 --- a/src/main/java/com/att/nsa/dmaap/JaxrsEchoService.java +++ b/src/main/java/org/onap/dmaap/JaxrsEchoService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap; + package org.onap.dmaap; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -31,7 +31,7 @@ import com.att.eelf.configuration.EELFManager; import com.att.ajsc.beans.PropertiesMapBean; -import com.att.nsa.dmaap.filemonitor.ServicePropertiesMap; +import org.onap.dmaap.filemonitor.ServicePropertiesMap; /** * Example JAX-RS Service diff --git a/src/main/java/com/att/nsa/dmaap/JaxrsUserService.java b/src/main/java/org/onap/dmaap/JaxrsUserService.java index 0631a13..714a9c1 100644 --- a/src/main/java/com/att/nsa/dmaap/JaxrsUserService.java +++ b/src/main/java/org/onap/dmaap/JaxrsUserService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap; + package org.onap.dmaap; import javax.ws.rs.GET; import javax.ws.rs.Path; diff --git a/src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesListener.java b/src/main/java/org/onap/dmaap/filemonitor/ServicePropertiesListener.java index edbdadf..56cccca 100644 --- a/src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesListener.java +++ b/src/main/java/org/onap/dmaap/filemonitor/ServicePropertiesListener.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.filemonitor; + package org.onap.dmaap.filemonitor; import java.io.File; diff --git a/src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesMap.java b/src/main/java/org/onap/dmaap/filemonitor/ServicePropertiesMap.java index 219a601..27cf0a2 100644 --- a/src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesMap.java +++ b/src/main/java/org/onap/dmaap/filemonitor/ServicePropertiesMap.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.filemonitor; + package org.onap.dmaap.filemonitor; import java.util.HashMap; diff --git a/src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertyService.java b/src/main/java/org/onap/dmaap/filemonitor/ServicePropertyService.java index 55c1661..fe25e58 100644 --- a/src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertyService.java +++ b/src/main/java/org/onap/dmaap/filemonitor/ServicePropertyService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.filemonitor; + package org.onap.dmaap.filemonitor; import java.io.File; import java.io.FileInputStream; diff --git a/src/main/java/com/att/nsa/dmaap/mmagent/CreateMirrorMaker.java b/src/main/java/org/onap/dmaap/mmagent/CreateMirrorMaker.java index 35b4f03..72df46f 100644 --- a/src/main/java/com/att/nsa/dmaap/mmagent/CreateMirrorMaker.java +++ b/src/main/java/org/onap/dmaap/mmagent/CreateMirrorMaker.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.mmagent; + package org.onap.dmaap.mmagent; import java.util.Date; diff --git a/src/main/java/com/att/nsa/dmaap/mmagent/MMAgentUtil.java b/src/main/java/org/onap/dmaap/mmagent/MMAgentUtil.java index 8b1ec3f..f2ddaed 100644 --- a/src/main/java/com/att/nsa/dmaap/mmagent/MMAgentUtil.java +++ b/src/main/java/org/onap/dmaap/mmagent/MMAgentUtil.java @@ -22,7 +22,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.mmagent; + package org.onap.dmaap.mmagent; import java.io.IOException; import java.io.InputStream; diff --git a/src/main/java/com/att/nsa/dmaap/mmagent/MirrorMaker.java b/src/main/java/org/onap/dmaap/mmagent/MirrorMaker.java index e3f688e..480c40f 100644 --- a/src/main/java/com/att/nsa/dmaap/mmagent/MirrorMaker.java +++ b/src/main/java/org/onap/dmaap/mmagent/MirrorMaker.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.mmagent; + package org.onap.dmaap.mmagent; public class MirrorMaker { public String name; diff --git a/src/main/java/com/att/nsa/dmaap/mmagent/UpdateMirrorMaker.java b/src/main/java/org/onap/dmaap/mmagent/UpdateMirrorMaker.java index 6e7a0f3..1c2f32c 100644 --- a/src/main/java/com/att/nsa/dmaap/mmagent/UpdateMirrorMaker.java +++ b/src/main/java/org/onap/dmaap/mmagent/UpdateMirrorMaker.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.mmagent; + package org.onap.dmaap.mmagent; import java.util.Date; diff --git a/src/main/java/com/att/nsa/dmaap/mmagent/UpdateWhiteList.java b/src/main/java/org/onap/dmaap/mmagent/UpdateWhiteList.java index a1064a4..dc67298 100644 --- a/src/main/java/com/att/nsa/dmaap/mmagent/UpdateWhiteList.java +++ b/src/main/java/org/onap/dmaap/mmagent/UpdateWhiteList.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.mmagent; + package org.onap.dmaap.mmagent; public class UpdateWhiteList { diff --git a/src/main/java/com/att/nsa/dmaap/service/AdminRestService.java b/src/main/java/org/onap/dmaap/service/AdminRestService.java index d2bf081..61f6a08 100644 --- a/src/main/java/com/att/nsa/dmaap/service/AdminRestService.java +++ b/src/main/java/org/onap/dmaap/service/AdminRestService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import java.io.IOException; import java.util.Enumeration; diff --git a/src/main/java/com/att/nsa/dmaap/service/ApiKeysRestService.java b/src/main/java/org/onap/dmaap/service/ApiKeysRestService.java index d44d259..49eddd9 100644 --- a/src/main/java/com/att/nsa/dmaap/service/ApiKeysRestService.java +++ b/src/main/java/org/onap/dmaap/service/ApiKeysRestService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import java.io.IOException; diff --git a/src/main/java/com/att/nsa/dmaap/service/EventsRestService.java b/src/main/java/org/onap/dmaap/service/EventsRestService.java index cd28967..2672261 100644 --- a/src/main/java/com/att/nsa/dmaap/service/EventsRestService.java +++ b/src/main/java/org/onap/dmaap/service/EventsRestService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import java.io.IOException; import java.io.InputStream; diff --git a/src/main/java/com/att/nsa/dmaap/service/MMRestService.java b/src/main/java/org/onap/dmaap/service/MMRestService.java index 853c9ba..fc3c9a1 100644 --- a/src/main/java/com/att/nsa/dmaap/service/MMRestService.java +++ b/src/main/java/org/onap/dmaap/service/MMRestService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import java.io.IOException; import java.io.InputStream; @@ -46,7 +46,7 @@ import org.onap.dmaap.dmf.mr.utils.ConfigurationReader; import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder; import org.onap.dmaap.dmf.mr.utils.Utils; import com.att.nsa.configs.ConfigDbException; -import com.att.nsa.dmaap.mmagent.*; +import org.onap.dmaap.mmagent.*; import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting; import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException; import com.google.gson.Gson; diff --git a/src/main/java/com/att/nsa/dmaap/service/MetricsRestService.java b/src/main/java/org/onap/dmaap/service/MetricsRestService.java index 8ff58f3..0a9193b 100644 --- a/src/main/java/com/att/nsa/dmaap/service/MetricsRestService.java +++ b/src/main/java/org/onap/dmaap/service/MetricsRestService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import java.io.IOException; diff --git a/src/main/java/com/att/nsa/dmaap/service/ServiceUtil.java b/src/main/java/org/onap/dmaap/service/ServiceUtil.java index d73bcaf..7384e54 100644 --- a/src/main/java/com/att/nsa/dmaap/service/ServiceUtil.java +++ b/src/main/java/org/onap/dmaap/service/ServiceUtil.java @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import org.onap.dmaap.dmf.mr.beans.DMaaPContext; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/com/att/nsa/dmaap/service/TopicRestService.java b/src/main/java/org/onap/dmaap/service/TopicRestService.java index 42049d2..bbf2708 100644 --- a/src/main/java/com/att/nsa/dmaap/service/TopicRestService.java +++ b/src/main/java/org/onap/dmaap/service/TopicRestService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import java.io.IOException; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/com/att/nsa/dmaap/service/TransactionRestService.java b/src/main/java/org/onap/dmaap/service/TransactionRestService.java index 9354f5c..8b806b0 100644 --- a/src/main/java/com/att/nsa/dmaap/service/TransactionRestService.java +++ b/src/main/java/org/onap/dmaap/service/TransactionRestService.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import java.io.IOException; diff --git a/src/main/java/com/att/nsa/dmaap/service/UIRestServices.java b/src/main/java/org/onap/dmaap/service/UIRestServices.java index f82d0a1..bca64c4 100644 --- a/src/main/java/com/att/nsa/dmaap/service/UIRestServices.java +++ b/src/main/java/org/onap/dmaap/service/UIRestServices.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.service; + package org.onap.dmaap.service; import java.io.IOException; diff --git a/src/main/java/com/att/nsa/dmaap/tools/ConfigTool.java b/src/main/java/org/onap/dmaap/tools/ConfigTool.java index d896bdd..2531318 100644 --- a/src/main/java/com/att/nsa/dmaap/tools/ConfigTool.java +++ b/src/main/java/org/onap/dmaap/tools/ConfigTool.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.tools; + package org.onap.dmaap.tools; import java.io.IOException; import java.io.PrintStream; diff --git a/src/main/java/com/att/nsa/dmaap/tools/ConfigToolContext.java b/src/main/java/org/onap/dmaap/tools/ConfigToolContext.java index f61d179..0e89098 100644 --- a/src/main/java/com/att/nsa/dmaap/tools/ConfigToolContext.java +++ b/src/main/java/org/onap/dmaap/tools/ConfigToolContext.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.tools; + package org.onap.dmaap.tools; import org.onap.dmaap.dmf.mr.beans.DMaaPMetricsSet; import com.att.nsa.cmdtool.CommandContext; diff --git a/src/main/java/com/att/nsa/dmaap/util/ContentLengthInterceptor.java b/src/main/java/org/onap/dmaap/util/ContentLengthInterceptor.java index 4ddc54a..b03eb5b 100644 --- a/src/main/java/com/att/nsa/dmaap/util/ContentLengthInterceptor.java +++ b/src/main/java/org/onap/dmaap/util/ContentLengthInterceptor.java @@ -19,120 +19,120 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.util;
-
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.apache.http.HttpStatus;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.springframework.stereotype.Component;
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import org.onap.dmaap.dmf.mr.exception.DMaaPResponseCode;
-import org.onap.dmaap.dmf.mr.exception.ErrorResponse;
-import ajsc.beans.interceptors.AjscInterceptor;
-
-/**
- * AJSC Intercepter implementation of ContentLengthFilter
- */
-@Component
-public class ContentLengthInterceptor implements AjscInterceptor{
-
-
- private String defLength;
- //private Logger log = Logger.getLogger(ContentLengthInterceptor.class.toString());
- private static final EELFLogger log = EELFManager.getInstance().getLogger(ContentLengthInterceptor.class);
-
-
- /**
- * Intercepter method to intercept requests before processing
- */
- @Override
- public boolean allowOrReject(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse,
- Map map) throws Exception {
-
- log.info("inside Interceptor allowOrReject content length checking before pub/sub");
-
- JSONObject jsonObj = null;
- int requestLength = 0;
- setDefLength(System.getProperty("maxcontentlength"));
- try {
- // retrieving content length from message header
-
- if (null != httpservletrequest.getHeader("Content-Length")) {
- requestLength = Integer.parseInt(httpservletrequest.getHeader("Content-Length"));
- }
- // retrieving encoding from message header
- String transferEncoding = httpservletrequest.getHeader("Transfer-Encoding");
- // checking for no encoding, chunked and requestLength greater then
- // default length
- if (null != transferEncoding && !(transferEncoding.contains("chunked"))
- && (requestLength > Integer.parseInt(getDefLength()))) {
- jsonObj = new JSONObject().append("defaultlength", getDefLength())
- .append("requestlength", requestLength);
- log.error("message length is greater than default");
- throw new CambriaApiException(jsonObj);
- }
- else if (null == transferEncoding && (requestLength > Integer.parseInt(getDefLength())))
- {
- jsonObj = new JSONObject().append("defaultlength", getDefLength()).append(
- "requestlength", requestLength);
- log.error("Request message is not chunked or request length is greater than default length");
- throw new CambriaApiException(jsonObj);
-
-
- }
- else
- {
- //chain.doFilter(req, res);
- return true;
- }
-
- } catch (CambriaApiException | NumberFormatException | JSONException e) {
-
- log.info("Exception obj--"+e);
+ package org.onap.dmaap.util; + +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.http.HttpStatus; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.stereotype.Component; +import org.onap.dmaap.dmf.mr.CambriaApiException; +import org.onap.dmaap.dmf.mr.exception.DMaaPResponseCode; +import org.onap.dmaap.dmf.mr.exception.ErrorResponse; +import ajsc.beans.interceptors.AjscInterceptor; + +/** + * AJSC Intercepter implementation of ContentLengthFilter + */ +@Component +public class ContentLengthInterceptor implements AjscInterceptor{ + + + private String defLength; + //private Logger log = Logger.getLogger(ContentLengthInterceptor.class.toString()); + private static final EELFLogger log = EELFManager.getInstance().getLogger(ContentLengthInterceptor.class); + + + /** + * Intercepter method to intercept requests before processing + */ + @Override + public boolean allowOrReject(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, + Map map) throws Exception { + + log.info("inside Interceptor allowOrReject content length checking before pub/sub"); + + JSONObject jsonObj = null; + int requestLength = 0; + setDefLength(System.getProperty("maxcontentlength")); + try { + // retrieving content length from message header + + if (null != httpservletrequest.getHeader("Content-Length")) { + requestLength = Integer.parseInt(httpservletrequest.getHeader("Content-Length")); + } + // retrieving encoding from message header + String transferEncoding = httpservletrequest.getHeader("Transfer-Encoding"); + // checking for no encoding, chunked and requestLength greater then + // default length + if (null != transferEncoding && !(transferEncoding.contains("chunked")) + && (requestLength > Integer.parseInt(getDefLength()))) { + jsonObj = new JSONObject().append("defaultlength", getDefLength()) + .append("requestlength", requestLength); + log.error("message length is greater than default"); + throw new CambriaApiException(jsonObj); + } + else if (null == transferEncoding && (requestLength > Integer.parseInt(getDefLength()))) + { + jsonObj = new JSONObject().append("defaultlength", getDefLength()).append( + "requestlength", requestLength); + log.error("Request message is not chunked or request length is greater than default length"); + throw new CambriaApiException(jsonObj); + + + } + else + { + //chain.doFilter(req, res); + return true; + } + + } catch (CambriaApiException | NumberFormatException | JSONException e) { + + log.info("Exception obj--"+e); log.error("message size is greater then default"+e.getMessage()); String messg=e.toString(); if(jsonObj!=null){ messg=jsonObj.toString(); - }
- ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_REQUEST_TOO_LONG,
- DMaaPResponseCode.MSG_SIZE_EXCEEDS_MSG_LIMIT.getResponseCode(), System.getProperty("msg_size_exceeds")
- + messg);
- log.info(errRes.toString());
-
-
- map.put(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"test");
+ } + ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_REQUEST_TOO_LONG, + DMaaPResponseCode.MSG_SIZE_EXCEEDS_MSG_LIMIT.getResponseCode(), System.getProperty("msg_size_exceeds") + + messg); + log.info(errRes.toString()); + + + map.put(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"test"); httpservletresponse.setStatus(HttpStatus.SC_REQUEST_TOO_LONG); - if(httpservletresponse.getOutputStream()!=null){
+ if(httpservletresponse.getOutputStream()!=null){ httpservletresponse.getOutputStream().write(errRes.toString().getBytes()); - }
- return false;
- }
-
-
-
- }
-
-
- /**
- * Get Default Content Length
- * @return defLength
- */
- public String getDefLength() {
- return defLength;
- }
- /**
- * Set Default Content Length
- * @param defLength
- */
- public void setDefLength(String defLength) {
- this.defLength = defLength;
- }
-
-
-
-}
+ } + return false; + } + + + + } + + + /** + * Get Default Content Length + * @return defLength + */ + public String getDefLength() { + return defLength; + } + /** + * Set Default Content Length + * @param defLength + */ + public void setDefLength(String defLength) { + this.defLength = defLength; + } + + + +} diff --git a/src/main/java/com/att/nsa/dmaap/util/DMaaPAuthFilter.java b/src/main/java/org/onap/dmaap/util/DMaaPAuthFilter.java index 4ef8626..547c4cd 100644 --- a/src/main/java/com/att/nsa/dmaap/util/DMaaPAuthFilter.java +++ b/src/main/java/org/onap/dmaap/util/DMaaPAuthFilter.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.util; + package org.onap.dmaap.util; import java.io.IOException; diff --git a/src/main/java/com/att/nsa/dmaap/util/ServicePropertiesMapBean.java b/src/main/java/org/onap/dmaap/util/ServicePropertiesMapBean.java index b16162b..1778182 100644 --- a/src/main/java/com/att/nsa/dmaap/util/ServicePropertiesMapBean.java +++ b/src/main/java/org/onap/dmaap/util/ServicePropertiesMapBean.java @@ -19,9 +19,9 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap.util; + package org.onap.dmaap.util; -import com.att.nsa.dmaap.filemonitor.ServicePropertiesMap; +import org.onap.dmaap.filemonitor.ServicePropertiesMap; /** * Class ServicePropertiesMapBean diff --git a/src/main/test/com/att/nsa/dmaap/DummyTest.java b/src/main/test/com/att/nsa/dmaap/DummyTest.java index b979e31..17adcea 100644 --- a/src/main/test/com/att/nsa/dmaap/DummyTest.java +++ b/src/main/test/com/att/nsa/dmaap/DummyTest.java @@ -19,7 +19,7 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * *******************************************************************************/ -package com.att.nsa.dmaap; + package org.onap.dmaap; import static org.junit.Assert.*; diff --git a/src/test/java/com/att/nsa/dmaap/filemonitor/TestRunner.java b/src/test/java/com/att/nsa/dmaap/filemonitor/TestRunner.java deleted file mode 100644 index 267a6bf..0000000 --- a/src/test/java/com/att/nsa/dmaap/filemonitor/TestRunner.java +++ /dev/null @@ -1,41 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.filemonitor;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}
diff --git a/src/test/java/com/att/nsa/dmaap/mmagent/TestRunner.java b/src/test/java/com/att/nsa/dmaap/mmagent/TestRunner.java deleted file mode 100644 index 63b128d..0000000 --- a/src/test/java/com/att/nsa/dmaap/mmagent/TestRunner.java +++ /dev/null @@ -1,41 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.mmagent;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}
diff --git a/src/test/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapperTest.java b/src/test/java/org/onap/dmaap/DMaaPCambriaExceptionMapperTest.java index 89c9400..a66da07 100644 --- a/src/test/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapperTest.java +++ b/src/test/java/org/onap/dmaap/DMaaPCambriaExceptionMapperTest.java @@ -1,86 +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 com.att.nsa.dmaap;
-
-import static org.junit.Assert.assertTrue;
-
-import org.json.JSONObject;
-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.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
-import org.onap.dmaap.dmf.mr.exception.ErrorResponse;
-@RunWith(PowerMockRunner.class)
-public class DMaaPCambriaExceptionMapperTest {
-
- @InjectMocks
- DMaaPCambriaExceptionMapper mapper;
-
- @Mock
- private ErrorResponse errRes;
-
- @Mock
- private DMaaPErrorMessages msgs;
-
- @Mock
- CambriaApiException exc;
-
- @Mock
- JSONObject json;
-
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testToResponse() {
- try {
- mapper.toResponse(null);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
-
- @Test
- public void testToResponseCambriaApiException2() {
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
- try {
- mapper.toResponse(new CambriaApiException(404,"Not found"));
- } catch (NullPointerException e) {
- assertTrue(true);
- }
- assertTrue(true);
- }
+/*- + * ============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; + +import static org.junit.Assert.assertTrue; + +import org.json.JSONObject; +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.powermock.api.mockito.PowerMockito; +import org.powermock.modules.junit4.PowerMockRunner; + +import org.onap.dmaap.dmf.mr.CambriaApiException; +import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages; +import org.onap.dmaap.dmf.mr.exception.ErrorResponse; +@RunWith(PowerMockRunner.class) +public class DMaaPCambriaExceptionMapperTest { + + @InjectMocks + DMaaPCambriaExceptionMapper mapper; + + @Mock + private ErrorResponse errRes; + + @Mock + private DMaaPErrorMessages msgs; + + @Mock + CambriaApiException exc; + + @Mock + JSONObject json; + + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToResponse() { + try { + mapper.toResponse(null); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + + @Test + public void testToResponseCambriaApiException2() { + PowerMockito.when(msgs.getNotFound()).thenReturn("Not found"); + try { + mapper.toResponse(new CambriaApiException(404,"Not found")); + } catch (NullPointerException e) { + assertTrue(true); + } + assertTrue(true); + } }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/DMaaPWebExceptionMapperTest.java b/src/test/java/org/onap/dmaap/DMaaPWebExceptionMapperTest.java index 9e67dcd..78f67c2 100644 --- a/src/test/java/com/att/nsa/dmaap/DMaaPWebExceptionMapperTest.java +++ b/src/test/java/org/onap/dmaap/DMaaPWebExceptionMapperTest.java @@ -1,142 +1,142 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap;
-
-import static org.junit.Assert.*;
-
-import javax.ws.rs.BadRequestException;
-import javax.ws.rs.InternalServerErrorException;
-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.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
-
-@RunWith(PowerMockRunner.class)
-public class DMaaPWebExceptionMapperTest {
-
- @InjectMocks
- DMaaPWebExceptionMapper mapper;
-
- @Mock
- DMaaPErrorMessages msgs;
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testToResponse() {
-
- try {
- mapper.toResponse(null);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testToResponseNotFoundException() {
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
- try {
- mapper.toResponse(new NotFoundException());
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testToResponseInternalServerErrorException() {
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
- try {
- mapper.toResponse(new InternalServerErrorException());
-
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testToResponseNotAuthorizedException() {
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
- try {
- mapper.toResponse(new NotAuthorizedException("Error", "Error"));
-
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testToResponseBadRequestException() {
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
- try {
- mapper.toResponse(new BadRequestException());
-
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testToResponseNotAllowedException() {
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
- try {
- mapper.toResponse(new NotAllowedException("Not Allowed"));
-
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testToResponseServiceUnavailableException() {
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
- try {
- mapper.toResponse(new ServiceUnavailableException());
-
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
+/*- + * ============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; + +import static org.junit.Assert.*; + +import javax.ws.rs.BadRequestException; +import javax.ws.rs.InternalServerErrorException; +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.powermock.api.mockito.PowerMockito; +import org.powermock.modules.junit4.PowerMockRunner; + +import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages; + +@RunWith(PowerMockRunner.class) +public class DMaaPWebExceptionMapperTest { + + @InjectMocks + DMaaPWebExceptionMapper mapper; + + @Mock + DMaaPErrorMessages msgs; + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToResponse() { + + try { + mapper.toResponse(null); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testToResponseNotFoundException() { + PowerMockito.when(msgs.getNotFound()).thenReturn("Not found"); + try { + mapper.toResponse(new NotFoundException()); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testToResponseInternalServerErrorException() { + PowerMockito.when(msgs.getNotFound()).thenReturn("Not found"); + try { + mapper.toResponse(new InternalServerErrorException()); + + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testToResponseNotAuthorizedException() { + PowerMockito.when(msgs.getNotFound()).thenReturn("Not found"); + try { + mapper.toResponse(new NotAuthorizedException("Error", "Error")); + + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testToResponseBadRequestException() { + PowerMockito.when(msgs.getNotFound()).thenReturn("Not found"); + try { + mapper.toResponse(new BadRequestException()); + + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testToResponseNotAllowedException() { + PowerMockito.when(msgs.getNotFound()).thenReturn("Not found"); + try { + mapper.toResponse(new NotAllowedException("Not Allowed")); + + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testToResponseServiceUnavailableException() { + PowerMockito.when(msgs.getNotFound()).thenReturn("Not found"); + try { + mapper.toResponse(new ServiceUnavailableException()); + + } catch (NullPointerException e) { + assertTrue(true); + } + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/DummyTest.java b/src/test/java/org/onap/dmaap/DummyTest.java index ea5bac9..8b01f94 100644 --- a/src/test/java/com/att/nsa/dmaap/DummyTest.java +++ b/src/test/java/org/onap/dmaap/DummyTest.java @@ -1,45 +1,45 @@ -/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-package com.att.nsa.dmaap;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DummyTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void test() {
- assertTrue("Dummy test case", true);
- }
-
-}
+/******************************************************************************* + * ============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; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class DummyTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() { + assertTrue("Dummy test case", true); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/HelloWorldTest.java b/src/test/java/org/onap/dmaap/HelloWorldTest.java index 6191cf1..0067b8f 100644 --- a/src/test/java/com/att/nsa/dmaap/HelloWorldTest.java +++ b/src/test/java/org/onap/dmaap/HelloWorldTest.java @@ -1,52 +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 com.att.nsa.dmaap;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class HelloWorldTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testToResponse() {
-
- HelloWorld hello = new HelloWorld();
-
- try {
- hello.speak(null);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
+/*- + * ============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; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HelloWorldTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToResponse() { + + HelloWorld hello = new HelloWorld(); + + try { + hello.speak(null); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/JUnitTestSuite.java index 576bc4a..d20d0d6 100644 --- a/src/test/java/com/att/nsa/dmaap/JUnitTestSuite.java +++ b/src/test/java/org/onap/dmaap/JUnitTestSuite.java @@ -1,43 +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 com.att.nsa.dmaap;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ DMaaPCambriaExceptionMapperTest.class, DMaaPWebExceptionMapper.class,
- JaxrsEchoServiceTest.class, HelloWorldTest.class, JaxrsUserServiceTest.class })
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
+/*- + * ============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; + +import junit.framework.TestSuite; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.apache.log4j.Logger; + +@RunWith(Suite.class) +@SuiteClasses({ DMaaPCambriaExceptionMapperTest.class, DMaaPWebExceptionMapper.class, + JaxrsEchoServiceTest.class, HelloWorldTest.class, JaxrsUserServiceTest.class }) +public class JUnitTestSuite { + private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class); + + public static void main(String[] args) { + LOGGER.info("Running the test suite"); + + TestSuite tstSuite = new TestSuite(); + LOGGER.info("Total Test Counts " + tstSuite.countTestCases()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/JaxrsEchoServiceTest.java b/src/test/java/org/onap/dmaap/JaxrsEchoServiceTest.java index 96fba99..94a6b96 100644 --- a/src/test/java/com/att/nsa/dmaap/JaxrsEchoServiceTest.java +++ b/src/test/java/org/onap/dmaap/JaxrsEchoServiceTest.java @@ -1,60 +1,60 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JaxrsEchoServiceTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testPing() {
-
- JaxrsEchoService service = new JaxrsEchoService();
-
- service.ping("hello");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetProperty() {
-
- JaxrsEchoService service = new JaxrsEchoService();
-
- service.getProperty("filename", "hello");
- assertTrue(true);
-
- }
-
+/*- + * ============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; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class JaxrsEchoServiceTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testPing() { + + JaxrsEchoService service = new JaxrsEchoService(); + + service.ping("hello"); + + assertTrue(true); + + } + + @Test + public void testGetProperty() { + + JaxrsEchoService service = new JaxrsEchoService(); + + service.getProperty("filename", "hello"); + assertTrue(true); + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/JaxrsUserServiceTest.java b/src/test/java/org/onap/dmaap/JaxrsUserServiceTest.java index acff4de..7d8ba47 100644 --- a/src/test/java/com/att/nsa/dmaap/JaxrsUserServiceTest.java +++ b/src/test/java/org/onap/dmaap/JaxrsUserServiceTest.java @@ -1,50 +1,50 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JaxrsUserServiceTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testLookupUser() {
-
- JaxrsUserService service = new JaxrsUserService();
-
- service.lookupUser("userid");
-
- assertTrue(true);
-
- }
-
+/*- + * ============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; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class JaxrsUserServiceTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testLookupUser() { + + JaxrsUserService service = new JaxrsUserService(); + + service.lookupUser("userid"); + + assertTrue(true); + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/TestRunner.java b/src/test/java/org/onap/dmaap/TestRunner.java index 5c18a19..4542566 100644 --- a/src/test/java/com/att/nsa/dmaap/TestRunner.java +++ b/src/test/java/org/onap/dmaap/TestRunner.java @@ -1,41 +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 com.att.nsa.dmaap;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}
+/*- + * ============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; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.apache.log4j.Logger; + +public class TestRunner { + private static final Logger LOGGER = Logger.getLogger(TestRunner.class); + + public static void main(String[] args) { + // TODO Auto-generated method stub + Result result = JUnitCore.runClasses(JUnitTestSuite.class); + for (Failure failure : result.getFailures()) { + LOGGER.info(failure.toString()); + + } + LOGGER.info(result.wasSuccessful()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/filemonitor/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/filemonitor/JUnitTestSuite.java index 6aa031b..9c87f24 100644 --- a/src/test/java/com/att/nsa/dmaap/filemonitor/JUnitTestSuite.java +++ b/src/test/java/org/onap/dmaap/filemonitor/JUnitTestSuite.java @@ -1,43 +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 com.att.nsa.dmaap.filemonitor;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ ServicePropertiesListenerTest.class, ServicePropertiesMapTest.class,
- ServicePropertyServiceTest.class, })
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
+/*- + * ============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.filemonitor; + +import junit.framework.TestSuite; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.apache.log4j.Logger; + +@RunWith(Suite.class) +@SuiteClasses({ ServicePropertiesListenerTest.class, ServicePropertiesMapTest.class, + ServicePropertyServiceTest.class, }) +public class JUnitTestSuite { + private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class); + + public static void main(String[] args) { + LOGGER.info("Running the test suite"); + + TestSuite tstSuite = new TestSuite(); + LOGGER.info("Total Test Counts " + tstSuite.countTestCases()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesListenerTest.java b/src/test/java/org/onap/dmaap/filemonitor/ServicePropertiesListenerTest.java index 210ecfd..cae0c68 100644 --- a/src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesListenerTest.java +++ b/src/test/java/org/onap/dmaap/filemonitor/ServicePropertiesListenerTest.java @@ -1,57 +1,57 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.filemonitor;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ServicePropertiesListenerTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- //@Test
- public void testUpdate() {/*
-
- ServicePropertiesListener listener = new ServicePropertiesListener();
-
- try {
- listener.update(new File(":/file"));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- assertTrue(true);
-
- */}
-
+/*- + * ============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.filemonitor; + +import static org.junit.Assert.*; + +import java.io.File; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ServicePropertiesListenerTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + //@Test + public void testUpdate() {/* + + ServicePropertiesListener listener = new ServicePropertiesListener(); + + try { + listener.update(new File(":/file")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + assertTrue(true); + + */} + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesMapTest.java b/src/test/java/org/onap/dmaap/filemonitor/ServicePropertiesMapTest.java index 636f051..1e8c9d7 100644 --- a/src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertiesMapTest.java +++ b/src/test/java/org/onap/dmaap/filemonitor/ServicePropertiesMapTest.java @@ -1,128 +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 com.att.nsa.dmaap.filemonitor;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashMap;
-
-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.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@RunWith(PowerMockRunner.class)
-public class ServicePropertiesMapTest {
-
- @InjectMocks
- ServicePropertiesMap map;
-
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- /*@Test
- public void testRefresh() {
-
- try {
- map.refresh(new File(":/file"));
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- assertTrue(true);
-
- }
-
- @Test()
- public void testRefreshJsonFile() throws Exception {
- //Path resourceDirectory = Paths.get("src/test/resources");
- // map.refresh(new File(resourceDirectory+"\\"+"test.json"));
- ClassLoader classLoader = getClass().getClassLoader();
- map.refresh(new File(classLoader.getResource("test.json").getFile()));
-
- assertTrue(true);
- }
-
- @Test
- public void testRefreshPropsFile() throws Exception {
- Path resourceDirectory = Paths.get("src/test/resources");
- map.refresh(new File(resourceDirectory+"\\"+"test.properties"));
- ClassLoader classLoader = getClass().getClassLoader();
- map.refresh(new File(classLoader.getResource("test.json").getFile()));
- assertTrue(true);
- }*/
-
- @Test
- public void testGetProperty() {
-
- try {
- map.getProperty("filename", "propertykey");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- assertTrue(true);
- }
-
- @Test
- public void testGetProperties() {
-
- try {
- map.getProperties("filename");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- assertTrue(true);
-
- }
-
- @Test
- public void testIfNullThenEmpty() {
-
- try {
- map.getProperties("filename");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- assertTrue(true);
-
- }
-
+/*- + * ============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.filemonitor; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileNotFoundException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; + +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.powermock.api.mockito.PowerMockito; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(PowerMockRunner.class) +public class ServicePropertiesMapTest { + + @InjectMocks + ServicePropertiesMap map; + + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + /*@Test + public void testRefresh() { + + try { + map.refresh(new File(":/file")); + } catch (Exception e) { + e.printStackTrace(); + } + + assertTrue(true); + + } + + @Test() + public void testRefreshJsonFile() throws Exception { + //Path resourceDirectory = Paths.get("src/test/resources"); + // map.refresh(new File(resourceDirectory+"\\"+"test.json")); + ClassLoader classLoader = getClass().getClassLoader(); + map.refresh(new File(classLoader.getResource("test.json").getFile())); + + assertTrue(true); + } + + @Test + public void testRefreshPropsFile() throws Exception { + Path resourceDirectory = Paths.get("src/test/resources"); + map.refresh(new File(resourceDirectory+"\\"+"test.properties")); + ClassLoader classLoader = getClass().getClassLoader(); + map.refresh(new File(classLoader.getResource("test.json").getFile())); + assertTrue(true); + }*/ + + @Test + public void testGetProperty() { + + try { + map.getProperty("filename", "propertykey"); + } catch (Exception e) { + e.printStackTrace(); + } + + assertTrue(true); + } + + @Test + public void testGetProperties() { + + try { + map.getProperties("filename"); + } catch (Exception e) { + e.printStackTrace(); + } + + assertTrue(true); + + } + + @Test + public void testIfNullThenEmpty() { + + try { + map.getProperties("filename"); + } catch (Exception e) { + e.printStackTrace(); + } + + assertTrue(true); + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertyServiceTest.java b/src/test/java/org/onap/dmaap/filemonitor/ServicePropertyServiceTest.java index e5f0cb8..461ad60 100644 --- a/src/test/java/com/att/nsa/dmaap/filemonitor/ServicePropertyServiceTest.java +++ b/src/test/java/org/onap/dmaap/filemonitor/ServicePropertyServiceTest.java @@ -1,153 +1,153 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.filemonitor;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ServicePropertyServiceTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testInit() {
-
- ServicePropertyService service = new ServicePropertyService();
- try {
- service.init();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- assertTrue(true);
-
- }
-
- @Test
- public void testsetLoadOnStartup() {
-
- ServicePropertyService service = new ServicePropertyService();
- try {
- service.setLoadOnStartup(true);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- assertTrue(true);
-
- }
-
- @Test
- public void testSetSsfFileMonitorPollingInterval() {
-
- ServicePropertyService service = new ServicePropertyService();
- try {
- service.setSsfFileMonitorPollingInterval("interval");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- assertTrue(true);
-
- }
-
- @Test
- public void testSetSsfFileMonitorThreadpoolSize() {
-
- ServicePropertyService service = new ServicePropertyService();
- try {
- service.setSsfFileMonitorThreadpoolSize("threadPoolSize");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- assertTrue(true);
-
- }
-
- @Test
- public void testIsLoadOnStartup() {
- ServicePropertyService service = new ServicePropertyService();
- service.isLoadOnStartup();
- assertTrue(true);
-
- }
-
- @Test
- public void testGetSsfFileMonitorPollingInterval() {
- ServicePropertyService service = new ServicePropertyService();
- service.getSsfFileMonitorPollingInterval();
- assertTrue(true);
-
- }
-
- @Test
- public void testGetSsfFileMonitorThreadpoolSize() {
- ServicePropertyService service = new ServicePropertyService();
- service.getSsfFileMonitorThreadpoolSize();
- assertTrue(true);
-
- }
-
- @Test
- public void testGetFileChangedListener() {
- ServicePropertyService service = new ServicePropertyService();
- service.getFileChangedListener();
- assertTrue(true);
-
- }
-
- @Test
- public void testSetFileChangedListener() {
- ServicePropertyService service = new ServicePropertyService();
- service.setFileChangedListener(null);
- assertTrue(true);
-
- }
-
- @Test
- public void testGetFilePropertiesMap() {
- ServicePropertyService service = new ServicePropertyService();
- service.getFilePropertiesMap();
- assertTrue(true);
-
- }
-
- @Test
- public void testSetFilePropertiesMap() {
- ServicePropertyService service = new ServicePropertyService();
- service.setFilePropertiesMap(null);
- assertTrue(true);
-
- }
-
+/*- + * ============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.filemonitor; + +import static org.junit.Assert.*; + +import java.io.File; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ServicePropertyServiceTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testInit() { + + ServicePropertyService service = new ServicePropertyService(); + try { + service.init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testsetLoadOnStartup() { + + ServicePropertyService service = new ServicePropertyService(); + try { + service.setLoadOnStartup(true); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testSetSsfFileMonitorPollingInterval() { + + ServicePropertyService service = new ServicePropertyService(); + try { + service.setSsfFileMonitorPollingInterval("interval"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testSetSsfFileMonitorThreadpoolSize() { + + ServicePropertyService service = new ServicePropertyService(); + try { + service.setSsfFileMonitorThreadpoolSize("threadPoolSize"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(true); + + } + + @Test + public void testIsLoadOnStartup() { + ServicePropertyService service = new ServicePropertyService(); + service.isLoadOnStartup(); + assertTrue(true); + + } + + @Test + public void testGetSsfFileMonitorPollingInterval() { + ServicePropertyService service = new ServicePropertyService(); + service.getSsfFileMonitorPollingInterval(); + assertTrue(true); + + } + + @Test + public void testGetSsfFileMonitorThreadpoolSize() { + ServicePropertyService service = new ServicePropertyService(); + service.getSsfFileMonitorThreadpoolSize(); + assertTrue(true); + + } + + @Test + public void testGetFileChangedListener() { + ServicePropertyService service = new ServicePropertyService(); + service.getFileChangedListener(); + assertTrue(true); + + } + + @Test + public void testSetFileChangedListener() { + ServicePropertyService service = new ServicePropertyService(); + service.setFileChangedListener(null); + assertTrue(true); + + } + + @Test + public void testGetFilePropertiesMap() { + ServicePropertyService service = new ServicePropertyService(); + service.getFilePropertiesMap(); + assertTrue(true); + + } + + @Test + public void testSetFilePropertiesMap() { + ServicePropertyService service = new ServicePropertyService(); + service.setFilePropertiesMap(null); + assertTrue(true); + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/util/TestRunner.java b/src/test/java/org/onap/dmaap/filemonitor/TestRunner.java index d0bec42..1af59c2 100644 --- a/src/test/java/com/att/nsa/dmaap/util/TestRunner.java +++ b/src/test/java/org/onap/dmaap/filemonitor/TestRunner.java @@ -1,41 +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 com.att.nsa.dmaap.util;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}
+/*- + * ============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.filemonitor; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.apache.log4j.Logger; + +public class TestRunner { + private static final Logger LOGGER = Logger.getLogger(TestRunner.class); + + public static void main(String[] args) { + // TODO Auto-generated method stub + Result result = JUnitCore.runClasses(JUnitTestSuite.class); + for (Failure failure : result.getFailures()) { + LOGGER.info(failure.toString()); + + } + LOGGER.info(result.wasSuccessful()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/mmagent/CreateMirrorMakerTest.java b/src/test/java/org/onap/dmaap/mmagent/CreateMirrorMakerTest.java index fde7ab4..bad987d 100644 --- a/src/test/java/com/att/nsa/dmaap/mmagent/CreateMirrorMakerTest.java +++ b/src/test/java/org/onap/dmaap/mmagent/CreateMirrorMakerTest.java @@ -1,82 +1,82 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.mmagent;
-
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class CreateMirrorMakerTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetCreateMirrorMaker() {
-
- CreateMirrorMaker mMaker = new CreateMirrorMaker();
- mMaker.getCreateMirrorMaker();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetCreateMirrorMaker() throws CambriaApiException {
-
- CreateMirrorMaker mMaker = new CreateMirrorMaker();
- mMaker.setCreateMirrorMaker(new MirrorMaker());
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMessageID() {
-
- CreateMirrorMaker mMaker = new CreateMirrorMaker();
- mMaker.getMessageID();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetMessageID() {
-
- CreateMirrorMaker mMaker = new CreateMirrorMaker();
- mMaker.setMessageID("messageID");
-
- assertTrue(true);
-
- }
-
+/*- + * ============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.mmagent; + +import org.onap.dmaap.dmf.mr.CambriaApiException; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +public class CreateMirrorMakerTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetCreateMirrorMaker() { + + CreateMirrorMaker mMaker = new CreateMirrorMaker(); + mMaker.getCreateMirrorMaker(); + + assertTrue(true); + + } + + @Test + public void testSetCreateMirrorMaker() throws CambriaApiException { + + CreateMirrorMaker mMaker = new CreateMirrorMaker(); + mMaker.setCreateMirrorMaker(new MirrorMaker()); + + assertTrue(true); + + } + + @Test + public void testGetMessageID() { + + CreateMirrorMaker mMaker = new CreateMirrorMaker(); + mMaker.getMessageID(); + + assertTrue(true); + + } + + @Test + public void testSetMessageID() { + + CreateMirrorMaker mMaker = new CreateMirrorMaker(); + mMaker.setMessageID("messageID"); + + assertTrue(true); + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/mmagent/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/mmagent/JUnitTestSuite.java index b8087a7..909ecd8 100644 --- a/src/test/java/com/att/nsa/dmaap/mmagent/JUnitTestSuite.java +++ b/src/test/java/org/onap/dmaap/mmagent/JUnitTestSuite.java @@ -1,43 +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 com.att.nsa.dmaap.mmagent;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ CreateMirrorMakerTest.class, MirrorMakerTest.class,
- UpdateMirrorMakerTest.class, UpdateWhiteListTest.class,})
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
+/*- + * ============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.mmagent; + +import junit.framework.TestSuite; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.apache.log4j.Logger; + +@RunWith(Suite.class) +@SuiteClasses({ CreateMirrorMakerTest.class, MirrorMakerTest.class, + UpdateMirrorMakerTest.class, UpdateWhiteListTest.class,}) +public class JUnitTestSuite { + private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class); + + public static void main(String[] args) { + LOGGER.info("Running the test suite"); + + TestSuite tstSuite = new TestSuite(); + LOGGER.info("Total Test Counts " + tstSuite.countTestCases()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/mmagent/MirrorMakerTest.java b/src/test/java/org/onap/dmaap/mmagent/MirrorMakerTest.java index ebcb61f..192ed1d 100644 --- a/src/test/java/com/att/nsa/dmaap/mmagent/MirrorMakerTest.java +++ b/src/test/java/org/onap/dmaap/mmagent/MirrorMakerTest.java @@ -1,142 +1,142 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.mmagent;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MirrorMakerTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetStatus() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.getStatus();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetStatus() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.setStatus("status");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetName() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.getName();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetName() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.setName("name");
-
- assertTrue(true);
-
- }
-
-
- @Test
- public void testGetConsumer() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.getConsumer();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetConsumer() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.setConsumer("consumer");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetProducer() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.getProducer();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetProducer() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.setProducer("producer");
-
- assertTrue(true);
-
- }
-
-
- @Test
- public void testGetWhitelist() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.getWhitelist();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetWhitelist() {
-
- MirrorMaker mMaker = new MirrorMaker();
- mMaker.setWhitelist("whitelist");
-
- assertTrue(true);
-
- }
-
-
+/*- + * ============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.mmagent; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class MirrorMakerTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetStatus() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.getStatus(); + + assertTrue(true); + + } + + @Test + public void testSetStatus() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.setStatus("status"); + + assertTrue(true); + + } + + @Test + public void testGetName() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.getName(); + + assertTrue(true); + + } + + @Test + public void testSetName() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.setName("name"); + + assertTrue(true); + + } + + + @Test + public void testGetConsumer() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.getConsumer(); + + assertTrue(true); + + } + + @Test + public void testSetConsumer() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.setConsumer("consumer"); + + assertTrue(true); + + } + + @Test + public void testGetProducer() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.getProducer(); + + assertTrue(true); + + } + + @Test + public void testSetProducer() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.setProducer("producer"); + + assertTrue(true); + + } + + + @Test + public void testGetWhitelist() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.getWhitelist(); + + assertTrue(true); + + } + + @Test + public void testSetWhitelist() { + + MirrorMaker mMaker = new MirrorMaker(); + mMaker.setWhitelist("whitelist"); + + assertTrue(true); + + } + + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/tools/TestRunner.java b/src/test/java/org/onap/dmaap/mmagent/TestRunner.java index 5c9387a..3e4ece3 100644 --- a/src/test/java/com/att/nsa/dmaap/tools/TestRunner.java +++ b/src/test/java/org/onap/dmaap/mmagent/TestRunner.java @@ -1,41 +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 com.att.nsa.dmaap.tools;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}
+/*- + * ============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.mmagent; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.apache.log4j.Logger; + +public class TestRunner { + private static final Logger LOGGER = Logger.getLogger(TestRunner.class); + + public static void main(String[] args) { + // TODO Auto-generated method stub + Result result = JUnitCore.runClasses(JUnitTestSuite.class); + for (Failure failure : result.getFailures()) { + LOGGER.info(failure.toString()); + + } + LOGGER.info(result.wasSuccessful()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/mmagent/UpdateMirrorMakerTest.java b/src/test/java/org/onap/dmaap/mmagent/UpdateMirrorMakerTest.java index 4e66d22..1826026 100644 --- a/src/test/java/com/att/nsa/dmaap/mmagent/UpdateMirrorMakerTest.java +++ b/src/test/java/org/onap/dmaap/mmagent/UpdateMirrorMakerTest.java @@ -1,81 +1,81 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.mmagent;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class UpdateMirrorMakerTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetUpdateMirrorMaker() {
-
- UpdateMirrorMaker mMaker = new UpdateMirrorMaker();
- mMaker.getUpdateMirrorMaker();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetUpdateMirrorMaker() {
-
- UpdateMirrorMaker mMaker = new UpdateMirrorMaker();
- mMaker.setUpdateMirrorMaker(new MirrorMaker());
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMessageID() {
-
- UpdateMirrorMaker mMaker = new UpdateMirrorMaker();
- mMaker.getMessageID();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetMessageID() {
-
- UpdateMirrorMaker mMaker = new UpdateMirrorMaker();
- mMaker.setMessageID("messageID");
-
- assertTrue(true);
-
- }
-
-
-
+/*- + * ============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.mmagent; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class UpdateMirrorMakerTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetUpdateMirrorMaker() { + + UpdateMirrorMaker mMaker = new UpdateMirrorMaker(); + mMaker.getUpdateMirrorMaker(); + + assertTrue(true); + + } + + @Test + public void testSetUpdateMirrorMaker() { + + UpdateMirrorMaker mMaker = new UpdateMirrorMaker(); + mMaker.setUpdateMirrorMaker(new MirrorMaker()); + + assertTrue(true); + + } + + @Test + public void testGetMessageID() { + + UpdateMirrorMaker mMaker = new UpdateMirrorMaker(); + mMaker.getMessageID(); + + assertTrue(true); + + } + + @Test + public void testSetMessageID() { + + UpdateMirrorMaker mMaker = new UpdateMirrorMaker(); + mMaker.setMessageID("messageID"); + + assertTrue(true); + + } + + + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/mmagent/UpdateWhiteListTest.java b/src/test/java/org/onap/dmaap/mmagent/UpdateWhiteListTest.java index 4e6d07a..75a9104 100644 --- a/src/test/java/com/att/nsa/dmaap/mmagent/UpdateWhiteListTest.java +++ b/src/test/java/org/onap/dmaap/mmagent/UpdateWhiteListTest.java @@ -1,85 +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 com.att.nsa.dmaap.mmagent;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class UpdateWhiteListTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetUpdateWhiteList() {
-
- UpdateWhiteList wList = new UpdateWhiteList();
- wList.getUpdateWhiteList();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetUpdateWhiteList() {
-
- UpdateWhiteList wList = new UpdateWhiteList();
- wList.setUpdateWhiteList(new MirrorMaker());
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMessageID() {
-
- UpdateWhiteList wList = new UpdateWhiteList();
- wList.getMessageID();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testSetMessageID() {
-
- UpdateWhiteList wList = new UpdateWhiteList();
- wList.setMessageID("messageID");
-
- assertTrue(true);
-
- }
-
-
-
-
-
-
-
+/*- + * ============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.mmagent; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class UpdateWhiteListTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetUpdateWhiteList() { + + UpdateWhiteList wList = new UpdateWhiteList(); + wList.getUpdateWhiteList(); + + assertTrue(true); + + } + + @Test + public void testSetUpdateWhiteList() { + + UpdateWhiteList wList = new UpdateWhiteList(); + wList.setUpdateWhiteList(new MirrorMaker()); + + assertTrue(true); + + } + + @Test + public void testGetMessageID() { + + UpdateWhiteList wList = new UpdateWhiteList(); + wList.getMessageID(); + + assertTrue(true); + + } + + @Test + public void testSetMessageID() { + + UpdateWhiteList wList = new UpdateWhiteList(); + wList.setMessageID("messageID"); + + assertTrue(true); + + } + + + + + + + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/service/AdminRestServiceTest.java b/src/test/java/org/onap/dmaap/service/AdminRestServiceTest.java index 5a05a73..0f99ff5 100644 --- a/src/test/java/com/att/nsa/dmaap/service/AdminRestServiceTest.java +++ b/src/test/java/org/onap/dmaap/service/AdminRestServiceTest.java @@ -1,295 +1,295 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.service;
-
-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.CambriaApiException;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import org.onap.dmaap.dmf.mr.service.AdminService;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ ServiceUtil.class })
-public class AdminRestServiceTest {
-
- @InjectMocks
- AdminRestService adminRestService;
-
- @Mock
- AdminService adminService;
-
- @Mock
- DMaaPContext dmaapContext;
-
- @Mock
- HttpServletRequest httpServReq;
- @Mock
- private HttpServletResponse response;
-
- @Mock
- Enumeration headerNames;
- @Mock
- private DMaaPContext dmaaPContext;
- @Mock
- private ConfigurationReader configReader;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetConsumerCache() throws CambriaApiException, AccessDeniedException {
- adminRestService.getConsumerCache();
-
- }
-
- @Test
- public void testGetConsumerCache_error() throws CambriaApiException, AccessDeniedException, IOException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).showConsumerCache(dmaaPContext);
- try {
- adminRestService.getConsumerCache();
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testDropConsumerCache() throws CambriaApiException, AccessDeniedException {
- adminRestService.dropConsumerCache();
-
- }
-
- @Test
- public void testDropConsumerCach_error() throws CambriaApiException, AccessDeniedException ,IOException{
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).dropConsumerCache(dmaaPContext);
- try {
- adminRestService.dropConsumerCache();
- }
- catch (CambriaApiException e) {
- assertTrue(true);
- }
-
-
- }
- @Test
- public void testDropConsumerCach_error1() throws CambriaApiException, AccessDeniedException,IOException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).dropConsumerCache(dmaaPContext);
- try {
- adminRestService.dropConsumerCache();
- }
- catch (CambriaApiException e) {
- assertTrue(true);
- }
-
-
- }
-
- @Test
- public void testGetBlacklist() throws CambriaApiException, AccessDeniedException {
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeaderNames()).thenReturn(headerNames);
- when(headerNames.nextElement()).thenReturn("key");
- when(httpServReq.getHeader("key")).thenReturn("value");
-
- adminRestService.getBlacklist();
-
- }
-
- //@Test
- public void testGetBlacklist_error() throws CambriaApiException, AccessDeniedException,IOException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).getBlacklist(dmaaPContext);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeaderNames()).thenReturn(headerNames);
- when(headerNames.nextElement()).thenReturn("key");
- when(httpServReq.getHeader("key")).thenReturn("value");
- when(headerNames.hasMoreElements()).thenReturn(false);
- try {
- adminRestService.getBlacklist();
- }
- catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
- ////@Test
- public void testGetBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).getBlacklist(dmaaPContext);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeaderNames()).thenReturn(headerNames);
- when(headerNames.nextElement()).thenReturn("key");
- when(httpServReq.getHeader("key")).thenReturn("value");
- when(headerNames.hasMoreElements()).thenReturn(false);
- try {
- adminRestService.getBlacklist();
- }
- catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testAddToBlacklist() throws CambriaApiException, AccessDeniedException {
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
-
- adminRestService.addToBlacklist("120.120.120.120");
-
- }
-
- @Test
- public void testAddToBlacklist_error() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).addToBlacklist(dmaaPContext,"120.120.120.120");
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- try {
- adminRestService.addToBlacklist("120.120.120.120");
- }catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testAddToBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException, ConfigDbException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).addToBlacklist(dmaaPContext,"120.120.120.120");
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- try {
- adminRestService.addToBlacklist("120.120.120.120");
- }catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testRemoveFromBlacklist() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
-
- adminRestService.removeFromBlacklist("120.120.120.120");
-
- }
-
- @Test
- public void testRemoveFromBlacklist_error() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException{
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new IOException("error")).when(adminService).removeFromBlacklist(dmaaPContext,"120.120.120.120");
-
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- try {
-
- adminRestService.removeFromBlacklist("120.120.120.120");
- }catch (CambriaApiException e) {
- assertTrue(true);
- }
- catch (AccessDeniedException e) {
- assertTrue(true);
- }
- catch (ConfigDbException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testRemoveFromBlacklist_error1() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {
-
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).removeFromBlacklist(dmaaPContext,"120.120.120.120");
-
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- try {
-
- adminRestService.removeFromBlacklist("120.120.120.120");
- }catch (CambriaApiException e) {
- assertTrue(true);
- }
- catch (AccessDeniedException e) {
- assertTrue(true);
- }
- catch (ConfigDbException e) {
- assertTrue(true);
- }
-
- }
-
+/*- + * ============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.service; + +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.CambriaApiException; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.onap.dmaap.dmf.mr.beans.DMaaPContext; + +import java.io.IOException; +import java.util.Enumeration; +import org.onap.dmaap.dmf.mr.service.AdminService; +import com.att.nsa.configs.ConfigDbException; +import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException; +import org.onap.dmaap.dmf.mr.beans.DMaaPContext; +import org.onap.dmaap.dmf.mr.utils.ConfigurationReader; +import org.powermock.core.classloader.annotations.PrepareForTest; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ ServiceUtil.class }) +public class AdminRestServiceTest { + + @InjectMocks + AdminRestService adminRestService; + + @Mock + AdminService adminService; + + @Mock + DMaaPContext dmaapContext; + + @Mock + HttpServletRequest httpServReq; + @Mock + private HttpServletResponse response; + + @Mock + Enumeration headerNames; + @Mock + private DMaaPContext dmaaPContext; + @Mock + private ConfigurationReader configReader; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetConsumerCache() throws CambriaApiException, AccessDeniedException { + adminRestService.getConsumerCache(); + + } + + @Test + public void testGetConsumerCache_error() throws CambriaApiException, AccessDeniedException, IOException { + + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new IOException("error")).when(adminService).showConsumerCache(dmaaPContext); + try { + adminRestService.getConsumerCache(); + } catch (CambriaApiException e) { + assertTrue(true); + } + + } + + @Test + public void testDropConsumerCache() throws CambriaApiException, AccessDeniedException { + adminRestService.dropConsumerCache(); + + } + + @Test + public void testDropConsumerCach_error() throws CambriaApiException, AccessDeniedException ,IOException{ + + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new IOException("error")).when(adminService).dropConsumerCache(dmaaPContext); + try { + adminRestService.dropConsumerCache(); + } + catch (CambriaApiException e) { + assertTrue(true); + } + + + } + @Test + public void testDropConsumerCach_error1() throws CambriaApiException, AccessDeniedException,IOException { + + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).dropConsumerCache(dmaaPContext); + try { + adminRestService.dropConsumerCache(); + } + catch (CambriaApiException e) { + assertTrue(true); + } + + + } + + @Test + public void testGetBlacklist() throws CambriaApiException, AccessDeniedException { + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeaderNames()).thenReturn(headerNames); + when(headerNames.nextElement()).thenReturn("key"); + when(httpServReq.getHeader("key")).thenReturn("value"); + + adminRestService.getBlacklist(); + + } + + //@Test + public void testGetBlacklist_error() throws CambriaApiException, AccessDeniedException,IOException { + + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new IOException("error")).when(adminService).getBlacklist(dmaaPContext); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeaderNames()).thenReturn(headerNames); + when(headerNames.nextElement()).thenReturn("key"); + when(httpServReq.getHeader("key")).thenReturn("value"); + when(headerNames.hasMoreElements()).thenReturn(false); + try { + adminRestService.getBlacklist(); + } + catch (CambriaApiException e) { + assertTrue(true); + } + + } + + ////@Test + public void testGetBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException { + + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).getBlacklist(dmaaPContext); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeaderNames()).thenReturn(headerNames); + when(headerNames.nextElement()).thenReturn("key"); + when(httpServReq.getHeader("key")).thenReturn("value"); + when(headerNames.hasMoreElements()).thenReturn(false); + try { + adminRestService.getBlacklist(); + } + catch (CambriaApiException e) { + assertTrue(true); + } + + } + + @Test + public void testAddToBlacklist() throws CambriaApiException, AccessDeniedException { + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + + adminRestService.addToBlacklist("120.120.120.120"); + + } + + @Test + public void testAddToBlacklist_error() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException { + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).addToBlacklist(dmaaPContext,"120.120.120.120"); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + try { + adminRestService.addToBlacklist("120.120.120.120"); + }catch (CambriaApiException e) { + assertTrue(true); + } + + } + + @Test + public void testAddToBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException, ConfigDbException { + + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new IOException("error")).when(adminService).addToBlacklist(dmaaPContext,"120.120.120.120"); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + try { + adminRestService.addToBlacklist("120.120.120.120"); + }catch (CambriaApiException e) { + assertTrue(true); + } + + } + + @Test + public void testRemoveFromBlacklist() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException { + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + + adminRestService.removeFromBlacklist("120.120.120.120"); + + } + + @Test + public void testRemoveFromBlacklist_error() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException{ + + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new IOException("error")).when(adminService).removeFromBlacklist(dmaaPContext,"120.120.120.120"); + + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + try { + + adminRestService.removeFromBlacklist("120.120.120.120"); + }catch (CambriaApiException e) { + assertTrue(true); + } + catch (AccessDeniedException e) { + assertTrue(true); + } + catch (ConfigDbException e) { + assertTrue(true); + } + + } + + @Test + public void testRemoveFromBlacklist_error1() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException { + + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext); + PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).removeFromBlacklist(dmaaPContext,"120.120.120.120"); + + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + try { + + adminRestService.removeFromBlacklist("120.120.120.120"); + }catch (CambriaApiException e) { + assertTrue(true); + } + catch (AccessDeniedException e) { + assertTrue(true); + } + catch (ConfigDbException e) { + assertTrue(true); + } + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/service/ApiKeysRestServiceTest.java b/src/test/java/org/onap/dmaap/service/ApiKeysRestServiceTest.java index c784f90..20438f3 100644 --- a/src/test/java/com/att/nsa/dmaap/service/ApiKeysRestServiceTest.java +++ b/src/test/java/org/onap/dmaap/service/ApiKeysRestServiceTest.java @@ -1,232 +1,232 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.service;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.json.JSONException;
-
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
-import org.onap.dmaap.dmf.mr.service.ApiKeysService;
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.db.NsaApiDb.KeyExistsException;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ ServiceUtil.class })
-public class ApiKeysRestServiceTest {
-
- @InjectMocks
- private ApiKeysRestService service;
-
- @Mock
- ApiKeysService apiKeyService;
-
- @Mock
- DMaaPContext dmaapContext;
-
- @Mock
- HttpServletRequest httpServReq;
- @Mock
- private HttpServletResponse response;
- @Mock
- private ConfigurationReader configReader;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetAllApiKeys() {
-
- try {
- service.getAllApiKeys();
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testGetAllApiKeys_error() throws ConfigDbException, IOException {
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).getAllApiKeys(dmaapContext);
- try {
- service.getAllApiKeys();
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- assertTrue(true);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testGetApiKey() {
-
- try {
- service.getApiKey("apikeyName");
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testGetApiKey_error() throws ConfigDbException, IOException {
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).getApiKey(dmaapContext, "apikeyName");
-
- try {
- service.getApiKey("apikeyName");
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- assertTrue(true);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testCreateApiKey() {
-
- try {
- service.createApiKey(new ApiKeyBean("hs647a@att.com", "test apikey"));
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testCreateApiKey_error()
- throws CambriaApiException, JSONException, KeyExistsException, ConfigDbException, IOException {
-
- ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).createApiKey(dmaapContext, bean);
-
- try {
- service.createApiKey(bean);
- } catch (CambriaApiException e) {
- assertTrue(true);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testUpdateApiKey() {
-
- try {
- service.updateApiKey("apikeyName", new ApiKeyBean("hs647a@att.com", "test apikey"));
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testUpdateApiKey_error() throws CambriaApiException, JSONException, KeyExistsException,
- ConfigDbException, IOException, AccessDeniedException {
-
- ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");
- PowerMockito.mockStatic(ServiceUtil.class);
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).updateApiKey(dmaapContext, "apikeyName",
- bean);
- try {
- service.updateApiKey("apikeyName", bean);
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testDeleteApiKey() {
-
- try {
- service.deleteApiKey("apikeyName");
- } catch (CambriaApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
- }
-
+/*- + * ============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.service; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.onap.dmaap.dmf.mr.CambriaApiException; +import org.onap.dmaap.dmf.mr.beans.ApiKeyBean; +import com.att.nsa.configs.ConfigDbException; +import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.json.JSONException; + +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.onap.dmaap.dmf.mr.beans.DMaaPContext; + +import org.onap.dmaap.dmf.mr.utils.ConfigurationReader; +import org.onap.dmaap.dmf.mr.service.ApiKeysService; +import org.onap.dmaap.dmf.mr.utils.ConfigurationReader; +import com.att.nsa.configs.ConfigDbException; +import com.att.nsa.security.db.NsaApiDb.KeyExistsException; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ ServiceUtil.class }) +public class ApiKeysRestServiceTest { + + @InjectMocks + private ApiKeysRestService service; + + @Mock + ApiKeysService apiKeyService; + + @Mock + DMaaPContext dmaapContext; + + @Mock + HttpServletRequest httpServReq; + @Mock + private HttpServletResponse response; + @Mock + private ConfigurationReader configReader; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetAllApiKeys() { + + try { + service.getAllApiKeys(); + } catch (CambriaApiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testGetAllApiKeys_error() throws ConfigDbException, IOException { + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext); + PowerMockito.doThrow(new IOException("error")).when(apiKeyService).getAllApiKeys(dmaapContext); + try { + service.getAllApiKeys(); + } catch (CambriaApiException e) { + // TODO Auto-generated catch block + assertTrue(true); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testGetApiKey() { + + try { + service.getApiKey("apikeyName"); + } catch (CambriaApiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testGetApiKey_error() throws ConfigDbException, IOException { + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext); + PowerMockito.doThrow(new IOException("error")).when(apiKeyService).getApiKey(dmaapContext, "apikeyName"); + + try { + service.getApiKey("apikeyName"); + } catch (CambriaApiException e) { + // TODO Auto-generated catch block + assertTrue(true); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testCreateApiKey() { + + try { + service.createApiKey(new ApiKeyBean("hs647a@att.com", "test apikey")); + } catch (CambriaApiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testCreateApiKey_error() + throws CambriaApiException, JSONException, KeyExistsException, ConfigDbException, IOException { + + ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey"); + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext); + PowerMockito.doThrow(new IOException("error")).when(apiKeyService).createApiKey(dmaapContext, bean); + + try { + service.createApiKey(bean); + } catch (CambriaApiException e) { + assertTrue(true); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testUpdateApiKey() { + + try { + service.updateApiKey("apikeyName", new ApiKeyBean("hs647a@att.com", "test apikey")); + } catch (CambriaApiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testUpdateApiKey_error() throws CambriaApiException, JSONException, KeyExistsException, + ConfigDbException, IOException, AccessDeniedException { + + ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey"); + PowerMockito.mockStatic(ServiceUtil.class); + PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext); + PowerMockito.doThrow(new IOException("error")).when(apiKeyService).updateApiKey(dmaapContext, "apikeyName", + bean); + try { + service.updateApiKey("apikeyName", bean); + } catch (CambriaApiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + + @Test + public void testDeleteApiKey() { + + try { + service.deleteApiKey("apikeyName"); + } catch (CambriaApiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NullPointerException e) { + assertTrue(true); + } + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/service/EventsRestServiceTest.java b/src/test/java/org/onap/dmaap/service/EventsRestServiceTest.java index 985d38f..7f30cf4 100644 --- a/src/test/java/com/att/nsa/dmaap/service/EventsRestServiceTest.java +++ b/src/test/java/org/onap/dmaap/service/EventsRestServiceTest.java @@ -1,328 +1,328 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package com.att.nsa.dmaap.service;
-
-import java.util.Date;
-
-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.Mockito;
-import org.mockito.MockitoAnnotations;
-import static org.mockito.Matchers.any;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.api.mockito.PowerMockito;
-import static org.mockito.Mockito.when;
-
-import com.att.ajsc.beans.PropertiesMapBean;
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;
-import org.onap.dmaap.dmf.mr.service.EventsService;
-import com.att.nsa.configs.ConfigDbException;
-import org.onap.dmaap.dmf.mr.utils.Utils;
-import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;
-import org.onap.dmaap.dmf.mr.exception.ErrorResponse;
-import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ PropertiesMapBean.class })
-public class EventsRestServiceTest {
-
- @InjectMocks
- EventsRestService eventsRestRestService;
-
- @Mock
- private EventsService eventsService;
-
- @Mock
- ErrorResponse errorResponse;
-
- @Mock
- DMaaPContext dmaapContext;
-
- @Mock
- InputStream iStream;
-
- @Mock
- ServletInputStream servletInputStream;
-
- @Mock
- HttpServletRequest request;
-
- @Mock
- private DMaaPErrorMessages errorMessages;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetEvents() throws CambriaApiException {
-
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");
-
- }
-
- @Test
- public void testGetEvents_error() {
-
- try {
- PowerMockito.doThrow(new IOException()).when(eventsService).getEvents(any(), any(),
- any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | UnavailableException | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).getEvents(any(), any(),
- any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | UnavailableException | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).getEvents(any(),
- any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | UnavailableException | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
- @Test(expected = TopicExistsException.class)
- public void testGetEvents_TopicExistException() throws CambriaApiException, ConfigDbException, TopicExistsException,
- UnavailableException, IOException, AccessDeniedException {
-
- Mockito.doThrow(new TopicExistsException("topic exists")).when(eventsService).getEvents(any(),
- any(), any(), any());
-
- eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");
-
- }
-
- @Test(expected = DMaaPAccessDeniedException.class)
- public void testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException, ConfigDbException,
- TopicExistsException, UnavailableException, IOException, AccessDeniedException {
-
- Mockito.doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(any(),
- any(), any(), any());
-
- eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");
-
- }
-
- /*
- * @Test(expected = DMaaPAccessDeniedException.class) public void
- * testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException,
- * ConfigDbException, TopicExistsException, UnavailableException,
- * IOException, AccessDeniedException {
- *
- * Mockito.doThrow(new
- * DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(
- * dmaapContext, "topicName", "consumergroup", "consumerid");
- *
- * eventsService.getEvents(dmaapContext, "topicName", "consumergroup",
- * "consumerid");
- *
- * }
- */
-
- @Test
- public void testPushEvents() throws CambriaApiException {
-
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
-
- }
-
- @Test
- public void testPushEvents_error() {
-
- try {
- PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(),
- any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(), any(),
- any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(),
- any(), any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testPushEvents_TopicExistException() throws CambriaApiException {
-
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");
-
- }
-
- @Test
- public void tesTPushEventsWithTransaction() throws CambriaApiException, IOException {
- when(request.getInputStream()).thenReturn(servletInputStream);
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");
-
- }
-
- @Test
- public void tesTPushEventsWithTransaction_error() throws IOException {
- when(request.getInputStream()).thenReturn(servletInputStream);
- ServletInputStream stream = request.getInputStream();
-
- try {
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(),
- any(), any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(),any(),
- any(), any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(),
- any(), any());
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException
- | missingReqdSetting | IOException excp) {
- assertTrue(false);
- } catch (CambriaApiException e) {
- assertTrue(false);
- }
-
- try {
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
-}
+/*- + * ============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.service; + +import java.util.Date; + +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.Mockito; +import org.mockito.MockitoAnnotations; +import static org.mockito.Matchers.any; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.api.mockito.PowerMockito; +import static org.mockito.Mockito.when; + +import com.att.ajsc.beans.PropertiesMapBean; +import org.onap.dmaap.dmf.mr.CambriaApiException; +import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException; +import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages; +import org.onap.dmaap.dmf.mr.service.EventsService; +import com.att.nsa.configs.ConfigDbException; +import org.onap.dmaap.dmf.mr.utils.Utils; +import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting; +import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Date; + +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; + +import org.onap.dmaap.dmf.mr.beans.DMaaPContext; +import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException; +import org.onap.dmaap.dmf.mr.exception.ErrorResponse; +import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ PropertiesMapBean.class }) +public class EventsRestServiceTest { + + @InjectMocks + EventsRestService eventsRestRestService; + + @Mock + private EventsService eventsService; + + @Mock + ErrorResponse errorResponse; + + @Mock + DMaaPContext dmaapContext; + + @Mock + InputStream iStream; + + @Mock + ServletInputStream servletInputStream; + + @Mock + HttpServletRequest request; + + @Mock + private DMaaPErrorMessages errorMessages; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetEvents() throws CambriaApiException { + + eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid"); + + } + + @Test + public void testGetEvents_error() { + + try { + PowerMockito.doThrow(new IOException()).when(eventsService).getEvents(any(), any(), + any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | UnavailableException | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).getEvents(any(), any(), + any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | UnavailableException | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).getEvents(any(), + any(), any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | UnavailableException | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + } + + @Test(expected = TopicExistsException.class) + public void testGetEvents_TopicExistException() throws CambriaApiException, ConfigDbException, TopicExistsException, + UnavailableException, IOException, AccessDeniedException { + + Mockito.doThrow(new TopicExistsException("topic exists")).when(eventsService).getEvents(any(), + any(), any(), any()); + + eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid"); + + } + + @Test(expected = DMaaPAccessDeniedException.class) + public void testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException, ConfigDbException, + TopicExistsException, UnavailableException, IOException, AccessDeniedException { + + Mockito.doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(any(), + any(), any(), any()); + + eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid"); + + } + + /* + * @Test(expected = DMaaPAccessDeniedException.class) public void + * testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException, + * ConfigDbException, TopicExistsException, UnavailableException, + * IOException, AccessDeniedException { + * + * Mockito.doThrow(new + * DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents( + * dmaapContext, "topicName", "consumergroup", "consumerid"); + * + * eventsService.getEvents(dmaapContext, "topicName", "consumergroup", + * "consumerid"); + * + * } + */ + + @Test + public void testPushEvents() throws CambriaApiException { + + eventsRestRestService.pushEvents("topicName", iStream, "partitionKey"); + + } + + @Test + public void testPushEvents_error() { + + try { + PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(), + any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | missingReqdSetting | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.pushEvents("topicName", iStream, "partitionKey"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(), any(), + any(), any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | missingReqdSetting | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.pushEvents("topicName", iStream, "partitionKey"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(), + any(), any(), any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | missingReqdSetting | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.pushEvents("topicName", iStream, "partitionKey"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + } + + @Test + public void testPushEvents_TopicExistException() throws CambriaApiException { + + eventsRestRestService.pushEvents("topicName", iStream, "partitionKey"); + + } + + @Test + public void tesTPushEventsWithTransaction() throws CambriaApiException, IOException { + when(request.getInputStream()).thenReturn(servletInputStream); + eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey"); + + } + + @Test + public void tesTPushEventsWithTransaction_error() throws IOException { + when(request.getInputStream()).thenReturn(servletInputStream); + ServletInputStream stream = request.getInputStream(); + + try { + PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(), + any(), any(), any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | missingReqdSetting | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(),any(), + any(), any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | missingReqdSetting | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(), + any(), any()); + } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException + | missingReqdSetting | IOException excp) { + assertTrue(false); + } catch (CambriaApiException e) { + assertTrue(false); + } + + try { + eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/service/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/service/JUnitTestSuite.java index b01a33e..c1518af 100644 --- a/src/test/java/com/att/nsa/dmaap/service/JUnitTestSuite.java +++ b/src/test/java/org/onap/dmaap/service/JUnitTestSuite.java @@ -1,44 +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 com.att.nsa.dmaap.service;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ AdminRestServiceTest.class, ApiKeysRestServiceTest.class,
- EventsRestServiceTest.class, MetricsRestServiceTest.class, MMRestServiceTest.class,
- TopicRestServiceTest.class, TransactionRestServiceTest.class, UIRestServicesTest.class,})
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
+/*- + * ============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.service; + +import junit.framework.TestSuite; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.apache.log4j.Logger; + +@RunWith(Suite.class) +@SuiteClasses({ AdminRestServiceTest.class, ApiKeysRestServiceTest.class, + EventsRestServiceTest.class, MetricsRestServiceTest.class, MMRestServiceTest.class, + TopicRestServiceTest.class, TransactionRestServiceTest.class, UIRestServicesTest.class,}) +public class JUnitTestSuite { + private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class); + + public static void main(String[] args) { + LOGGER.info("Running the test suite"); + + TestSuite tstSuite = new TestSuite(); + LOGGER.info("Total Test Counts " + tstSuite.countTestCases()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/service/MMRestServiceTest.java b/src/test/java/org/onap/dmaap/service/MMRestServiceTest.java index 29d6bc4..4832d84 100644 --- a/src/test/java/com/att/nsa/dmaap/service/MMRestServiceTest.java +++ b/src/test/java/org/onap/dmaap/service/MMRestServiceTest.java @@ -1,384 +1,384 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.service;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.anyString;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-
-//import static org.mockito.Matchers.anyString;
-//import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.IOUtils;
-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.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.att.ajsc.beans.PropertiesMapBean;
-import com.att.ajsc.filemonitor.AJSCPropertiesMap;
-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.constants.CambriaConstants;
-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.Topic;
-import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator;
-import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticatorImpl;
-import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;
-import org.onap.dmaap.dmf.mr.service.MMService;
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.dmaap.mmagent.CreateMirrorMaker;
-import com.att.nsa.dmaap.mmagent.MirrorMaker;
-import com.att.nsa.dmaap.mmagent.UpdateMirrorMaker;
-import com.att.nsa.security.NsaAcl;
-import com.att.nsa.security.NsaApiKey;
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;
-import com.google.gson.Gson;
-
-//@RunWith(MockitoJUnitRunner.class)
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ PropertiesMapBean.class, AJSCPropertiesMap.class })
-public class MMRestServiceTest {
-
- @InjectMocks
- MMRestService mmRestService;
-
- @Mock
- private MMService mmservice;
-
- @Mock
- CreateMirrorMaker cMirroMaker;
-
- @Mock
- UpdateMirrorMaker uMirroMaker;
-
- private TopicRestService service = new TopicRestService();
- @Mock
- private DMaaPErrorMessages errorMessages;
-
- @Mock
- DMaaPContext dmaapContext;
-
- @Mock
- ConfigurationReader configReader;
-
- @Mock
- ServletOutputStream oStream;
-
- @Mock
- DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
-
- @Mock
- MirrorMaker mMaker;
-
- @Mock
- DMaaPAAFAuthenticator dmaapAAFauthenticator;
-
- @Mock
- DMaaPAAFAuthenticatorImpl impl;
-
- @Mock
- NsaApiKey user;
-
- @Mock
- NsaSimpleApiKey nsaSimpleApiKey;
-
- @Mock
- HttpServletRequest httpServReq;
-
- @Mock
- HttpServletResponse httpServRes;
-
- @Mock
- InputStream iStream;
-
- @Mock
- DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;
-
- @Mock
- Topic createdTopic;
-
- @Mock
- NsaAcl nsaAcl;
-
- @Mock
- JSONObject jsonObj;
-
- @Mock
- JSONArray jsonArray;
-
- @Before
- public void setUp() throws Exception {
-
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testCallCreateMirrorMaker() throws Exception {
- prepareForTestCommon();
-
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {
- // name:\"test\", consumer:\"test\", producer:\"test\",
- // whitelist:\"test\",status:\"test\" }}";
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callCreateMirrorMaker(inputSteam);
- assertTrue(true);
-
- }
- @Test
- public void testCallCreateMirrorMaker_error4() throws Exception {
- prepareForTestCommon();
-
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {
- // name:\"test\", consumer:\"test\", producer:\"test\",
- // whitelist:\"test\",status:\"test\" }}";
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test@#\", consumer:\"test\", producer:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callCreateMirrorMaker(inputSteam);
- assertTrue(true);
-
- }
- @Test
- public void testCallCreateMirrorMaker_3() throws Exception {
- prepareForTestCommon();
-
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {
- // name:\"test\", consumer:\"test\", producer:\"test\",
- // whitelist:\"test\",status:\"test\" }}";
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"\", consumer:\"test\", producer:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callCreateMirrorMaker(inputSteam);
- assertTrue(true);
-
- }
- @Test
- public void testCallCreateMirrorMaker_error2() throws Exception {
- prepareForTestCommon();
-
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {
- // name:\"test\", consumer:\"test\", producer:\"test\",
- // whitelist:\"test\",status:\"test\" }}";
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\",whitelist:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callCreateMirrorMaker(inputSteam);
- assertTrue(true);
-
- }
-
- @Test
- public void testCallCreateMirrorMaker_error1() throws Exception {
- prepareForTestCommon();
-
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {
- // name:\"test\", consumer:\"test\", producer:\"test\",
- // whitelist:\"test\",status:\"test\" }}";
- String sampleJson = "{ messageID:\"test\"}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callCreateMirrorMaker(inputSteam);
- assertTrue(true);
-
- }
-
- @Test
- public void testCallListAllMirrorMaker() throws Exception {
- prepareForTestCommon();
-
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\" }}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callListAllMirrorMaker(inputSteam);
- assertTrue(true);
- }
-
- @Test
- public void testCallUpdateMirrorMaker() throws Exception {
- prepareForTestCommon();
-
- String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callUpdateMirrorMaker(inputSteam);
- assertTrue(true);
- }
-
- @Test
- public void testCallUpdateMirrorMaker_error1() throws Exception {
- prepareForTestCommon();
-
- String sampleJson = "{ messageID:\"test@1\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callUpdateMirrorMaker(inputSteam);
- assertTrue(true);
- }
- @Test
- public void testCallUpdateMirrorMaker_error2() throws Exception {
- prepareForTestCommon();
-
- String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"\", consumer:\"test\", producer:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callUpdateMirrorMaker(inputSteam);
- assertTrue(true);
- }
- @Test
- public void testCallUpdateMirrorMaker_error3() throws Exception{
- prepareForTestCommon();
-
- String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callUpdateMirrorMaker(inputSteam);
- assertTrue(true);
- }
- @Test
- public void testCallUpdateMirrorMaker_error4() throws Exception {
- prepareForTestCommon();
-
- String sampleJson = "{ messageID:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callUpdateMirrorMaker(inputSteam);
- assertTrue(true);
- }
-
- @Test
- public void testCallDeleteMirrorMaker() throws Exception {
- prepareForTestCommon();
-
- String sampleJson = "{ messageID:\"test\", deleteMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\" }}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.callDeleteMirrorMaker(inputSteam);
- assertTrue(true);
- }
-
- @Test
- public void testListWhiteList() throws Exception {
- prepareForTestCommon();
-
- String sampleJson = "{ name:\"test\", namespace:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.listWhiteList(inputSteam);
- assertTrue(true);
- }
-
- @Test
- public void testCreateWhiteList() throws Exception {
- prepareForTestCommon();
- String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
-
- mmRestService.createWhiteList(inputSteam);
- assertTrue(true);
- }
-
- @Test
- public void testDeleteWhiteList() throws Exception {
- prepareForTestCommon();
-
- String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());
- mmRestService.deleteWhiteList(inputSteam);
- assertTrue(true);
- }
-
- private void prepareForTestCommon() throws Exception {
- Assert.assertNotNull(mmRestService);
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq);
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);
- PowerMockito.when(httpServReq.isUserInRole("admin")).thenReturn(true);
-
- PowerMockito.mockStatic(AJSCPropertiesMap.class);
-
- assertTrue(true);
-
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeradmin.aaf"))
- .thenReturn("admin");
- PowerMockito
- .when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf.create"))
- .thenReturn("aafcreate");
-
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf"))
- .thenReturn("admin");
-
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.timeout"))
- .thenReturn("100");
-
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.topic"))
- .thenReturn("mirrormaker.topic");
-
- PowerMockito
- .when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumergroup"))
- .thenReturn("mirrormaker.consumergroup");
-
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumerid"))
- .thenReturn("mirrormaker.consumerid");
-
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq);
-
- PowerMockito.when(httpServReq.isUserInRole("admin")).thenReturn(true);
-
- // PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin.aaf")).thenReturn(true);
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);
- PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Admin");
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "aafcreatetest|create"))
- .thenReturn(true);
-
- PowerMockito.when(cMirroMaker.getCreateMirrorMaker()).thenReturn(mMaker);
-
- PowerMockito.when(mMaker.getName()).thenReturn("mirroMakerName");
- PowerMockito.when(dmaapContext.getConfigReader()).thenReturn(configReader);
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq);
- PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");
-
- PowerMockito.when(dmaapContext.getResponse()).thenReturn(httpServRes);
- PowerMockito.when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
- PowerMockito.when(httpServReq.getMethod()).thenReturn("HEAD");
-
- PowerMockito.when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);
- }
-
-}
+/*- + * ============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.service; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.anyString; + +import java.io.ByteArrayInputStream; +import java.io.FileInputStream; + +//import static org.mockito.Matchers.anyString; +//import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.io.InputStream; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.io.IOUtils; +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.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.att.ajsc.beans.PropertiesMapBean; +import com.att.ajsc.filemonitor.AJSCPropertiesMap; +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.constants.CambriaConstants; +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.Topic; +import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator; +import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticatorImpl; +import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator; +import org.onap.dmaap.dmf.mr.service.MMService; +import org.onap.dmaap.dmf.mr.utils.ConfigurationReader; +import com.att.nsa.configs.ConfigDbException; +import org.onap.dmaap.mmagent.CreateMirrorMaker; +import org.onap.dmaap.mmagent.MirrorMaker; +import org.onap.dmaap.mmagent.UpdateMirrorMaker; +import com.att.nsa.security.NsaAcl; +import com.att.nsa.security.NsaApiKey; +import com.att.nsa.security.db.simple.NsaSimpleApiKey; +import com.google.gson.Gson; + +//@RunWith(MockitoJUnitRunner.class) +@RunWith(PowerMockRunner.class) +@PrepareForTest({ PropertiesMapBean.class, AJSCPropertiesMap.class }) +public class MMRestServiceTest { + + @InjectMocks + MMRestService mmRestService; + + @Mock + private MMService mmservice; + + @Mock + CreateMirrorMaker cMirroMaker; + + @Mock + UpdateMirrorMaker uMirroMaker; + + private TopicRestService service = new TopicRestService(); + @Mock + private DMaaPErrorMessages errorMessages; + + @Mock + DMaaPContext dmaapContext; + + @Mock + ConfigurationReader configReader; + + @Mock + ServletOutputStream oStream; + + @Mock + DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator; + + @Mock + MirrorMaker mMaker; + + @Mock + DMaaPAAFAuthenticator dmaapAAFauthenticator; + + @Mock + DMaaPAAFAuthenticatorImpl impl; + + @Mock + NsaApiKey user; + + @Mock + NsaSimpleApiKey nsaSimpleApiKey; + + @Mock + HttpServletRequest httpServReq; + + @Mock + HttpServletResponse httpServRes; + + @Mock + InputStream iStream; + + @Mock + DMaaPKafkaMetaBroker dmaapKafkaMetaBroker; + + @Mock + Topic createdTopic; + + @Mock + NsaAcl nsaAcl; + + @Mock + JSONObject jsonObj; + + @Mock + JSONArray jsonArray; + + @Before + public void setUp() throws Exception { + + MockitoAnnotations.initMocks(this); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testCallCreateMirrorMaker() throws Exception { + prepareForTestCommon(); + + // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: { + // name:\"test\", consumer:\"test\", producer:\"test\", + // whitelist:\"test\",status:\"test\" }}"; + String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callCreateMirrorMaker(inputSteam); + assertTrue(true); + + } + @Test + public void testCallCreateMirrorMaker_error4() throws Exception { + prepareForTestCommon(); + + // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: { + // name:\"test\", consumer:\"test\", producer:\"test\", + // whitelist:\"test\",status:\"test\" }}"; + String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test@#\", consumer:\"test\", producer:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callCreateMirrorMaker(inputSteam); + assertTrue(true); + + } + @Test + public void testCallCreateMirrorMaker_3() throws Exception { + prepareForTestCommon(); + + // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: { + // name:\"test\", consumer:\"test\", producer:\"test\", + // whitelist:\"test\",status:\"test\" }}"; + String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"\", consumer:\"test\", producer:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callCreateMirrorMaker(inputSteam); + assertTrue(true); + + } + @Test + public void testCallCreateMirrorMaker_error2() throws Exception { + prepareForTestCommon(); + + // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: { + // name:\"test\", consumer:\"test\", producer:\"test\", + // whitelist:\"test\",status:\"test\" }}"; + String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\",whitelist:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callCreateMirrorMaker(inputSteam); + assertTrue(true); + + } + + @Test + public void testCallCreateMirrorMaker_error1() throws Exception { + prepareForTestCommon(); + + // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: { + // name:\"test\", consumer:\"test\", producer:\"test\", + // whitelist:\"test\",status:\"test\" }}"; + String sampleJson = "{ messageID:\"test\"}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callCreateMirrorMaker(inputSteam); + assertTrue(true); + + } + + @Test + public void testCallListAllMirrorMaker() throws Exception { + prepareForTestCommon(); + + String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\" }}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callListAllMirrorMaker(inputSteam); + assertTrue(true); + } + + @Test + public void testCallUpdateMirrorMaker() throws Exception { + prepareForTestCommon(); + + String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callUpdateMirrorMaker(inputSteam); + assertTrue(true); + } + + @Test + public void testCallUpdateMirrorMaker_error1() throws Exception { + prepareForTestCommon(); + + String sampleJson = "{ messageID:\"test@1\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callUpdateMirrorMaker(inputSteam); + assertTrue(true); + } + @Test + public void testCallUpdateMirrorMaker_error2() throws Exception { + prepareForTestCommon(); + + String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"\", consumer:\"test\", producer:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callUpdateMirrorMaker(inputSteam); + assertTrue(true); + } + @Test + public void testCallUpdateMirrorMaker_error3() throws Exception{ + prepareForTestCommon(); + + String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callUpdateMirrorMaker(inputSteam); + assertTrue(true); + } + @Test + public void testCallUpdateMirrorMaker_error4() throws Exception { + prepareForTestCommon(); + + String sampleJson = "{ messageID:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callUpdateMirrorMaker(inputSteam); + assertTrue(true); + } + + @Test + public void testCallDeleteMirrorMaker() throws Exception { + prepareForTestCommon(); + + String sampleJson = "{ messageID:\"test\", deleteMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\" }}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.callDeleteMirrorMaker(inputSteam); + assertTrue(true); + } + + @Test + public void testListWhiteList() throws Exception { + prepareForTestCommon(); + + String sampleJson = "{ name:\"test\", namespace:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.listWhiteList(inputSteam); + assertTrue(true); + } + + @Test + public void testCreateWhiteList() throws Exception { + prepareForTestCommon(); + String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + + mmRestService.createWhiteList(inputSteam); + assertTrue(true); + } + + @Test + public void testDeleteWhiteList() throws Exception { + prepareForTestCommon(); + + String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}"; + InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes()); + mmRestService.deleteWhiteList(inputSteam); + assertTrue(true); + } + + private void prepareForTestCommon() throws Exception { + Assert.assertNotNull(mmRestService); + PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq); + PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true); + PowerMockito.when(httpServReq.isUserInRole("admin")).thenReturn(true); + + PowerMockito.mockStatic(AJSCPropertiesMap.class); + + assertTrue(true); + + PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeradmin.aaf")) + .thenReturn("admin"); + PowerMockito + .when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf.create")) + .thenReturn("aafcreate"); + + PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf")) + .thenReturn("admin"); + + PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.timeout")) + .thenReturn("100"); + + PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.topic")) + .thenReturn("mirrormaker.topic"); + + PowerMockito + .when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumergroup")) + .thenReturn("mirrormaker.consumergroup"); + + PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumerid")) + .thenReturn("mirrormaker.consumerid"); + + PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq); + + PowerMockito.when(httpServReq.isUserInRole("admin")).thenReturn(true); + + // PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Admin"); + PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin.aaf")).thenReturn(true); + PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true); + PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Admin"); + PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true); + PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "aafcreatetest|create")) + .thenReturn(true); + + PowerMockito.when(cMirroMaker.getCreateMirrorMaker()).thenReturn(mMaker); + + PowerMockito.when(mMaker.getName()).thenReturn("mirroMakerName"); + PowerMockito.when(dmaapContext.getConfigReader()).thenReturn(configReader); + PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq); + PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Authorization"); + + PowerMockito.when(dmaapContext.getResponse()).thenReturn(httpServRes); + PowerMockito.when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker); + PowerMockito.when(httpServReq.getMethod()).thenReturn("HEAD"); + + PowerMockito.when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/service/MetricsRestServiceTest.java b/src/test/java/org/onap/dmaap/service/MetricsRestServiceTest.java index 5f0669c..1188945 100644 --- a/src/test/java/com/att/nsa/dmaap/service/MetricsRestServiceTest.java +++ b/src/test/java/org/onap/dmaap/service/MetricsRestServiceTest.java @@ -1,74 +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 com.att.nsa.dmaap.service;
-
-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.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.service.MetricsService;
-
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ PropertiesMapBean.class })
-public class MetricsRestServiceTest {
-
- @InjectMocks
- MetricsRestService metricsRestService;
-
- @Mock
- private MetricsService metricsService;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetMetrics() throws CambriaApiException {
-
- metricsRestService.getMetrics();
-
- }
-
- @Test
- public void testGetMetricsByName() throws CambriaApiException {
-
- metricsRestService.getMetricsByName("metricsName");
-
- }
-
-
-
+/*- + * ============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.service; + +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.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.service.MetricsService; + + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ PropertiesMapBean.class }) +public class MetricsRestServiceTest { + + @InjectMocks + MetricsRestService metricsRestService; + + @Mock + private MetricsService metricsService; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetMetrics() throws CambriaApiException { + + metricsRestService.getMetrics(); + + } + + @Test + public void testGetMetricsByName() throws CambriaApiException { + + metricsRestService.getMetricsByName("metricsName"); + + } + + + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/service/TestRunner.java b/src/test/java/org/onap/dmaap/service/TestRunner.java index 26a88bb..0441645 100644 --- a/src/test/java/com/att/nsa/dmaap/service/TestRunner.java +++ b/src/test/java/org/onap/dmaap/service/TestRunner.java @@ -1,41 +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 com.att.nsa.dmaap.service;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.apache.log4j.Logger;
-
-public class TestRunner {
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);
- for (Failure failure : result.getFailures()) {
- LOGGER.info(failure.toString());
-
- }
- LOGGER.info(result.wasSuccessful());
- }
-
-}
+/*- + * ============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.service; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.apache.log4j.Logger; + +public class TestRunner { + private static final Logger LOGGER = Logger.getLogger(TestRunner.class); + + public static void main(String[] args) { + // TODO Auto-generated method stub + Result result = JUnitCore.runClasses(JUnitTestSuite.class); + for (Failure failure : result.getFailures()) { + LOGGER.info(failure.toString()); + + } + LOGGER.info(result.wasSuccessful()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/service/TopicRestServiceTest.java b/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java index c805fcb..0c563b4 100644 --- a/src/test/java/com/att/nsa/dmaap/service/TopicRestServiceTest.java +++ b/src/test/java/org/onap/dmaap/service/TopicRestServiceTest.java @@ -1,838 +1,838 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.service;
-
-import static org.junit.Assert.*;
-
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
-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.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.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;
-import org.onap.dmaap.dmf.mr.beans.TopicBean;
-import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
-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.Topic;
-import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator;
-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;
-
-//@RunWith(MockitoJUnitRunner.class)
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ PropertiesMapBean.class })
-public class TopicRestServiceTest {
-
- @InjectMocks
- TopicRestService topicRestService;
-
- @Mock
- private TopicService topicService;
-
- private TopicRestService service = new TopicRestService();
- @Mock
- private DMaaPErrorMessages errorMessages;
-
- @Mock
- DMaaPContext dmaapContext;
-
- @Mock
- ConfigurationReader configReader;
-
- @Mock
- ServletOutputStream oStream;
-
- @Mock
- DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;
-
- @Mock
- DMaaPAAFAuthenticator dmaapAAFauthenticator;
- @Mock
- NsaApiKey user;
-
- @Mock
- NsaSimpleApiKey nsaSimpleApiKey;
-
- @Mock
- HttpServletRequest httpServReq;
-
- @Mock
- HttpServletResponse httpServRes;
-
- @Mock
- DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;
-
- @Mock
- Topic createdTopic;
-
- @Mock
- NsaAcl nsaAcl;
-
- @Mock
- JSONObject jsonObj;
-
- @Mock
- JSONArray jsonArray;
-
- @Before
- public void setUp() throws Exception {
-
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test(expected = DMaaPAccessDeniedException.class)
- public void testGetTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
-
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))
- .thenReturn("namespace");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
- when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);
- when(httpServReq.getMethod()).thenReturn("HEAD");
-
- when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);
-
- topicRestService.getTopics();
- }
-
- @Test
- public void testGetTopics_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
-
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))
- .thenReturn("namespace");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn(null);
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
- String perms = "namespace" + "|" + "*" + "|" + "view";
- when(dmaapAAFauthenticator.aafAuthentication(httpServReq, perms)).thenReturn(true);
-
- when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);
-
- topicRestService.getTopics();
- }
-
- @Test
- public void testGetTopics_error() throws DMaaPAccessDeniedException, TopicExistsException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
-
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))
- .thenReturn("namespace");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn(null);
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
- String perms = "namespace" + "|" + "*" + "|" + "view";
- when(dmaapAAFauthenticator.aafAuthentication(httpServReq, perms)).thenReturn(true);
-
- when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).getTopics(any());
- } catch (JSONException | ConfigDbException | IOException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.getTopics();
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test(expected = DMaaPAccessDeniedException.class)
- public void testGetAllTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
-
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))
- .thenReturn("namespace");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
-
- topicRestService.getAllTopics();
- }
-
- @Test
- public void testGetAllTopics_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))
- .thenReturn("namespace");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn(null);
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
-
- topicRestService.getAllTopics();
- }
-
- @Test
- public void testGetAllTopics_error() throws DMaaPAccessDeniedException, TopicExistsException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))
- .thenReturn("namespace");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn(null);
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).getAllTopics(any());
- } catch (JSONException | ConfigDbException | IOException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.getAllTopics();
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test(expected = DMaaPAccessDeniedException.class)
- public void testGetTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
-
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))
- .thenReturn("enfTopicName");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
-
- topicRestService.getTopic("topicName");
- }
-
- @Test
- public void testGetTopic_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, JSONException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
-
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))
- .thenReturn("enfTopicName");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn(null);
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
-
- topicRestService.getTopic("topicName");
- }
-
- @Test
- public void testGetTopic_error() throws DMaaPAccessDeniedException, ConfigDbException {
-
- Assert.assertNotNull(topicRestService);
-
- PowerMockito.mockStatic(PropertiesMapBean.class);
-
- assertTrue(true);
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))
- .thenReturn("enfTopicName");
-
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(httpServReq.getHeader("Authorization")).thenReturn(null);
-
- when(dmaapContext.getResponse()).thenReturn(httpServRes);
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).getTopic(any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.getTopic("topicName");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testCreateTopic()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.createTopic(topicBean);
- }
-
- @Test
- public void testCreateTopic_error() {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).createTopic(any(), any());
- } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- } catch (CambriaApiException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.createTopic(topicBean);
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new TopicExistsException("error")).when(topicService).createTopic(any(), any());
- } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- } catch (CambriaApiException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.createTopic(topicBean);
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).createTopic(any(), any());
- } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- } catch (CambriaApiException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.createTopic(topicBean);
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testDeleteTopic()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.deleteTopic("enfTopicNamePlusExtra");
- }
-
- @Test
- public void testDeleteTopic_error()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).deleteTopic(any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.deleteTopic("enfTopicNamePlusExtra");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).deleteTopic(any(),
- any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.deleteTopic("enfTopicNamePlusExtra");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testGetPublishersByTopicName()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.getPublishersByTopicName("enfTopicNamePlusExtra");
- }
-
- @Test
- public void testGetPublishersByTopicName_error() {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).getPublishersByTopicName(any(),
- any());
- } catch (TopicExistsException | ConfigDbException | IOException e) {
- assertTrue(false);
- }
-
- try {
- topicRestService.getPublishersByTopicName("enfTopicNamePlusExtra");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testPermitPublisherForTopic()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID");
- }
-
- @Test
- public void testPermitPublisherForTopic_error()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).permitPublisherForTopic(any(),
- any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).permitPublisherForTopic(any(),
- any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testDenyPublisherForTopic()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID");
- }
-
- @Test
- public void testDenyPublisherForTopic_error()
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).denyPublisherForTopic(any(),
- any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).denyPublisherForTopic(any(),
- any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testGetConsumersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, AccessDeniedException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.getConsumersByTopicName("enfTopicNamePlusExtra");
- }
-
- @Test
- public void testGetConsumersByTopicName_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, AccessDeniedException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).getConsumersByTopicName(any(),
- any());
- } catch (TopicExistsException | ConfigDbException | IOException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.getConsumersByTopicName("enfTopicNamePlusExtra");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testPermitConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, AccessDeniedException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID");
- }
-
- @Test
- public void testPermitConsumerForTopic_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, AccessDeniedException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).permitConsumerForTopic(any(),
- any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testPermitConsumerForTopicWithException() throws DMaaPAccessDeniedException, CambriaApiException,
- IOException, TopicExistsException, AccessDeniedException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID");
- }
-
- @Test
- public void testDenyConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, AccessDeniedException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID");
- }
-
- @Test
- public void testDenyConsumerForTopic_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException,
- TopicExistsException, AccessDeniedException {
-
- Assert.assertNotNull(topicRestService);
-
- when(dmaapContext.getRequest()).thenReturn(httpServReq);
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);
- when(dmaapContext.getConfigReader()).thenReturn(configReader);
-
- TopicBean topicBean = new TopicBean();
- topicBean.setTopicName("enfTopicNamePlusExtra");
-
- try {
- PowerMockito.doThrow(new IOException()).when(topicService).denyConsumerForTopic(any(),
- any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
-
- try {
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).denyConsumerForTopic(any(),
- any(), any());
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException
- | DMaaPAccessDeniedException excp) {
- assertTrue(false);
- }
-
- try {
- topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID");
- } catch (CambriaApiException excp) {
- assertTrue(true);
- }
- }
-
-}
+/*- + * ============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.service; + +import static org.junit.Assert.*; + +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.when; + +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.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.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; +import org.onap.dmaap.dmf.mr.beans.TopicBean; +import org.onap.dmaap.dmf.mr.constants.CambriaConstants; +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.Topic; +import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator; +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; + +//@RunWith(MockitoJUnitRunner.class) +@RunWith(PowerMockRunner.class) +@PrepareForTest({ PropertiesMapBean.class }) +public class TopicRestServiceTest { + + @InjectMocks + TopicRestService topicRestService; + + @Mock + private TopicService topicService; + + private TopicRestService service = new TopicRestService(); + @Mock + private DMaaPErrorMessages errorMessages; + + @Mock + DMaaPContext dmaapContext; + + @Mock + ConfigurationReader configReader; + + @Mock + ServletOutputStream oStream; + + @Mock + DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator; + + @Mock + DMaaPAAFAuthenticator dmaapAAFauthenticator; + @Mock + NsaApiKey user; + + @Mock + NsaSimpleApiKey nsaSimpleApiKey; + + @Mock + HttpServletRequest httpServReq; + + @Mock + HttpServletResponse httpServRes; + + @Mock + DMaaPKafkaMetaBroker dmaapKafkaMetaBroker; + + @Mock + Topic createdTopic; + + @Mock + NsaAcl nsaAcl; + + @Mock + JSONObject jsonObj; + + @Mock + JSONArray jsonArray; + + @Before + public void setUp() throws Exception { + + MockitoAnnotations.initMocks(this); + } + + @After + public void tearDown() throws Exception { + } + + @Test(expected = DMaaPAccessDeniedException.class) + public void testGetTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, JSONException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf")) + .thenReturn("namespace"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn("Authorization"); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker); + when(httpServReq.getMethod()).thenReturn("HEAD"); + + when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null); + + topicRestService.getTopics(); + } + + @Test + public void testGetTopics_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, JSONException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf")) + .thenReturn("namespace"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn(null); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + String perms = "namespace" + "|" + "*" + "|" + "view"; + when(dmaapAAFauthenticator.aafAuthentication(httpServReq, perms)).thenReturn(true); + + when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null); + + topicRestService.getTopics(); + } + + @Test + public void testGetTopics_error() throws DMaaPAccessDeniedException, TopicExistsException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf")) + .thenReturn("namespace"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn(null); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + String perms = "namespace" + "|" + "*" + "|" + "view"; + when(dmaapAAFauthenticator.aafAuthentication(httpServReq, perms)).thenReturn(true); + + when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null); + try { + PowerMockito.doThrow(new IOException()).when(topicService).getTopics(any()); + } catch (JSONException | ConfigDbException | IOException excp) { + assertTrue(false); + } + + try { + topicRestService.getTopics(); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test(expected = DMaaPAccessDeniedException.class) + public void testGetAllTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, JSONException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf")) + .thenReturn("namespace"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn("Authorization"); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + + topicRestService.getAllTopics(); + } + + @Test + public void testGetAllTopics_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, JSONException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf")) + .thenReturn("namespace"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn(null); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + + topicRestService.getAllTopics(); + } + + @Test + public void testGetAllTopics_error() throws DMaaPAccessDeniedException, TopicExistsException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf")) + .thenReturn("namespace"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn(null); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).getAllTopics(any()); + } catch (JSONException | ConfigDbException | IOException excp) { + assertTrue(false); + } + + try { + topicRestService.getAllTopics(); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test(expected = DMaaPAccessDeniedException.class) + public void testGetTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, JSONException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF")) + .thenReturn("enfTopicName"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn("Authorization"); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + + topicRestService.getTopic("topicName"); + } + + @Test + public void testGetTopic_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, JSONException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF")) + .thenReturn("enfTopicName"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn(null); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + + topicRestService.getTopic("topicName"); + } + + @Test + public void testGetTopic_error() throws DMaaPAccessDeniedException, ConfigDbException { + + Assert.assertNotNull(topicRestService); + + PowerMockito.mockStatic(PropertiesMapBean.class); + + assertTrue(true); + when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF")) + .thenReturn("enfTopicName"); + + PowerMockito.mockStatic(DMaaPResponseBuilder.class); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(httpServReq.getHeader("Authorization")).thenReturn(null); + + when(dmaapContext.getResponse()).thenReturn(httpServRes); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).getTopic(any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException excp) { + assertTrue(false); + } + + try { + topicRestService.getTopic("topicName"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test + public void testCreateTopic() + throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.createTopic(topicBean); + } + + @Test + public void testCreateTopic_error() { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).createTopic(any(), any()); + } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) { + assertTrue(false); + } catch (CambriaApiException excp) { + assertTrue(false); + } + + try { + topicRestService.createTopic(topicBean); + } catch (CambriaApiException excp) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new TopicExistsException("error")).when(topicService).createTopic(any(), any()); + } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) { + assertTrue(false); + } catch (CambriaApiException excp) { + assertTrue(false); + } + + try { + topicRestService.createTopic(topicBean); + } catch (CambriaApiException excp) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new AccessDeniedException()).when(topicService).createTopic(any(), any()); + } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) { + assertTrue(false); + } catch (CambriaApiException excp) { + assertTrue(false); + } + + try { + topicRestService.createTopic(topicBean); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test + public void testDeleteTopic() + throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.deleteTopic("enfTopicNamePlusExtra"); + } + + @Test + public void testDeleteTopic_error() + throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).deleteTopic(any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.deleteTopic("enfTopicNamePlusExtra"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new AccessDeniedException()).when(topicService).deleteTopic(any(), + any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.deleteTopic("enfTopicNamePlusExtra"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test + public void testGetPublishersByTopicName() + throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.getPublishersByTopicName("enfTopicNamePlusExtra"); + } + + @Test + public void testGetPublishersByTopicName_error() { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).getPublishersByTopicName(any(), + any()); + } catch (TopicExistsException | ConfigDbException | IOException e) { + assertTrue(false); + } + + try { + topicRestService.getPublishersByTopicName("enfTopicNamePlusExtra"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test + public void testPermitPublisherForTopic() + throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID"); + } + + @Test + public void testPermitPublisherForTopic_error() + throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).permitPublisherForTopic(any(), + any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new AccessDeniedException()).when(topicService).permitPublisherForTopic(any(), + any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test + public void testDenyPublisherForTopic() + throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID"); + } + + @Test + public void testDenyPublisherForTopic_error() + throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).denyPublisherForTopic(any(), + any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new AccessDeniedException()).when(topicService).denyPublisherForTopic(any(), + any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + + } + + @Test + public void testGetConsumersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, AccessDeniedException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.getConsumersByTopicName("enfTopicNamePlusExtra"); + } + + @Test + public void testGetConsumersByTopicName_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, AccessDeniedException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).getConsumersByTopicName(any(), + any()); + } catch (TopicExistsException | ConfigDbException | IOException excp) { + assertTrue(false); + } + + try { + topicRestService.getConsumersByTopicName("enfTopicNamePlusExtra"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test + public void testPermitConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, AccessDeniedException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID"); + } + + @Test + public void testPermitConsumerForTopic_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, AccessDeniedException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).permitConsumerForTopic(any(), + any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + + @Test + public void testPermitConsumerForTopicWithException() throws DMaaPAccessDeniedException, CambriaApiException, + IOException, TopicExistsException, AccessDeniedException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID"); + } + + @Test + public void testDenyConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, AccessDeniedException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID"); + } + + @Test + public void testDenyConsumerForTopic_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException, + TopicExistsException, AccessDeniedException { + + Assert.assertNotNull(topicRestService); + + when(dmaapContext.getRequest()).thenReturn(httpServReq); + when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey); + when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator); + when(dmaapContext.getConfigReader()).thenReturn(configReader); + + TopicBean topicBean = new TopicBean(); + topicBean.setTopicName("enfTopicNamePlusExtra"); + + try { + PowerMockito.doThrow(new IOException()).when(topicService).denyConsumerForTopic(any(), + any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + + try { + PowerMockito.doThrow(new AccessDeniedException()).when(topicService).denyConsumerForTopic(any(), + any(), any()); + } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException + | DMaaPAccessDeniedException excp) { + assertTrue(false); + } + + try { + topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID"); + } catch (CambriaApiException excp) { + assertTrue(true); + } + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/service/TransactionRestServiceTest.java b/src/test/java/org/onap/dmaap/service/TransactionRestServiceTest.java index a5abb75..b849daa 100644 --- a/src/test/java/com/att/nsa/dmaap/service/TransactionRestServiceTest.java +++ b/src/test/java/org/onap/dmaap/service/TransactionRestServiceTest.java @@ -1,123 +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 com.att.nsa.dmaap.service;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-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.service.EventsService;
-import org.onap.dmaap.dmf.mr.service.TransactionService;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-import com.att.aft.dme2.internal.jettison.json.JSONException;
-import org.powermock.api.mockito.PowerMockito;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ PropertiesMapBean.class })
-public class TransactionRestServiceTest {
-
- @InjectMocks
- TransactionRestService transactionRestService;
-
- @Mock
- private TransactionService transactionService;
-
- @Mock
- DMaaPContext dmaapContext;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void testGetAllTransactionObjs() throws CambriaApiException {
-
- transactionRestService.getAllTransactionObjs();
- assertTrue(true);
-
- }
-
- @Test
- public void testGetTransactionObj() throws CambriaApiException {
-
- transactionRestService.getTransactionObj("transactionId");
- assertTrue(true);
-
- }
-
- @Test
- public void testGetAllTransactionObjsError() throws CambriaApiException {
-
- try {
- PowerMockito.doThrow(new IOException()).when(transactionService).getAllTransactionObjs(dmaapContext);
- } catch (ConfigDbException | IOException e) {
- assertTrue(false);
- }
-
- try {
- transactionRestService.getAllTransactionObjs();
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testGetTransactionObjError() {
-
- try {
- PowerMockito.doThrow(new IOException()).when(transactionService).getTransactionObj(dmaapContext,
- "transactionId");
- } catch (ConfigDbException | JSONException | IOException e) {
- assertTrue(false);
- }
-
- try {
- transactionRestService.getTransactionObj("transactionId");
- } catch (CambriaApiException e) {
- assertTrue(true);
- }
-
- }
-
+/*- + * ============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.service; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +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.service.EventsService; +import org.onap.dmaap.dmf.mr.service.TransactionService; +import com.att.nsa.configs.ConfigDbException; +import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException; +import com.att.aft.dme2.internal.jettison.json.JSONException; +import org.powermock.api.mockito.PowerMockito; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ PropertiesMapBean.class }) +public class TransactionRestServiceTest { + + @InjectMocks + TransactionRestService transactionRestService; + + @Mock + private TransactionService transactionService; + + @Mock + DMaaPContext dmaapContext; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testGetAllTransactionObjs() throws CambriaApiException { + + transactionRestService.getAllTransactionObjs(); + assertTrue(true); + + } + + @Test + public void testGetTransactionObj() throws CambriaApiException { + + transactionRestService.getTransactionObj("transactionId"); + assertTrue(true); + + } + + @Test + public void testGetAllTransactionObjsError() throws CambriaApiException { + + try { + PowerMockito.doThrow(new IOException()).when(transactionService).getAllTransactionObjs(dmaapContext); + } catch (ConfigDbException | IOException e) { + assertTrue(false); + } + + try { + transactionRestService.getAllTransactionObjs(); + } catch (CambriaApiException e) { + assertTrue(true); + } + + } + + @Test + public void testGetTransactionObjError() { + + try { + PowerMockito.doThrow(new IOException()).when(transactionService).getTransactionObj(dmaapContext, + "transactionId"); + } catch (ConfigDbException | JSONException | IOException e) { + assertTrue(false); + } + + try { + transactionRestService.getTransactionObj("transactionId"); + } catch (CambriaApiException e) { + assertTrue(true); + } + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/service/UIRestServicesTest.java b/src/test/java/org/onap/dmaap/service/UIRestServicesTest.java index ea6535a..3024484 100644 --- a/src/test/java/com/att/nsa/dmaap/service/UIRestServicesTest.java +++ b/src/test/java/org/onap/dmaap/service/UIRestServicesTest.java @@ -1,142 +1,142 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.service;
-
-import static org.junit.Assert.*;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.onap.dmaap.dmf.mr.CambriaApiException;
-import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-
-public class UIRestServicesTest {
-
- private UIRestServices service = null;
-
- @Before
- public void setUp() throws Exception {
- service = new UIRestServices();
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testHello() {
-
- try {
- service.hello();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
- assertTrue(true);
- }
-
- @Test
- public void testGetApiKeysTable() {
-
- try {
- service.getApiKeysTable();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
- assertTrue(true);
- }
-
-
- @Test
- public void testGetApiKey() {
-
- try {
- service.getApiKey("apikey");
- } catch (NullPointerException e) {
- assertTrue(true);
- }
- assertTrue(true);
- }
-
- @Test
- public void testGetTopicsTable() {
-
- try {
- service.getTopicsTable();
- } catch (NullPointerException e) {
- assertTrue(true);
- }
- assertTrue(true);
- }
-
- @Test
- public void testGetTopic() {
-
- try {
- service.getTopic("topicName");
- } catch (NullPointerException e) {
- assertTrue(true);
- }
- assertTrue(true);
- }
-
- @Test
- public void testGetDmaapContext() {
- Class clazz = null;
- Method method = null;
- try {
- clazz = Class.forName("UIRestServices");
- Object obj = clazz.newInstance();
- method = clazz.getDeclaredMethod("getDmaapContext", null);
- method.setAccessible(true);
- method.invoke(obj, null);
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- assertTrue(true);
- }
-
-
+/*- + * ============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.service; + +import static org.junit.Assert.*; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.onap.dmaap.dmf.mr.CambriaApiException; +import com.att.nsa.configs.ConfigDbException; +import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException; + +public class UIRestServicesTest { + + private UIRestServices service = null; + + @Before + public void setUp() throws Exception { + service = new UIRestServices(); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testHello() { + + try { + service.hello(); + } catch (NullPointerException e) { + assertTrue(true); + } + assertTrue(true); + } + + @Test + public void testGetApiKeysTable() { + + try { + service.getApiKeysTable(); + } catch (NullPointerException e) { + assertTrue(true); + } + assertTrue(true); + } + + + @Test + public void testGetApiKey() { + + try { + service.getApiKey("apikey"); + } catch (NullPointerException e) { + assertTrue(true); + } + assertTrue(true); + } + + @Test + public void testGetTopicsTable() { + + try { + service.getTopicsTable(); + } catch (NullPointerException e) { + assertTrue(true); + } + assertTrue(true); + } + + @Test + public void testGetTopic() { + + try { + service.getTopic("topicName"); + } catch (NullPointerException e) { + assertTrue(true); + } + assertTrue(true); + } + + @Test + public void testGetDmaapContext() { + Class clazz = null; + Method method = null; + try { + clazz = Class.forName("UIRestServices"); + Object obj = clazz.newInstance(); + method = clazz.getDeclaredMethod("getDmaapContext", null); + method.setAccessible(true); + method.invoke(obj, null); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + assertTrue(true); + } + + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/tools/ConfigToolContextTest.java b/src/test/java/org/onap/dmaap/tools/ConfigToolContextTest.java index 87da0d2..0dad4af 100644 --- a/src/test/java/com/att/nsa/dmaap/tools/ConfigToolContextTest.java +++ b/src/test/java/org/onap/dmaap/tools/ConfigToolContextTest.java @@ -1,86 +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 com.att.nsa.dmaap.tools;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ConfigToolContextTest {
-
- private ConfigToolContext context;
- @Before
- public void setUp() throws Exception {
- context = new ConfigToolContext(null, "connStr", null);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testRequestShutdown() {
-
- context.requestShutdown();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testShouldContinue() {
-
- context.shouldContinue();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetDb() {
-
- context.getDb();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMetrics() {
-
- context.getMetrics();
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetConnectionString() {
-
- context.getConnectionString();
-
- assertTrue(true);
-
- }
-
+/*- + * ============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.tools; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ConfigToolContextTest { + + private ConfigToolContext context; + @Before + public void setUp() throws Exception { + context = new ConfigToolContext(null, "connStr", null); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testRequestShutdown() { + + context.requestShutdown(); + + assertTrue(true); + + } + + @Test + public void testShouldContinue() { + + context.shouldContinue(); + + assertTrue(true); + + } + + @Test + public void testGetDb() { + + context.getDb(); + + assertTrue(true); + + } + + @Test + public void testGetMetrics() { + + context.getMetrics(); + + assertTrue(true); + + } + + @Test + public void testGetConnectionString() { + + context.getConnectionString(); + + assertTrue(true); + + } + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/tools/ConfigToolTest.java b/src/test/java/org/onap/dmaap/tools/ConfigToolTest.java index 39a312d..85b41dc 100644 --- a/src/test/java/com/att/nsa/dmaap/tools/ConfigToolTest.java +++ b/src/test/java/org/onap/dmaap/tools/ConfigToolTest.java @@ -1,523 +1,523 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.att.nsa.dmaap.tools;
-
-import static org.junit.Assert.*;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ConfigToolTest {
-
- private String[] parts = new String[5];
-
- @Before
- public void setUp() throws Exception {
-
- for (int i = 0; i < parts.length; i++) {
- parts[i] = "string" + (i + 1);
- }
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- public void callMethodViaReflection(String outer, String inner, String methodName, Object... args) {
-
- String foreNameString = outer + "$" + inner;
- Object parent = new ConfigTool();
-
- Class<?> innerClass;
- try {
- innerClass = Class.forName(foreNameString);
- Constructor<?> constructor = innerClass.getDeclaredConstructor(ConfigTool.class);
- constructor.setAccessible(true);
- Object child = constructor.newInstance(parent);
-
- // invoking method on inner class object
- Method method = innerClass.getDeclaredMethod(methodName, null);
- method.setAccessible(true);// in case of unaccessible method
- method.invoke(child, args);
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches() {
-
- callMethodViaReflection("ConfigTool", "ListTopicCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady() {
-
- callMethodViaReflection("ConfigTool", "ListTopicCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute() {
-
- callMethodViaReflection("ConfigTool", "ListTopicCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp() {
-
- callMethodViaReflection("ConfigTool", "ListTopicCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches2() {
-
- callMethodViaReflection("ConfigTool", "WriteTopicCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady2() {
-
- callMethodViaReflection("ConfigTool", "WriteTopicCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute2() {
-
- callMethodViaReflection("ConfigTool", "WriteTopicCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp2() {
-
- callMethodViaReflection("ConfigTool", "WriteTopicCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches3() {
-
- callMethodViaReflection("ConfigTool", "ReadTopicCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady3() {
-
- callMethodViaReflection("ConfigTool", "ReadTopicCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute3() {
-
- callMethodViaReflection("ConfigTool", "ReadTopicCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp3() {
-
- callMethodViaReflection("ConfigTool", "ReadTopicCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches4() {
-
- callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady4() {
-
- callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute4() {
-
- callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp4() {
-
- callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches5() {
-
- callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady5() {
-
- callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute5() {
-
- callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp5() {
-
- callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches6() {
-
- callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady6() {
-
- callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute6() {
-
- callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp6() {
-
- callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches7() {
-
- callMethodViaReflection("ConfigTool", "PutApiCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady7() {
-
- callMethodViaReflection("ConfigTool", "PutApiCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute7() {
-
- callMethodViaReflection("ConfigTool", "PutApiCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp7() {
-
- callMethodViaReflection("ConfigTool", "PutApiCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches8() {
-
- callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady8() {
-
- callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute8() {
-
- callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp8() {
-
- callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches9() {
-
- callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady9() {
-
- callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute9() {
-
- callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp9() {
-
- callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches10() {
-
- callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady10() {
-
- callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute10() {
-
- callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp10() {
-
- callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches11() {
-
- callMethodViaReflection("ConfigTool", "NodeFetchCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady11() {
-
- callMethodViaReflection("ConfigTool", "NodeFetchCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute11() {
-
- callMethodViaReflection("ConfigTool", "NodeFetchCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp11() {
-
- callMethodViaReflection("ConfigTool", "NodeFetchCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testGetMatches12() {
-
- callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "getMatches");
-
- assertTrue(true);
-
- }
-
- @Test
- public void testCheckReady12() {
-
- callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "checkReady", null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testExecute12() {
-
- callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "execute", parts, null, null);
-
- assertTrue(true);
-
- }
-
- @Test
- public void testDisplayHelp12() {
-
- callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "displayHelp", null);
-
- assertTrue(true);
-
- }
+/*- + * ============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.tools; + +import static org.junit.Assert.*; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ConfigToolTest { + + private String[] parts = new String[5]; + + @Before + public void setUp() throws Exception { + + for (int i = 0; i < parts.length; i++) { + parts[i] = "string" + (i + 1); + } + } + + @After + public void tearDown() throws Exception { + } + + public void callMethodViaReflection(String outer, String inner, String methodName, Object... args) { + + String foreNameString = outer + "$" + inner; + Object parent = new ConfigTool(); + + Class<?> innerClass; + try { + innerClass = Class.forName(foreNameString); + Constructor<?> constructor = innerClass.getDeclaredConstructor(ConfigTool.class); + constructor.setAccessible(true); + Object child = constructor.newInstance(parent); + + // invoking method on inner class object + Method method = innerClass.getDeclaredMethod(methodName, null); + method.setAccessible(true);// in case of unaccessible method + method.invoke(child, args); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + assertTrue(true); + + } + + @Test + public void testGetMatches() { + + callMethodViaReflection("ConfigTool", "ListTopicCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady() { + + callMethodViaReflection("ConfigTool", "ListTopicCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute() { + + callMethodViaReflection("ConfigTool", "ListTopicCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp() { + + callMethodViaReflection("ConfigTool", "ListTopicCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches2() { + + callMethodViaReflection("ConfigTool", "WriteTopicCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady2() { + + callMethodViaReflection("ConfigTool", "WriteTopicCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute2() { + + callMethodViaReflection("ConfigTool", "WriteTopicCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp2() { + + callMethodViaReflection("ConfigTool", "WriteTopicCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches3() { + + callMethodViaReflection("ConfigTool", "ReadTopicCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady3() { + + callMethodViaReflection("ConfigTool", "ReadTopicCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute3() { + + callMethodViaReflection("ConfigTool", "ReadTopicCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp3() { + + callMethodViaReflection("ConfigTool", "ReadTopicCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches4() { + + callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady4() { + + callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute4() { + + callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp4() { + + callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches5() { + + callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady5() { + + callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute5() { + + callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp5() { + + callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches6() { + + callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady6() { + + callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute6() { + + callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp6() { + + callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches7() { + + callMethodViaReflection("ConfigTool", "PutApiCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady7() { + + callMethodViaReflection("ConfigTool", "PutApiCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute7() { + + callMethodViaReflection("ConfigTool", "PutApiCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp7() { + + callMethodViaReflection("ConfigTool", "PutApiCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches8() { + + callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady8() { + + callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute8() { + + callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp8() { + + callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches9() { + + callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady9() { + + callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute9() { + + callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp9() { + + callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches10() { + + callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady10() { + + callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute10() { + + callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp10() { + + callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches11() { + + callMethodViaReflection("ConfigTool", "NodeFetchCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady11() { + + callMethodViaReflection("ConfigTool", "NodeFetchCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute11() { + + callMethodViaReflection("ConfigTool", "NodeFetchCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp11() { + + callMethodViaReflection("ConfigTool", "NodeFetchCommand", "displayHelp", null); + + assertTrue(true); + + } + + @Test + public void testGetMatches12() { + + callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "getMatches"); + + assertTrue(true); + + } + + @Test + public void testCheckReady12() { + + callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "checkReady", null); + + assertTrue(true); + + } + + @Test + public void testExecute12() { + + callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "execute", parts, null, null); + + assertTrue(true); + + } + + @Test + public void testDisplayHelp12() { + + callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "displayHelp", null); + + assertTrue(true); + + } }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/tools/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/tools/JUnitTestSuite.java index c9b4427..b50c950 100644 --- a/src/test/java/com/att/nsa/dmaap/tools/JUnitTestSuite.java +++ b/src/test/java/org/onap/dmaap/tools/JUnitTestSuite.java @@ -1,42 +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 com.att.nsa.dmaap.tools;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ ConfigToolTest.class, ConfigToolContextTest.class,})
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
+/*- + * ============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.tools; + +import junit.framework.TestSuite; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.apache.log4j.Logger; + +@RunWith(Suite.class) +@SuiteClasses({ ConfigToolTest.class, ConfigToolContextTest.class,}) +public class JUnitTestSuite { + private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class); + + public static void main(String[] args) { + LOGGER.info("Running the test suite"); + + TestSuite tstSuite = new TestSuite(); + LOGGER.info("Total Test Counts " + tstSuite.countTestCases()); + } + +} diff --git a/src/test/java/org/onap/dmaap/tools/TestRunner.java b/src/test/java/org/onap/dmaap/tools/TestRunner.java new file mode 100644 index 0000000..2266be0 --- /dev/null +++ b/src/test/java/org/onap/dmaap/tools/TestRunner.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + package org.onap.dmaap.tools; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.apache.log4j.Logger; + +public class TestRunner { + private static final Logger LOGGER = Logger.getLogger(TestRunner.class); + + public static void main(String[] args) { + // TODO Auto-generated method stub + Result result = JUnitCore.runClasses(JUnitTestSuite.class); + for (Failure failure : result.getFailures()) { + LOGGER.info(failure.toString()); + + } + LOGGER.info(result.wasSuccessful()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/util/ContentLengthInterceptorTest.java b/src/test/java/org/onap/dmaap/util/ContentLengthInterceptorTest.java index 2fe06a8..0608d2e 100644 --- a/src/test/java/com/att/nsa/dmaap/util/ContentLengthInterceptorTest.java +++ b/src/test/java/org/onap/dmaap/util/ContentLengthInterceptorTest.java @@ -1,93 +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 com.att.nsa.dmaap.util;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-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.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ System.class })
-public class ContentLengthInterceptorTest {
- @InjectMocks
- ContentLengthInterceptor interceptor = null;
-
- @Mock
- Map map;
-
- @Mock
- HttpServletRequest req;
-
- @Mock
- HttpServletResponse res;
-
- @Before
- public void setUp() throws Exception {
- // interceptor = new ContentLengthInterceptor();
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testAllowOrReject() throws Exception {
- PowerMockito.when(req.getHeader("Transfer-Encoding")).thenReturn("UTF-8");
- PowerMockito.when(req.getHeader("Content-Length")).thenReturn("1027");
-
- interceptor.allowOrReject(req, res, map);
- assertTrue(true);
- }
-
- //@Test(expected = NullPointerException.class)
- public void testAllowOrRejectWithException() throws Exception {
- PowerMockito.when(req.getHeader("Transfer-Encoding")).thenThrow(new NumberFormatException());
- interceptor.allowOrReject(req, res, map);
- assertTrue(true);
- }
-
-
- @Test
- public void testGetDefLength() {
- interceptor.getDefLength();
- assertTrue(true);
- }
-
- @Test
- public void testSetDefLength() {
- interceptor.setDefLength("defLength");
- assertTrue(true);
-
- }
+/*- + * ============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.util; + +import static org.junit.Assert.assertTrue; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +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.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ System.class }) +public class ContentLengthInterceptorTest { + @InjectMocks + ContentLengthInterceptor interceptor = null; + + @Mock + Map map; + + @Mock + HttpServletRequest req; + + @Mock + HttpServletResponse res; + + @Before + public void setUp() throws Exception { + // interceptor = new ContentLengthInterceptor(); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testAllowOrReject() throws Exception { + PowerMockito.when(req.getHeader("Transfer-Encoding")).thenReturn("UTF-8"); + PowerMockito.when(req.getHeader("Content-Length")).thenReturn("1027"); + + interceptor.allowOrReject(req, res, map); + assertTrue(true); + } + + //@Test(expected = NullPointerException.class) + public void testAllowOrRejectWithException() throws Exception { + PowerMockito.when(req.getHeader("Transfer-Encoding")).thenThrow(new NumberFormatException()); + interceptor.allowOrReject(req, res, map); + assertTrue(true); + } + + + @Test + public void testGetDefLength() { + interceptor.getDefLength(); + assertTrue(true); + } + + @Test + public void testSetDefLength() { + interceptor.setDefLength("defLength"); + assertTrue(true); + + } }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/util/DMaaPAuthFilterTest.java b/src/test/java/org/onap/dmaap/util/DMaaPAuthFilterTest.java index dc59f9c..ad94441 100644 --- a/src/test/java/com/att/nsa/dmaap/util/DMaaPAuthFilterTest.java +++ b/src/test/java/org/onap/dmaap/util/DMaaPAuthFilterTest.java @@ -1,100 +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 com.att.nsa.dmaap.util;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.att.ajsc.beans.PropertiesMapBean;
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-import org.onap.dmaap.dmf.mr.exception.DMaaPResponseCode;
-
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ PropertiesMapBean.class, DMaaPResponseCode.class })
-public class DMaaPAuthFilterTest {
-
- @InjectMocks
- DMaaPAuthFilter filter;
-
- @Mock
- HttpServletRequest req;
-
- @Mock
- ServletResponse res;
-
- @Mock
- FilterChain chain;
-
- @Mock
- DMaaPContext dmaapContext;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- //@Test
- public void testDoFilter() throws IOException, ServletException {
-
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(req);
- PowerMockito.when(req.getHeader("Authorization")).thenReturn("Authorization");
- // when(dmaapContext.getResponse()).thenReturn(res);
- filter.doFilter(req, res, chain);
- assertTrue(true);
-
- }
-
- //@Test
- public void testDoFilter_nullAuth() throws IOException, ServletException {
-
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(req);
- PowerMockito.when(req.getHeader("Authorization")).thenReturn("Authorization");
-
- // when(dmaapContext.getResponse()).thenReturn(res);
- filter.doFilter(req, res, chain);
- assertTrue(true);
-
- }
-
-
+/*- + * ============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.util; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.att.ajsc.beans.PropertiesMapBean; +import org.onap.dmaap.dmf.mr.beans.DMaaPContext; +import org.onap.dmaap.dmf.mr.exception.DMaaPResponseCode; + + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ PropertiesMapBean.class, DMaaPResponseCode.class }) +public class DMaaPAuthFilterTest { + + @InjectMocks + DMaaPAuthFilter filter; + + @Mock + HttpServletRequest req; + + @Mock + ServletResponse res; + + @Mock + FilterChain chain; + + @Mock + DMaaPContext dmaapContext; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @After + public void tearDown() throws Exception { + } + + //@Test + public void testDoFilter() throws IOException, ServletException { + + PowerMockito.when(dmaapContext.getRequest()).thenReturn(req); + PowerMockito.when(req.getHeader("Authorization")).thenReturn("Authorization"); + // when(dmaapContext.getResponse()).thenReturn(res); + filter.doFilter(req, res, chain); + assertTrue(true); + + } + + //@Test + public void testDoFilter_nullAuth() throws IOException, ServletException { + + PowerMockito.when(dmaapContext.getRequest()).thenReturn(req); + PowerMockito.when(req.getHeader("Authorization")).thenReturn("Authorization"); + + // when(dmaapContext.getResponse()).thenReturn(res); + filter.doFilter(req, res, chain); + assertTrue(true); + + } + + }
\ No newline at end of file diff --git a/src/test/java/com/att/nsa/dmaap/util/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/util/JUnitTestSuite.java index 17a6bad..9de79ab 100644 --- a/src/test/java/com/att/nsa/dmaap/util/JUnitTestSuite.java +++ b/src/test/java/org/onap/dmaap/util/JUnitTestSuite.java @@ -1,42 +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 com.att.nsa.dmaap.util;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.apache.log4j.Logger;
-
-@RunWith(Suite.class)
-@SuiteClasses({ ContentLengthInterceptorTest.class, DMaaPAuthFilterTest.class, ServicePropertiesMapBeanTest.class})
-public class JUnitTestSuite {
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
-
- public static void main(String[] args) {
- LOGGER.info("Running the test suite");
-
- TestSuite tstSuite = new TestSuite();
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
- }
-
-}
+/*- + * ============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.util; + +import junit.framework.TestSuite; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.apache.log4j.Logger; + +@RunWith(Suite.class) +@SuiteClasses({ ContentLengthInterceptorTest.class, DMaaPAuthFilterTest.class, ServicePropertiesMapBeanTest.class}) +public class JUnitTestSuite { + private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class); + + public static void main(String[] args) { + LOGGER.info("Running the test suite"); + + TestSuite tstSuite = new TestSuite(); + LOGGER.info("Total Test Counts " + tstSuite.countTestCases()); + } + +} diff --git a/src/test/java/com/att/nsa/dmaap/util/ServicePropertiesMapBeanTest.java b/src/test/java/org/onap/dmaap/util/ServicePropertiesMapBeanTest.java index da3eaf0..036bd13 100644 --- a/src/test/java/com/att/nsa/dmaap/util/ServicePropertiesMapBeanTest.java +++ b/src/test/java/org/onap/dmaap/util/ServicePropertiesMapBeanTest.java @@ -1,53 +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 com.att.nsa.dmaap.util;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ServicePropertiesMapBeanTest {
-
- @Before
- public void setUp() throws Exception {
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetProperty() {
-
- try {
- ServicePropertiesMapBean.getProperty(null, null);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- assertTrue(true);
-
- }
-
+/*- + * ============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.util; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ServicePropertiesMapBeanTest { + + @Before + public void setUp() throws Exception { + + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetProperty() { + + try { + ServicePropertiesMapBean.getProperty(null, null); + } catch (Exception e) { + e.printStackTrace(); + } + + assertTrue(true); + + } + }
\ No newline at end of file diff --git a/src/test/java/org/onap/dmaap/util/TestRunner.java b/src/test/java/org/onap/dmaap/util/TestRunner.java new file mode 100644 index 0000000..72a77a1 --- /dev/null +++ b/src/test/java/org/onap/dmaap/util/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.util; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.apache.log4j.Logger; + +public class TestRunner { + private static final Logger LOGGER = Logger.getLogger(TestRunner.class); + + public static void main(String[] args) { + // TODO Auto-generated method stub + Result result = JUnitCore.runClasses(JUnitTestSuite.class); + for (Failure failure : result.getFailures()) { + LOGGER.info(failure.toString()); + + } + LOGGER.info(result.wasSuccessful()); + } + +} |