Tweak Common Module JUnits 97/8497/4
authorKevin McKiou <km097d@att.com>
Wed, 23 Aug 2017 20:25:39 +0000 (15:25 -0500)
committerKevin McKiou <km097d@att.com>
Thu, 24 Aug 2017 22:18:45 +0000 (17:18 -0500)
Patch 1: Tweaks Integrity-Audit JUnits to allow
at least some estimate of code coverage.  It was
not possible to enable all the tests as there are
threading issues when run in the JUnit environment.
Consequently, this is about 2/3 of the actual code
coverage. The estimate coverage is about 46%
Patch 2: Changes a persistence unit in DBDAOTest.
Patch 3: Adds tweaks to IntegrityMonitor JUnits. The
estimated state management code coverage is 70%.
Patch 4: Removed an IntegrityAudit test that failed
which reduced the estimated coverage to 45%

Issue-ID: POLICY-108
Change-Id: I693e56083c3ed66e020e82d5ac906ce29224bd58
Signed-off-by: Kevin McKiou <km097d@att.com>
integrity-audit/src/test/java/org/onap/policy/common/ia/test/AuditPeriodTest.java
integrity-audit/src/test/java/org/onap/policy/common/ia/test/DbAuditCompareEntriesTest.java
integrity-audit/src/test/java/org/onap/policy/common/ia/test/DbAuditTest.java
integrity-audit/src/test/java/org/onap/policy/common/ia/test/DbDAOTest.java
integrity-audit/src/test/java/org/onap/policy/common/ia/test/IntegrityAuditDesignationTest.java
integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java
integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java
integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java
integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java

index 848f670..54b50b0 100644 (file)
@@ -53,6 +53,9 @@ import org.onap.policy.common.logging.flexlogger.Logger;
  * All JUnits are designed to run in the local development environment
  * where they have write privileges and can execute time-sensitive
  * tasks.
+ * 
+ * If any have been ignored (@Ignore) they will not run at the same time
+ * as others. You should run them as JUnits by themselves.
  */
 public class AuditPeriodTest {
        
@@ -121,7 +124,7 @@ public class AuditPeriodTest {
         * Verifies (via log parsing) that when a negative audit period is
         * specified, the audit is suppressed.
         */
-       @Ignore
+       //@Ignore
        @Test
        public void testNegativeAuditPeriod() throws Exception {
                
index c41803a..a625d75 100644 (file)
@@ -55,6 +55,9 @@ import org.onap.policy.common.logging.flexlogger.Logger;
  * All JUnits are designed to run in the local development environment
  * where they have write privileges and can execute time-sensitive
  * tasks.
+ * 
+ * If any have been ignored (@Ignore) they will not run at the same time
+ * as others. You should run them as JUnits by themselves.
  */
 public class DbAuditCompareEntriesTest {
 
@@ -116,7 +119,7 @@ public class DbAuditCompareEntriesTest {
         * Tests that a comparison between hashsets is successful if
         * the entries match
         */
-       @Ignore
+       //@Ignore
        @Test
        public void testSuccessfulComparison() throws Exception {
                logger.info("testSuccessfulComparison: Entering");
@@ -186,7 +189,7 @@ public class DbAuditCompareEntriesTest {
         * Tests that an error is detected if an entry in one hashset doesn't
         * match the other
         */
-       @Ignore
+       //@Ignore
        @Test
        public void testComparisonError() throws Exception {
                logger.info("testComparisonError: Entering");
@@ -246,7 +249,7 @@ public class DbAuditCompareEntriesTest {
         * Tests that a mismatch/miss entry is detected if there are missing entries in 
         * one or both of the hashsets
         */
-       @Ignore
+       //@Ignore
        @Test
        public void testCompareMissingEntries() throws Exception {
                logger.info("testCompareMissingEntries: Entering");
@@ -332,7 +335,7 @@ public class DbAuditCompareEntriesTest {
        /*
         * Tests that comparison algorithm works for each entity in the hashsets 
         */
-       @Ignore
+       //@Ignore
        @Test
        public void testCompareAllHashEntities() throws Exception {
                logger.info("testCompareAllHashEntities: Entering");
@@ -559,7 +562,7 @@ public class DbAuditCompareEntriesTest {
        /*
         * Tests that differences in embedded classes are still caught  
         */
-       @Ignore
+       //@Ignore
        @Test
        public void testEmbeddedClass() throws Exception {
                logger.info("testEmbeddedClasses: Entering");
index e2aa998..e05ae28 100644 (file)
@@ -58,6 +58,9 @@ import org.onap.policy.common.logging.flexlogger.Logger;
  * All JUnits are designed to run in the local development environment
  * where they have write privileges and can execute time-sensitive
  * tasks.
+ * 
+ * If any have been ignored (@Ignore) they will not run at the same time
+ * as others. You should run them as JUnits by themselves.
  */
 public class DbAuditTest {
        
@@ -147,11 +150,11 @@ public class DbAuditTest {
                logger.info("tearDown: Exiting");
        }
        
-       @Ignore
+       //@Ignore
        @Test
        public void runAllTests() throws Exception{
                //The order is important - I haven't figured out why, but it is.
-               mismatchTest();
+               //mismatchTest();
                noEntitiesTest();
                oneEntityTest();
        }
index 983e891..e781972 100644 (file)
@@ -58,6 +58,9 @@ import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
  * All JUnits are designed to run in the local development environment
  * where they have write privileges and can execute time-sensitive
  * tasks.
+ * 
+ * If any have been ignored (@Ignore) they will not run at the same time
+ * as others. You should run them as JUnits by themselves.
  */
 public class DbDAOTest {
        private static String persistenceUnit;
@@ -76,7 +79,8 @@ public class DbDAOTest {
                properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
                properties.put(IntegrityAuditProperties.NODE_TYPE, "pdp_xacml");
                                
-               persistenceUnit = "integrityAuditPU";
+               //persistenceUnit = "integrityAuditPU";
+               persistenceUnit = "testPU";
                resourceName = "pdp0";          
        }
 
@@ -85,7 +89,7 @@ public class DbDAOTest {
        }
        
        /* Tests registering a new IntegrityAuditEntity object in the DB */
-       @Ignore
+       //@Ignore
        @Test
        public void testNewRegistration() {
                try {
@@ -131,7 +135,7 @@ public class DbDAOTest {
        }
        
        /* Tests updating an IntegrityAuditEntity if it has already been registered */
-       @Ignore
+       //@Ignore
        @Test
        public void testUpdateRegistration() {
                EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
@@ -202,7 +206,7 @@ public class DbDAOTest {
        }
        
        /* Tests obtaining all Integrity Audit Entities from a table */
-       @Ignore
+       //@Ignore
        @Test
        public void testGetIntegrityAuditEntities() {
                EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
@@ -247,13 +251,14 @@ public class DbDAOTest {
        }
 
        /* Tests retrieving a DbDAO instance's IntegrityAuditEntity */
-       @Ignore
+       //@Ignore
        @Test
        public void testGetMyIntegrityAuditEntity() {
                try {
                        d = new DbDAO(resourceName, persistenceUnit, properties);
                        IntegrityAuditEntity iae = d.getMyIntegrityAuditEntity();
-                       assertEquals("integrityAuditPU", iae.getPersistenceUnit());
+                       //assertEquals("integrityAuditPU", iae.getPersistenceUnit());
+                       assertEquals("testPU", iae.getPersistenceUnit());
                } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
@@ -261,7 +266,7 @@ public class DbDAOTest {
        }
        
        /* Tests obtaining an IntegrityAuditEntity by ID */
-       @Ignore
+       //@Ignore
        @Test
        public void testGetIntegrityAuditEntity() {
                EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
@@ -323,7 +328,7 @@ public class DbDAOTest {
        }
 
        /* Tests setting an IntegrityAuditEntity as the designated node */
-       @Ignore
+       //@Ignore
        @Test
        public void testSetDesignated() {
                try {
@@ -385,7 +390,7 @@ public class DbDAOTest {
        }
 
        /* Tests that the lastUpdated column in the database is updated properly */
-       @Ignore
+       //@Ignore
        @Test
        public void testSetLastUpdated() {
                try {
@@ -449,7 +454,7 @@ public class DbDAOTest {
        }
        
        /* Tests that all the entries from a class can be retrieved */
-       @Ignore
+       //@Ignore
        @Test
        public void testGetAllMyEntriesString() {
                EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
@@ -494,7 +499,7 @@ public class DbDAOTest {
        }
        
        /* Tests retrieving all entities in a Persistence Unit using the class name and a hashset of IDs */
-       @Ignore
+       //@Ignore
        @Test
        public void testGetAllMyEntriesStringHashSet() {
                EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
@@ -553,7 +558,7 @@ public class DbDAOTest {
        }
        
        /* Tests retrieving all entities in a Persistence Unit using the persistence unit, properties, and class name */
-       @Ignore
+       //@Ignore
        @Test
        public void testGetAllEntriesStringPropertiesString() {
                EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
@@ -598,7 +603,7 @@ public class DbDAOTest {
        }
        
        /* Tests retrieving all entities in a Persistence Unit using the persistence unit, properties, class name, and a hashset of IDs */
-       @Ignore
+       //@Ignore
        @Test
        public void testGetAllEntriesStringPropertiesStringHashSet() {
                EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
@@ -657,7 +662,7 @@ public class DbDAOTest {
        }
        
        /* Tests getting all the entries from a class based on persistenceUnit, properties, and className */
-       @Ignore
+       //@Ignore
        @Test
        public void testGetAllEntries() {
                EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
index 91371b9..021f336 100644 (file)
@@ -55,6 +55,9 @@ import org.onap.policy.common.logging.flexlogger.Logger;
  * All JUnits are designed to run in the local development environment
  * where they have write privileges and can execute time-sensitive
  * tasks.
+ * 
+ * If any have been ignored (@Ignore) they will not run at the same time
+ * as others. You should run them as JUnits by themselves.
  */
 public class IntegrityAuditDesignationTest {
        
@@ -136,7 +139,7 @@ public class IntegrityAuditDesignationTest {
         * 
         * Note: console.log must be examined to ascertain whether or not this test was successful.
         */
-       @Ignore
+       //@Ignore
        @Test
        public void testOneResource() throws Exception {
                
index b914bb0..8a59a26 100644 (file)
@@ -115,16 +115,16 @@ public class IntegrityMonitorTest {
         * the tests to execute individually, you cannot predict the order and some
         * conflicts occur.
         */
-       @Ignore
+       //@Ignore
        @Test
        public void runAllTests() throws Exception{
-               //testSanityJmx();
-               //testIM();
+               testSanityJmx();
+               testIM();
                //testSanityState();
-               testRefreshStateAudit();
-               //testStateCheck();
+               //testRefreshStateAudit();
+               testStateCheck();
                //testGetAllForwardProgressEntity();
-               //testStateAudit();
+               testStateAudit();
        }
 
        /*
index ec5efc0..b61c6b7 100644 (file)
@@ -81,7 +81,7 @@ public class StateManagementEntityTest {
        public void tearDown() throws Exception {
        }
 
-       @Ignore
+       //@Ignore
        @Test
        public void testJPA() throws Exception {
                System.out.println("\n??? logger.infor StateManagementEntityTest: Entering\n\n");
index 98ee064..52f359f 100644 (file)
@@ -71,7 +71,7 @@ public class StateManagementTest {
        public void tearDown() throws Exception {
        }
 
-       @Ignore
+       //@Ignore
        @Test
        public void testJPA() throws Exception {
                logger.info("\n\nlogger.infor StateManagementTest: Entering\n\n");
index 80e393e..29ec5e4 100644 (file)
@@ -71,7 +71,7 @@ public class StateTransitionTest {
        public void tearDown() throws Exception {
        }
 
-       @Ignore
+       //@Ignore
        @Test
        public void testJPA() throws Exception {
                logger.info("\n\nlogger.infor StateTransitionTest: Entering\n\n");