summaryrefslogtreecommitdiffstats
path: root/ONAP-XACML/src/test
diff options
context:
space:
mode:
authorguangxingwang <gw1218@att.com>2017-09-21 16:41:50 -0500
committerguangxingwang <gw1218@att.com>2017-09-22 09:07:55 -0500
commitb08ee72d9d64aa3728450d1c23b3faf5bca34268 (patch)
treee381f7b9c21fbfca90b07e9170ea8369e522681c /ONAP-XACML/src/test
parent94eaa7529fa3dd60eda311ac14da93b57f31f1e2 (diff)
Add New Junit Tests For ONAP-XACML
Add three new java junit test files to ONAP-XACML Issue-ID: POLICY-52 Change-Id: I900f09c9baf773e46dadddf9d715af6033ffce0e Signed-off-by: guangxingwang <gw1218@att.com>
Diffstat (limited to 'ONAP-XACML/src/test')
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java208
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java231
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java107
3 files changed, 546 insertions, 0 deletions
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java
new file mode 100644
index 000000000..f0626188c
--- /dev/null
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java
@@ -0,0 +1,208 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.xacml.test.std.pap;
+
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.xacml.std.pap.StdPDP;
+import org.onap.policy.xacml.std.pap.StdPDPGroupStatus;
+import org.onap.policy.xacml.std.pap.StdPDPPIPConfig;
+
+public class StdPDPGroupStatusTest {
+
+ private static Logger logger = FlexLogger.getLogger(StdPDPGroupStatus.class);
+
+ private StdPDPGroupStatus stdPDPGroupStatus;
+
+ @Before
+ public void setUp(){
+
+ try {
+ stdPDPGroupStatus = new StdPDPGroupStatus();
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void tesGgetStatus() {
+ try {
+ assertTrue(stdPDPGroupStatus.getStatus() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetFailedPIPConfigs() {
+ try {
+ assertTrue(stdPDPGroupStatus.getFailedPIPConfigs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetUnknownPDPs() {
+ try {
+ assertTrue(stdPDPGroupStatus.getUnknownPDPs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetLoadErrors() {
+ try {
+ stdPDPGroupStatus.setLoadErrors(new HashSet<String>());
+ assertTrue(stdPDPGroupStatus.getLoadErrors() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetLoadWarnings() {
+ try {
+ stdPDPGroupStatus.setLoadWarnings(new HashSet<>());
+ assertTrue(stdPDPGroupStatus.getLoadWarnings() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetLoadedPolicies() {
+ try {
+ stdPDPGroupStatus.setLoadedPolicies(new HashSet<>());
+ assertTrue(stdPDPGroupStatus.getLoadedPolicies() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetFailedPolicies() {
+ try {
+ stdPDPGroupStatus.setFailedPolicies(new HashSet<>());
+ assertTrue(stdPDPGroupStatus.getFailedPolicies() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetLoadedPipConfigs() {
+ try {
+ stdPDPGroupStatus.addLoadedPipConfig(new StdPDPPIPConfig());
+ assertTrue(stdPDPGroupStatus.getLoadedPipConfigs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetFailedPipConfigs() {
+ try {
+ stdPDPGroupStatus.addFailedPipConfig(new StdPDPPIPConfig());
+ assertTrue(stdPDPGroupStatus.getFailedPipConfigs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetInSynchPDPs() {
+ try {
+ stdPDPGroupStatus.addInSynchPDP(new StdPDP());
+ assertTrue(stdPDPGroupStatus.getInSynchPDPs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetOutOfSynchPDPs() {
+ try {
+ stdPDPGroupStatus.addOutOfSynchPDP(new StdPDP());
+ assertTrue(stdPDPGroupStatus.getOutOfSynchPDPs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetFailedPDPs() {
+ try {
+ stdPDPGroupStatus.addFailedPDP(new StdPDP());
+ assertTrue(stdPDPGroupStatus.getFailedPDPs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetUpdatingPDPs() {
+ try {
+ stdPDPGroupStatus.addUpdatingPDP(new StdPDP());
+ assertTrue(stdPDPGroupStatus.getUpdatingPDPs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetLastUpdateFailedPDPs() {
+ try {
+ stdPDPGroupStatus.addLastUpdateFailedPDP(new StdPDP());
+ assertTrue(stdPDPGroupStatus.getLastUpdateFailedPDPs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetUnknownStatusPDPs() {
+ try {
+ stdPDPGroupStatus.addUnknownPDP(new StdPDP());
+ assertTrue(stdPDPGroupStatus.getUnknownStatusPDPs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testIsGroupOk() {
+ try {
+ stdPDPGroupStatus.policiesOK();
+ assertTrue(stdPDPGroupStatus.isGroupOk() == false);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java
new file mode 100644
index 000000000..a8a2abf54
--- /dev/null
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java
@@ -0,0 +1,231 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.xacml.test.std.pap;
+
+import static org.junit.Assert.*;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.xacml.api.pap.OnapPDP;
+import org.onap.policy.xacml.std.pap.StdPDP;
+import org.onap.policy.xacml.std.pap.StdPDPGroup;
+import org.onap.policy.xacml.std.pap.StdPDPGroupStatus;
+
+public class StdPDPGroupTest {
+
+
+ private static Logger logger = FlexLogger.getLogger(StdPDPGroupTest.class);
+
+ private StdPDPGroup stdPDPGroup;
+ private Path repository;
+ private StdPDP testPdp = new StdPDP();
+ private StdPDP testPdp1 = new StdPDP();
+
+ @Before
+ public void setUp(){
+
+ try {
+ stdPDPGroup = new StdPDPGroup();
+ repository = Paths.get("src/test/resources/pdps");
+ testPdp1.setId("100");
+
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+
+ @Test
+ public void testGetStatus() {
+ try {
+ assertTrue(stdPDPGroup.getStatus() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetId() {
+ try {
+ stdPDPGroup.setId("testId");
+ assertTrue(stdPDPGroup.getId() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testIsDefaultGroup() {
+ try {
+ stdPDPGroup.setDefaultGroup(true);
+ assertTrue(stdPDPGroup.isDefaultGroup() == true);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetName() {
+ try {
+ stdPDPGroup.setName("testing");
+ assertTrue(stdPDPGroup.getName() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetDescription() {
+ try {
+ stdPDPGroup.setDescription("description");
+ assertTrue(stdPDPGroup.getDescription() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetDirectory() {
+ try {
+ stdPDPGroup.setDirectory(repository);
+ assertTrue(stdPDPGroup.getDirectory() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetSelectedPolicies() {
+ try {
+ assertTrue(stdPDPGroup.getSelectedPolicies() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetOperation() {
+ try {
+ stdPDPGroup.setOperation("test");
+ assertTrue(stdPDPGroup.getOperation() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetPdps() {
+ try {
+ stdPDPGroup.setOnapPdps(new HashSet<>());
+ assertTrue(stdPDPGroup.getPdps() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetOnapPdps() {
+ try {
+ stdPDPGroup.setOnapPdps(new HashSet<>());
+ assertTrue(stdPDPGroup.getOnapPdps() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testAddPDP() {
+ try {
+ assertTrue(stdPDPGroup.addPDP(testPdp) == true);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testRemovePDP() {
+ try {
+ assertTrue(stdPDPGroup.removePDP(testPdp) == false);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetPolicies() {
+ try {
+ stdPDPGroup.setPolicies(new HashSet());
+ assertTrue(stdPDPGroup.getPolicies() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetPolicy() {
+ try {
+ assertTrue(stdPDPGroup.getPolicy("wrongId") == null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+
+ @Test
+ public void testGetPipConfigs() {
+ try {
+ stdPDPGroup.setPipConfigs(new HashSet());
+ assertTrue(stdPDPGroup.getPipConfigs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetPipConfig() {
+ try {
+ Set pipConfigs = new HashSet();
+ StdPDP testPdp = new StdPDP();
+ testPdp.setId("20");
+ pipConfigs.add(testPdp);
+ stdPDPGroup.setId("testId");
+ assertTrue(stdPDPGroup.getPipConfig("222") == null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetPipConfigProperties() {
+ try {
+ assertTrue(stdPDPGroup.getPipConfigProperties() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java
new file mode 100644
index 000000000..628e725f2
--- /dev/null
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java
@@ -0,0 +1,107 @@
+package org.onap.policy.xacml.test.std.pap;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.xacml.std.pap.StdPDP;
+import org.onap.policy.xacml.std.pap.StdPDPStatus;
+
+public class StdPDPTest {
+
+ private static Logger logger = FlexLogger.getLogger(StdPDPTest.class);
+
+ private StdPDP stdPDP;
+
+ @Before
+ public void setUp(){
+
+ try {
+ stdPDP = new StdPDP();
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetId() {
+ try {
+ stdPDP.setId("testId");
+ assertTrue(stdPDP.getId() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetName() {
+ try {
+ stdPDP.setName("abc");
+ assertTrue(stdPDP.getName() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetDescription() {
+ try {
+ stdPDP.setDescription("somee here");
+ assertTrue(stdPDP.getDescription() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetStatus() {
+ try {
+ stdPDP.setStatus(new StdPDPStatus());
+ assertTrue(stdPDP.getStatus() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetPipConfigs() {
+ try {
+ assertTrue(stdPDP.getPipConfigs() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+ @Test
+ public void testGetJmxPort() {
+ try {
+ stdPDP.setJmxPort(123);
+ assertTrue(stdPDP.getJmxPort() != null);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+
+}