From 31e122b8c77b933db7475b2889efcfba83e378b5 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Thu, 27 Dec 2018 19:52:56 +0900 Subject: Rename test classes in policy/engine Make test classes name consitence by adding 'Test' at end of junit test classes and adding 'Support' or 'Dummy' at start of util or dummy type of test classes Issue-ID: POLICY-1281 Change-Id: I5fa65d0cfc95edc8f2fe0ca678a43d2011a39670 Signed-off-by: Parshad Patel --- .../pdp/rest/api/test/GetConfigServiceTest.java | 70 ++++ .../rest/api/test/GetDictionaryServiceTest.java | 231 ++++++++++++ .../policy/pdp/rest/api/test/getConfigTest.java | 70 ---- .../pdp/rest/api/test/getDictionaryTest.java | 231 ------------ .../pdp/rest/jmx/DummyServerContextImpl.java | 399 +++++++++++++++++++++ .../pdp/rest/jmx/PdpRestMBeanListenerTest.java | 2 +- .../policy/pdp/rest/jmx/ServerContextImpl.java | 399 --------------------- 7 files changed, 701 insertions(+), 701 deletions(-) create mode 100644 ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java create mode 100644 ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java delete mode 100644 ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/getConfigTest.java delete mode 100644 ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/getDictionaryTest.java create mode 100644 ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java delete mode 100644 ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/ServerContextImpl.java (limited to 'ONAP-PDP-REST') diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java new file mode 100644 index 000000000..a3c1b2b05 --- /dev/null +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP-PDP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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.policy.pdp.rest.api.test; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.onap.policy.api.ConfigRequestParameters; +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.pdp.rest.api.models.PolicyConfig; +import org.onap.policy.pdp.rest.api.services.GetConfigService; + +public class GetConfigServiceTest { + private static final String TEST = "test"; + + @SuppressWarnings("unchecked") + @Test + public void filterMethodTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{ + ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); + GetConfigService getConfigService= new GetConfigService(configRequestParameters, null); + Method filter = GetConfigService.class.getDeclaredMethod("filterResults", Collection.class,ConfigRequestParameters.class); + filter.setAccessible(true); + List policyConfigs = new LinkedList<>(); + + List filterResults = (List) filter.invoke(getConfigService, policyConfigs,configRequestParameters); + assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus()); + // Check again with some values + configRequestParameters.setPolicyName(TEST); + configRequestParameters.setOnapName(TEST); + configRequestParameters.setConfigName(TEST); + Map configAttributes = new HashMap<>(); + configAttributes.put(TEST, TEST); + configRequestParameters.setConfigAttributes(configAttributes); + PolicyConfig pConfig = new PolicyConfig(); + pConfig.setPolicyName(TEST); + Map matching = new HashMap<>(); + matching.put("ONAPName", TEST); + matching.put("ConfigName", TEST); + matching.put("TEST", TEST); + pConfig.setMatchingConditions(matching); + policyConfigs.add(pConfig); + filterResults = (List) filter.invoke(getConfigService, policyConfigs,configRequestParameters); + assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus()); + } +} diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java new file mode 100644 index 000000000..b5706a8ed --- /dev/null +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java @@ -0,0 +1,231 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP-PDP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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.policy.pdp.rest.api.test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.lang.reflect.Method; + +import org.junit.Test; +import org.onap.policy.api.DictionaryParameters; +import org.onap.policy.pdp.rest.api.services.GetDictionaryService; + +public class GetDictionaryServiceTest { + + @Test + public void dictionaryJsonTest() throws Exception{ + Method formatDictionary = GetDictionaryService.class.getDeclaredMethod("formatDictionaryJson", String.class); + formatDictionary.setAccessible(true); + String input="{\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"," + + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"," + + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"}"; + DictionaryParameters dp = new DictionaryParameters(); + dp.setDictionary("test"); + GetDictionaryService gds = new GetDictionaryService(dp, null); + String result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("OnapName"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Attribute"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Action"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("BRMSParamTemplate"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("VSCLAction"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("VNFType"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("PEPOptions"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Varbind"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Service"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Site"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Settings"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("DescriptiveScope"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Enforcer"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("ActionList"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("ProtocolList"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Zone"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("SecurityZone"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("PrefixList"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("AddressGroup"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("ServiceGroup"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("ServiceList"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("TermList"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("RuleList"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("FirewallRuleList"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("Term"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("MicroServiceLocation"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("MicroServiceConfigName"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("DCAEUUID"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("MicroServiceModels"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("PolicyScopeService"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("PolicyScopeResource"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("PolicyScopeType"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("PolicyScopeClosedLoop"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("GroupPolicyScopeList"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("RiskType"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("SafePolicyWarning"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + // + dp.setDictionary("MicroServiceDictionary"); + gds = new GetDictionaryService(dp, null); + result = (String) formatDictionary.invoke(gds, input); + assertNotNull(result); + } +} diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/getConfigTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/getConfigTest.java deleted file mode 100644 index 2d79b234a..000000000 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/getConfigTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP-PDP-REST - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS 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.policy.pdp.rest.api.test; - -import static org.junit.Assert.assertEquals; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.onap.policy.api.ConfigRequestParameters; -import org.onap.policy.api.PolicyConfigStatus; -import org.onap.policy.pdp.rest.api.models.PolicyConfig; -import org.onap.policy.pdp.rest.api.services.GetConfigService; - -public class getConfigTest { - private static final String TEST = "test"; - - @SuppressWarnings("unchecked") - @Test - public void filterMethodTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{ - ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); - GetConfigService getConfigService= new GetConfigService(configRequestParameters, null); - Method filter = GetConfigService.class.getDeclaredMethod("filterResults", Collection.class,ConfigRequestParameters.class); - filter.setAccessible(true); - List policyConfigs = new LinkedList<>(); - - List filterResults = (List) filter.invoke(getConfigService, policyConfigs,configRequestParameters); - assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus()); - // Check again with some values - configRequestParameters.setPolicyName(TEST); - configRequestParameters.setOnapName(TEST); - configRequestParameters.setConfigName(TEST); - Map configAttributes = new HashMap<>(); - configAttributes.put(TEST, TEST); - configRequestParameters.setConfigAttributes(configAttributes); - PolicyConfig pConfig = new PolicyConfig(); - pConfig.setPolicyName(TEST); - Map matching = new HashMap<>(); - matching.put("ONAPName", TEST); - matching.put("ConfigName", TEST); - matching.put("TEST", TEST); - pConfig.setMatchingConditions(matching); - policyConfigs.add(pConfig); - filterResults = (List) filter.invoke(getConfigService, policyConfigs,configRequestParameters); - assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus()); - } -} diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/getDictionaryTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/getDictionaryTest.java deleted file mode 100644 index 38dafee35..000000000 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/getDictionaryTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP-PDP-REST - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS 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.policy.pdp.rest.api.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.lang.reflect.Method; - -import org.junit.Test; -import org.onap.policy.api.DictionaryParameters; -import org.onap.policy.pdp.rest.api.services.GetDictionaryService; - -public class getDictionaryTest { - - @Test - public void dictionaryJsonTest() throws Exception{ - Method formatDictionary = GetDictionaryService.class.getDeclaredMethod("formatDictionaryJson", String.class); - formatDictionary.setAccessible(true); - String input="{\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"," - + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"," - + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"}"; - DictionaryParameters dp = new DictionaryParameters(); - dp.setDictionary("test"); - GetDictionaryService gds = new GetDictionaryService(dp, null); - String result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("OnapName"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Attribute"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Action"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("BRMSParamTemplate"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("VSCLAction"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("VNFType"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("PEPOptions"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Varbind"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Service"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Site"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Settings"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("DescriptiveScope"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Enforcer"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("ActionList"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("ProtocolList"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Zone"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("SecurityZone"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("PrefixList"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("AddressGroup"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("ServiceGroup"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("ServiceList"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("TermList"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("RuleList"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("FirewallRuleList"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("Term"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("MicroServiceLocation"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("MicroServiceConfigName"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("DCAEUUID"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("MicroServiceModels"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("PolicyScopeService"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("PolicyScopeResource"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("PolicyScopeType"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("PolicyScopeClosedLoop"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("GroupPolicyScopeList"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("RiskType"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("SafePolicyWarning"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - // - dp.setDictionary("MicroServiceDictionary"); - gds = new GetDictionaryService(dp, null); - result = (String) formatDictionary.invoke(gds, input); - assertNotNull(result); - } -} diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java new file mode 100644 index 000000000..056b73199 --- /dev/null +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java @@ -0,0 +1,399 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP-PDP-REST + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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.policy.pdp.rest.jmx; + +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.EventListener; +import java.util.Map; +import java.util.Set; + +import javax.servlet.Filter; +import javax.servlet.FilterRegistration; +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; +import javax.servlet.ServletRegistration.Dynamic; +import javax.servlet.SessionCookieConfig; +import javax.servlet.SessionTrackingMode; +import javax.servlet.descriptor.JspConfigDescriptor; + +public class DummyServerContextImpl implements ServletContext { + + @Override + public String getContextPath() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ServletContext getContext(String uripath) { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getMajorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMinorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getEffectiveMajorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getEffectiveMinorVersion() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String getMimeType(String file) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Set getResourcePaths(String path) { + // TODO Auto-generated method stub + return null; + } + + @Override + public URL getResource(String path) throws MalformedURLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public InputStream getResourceAsStream(String path) { + // TODO Auto-generated method stub + return null; + } + + @Override + public RequestDispatcher getRequestDispatcher(String path) { + // TODO Auto-generated method stub + return null; + } + + @Override + public RequestDispatcher getNamedDispatcher(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Servlet getServlet(String name) throws ServletException { + // TODO Auto-generated method stub + return null; + } + + @Override + public Enumeration getServlets() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Enumeration getServletNames() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void log(String msg) { + // TODO Auto-generated method stub + + } + + @Override + public void log(Exception exception, String msg) { + // TODO Auto-generated method stub + + } + + @Override + public void log(String message, Throwable throwable) { + // TODO Auto-generated method stub + + } + + @Override + public String getRealPath(String path) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getServerInfo() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getInitParameter(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Enumeration getInitParameterNames() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean setInitParameter(String name, String value) { + // TODO Auto-generated method stub + return false; + } + + @Override + public Object getAttribute(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Enumeration getAttributeNames() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setAttribute(String name, Object object) { + // TODO Auto-generated method stub + + } + + @Override + public void removeAttribute(String name) { + // TODO Auto-generated method stub + + } + + @Override + public String getServletContextName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Dynamic addServlet(String servletName, String className) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Dynamic addServlet(String servletName, Servlet servlet) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Dynamic addServlet(String servletName, Class servletClass) { + // TODO Auto-generated method stub + return null; + } + + @Override + public T createServlet(Class clazz) throws ServletException { + // TODO Auto-generated method stub + return null; + } + + @Override + public ServletRegistration getServletRegistration(String servletName) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getServletRegistrations() { + // TODO Auto-generated method stub + return null; + } + + @Override + public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className) { + // TODO Auto-generated method stub + return null; + } + + @Override + public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Filter filter) { + // TODO Auto-generated method stub + return null; + } + + @Override + public javax.servlet.FilterRegistration.Dynamic addFilter( + String filterName, Class filterClass) { + // TODO Auto-generated method stub + return null; + } + + @Override + public T createFilter(Class clazz) throws ServletException { + // TODO Auto-generated method stub + return null; + } + + @Override + public FilterRegistration getFilterRegistration(String filterName) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getFilterRegistrations() { + // TODO Auto-generated method stub + return null; + } + + @Override + public SessionCookieConfig getSessionCookieConfig() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setSessionTrackingModes(Set sessionTrackingModes) { + // TODO Auto-generated method stub + + } + + @Override + public Set getDefaultSessionTrackingModes() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Set getEffectiveSessionTrackingModes() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void addListener(String className) { + // TODO Auto-generated method stub + + } + + @Override + public void addListener(T t) { + // TODO Auto-generated method stub + + } + + @Override + public void addListener(Class listenerClass) { + // TODO Auto-generated method stub + + } + + @Override + public T createListener(Class clazz) throws ServletException { + // TODO Auto-generated method stub + return null; + } + + @Override + public JspConfigDescriptor getJspConfigDescriptor() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ClassLoader getClassLoader() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void declareRoles(String... roleNames) { + // TODO Auto-generated method stub + + } + + @Override + public String getVirtualServerName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Dynamic addJspFile(String arg0, String arg1) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getRequestCharacterEncoding() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getResponseCharacterEncoding() { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getSessionTimeout() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void setRequestCharacterEncoding(String arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void setResponseCharacterEncoding(String arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void setSessionTimeout(int arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java index ea689e663..59e14db1e 100644 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java @@ -37,7 +37,7 @@ public class PdpRestMBeanListenerTest { try { PdpRestMBeanListener listener = new PdpRestMBeanListener(); - ServerContextImpl source = new ServerContextImpl(); + DummyServerContextImpl source = new DummyServerContextImpl(); ServletContextEvent event = new ServletContextEvent(source); listener.contextInitialized(event); diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/ServerContextImpl.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/ServerContextImpl.java deleted file mode 100644 index 2f8683c5c..000000000 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/ServerContextImpl.java +++ /dev/null @@ -1,399 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP-PDP-REST - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS 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.policy.pdp.rest.jmx; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; -import java.util.EventListener; -import java.util.Map; -import java.util.Set; - -import javax.servlet.Filter; -import javax.servlet.FilterRegistration; -import javax.servlet.RequestDispatcher; -import javax.servlet.Servlet; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; -import javax.servlet.ServletRegistration.Dynamic; -import javax.servlet.SessionCookieConfig; -import javax.servlet.SessionTrackingMode; -import javax.servlet.descriptor.JspConfigDescriptor; - -public class ServerContextImpl implements ServletContext { - - @Override - public String getContextPath() { - // TODO Auto-generated method stub - return null; - } - - @Override - public ServletContext getContext(String uripath) { - // TODO Auto-generated method stub - return null; - } - - @Override - public int getMajorVersion() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public int getMinorVersion() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public int getEffectiveMajorVersion() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public int getEffectiveMinorVersion() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public String getMimeType(String file) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set getResourcePaths(String path) { - // TODO Auto-generated method stub - return null; - } - - @Override - public URL getResource(String path) throws MalformedURLException { - // TODO Auto-generated method stub - return null; - } - - @Override - public InputStream getResourceAsStream(String path) { - // TODO Auto-generated method stub - return null; - } - - @Override - public RequestDispatcher getRequestDispatcher(String path) { - // TODO Auto-generated method stub - return null; - } - - @Override - public RequestDispatcher getNamedDispatcher(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Servlet getServlet(String name) throws ServletException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Enumeration getServlets() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Enumeration getServletNames() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void log(String msg) { - // TODO Auto-generated method stub - - } - - @Override - public void log(Exception exception, String msg) { - // TODO Auto-generated method stub - - } - - @Override - public void log(String message, Throwable throwable) { - // TODO Auto-generated method stub - - } - - @Override - public String getRealPath(String path) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getServerInfo() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getInitParameter(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Enumeration getInitParameterNames() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean setInitParameter(String name, String value) { - // TODO Auto-generated method stub - return false; - } - - @Override - public Object getAttribute(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Enumeration getAttributeNames() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setAttribute(String name, Object object) { - // TODO Auto-generated method stub - - } - - @Override - public void removeAttribute(String name) { - // TODO Auto-generated method stub - - } - - @Override - public String getServletContextName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Dynamic addServlet(String servletName, String className) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Dynamic addServlet(String servletName, Servlet servlet) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Dynamic addServlet(String servletName, Class servletClass) { - // TODO Auto-generated method stub - return null; - } - - @Override - public T createServlet(Class clazz) throws ServletException { - // TODO Auto-generated method stub - return null; - } - - @Override - public ServletRegistration getServletRegistration(String servletName) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getServletRegistrations() { - // TODO Auto-generated method stub - return null; - } - - @Override - public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className) { - // TODO Auto-generated method stub - return null; - } - - @Override - public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Filter filter) { - // TODO Auto-generated method stub - return null; - } - - @Override - public javax.servlet.FilterRegistration.Dynamic addFilter( - String filterName, Class filterClass) { - // TODO Auto-generated method stub - return null; - } - - @Override - public T createFilter(Class clazz) throws ServletException { - // TODO Auto-generated method stub - return null; - } - - @Override - public FilterRegistration getFilterRegistration(String filterName) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getFilterRegistrations() { - // TODO Auto-generated method stub - return null; - } - - @Override - public SessionCookieConfig getSessionCookieConfig() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setSessionTrackingModes(Set sessionTrackingModes) { - // TODO Auto-generated method stub - - } - - @Override - public Set getDefaultSessionTrackingModes() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set getEffectiveSessionTrackingModes() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void addListener(String className) { - // TODO Auto-generated method stub - - } - - @Override - public void addListener(T t) { - // TODO Auto-generated method stub - - } - - @Override - public void addListener(Class listenerClass) { - // TODO Auto-generated method stub - - } - - @Override - public T createListener(Class clazz) throws ServletException { - // TODO Auto-generated method stub - return null; - } - - @Override - public JspConfigDescriptor getJspConfigDescriptor() { - // TODO Auto-generated method stub - return null; - } - - @Override - public ClassLoader getClassLoader() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void declareRoles(String... roleNames) { - // TODO Auto-generated method stub - - } - - @Override - public String getVirtualServerName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Dynamic addJspFile(String arg0, String arg1) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getRequestCharacterEncoding() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getResponseCharacterEncoding() { - // TODO Auto-generated method stub - return null; - } - - @Override - public int getSessionTimeout() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void setRequestCharacterEncoding(String arg0) { - // TODO Auto-generated method stub - - } - - @Override - public void setResponseCharacterEncoding(String arg0) { - // TODO Auto-generated method stub - - } - - @Override - public void setSessionTimeout(int arg0) { - // TODO Auto-generated method stub - - } -} -- cgit 1.2.3-korg