summaryrefslogtreecommitdiffstats
path: root/feature-state-management/src/test/java/org
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-09-25 19:28:23 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-25 19:28:23 +0000
commit857e086044637992fe7ba69e8bd423805c329ad7 (patch)
tree551168c7b3b6e81182c57e9dfd15732dcaf4c20d /feature-state-management/src/test/java/org
parent872ca20525796cb1de950f78f573cda92073a694 (diff)
parent2b2d21fd2761ceab9faa50f224b1d136f3b36d34 (diff)
Merge "Incr State Mgmt Code Coverage"
Diffstat (limited to 'feature-state-management/src/test/java/org')
-rw-r--r--feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/Audit.java43
-rw-r--r--feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java70
2 files changed, 93 insertions, 20 deletions
diff --git a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/Audit.java b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/Audit.java
new file mode 100644
index 00000000..b33171bb
--- /dev/null
+++ b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/Audit.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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.drools.statemanagement.test;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="Audit")
+
+public class Audit implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @Column(name="name", length=64, unique=true)
+ private String name;
+
+ public Audit() {
+ //default constructor
+ }
+}
diff --git a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
index 1cd61788..ba7ce3ea 100644
--- a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
+++ b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
@@ -24,12 +24,14 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.util.Properties;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
+import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.AfterClass;
@@ -38,6 +40,9 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.core.PolicySessionFeatureAPI;
+import org.onap.policy.drools.statemanagement.DbAudit;
+import org.onap.policy.drools.statemanagement.IntegrityMonitorRestManager;
+import org.onap.policy.drools.statemanagement.RepositoryAudit;
import org.onap.policy.drools.statemanagement.StateManagementFeatureAPI;
import org.onap.policy.drools.statemanagement.StateManagementProperties;
import org.slf4j.Logger;
@@ -49,10 +54,10 @@ public class StateManagementTest {
private static Logger logger = LoggerFactory.getLogger(StateManagementTest.class);
/*
- * Sleep 5 seconds after each test to allow interrupt (shutdown) recovery.
+ * Sleep after each test to allow interrupt (shutdown) recovery.
*/
- private long interruptRecoveryTime = 1000;
+ private long interruptRecoveryTime = 1500L;
StateManagementFeatureAPI stateManagementFeature;
@@ -90,7 +95,6 @@ public class StateManagementTest {
public void tearDown() throws Exception {
}
-
/*
* Verifies that StateManagementFeature starts and runs successfully.
@@ -106,6 +110,8 @@ public class StateManagementTest {
String configDir = "src/test/resources";
+ DbAudit.isJunit = true;
+
Properties fsmProperties = new Properties();
fsmProperties.load(new FileInputStream(new File(
configDir + "/feature-state-management.properties")));
@@ -136,13 +142,9 @@ public class StateManagementTest {
String standby = stateManagementFeature.getStandbyStatus();
logger.debug("admin = {}", admin);
- System.out.println("admin = " + admin);
logger.debug("oper = {}", oper);
- System.out.println("oper = " + oper);
logger.debug("avail = {}", avail);
- System.out.println("avail = " + avail);
logger.debug("standby = {}", standby);
- System.out.println("standby = " + standby);
assertTrue("Admin state not unlocked after initialization", admin.equals(StateManagement.UNLOCKED));
assertTrue("Operational state not enabled after initialization", oper.equals(StateManagement.ENABLED));
@@ -151,7 +153,6 @@ public class StateManagementTest {
stateManagementFeature.disableFailed();
}catch(Exception e){
logger.error(e.getMessage());
- System.out.println(e.getMessage());
assertTrue(e.getMessage(), false);
}
@@ -163,15 +164,10 @@ public class StateManagementTest {
standby = stateManagementFeature.getStandbyStatus();
logger.debug("after disableFailed()");
- System.out.println("after disableFailed()");
logger.debug("admin = {}", admin);
- System.out.println("admin = " + admin);
logger.debug("oper = {}", oper);
- System.out.println("oper = " + oper);
logger.debug("avail = {}", avail);
- System.out.println("avail = " + avail);
logger.debug("standby = {}", standby);
- System.out.println("standby = " + standby);
assertTrue("Operational state not disabled after disableFailed()", oper.equals(StateManagement.DISABLED));
assertTrue("Availability status not failed after disableFailed()", avail.equals(StateManagement.FAILED));
@@ -181,7 +177,6 @@ public class StateManagementTest {
stateManagementFeature.promote();
}catch(Exception e){
logger.debug(e.getMessage());
- System.out.println(e.getMessage());
}
Thread.sleep(interruptRecoveryTime);
@@ -192,18 +187,53 @@ public class StateManagementTest {
standby = stateManagementFeature.getStandbyStatus();
logger.debug("after promote()");
- System.out.println("after promote()");
logger.debug("admin = {}", admin);
- System.out.println("admin = " + admin);
logger.debug("oper = {}", oper);
- System.out.println("oper = " + oper);
logger.debug("avail = {}", avail);
- System.out.println("avail = " + avail);
logger.debug("standby = {}", standby);
- System.out.println("standby = " + standby);
assertTrue("Standby status not coldstandby after promote()", standby.equals(StateManagement.COLD_STANDBY));
-
+
+ /**************Repository Audit Test**************/
+ logger.debug("\n\ntestStateManagementOperation: Repository Audit\n\n");
+ try{
+ RepositoryAudit repositoryAudit = (RepositoryAudit) RepositoryAudit.getInstance();
+ repositoryAudit.invoke(fsmProperties);
+
+ //Should not throw an IOException in Linux Foundation env
+ assertTrue(true);
+ }catch(IOException e){
+ //Note: this catch is here because in a local environment mvn will not run in
+ //in the temp directory
+ logger.debug("testSubsytemTest RepositoryAudit IOException", e);
+ }catch(InterruptedException e){
+ assertTrue(false);
+ logger.debug("testSubsytemTest RepositoryAudit InterruptedException", e);
+ }
+
+ /*****************Db Audit Test***************/
+ logger.debug("\n\ntestStateManagementOperation: DB Audit\n\n");
+
+ try{
+ DbAudit dbAudit = (DbAudit) DbAudit.getInstance();
+ dbAudit.invoke(fsmProperties);
+
+ assertTrue(true);
+ }catch(Exception e){
+ assertTrue(false);
+ logger.debug("testSubsytemTest DbAudit exception", e);
+ }
+
+ /*************IntegrityMonitorRestManager Test*************/
+ logger.debug("\n\ntestStateManagementOperation: IntegrityMonitorRestManager\n\n");
+ IntegrityMonitorRestManager integrityMonitorRestManager = new IntegrityMonitorRestManager();
+
+ Response response = integrityMonitorRestManager.test();
+ logger.debug("\n\nIntegrityMonitorRestManager response: " + response.toString());
+
+ assertTrue(response.toString().contains("status=500"));
+
+ //All done
logger.debug("\n\ntestStateManagementOperation: Exiting\n\n");
}