<!-- 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 -->
<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" />
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>
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')
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
<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" />
<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>
<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" />
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"/>
<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>
<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>
* 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;
* 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;
* 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;
* 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;
import com.att.ajsc.beans.PropertiesMapBean;
-import com.att.nsa.dmaap.filemonitor.ServicePropertiesMap;
+import org.onap.dmaap.filemonitor.ServicePropertiesMap;
/**
* Example JAX-RS Service
* 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;
* 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;
* 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;
* 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;
* 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;
* 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;
* 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;
* 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;
* 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 {
* 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;
* 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;
* 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;
* 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;
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;
* 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;
* 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;
* 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;
* 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;
* 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;
* 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;
* 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;
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*
*******************************************************************************/
-package com.att.nsa.dmaap.util;\r
-\r
-import java.util.Map;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-import org.apache.http.HttpStatus;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.json.JSONException;\r
-import org.json.JSONObject;\r
-import org.springframework.stereotype.Component;\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPResponseCode;\r
-import org.onap.dmaap.dmf.mr.exception.ErrorResponse;\r
-import ajsc.beans.interceptors.AjscInterceptor;\r
-\r
-/**\r
- * AJSC Intercepter implementation of ContentLengthFilter\r
- */\r
-@Component\r
-public class ContentLengthInterceptor implements AjscInterceptor{\r
-\r
- \r
- private String defLength;\r
- //private Logger log = Logger.getLogger(ContentLengthInterceptor.class.toString());\r
- private static final EELFLogger log = EELFManager.getInstance().getLogger(ContentLengthInterceptor.class);\r
-\r
-\r
- /**\r
- * Intercepter method to intercept requests before processing\r
- */\r
- @Override\r
- public boolean allowOrReject(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse,\r
- Map map) throws Exception {\r
- \r
- log.info("inside Interceptor allowOrReject content length checking before pub/sub");\r
- \r
- JSONObject jsonObj = null;\r
- int requestLength = 0;\r
- setDefLength(System.getProperty("maxcontentlength"));\r
- try {\r
- // retrieving content length from message header\r
-\r
- if (null != httpservletrequest.getHeader("Content-Length")) {\r
- requestLength = Integer.parseInt(httpservletrequest.getHeader("Content-Length"));\r
- }\r
- // retrieving encoding from message header\r
- String transferEncoding = httpservletrequest.getHeader("Transfer-Encoding");\r
- // checking for no encoding, chunked and requestLength greater then\r
- // default length\r
- if (null != transferEncoding && !(transferEncoding.contains("chunked"))\r
- && (requestLength > Integer.parseInt(getDefLength()))) {\r
- jsonObj = new JSONObject().append("defaultlength", getDefLength())\r
- .append("requestlength", requestLength);\r
- log.error("message length is greater than default");\r
- throw new CambriaApiException(jsonObj);\r
- } \r
- else if (null == transferEncoding && (requestLength > Integer.parseInt(getDefLength()))) \r
- {\r
- jsonObj = new JSONObject().append("defaultlength", getDefLength()).append(\r
- "requestlength", requestLength);\r
- log.error("Request message is not chunked or request length is greater than default length");\r
- throw new CambriaApiException(jsonObj);\r
- \r
- \r
- } \r
- else \r
- {\r
- //chain.doFilter(req, res);\r
- return true;\r
- }\r
- \r
- } catch (CambriaApiException | NumberFormatException | JSONException e) {\r
- \r
- log.info("Exception obj--"+e);\r
+ 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();
- }\r
- ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_REQUEST_TOO_LONG,\r
- DMaaPResponseCode.MSG_SIZE_EXCEEDS_MSG_LIMIT.getResponseCode(), System.getProperty("msg_size_exceeds")\r
- + messg);\r
- log.info(errRes.toString());\r
- \r
- \r
- map.put(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"test");\r
+ }
+ 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){\r
+ if(httpservletresponse.getOutputStream()!=null){
httpservletresponse.getOutputStream().write(errRes.toString().getBytes());
- }\r
- return false;\r
- }\r
-\r
- \r
- \r
- }\r
-\r
- \r
- /**\r
- * Get Default Content Length\r
- * @return defLength\r
- */\r
- public String getDefLength() {\r
- return defLength;\r
- }\r
- /**\r
- * Set Default Content Length\r
- * @param defLength\r
- */\r
- public void setDefLength(String defLength) {\r
- this.defLength = defLength;\r
- }\r
-\r
- \r
-\r
-}\r
+ }
+ 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;
+ }
+
+
+
+}
* 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;
* 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
* 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.*;
+++ /dev/null
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.filemonitor;\r
-\r
-import org.junit.runner.JUnitCore;\r
-import org.junit.runner.Result;\r
-import org.junit.runner.notification.Failure;\r
-import org.apache.log4j.Logger;\r
-\r
-public class TestRunner {\r
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
-\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
- for (Failure failure : result.getFailures()) {\r
- LOGGER.info(failure.toString());\r
- \r
- }\r
- LOGGER.info(result.wasSuccessful());\r
- }\r
-\r
-}\r
+++ /dev/null
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.mmagent;\r
-\r
-import org.junit.runner.JUnitCore;\r
-import org.junit.runner.Result;\r
-import org.junit.runner.notification.Failure;\r
-import org.apache.log4j.Logger;\r
-\r
-public class TestRunner {\r
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
-\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
- for (Failure failure : result.getFailures()) {\r
- LOGGER.info(failure.toString());\r
- \r
- }\r
- LOGGER.info(result.wasSuccessful());\r
- }\r
-\r
-}\r
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import org.json.JSONObject;\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;\r
-import org.onap.dmaap.dmf.mr.exception.ErrorResponse;\r
-@RunWith(PowerMockRunner.class)\r
-public class DMaaPCambriaExceptionMapperTest {\r
-\r
- @InjectMocks\r
- DMaaPCambriaExceptionMapper mapper;\r
-\r
- @Mock\r
- private ErrorResponse errRes;\r
- \r
- @Mock\r
- private DMaaPErrorMessages msgs;\r
- \r
- @Mock\r
- CambriaApiException exc;\r
- \r
- @Mock\r
- JSONObject json;\r
-\r
- \r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testToResponse() {\r
- try {\r
- mapper.toResponse(null);\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- \r
- @Test\r
- public void testToResponseCambriaApiException2() {\r
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");\r
- try {\r
- mapper.toResponse(new CambriaApiException(404,"Not found"));\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
- assertTrue(true);\r
- }\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import javax.ws.rs.BadRequestException;\r
-import javax.ws.rs.InternalServerErrorException;\r
-import javax.ws.rs.NotAllowedException;\r
-import javax.ws.rs.NotAuthorizedException;\r
-import javax.ws.rs.NotFoundException;\r
-import javax.ws.rs.ServiceUnavailableException;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class DMaaPWebExceptionMapperTest {\r
-\r
- @InjectMocks\r
- DMaaPWebExceptionMapper mapper;\r
-\r
- @Mock\r
- DMaaPErrorMessages msgs;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testToResponse() {\r
-\r
- try {\r
- mapper.toResponse(null);\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testToResponseNotFoundException() {\r
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");\r
- try {\r
- mapper.toResponse(new NotFoundException());\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testToResponseInternalServerErrorException() {\r
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");\r
- try {\r
- mapper.toResponse(new InternalServerErrorException());\r
-\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testToResponseNotAuthorizedException() {\r
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");\r
- try {\r
- mapper.toResponse(new NotAuthorizedException("Error", "Error"));\r
-\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testToResponseBadRequestException() {\r
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");\r
- try {\r
- mapper.toResponse(new BadRequestException());\r
-\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testToResponseNotAllowedException() {\r
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");\r
- try {\r
- mapper.toResponse(new NotAllowedException("Not Allowed"));\r
-\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testToResponseServiceUnavailableException() {\r
- PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");\r
- try {\r
- mapper.toResponse(new ServiceUnavailableException());\r
-\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*******************************************************************************\r
- * ============LICENSE_START=======================================================\r
- * org.onap.dmaap\r
- * ================================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * \r
- *******************************************************************************/\r
-package com.att.nsa.dmaap;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class DummyTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void test() {\r
- assertTrue("Dummy test case", true);\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * ============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);
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class HelloWorldTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testToResponse() {\r
-\r
- HelloWorld hello = new HelloWorld();\r
-\r
- try {\r
- hello.speak(null);\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap;\r
-\r
-import junit.framework.TestSuite;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.Suite;\r
-import org.junit.runners.Suite.SuiteClasses;\r
-import org.apache.log4j.Logger;\r
-\r
-@RunWith(Suite.class)\r
-@SuiteClasses({ DMaaPCambriaExceptionMapperTest.class, DMaaPWebExceptionMapper.class, \r
- JaxrsEchoServiceTest.class, HelloWorldTest.class, JaxrsUserServiceTest.class })\r
-public class JUnitTestSuite {\r
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
-\r
- public static void main(String[] args) {\r
- LOGGER.info("Running the test suite");\r
- \r
- TestSuite tstSuite = new TestSuite();\r
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class JaxrsEchoServiceTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testPing() {\r
-\r
- JaxrsEchoService service = new JaxrsEchoService();\r
-\r
- service.ping("hello");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetProperty() {\r
-\r
- JaxrsEchoService service = new JaxrsEchoService();\r
-\r
- service.getProperty("filename", "hello");\r
- assertTrue(true);\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class JaxrsUserServiceTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testLookupUser() {\r
-\r
- JaxrsUserService service = new JaxrsUserService();\r
-\r
- service.lookupUser("userid");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap;\r
-\r
-import org.junit.runner.JUnitCore;\r
-import org.junit.runner.Result;\r
-import org.junit.runner.notification.Failure;\r
-import org.apache.log4j.Logger;\r
-\r
-public class TestRunner {\r
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
-\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
- for (Failure failure : result.getFailures()) {\r
- LOGGER.info(failure.toString());\r
- \r
- }\r
- LOGGER.info(result.wasSuccessful());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.filemonitor;\r
-\r
-import junit.framework.TestSuite;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.Suite;\r
-import org.junit.runners.Suite.SuiteClasses;\r
-import org.apache.log4j.Logger;\r
-\r
-@RunWith(Suite.class)\r
-@SuiteClasses({ ServicePropertiesListenerTest.class, ServicePropertiesMapTest.class, \r
- ServicePropertyServiceTest.class, })\r
-public class JUnitTestSuite {\r
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
-\r
- public static void main(String[] args) {\r
- LOGGER.info("Running the test suite");\r
- \r
- TestSuite tstSuite = new TestSuite();\r
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.filemonitor;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.File;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class ServicePropertiesListenerTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- //@Test\r
- public void testUpdate() {/*\r
-\r
- ServicePropertiesListener listener = new ServicePropertiesListener();\r
-\r
- try {\r
- listener.update(new File(":/file"));\r
- } catch (Exception e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
-\r
- assertTrue(true);\r
-\r
- */}\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.filemonitor;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.nio.file.Path;\r
-import java.nio.file.Paths;\r
-import java.util.HashMap;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import com.fasterxml.jackson.core.type.TypeReference;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class ServicePropertiesMapTest {\r
-\r
- @InjectMocks\r
- ServicePropertiesMap map;\r
-\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- /*@Test\r
- public void testRefresh() {\r
-\r
- try {\r
- map.refresh(new File(":/file"));\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test()\r
- public void testRefreshJsonFile() throws Exception {\r
- //Path resourceDirectory = Paths.get("src/test/resources");\r
- // map.refresh(new File(resourceDirectory+"\\"+"test.json"));\r
- ClassLoader classLoader = getClass().getClassLoader();\r
- map.refresh(new File(classLoader.getResource("test.json").getFile()));\r
- \r
- assertTrue(true);\r
- }\r
- \r
- @Test\r
- public void testRefreshPropsFile() throws Exception {\r
- Path resourceDirectory = Paths.get("src/test/resources");\r
- map.refresh(new File(resourceDirectory+"\\"+"test.properties"));\r
- ClassLoader classLoader = getClass().getClassLoader();\r
- map.refresh(new File(classLoader.getResource("test.json").getFile()));\r
- assertTrue(true);\r
- }*/\r
-\r
- @Test\r
- public void testGetProperty() {\r
-\r
- try {\r
- map.getProperty("filename", "propertykey");\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
-\r
- assertTrue(true);\r
- }\r
-\r
- @Test\r
- public void testGetProperties() {\r
-\r
- try {\r
- map.getProperties("filename");\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testIfNullThenEmpty() {\r
-\r
- try {\r
- map.getProperties("filename");\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.filemonitor;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.File;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class ServicePropertyServiceTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testInit() {\r
-\r
- ServicePropertyService service = new ServicePropertyService();\r
- try {\r
- service.init();\r
- } catch (Exception e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testsetLoadOnStartup() {\r
-\r
- ServicePropertyService service = new ServicePropertyService();\r
- try {\r
- service.setLoadOnStartup(true);\r
- } catch (Exception e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetSsfFileMonitorPollingInterval() {\r
-\r
- ServicePropertyService service = new ServicePropertyService();\r
- try {\r
- service.setSsfFileMonitorPollingInterval("interval");\r
- } catch (Exception e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetSsfFileMonitorThreadpoolSize() {\r
-\r
- ServicePropertyService service = new ServicePropertyService();\r
- try {\r
- service.setSsfFileMonitorThreadpoolSize("threadPoolSize");\r
- } catch (Exception e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testIsLoadOnStartup() {\r
- ServicePropertyService service = new ServicePropertyService();\r
- service.isLoadOnStartup();\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetSsfFileMonitorPollingInterval() {\r
- ServicePropertyService service = new ServicePropertyService();\r
- service.getSsfFileMonitorPollingInterval();\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetSsfFileMonitorThreadpoolSize() {\r
- ServicePropertyService service = new ServicePropertyService();\r
- service.getSsfFileMonitorThreadpoolSize();\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetFileChangedListener() {\r
- ServicePropertyService service = new ServicePropertyService();\r
- service.getFileChangedListener();\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetFileChangedListener() {\r
- ServicePropertyService service = new ServicePropertyService();\r
- service.setFileChangedListener(null);\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetFilePropertiesMap() {\r
- ServicePropertyService service = new ServicePropertyService();\r
- service.getFilePropertiesMap();\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetFilePropertiesMap() {\r
- ServicePropertyService service = new ServicePropertyService();\r
- service.setFilePropertiesMap(null);\r
- assertTrue(true);\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.util;\r
-\r
-import org.junit.runner.JUnitCore;\r
-import org.junit.runner.Result;\r
-import org.junit.runner.notification.Failure;\r
-import org.apache.log4j.Logger;\r
-\r
-public class TestRunner {\r
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
-\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
- for (Failure failure : result.getFailures()) {\r
- LOGGER.info(failure.toString());\r
- \r
- }\r
- LOGGER.info(result.wasSuccessful());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.mmagent;\r
-\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-\r
-public class CreateMirrorMakerTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetCreateMirrorMaker() {\r
-\r
- CreateMirrorMaker mMaker = new CreateMirrorMaker();\r
- mMaker.getCreateMirrorMaker();\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testSetCreateMirrorMaker() throws CambriaApiException {\r
-\r
- CreateMirrorMaker mMaker = new CreateMirrorMaker();\r
- mMaker.setCreateMirrorMaker(new MirrorMaker());\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetMessageID() {\r
-\r
- CreateMirrorMaker mMaker = new CreateMirrorMaker();\r
- mMaker.getMessageID();\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testSetMessageID() {\r
-\r
- CreateMirrorMaker mMaker = new CreateMirrorMaker();\r
- mMaker.setMessageID("messageID");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.mmagent;\r
-\r
-import junit.framework.TestSuite;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.Suite;\r
-import org.junit.runners.Suite.SuiteClasses;\r
-import org.apache.log4j.Logger;\r
-\r
-@RunWith(Suite.class)\r
-@SuiteClasses({ CreateMirrorMakerTest.class, MirrorMakerTest.class, \r
- UpdateMirrorMakerTest.class, UpdateWhiteListTest.class,})\r
-public class JUnitTestSuite {\r
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
-\r
- public static void main(String[] args) {\r
- LOGGER.info("Running the test suite");\r
- \r
- TestSuite tstSuite = new TestSuite();\r
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.mmagent;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class MirrorMakerTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetStatus() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.getStatus();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetStatus() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.setStatus("status");\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetName() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.getName();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetName() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.setName("name");\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- \r
- @Test\r
- public void testGetConsumer() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.getConsumer();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetConsumer() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.setConsumer("consumer");\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetProducer() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.getProducer();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetProducer() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.setProducer("producer");\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
-\r
- @Test\r
- public void testGetWhitelist() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.getWhitelist();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetWhitelist() {\r
-\r
- MirrorMaker mMaker = new MirrorMaker();\r
- mMaker.setWhitelist("whitelist");\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- \r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.tools;\r
-\r
-import org.junit.runner.JUnitCore;\r
-import org.junit.runner.Result;\r
-import org.junit.runner.notification.Failure;\r
-import org.apache.log4j.Logger;\r
-\r
-public class TestRunner {\r
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
-\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
- for (Failure failure : result.getFailures()) {\r
- LOGGER.info(failure.toString());\r
- \r
- }\r
- LOGGER.info(result.wasSuccessful());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.mmagent;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class UpdateMirrorMakerTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetUpdateMirrorMaker() {\r
-\r
- UpdateMirrorMaker mMaker = new UpdateMirrorMaker();\r
- mMaker.getUpdateMirrorMaker();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetUpdateMirrorMaker() {\r
-\r
- UpdateMirrorMaker mMaker = new UpdateMirrorMaker();\r
- mMaker.setUpdateMirrorMaker(new MirrorMaker());\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMessageID() {\r
-\r
- UpdateMirrorMaker mMaker = new UpdateMirrorMaker();\r
- mMaker.getMessageID();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetMessageID() {\r
-\r
- UpdateMirrorMaker mMaker = new UpdateMirrorMaker();\r
- mMaker.setMessageID("messageID");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
-\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.mmagent;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class UpdateWhiteListTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetUpdateWhiteList() {\r
-\r
- UpdateWhiteList wList = new UpdateWhiteList();\r
- wList.getUpdateWhiteList();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetUpdateWhiteList() {\r
-\r
- UpdateWhiteList wList = new UpdateWhiteList();\r
- wList.setUpdateWhiteList(new MirrorMaker());\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMessageID() {\r
-\r
- UpdateWhiteList wList = new UpdateWhiteList();\r
- wList.getMessageID();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testSetMessageID() {\r
-\r
- UpdateWhiteList wList = new UpdateWhiteList();\r
- wList.setMessageID("messageID");\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- \r
- \r
-\r
-\r
-\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-import static org.mockito.Mockito.when;\r
-\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;\r
-\r
-import java.io.IOException;\r
-import java.util.Enumeration;\r
-import org.onap.dmaap.dmf.mr.service.AdminService;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;\r
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ ServiceUtil.class })\r
-public class AdminRestServiceTest {\r
-\r
- @InjectMocks\r
- AdminRestService adminRestService;\r
-\r
- @Mock\r
- AdminService adminService;\r
-\r
- @Mock\r
- DMaaPContext dmaapContext;\r
-\r
- @Mock\r
- HttpServletRequest httpServReq;\r
- @Mock\r
- private HttpServletResponse response;\r
-\r
- @Mock\r
- Enumeration headerNames;\r
- @Mock\r
- private DMaaPContext dmaaPContext;\r
- @Mock\r
- private ConfigurationReader configReader;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- MockitoAnnotations.initMocks(this);\r
-\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetConsumerCache() throws CambriaApiException, AccessDeniedException {\r
- adminRestService.getConsumerCache();\r
-\r
- }\r
-\r
- @Test\r
- public void testGetConsumerCache_error() throws CambriaApiException, AccessDeniedException, IOException {\r
-\r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new IOException("error")).when(adminService).showConsumerCache(dmaaPContext);\r
- try {\r
- adminRestService.getConsumerCache();\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testDropConsumerCache() throws CambriaApiException, AccessDeniedException {\r
- adminRestService.dropConsumerCache();\r
-\r
- }\r
- \r
- @Test\r
- public void testDropConsumerCach_error() throws CambriaApiException, AccessDeniedException ,IOException{\r
- \r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new IOException("error")).when(adminService).dropConsumerCache(dmaaPContext);\r
- try {\r
- adminRestService.dropConsumerCache();\r
- }\r
- catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
- \r
-\r
- }\r
- @Test\r
- public void testDropConsumerCach_error1() throws CambriaApiException, AccessDeniedException,IOException {\r
- \r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).dropConsumerCache(dmaaPContext);\r
- try {\r
- adminRestService.dropConsumerCache();\r
- }\r
- catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
- \r
-\r
- }\r
-\r
- @Test\r
- public void testGetBlacklist() throws CambriaApiException, AccessDeniedException {\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeaderNames()).thenReturn(headerNames);\r
- when(headerNames.nextElement()).thenReturn("key");\r
- when(httpServReq.getHeader("key")).thenReturn("value");\r
-\r
- adminRestService.getBlacklist();\r
-\r
- }\r
- \r
- //@Test\r
- public void testGetBlacklist_error() throws CambriaApiException, AccessDeniedException,IOException {\r
- \r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new IOException("error")).when(adminService).getBlacklist(dmaaPContext);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeaderNames()).thenReturn(headerNames);\r
- when(headerNames.nextElement()).thenReturn("key");\r
- when(httpServReq.getHeader("key")).thenReturn("value");\r
- when(headerNames.hasMoreElements()).thenReturn(false);\r
- try {\r
- adminRestService.getBlacklist();\r
- }\r
- catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
- \r
- ////@Test\r
- public void testGetBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException {\r
- \r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).getBlacklist(dmaaPContext);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeaderNames()).thenReturn(headerNames);\r
- when(headerNames.nextElement()).thenReturn("key");\r
- when(httpServReq.getHeader("key")).thenReturn("value");\r
- when(headerNames.hasMoreElements()).thenReturn(false);\r
- try {\r
- adminRestService.getBlacklist();\r
- }\r
- catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testAddToBlacklist() throws CambriaApiException, AccessDeniedException {\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
- adminRestService.addToBlacklist("120.120.120.120");\r
-\r
- }\r
- \r
- @Test\r
- public void testAddToBlacklist_error() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {\r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).addToBlacklist(dmaaPContext,"120.120.120.120");\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- try {\r
- adminRestService.addToBlacklist("120.120.120.120");\r
- }catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
- \r
- @Test\r
- public void testAddToBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException, ConfigDbException {\r
- \r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new IOException("error")).when(adminService).addToBlacklist(dmaaPContext,"120.120.120.120");\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- try {\r
- adminRestService.addToBlacklist("120.120.120.120");\r
- }catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testRemoveFromBlacklist() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
- adminRestService.removeFromBlacklist("120.120.120.120");\r
-\r
- }\r
- \r
- @Test\r
- public void testRemoveFromBlacklist_error() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException{\r
- \r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new IOException("error")).when(adminService).removeFromBlacklist(dmaaPContext,"120.120.120.120");\r
-\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- try {\r
-\r
- adminRestService.removeFromBlacklist("120.120.120.120");\r
- }catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
- catch (AccessDeniedException e) {\r
- assertTrue(true);\r
- }\r
- catch (ConfigDbException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
- \r
- @Test\r
- public void testRemoveFromBlacklist_error1() throws CambriaApiException, AccessDeniedException, ConfigDbException,IOException {\r
- \r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);\r
- PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).removeFromBlacklist(dmaaPContext,"120.120.120.120");\r
-\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- try {\r
-\r
- adminRestService.removeFromBlacklist("120.120.120.120");\r
- }catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
- catch (AccessDeniedException e) {\r
- assertTrue(true);\r
- }\r
- catch (ConfigDbException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.IOException;\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.lang.reflect.Method;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import org.onap.dmaap.dmf.mr.beans.ApiKeyBean;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-import static org.mockito.Mockito.when;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.json.JSONException;\r
-\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;\r
-\r
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;\r
-import org.onap.dmaap.dmf.mr.service.ApiKeysService;\r
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.security.db.NsaApiDb.KeyExistsException;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ ServiceUtil.class })\r
-public class ApiKeysRestServiceTest {\r
-\r
- @InjectMocks\r
- private ApiKeysRestService service;\r
-\r
- @Mock\r
- ApiKeysService apiKeyService;\r
-\r
- @Mock\r
- DMaaPContext dmaapContext;\r
-\r
- @Mock\r
- HttpServletRequest httpServReq;\r
- @Mock\r
- private HttpServletResponse response;\r
- @Mock\r
- private ConfigurationReader configReader;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetAllApiKeys() {\r
-\r
- try {\r
- service.getAllApiKeys();\r
- } catch (CambriaApiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testGetAllApiKeys_error() throws ConfigDbException, IOException {\r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);\r
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).getAllApiKeys(dmaapContext);\r
- try {\r
- service.getAllApiKeys();\r
- } catch (CambriaApiException e) {\r
- // TODO Auto-generated catch block\r
- assertTrue(true);\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testGetApiKey() {\r
-\r
- try {\r
- service.getApiKey("apikeyName");\r
- } catch (CambriaApiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testGetApiKey_error() throws ConfigDbException, IOException {\r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);\r
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).getApiKey(dmaapContext, "apikeyName");\r
-\r
- try {\r
- service.getApiKey("apikeyName");\r
- } catch (CambriaApiException e) {\r
- // TODO Auto-generated catch block\r
- assertTrue(true);\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testCreateApiKey() {\r
-\r
- try {\r
- service.createApiKey(new ApiKeyBean("hs647a@att.com", "test apikey"));\r
- } catch (CambriaApiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testCreateApiKey_error()\r
- throws CambriaApiException, JSONException, KeyExistsException, ConfigDbException, IOException {\r
-\r
- ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");\r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);\r
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).createApiKey(dmaapContext, bean);\r
-\r
- try {\r
- service.createApiKey(bean);\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testUpdateApiKey() {\r
-\r
- try {\r
- service.updateApiKey("apikeyName", new ApiKeyBean("hs647a@att.com", "test apikey"));\r
- } catch (CambriaApiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testUpdateApiKey_error() throws CambriaApiException, JSONException, KeyExistsException,\r
- ConfigDbException, IOException, AccessDeniedException {\r
-\r
- ApiKeyBean bean = new ApiKeyBean("test@onap.com", "test apikey");\r
- PowerMockito.mockStatic(ServiceUtil.class);\r
- PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaapContext);\r
- PowerMockito.doThrow(new IOException("error")).when(apiKeyService).updateApiKey(dmaapContext, "apikeyName",\r
- bean);\r
- try {\r
- service.updateApiKey("apikeyName", bean);\r
- } catch (CambriaApiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testDeleteApiKey() {\r
-\r
- try {\r
- service.deleteApiKey("apikeyName");\r
- } catch (CambriaApiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package com.att.nsa.dmaap.service;\r
-\r
-import java.util.Date;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.MockitoAnnotations;\r
-import static org.mockito.Matchers.any;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import static org.mockito.Mockito.when;\r
-\r
-import com.att.ajsc.beans.PropertiesMapBean;\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import org.onap.dmaap.dmf.mr.backends.ConsumerFactory.UnavailableException;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;\r
-import org.onap.dmaap.dmf.mr.service.EventsService;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import org.onap.dmaap.dmf.mr.utils.Utils;\r
-import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;\r
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.util.Date;\r
-\r
-import javax.servlet.ServletInputStream;\r
-import javax.servlet.ServletOutputStream;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;\r
-import org.onap.dmaap.dmf.mr.exception.ErrorResponse;\r
-import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ PropertiesMapBean.class })\r
-public class EventsRestServiceTest {\r
-\r
- @InjectMocks\r
- EventsRestService eventsRestRestService;\r
-\r
- @Mock\r
- private EventsService eventsService;\r
-\r
- @Mock\r
- ErrorResponse errorResponse;\r
-\r
- @Mock\r
- DMaaPContext dmaapContext;\r
-\r
- @Mock\r
- InputStream iStream;\r
-\r
- @Mock\r
- ServletInputStream servletInputStream;\r
-\r
- @Mock\r
- HttpServletRequest request;\r
-\r
- @Mock\r
- private DMaaPErrorMessages errorMessages;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetEvents() throws CambriaApiException {\r
-\r
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");\r
-\r
- }\r
-\r
- @Test\r
- public void testGetEvents_error() {\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(eventsService).getEvents(any(), any(),\r
- any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | UnavailableException | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).getEvents(any(), any(),\r
- any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | UnavailableException | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).getEvents(any(),\r
- any(), any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | UnavailableException | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.getEvents("topicName", "consumergroup", "consumerid");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test(expected = TopicExistsException.class)\r
- public void testGetEvents_TopicExistException() throws CambriaApiException, ConfigDbException, TopicExistsException,\r
- UnavailableException, IOException, AccessDeniedException {\r
-\r
- Mockito.doThrow(new TopicExistsException("topic exists")).when(eventsService).getEvents(any(),\r
- any(), any(), any());\r
-\r
- eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");\r
-\r
- }\r
-\r
- @Test(expected = DMaaPAccessDeniedException.class)\r
- public void testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException, ConfigDbException,\r
- TopicExistsException, UnavailableException, IOException, AccessDeniedException {\r
-\r
- Mockito.doThrow(new DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(any(),\r
- any(), any(), any());\r
-\r
- eventsService.getEvents(dmaapContext, "topicName", "consumergroup", "consumerid");\r
-\r
- }\r
-\r
- /*\r
- * @Test(expected = DMaaPAccessDeniedException.class) public void\r
- * testGetEvents_DMaaPAccessDeniedException() throws CambriaApiException,\r
- * ConfigDbException, TopicExistsException, UnavailableException,\r
- * IOException, AccessDeniedException {\r
- * \r
- * Mockito.doThrow(new\r
- * DMaaPAccessDeniedException(errorResponse)).when(eventsService).getEvents(\r
- * dmaapContext, "topicName", "consumergroup", "consumerid");\r
- * \r
- * eventsService.getEvents(dmaapContext, "topicName", "consumergroup",\r
- * "consumerid");\r
- * \r
- * }\r
- */\r
-\r
- @Test\r
- public void testPushEvents() throws CambriaApiException {\r
-\r
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");\r
-\r
- }\r
-\r
- @Test\r
- public void testPushEvents_error() {\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(),\r
- any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | missingReqdSetting | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(), any(),\r
- any(), any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | missingReqdSetting | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(),\r
- any(), any(), any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | missingReqdSetting | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testPushEvents_TopicExistException() throws CambriaApiException {\r
-\r
- eventsRestRestService.pushEvents("topicName", iStream, "partitionKey");\r
-\r
- }\r
-\r
- @Test\r
- public void tesTPushEventsWithTransaction() throws CambriaApiException, IOException {\r
- when(request.getInputStream()).thenReturn(servletInputStream);\r
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");\r
-\r
- }\r
-\r
- @Test\r
- public void tesTPushEventsWithTransaction_error() throws IOException {\r
- when(request.getInputStream()).thenReturn(servletInputStream);\r
- ServletInputStream stream = request.getInputStream();\r
-\r
- try {\r
- PowerMockito.doThrow(new TopicExistsException("error")).when(eventsService).pushEvents(any(),\r
- any(), any(), any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | missingReqdSetting | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new AccessDeniedException()).when(eventsService).pushEvents(any(),any(),\r
- any(), any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | missingReqdSetting | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(eventsService).pushEvents(any(), any(), any(),\r
- any(), any());\r
- } catch (TopicExistsException | DMaaPAccessDeniedException | AccessDeniedException | ConfigDbException\r
- | missingReqdSetting | IOException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- eventsRestRestService.pushEventsWithTransaction("topicName", "partitionKey");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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);
+ }
+
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import junit.framework.TestSuite;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.Suite;\r
-import org.junit.runners.Suite.SuiteClasses;\r
-import org.apache.log4j.Logger;\r
-\r
-@RunWith(Suite.class)\r
-@SuiteClasses({ AdminRestServiceTest.class, ApiKeysRestServiceTest.class, \r
- EventsRestServiceTest.class, MetricsRestServiceTest.class, MMRestServiceTest.class, \r
- TopicRestServiceTest.class, TransactionRestServiceTest.class, UIRestServicesTest.class,})\r
-public class JUnitTestSuite {\r
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
-\r
- public static void main(String[] args) {\r
- LOGGER.info("Running the test suite");\r
- \r
- TestSuite tstSuite = new TestSuite();\r
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-import static org.junit.Assert.fail;\r
-import static org.mockito.Matchers.anyString;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.FileInputStream;\r
-\r
-//import static org.mockito.Matchers.anyString;\r
-//import static org.mockito.Mockito.when;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-\r
-import javax.servlet.ServletOutputStream;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.apache.commons.io.IOUtils;\r
-import org.json.JSONArray;\r
-import org.json.JSONException;\r
-import org.json.JSONObject;\r
-import org.junit.After;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import com.att.ajsc.beans.PropertiesMapBean;\r
-import com.att.ajsc.filemonitor.AJSCPropertiesMap;\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;\r
-import org.onap.dmaap.dmf.mr.constants.CambriaConstants;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;\r
-import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;\r
-import org.onap.dmaap.dmf.mr.metabroker.Topic;\r
-import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator;\r
-import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticatorImpl;\r
-import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;\r
-import org.onap.dmaap.dmf.mr.service.MMService;\r
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.dmaap.mmagent.CreateMirrorMaker;\r
-import com.att.nsa.dmaap.mmagent.MirrorMaker;\r
-import com.att.nsa.dmaap.mmagent.UpdateMirrorMaker;\r
-import com.att.nsa.security.NsaAcl;\r
-import com.att.nsa.security.NsaApiKey;\r
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;\r
-import com.google.gson.Gson;\r
-\r
-//@RunWith(MockitoJUnitRunner.class)\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ PropertiesMapBean.class, AJSCPropertiesMap.class })\r
-public class MMRestServiceTest {\r
-\r
- @InjectMocks\r
- MMRestService mmRestService;\r
-\r
- @Mock\r
- private MMService mmservice;\r
-\r
- @Mock\r
- CreateMirrorMaker cMirroMaker;\r
-\r
- @Mock\r
- UpdateMirrorMaker uMirroMaker;\r
-\r
- private TopicRestService service = new TopicRestService();\r
- @Mock\r
- private DMaaPErrorMessages errorMessages;\r
-\r
- @Mock\r
- DMaaPContext dmaapContext;\r
-\r
- @Mock\r
- ConfigurationReader configReader;\r
-\r
- @Mock\r
- ServletOutputStream oStream;\r
-\r
- @Mock\r
- DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;\r
-\r
- @Mock\r
- MirrorMaker mMaker;\r
-\r
- @Mock\r
- DMaaPAAFAuthenticator dmaapAAFauthenticator;\r
-\r
- @Mock\r
- DMaaPAAFAuthenticatorImpl impl;\r
-\r
- @Mock\r
- NsaApiKey user;\r
-\r
- @Mock\r
- NsaSimpleApiKey nsaSimpleApiKey;\r
-\r
- @Mock\r
- HttpServletRequest httpServReq;\r
-\r
- @Mock\r
- HttpServletResponse httpServRes;\r
-\r
- @Mock\r
- InputStream iStream;\r
-\r
- @Mock\r
- DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;\r
-\r
- @Mock\r
- Topic createdTopic;\r
-\r
- @Mock\r
- NsaAcl nsaAcl;\r
-\r
- @Mock\r
- JSONObject jsonObj;\r
-\r
- @Mock\r
- JSONArray jsonArray;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
-\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testCallCreateMirrorMaker() throws Exception {\r
- prepareForTestCommon();\r
-\r
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {\r
- // name:\"test\", consumer:\"test\", producer:\"test\",\r
- // whitelist:\"test\",status:\"test\" }}";\r
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callCreateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
-\r
- }\r
- @Test\r
- public void testCallCreateMirrorMaker_error4() throws Exception {\r
- prepareForTestCommon();\r
-\r
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {\r
- // name:\"test\", consumer:\"test\", producer:\"test\",\r
- // whitelist:\"test\",status:\"test\" }}";\r
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test@#\", consumer:\"test\", producer:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callCreateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
-\r
- }\r
- @Test\r
- public void testCallCreateMirrorMaker_3() throws Exception {\r
- prepareForTestCommon();\r
-\r
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {\r
- // name:\"test\", consumer:\"test\", producer:\"test\",\r
- // whitelist:\"test\",status:\"test\" }}";\r
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"\", consumer:\"test\", producer:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callCreateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
-\r
- }\r
- @Test\r
- public void testCallCreateMirrorMaker_error2() throws Exception {\r
- prepareForTestCommon();\r
-\r
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {\r
- // name:\"test\", consumer:\"test\", producer:\"test\",\r
- // whitelist:\"test\",status:\"test\" }}";\r
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\",whitelist:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callCreateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testCallCreateMirrorMaker_error1() throws Exception {\r
- prepareForTestCommon();\r
-\r
- // String sampleJson = ""{ messageID:\"test\", createMirrorMaker: {\r
- // name:\"test\", consumer:\"test\", producer:\"test\",\r
- // whitelist:\"test\",status:\"test\" }}";\r
- String sampleJson = "{ messageID:\"test\"}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callCreateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCallListAllMirrorMaker() throws Exception {\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ messageID:\"test\", createMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\" }}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callListAllMirrorMaker(inputSteam);\r
- assertTrue(true);\r
- }\r
-\r
- @Test\r
- public void testCallUpdateMirrorMaker() throws Exception {\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callUpdateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
- }\r
- \r
- @Test\r
- public void testCallUpdateMirrorMaker_error1() throws Exception {\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ messageID:\"test@1\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callUpdateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
- }\r
- @Test\r
- public void testCallUpdateMirrorMaker_error2() throws Exception {\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"\", consumer:\"test\", producer:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callUpdateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
- }\r
- @Test\r
- public void testCallUpdateMirrorMaker_error3() throws Exception{\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ messageID:\"test\", updateMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callUpdateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
- }\r
- @Test\r
- public void testCallUpdateMirrorMaker_error4() throws Exception {\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ messageID:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callUpdateMirrorMaker(inputSteam);\r
- assertTrue(true);\r
- }\r
-\r
- @Test\r
- public void testCallDeleteMirrorMaker() throws Exception {\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ messageID:\"test\", deleteMirrorMaker: { name:\"test\", consumer:\"test\", producer:\"test\", whitelist:\"test\",status:\"test\" }}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.callDeleteMirrorMaker(inputSteam);\r
- assertTrue(true);\r
- }\r
-\r
- @Test\r
- public void testListWhiteList() throws Exception {\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ name:\"test\", namespace:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.listWhiteList(inputSteam);\r
- assertTrue(true);\r
- }\r
-\r
- @Test\r
- public void testCreateWhiteList() throws Exception {\r
- prepareForTestCommon();\r
- String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
-\r
- mmRestService.createWhiteList(inputSteam);\r
- assertTrue(true);\r
- }\r
-\r
- @Test\r
- public void testDeleteWhiteList() throws Exception {\r
- prepareForTestCommon();\r
-\r
- String sampleJson = "{ name:\"test\", namespace:\"test\", whitelistTopicName:\"test\"}}";\r
- InputStream inputSteam = new ByteArrayInputStream(sampleJson.getBytes());\r
- mmRestService.deleteWhiteList(inputSteam);\r
- assertTrue(true);\r
- }\r
-\r
- private void prepareForTestCommon() throws Exception {\r
- Assert.assertNotNull(mmRestService);\r
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
- PowerMockito.when(httpServReq.isUserInRole("admin")).thenReturn(true);\r
-\r
- PowerMockito.mockStatic(AJSCPropertiesMap.class);\r
-\r
- assertTrue(true);\r
-\r
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeradmin.aaf"))\r
- .thenReturn("admin");\r
- PowerMockito\r
- .when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf.create"))\r
- .thenReturn("aafcreate");\r
-\r
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormakeruser.aaf"))\r
- .thenReturn("admin");\r
-\r
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.timeout"))\r
- .thenReturn("100");\r
-\r
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.topic"))\r
- .thenReturn("mirrormaker.topic");\r
-\r
- PowerMockito\r
- .when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumergroup"))\r
- .thenReturn("mirrormaker.consumergroup");\r
-\r
- PowerMockito.when(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.mirrormaker.consumerid"))\r
- .thenReturn("mirrormaker.consumerid");\r
-\r
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
-\r
- PowerMockito.when(httpServReq.isUserInRole("admin")).thenReturn(true);\r
-\r
- // PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin.aaf")).thenReturn(true);\r
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
- PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Admin");\r
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "admin")).thenReturn(true);\r
- PowerMockito.when(dmaapAAFauthenticator.aafAuthentication(httpServReq, "aafcreatetest|create"))\r
- .thenReturn(true);\r
-\r
- PowerMockito.when(cMirroMaker.getCreateMirrorMaker()).thenReturn(mMaker);\r
-\r
- PowerMockito.when(mMaker.getName()).thenReturn("mirroMakerName");\r
- PowerMockito.when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- PowerMockito.when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
-\r
- PowerMockito.when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
- PowerMockito.when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
- PowerMockito.when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
- PowerMockito.when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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);
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import com.att.ajsc.beans.PropertiesMapBean;\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import org.onap.dmaap.dmf.mr.service.MetricsService;\r
-\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ PropertiesMapBean.class })\r
-public class MetricsRestServiceTest {\r
-\r
- @InjectMocks\r
- MetricsRestService metricsRestService;\r
-\r
- @Mock\r
- private MetricsService metricsService;\r
- \r
- @Before\r
- public void setUp() throws Exception {\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetMetrics() throws CambriaApiException {\r
-\r
- metricsRestService.getMetrics();\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMetricsByName() throws CambriaApiException {\r
-\r
- metricsRestService.getMetricsByName("metricsName");\r
-\r
- }\r
-\r
-\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import org.junit.runner.JUnitCore;\r
-import org.junit.runner.Result;\r
-import org.junit.runner.notification.Failure;\r
-import org.apache.log4j.Logger;\r
-\r
-public class TestRunner {\r
- private static final Logger LOGGER = Logger.getLogger(TestRunner.class);\r
-\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
- Result result = JUnitCore.runClasses(JUnitTestSuite.class);\r
- for (Failure failure : result.getFailures()) {\r
- LOGGER.info(failure.toString());\r
- \r
- }\r
- LOGGER.info(result.wasSuccessful());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import static org.mockito.Matchers.anyString;\r
-import static org.mockito.Matchers.any;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.io.IOException;\r
-import java.util.ConcurrentModificationException;\r
-\r
-import javax.servlet.ServletOutputStream;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.junit.After;\r
-import org.json.JSONArray;\r
-import org.json.JSONException;\r
-import org.json.JSONObject;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import com.att.ajsc.beans.PropertiesMapBean;\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;\r
-import org.onap.dmaap.dmf.mr.beans.TopicBean;\r
-import org.onap.dmaap.dmf.mr.constants.CambriaConstants;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPAccessDeniedException;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPErrorMessages;\r
-import org.onap.dmaap.dmf.mr.metabroker.Broker.TopicExistsException;\r
-import org.onap.dmaap.dmf.mr.metabroker.Topic;\r
-import org.onap.dmaap.dmf.mr.security.DMaaPAAFAuthenticator;\r
-import org.onap.dmaap.dmf.mr.security.DMaaPAuthenticator;\r
-import org.onap.dmaap.dmf.mr.service.TopicService;\r
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;\r
-import org.onap.dmaap.dmf.mr.utils.DMaaPResponseBuilder;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.security.NsaAcl;\r
-import com.att.nsa.security.NsaApiKey;\r
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;\r
-\r
-//@RunWith(MockitoJUnitRunner.class)\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ PropertiesMapBean.class })\r
-public class TopicRestServiceTest {\r
-\r
- @InjectMocks\r
- TopicRestService topicRestService;\r
-\r
- @Mock\r
- private TopicService topicService;\r
-\r
- private TopicRestService service = new TopicRestService();\r
- @Mock\r
- private DMaaPErrorMessages errorMessages;\r
-\r
- @Mock\r
- DMaaPContext dmaapContext;\r
-\r
- @Mock\r
- ConfigurationReader configReader;\r
-\r
- @Mock\r
- ServletOutputStream oStream;\r
-\r
- @Mock\r
- DMaaPAuthenticator<NsaSimpleApiKey> dmaaPAuthenticator;\r
-\r
- @Mock\r
- DMaaPAAFAuthenticator dmaapAAFauthenticator;\r
- @Mock\r
- NsaApiKey user;\r
-\r
- @Mock\r
- NsaSimpleApiKey nsaSimpleApiKey;\r
-\r
- @Mock\r
- HttpServletRequest httpServReq;\r
-\r
- @Mock\r
- HttpServletResponse httpServRes;\r
-\r
- @Mock\r
- DMaaPKafkaMetaBroker dmaapKafkaMetaBroker;\r
-\r
- @Mock\r
- Topic createdTopic;\r
-\r
- @Mock\r
- NsaAcl nsaAcl;\r
-\r
- @Mock\r
- JSONObject jsonObj;\r
-\r
- @Mock\r
- JSONArray jsonArray;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
-\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test(expected = DMaaPAccessDeniedException.class)\r
- public void testGetTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, JSONException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
- .thenReturn("namespace");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
- when(configReader.getfMetaBroker()).thenReturn(dmaapKafkaMetaBroker);\r
- when(httpServReq.getMethod()).thenReturn("HEAD");\r
-\r
- when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
-\r
- topicRestService.getTopics();\r
- }\r
-\r
- @Test\r
- public void testGetTopics_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, JSONException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
- .thenReturn("namespace");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
- String perms = "namespace" + "|" + "*" + "|" + "view";\r
- when(dmaapAAFauthenticator.aafAuthentication(httpServReq, perms)).thenReturn(true);\r
-\r
- when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
-\r
- topicRestService.getTopics();\r
- }\r
-\r
- @Test\r
- public void testGetTopics_error() throws DMaaPAccessDeniedException, TopicExistsException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
- .thenReturn("namespace");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
- String perms = "namespace" + "|" + "*" + "|" + "view";\r
- when(dmaapAAFauthenticator.aafAuthentication(httpServReq, perms)).thenReturn(true);\r
-\r
- when(dmaapKafkaMetaBroker.getTopic(anyString())).thenReturn(null);\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).getTopics(any());\r
- } catch (JSONException | ConfigDbException | IOException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.getTopics();\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test(expected = DMaaPAccessDeniedException.class)\r
- public void testGetAllTopics() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, JSONException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
- .thenReturn("namespace");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-\r
- topicRestService.getAllTopics();\r
- }\r
-\r
- @Test\r
- public void testGetAllTopics_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, JSONException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
- .thenReturn("namespace");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-\r
- topicRestService.getAllTopics();\r
- }\r
-\r
- @Test\r
- public void testGetAllTopics_error() throws DMaaPAccessDeniedException, TopicExistsException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "msgRtr.namespace.aaf"))\r
- .thenReturn("namespace");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).getAllTopics(any());\r
- } catch (JSONException | ConfigDbException | IOException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.getAllTopics();\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test(expected = DMaaPAccessDeniedException.class)\r
- public void testGetTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, JSONException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
- .thenReturn("enfTopicName");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn("Authorization");\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-\r
- topicRestService.getTopic("topicName");\r
- }\r
-\r
- @Test\r
- public void testGetTopic_nullAuth() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, JSONException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
- .thenReturn("enfTopicName");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-\r
- topicRestService.getTopic("topicName");\r
- }\r
-\r
- @Test\r
- public void testGetTopic_error() throws DMaaPAccessDeniedException, ConfigDbException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- PowerMockito.mockStatic(PropertiesMapBean.class);\r
-\r
- assertTrue(true);\r
- when(PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop, "enforced.topic.name.AAF"))\r
- .thenReturn("enfTopicName");\r
-\r
- PowerMockito.mockStatic(DMaaPResponseBuilder.class);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(httpServReq.getHeader("Authorization")).thenReturn(null);\r
-\r
- when(dmaapContext.getResponse()).thenReturn(httpServRes);\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).getTopic(any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.getTopic("topicName");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test\r
- public void testCreateTopic()\r
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.createTopic(topicBean);\r
- }\r
-\r
- @Test\r
- public void testCreateTopic_error() {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).createTopic(any(), any());\r
- } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.createTopic(topicBean);\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new TopicExistsException("error")).when(topicService).createTopic(any(), any());\r
- } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.createTopic(topicBean);\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).createTopic(any(), any());\r
- } catch (TopicExistsException | IOException | AccessDeniedException | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- } catch (CambriaApiException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.createTopic(topicBean);\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test\r
- public void testDeleteTopic()\r
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.deleteTopic("enfTopicNamePlusExtra");\r
- }\r
-\r
- @Test\r
- public void testDeleteTopic_error()\r
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).deleteTopic(any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.deleteTopic("enfTopicNamePlusExtra");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).deleteTopic(any(),\r
- any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.deleteTopic("enfTopicNamePlusExtra");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test\r
- public void testGetPublishersByTopicName()\r
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.getPublishersByTopicName("enfTopicNamePlusExtra");\r
- }\r
-\r
- @Test\r
- public void testGetPublishersByTopicName_error() {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).getPublishersByTopicName(any(),\r
- any());\r
- } catch (TopicExistsException | ConfigDbException | IOException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.getPublishersByTopicName("enfTopicNamePlusExtra");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test\r
- public void testPermitPublisherForTopic()\r
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID");\r
- }\r
-\r
- @Test\r
- public void testPermitPublisherForTopic_error()\r
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).permitPublisherForTopic(any(),\r
- any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).permitPublisherForTopic(any(),\r
- any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.permitPublisherForTopic("enfTopicNamePlusExtra", "producerID");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test\r
- public void testDenyPublisherForTopic()\r
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID");\r
- }\r
-\r
- @Test\r
- public void testDenyPublisherForTopic_error()\r
- throws DMaaPAccessDeniedException, CambriaApiException, IOException, TopicExistsException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).denyPublisherForTopic(any(),\r
- any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).denyPublisherForTopic(any(),\r
- any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.denyPublisherForTopic("enfTopicNamePlusExtra", "producerID");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testGetConsumersByTopicName() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, AccessDeniedException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.getConsumersByTopicName("enfTopicNamePlusExtra");\r
- }\r
-\r
- @Test\r
- public void testGetConsumersByTopicName_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, AccessDeniedException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).getConsumersByTopicName(any(),\r
- any());\r
- } catch (TopicExistsException | ConfigDbException | IOException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.getConsumersByTopicName("enfTopicNamePlusExtra");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test\r
- public void testPermitConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, AccessDeniedException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID");\r
- }\r
-\r
- @Test\r
- public void testPermitConsumerForTopic_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, AccessDeniedException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(any())).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).permitConsumerForTopic(any(),\r
- any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
- @Test\r
- public void testPermitConsumerForTopicWithException() throws DMaaPAccessDeniedException, CambriaApiException,\r
- IOException, TopicExistsException, AccessDeniedException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.permitConsumerForTopic("enfTopicNamePlusExtra", "consumerID");\r
- }\r
-\r
- @Test\r
- public void testDenyConsumerForTopic() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, AccessDeniedException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID");\r
- }\r
-\r
- @Test\r
- public void testDenyConsumerForTopic_error() throws DMaaPAccessDeniedException, CambriaApiException, IOException,\r
- TopicExistsException, AccessDeniedException {\r
-\r
- Assert.assertNotNull(topicRestService);\r
-\r
- when(dmaapContext.getRequest()).thenReturn(httpServReq);\r
- when(dmaaPAuthenticator.authenticate(dmaapContext)).thenReturn(nsaSimpleApiKey);\r
- when(configReader.getfSecurityManager()).thenReturn(dmaaPAuthenticator);\r
- when(dmaapContext.getConfigReader()).thenReturn(configReader);\r
-\r
- TopicBean topicBean = new TopicBean();\r
- topicBean.setTopicName("enfTopicNamePlusExtra");\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(topicService).denyConsumerForTopic(any(),\r
- any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
-\r
- try {\r
- PowerMockito.doThrow(new AccessDeniedException()).when(topicService).denyConsumerForTopic(any(),\r
- any(), any());\r
- } catch (TopicExistsException | ConfigDbException | IOException | AccessDeniedException\r
- | DMaaPAccessDeniedException excp) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- topicRestService.denyConsumerForTopic("enfTopicNamePlusExtra", "consumerID");\r
- } catch (CambriaApiException excp) {\r
- assertTrue(true);\r
- }\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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);
+ }
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.IOException;\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.lang.reflect.Method;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import com.att.ajsc.beans.PropertiesMapBean;\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;\r
-import org.onap.dmaap.dmf.mr.service.EventsService;\r
-import org.onap.dmaap.dmf.mr.service.TransactionService;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
-import com.att.aft.dme2.internal.jettison.json.JSONException;\r
-import org.powermock.api.mockito.PowerMockito;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ PropertiesMapBean.class })\r
-public class TransactionRestServiceTest {\r
-\r
- @InjectMocks\r
- TransactionRestService transactionRestService;\r
-\r
- @Mock\r
- private TransactionService transactionService;\r
-\r
- @Mock\r
- DMaaPContext dmaapContext;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
-\r
- }\r
-\r
- @Test\r
- public void testGetAllTransactionObjs() throws CambriaApiException {\r
-\r
- transactionRestService.getAllTransactionObjs();\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetTransactionObj() throws CambriaApiException {\r
-\r
- transactionRestService.getTransactionObj("transactionId");\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetAllTransactionObjsError() throws CambriaApiException {\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(transactionService).getAllTransactionObjs(dmaapContext);\r
- } catch (ConfigDbException | IOException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- transactionRestService.getAllTransactionObjs();\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testGetTransactionObjError() {\r
-\r
- try {\r
- PowerMockito.doThrow(new IOException()).when(transactionService).getTransactionObj(dmaapContext,\r
- "transactionId");\r
- } catch (ConfigDbException | JSONException | IOException e) {\r
- assertTrue(false);\r
- }\r
-\r
- try {\r
- transactionRestService.getTransactionObj("transactionId");\r
- } catch (CambriaApiException e) {\r
- assertTrue(true);\r
- }\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.service;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.lang.reflect.Method;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-import org.onap.dmaap.dmf.mr.CambriaApiException;\r
-import com.att.nsa.configs.ConfigDbException;\r
-import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;\r
-\r
-public class UIRestServicesTest {\r
-\r
- private UIRestServices service = null;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- service = new UIRestServices();\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testHello() {\r
-\r
- try {\r
- service.hello();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
- assertTrue(true);\r
- }\r
- \r
- @Test\r
- public void testGetApiKeysTable() {\r
-\r
- try {\r
- service.getApiKeysTable();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
- assertTrue(true);\r
- }\r
- \r
-\r
- @Test\r
- public void testGetApiKey() {\r
-\r
- try {\r
- service.getApiKey("apikey");\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
- assertTrue(true);\r
- }\r
- \r
- @Test\r
- public void testGetTopicsTable() {\r
-\r
- try {\r
- service.getTopicsTable();\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
- assertTrue(true);\r
- }\r
- \r
- @Test\r
- public void testGetTopic() {\r
-\r
- try {\r
- service.getTopic("topicName");\r
- } catch (NullPointerException e) {\r
- assertTrue(true);\r
- }\r
- assertTrue(true);\r
- }\r
- \r
- @Test\r
- public void testGetDmaapContext() {\r
- Class clazz = null;\r
- Method method = null;\r
- try {\r
- clazz = Class.forName("UIRestServices");\r
- Object obj = clazz.newInstance();\r
- method = clazz.getDeclaredMethod("getDmaapContext", null);\r
- method.setAccessible(true);\r
- method.invoke(obj, null);\r
- } catch (ClassNotFoundException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (NoSuchMethodException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (SecurityException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (InstantiationException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (IllegalAccessException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (IllegalArgumentException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (InvocationTargetException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
-\r
- assertTrue(true);\r
- }\r
- \r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.tools;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class ConfigToolContextTest {\r
- \r
- private ConfigToolContext context;\r
- @Before\r
- public void setUp() throws Exception {\r
- context = new ConfigToolContext(null, "connStr", null);\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testRequestShutdown() {\r
-\r
- context.requestShutdown();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testShouldContinue() {\r
-\r
- context.shouldContinue();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetDb() {\r
-\r
- context.getDb();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMetrics() {\r
-\r
- context.getMetrics();\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetConnectionString() {\r
-\r
- context.getConnectionString();\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.tools;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.lang.reflect.Constructor;\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.lang.reflect.Method;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class ConfigToolTest {\r
-\r
- private String[] parts = new String[5];\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
-\r
- for (int i = 0; i < parts.length; i++) {\r
- parts[i] = "string" + (i + 1);\r
- }\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- public void callMethodViaReflection(String outer, String inner, String methodName, Object... args) {\r
-\r
- String foreNameString = outer + "$" + inner;\r
- Object parent = new ConfigTool();\r
-\r
- Class<?> innerClass;\r
- try {\r
- innerClass = Class.forName(foreNameString);\r
- Constructor<?> constructor = innerClass.getDeclaredConstructor(ConfigTool.class);\r
- constructor.setAccessible(true);\r
- Object child = constructor.newInstance(parent);\r
-\r
- // invoking method on inner class object\r
- Method method = innerClass.getDeclaredMethod(methodName, null);\r
- method.setAccessible(true);// in case of unaccessible method\r
- method.invoke(child, args);\r
- } catch (ClassNotFoundException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (NoSuchMethodException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (SecurityException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (InstantiationException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (IllegalAccessException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (IllegalArgumentException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (InvocationTargetException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetMatches() {\r
-\r
- callMethodViaReflection("ConfigTool", "ListTopicCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady() {\r
-\r
- callMethodViaReflection("ConfigTool", "ListTopicCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute() {\r
-\r
- callMethodViaReflection("ConfigTool", "ListTopicCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp() {\r
-\r
- callMethodViaReflection("ConfigTool", "ListTopicCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetMatches2() {\r
-\r
- callMethodViaReflection("ConfigTool", "WriteTopicCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady2() {\r
-\r
- callMethodViaReflection("ConfigTool", "WriteTopicCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute2() {\r
-\r
- callMethodViaReflection("ConfigTool", "WriteTopicCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp2() {\r
-\r
- callMethodViaReflection("ConfigTool", "WriteTopicCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetMatches3() {\r
-\r
- callMethodViaReflection("ConfigTool", "ReadTopicCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady3() {\r
-\r
- callMethodViaReflection("ConfigTool", "ReadTopicCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute3() {\r
-\r
- callMethodViaReflection("ConfigTool", "ReadTopicCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp3() {\r
-\r
- callMethodViaReflection("ConfigTool", "ReadTopicCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetMatches4() {\r
-\r
- callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady4() {\r
-\r
- callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute4() {\r
-\r
- callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp4() {\r
-\r
- callMethodViaReflection("ConfigTool", "InitSecureTopicCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testGetMatches5() {\r
-\r
- callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady5() {\r
-\r
- callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute5() {\r
-\r
- callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp5() {\r
-\r
- callMethodViaReflection("ConfigTool", "SetTopicOwnerCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMatches6() {\r
-\r
- callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady6() {\r
-\r
- callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute6() {\r
-\r
- callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp6() {\r
-\r
- callMethodViaReflection("ConfigTool", "ListApiKeysCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMatches7() {\r
-\r
- callMethodViaReflection("ConfigTool", "PutApiCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady7() {\r
-\r
- callMethodViaReflection("ConfigTool", "PutApiCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute7() {\r
-\r
- callMethodViaReflection("ConfigTool", "PutApiCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp7() {\r
-\r
- callMethodViaReflection("ConfigTool", "PutApiCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMatches8() {\r
-\r
- callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady8() {\r
-\r
- callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute8() {\r
-\r
- callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp8() {\r
-\r
- callMethodViaReflection("ConfigTool", "writeApiKeyCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMatches9() {\r
-\r
- callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady9() {\r
-\r
- callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute9() {\r
-\r
- callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp9() {\r
-\r
- callMethodViaReflection("ConfigTool", "EncryptApiKeysCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMatches10() {\r
-\r
- callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady10() {\r
-\r
- callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute10() {\r
-\r
- callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp10() {\r
-\r
- callMethodViaReflection("ConfigTool", "DecryptApiKeysCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMatches11() {\r
-\r
- callMethodViaReflection("ConfigTool", "NodeFetchCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady11() {\r
-\r
- callMethodViaReflection("ConfigTool", "NodeFetchCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute11() {\r
-\r
- callMethodViaReflection("ConfigTool", "NodeFetchCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp11() {\r
-\r
- callMethodViaReflection("ConfigTool", "NodeFetchCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
- \r
- @Test\r
- public void testGetMatches12() {\r
-\r
- callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "getMatches");\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testCheckReady12() {\r
-\r
- callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "checkReady", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testExecute12() {\r
-\r
- callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "execute", parts, null, null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
- @Test\r
- public void testDisplayHelp12() {\r
-\r
- callMethodViaReflection("ConfigTool", "DropOldConsumerGroupsCommand", "displayHelp", null);\r
-\r
- assertTrue(true);\r
-\r
- }\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.tools;\r
-\r
-import junit.framework.TestSuite;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.Suite;\r
-import org.junit.runners.Suite.SuiteClasses;\r
-import org.apache.log4j.Logger;\r
-\r
-@RunWith(Suite.class)\r
-@SuiteClasses({ ConfigToolTest.class, ConfigToolContextTest.class,})\r
-public class JUnitTestSuite {\r
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
-\r
- public static void main(String[] args) {\r
- LOGGER.info("Running the test suite");\r
- \r
- TestSuite tstSuite = new TestSuite();\r
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
--- /dev/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.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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.util;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.util.Map;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ System.class })\r
-public class ContentLengthInterceptorTest {\r
- @InjectMocks\r
- ContentLengthInterceptor interceptor = null;\r
-\r
- @Mock\r
- Map map;\r
-\r
- @Mock\r
- HttpServletRequest req;\r
-\r
- @Mock\r
- HttpServletResponse res;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- // interceptor = new ContentLengthInterceptor();\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testAllowOrReject() throws Exception {\r
- PowerMockito.when(req.getHeader("Transfer-Encoding")).thenReturn("UTF-8");\r
- PowerMockito.when(req.getHeader("Content-Length")).thenReturn("1027");\r
-\r
- interceptor.allowOrReject(req, res, map);\r
- assertTrue(true);\r
- }\r
- \r
- //@Test(expected = NullPointerException.class) \r
- public void testAllowOrRejectWithException() throws Exception {\r
- PowerMockito.when(req.getHeader("Transfer-Encoding")).thenThrow(new NumberFormatException());\r
- interceptor.allowOrReject(req, res, map);\r
- assertTrue(true);\r
- }\r
- \r
-\r
- @Test\r
- public void testGetDefLength() {\r
- interceptor.getDefLength();\r
- assertTrue(true);\r
- }\r
-\r
- @Test\r
- public void testSetDefLength() {\r
- interceptor.setDefLength("defLength");\r
- assertTrue(true);\r
-\r
- }\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.util;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.servlet.FilterChain;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.ServletResponse;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import com.att.ajsc.beans.PropertiesMapBean;\r
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;\r
-import org.onap.dmaap.dmf.mr.exception.DMaaPResponseCode;\r
-\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest({ PropertiesMapBean.class, DMaaPResponseCode.class })\r
-public class DMaaPAuthFilterTest {\r
-\r
- @InjectMocks\r
- DMaaPAuthFilter filter;\r
-\r
- @Mock\r
- HttpServletRequest req;\r
-\r
- @Mock\r
- ServletResponse res;\r
-\r
- @Mock\r
- FilterChain chain;\r
-\r
- @Mock\r
- DMaaPContext dmaapContext;\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- //@Test\r
- public void testDoFilter() throws IOException, ServletException {\r
-\r
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(req);\r
- PowerMockito.when(req.getHeader("Authorization")).thenReturn("Authorization");\r
- // when(dmaapContext.getResponse()).thenReturn(res);\r
- filter.doFilter(req, res, chain);\r
- assertTrue(true);\r
-\r
- }\r
-\r
- //@Test\r
- public void testDoFilter_nullAuth() throws IOException, ServletException {\r
-\r
- PowerMockito.when(dmaapContext.getRequest()).thenReturn(req);\r
- PowerMockito.when(req.getHeader("Authorization")).thenReturn("Authorization");\r
-\r
- // when(dmaapContext.getResponse()).thenReturn(res);\r
- filter.doFilter(req, res, chain);\r
- assertTrue(true);\r
-\r
- }\r
- \r
- \r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.util;\r
-\r
-import junit.framework.TestSuite;\r
-\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.Suite;\r
-import org.junit.runners.Suite.SuiteClasses;\r
-import org.apache.log4j.Logger;\r
-\r
-@RunWith(Suite.class)\r
-@SuiteClasses({ ContentLengthInterceptorTest.class, DMaaPAuthFilterTest.class, ServicePropertiesMapBeanTest.class})\r
-public class JUnitTestSuite {\r
- private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);\r
-\r
- public static void main(String[] args) {\r
- LOGGER.info("Running the test suite");\r
- \r
- TestSuite tstSuite = new TestSuite();\r
- LOGGER.info("Total Test Counts " + tstSuite.countTestCases());\r
- }\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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());
+ }
+
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP Policy Engine\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package com.att.nsa.dmaap.util;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class ServicePropertiesMapBeanTest {\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
-\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
-\r
- @Test\r
- public void testGetProperty() {\r
-\r
- try {\r
- ServicePropertiesMapBean.getProperty(null, null);\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
-\r
- assertTrue(true);\r
-\r
- }\r
-\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
--- /dev/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.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());
+ }
+
+}