diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
index 932ebb2..9e481f0 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
@@ -29,13 +29,13 @@
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Persistence;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.onap.policy.drools.core.PolicySessionFeatureAPI;
 import org.onap.policy.drools.features.PolicyEngineFeatureAPI;
 import org.onap.policy.drools.statemanagement.StateManagementFeatureAPI;
 import org.onap.policy.drools.system.PolicyEngine;
 import org.onap.policy.drools.utils.PropertyUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * If this feature is supported, there is a single instance of it.
@@ -43,197 +43,193 @@
  * active/standby state management and IntegrityMonitor. For now, they are
  * all treated as a single feature, but it would be nice to separate them.
  *
- * The bulk of the code here was once in other classes, such as
+ * <p>The bulk of the code here was once in other classes, such as
  * 'PolicyContainer' and 'Main'. It was moved here as part of making this
  * a separate optional feature.
  */
 public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI, 
-				PolicySessionFeatureAPI, PolicyEngineFeatureAPI
-{
-	// get an instance of logger
-	private static final Logger logger =
-			LoggerFactory.getLogger(ActiveStandbyFeature.class);
-	
-	private static DroolsPdp myPdp;
-	private static Object myPdpSync = new Object();
-	private static DroolsPdpsElectionHandler electionHandler;
-	
-	private StateManagementFeatureAPI stateManagementFeature;
-	
-	public static final int SEQ_NUM = 1;
-	
+    PolicySessionFeatureAPI, PolicyEngineFeatureAPI {
+    // get an instance of logger
+    private static final Logger logger =
+            LoggerFactory.getLogger(ActiveStandbyFeature.class);
 
-	/**************************/
-	/* 'FeatureAPI' interface */
-	/**************************/
+    private static DroolsPdp myPdp;
+    private static Object myPdpSync = new Object();
+    private static DroolsPdpsElectionHandler electionHandler;
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public int getSequenceNumber()
-	{
-		return(SEQ_NUM);
-	}
+    private StateManagementFeatureAPI stateManagementFeature;
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void globalInit(String[] args, String configDir)
-	{
-		// This must come first since it initializes myPdp
-		initializePersistence(configDir);
-		
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			if (feature.getResourceName().equals(myPdp.getPdpId()))
-			{
-				if(logger.isDebugEnabled()){
-					logger.debug("ActiveStandbyFeature.globalInit: Found StateManagementFeature"
-						+ " with resourceName: {}", myPdp.getPdpId());
-				}
-				stateManagementFeature = feature;
-				break;
-			}
-		}
-		if(stateManagementFeature == null){
-			if(logger.isDebugEnabled()){
-				logger.debug("ActiveStandbyFeature failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", myPdp.getPdpId());
-			}
-			logger.error("ActiveStandbyFeature failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", myPdp.getPdpId());
-			//
-			// Cannot add observer since stateManagementFeature is null
-			//
-			return;
-		}
+    public static final int SEQ_NUM = 1;
+
+
+    /**************************/
+    /* 'FeatureAPI' interface */
+    /**************************/
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int getSequenceNumber() {
+        return SEQ_NUM;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void globalInit(String[] args, String configDir) {
+        // This must come first since it initializes myPdp
+        initializePersistence(configDir);
+
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            if (feature.getResourceName().equals(myPdp.getPdpId())) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("ActiveStandbyFeature.globalInit: Found StateManagementFeature"
+                            + " with resourceName: {}", myPdp.getPdpId());
+                }
+                stateManagementFeature = feature;
+                break;
+            }
+        }
+        if (stateManagementFeature == null) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("ActiveStandbyFeature failed to initialize.  "
+                        + "Unable to get instance of StateManagementFeatureAPI "
+                        + "with resourceID: {}", myPdp.getPdpId());
+            }
+            logger.error("ActiveStandbyFeature failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", myPdp.getPdpId());
+            //
+            // Cannot add observer since stateManagementFeature is null
+            //
+            return;
+        }
 
 
 
-		//Create an instance of the Observer
-		PMStandbyStateChangeNotifier pmNotifier = new PMStandbyStateChangeNotifier();
+        //Create an instance of the Observer
+        PMStandbyStateChangeNotifier pmNotifier = new PMStandbyStateChangeNotifier();
 
-		//Register the PMStandbyStateChangeNotifier Observer
-		stateManagementFeature.addObserver(pmNotifier);
-		if(logger.isDebugEnabled()){
-			logger.debug("ActiveStandbyFeature.globalInit() exit");
-		}
-	}
+        //Register the PMStandbyStateChangeNotifier Observer
+        stateManagementFeature.addObserver(pmNotifier);
+        if (logger.isDebugEnabled()) {
+            logger.debug("ActiveStandbyFeature.globalInit() exit");
+        }
+    }
 
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public boolean afterStart(PolicyEngine engine) 
-	{
-		// ASSERTION: engine == PolicyEngine.manager
-		PolicyEngine.manager.lock();
-		return false;
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean afterStart(PolicyEngine engine) {
+        // ASSERTION: engine == PolicyEngine.manager
+        PolicyEngine.manager.lock();
+        return false;
+    }
 
-	/**
-	 * Read in the persistence properties, determine whether persistence is
-	 * enabled or disabled, and initialize persistence if enabled.
-	 */
-	private static void initializePersistence(String configDir)
-	{
-		//Get the Active Standby properties
-		try {
-				Properties activeStandbyProperties = 
-						PropertyUtil.getProperties(configDir + "/feature-active-standby-management.properties");
-				ActiveStandbyProperties.initProperties(activeStandbyProperties);
-				logger.info("initializePersistence: ActiveStandbyProperties success");
-		} catch (IOException e) {
-			logger.error("ActiveStandbyFeature: initializePersistence ActiveStandbyProperties", e);
-		}
-		
-		DroolsPdpsConnector conn = getDroolsPdpsConnector("activeStandbyPU");
-		String resourceName = ActiveStandbyProperties.getProperty(ActiveStandbyProperties.NODE_NAME);
-		if(resourceName == null){
-			throw new NullPointerException();
-		}
+    /**
+     * Read in the persistence properties, determine whether persistence is
+     * enabled or disabled, and initialize persistence if enabled.
+     */
+    private static void initializePersistence(String configDir) {
+        //Get the Active Standby properties
+        try {
+            Properties activeStandbyProperties = 
+                    PropertyUtil.getProperties(configDir + "/feature-active-standby-management.properties");
+            ActiveStandbyProperties.initProperties(activeStandbyProperties);
+            logger.info("initializePersistence: ActiveStandbyProperties success");
+        } catch (IOException e) {
+            logger.error("ActiveStandbyFeature: initializePersistence ActiveStandbyProperties", e);
+        }
 
-		/*
-		 * In a JUnit test environment, one or more PDPs may already have been
-		 * inserted in the DB, so we need to check for this.
-		 */
-		DroolsPdp existingPdp = conn.getPdp(resourceName);
-		if (existingPdp != null) {
-			logger.info("Found existing PDP record, pdpId="
-					+ existingPdp.getPdpId() + ", isDesignated="
-					+ existingPdp.isDesignated() + ", updatedDate="
-					+ existingPdp.getUpdatedDate());
-			myPdp = existingPdp;
-		}
+        DroolsPdpsConnector conn = getDroolsPdpsConnector("activeStandbyPU");
+        String resourceName = ActiveStandbyProperties.getProperty(ActiveStandbyProperties.NODE_NAME);
+        if (resourceName == null) {
+            throw new NullPointerException();
+        }
 
-		synchronized(myPdpSync){
-			if(myPdp == null){
+        /*
+         * In a JUnit test environment, one or more PDPs may already have been
+         * inserted in the DB, so we need to check for this.
+         */
+        DroolsPdp existingPdp = conn.getPdp(resourceName);
+        if (existingPdp != null) {
+            logger.info("Found existing PDP record, pdpId="
+                    + existingPdp.getPdpId() + ", isDesignated="
+                    + existingPdp.isDesignated() + ", updatedDate="
+                    + existingPdp.getUpdatedDate());
+            myPdp = existingPdp;
+        }
 
-				myPdp = new DroolsPdpImpl(resourceName,false,4,new Date());	
-			}
-			String siteName = ActiveStandbyProperties.getProperty(ActiveStandbyProperties.SITE_NAME);
-			if (siteName == null) {
-				siteName = "";
-			}else{
-				siteName = siteName.trim();
-			}
-			myPdp.setSiteName(siteName);
-			if(electionHandler == null){
-				electionHandler = new DroolsPdpsElectionHandler(conn,myPdp);
-			}
-		}
-		logger.info("\n\nThis controller is a standby, waiting to be chosen as primary...\n\n");
-	}
+        synchronized (myPdpSync) {
+            if (myPdp == null) {
+
+                myPdp = new DroolsPdpImpl(resourceName,false,4,new Date());
+            }
+            String siteName = ActiveStandbyProperties.getProperty(ActiveStandbyProperties.SITE_NAME);
+            if (siteName == null) {
+                siteName = "";
+            } else {
+                siteName = siteName.trim();
+            }
+            myPdp.setSiteName(siteName);
+            if (electionHandler == null) {
+                electionHandler = new DroolsPdpsElectionHandler(conn,myPdp);
+            }
+        }
+        logger.info("\n\nThis controller is a standby, waiting to be chosen as primary...\n\n");
+    }
 
 
-	/*
-	 * Moved code to instantiate a JpaDroolsPdpsConnector object from main() to
-	 * this method, so it can also be accessed from StandbyStateChangeNotifier
-	 * class.
-	 */
-	public static DroolsPdpsConnector getDroolsPdpsConnector(String pu) {
+    /**
+     * Moved code to instantiate a JpaDroolsPdpsConnector object from main() to
+     * this method, so it can also be accessed from StandbyStateChangeNotifier
+     * class.
+     * 
+     * @param pu string
+     * @return connector object
+     */
+    public static DroolsPdpsConnector getDroolsPdpsConnector(String pu) {
 
-		Map<String, Object> propMap = new HashMap<>();
-		propMap.put("javax.persistence.jdbc.driver", ActiveStandbyProperties
-				.getProperty(ActiveStandbyProperties.DB_DRIVER));
-		propMap.put("javax.persistence.jdbc.url",
-				ActiveStandbyProperties.getProperty(ActiveStandbyProperties.DB_URL));
-		propMap.put("javax.persistence.jdbc.user", ActiveStandbyProperties
-				.getProperty(ActiveStandbyProperties.DB_USER));
-		propMap.put("javax.persistence.jdbc.password",
-				ActiveStandbyProperties.getProperty(ActiveStandbyProperties.DB_PWD));
+        Map<String, Object> propMap = new HashMap<>();
+        propMap.put("javax.persistence.jdbc.driver", ActiveStandbyProperties
+                .getProperty(ActiveStandbyProperties.DB_DRIVER));
+        propMap.put("javax.persistence.jdbc.url",
+                ActiveStandbyProperties.getProperty(ActiveStandbyProperties.DB_URL));
+        propMap.put("javax.persistence.jdbc.user", ActiveStandbyProperties
+                .getProperty(ActiveStandbyProperties.DB_USER));
+        propMap.put("javax.persistence.jdbc.password",
+                ActiveStandbyProperties.getProperty(ActiveStandbyProperties.DB_PWD));
 
-		EntityManagerFactory emf = Persistence.createEntityManagerFactory(
-				pu, propMap);
-		return new JpaDroolsPdpsConnector(emf);
-	}
+        EntityManagerFactory emf = Persistence.createEntityManagerFactory(
+                pu, propMap);
+        return new JpaDroolsPdpsConnector(emf);
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getPdpdNowActive(){
-		return electionHandler.getPdpdNowActive();
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getPdpdNowActive() {
+        return electionHandler.getPdpdNowActive();
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getPdpdLastActive(){
-		return electionHandler.getPdpdLastActive();
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getPdpdLastActive() {
+        return electionHandler.getPdpdLastActive();
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getResourceName() {
-		return myPdp.getPdpId();
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getResourceName() {
+        return myPdp.getPdpId();
+    }
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
index a70c71f..009ff8c 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-active-standby-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -25,51 +25,53 @@
 import org.slf4j.LoggerFactory;
 
 public class ActiveStandbyProperties {
-	// get an instance of logger 
-	private static final Logger  logger = LoggerFactory.getLogger(ActiveStandbyProperties.class);
-		
-	public static final String PDP_CHECK_INVERVAL = "pdp.checkInterval";
-	public static final String PDP_UPDATE_INTERVAL = "pdp.updateInterval";
-	public static final String PDP_TIMEOUT = "pdp.timeout";
-	public static final String PDP_INITIAL_WAIT_PERIOD = "pdp.initialWait";
+    // get an instance of logger 
+    private static final Logger  logger = LoggerFactory.getLogger(ActiveStandbyProperties.class);
 
-	public static final String NODE_NAME = "resource.name";
-	public static final String SITE_NAME = "site_name";
-	
-	/*
-	 * feature-active-standby-management.properties parameter key values
-	 */
-	public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
-	public static final String DB_URL = "javax.persistence.jdbc.url";
-	public static final String DB_USER = "javax.persistence.jdbc.user";
-	public static final String DB_PWD = "javax.persistence.jdbc.password";
-		
-	private static Properties properties = null;
-	
-	private ActiveStandbyProperties() {
-		throw new IllegalStateException("Utility class");
-	}
-	/*
-	 * Initialize the parameter values from the droolsPersitence.properties file values
-	 * 
-	 * This is designed so that the Properties object is obtained from properties
-	 * file and then is passed to this method to initialize the value of the parameters.
-	 * This allows the flexibility of JUnit tests using getProperties(filename) to get the
-	 * properties while runtime methods can use getPropertiesFromClassPath(filename).
-	 * 
-	 */
-	public static void initProperties (Properties prop){
-		logger.info("ActiveStandbyProperties.initProperties(Properties): entry");
-		logger.info("\n\nActiveStandbyProperties.initProperties: Properties = \n{}\n\n", prop);
-		
-		properties = prop;
-	}
+    public static final String PDP_CHECK_INVERVAL = "pdp.checkInterval";
+    public static final String PDP_UPDATE_INTERVAL = "pdp.updateInterval";
+    public static final String PDP_TIMEOUT = "pdp.timeout";
+    public static final String PDP_INITIAL_WAIT_PERIOD = "pdp.initialWait";
 
-	public static String getProperty(String key){
-		return properties.getProperty(key);
-	}
-	
-	public static Properties getProperties() {
-		return properties;
-	}
+    public static final String NODE_NAME = "resource.name";
+    public static final String SITE_NAME = "site_name";
+
+    /*
+     * feature-active-standby-management.properties parameter key values
+     */
+    public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
+    public static final String DB_URL = "javax.persistence.jdbc.url";
+    public static final String DB_USER = "javax.persistence.jdbc.user";
+    public static final String DB_PWD = "javax.persistence.jdbc.password";
+
+    private static Properties properties = null;
+
+    private ActiveStandbyProperties() {
+        throw new IllegalStateException("Utility class");
+    }
+    
+    /**
+     * Initialize the parameter values from the droolsPersitence.properties file values.
+     * 
+     * <p>This is designed so that the Properties object is obtained from properties
+     * file and then is passed to this method to initialize the value of the parameters.
+     * This allows the flexibility of JUnit tests using getProperties(filename) to get the
+     * properties while runtime methods can use getPropertiesFromClassPath(filename).
+     * 
+     * @param prop properties
+     */
+    public static void initProperties(Properties prop) {
+        logger.info("ActiveStandbyProperties.initProperties(Properties): entry");
+        logger.info("\n\nActiveStandbyProperties.initProperties: Properties = \n{}\n\n", prop);
+
+        properties = prop;
+    }
+
+    public static String getProperty(String key) {
+        return properties.getProperty(key);
+    }
+
+    public static Properties getProperties() {
+        return properties;
+    }
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java
index a440a7e..46096bd 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-active-standby-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -24,16 +24,27 @@
 
 public interface DroolsPdp {
 
-	public String getPdpId();
-	public boolean isDesignated();
-	public int getPriority();
-	public Date getUpdatedDate();
-	public void setDesignated(boolean isDesignated);
-	public void setUpdatedDate(Date updatedDate);
-	public int comparePriority(DroolsPdp other);
-	public int comparePriority(DroolsPdp other,String previousSite);
-	public String getSiteName();
-	public void setSiteName(String siteName);
-	public Date getDesignatedDate();
-	public void setDesignatedDate(Date designatedDate);
+    public String getPdpId();
+    
+    public boolean isDesignated();
+    
+    public int getPriority();
+    
+    public Date getUpdatedDate();
+    
+    public void setDesignated(boolean isDesignated);
+    
+    public void setUpdatedDate(Date updatedDate);
+    
+    public int comparePriority(DroolsPdp other);
+    
+    public int comparePriority(DroolsPdp other,String previousSite);
+    
+    public String getSiteName();
+    
+    public void setSiteName(String siteName);
+    
+    public Date getDesignatedDate();
+    
+    public void setDesignatedDate(Date designatedDate);
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
index ed10f4c..f0fd278 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-active-standby-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -37,121 +37,123 @@
 //@Table(name="DroolsPdpEntity")
 
 @NamedQueries({
-	@NamedQuery(name="DroolsPdpEntity.findAll", query="SELECT e FROM DroolsPdpEntity e "),
-	@NamedQuery(name="DroolsPdpEntity.deleteAll", query="DELETE FROM DroolsPdpEntity WHERE 1=1")
+    @NamedQuery(name = "DroolsPdpEntity.findAll", query = "SELECT e FROM DroolsPdpEntity e "),
+    @NamedQuery(name = "DroolsPdpEntity.deleteAll", query = "DELETE FROM DroolsPdpEntity WHERE 1=1")
 })
-public class DroolsPdpEntity extends DroolsPdpObject implements Serializable{
+public class DroolsPdpEntity extends DroolsPdpObject implements Serializable {
 
-	private static final long serialVersionUID = 1L;
-	
-	@Id
-	@Column(name="pdpId", nullable=false)
-	private String pdpId="-1";
-	
-	@Column(name="designated", nullable=false)
-	private boolean designated=false;
-	
-	@Column(name="priority", nullable=false)
-	private int priority=0;
-	
-	@Temporal(TemporalType.TIMESTAMP)
-	@Column(name="updatedDate", nullable=false)
-	private Date updatedDate;
-	
-	@Temporal(TemporalType.TIMESTAMP)
-	@Column(name="designatedDate",nullable=false)
-	private Date designatedDate;
-	
-	@Column(name="site", nullable=true, length = 50)
-	private String site;
-	
-	
-	public DroolsPdpEntity(){
-		updatedDate = new Date();
-		//When this is translated to a TimeStamp in MySQL, it assumes the date is relative
-		//to the local timezone.  So, a value of Date(0) is actually Dec 31 18:00:00 CST 1969
-		//which is an invalid value for the MySql TimeStamp 
-		designatedDate = new Date(864000000);
-	}
+    private static final long serialVersionUID = 1L;
 
-	@Override
-	public String getPdpId() {
-		return this.pdpId;
-	}
-	
-	public void setPdpId(String pdpId) {
-		this.pdpId = pdpId;
-	}
-	
-	@Override
-	public boolean isDesignated() {
-		return this.designated;
-	}
+    @Id
+    @Column(name = "pdpId", nullable = false)
+    private String pdpId = "-1";
 
-	@Override
-	public int getPriority() {
-		return this.priority;
-	}
+    @Column(name = "designated", nullable = false)
+    private boolean designated = false;
 
-	public void setPriority(int priority) {
-		this.priority = priority;
-	}
+    @Column(name = "priority", nullable = false)
+    private int priority = 0;
 
-	@Override
-	public Date getUpdatedDate() {
-		return this.updatedDate;
-	}
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "updatedDate", nullable = false)
+    private Date updatedDate;
 
-	@Override
-	public void setDesignated(boolean isDesignated) {		
-		this.designated=isDesignated;		
-	}
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "designatedDate",nullable = false)
+    private Date designatedDate;
 
-	@Override
-	public void setUpdatedDate(Date updatedDate) {
-		this.updatedDate=updatedDate;
-	}
+    @Column(name = "site", nullable = true, length = 50)
+    private String site;
 
-	
-	@Override
-	public String getSiteName() {
-		return site;
-	}
+    /**
+     * Constructor.
+     */
+    public DroolsPdpEntity() {
+        updatedDate = new Date();
+        //When this is translated to a TimeStamp in MySQL, it assumes the date is relative
+        //to the local timezone.  So, a value of Date(0) is actually Dec 31 18:00:00 CST 1969
+        //which is an invalid value for the MySql TimeStamp 
+        designatedDate = new Date(864000000);
+    }
 
-	@Override
-	public void setSiteName(String siteName) {
-		site = siteName;
-		
-	}
+    @Override
+    public String getPdpId() {
+        return this.pdpId;
+    }
 
-	@Override
-	public Date getDesignatedDate() {
-		return designatedDate;
-	}
+    public void setPdpId(String pdpId) {
+        this.pdpId = pdpId;
+    }
 
-	@Override
-	public void setDesignatedDate(Date designatedDate) {
-		this.designatedDate = designatedDate;		
-	}
-	
-	@Override
-	public boolean equals(Object obj){
+    @Override
+    public boolean isDesignated() {
+        return this.designated;
+    }
 
-		if (obj instanceof DroolsPdp) {
-			DroolsPdpEntity d = (DroolsPdpEntity) obj;
-			return this.pdpId.equals(d.getPdpId());
-		} else {
-			return false;
-		}
+    @Override
+    public int getPriority() {
+        return this.priority;
+    }
 
-	}
-	
-	@Override
-	public int hashCode() {
+    public void setPriority(int priority) {
+        this.priority = priority;
+    }
+
+    @Override
+    public Date getUpdatedDate() {
+        return this.updatedDate;
+    }
+
+    @Override
+    public void setDesignated(boolean isDesignated) {
+        this.designated = isDesignated;
+    }
+
+    @Override
+    public void setUpdatedDate(Date updatedDate) {
+        this.updatedDate = updatedDate;
+    }
+
+
+    @Override
+    public String getSiteName() {
+        return site;
+    }
+
+    @Override
+    public void setSiteName(String siteName) {
+        site = siteName;
+
+    }
+
+    @Override
+    public Date getDesignatedDate() {
+        return designatedDate;
+    }
+
+    @Override
+    public void setDesignatedDate(Date designatedDate) {
+        this.designatedDate = designatedDate;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+
+        if (obj instanceof DroolsPdp) {
+            DroolsPdpEntity entity = (DroolsPdpEntity) obj;
+            return this.pdpId.equals(entity.getPdpId());
+        } else {
+            return false;
+        }
+
+    }
+
+    @Override
+    public int hashCode() {
         final int prime = 31;
         int result = 1;
         result = prime * result + (this.pdpId == null ? 0 : this.pdpId.hashCode());
-		return result;
-	}
+        return result;
+    }
 
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
index f54a18c..31728bc 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-active-standby-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -24,89 +24,104 @@
 
 public class DroolsPdpImpl extends DroolsPdpObject {
 
-	private boolean designated;
-	private int priority;
-	private Date updatedDate;
-	private Date designatedDate;
-	private String pdpId;
-	private String site;
-	
-	public DroolsPdpImpl(String pdpId, boolean designated, int priority, Date updatedDate){
-		this.pdpId = pdpId;
-		this.designated = designated;
-		this.priority = priority;
-		this.updatedDate = updatedDate;
-		//When this is translated to a TimeStamp in MySQL, it assumes the date is relative
-		//to the local timezone.  So, a value of Date(0) is actually Dec 31 18:00:00 CST 1969
-		//which is an invalid value for the MySql TimeStamp 
-		this.designatedDate = new Date(864000000);
+    private boolean designated;
+    private int priority;
+    private Date updatedDate;
+    private Date designatedDate;
+    private String pdpId;
+    private String site;
 
-	}
-	@Override
-	public boolean isDesignated() {
-		
-		return designated;
-	}
+    /**
+     * Contructor.
+     * 
+     * @param pdpId ID for the PDP
+     * @param designated is designated
+     * @param priority priority
+     * @param updatedDate date updated
+     */
+    public DroolsPdpImpl(String pdpId, boolean designated, int priority, Date updatedDate) {
+        this.pdpId = pdpId;
+        this.designated = designated;
+        this.priority = priority;
+        this.updatedDate = updatedDate;
+        //When this is translated to a TimeStamp in MySQL, it assumes the date is relative
+        //to the local timezone.  So, a value of Date(0) is actually Dec 31 18:00:00 CST 1969
+        //which is an invalid value for the MySql TimeStamp 
+        this.designatedDate = new Date(864000000);
 
-	@Override
-	public int getPriority() {		
-		return priority;
-	}
-	@Override
-	public void setUpdatedDate(Date date){
-		this.updatedDate = date;
-	}
-	@Override
-	public Date getUpdatedDate() {		
-		return updatedDate;
-	}
-	
-	@Override
-	public String getPdpId() {		
-		return pdpId;
-	}
-	@Override
-	public void setDesignated(boolean isDesignated) {		
-		this.designated = isDesignated;
-		
-	}
+    }
+    
+    @Override
+    public boolean isDesignated() {
 
-	@Override
-	public String getSiteName() {
-		return site;
-	}
-	@Override
-	public void setSiteName(String siteName) {
-		this.site = siteName;
-		
-	}
-	@Override
-	public Date getDesignatedDate() {
-		return designatedDate;
-	}
-	@Override
-	public void setDesignatedDate(Date designatedDate) {
-		this.designatedDate = designatedDate;
-		
-	}
-	
-	@Override
-	public boolean equals(Object obj){
-		
+        return designated;
+    }
 
-		if (obj instanceof DroolsPdp) {
-			DroolsPdpImpl p = (DroolsPdpImpl) obj;
-			return this.pdpId.equals(p.getPdpId());
-		} else {
-			return false;
-		}
-	}
-	
-	@Override
-	public int hashCode() {
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+    
+    @Override
+    public void setUpdatedDate(Date date) {
+        this.updatedDate = date;
+    }
+    
+    @Override
+    public Date getUpdatedDate() {
+        return updatedDate;
+    }
+
+    @Override
+    public String getPdpId() {
+        return pdpId;
+    }
+    
+    @Override
+    public void setDesignated(boolean isDesignated) {
+        this.designated = isDesignated;
+
+    }
+
+    @Override
+    public String getSiteName() {
+        return site;
+    }
+    
+    @Override
+    public void setSiteName(String siteName) {
+        this.site = siteName;
+
+    }
+    
+    @Override
+    public Date getDesignatedDate() {
+        return designatedDate;
+    }
+    
+    @Override
+    public void setDesignatedDate(Date designatedDate) {
+        this.designatedDate = designatedDate;
+
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+
+
+        if (obj instanceof DroolsPdp) {
+            DroolsPdpImpl temp = (DroolsPdpImpl) obj;
+            return this.pdpId.equals(temp.getPdpId());
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public int hashCode() {
         final int prime = 31;
         int result = 1;
         result = prime * result + (this.pdpId == null ? 0 : this.pdpId.hashCode());
-		return result;
-	}
+        return result;
+    }
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
index 690b260..49f6b02 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpObject.java
@@ -21,60 +21,64 @@
 package org.onap.policy.drools.activestandby;
 
 
-public abstract class DroolsPdpObject implements DroolsPdp{
-	
-	@Override
-	public boolean equals(Object other){
-		if(other instanceof DroolsPdp){
-		return this.getPdpId().equals(((DroolsPdp)other).getPdpId());
-		}else{
-			return false;
-		}
-	}
-	@Override
-	public int hashCode() {
+public abstract class DroolsPdpObject implements DroolsPdp {
+
+    @Override
+    public boolean equals(Object other) {
+        if (other instanceof DroolsPdp) {
+            return this.getPdpId().equals(((DroolsPdp)other).getPdpId());
+        } else {
+            return false;
+        }
+    }
+    
+    @Override
+    public int hashCode() {
         final int prime = 31;
         int result = 1;
         result = prime * result + (this.getPdpId() == null ? 0 : this.getPdpId().hashCode());
         result = prime * result + (this.getSiteName() == null ? 0 : this.getSiteName().hashCode());
         result = prime * result + this.getPriority();
-		return super.hashCode();
-	}
-	private int nullSafeCompare(String one, String two){
-		if(one != null && two != null){
-			return one.compareTo(two);
-		}
-		if(one == null && two != null){
-			return -1;
-		}
-		if(one != null && two == null){
-			return 1;
-		}
-		return 0;
-	}
-	@Override
-	public int comparePriority(DroolsPdp other){
-		if(nullSafeCompare(this.getSiteName(),other.getSiteName()) == 0){
-		if(this.getPriority() != other.getPriority()){
-			return this.getPriority() - other.getPriority();
-		}
-		return this.getPdpId().compareTo(other.getPdpId());
-		} else {
-			return nullSafeCompare(this.getSiteName(),other.getSiteName());
-		}
-	}
-	@Override
-	public int comparePriority(DroolsPdp other, String previousSite){
-		if(previousSite == null || previousSite.isEmpty()){
-			return comparePriority(other);
-		}
-		if(nullSafeCompare(this.getSiteName(),other.getSiteName()) == 0){
-			if(this.getPriority() != other.getPriority()){
-				return this.getPriority() - other.getPriority();
-			}
-			return this.getPdpId().compareTo(other.getPdpId());
-		} else {
-			return nullSafeCompare(this.getSiteName(),other.getSiteName());
-		}
-	}
+        return super.hashCode();
+    }
+    
+    private int nullSafeCompare(String one, String two) {
+        if (one != null && two != null) {
+            return one.compareTo(two);
+        }
+        if (one == null && two != null) {
+            return -1;
+        }
+        if (one != null && two == null) {
+            return 1;
+        }
+        return 0;
+    }
+    
+    @Override
+    public int comparePriority(DroolsPdp other) {
+        if (nullSafeCompare(this.getSiteName(),other.getSiteName()) == 0) {
+            if (this.getPriority() != other.getPriority()) {
+                return this.getPriority() - other.getPriority();
+            }
+            return this.getPdpId().compareTo(other.getPdpId());
+        } else {
+            return nullSafeCompare(this.getSiteName(),other.getSiteName());
+        }
+    }
+    
+    @Override
+    public int comparePriority(DroolsPdp other, String previousSite) {
+        if (previousSite == null || previousSite.isEmpty()) {
+            return comparePriority(other);
+        }
+        if (nullSafeCompare(this.getSiteName(),other.getSiteName()) == 0) {
+            if (this.getPriority() != other.getPriority()) {
+                return this.getPriority() - other.getPriority();
+            }
+            return this.getPdpId().compareTo(other.getPdpId());
+        } else {
+            return nullSafeCompare(this.getSiteName(),other.getSiteName());
+        }
+    }
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java
index d0d33f0..fdb8737 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-active-standby-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -24,40 +24,41 @@
 
 public interface DroolsPdpsConnector {
 
-	
-	//return a list of PDPs, NOT including this PDP
-	public Collection<DroolsPdp> getDroolsPdps();
-	
-	public void update(DroolsPdp pdp);
-	
-	//determines if the DroolsPdp parameter is considered "current" or expired (has it been too long since the Pdp sent an update)
-	public boolean isPdpCurrent(DroolsPdp pdp);
-	
-	// Updates DESIGNATED boolean in PDP record.
-	public void setDesignated(DroolsPdp pdp, boolean designated);
-	
-	// Marks droolspdpentity.DESIGNATED=false, so another PDP-D will go active.
-	public void standDownPdp(String pdpId);
-			
-	// This is used in a JUnit test environment to manually
-	// insert a PDP
-	public void insertPdp(DroolsPdp pdp);
-	
-	// This is used in a JUnit test environment to manually
-	// delete a PDP
-	public void deletePdp(String pdpId);
-		
-	// This is used in a JUnit test environment to manually
-	// clear the droolspdpentity table.
-	public void deleteAllPdps();
-	
-	// This is used in a JUnit test environment to manually
-	// get a PDP
-	public DroolsPdpEntity getPdp(String pdpId);
-	
-	// Used by DroolsPdpsElectionHandler to determine if the currently designated
-	// PDP has failed.
-	public boolean hasDesignatedPdpFailed(Collection<DroolsPdp> pdps);
 
-	
+    //return a list of PDPs, NOT including this PDP
+    public Collection<DroolsPdp> getDroolsPdps();
+
+    public void update(DroolsPdp pdp);
+
+    //determines if the DroolsPdp parameter is considered "current" or expired 
+    //(has it been too long since the Pdp sent an update)
+    public boolean isPdpCurrent(DroolsPdp pdp);
+
+    // Updates DESIGNATED boolean in PDP record.
+    public void setDesignated(DroolsPdp pdp, boolean designated);
+
+    // Marks droolspdpentity.DESIGNATED=false, so another PDP-D will go active.
+    public void standDownPdp(String pdpId);
+
+    // This is used in a JUnit test environment to manually
+    // insert a PDP
+    public void insertPdp(DroolsPdp pdp);
+
+    // This is used in a JUnit test environment to manually
+    // delete a PDP
+    public void deletePdp(String pdpId);
+
+    // This is used in a JUnit test environment to manually
+    // clear the droolspdpentity table.
+    public void deleteAllPdps();
+
+    // This is used in a JUnit test environment to manually
+    // get a PDP
+    public DroolsPdpEntity getPdp(String pdpId);
+
+    // Used by DroolsPdpsElectionHandler to determine if the currently designated
+    // PDP has failed.
+    public boolean hasDesignatedPdpFailed(Collection<DroolsPdp> pdps);
+
+
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
index 9b172e1..08592f2 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
@@ -28,991 +28,996 @@
 import java.util.TimerTask;
 
 import org.onap.policy.common.im.StateManagement;
+import org.onap.policy.drools.statemanagement.StateManagementFeatureAPI;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.onap.policy.drools.statemanagement.StateManagementFeatureAPI;
 
 public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
-	// get an instance of logger 
-	private static final Logger  logger = LoggerFactory.getLogger(DroolsPdpsElectionHandler.class);	
-	private DroolsPdpsConnector pdpsConnector;
-	private Object checkWaitTimerLock = new Object();
-	private Object designationWaiterLock = new Object();
-	
-	/*
-	 * Must be static, so it can be referenced by JpaDroolsPdpsConnector,
-	 * without requiring a reference to the election handler instantiation.
-	 */
-	private static DroolsPdp myPdp;
-	
-	private DesignationWaiter designationWaiter;
-	private Timer updateWorker;
-	private Timer waitTimer;
-	private Date waitTimerLastRunDate;
-	
-	// The interval between checks of the DesignationWaiter to be sure it is running.
-	private int pdpCheckInterval;
-	
-	// The interval between runs of the DesignationWaiter
-	private int pdpUpdateInterval;
-	
-	private volatile boolean isDesignated;
+    // get an instance of logger 
+    private static final Logger  logger = LoggerFactory.getLogger(DroolsPdpsElectionHandler.class);
+    private DroolsPdpsConnector pdpsConnector;
+    private Object checkWaitTimerLock = new Object();
+    private Object designationWaiterLock = new Object();
 
-	private String pdpdNowActive;
-	private String pdpdLastActive;
-	
-	/*
-	 * Start allSeemsWell with a value of null so that, on the first run
-	 * of the checkWaitTimer it will set the value in IntegrityMonitor
-	 * regardless of whether it needs to be set to true or false.
-	 */
-	private Boolean allSeemsWell=null;
-	
-	private StateManagementFeatureAPI stateManagementFeature;
-	
-	private static boolean isUnitTesting = false;
-	private static boolean isStalled = false;
-	
-	public DroolsPdpsElectionHandler(DroolsPdpsConnector pdps, DroolsPdp myPdp){
-		if (pdps == null) {
-			logger.error("DroolsPdpsElectinHandler(): pdpsConnector==null");
-			throw new IllegalArgumentException("DroolsPdpsElectinHandler(): pdpsConnector==null");
-		}
-		if (myPdp == null){
-			logger.error("DroolsPdpsElectinHandler(): droolsPdp==null");
-			throw new IllegalArgumentException("DroolsPdpsElectinHandler(): DroolsPdp==null");
-		}
+    /*
+     * Must be static, so it can be referenced by JpaDroolsPdpsConnector,
+     * without requiring a reference to the election handler instantiation.
+     */
+    private static DroolsPdp myPdp;
 
-		pdpdNowActive = null;
-		pdpdLastActive = null;
-		this.pdpsConnector = pdps;
-		DroolsPdpsElectionHandler.myPdp = myPdp;
-		this.isDesignated = false;
-		pdpCheckInterval = 3000;
-		try{
-			pdpCheckInterval = Integer.parseInt(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_CHECK_INVERVAL));
-		}catch(Exception e){
-			logger.error
-			("Could not get pdpCheckInterval property. Using default {}",pdpCheckInterval, e);
-		}
-		pdpUpdateInterval = 2000;
-		try{
-			pdpUpdateInterval = Integer.parseInt(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_UPDATE_INTERVAL));
-		}catch(Exception e){
-			logger.error
-			("Could not get pdpUpdateInterval property. Using default {} ", pdpUpdateInterval, e);
-		}	
+    private DesignationWaiter designationWaiter;
+    private Timer updateWorker;
+    private Timer waitTimer;
+    private Date waitTimerLastRunDate;
 
-		Date now = new Date();
+    // The interval between checks of the DesignationWaiter to be sure it is running.
+    private int pdpCheckInterval;
 
-		// Retrieve the ms since the epoch
-		long nowMs = now.getTime();
+    // The interval between runs of the DesignationWaiter
+    private int pdpUpdateInterval;
 
-		// Create the timer which will update the updateDate in DroolsPdpEntity table.
-		// This is the heartbeat 
-		updateWorker = new Timer();
+    private volatile boolean isDesignated;
 
-		// Schedule the TimerUpdateClass to run at 100 ms and run at pdpCheckInterval ms thereafter
-		// NOTE: The first run of the TimerUpdateClass results in myPdp being added to the 
-		// drools droolsPdpEntity table.
-		updateWorker.scheduleAtFixedRate(new TimerUpdateClass(), 100, pdpCheckInterval);
+    private String pdpdNowActive;
+    private String pdpdLastActive;
 
-		// Create the timer which will run the election algorithm
-		waitTimer = new Timer();
+    /*
+     * Start allSeemsWell with a value of null so that, on the first run
+     * of the checkWaitTimer it will set the value in IntegrityMonitor
+     * regardless of whether it needs to be set to true or false.
+     */
+    private Boolean allSeemsWell = null;
 
-		// Schedule it to start in startMs ms (so it will run after the updateWorker and run at pdpUpdateInterval ms thereafter
-		long startMs = getDWaiterStartMs();
-		designationWaiter = new DesignationWaiter();
-		waitTimer.scheduleAtFixedRate(designationWaiter, startMs, pdpUpdateInterval);
-		waitTimerLastRunDate = new Date(nowMs + startMs);
+    private StateManagementFeatureAPI stateManagementFeature;
 
-		//Get the StateManagementFeature instance
-		
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			if (feature.getResourceName().equals(myPdp.getPdpId()))
-			{
-				if(logger.isDebugEnabled()){
-					logger.debug("DroolsPdpsElectionHandler: Found StateManagementFeature"
-						+ " with resourceName: {}", myPdp.getPdpId());
-				}
-				stateManagementFeature = feature;
-				break;
-			}
-		}
-		if(stateManagementFeature == null){
-			logger.error("DroolsPdpsElectionHandler failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", myPdp.getPdpId());
-		}
-	}
-	
-	public static void setIsUnitTesting(boolean val){
-		isUnitTesting = val;
-	}
-	public static void setIsStalled(boolean val){
-		isStalled = val;
-	}
-	
-	/*
-	 * When the JpaDroolsPdpsConnector.standDown() method is invoked, it needs
-	 * access to myPdp, so it can keep its designation status in sync with the
-	 * DB.
-	 */
-	public static void setMyPdpDesignated(boolean designated) {
-		if(logger.isDebugEnabled()){
-			logger.debug
-			("setMyPdpDesignated: designated= {}", designated);
-		}
-		myPdp.setDesignated(designated);
-	}
-	
-	private class DesignationWaiter extends TimerTask {
-		// get an instance of logger 
-		private final Logger  logger = LoggerFactory.getLogger(DesignationWaiter.class);
+    private static boolean isUnitTesting = false;
+    private static boolean isStalled = false;
 
-		@Override
-		public void run() {
-			try{
-				if(logger.isDebugEnabled()){
-					logger.debug
-					("DesignatedWaiter.run: Entering");
-				}
-				
-				//This is for testing the checkWaitTimer
-				if(isUnitTesting && isStalled){
-					if(logger.isDebugEnabled()){
-						logger.debug("DesignatedWaiter.run: isUnitTesting = {} isStalled = {}", isUnitTesting, isStalled);
-					}
-					return;
-				}
+    /**
+     * Constructor.
+     * 
+     * @param pdps connectors
+     * @param myPdp pdp
+     */
+    public DroolsPdpsElectionHandler(DroolsPdpsConnector pdps, DroolsPdp myPdp) {
+        if (pdps == null) {
+            logger.error("DroolsPdpsElectinHandler(): pdpsConnector==null");
+            throw new IllegalArgumentException("DroolsPdpsElectinHandler(): pdpsConnector==null");
+        }
+        if (myPdp == null) {
+            logger.error("DroolsPdpsElectinHandler(): droolsPdp==null");
+            throw new IllegalArgumentException("DroolsPdpsElectinHandler(): DroolsPdp==null");
+        }
 
-				synchronized (designationWaiterLock) {
+        pdpdNowActive = null;
+        pdpdLastActive = null;
+        this.pdpsConnector = pdps;
+        DroolsPdpsElectionHandler.myPdp = myPdp;
+        this.isDesignated = false;
+        pdpCheckInterval = 3000;
+        try {
+            pdpCheckInterval = Integer.parseInt(ActiveStandbyProperties.getProperty(
+                    ActiveStandbyProperties.PDP_CHECK_INVERVAL));
+        } catch (Exception e) {
+            logger.error("Could not get pdpCheckInterval property. Using default {}",pdpCheckInterval, e);
+        }
+        pdpUpdateInterval = 2000;
+        try {
+            pdpUpdateInterval = Integer.parseInt(ActiveStandbyProperties.getProperty(
+                    ActiveStandbyProperties.PDP_UPDATE_INTERVAL));
+        } catch (Exception e) {
+            logger.error("Could not get pdpUpdateInterval property. Using default {} ", pdpUpdateInterval, e);
+        }
 
-					if(logger.isDebugEnabled()){
-						logger.debug
-						("DesignatedWaiter.run: Entering synchronized block");
-					}
+        Date now = new Date();
 
-					//It is possible that multiple PDPs are designated lead.  So, we will make a list of all designated
-					//PDPs and then decide which one really should be designated at the end.
-					List<DroolsPdp> listOfDesignated = new ArrayList<>();
+        // Retrieve the ms since the epoch
+        final long nowMs = now.getTime();
 
-					Collection<DroolsPdp> pdps = pdpsConnector.getDroolsPdps();
-					DroolsPdp designatedPdp = null;
+        // Create the timer which will update the updateDate in DroolsPdpEntity table.
+        // This is the heartbeat 
+        updateWorker = new Timer();
 
-					if(logger.isDebugEnabled()){
-						logger.debug
-						("DesignatedWaiter.run: pdps.size= {}", pdps.size());
-					}
+        // Schedule the TimerUpdateClass to run at 100 ms and run at pdpCheckInterval ms thereafter
+        // NOTE: The first run of the TimerUpdateClass results in myPdp being added to the 
+        // drools droolsPdpEntity table.
+        updateWorker.scheduleAtFixedRate(new TimerUpdateClass(), 100, pdpCheckInterval);
 
-					//This is only true if all designated PDPs have failed
-					boolean designatedPdpHasFailed = pdpsConnector.hasDesignatedPdpFailed(pdps);
-					if(logger.isDebugEnabled()){
-						logger.debug
-						("DesignatedWaiter.run: designatedPdpHasFailed= {}", designatedPdpHasFailed);
-					}
-					for (DroolsPdp pdp : pdps) {
-						if(logger.isDebugEnabled()){
-							logger.debug
-							("DesignatedWaiter.run: evaluating pdp ID: {}", pdp.getPdpId());
-						}
+        // Create the timer which will run the election algorithm
+        waitTimer = new Timer();
 
-						/*
-						 * Note: side effect of isPdpCurrent is that any stale but
-						 * designated PDPs will be marked as un-designated.
-						 */
-						boolean isCurrent = pdpsConnector.isPdpCurrent(pdp);
+        // Schedule it to start in startMs ms 
+        // (so it will run after the updateWorker and run at pdpUpdateInterval ms thereafter
+        long startMs = getDWaiterStartMs();
+        designationWaiter = new DesignationWaiter();
+        waitTimer.scheduleAtFixedRate(designationWaiter, startMs, pdpUpdateInterval);
+        waitTimerLastRunDate = new Date(nowMs + startMs);
 
-						/*
-						 * We can't use stateManagement.getStandbyStatus() here, because
-						 * we need the standbyStatus, not for this PDP, but for the PDP
-						 * being processed by this loop iteration.
-						 */
-						String standbyStatus = stateManagementFeature.getStandbyStatus(pdp.getPdpId());
-						if(standbyStatus==null){
-							// Treat this case as a cold standby -- if we
-							// abort here, no sessions will be created in a
-							// single-node test environment.
-							standbyStatus = StateManagement.COLD_STANDBY;
-						}
-						if(logger.isDebugEnabled()){
-							logger.debug
-							("DesignatedWaiter.run: PDP= {},  isCurrent= {}", pdp.getPdpId(), isCurrent);
-						}
+        //Get the StateManagementFeature instance
 
-						/*
-						 * There are 4 combinations of isDesignated and isCurrent.  We will examine each one in-turn
-						 * and evaluate the each pdp in the list of pdps against each combination.
-						 * 
-						 * This is the first combination of isDesignated and isCurrent
-						 */
-						if (pdp.isDesignated()  &&  isCurrent) { 
-							//It is current, but it could have a standbystatus=coldstandby / hotstandby
-							//If so, we need to stand it down and demote it
-							if(!standbyStatus.equals(StateManagement.PROVIDING_SERVICE)){
-								if(pdp.getPdpId().equals(myPdp.getPdpId())){
-									if(logger.isDebugEnabled()){
-										logger.debug
-										("\n\nDesignatedWaiter.run: myPdp {} is current and designated, "
-											+ "butstandbystatus is not providingservice. "
-											+ " Executing stateManagement.demote()" + "\n\n", myPdp.getPdpId());
-									}
-									// So, we must demote it
-									try {
-										//Keep the order like this.  StateManagement is last since it triggers controller shutdown
-										//This will change isDesignated and it can enter another if(combination) below
-										pdpsConnector.standDownPdp(pdp.getPdpId()); 
-										myPdp.setDesignated(false);
-										isDesignated = false;
-										if(!(standbyStatus.equals(StateManagement.HOT_STANDBY) || 
-												standbyStatus.equals(StateManagement.COLD_STANDBY))){
-											/*
-											 * Only demote it if it appears it has not already been demoted. Don't worry
-											 * about synching with the topic endpoint states.  That is done by the 
-											 * refreshStateAudit
-											 */
-											stateManagementFeature.demote();
-										}
-										//update the standbystatus to check in a later combination of isDesignated and isCurrent
-										standbyStatus=stateManagementFeature.getStandbyStatus(pdp.getPdpId());
-									} catch (Exception e) {
-										logger.error
-										("DesignatedWaiter.run: myPdp: {} "
-												+ "Caught Exception attempting to demote myPdp,"
-												+ "message= {}", myPdp.getPdpId(), e);
-									}
-								}else{
-									// Don't demote a remote PDP that is current.  It should catch itself
-									if(logger.isDebugEnabled()){
-										logger.debug
-										("\n\nDesignatedWaiter.run: myPdp {} is current and designated, "
-											+ "but standbystatus is not providingservice. "
-											+ " Cannot execute stateManagement.demote() since it it is not myPdp\n\n", myPdp.getPdpId());
-									}
-								}
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            if (feature.getResourceName().equals(myPdp.getPdpId())) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("DroolsPdpsElectionHandler: Found StateManagementFeature"
+                            + " with resourceName: {}", myPdp.getPdpId());
+                }
+                stateManagementFeature = feature;
+                break;
+            }
+        }
+        if (stateManagementFeature == null) {
+            logger.error("DroolsPdpsElectionHandler failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", myPdp.getPdpId());
+        }
+    }
 
-							}else{
-								// If we get here, it is ok to be on the list
-								if(logger.isDebugEnabled()){
-									logger.debug
-									("DesignatedWaiter.run: PDP= {} is designated, current and {} Noting PDP as "
-										+ "designated, standbyStatus= {}", pdp.getPdpId(), standbyStatus, standbyStatus);
-								}
-								listOfDesignated.add(pdp);
-							}
+    public static void setIsUnitTesting(boolean val) {
+        isUnitTesting = val;
+    }
+    
+    public static void setIsStalled(boolean val) {
+        isStalled = val;
+    }
+
+    /**
+     * When the JpaDroolsPdpsConnector.standDown() method is invoked, it needs
+     * access to myPdp, so it can keep its designation status in sync with the
+     * DB.
+     * 
+     * @param designated is designated value
+     */
+    public static void setMyPdpDesignated(boolean designated) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("setMyPdpDesignated: designated= {}", designated);
+        }
+        myPdp.setDesignated(designated);
+    }
+
+    private class DesignationWaiter extends TimerTask {
+        // get an instance of logger 
+        private final Logger  logger = LoggerFactory.getLogger(DesignationWaiter.class);
+
+        @Override
+        public void run() {
+            try {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("DesignatedWaiter.run: Entering");
+                }
+
+                //This is for testing the checkWaitTimer
+                if (isUnitTesting && isStalled) {
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("DesignatedWaiter.run: isUnitTesting = {} isStalled = {}", 
+                                isUnitTesting, isStalled);
+                    }
+                    return;
+                }
+
+                synchronized (designationWaiterLock) {
+
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("DesignatedWaiter.run: Entering synchronized block");
+                    }
+
+                    //It is possible that multiple PDPs are designated lead.  So, we will make a list of all designated
+                    //PDPs and then decide which one really should be designated at the end.
+                    List<DroolsPdp> listOfDesignated = new ArrayList<>();
+
+                    Collection<DroolsPdp> pdps = pdpsConnector.getDroolsPdps();
+
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("DesignatedWaiter.run: pdps.size= {}", pdps.size());
+                    }
+
+                    //This is only true if all designated PDPs have failed
+                    boolean designatedPdpHasFailed = pdpsConnector.hasDesignatedPdpFailed(pdps);
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("DesignatedWaiter.run: designatedPdpHasFailed= {}", designatedPdpHasFailed);
+                    }
+                    for (DroolsPdp pdp : pdps) {
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run: evaluating pdp ID: {}", pdp.getPdpId());
+                        }
+
+                        /*
+                         * Note: side effect of isPdpCurrent is that any stale but
+                         * designated PDPs will be marked as un-designated.
+                         */
+                        boolean isCurrent = pdpsConnector.isPdpCurrent(pdp);
+
+                        /*
+                         * We can't use stateManagement.getStandbyStatus() here, because
+                         * we need the standbyStatus, not for this PDP, but for the PDP
+                         * being processed by this loop iteration.
+                         */
+                        String standbyStatus = stateManagementFeature.getStandbyStatus(pdp.getPdpId());
+                        if (standbyStatus == null) {
+                            // Treat this case as a cold standby -- if we
+                            // abort here, no sessions will be created in a
+                            // single-node test environment.
+                            standbyStatus = StateManagement.COLD_STANDBY;
+                        }
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run: PDP= {},  isCurrent= {}", pdp.getPdpId(), isCurrent);
+                        }
+
+                        /*
+                         * There are 4 combinations of isDesignated and isCurrent.  We will examine each one in-turn
+                         * and evaluate the each pdp in the list of pdps against each combination.
+                         * 
+                         * This is the first combination of isDesignated and isCurrent
+                         */
+                        if (pdp.isDesignated()  &&  isCurrent) { 
+                            //It is current, but it could have a standbystatus=coldstandby / hotstandby
+                            //If so, we need to stand it down and demote it
+                            if (!standbyStatus.equals(StateManagement.PROVIDING_SERVICE)) {
+                                if (pdp.getPdpId().equals(myPdp.getPdpId())) {
+                                    if (logger.isDebugEnabled()) {
+                                        logger.debug("\n\nDesignatedWaiter.run: myPdp {} is current and designated, "
+                                                + "butstandbystatus is not providingservice. "
+                                                + " Executing stateManagement.demote()" + "\n\n", myPdp.getPdpId());
+                                    }
+                                    // So, we must demote it
+                                    try {
+                                        //Keep the order like this.  StateManagement is last since it 
+                                        //triggers controller shutdown
+                                        //This will change isDesignated and it can enter another if(combination) below
+                                        pdpsConnector.standDownPdp(pdp.getPdpId()); 
+                                        myPdp.setDesignated(false);
+                                        isDesignated = false;
+                                        if (!(standbyStatus.equals(StateManagement.HOT_STANDBY) 
+                                                || standbyStatus.equals(StateManagement.COLD_STANDBY))) {
+                                            /*
+                                             * Only demote it if it appears it has not already been demoted. Don't worry
+                                             * about synching with the topic endpoint states.  That is done by the 
+                                             * refreshStateAudit
+                                             */
+                                            stateManagementFeature.demote();
+                                        }
+                                        //update the standbystatus to check in a later 
+                                        //combination of isDesignated and isCurrent
+                                        standbyStatus = stateManagementFeature.getStandbyStatus(pdp.getPdpId());
+                                    } catch (Exception e) {
+                                        logger.error("DesignatedWaiter.run: myPdp: {} "
+                                                + "Caught Exception attempting to demote myPdp,"
+                                                + "message= {}", myPdp.getPdpId(), e);
+                                    }
+                                } else {
+                                    // Don't demote a remote PDP that is current.  It should catch itself
+                                    if (logger.isDebugEnabled()) {
+                                        logger.debug("\n\nDesignatedWaiter.run: myPdp {} is current and designated, "
+                                                + "but standbystatus is not providingservice. "
+                                                + " Cannot execute stateManagement.demote() "
+                                                + "since it it is not myPdp\n\n", 
+                                                myPdp.getPdpId());
+                                    }
+                                }
+
+                            } else {
+                                // If we get here, it is ok to be on the list
+                                if (logger.isDebugEnabled()) {
+                                    logger.debug("DesignatedWaiter.run: PDP= {} is designated, "
+                                            + "current and {} Noting PDP as "
+                                            + "designated, standbyStatus= {}", 
+                                            pdp.getPdpId(), standbyStatus, standbyStatus);
+                                }
+                                listOfDesignated.add(pdp);
+                            }
 
 
-						}
+                        }
 
 
-						/*
-						 * The second combination of isDesignated and isCurrent
-						 * 					
-						 * PDP is designated but not current; it has failed.   So we stand it down (it doesn't matter what
-						 * its standbyStatus is). None of these go on the list.
-						 */
-						if (pdp.isDesignated()  &&  !isCurrent) {
-							if(logger.isDebugEnabled()){
-								logger.debug
-								("INFO: DesignatedWaiter.run: PDP= {} is currently designated but is not current; "
-									+ "it has failed.  Standing down.  standbyStatus= {}", pdp.getPdpId(), standbyStatus);
-							}
-							/*
-							 * Changes designated to 0 but it is still potentially providing service
-							 * Will affect isDesignated, so, it can enter an if(combination) below
-							 */
-							pdpsConnector.standDownPdp(pdp.getPdpId()); 
+                        /*
+                         * The second combination of isDesignated and isCurrent
+                         * 
+                         * PDP is designated but not current; it has failed.   
+                         * So we stand it down (it doesn't matter what
+                         * its standbyStatus is). None of these go on the list.
+                         */
+                        if (pdp.isDesignated()  &&  !isCurrent) {
+                            if (logger.isDebugEnabled()) {
+                                logger.debug("INFO: DesignatedWaiter.run: PDP= {} is currently "
+                                        + "designated but is not current; "
+                                        + "it has failed.  Standing down.  standbyStatus= {}", 
+                                        pdp.getPdpId(), standbyStatus);
+                            }
+                            /*
+                             * Changes designated to 0 but it is still potentially providing service
+                             * Will affect isDesignated, so, it can enter an if(combination) below
+                             */
+                            pdpsConnector.standDownPdp(pdp.getPdpId()); 
 
-							//need to change standbystatus to coldstandby
-							if (pdp.getPdpId().equals(myPdp.getPdpId())){
-								if(logger.isDebugEnabled()){
-									logger.debug
-									("\n\nDesignatedWaiter.run: myPdp {} is not Current. "
-										+ " Executing stateManagement.disableFailed()\n\n", myPdp.getPdpId());
-								}
-								// We found that myPdp is designated but not current
-								// So, we must cause it to disableFail
-								try {
-									myPdp.setDesignated(false);
-									pdpsConnector.setDesignated(myPdp, false);
-									isDesignated = false;
-									stateManagementFeature.disableFailed();
-								} catch (Exception e) {
-									logger.error
-									("DesignatedWaiter.run: myPdp: {} Caught Exception "
-											+ "attempting to disableFail myPdp {}, message= {}",
-											myPdp.getPdpId(), myPdp.getPdpId(), e);
-								}
-							} else { //it is a remote PDP that is failed
-								if(logger.isDebugEnabled()){
-									logger.debug
-									("\n\nDesignatedWaiter.run: PDP {} is not Current. "
-										+ " Executing stateManagement.disableFailed(otherResourceName)\n\n", pdp.getPdpId() );
-								}
-								// We found a PDP is designated but not current
-								// We already called standdown(pdp) which will change designated to false
-								// Now we need to disableFail it to get its states in synch.  The standbyStatus
-								// should equal coldstandby
-								try {
-									stateManagementFeature.disableFailed(pdp.getPdpId());
-								} catch (Exception e) {
-									logger.error
-									("DesignatedWaiter.run: for PDP {}  Caught Exception attempting to "
-											+ "disableFail({}), message= {}",
-											pdp.getPdpId(), pdp.getPdpId(), e);
-								}
+                            //need to change standbystatus to coldstandby
+                            if (pdp.getPdpId().equals(myPdp.getPdpId())) {
+                                if (logger.isDebugEnabled()) {
+                                    logger.debug("\n\nDesignatedWaiter.run: myPdp {} is not Current. "
+                                            + " Executing stateManagement.disableFailed()\n\n", myPdp.getPdpId());
+                                }
+                                // We found that myPdp is designated but not current
+                                // So, we must cause it to disableFail
+                                try {
+                                    myPdp.setDesignated(false);
+                                    pdpsConnector.setDesignated(myPdp, false);
+                                    isDesignated = false;
+                                    stateManagementFeature.disableFailed();
+                                } catch (Exception e) {
+                                    logger.error("DesignatedWaiter.run: myPdp: {} Caught Exception "
+                                            + "attempting to disableFail myPdp {}, message= {}",
+                                            myPdp.getPdpId(), myPdp.getPdpId(), e);
+                                }
+                            } else { //it is a remote PDP that is failed
+                                if (logger.isDebugEnabled()) {
+                                    logger.debug("\n\nDesignatedWaiter.run: PDP {} is not Current. "
+                                            + " Executing stateManagement.disableFailed(otherResourceName)\n\n",
+                                            pdp.getPdpId() );
+                                }
+                                // We found a PDP is designated but not current
+                                // We already called standdown(pdp) which will change designated to false
+                                // Now we need to disableFail it to get its states in synch.  The standbyStatus
+                                // should equal coldstandby
+                                try {
+                                    stateManagementFeature.disableFailed(pdp.getPdpId());
+                                } catch (Exception e) {
+                                    logger.error("DesignatedWaiter.run: for PDP {}  Caught Exception attempting to "
+                                            + "disableFail({}), message= {}",
+                                            pdp.getPdpId(), pdp.getPdpId(), e);
+                                }
 
-							}
-							continue; //we are not going to do anything else with this pdp
-						} 
+                            }
+                            continue; //we are not going to do anything else with this pdp
+                        } 
 
-						/*
-						 * The third combination of isDesignated and isCurrent
-						 * /*
-						 * If a PDP is not currently designated but is providing service (erroneous, but recoverable) or hot standby 
-						 * we can add it to the list of possible designated if all the designated have failed
-						 */
-						if (!pdp.isDesignated() && isCurrent){
-							if(!(standbyStatus.equals(StateManagement.HOT_STANDBY) ||
-									standbyStatus.equals(StateManagement.COLD_STANDBY))){
-								if(logger.isDebugEnabled()){
-									logger.debug("\n\nDesignatedWaiter.run: PDP {}"
-										+ " is NOT designated but IS current and"
-										+ " has a standbystatus= {}", pdp.getPdpId(), standbyStatus);
-								}
-								// Since it is current, we assume it can adjust its own state.
-								// We will demote if it is myPdp
-								if(pdp.getPdpId().equals(myPdp.getPdpId())){
-									//demote it
-									if(logger.isDebugEnabled()){
-										logger.debug("DesignatedWaiter.run: PDP {} going to "
-											+ "setDesignated = false and calling stateManagement.demote",  pdp.getPdpId());
-									}
-									try {
-										//Keep the order like this.  StateManagement is last since it triggers controller shutdown
-										pdpsConnector.setDesignated(myPdp, false);
-										myPdp.setDesignated(false);
-										isDesignated = false;
-										//This is definitely not a redundant call.  It is attempting to correct a problem
-										stateManagementFeature.demote();
-										//recheck the standbystatus
-										standbyStatus = stateManagementFeature.getStandbyStatus(pdp.getPdpId());
-									} catch (Exception e) {
-										logger.error
-										("DesignatedWaiter.run: myPdp: {} Caught Exception "
-												+ "attempting to demote myPdp {}, message = {}",  myPdp.getPdpId(),
-												myPdp.getPdpId(), e);
-									}
+                        /*
+                         * The third combination of isDesignated and isCurrent
+                         * /*
+                         * If a PDP is not currently designated but is providing service 
+                         * (erroneous, but recoverable) or hot standby 
+                         * we can add it to the list of possible designated if all the designated have failed
+                         */
+                        if (!pdp.isDesignated() && isCurrent) {
+                            if (!(standbyStatus.equals(StateManagement.HOT_STANDBY)
+                                    || standbyStatus.equals(StateManagement.COLD_STANDBY))) {
+                                if (logger.isDebugEnabled()) {
+                                    logger.debug("\n\nDesignatedWaiter.run: PDP {}"
+                                            + " is NOT designated but IS current and"
+                                            + " has a standbystatus= {}", pdp.getPdpId(), standbyStatus);
+                                }
+                                // Since it is current, we assume it can adjust its own state.
+                                // We will demote if it is myPdp
+                                if (pdp.getPdpId().equals(myPdp.getPdpId())) {
+                                    //demote it
+                                    if (logger.isDebugEnabled()) {
+                                        logger.debug("DesignatedWaiter.run: PDP {} going to "
+                                                + "setDesignated = false and calling stateManagement.demote",  
+                                                pdp.getPdpId());
+                                    }
+                                    try {
+                                        //Keep the order like this.  
+                                        //StateManagement is last since it triggers controller shutdown
+                                        pdpsConnector.setDesignated(myPdp, false);
+                                        myPdp.setDesignated(false);
+                                        isDesignated = false;
+                                        //This is definitely not a redundant call.  
+                                        //It is attempting to correct a problem
+                                        stateManagementFeature.demote();
+                                        //recheck the standbystatus
+                                        standbyStatus = stateManagementFeature.getStandbyStatus(pdp.getPdpId());
+                                    } catch (Exception e) {
+                                        logger.error("DesignatedWaiter.run: myPdp: {} Caught Exception "
+                                                + "attempting to demote myPdp {}, message = {}",  myPdp.getPdpId(),
+                                                myPdp.getPdpId(), e);
+                                    }
 
-								}
-							}
-							if(standbyStatus.equals(StateManagement.HOT_STANDBY) && designatedPdpHasFailed){
-								//add it to the list
-								if(logger.isDebugEnabled()){
-									logger.debug
-									("INFO: DesignatedWaiter.run: PDP= {}"
-										+ " is not designated but is {} and designated PDP "
-										+ "has failed.  standbyStatus= {}", pdp.getPdpId(), 
-										standbyStatus, standbyStatus);
-								}
-								listOfDesignated.add(pdp);
-							}
-							continue; //done with this one
-						}
+                                }
+                            }
+                            if (standbyStatus.equals(StateManagement.HOT_STANDBY) && designatedPdpHasFailed) {
+                                //add it to the list
+                                if (logger.isDebugEnabled()) {
+                                    logger.debug("INFO: DesignatedWaiter.run: PDP= {}"
+                                            + " is not designated but is {} and designated PDP "
+                                            + "has failed.  standbyStatus= {}", pdp.getPdpId(), 
+                                            standbyStatus, standbyStatus);
+                                }
+                                listOfDesignated.add(pdp);
+                            }
+                            continue; //done with this one
+                        }
 
-						/*
-						 * The fourth combination of isDesignated and isCurrent
-						 * 
-						 * We are not going to put any of these on the list since it appears they have failed.
+                        /*
+                         * The fourth combination of isDesignated and isCurrent
+                         * 
+                         * We are not going to put any of these on the list since it appears they have failed.
 
-						 * 
-						 */
-						if(!pdp.isDesignated() && !isCurrent) {
-							if(logger.isDebugEnabled()){
-								logger.debug
-								("INFO: DesignatedWaiter.run: PDP= {} "
-									+ "designated= {}, current= {}, "
-									+ "designatedPdpHasFailed= {}, "
-									+ "standbyStatus= {}",pdp.getPdpId(), 
-									pdp.isDesignated(), isCurrent, designatedPdpHasFailed, standbyStatus);
-							}
-							if(!standbyStatus.equals(StateManagement.COLD_STANDBY)){
-								//stand it down
-								//disableFail it
-								pdpsConnector.standDownPdp(pdp.getPdpId()); 
-								if(pdp.getPdpId().equals(myPdp.getPdpId())){
-									/*
-									 * I don't actually know how this condition could happen, but if it did, we would want
-									 * to declare it failed.
-									 */
-									if(logger.isDebugEnabled()){
-										logger.debug
-										("\n\nDesignatedWaiter.run: myPdp {} is !current and !designated, "
-											+ " Executing stateManagement.disableFailed()\n\n", myPdp.getPdpId());
-									}
-									// So, we must disableFail it
-									try {
-										//Keep the order like this.  StateManagement is last since it triggers controller shutdown
-										pdpsConnector.setDesignated(myPdp, false);
-										myPdp.setDesignated(false);
-										isDesignated = false;
-										stateManagementFeature.disableFailed();
-									} catch (Exception e) {
-										logger.error
-										("DesignatedWaiter.run: myPdp: {} Caught Exception attempting to "
-												+ "disableFail myPdp {}, message= {}", 
-												 myPdp.getPdpId(), myPdp.getPdpId(), e);
-									}
-								}else{//it is remote
-									if(logger.isDebugEnabled()){
-										logger.debug
-										("\n\nDesignatedWaiter.run: myPdp {} is !current and !designated, "
-											+ " Executing stateManagement.disableFailed({})\n\n", 
-											myPdp.getPdpId(), pdp.getPdpId());
-									}
-									// We already called standdown(pdp) which will change designated to false
-									// Now we need to disableFail it to get its states in sync.  StandbyStatus = coldstandby
-									try {
-										stateManagementFeature.disableFailed(pdp.getPdpId());
-									} catch (Exception e) {
-										logger.error
-										("DesignatedWaiter.run: for PDP {}" 
-												+ " Caught Exception attempting to disableFail({})"
-												+ ", message=", pdp.getPdpId(), pdp.getPdpId(), e);
-									}
-								}
-							}
-						}
+                         * 
+                         */
+                        if (!pdp.isDesignated() && !isCurrent) {
+                            if (logger.isDebugEnabled()) {
+                                logger.debug("INFO: DesignatedWaiter.run: PDP= {} "
+                                        + "designated= {}, current= {}, "
+                                        + "designatedPdpHasFailed= {}, "
+                                        + "standbyStatus= {}",pdp.getPdpId(), 
+                                        pdp.isDesignated(), isCurrent, designatedPdpHasFailed, standbyStatus);
+                            }
+                            if (!standbyStatus.equals(StateManagement.COLD_STANDBY)) {
+                                //stand it down
+                                //disableFail it
+                                pdpsConnector.standDownPdp(pdp.getPdpId()); 
+                                if (pdp.getPdpId().equals(myPdp.getPdpId())) {
+                                    /*
+                                     * I don't actually know how this condition could happen, 
+                                     * but if it did, we would want
+                                     * to declare it failed.
+                                     */
+                                    if (logger.isDebugEnabled()) {
+                                        logger.debug("\n\nDesignatedWaiter.run: myPdp {} is !current and !designated, "
+                                                + " Executing stateManagement.disableFailed()\n\n", myPdp.getPdpId());
+                                    }
+                                    // So, we must disableFail it
+                                    try {
+                                        //Keep the order like this.  
+                                        //StateManagement is last since it triggers controller shutdown
+                                        pdpsConnector.setDesignated(myPdp, false);
+                                        myPdp.setDesignated(false);
+                                        isDesignated = false;
+                                        stateManagementFeature.disableFailed();
+                                    } catch (Exception e) {
+                                        logger.error("DesignatedWaiter.run: myPdp: {} Caught Exception attempting to "
+                                                + "disableFail myPdp {}, message= {}", 
+                                                myPdp.getPdpId(), myPdp.getPdpId(), e);
+                                    }
+                                } else { //it is remote
+                                    if (logger.isDebugEnabled()) {
+                                        logger.debug("\n\nDesignatedWaiter.run: myPdp {} is !current and !designated, "
+                                                + " Executing stateManagement.disableFailed({})\n\n", 
+                                                myPdp.getPdpId(), pdp.getPdpId());
+                                    }
+                                    // We already called standdown(pdp) which will change designated to false
+                                    // Now we need to disableFail it to get its states in sync.  
+                                    // StandbyStatus = coldstandby
+                                    try {
+                                        stateManagementFeature.disableFailed(pdp.getPdpId());
+                                    } catch (Exception e) {
+                                        logger.error("DesignatedWaiter.run: for PDP {}" 
+                                                + " Caught Exception attempting to disableFail({})"
+                                                + ", message=", pdp.getPdpId(), pdp.getPdpId(), e);
+                                    }
+                                }
+                            }
+                        }
 
 
-					} // end pdps loop
+                    } // end pdps loop
 
-					/*
-					 * We have checked the four combinations of isDesignated and isCurrent.  Where appropriate,
-					 * we added the PDPs to the potential list of designated pdps
-					 * 
-					 * We need to give priority to pdps on the same site that is currently being used
-					 * First, however, we must sanitize the list of designated to make sure their are
-					 * only designated members or non-designated members.  There should not be both in 
-					 * the list. Because there are real time delays, it is possible that both types could
-					 * be on the list.
-					 */
-					
-					listOfDesignated = santizeDesignatedList(listOfDesignated);
+                    /*
+                     * We have checked the four combinations of isDesignated and isCurrent.  Where appropriate,
+                     * we added the PDPs to the potential list of designated pdps
+                     * 
+                     * We need to give priority to pdps on the same site that is currently being used
+                     * First, however, we must sanitize the list of designated to make sure their are
+                     * only designated members or non-designated members.  There should not be both in 
+                     * the list. Because there are real time delays, it is possible that both types could
+                     * be on the list.
+                     */
 
-					/*
-					 * We need to figure out the last pdp that was the primary so we can get the last site 
-					 * name and the last session numbers.  We need to create a "dummy" droolspdp since
-					 * it will be used in later comparisons and cannot be null.
-					 */
-					
-					DroolsPdp mostRecentPrimary = computeMostRecentPrimary(pdps, listOfDesignated);
-					
-					if(mostRecentPrimary != null){
-						pdpdLastActive = mostRecentPrimary.getPdpId();
-					}
-					
-					
-					/*
-					 * It is possible to get here with more than one pdp designated and providingservice. This normally
-					 * occurs when there is a race condition with multiple nodes coming up at the same time. If that is
-					 * the case we must determine which one is the one that should be designated and which one should
-					 * be demoted.
-					 * 
-					 * It is possible to have 0, 1, 2 or more but not all, or all designated.  
-					 *   If we have one designated and current, we chose it and are done
-					 *   If we have 2 or more, but not all, we must determine which one is in the same site as
-					 *   the previously designated pdp.
-					 */
-					
-					designatedPdp = computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-					if(designatedPdp != null){
-						pdpdNowActive = designatedPdp.getPdpId();
-					}
+                    listOfDesignated = santizeDesignatedList(listOfDesignated);
 
-					if (designatedPdp == null) {
-						logger.warn
-						("WARNING: DesignatedWaiter.run: No viable PDP found to be Designated. designatedPdp still null.");
-						// Just to be sure the parameters are correctly set
-						myPdp.setDesignated(false);
-						pdpsConnector.setDesignated(myPdp,false);
-						isDesignated = false;
-						
-						waitTimerLastRunDate = new Date();
-						if(logger.isDebugEnabled()){
-							logger.debug("DesignatedWaiter.run (designatedPdp == null) waitTimerLastRunDate = {}", waitTimerLastRunDate);
-						}
-						myPdp.setUpdatedDate(waitTimerLastRunDate);
-						pdpsConnector.update(myPdp);
-						
-						return;
-						
-					} else if (designatedPdp.getPdpId().equals(myPdp.getPdpId())) {
-						if(logger.isDebugEnabled()){
-							logger.debug
-							("DesignatedWaiter.run: designatedPdp is PDP={}", myPdp.getPdpId());
-						}
-						/*
-						 * update function expects myPdp.isDesignated to be true.
-						 */
-						try {
-							//Keep the order like this.  StateManagement is last since it triggers controller init
-							myPdp.setDesignated(true);
-							myPdp.setDesignatedDate(new Date());
-							pdpsConnector.setDesignated(myPdp, true);
-							isDesignated = true;
-							String standbyStatus = stateManagementFeature.getStandbyStatus();
-							if(!standbyStatus.equals(StateManagement.PROVIDING_SERVICE)){
-								/*
-								 * Only call promote if it is not already in the right state.  Don't worry about
-								 * synching the lower level topic endpoint states.  That is done by the
-								 * refreshStateAudit.
-								 * Note that we need to fetch the session list from 'mostRecentPrimary'
-								 * at this point -- soon, 'mostRecentPrimary' will be set to this host.
-								 */
-								//this.sessions = mostRecentPrimary.getSessions();
-								stateManagementFeature.promote();
-							}
-						} catch (Exception e) {
-							logger.error
-							("ERROR: DesignatedWaiter.run: Caught Exception attempting to promote PDP={}"
-									+ ", message=", myPdp.getPdpId(), e);
-							myPdp.setDesignated(false);
-							pdpsConnector.setDesignated(myPdp,false);
-							isDesignated = false;
-							//If you can't promote it, demote it
-							try {
-								String standbyStatus = stateManagementFeature.getStandbyStatus();
-								if(!(standbyStatus.equals(StateManagement.HOT_STANDBY) || 
-										standbyStatus.equals(StateManagement.COLD_STANDBY))){
-									/*
-									 * Only call demote if it is not already in the right state.  Don't worry about
-									 * synching the lower level topic endpoint states.  That is done by the
-									 * refreshStateAudit.
-									 */
-									stateManagementFeature.demote();
-								}
-							} catch (Exception e1) {
-								logger.error
-								("ERROR: DesignatedWaiter.run: Caught StandbyStatusException "
-										+ "attempting to promote then demote PDP={}, message=",
-										myPdp.getPdpId(), e1);
-							}
+                    /*
+                     * We need to figure out the last pdp that was the primary so we can get the last site 
+                     * name and the last session numbers.  We need to create a "dummy" droolspdp since
+                     * it will be used in later comparisons and cannot be null.
+                     */
 
-						} 
-						waitTimerLastRunDate = new Date();
-						if(logger.isDebugEnabled()){
-							logger.debug("DesignatedWaiter.run (designatedPdp.getPdpId().equals(myPdp.getPdpId())) "
-								+ "waitTimerLastRunDate = " + waitTimerLastRunDate);
-						}
-						myPdp.setUpdatedDate(waitTimerLastRunDate);
-						pdpsConnector.update(myPdp);
+                    DroolsPdp mostRecentPrimary = computeMostRecentPrimary(pdps, listOfDesignated);
 
-						return;
-					}
-					isDesignated = false;
+                    if (mostRecentPrimary != null) {
+                        pdpdLastActive = mostRecentPrimary.getPdpId();
+                    }
 
-				} // end synchronized
-				if(logger.isDebugEnabled()){
-					logger.debug
-					("DesignatedWaiter.run: myPdp: {}; Returning, isDesignated= {}",
-						isDesignated, myPdp.getPdpId());
-				}
 
-				Date tmpDate = new Date();
-				if(logger.isDebugEnabled()){
-					logger.debug("DesignatedWaiter.run (end of run) waitTimerLastRunDate = {}", tmpDate);
-				}
-				
-				waitTimerLastRunDate = tmpDate;
-				myPdp.setUpdatedDate(waitTimerLastRunDate);
-				pdpsConnector.update(myPdp);
-				
-			}catch(Exception e){
-				logger.error("DesignatedWaiter.run caught an unexpected exception: ", e);
-			}
-		} // end run
-	}
-	
-	public List<DroolsPdp> santizeDesignatedList(List<DroolsPdp> listOfDesignated){
+                    /*
+                     * It is possible to get here with more than one pdp designated and providingservice. This normally
+                     * occurs when there is a race condition with multiple nodes coming up at the same time. If that is
+                     * the case we must determine which one is the one that should be designated and which one should
+                     * be demoted.
+                     * 
+                     * It is possible to have 0, 1, 2 or more but not all, or all designated.  
+                     *   If we have one designated and current, we chose it and are done
+                     *   If we have 2 or more, but not all, we must determine which one is in the same site as
+                     *   the previously designated pdp.
+                     */
+                    DroolsPdp designatedPdp = computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
+                    if (designatedPdp != null) {
+                        pdpdNowActive = designatedPdp.getPdpId();
+                    }
 
-		boolean containsDesignated = false;
-		boolean containsHotStandby = false;
-		List<DroolsPdp> listForRemoval = new ArrayList<>();
-		for(DroolsPdp pdp : listOfDesignated){
-			if(logger.isDebugEnabled()){
-				logger.debug
-				("DesignatedWaiter.run sanitizing: pdp = {}" 
-					+ " isDesignated = {}",pdp.getPdpId(), pdp.isDesignated());
-			}
-			if(pdp.isDesignated()){
-				containsDesignated = true;
-			}else {
-				containsHotStandby = true;
-				listForRemoval.add(pdp);
-			}
-		}
-		if(containsDesignated && containsHotStandby){
-			//remove the hot standby from the list
-			listOfDesignated.removeAll(listForRemoval);
-		}
-		return listOfDesignated;
-	}
-	
-	public DroolsPdp computeMostRecentPrimary(Collection<DroolsPdp> pdps, List<DroolsPdp> listOfDesignated){
-		boolean containsDesignated = false;
-		for(DroolsPdp pdp : listOfDesignated){
-			if(pdp.isDesignated()){
-				containsDesignated = true;
-			}
-		}
-		DroolsPdp mostRecentPrimary = new DroolsPdpImpl(null, true, 1, new Date(0));
-		mostRecentPrimary.setSiteName(null);
-		if(logger.isDebugEnabled()){
-			logger.debug
-			("DesignatedWaiter.run listOfDesignated.size() = {}", listOfDesignated.size());
-		}
-		if(listOfDesignated.size() <=1){
-			if(logger.isDebugEnabled()){
-				logger.debug("DesignatedWainter.run: listOfDesignated.size <=1");
-			}
-			//Only one or none is designated or hot standby.  Choose the latest designated date
-			for(DroolsPdp pdp : pdps){
-				if(logger.isDebugEnabled()){
-					logger.debug
-					("DesignatedWaiter.run pdp = {}" 
-						+ " pdp.getDesignatedDate() = {}", pdp.getPdpId(), pdp.getDesignatedDate());
-				}
-				if(pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0){
-					mostRecentPrimary = pdp;
-					if(logger.isDebugEnabled()){
-						logger.debug
-						("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
-					}
-				}
-			}
-		}else if(listOfDesignated.size() == pdps.size()){
-			if(logger.isDebugEnabled()){
-				logger.debug("DesignatedWainter.run: listOfDesignated.size = pdps.size() which is {}", pdps.size());
-			}
-			//They are all designated or all hot standby.
-			mostRecentPrimary = null;
-			for(DroolsPdp pdp : pdps){
-				if(mostRecentPrimary == null){
-					mostRecentPrimary = pdp;
-					continue;
-				}
-				if(containsDesignated){ //Choose the site of the first designated date
-					if(pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) < 0){
-						mostRecentPrimary = pdp;
-						if(logger.isDebugEnabled()){
-							logger.debug
-							("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
-						}
-					}
-				}else{ //Choose the site with the latest designated date
-					if(pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0){
-						mostRecentPrimary = pdp;
-						if(logger.isDebugEnabled()){
-							logger.debug
-							("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
-						}
-					}
-				}
-			}
-		}else{
-			if(logger.isDebugEnabled()){
-				logger.debug("DesignatedWainter.run: Some but not all are designated or hot standby. ");
-			}
-			//Some but not all are designated or hot standby. 
-			if(containsDesignated){
-				if(logger.isDebugEnabled()){
-					logger.debug("DesignatedWainter.run: containsDesignated = {}", containsDesignated);
-				}
-				/*
-				 * The list only contains designated.  This is a problem.  It is most likely a race
-				 * condition that resulted in two thinking they should be designated. Choose the 
-				 * site with the latest designated date for the pdp not included on the designated list.
-				 * This should be the site that had the last designation before this race condition
-				 * occurred.
-				 */
-				for(DroolsPdp pdp : pdps){
-					if(listOfDesignated.contains(pdp)){
-						continue; //Don't consider this entry
-					}
-					if(pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0){
-						mostRecentPrimary = pdp;
-						if(logger.isDebugEnabled()){
-							logger.debug
-							("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
-						}
-					}
-				}
-			}else{
-				if(logger.isDebugEnabled()){
-					logger.debug("DesignatedWainter.run: containsDesignated = {}", containsDesignated);
-				}
-				//The list only contains hot standby. Choose the site of the latest designated date
-				for(DroolsPdp pdp : pdps){
-					if(pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0){
-						mostRecentPrimary = pdp;
-						if(logger.isDebugEnabled()){
-							logger.debug
-							("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
-						}
-					}
-				}
-			}
-		}
-		return mostRecentPrimary;
-	}
-	
-	public DroolsPdp computeDesignatedPdp(List<DroolsPdp> listOfDesignated, DroolsPdp mostRecentPrimary){
-		DroolsPdp designatedPdp = null;
-		DroolsPdp lowestPriorityPdp = null;
-		if(listOfDesignated.size() > 1){
-			if(logger.isDebugEnabled()){
-				logger.debug
-				("DesignatedWaiter.run: myPdp: {} listOfDesignated.size(): {}", myPdp.getPdpId(), listOfDesignated.size());
-			}
-			DroolsPdp rejectedPdp = null;
-			DroolsPdp lowestPrioritySameSite = null;
-			DroolsPdp lowestPriorityDifferentSite = null;
-			for(DroolsPdp pdp : listOfDesignated){
-				// We need to determine if another PDP is the lowest priority
-				if(nullSafeEquals(pdp.getSiteName(),mostRecentPrimary.getSiteName())){
-					if(lowestPrioritySameSite == null){
-						if(lowestPriorityDifferentSite != null){
-							rejectedPdp = lowestPriorityDifferentSite;
-						}
-						lowestPrioritySameSite = pdp;									
-					}else{
-						if(pdp.getPdpId().equals((lowestPrioritySameSite.getPdpId()))){
-							continue;//nothing to compare
-						}
-						if(pdp.comparePriority(lowestPrioritySameSite) <0){
-							if(logger.isDebugEnabled()){
-								logger.debug
-								("\nDesignatedWaiter.run: myPdp {}  listOfDesignated pdp ID: {}" 
-									+ " has lower priority than pdp ID: {}",myPdp.getPdpId(), pdp.getPdpId(),
-									lowestPrioritySameSite.getPdpId());
-							}
-							//we need to reject lowestPrioritySameSite
-							rejectedPdp = lowestPrioritySameSite;
-							lowestPrioritySameSite = pdp;
-						} else{
-							//we need to reject pdp and keep lowestPrioritySameSite
-							if(logger.isDebugEnabled()){
-								logger.debug
-								("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {} " 
-									+ " has higher priority than pdp ID: {}", myPdp.getPdpId(),pdp.getPdpId(),
-									lowestPrioritySameSite.getPdpId());
-							}
-							rejectedPdp = pdp;
-						}
-					}
-				} else{
-					if(lowestPrioritySameSite != null){
-						//if we already have a candidate for same site, we don't want to bother with different sites
-						rejectedPdp = pdp;
-					} else{
-						if(lowestPriorityDifferentSite == null){
-							lowestPriorityDifferentSite = pdp;
-							continue;
-						}
-						if(pdp.getPdpId().equals((lowestPriorityDifferentSite.getPdpId()))){
-							continue;//nothing to compare
-						}
-						if(pdp.comparePriority(lowestPriorityDifferentSite) <0){
-							if(logger.isDebugEnabled()){
-								logger.debug
-								("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {}" 
-									+ " has lower priority than pdp ID: {}", myPdp.getPdpId(), pdp.getPdpId(),
-									lowestPriorityDifferentSite.getPdpId());
-							}
-							//we need to reject lowestPriorityDifferentSite
-							rejectedPdp = lowestPriorityDifferentSite;
-							lowestPriorityDifferentSite = pdp;
-						} else{
-							//we need to reject pdp and keep lowestPriorityDifferentSite
-							if(logger.isDebugEnabled()){
-								logger.debug
-								("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {}" 
-									+ " has higher priority than pdp ID: {}", myPdp.getPdpId(), pdp.getPdpId(),
-									lowestPriorityDifferentSite.getPdpId());
-							}
-							rejectedPdp = pdp;
-						}
-					}
-				}
-				// If the rejectedPdp is myPdp, we need to stand it down and demote it.  Each pdp is responsible
-				// for demoting itself
-				if(rejectedPdp != null && nullSafeEquals(rejectedPdp.getPdpId(),myPdp.getPdpId())){
-					if(logger.isDebugEnabled()){
-						logger.debug
-						("\n\nDesignatedWaiter.run: myPdp: {} listOfDesignated myPdp ID: {}" 
-							+ " is NOT the lowest priority.  Executing stateManagement.demote()\n\n", myPdp.getPdpId(),
-							 myPdp.getPdpId());
-					}
-					// We found that myPdp is on the listOfDesignated and it is not the lowest priority
-					// So, we must demote it
-					try {
-						//Keep the order like this.  StateManagement is last since it triggers controller shutdown
-						myPdp.setDesignated(false);
-						pdpsConnector.setDesignated(myPdp, false);
-						isDesignated = false;
-						String standbyStatus = stateManagementFeature.getStandbyStatus();
-						if(!(standbyStatus.equals(StateManagement.HOT_STANDBY) || 
-								standbyStatus.equals(StateManagement.COLD_STANDBY))){
-							/*
-							 * Only call demote if it is not already in the right state.  Don't worry about
-							 * synching the lower level topic endpoint states.  That is done by the
-							 * refreshStateAudit.
-							 */
-							stateManagementFeature.demote();
-						}
-					} catch (Exception e) {
-						myPdp.setDesignated(false);
-						pdpsConnector.setDesignated(myPdp, false);
-						isDesignated = false;
-						logger.error
-						("DesignatedWaiter.run: myPdp: {} Caught Exception attempting to "
-								+ "demote myPdp {} myPdp.getPdpId(), message= {}", myPdp.getPdpId(), 
-								e);
-					}
-				}
-			} //end: for(DroolsPdp pdp : listOfDesignated)
-			if(lowestPrioritySameSite != null){
-				lowestPriorityPdp = lowestPrioritySameSite;
-			} else {
-				lowestPriorityPdp = lowestPriorityDifferentSite;
-			}
-			//now we have a valid value for lowestPriorityPdp
-			if(logger.isDebugEnabled()){
-				logger.debug
-				("\n\nDesignatedWaiter.run: myPdp: {} listOfDesignated "
-					+ "found the LOWEST priority pdp ID: {} " 
-					+ " It is now the designatedPpd from the perspective of myPdp ID: {} \n\n",
-					 myPdp.getPdpId(), lowestPriorityPdp.getPdpId(), myPdp);
-			}
-			designatedPdp = lowestPriorityPdp;
+                    if (designatedPdp == null) {
+                        logger.warn("WARNING: DesignatedWaiter.run: No viable PDP found to be Designated. "
+                            + "designatedPdp still null.");
+                        // Just to be sure the parameters are correctly set
+                        myPdp.setDesignated(false);
+                        pdpsConnector.setDesignated(myPdp,false);
+                        isDesignated = false;
 
-		} else if(listOfDesignated.isEmpty()){
-			if(logger.isDebugEnabled()){
-				logger.debug
-				("\nDesignatedWaiter.run: myPdp: {} listOfDesignated is: EMPTY.", myPdp.getPdpId());
-			}
-			designatedPdp = null;
-		} else{ //only one in listOfDesignated
-			if(logger.isDebugEnabled()){
-				logger.debug
-				("\nDesignatedWaiter.run: myPdp: {} listOfDesignated "
-					+ "has ONE entry. PDP ID: {}", myPdp.getPdpId(), listOfDesignated.get(0).getPdpId());
-			}
-			designatedPdp = listOfDesignated.get(0);
-		}
-		return designatedPdp;
+                        waitTimerLastRunDate = new Date();
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run (designatedPdp == null) waitTimerLastRunDate = {}", 
+                                    waitTimerLastRunDate);
+                        }
+                        myPdp.setUpdatedDate(waitTimerLastRunDate);
+                        pdpsConnector.update(myPdp);
 
-	}
-	
-	private class TimerUpdateClass extends TimerTask{
+                        return;
 
-		@Override
-		public void run() {
-			try{
-				if(logger.isDebugEnabled()){
-					logger.debug("TimerUpdateClass.run: entry");
-				}
-				checkWaitTimer();
-			}catch(Exception e){
-				logger.error("TimerUpdateClass.run caught an unexpected exception: ", e);
-			}
-			if(logger.isDebugEnabled()){
-				logger.debug("TimerUpdateClass.run.exit");
-			}
-		}
-	}
-	@Override
-	public void checkThreadStatus() {
-		checkWaitTimer();
-	}
+                    } else if (designatedPdp.getPdpId().equals(myPdp.getPdpId())) {
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run: designatedPdp is PDP={}", myPdp.getPdpId());
+                        }
+                        /*
+                         * update function expects myPdp.isDesignated to be true.
+                         */
+                        try {
+                            //Keep the order like this.  StateManagement is last since it triggers controller init
+                            myPdp.setDesignated(true);
+                            myPdp.setDesignatedDate(new Date());
+                            pdpsConnector.setDesignated(myPdp, true);
+                            isDesignated = true;
+                            String standbyStatus = stateManagementFeature.getStandbyStatus();
+                            if (!standbyStatus.equals(StateManagement.PROVIDING_SERVICE)) {
+                                /*
+                                 * Only call promote if it is not already in the right state.  Don't worry about
+                                 * synching the lower level topic endpoint states.  That is done by the
+                                 * refreshStateAudit.
+                                 * Note that we need to fetch the session list from 'mostRecentPrimary'
+                                 * at this point -- soon, 'mostRecentPrimary' will be set to this host.
+                                 */
+                                //this.sessions = mostRecentPrimary.getSessions();
+                                stateManagementFeature.promote();
+                            }
+                        } catch (Exception e) {
+                            logger.error("ERROR: DesignatedWaiter.run: Caught Exception attempting to promote PDP={}"
+                                    + ", message=", myPdp.getPdpId(), e);
+                            myPdp.setDesignated(false);
+                            pdpsConnector.setDesignated(myPdp,false);
+                            isDesignated = false;
+                            //If you can't promote it, demote it
+                            try {
+                                String standbyStatus = stateManagementFeature.getStandbyStatus();
+                                if (!(standbyStatus.equals(StateManagement.HOT_STANDBY)
+                                        || standbyStatus.equals(StateManagement.COLD_STANDBY))) {
+                                    /*
+                                     * Only call demote if it is not already in the right state.  Don't worry about
+                                     * synching the lower level topic endpoint states.  That is done by the
+                                     * refreshStateAudit.
+                                     */
+                                    stateManagementFeature.demote();
+                                }
+                            } catch (Exception e1) {
+                                logger.error("ERROR: DesignatedWaiter.run: Caught StandbyStatusException "
+                                        + "attempting to promote then demote PDP={}, message=",
+                                        myPdp.getPdpId(), e1);
+                            }
 
-	private void checkWaitTimer(){
-		synchronized(checkWaitTimerLock){
-			try{
-				if(logger.isDebugEnabled()){
-					logger.debug("checkWaitTimer: entry");
-				}
-				Date now = new Date();
-				long nowMs = now.getTime();
-				long waitTimerMs = waitTimerLastRunDate.getTime();
+                        } 
+                        waitTimerLastRunDate = new Date();
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run (designatedPdp.getPdpId().equals(myPdp.getPdpId())) "
+                                    + "waitTimerLastRunDate = " + waitTimerLastRunDate);
+                        }
+                        myPdp.setUpdatedDate(waitTimerLastRunDate);
+                        pdpsConnector.update(myPdp);
 
-				//give it 10 times leeway  
-				if((nowMs - waitTimerMs)  > 10*pdpUpdateInterval){
-					if(allSeemsWell==null || allSeemsWell){
-						allSeemsWell = false;
-						if(logger.isDebugEnabled()){
-							logger.debug("checkWaitTimer: calling allSeemsWell with ALLNOTWELL param");
-						}
-						stateManagementFeature.allSeemsWell(this.getClass().getName(), 
-								StateManagementFeatureAPI.ALLNOTWELL_STATE,
-								"DesignationWaiter/ElectionHandler has STALLED");
-					}
-					logger.error("checkWaitTimer: nowMs - waitTimerMs = {}" 
-							+ ", exceeds 10* pdpUpdateInterval = {}"
-							+ " DesignationWaiter is STALLED!", (nowMs - waitTimerMs), (10*pdpUpdateInterval));
-				}else if(allSeemsWell==null || !allSeemsWell){
-					allSeemsWell = true;
-					stateManagementFeature.allSeemsWell(this.getClass().getName(), 
-							StateManagementFeatureAPI.ALLSEEMSWELL_STATE,
-							"DesignationWaiter/ElectionHandler has RESUMED");
-					logger.info("DesignationWaiter/ElectionHandler has RESUMED");
-				}
-				if(logger.isDebugEnabled()){
-					logger.debug("checkWaitTimer: exit");
-				}
-			}catch(Exception e){
-				logger.error("checkWaitTimer: caught unexpected exception: ", e);
-			}
-		}
-	}
-	
-	private long getDWaiterStartMs(){
-		Date now = new Date();
-		
-		// Retrieve the ms since the epoch
-		long nowMs = now.getTime();
-		
-		// Time since the end of the last pdpUpdateInterval multiple
-		long nowModMs = nowMs % pdpUpdateInterval;
-		
-		// Time to the start of the next pdpUpdateInterval multiple
-		long startMs = 2*pdpUpdateInterval - nowModMs;
+                        return;
+                    }
+                    isDesignated = false;
 
-		// Give the start time a minimum of a 5 second cushion
-		if(startMs < 5000){
-			// Start at the beginning  of following interval
-			startMs = pdpUpdateInterval + startMs;
-		}
-		return startMs;
-	}
-	
-	private boolean nullSafeEquals(Object one, Object two){
-		if(one == null && two == null){
-			return true;
-		}
-		if(one != null && two != null){
-			return one.equals(two);
-		}
-		return false;
-	}
-	
-	public String getPdpdNowActive(){
-		return pdpdNowActive;
-	}
-	
-	public String getPdpdLastActive(){
-		return pdpdLastActive;
-	}
+                } // end synchronized
+                if (logger.isDebugEnabled()) {
+                    logger.debug("DesignatedWaiter.run: myPdp: {}; Returning, isDesignated= {}",
+                            isDesignated, myPdp.getPdpId());
+                }
+
+                Date tmpDate = new Date();
+                if (logger.isDebugEnabled()) {
+                    logger.debug("DesignatedWaiter.run (end of run) waitTimerLastRunDate = {}", tmpDate);
+                }
+
+                waitTimerLastRunDate = tmpDate;
+                myPdp.setUpdatedDate(waitTimerLastRunDate);
+                pdpsConnector.update(myPdp);
+
+            } catch (Exception e) {
+                logger.error("DesignatedWaiter.run caught an unexpected exception: ", e);
+            }
+        } // end run
+    }
+
+    /**
+     * Sanitize designated list.
+     * 
+     * @param listOfDesignated list of designated pdps
+     * @return
+     */
+    public List<DroolsPdp> santizeDesignatedList(List<DroolsPdp> listOfDesignated) {
+
+        boolean containsDesignated = false;
+        boolean containsHotStandby = false;
+        List<DroolsPdp> listForRemoval = new ArrayList<>();
+        for (DroolsPdp pdp : listOfDesignated) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("DesignatedWaiter.run sanitizing: pdp = {}" 
+                        + " isDesignated = {}",pdp.getPdpId(), pdp.isDesignated());
+            }
+            if (pdp.isDesignated()) {
+                containsDesignated = true;
+            } else {
+                containsHotStandby = true;
+                listForRemoval.add(pdp);
+            }
+        }
+        if (containsDesignated && containsHotStandby) {
+            //remove the hot standby from the list
+            listOfDesignated.removeAll(listForRemoval);
+        }
+        return listOfDesignated;
+    }
+
+    /**
+     * Compute most recent primary.
+     * 
+     * @param pdps collection of pdps
+     * @param listOfDesignated list of designated pdps
+     * @return
+     */
+    public DroolsPdp computeMostRecentPrimary(Collection<DroolsPdp> pdps, List<DroolsPdp> listOfDesignated) {
+        boolean containsDesignated = false;
+        for (DroolsPdp pdp : listOfDesignated) {
+            if (pdp.isDesignated()) {
+                containsDesignated = true;
+            }
+        }
+        DroolsPdp mostRecentPrimary = new DroolsPdpImpl(null, true, 1, new Date(0));
+        mostRecentPrimary.setSiteName(null);
+        if (logger.isDebugEnabled()) {
+            logger.debug("DesignatedWaiter.run listOfDesignated.size() = {}", listOfDesignated.size());
+        }
+        if (listOfDesignated.size() <= 1) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("DesignatedWainter.run: listOfDesignated.size <=1");
+            }
+            //Only one or none is designated or hot standby.  Choose the latest designated date
+            for (DroolsPdp pdp : pdps) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("DesignatedWaiter.run pdp = {}" 
+                            + " pdp.getDesignatedDate() = {}", 
+                            pdp.getPdpId(), pdp.getDesignatedDate());
+                }
+                if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0) {
+                    mostRecentPrimary = pdp;
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", 
+                                mostRecentPrimary.getPdpId());
+                    }
+                }
+            }
+        } else if (listOfDesignated.size() == pdps.size()) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("DesignatedWainter.run: listOfDesignated.size = pdps.size() which is {}", pdps.size());
+            }
+            //They are all designated or all hot standby.
+            mostRecentPrimary = null;
+            for (DroolsPdp pdp : pdps) {
+                if (mostRecentPrimary == null) {
+                    mostRecentPrimary = pdp;
+                    continue;
+                }
+                if (containsDesignated) { //Choose the site of the first designated date
+                    if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) < 0) {
+                        mostRecentPrimary = pdp;
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
+                        }
+                    }
+                } else { //Choose the site with the latest designated date
+                    if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0) {
+                        mostRecentPrimary = pdp;
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
+                        }
+                    }
+                }
+            }
+        } else {
+            if (logger.isDebugEnabled()) {
+                logger.debug("DesignatedWainter.run: Some but not all are designated or hot standby. ");
+            }
+            //Some but not all are designated or hot standby. 
+            if (containsDesignated) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("DesignatedWainter.run: containsDesignated = {}", containsDesignated);
+                }
+                /*
+                 * The list only contains designated.  This is a problem.  It is most likely a race
+                 * condition that resulted in two thinking they should be designated. Choose the 
+                 * site with the latest designated date for the pdp not included on the designated list.
+                 * This should be the site that had the last designation before this race condition
+                 * occurred.
+                 */
+                for (DroolsPdp pdp : pdps) {
+                    if (listOfDesignated.contains(pdp)) {
+                        continue; //Don't consider this entry
+                    }
+                    if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0) {
+                        mostRecentPrimary = pdp;
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
+                        }
+                    }
+                }
+            } else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("DesignatedWainter.run: containsDesignated = {}", containsDesignated);
+                }
+                //The list only contains hot standby. Choose the site of the latest designated date
+                for (DroolsPdp pdp : pdps) {
+                    if (pdp.getDesignatedDate().compareTo(mostRecentPrimary.getDesignatedDate()) > 0) {
+                        mostRecentPrimary = pdp;
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("DesignatedWaiter.run mostRecentPrimary = {}", mostRecentPrimary.getPdpId());
+                        }
+                    }
+                }
+            }
+        }
+        return mostRecentPrimary;
+    }
+
+    /**
+     * Compue designated pdp.
+     * 
+     * @param listOfDesignated list of designated pdps
+     * @param mostRecentPrimary most recent primary pdpd
+     * @return
+     */
+    public DroolsPdp computeDesignatedPdp(List<DroolsPdp> listOfDesignated, DroolsPdp mostRecentPrimary) {
+        DroolsPdp designatedPdp = null;
+        DroolsPdp lowestPriorityPdp = null;
+        if (listOfDesignated.size() > 1) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("DesignatedWaiter.run: myPdp: {} listOfDesignated.size(): {}", myPdp.getPdpId(), 
+                        listOfDesignated.size());
+            }
+            DroolsPdp rejectedPdp = null;
+            DroolsPdp lowestPrioritySameSite = null;
+            DroolsPdp lowestPriorityDifferentSite = null;
+            for (DroolsPdp pdp : listOfDesignated) {
+                // We need to determine if another PDP is the lowest priority
+                if (nullSafeEquals(pdp.getSiteName(),mostRecentPrimary.getSiteName())) {
+                    if (lowestPrioritySameSite == null) {
+                        if (lowestPriorityDifferentSite != null) {
+                            rejectedPdp = lowestPriorityDifferentSite;
+                        }
+                        lowestPrioritySameSite = pdp;
+                    } else {
+                        if (pdp.getPdpId().equals((lowestPrioritySameSite.getPdpId()))) {
+                            continue;//nothing to compare
+                        }
+                        if (pdp.comparePriority(lowestPrioritySameSite) < 0) {
+                            if (logger.isDebugEnabled()) {
+                                logger.debug("\nDesignatedWaiter.run: myPdp {}  listOfDesignated pdp ID: {}" 
+                                        + " has lower priority than pdp ID: {}",myPdp.getPdpId(), pdp.getPdpId(),
+                                        lowestPrioritySameSite.getPdpId());
+                            }
+                            //we need to reject lowestPrioritySameSite
+                            rejectedPdp = lowestPrioritySameSite;
+                            lowestPrioritySameSite = pdp;
+                        } else {
+                            //we need to reject pdp and keep lowestPrioritySameSite
+                            if (logger.isDebugEnabled()) {
+                                logger.debug("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {} " 
+                                        + " has higher priority than pdp ID: {}", myPdp.getPdpId(),pdp.getPdpId(),
+                                        lowestPrioritySameSite.getPdpId());
+                            }
+                            rejectedPdp = pdp;
+                        }
+                    }
+                } else {
+                    if (lowestPrioritySameSite != null) {
+                        //if we already have a candidate for same site, we don't want to bother with different sites
+                        rejectedPdp = pdp;
+                    } else {
+                        if (lowestPriorityDifferentSite == null) {
+                            lowestPriorityDifferentSite = pdp;
+                            continue;
+                        }
+                        if (pdp.getPdpId().equals((lowestPriorityDifferentSite.getPdpId()))) {
+                            continue;//nothing to compare
+                        }
+                        if (pdp.comparePriority(lowestPriorityDifferentSite) < 0) {
+                            if (logger.isDebugEnabled()) {
+                                logger.debug("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {}" 
+                                        + " has lower priority than pdp ID: {}", myPdp.getPdpId(), pdp.getPdpId(),
+                                        lowestPriorityDifferentSite.getPdpId());
+                            }
+                            //we need to reject lowestPriorityDifferentSite
+                            rejectedPdp = lowestPriorityDifferentSite;
+                            lowestPriorityDifferentSite = pdp;
+                        } else {
+                            //we need to reject pdp and keep lowestPriorityDifferentSite
+                            if (logger.isDebugEnabled()) {
+                                logger.debug("\nDesignatedWaiter.run: myPdp {} listOfDesignated pdp ID: {}" 
+                                        + " has higher priority than pdp ID: {}", myPdp.getPdpId(), pdp.getPdpId(),
+                                        lowestPriorityDifferentSite.getPdpId());
+                            }
+                            rejectedPdp = pdp;
+                        }
+                    }
+                }
+                // If the rejectedPdp is myPdp, we need to stand it down and demote it.  Each pdp is responsible
+                // for demoting itself
+                if (rejectedPdp != null && nullSafeEquals(rejectedPdp.getPdpId(),myPdp.getPdpId())) {
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("\n\nDesignatedWaiter.run: myPdp: {} listOfDesignated myPdp ID: {}" 
+                                + " is NOT the lowest priority.  Executing stateManagement.demote()\n\n", 
+                                myPdp.getPdpId(),
+                                myPdp.getPdpId());
+                    }
+                    // We found that myPdp is on the listOfDesignated and it is not the lowest priority
+                    // So, we must demote it
+                    try {
+                        //Keep the order like this.  StateManagement is last since it triggers controller shutdown
+                        myPdp.setDesignated(false);
+                        pdpsConnector.setDesignated(myPdp, false);
+                        isDesignated = false;
+                        String standbyStatus = stateManagementFeature.getStandbyStatus();
+                        if (!(standbyStatus.equals(StateManagement.HOT_STANDBY) 
+                                || standbyStatus.equals(StateManagement.COLD_STANDBY))) {
+                            /*
+                             * Only call demote if it is not already in the right state.  Don't worry about
+                             * synching the lower level topic endpoint states.  That is done by the
+                             * refreshStateAudit.
+                             */
+                            stateManagementFeature.demote();
+                        }
+                    } catch (Exception e) {
+                        myPdp.setDesignated(false);
+                        pdpsConnector.setDesignated(myPdp, false);
+                        isDesignated = false;
+                        logger.error("DesignatedWaiter.run: myPdp: {} Caught Exception attempting to "
+                                + "demote myPdp {} myPdp.getPdpId(), message= {}", myPdp.getPdpId(), 
+                                e);
+                    }
+                }
+            } //end: for(DroolsPdp pdp : listOfDesignated)
+            if (lowestPrioritySameSite != null) {
+                lowestPriorityPdp = lowestPrioritySameSite;
+            } else {
+                lowestPriorityPdp = lowestPriorityDifferentSite;
+            }
+            //now we have a valid value for lowestPriorityPdp
+            if (logger.isDebugEnabled()) {
+                logger.debug("\n\nDesignatedWaiter.run: myPdp: {} listOfDesignated "
+                        + "found the LOWEST priority pdp ID: {} " 
+                        + " It is now the designatedPpd from the perspective of myPdp ID: {} \n\n",
+                        myPdp.getPdpId(), lowestPriorityPdp.getPdpId(), myPdp);
+            }
+            designatedPdp = lowestPriorityPdp;
+
+        } else if (listOfDesignated.isEmpty()) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("\nDesignatedWaiter.run: myPdp: {} listOfDesignated is: EMPTY.", myPdp.getPdpId());
+            }
+            designatedPdp = null;
+        } else { //only one in listOfDesignated
+            if (logger.isDebugEnabled()) {
+                logger.debug("\nDesignatedWaiter.run: myPdp: {} listOfDesignated "
+                        + "has ONE entry. PDP ID: {}", myPdp.getPdpId(), listOfDesignated.get(0).getPdpId());
+            }
+            designatedPdp = listOfDesignated.get(0);
+        }
+        return designatedPdp;
+
+    }
+
+    private class TimerUpdateClass extends TimerTask {
+
+        @Override
+        public void run() {
+            try {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("TimerUpdateClass.run: entry");
+                }
+                checkWaitTimer();
+            } catch (Exception e) {
+                logger.error("TimerUpdateClass.run caught an unexpected exception: ", e);
+            }
+            if (logger.isDebugEnabled()) {
+                logger.debug("TimerUpdateClass.run.exit");
+            }
+        }
+    }
+    
+    @Override
+    public void checkThreadStatus() {
+        checkWaitTimer();
+    }
+
+    private void checkWaitTimer() {
+        synchronized (checkWaitTimerLock) {
+            try {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("checkWaitTimer: entry");
+                }
+                Date now = new Date();
+                long nowMs = now.getTime();
+                long waitTimerMs = waitTimerLastRunDate.getTime();
+
+                //give it 10 times leeway  
+                if ((nowMs - waitTimerMs)  > 10 * pdpUpdateInterval) {
+                    if (allSeemsWell == null || allSeemsWell) {
+                        allSeemsWell = false;
+                        if (logger.isDebugEnabled()) {
+                            logger.debug("checkWaitTimer: calling allSeemsWell with ALLNOTWELL param");
+                        }
+                        stateManagementFeature.allSeemsWell(this.getClass().getName(), 
+                                StateManagementFeatureAPI.ALLNOTWELL_STATE,
+                                "DesignationWaiter/ElectionHandler has STALLED");
+                    }
+                    logger.error("checkWaitTimer: nowMs - waitTimerMs = {}" 
+                            + ", exceeds 10* pdpUpdateInterval = {}"
+                            + " DesignationWaiter is STALLED!", (nowMs - waitTimerMs), (10 * pdpUpdateInterval));
+                } else if (allSeemsWell == null || !allSeemsWell) {
+                    allSeemsWell = true;
+                    stateManagementFeature.allSeemsWell(this.getClass().getName(), 
+                            StateManagementFeatureAPI.ALLSEEMSWELL_STATE,
+                            "DesignationWaiter/ElectionHandler has RESUMED");
+                    logger.info("DesignationWaiter/ElectionHandler has RESUMED");
+                }
+                if (logger.isDebugEnabled()) {
+                    logger.debug("checkWaitTimer: exit");
+                }
+            } catch (Exception e) {
+                logger.error("checkWaitTimer: caught unexpected exception: ", e);
+            }
+        }
+    }
+
+    private long getDWaiterStartMs() {
+        Date now = new Date();
+
+        // Retrieve the ms since the epoch
+        long nowMs = now.getTime();
+
+        // Time since the end of the last pdpUpdateInterval multiple
+        long nowModMs = nowMs % pdpUpdateInterval;
+
+        // Time to the start of the next pdpUpdateInterval multiple
+        long startMs = 2 * pdpUpdateInterval - nowModMs;
+
+        // Give the start time a minimum of a 5 second cushion
+        if (startMs < 5000) {
+            // Start at the beginning  of following interval
+            startMs = pdpUpdateInterval + startMs;
+        }
+        return startMs;
+    }
+
+    private boolean nullSafeEquals(Object one, Object two) {
+        if (one == null && two == null) {
+            return true;
+        }
+        if (one != null && two != null) {
+            return one.equals(two);
+        }
+        return false;
+    }
+
+    public String getPdpdNowActive() {
+        return pdpdNowActive;
+    }
+
+    public String getPdpdLastActive() {
+        return pdpdLastActive;
+    }
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java
index dc907b2..0444805 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/JpaDroolsPdpsConnector.java
@@ -36,599 +36,599 @@
 
 public class JpaDroolsPdpsConnector implements DroolsPdpsConnector {
 
-	// get an instance of logger 
-	private static final Logger  logger = LoggerFactory.getLogger(JpaDroolsPdpsConnector.class);
-	private EntityManagerFactory emf;
-		
-	
-	//not sure if we want to use the same entity manager factory for drools session and pass it in here, or create a new one
-	public JpaDroolsPdpsConnector(EntityManagerFactory emf){
-		this.emf = emf;		
-	}
-	@Override
-	public Collection<DroolsPdp> getDroolsPdps() {
-		//return a list of all the DroolsPdps in the database
-		EntityManager em = emf.createEntityManager();
-		try {
-			em.getTransaction().begin();
-			Query droolsPdpsListQuery = em.createQuery("SELECT p FROM DroolsPdpEntity p");
-			List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
-			LinkedList<DroolsPdp> droolsPdpsReturnList = new LinkedList<>();
-			for(Object o : droolsPdpsList){
-				if(o instanceof DroolsPdp){
-					//Make sure it is not a cached version
-					em.refresh((DroolsPdpEntity)o);
-					droolsPdpsReturnList.add((DroolsPdp)o);
-					if (logger.isDebugEnabled()) {
-						DroolsPdp droolsPdp = (DroolsPdp)o;
-						logger.debug("getDroolsPdps: PDP= {}"
-								+ ", isDesignated= {}"
-								+ ", updatedDate= {}"
-								+ ", priority= {}", droolsPdp.getPdpId(), droolsPdp.isDesignated(),
-								 droolsPdp.getUpdatedDate(), droolsPdp.getPriority());
-					}
-				}
-			}
-			try{
-			em.getTransaction().commit();
-			}catch(Exception e){
-				  logger.error
-					("Cannot commit getDroolsPdps() transaction", e);
-			}
-			return droolsPdpsReturnList;
-		} finally {
-			cleanup(em, "getDroolsPdps");
-		}
-	}
+    // get an instance of logger 
+    private static final Logger  logger = LoggerFactory.getLogger(JpaDroolsPdpsConnector.class);
+    private EntityManagerFactory emf;
 
-	private boolean nullSafeEquals(Object one, Object two){
-		if(one == null && two == null){
-			return true;
-		}
-		if(one != null && two != null){
-			return one.equals(two);
-		}
-		return false;
-	}
-	
-	@Override
-	public void update(DroolsPdp pdp) {
-		
-		if (logger.isDebugEnabled()) {
-			logger.debug("update: Entering, pdpId={}", pdp.getPdpId());
-		}
-		
-		//this is to update our own pdp in the database
-		EntityManager em = emf.createEntityManager();
-		try {
-			em.getTransaction().begin();
-			Query droolsPdpsListQuery = em.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
-			droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
-			List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
-			DroolsPdpEntity droolsPdpEntity;
-			if(droolsPdpsList.size() == 1 && (droolsPdpsList.get(0) instanceof DroolsPdpEntity)){						
-				droolsPdpEntity = (DroolsPdpEntity)droolsPdpsList.get(0);
-				em.refresh(droolsPdpEntity); //Make sure we have current values
-				Date currentDate = new Date();
-				long difference = currentDate.getTime()-droolsPdpEntity.getUpdatedDate().getTime();
-				//just set some kind of default here
-				long pdpTimeout = 15000;
-				try{
-					pdpTimeout = Long.parseLong(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_TIMEOUT));
-				}catch(Exception e){
-					  logger.error
-						("Could not get PDP timeout property, using default.", e);
-				}
-				boolean isCurrent = difference<pdpTimeout;
-				if (logger.isDebugEnabled()) {
-					logger.debug("update: PDP= {}, isCurrent={}"
-							+ " difference= {}"
-							+ ", pdpTimeout= {}, designated= {}",
-							pdp.getPdpId(), isCurrent, difference, pdpTimeout, droolsPdpEntity.isDesignated());
-				}
-			} else {
-				if (logger.isDebugEnabled()) {
-					logger.debug("update: For PDP={}"
-							+ ", instantiating new DroolsPdpEntity", pdp.getPdpId());
-				}
-				droolsPdpEntity = new DroolsPdpEntity();
-				em.persist(droolsPdpEntity);
-				droolsPdpEntity.setPdpId(pdp.getPdpId());				
-			}
-			if(droolsPdpEntity.getPriority() != pdp.getPriority()){
-				droolsPdpEntity.setPriority(pdp.getPriority());
-			}
-			if(!droolsPdpEntity.getUpdatedDate().equals(pdp.getUpdatedDate())){
-				droolsPdpEntity.setUpdatedDate(pdp.getUpdatedDate());
-			}
-			/*if(!droolsPdpEntity.getDesignatedDate().equals(pdp.getDesignatedDate())){
-				droolsPdpEntity.setDesignatedDate(pdp.getDesignatedDate());
-			} The designated date is only set below when this first becomes designated*/
-			if(!nullSafeEquals(droolsPdpEntity.getSiteName(),pdp.getSiteName())){
-				droolsPdpEntity.setSiteName(pdp.getSiteName());
-			}
-			
-			if(droolsPdpEntity.isDesignated() != pdp.isDesignated()){
-				if (logger.isDebugEnabled()) {
-					logger.debug("update: pdpId={}"
-							+ ", pdp.isDesignated={}"
-							+ ", droolsPdpEntity.pdpId= {}"
-							+ ", droolsPdpEntity.isDesignated={}",
-							 pdp.getPdpId(), pdp.isDesignated(),droolsPdpEntity.getPdpId(), droolsPdpEntity.isDesignated());
-				}
-				droolsPdpEntity.setDesignated(pdp.isDesignated());
-				//The isDesignated value is not the same and the new one == true
-				if(pdp.isDesignated()){
-					droolsPdpEntity.setDesignatedDate(new Date());
-				}
-			}
-			em.getTransaction().commit();
-		} finally {
-			cleanup(em, "update");
-		}
-		
-		if (logger.isDebugEnabled()) {
-			logger.debug("update: Exiting");
-		}
 
-	}
+    //not sure if we want to use the same entity manager factory 
+    //for drools session and pass it in here, or create a new one
+    public JpaDroolsPdpsConnector(EntityManagerFactory emf) {
+        this.emf = emf;
+    }
+    
+    @Override
+    public Collection<DroolsPdp> getDroolsPdps() {
+        //return a list of all the DroolsPdps in the database
+        EntityManager em = emf.createEntityManager();
+        try {
+            em.getTransaction().begin();
+            Query droolsPdpsListQuery = em.createQuery("SELECT p FROM DroolsPdpEntity p");
+            List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(LockModeType.NONE)
+                    .setFlushMode(FlushModeType.COMMIT).getResultList();
+            LinkedList<DroolsPdp> droolsPdpsReturnList = new LinkedList<>();
+            for (Object o : droolsPdpsList) {
+                if (o instanceof DroolsPdp) {
+                    //Make sure it is not a cached version
+                    em.refresh((DroolsPdpEntity)o);
+                    droolsPdpsReturnList.add((DroolsPdp)o);
+                    if (logger.isDebugEnabled()) {
+                        DroolsPdp droolsPdp = (DroolsPdp)o;
+                        logger.debug("getDroolsPdps: PDP= {}"
+                                + ", isDesignated= {}"
+                                + ", updatedDate= {}"
+                                + ", priority= {}", droolsPdp.getPdpId(), droolsPdp.isDesignated(),
+                                droolsPdp.getUpdatedDate(), droolsPdp.getPriority());
+                    }
+                }
+            }
+            try {
+                em.getTransaction().commit();
+            } catch (Exception e) {
+                logger.error("Cannot commit getDroolsPdps() transaction", e);
+            }
+            return droolsPdpsReturnList;
+        } finally {
+            cleanup(em, "getDroolsPdps");
+        }
+    }
 
-	/*
-	 * Note: A side effect of this boolean method is that if the PDP is designated but not current, the 
-	 * droolspdpentity.DESIGNATED column will be set to false (the PDP will be un-designated, i.e. marked as
-	 * being in standby mode)
-	 */
-	@Override
-	public boolean isPdpCurrent(DroolsPdp pdp) {
-		
-		boolean isCurrent = isCurrent(pdp);
-		
-		EntityManager em = emf.createEntityManager();
-		try{
-		if(!isCurrent && pdp.isDesignated()){
-			em.getTransaction().begin();
-			Query droolsPdpsListQuery = em.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
-			droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
-			List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
-			if(droolsPdpsList.size() == 1 && droolsPdpsList.get(0) instanceof DroolsPdpEntity){			
-				if (logger.isDebugEnabled()) {
-					logger.debug("isPdpCurrent: PDP={}  designated but not current; setting designated to false", pdp.getPdpId());
-				}
-				DroolsPdpEntity droolsPdpEntity = (DroolsPdpEntity)droolsPdpsList.get(0);
-				droolsPdpEntity.setDesignated(false);
-				em.getTransaction().commit();
-			} else {
-				logger.warn("isPdpCurrent: PDP={} is designated but not current; "
-						+ "however it does not have a DB entry, so cannot set DESIGNATED to false!", pdp.getPdpId());
-			}
-		} else {
-			if (logger.isDebugEnabled()) {
-				logger.debug("isPdpCurrent: For PDP= {}, "
-						+ "designated={}, isCurrent={}", pdp.getPdpId(), pdp.isDesignated(), isCurrent);
-			}
-		}
-		}catch(Exception e){
-			  logger.error
-				("Could not update expired record marked as designated in the database", e);
-		} finally {
-			cleanup(em, "isPdpCurrent");
-		}
-		return isCurrent;
-		
-	}
-	
-	@Override
-	public void setDesignated(DroolsPdp pdp, boolean designated) {
+    private boolean nullSafeEquals(Object one, Object two) {
+        if (one == null && two == null) {
+            return true;
+        }
+        if (one != null && two != null) {
+            return one.equals(two);
+        }
+        return false;
+    }
 
-		if (logger.isDebugEnabled()) {
-			logger.debug("setDesignated: Entering, pdpId={}"
-					+ ", designated={}", pdp.getPdpId(), designated);
-		}
+    @Override
+    public void update(DroolsPdp pdp) {
 
-		EntityManager em = null;
-		try {
-			em = emf.createEntityManager();
-			em.getTransaction().begin();
-			Query droolsPdpsListQuery = em
-					.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
-			droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
-			List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
-					LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
-			if (droolsPdpsList.size() == 1
-					&& droolsPdpsList.get(0) instanceof DroolsPdpEntity) {
-				DroolsPdpEntity droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList
-						.get(0);
+        if (logger.isDebugEnabled()) {
+            logger.debug("update: Entering, pdpId={}", pdp.getPdpId());
+        }
 
-				if (logger.isDebugEnabled()) {
-					logger.debug("setDesignated: PDP={}"
-							+ " found, designated= {}"
-							+ ", setting to {}", pdp.getPdpId(), droolsPdpEntity.isDesignated(),
-							 designated);
-				}
-				droolsPdpEntity.setDesignated(designated);
-				if(designated){
-					em.refresh(droolsPdpEntity); //make sure we get the DB value
-					if(!droolsPdpEntity.isDesignated()){ 
-						droolsPdpEntity.setDesignatedDate(new Date());
-					}
-				
-				}
-				em.getTransaction().commit();
-			} else {
-				logger.error("setDesignated: PDP={}"
-						+ " not in DB; cannot update designation", pdp.getPdpId());
-			}
-		} catch (Exception e) {
-			logger.error("setDesignated: Caught Exception", e);
-		} finally {
-			cleanup(em, "setDesignated");
-		}
+        //this is to update our own pdp in the database
+        EntityManager em = emf.createEntityManager();
+        try {
+            em.getTransaction().begin();
+            Query droolsPdpsListQuery = em.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
+            droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
+            List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(LockModeType.NONE)
+                    .setFlushMode(FlushModeType.COMMIT).getResultList();
+            DroolsPdpEntity droolsPdpEntity;
+            if (droolsPdpsList.size() == 1 && (droolsPdpsList.get(0) instanceof DroolsPdpEntity)) {
+                droolsPdpEntity = (DroolsPdpEntity)droolsPdpsList.get(0);
+                em.refresh(droolsPdpEntity); //Make sure we have current values
+                Date currentDate = new Date();
+                long difference = currentDate.getTime() - droolsPdpEntity.getUpdatedDate().getTime();
+                //just set some kind of default here
+                long pdpTimeout = 15000;
+                try {
+                    pdpTimeout = Long.parseLong(
+                            ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_TIMEOUT));
+                } catch (Exception e) {
+                    logger.error("Could not get PDP timeout property, using default.", e);
+                }
+                boolean isCurrent = difference < pdpTimeout;
+                if (logger.isDebugEnabled()) {
+                    logger.debug("update: PDP= {}, isCurrent={}"
+                            + " difference= {}"
+                            + ", pdpTimeout= {}, designated= {}",
+                            pdp.getPdpId(), isCurrent, difference, pdpTimeout, droolsPdpEntity.isDesignated());
+                }
+            } else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("update: For PDP={}"
+                            + ", instantiating new DroolsPdpEntity", pdp.getPdpId());
+                }
+                droolsPdpEntity = new DroolsPdpEntity();
+                em.persist(droolsPdpEntity);
+                droolsPdpEntity.setPdpId(pdp.getPdpId());
+            }
+            if (droolsPdpEntity.getPriority() != pdp.getPriority()) {
+                droolsPdpEntity.setPriority(pdp.getPriority());
+            }
+            if (!droolsPdpEntity.getUpdatedDate().equals(pdp.getUpdatedDate())) {
+                droolsPdpEntity.setUpdatedDate(pdp.getUpdatedDate());
+            }
+            if (!nullSafeEquals(droolsPdpEntity.getSiteName(),pdp.getSiteName())) {
+                droolsPdpEntity.setSiteName(pdp.getSiteName());
+            }
 
-		if (logger.isDebugEnabled()) {
-			logger.debug("setDesignated: Exiting");
-		}
+            if (droolsPdpEntity.isDesignated() != pdp.isDesignated()) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("update: pdpId={}"
+                            + ", pdp.isDesignated={}"
+                            + ", droolsPdpEntity.pdpId= {}"
+                            + ", droolsPdpEntity.isDesignated={}",
+                            pdp.getPdpId(), pdp.isDesignated(),
+                            droolsPdpEntity.getPdpId(), droolsPdpEntity.isDesignated());
+                }
+                droolsPdpEntity.setDesignated(pdp.isDesignated());
+                //The isDesignated value is not the same and the new one == true
+                if (pdp.isDesignated()) {
+                    droolsPdpEntity.setDesignatedDate(new Date());
+                }
+            }
+            em.getTransaction().commit();
+        } finally {
+            cleanup(em, "update");
+        }
 
-	}
-	
-	
-	@Override
-	public void standDownPdp(String pdpId) {
-		if(logger.isDebugEnabled()){
-			logger.debug("standDownPdp: Entering, pdpId={}", pdpId);
-		}
+        if (logger.isDebugEnabled()) {
+            logger.debug("update: Exiting");
+        }
 
-		EntityManager em = null;
-		try {
-			/*
-			 * Start transaction.
-			 */
-			em = emf.createEntityManager();
-			em.getTransaction().begin();
+    }
 
-			/*
-			 * Get droolspdpentity record for this PDP and mark DESIGNATED as
-			 * false.
-			 */
-			Query droolsPdpsListQuery = em
-					.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
-			droolsPdpsListQuery.setParameter("pdpId", pdpId);
-			List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
-					LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
-			DroolsPdpEntity droolsPdpEntity;
-			if (droolsPdpsList.size() == 1
-					&& (droolsPdpsList.get(0) instanceof DroolsPdpEntity)) {
-				droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList.get(0);
-				droolsPdpEntity.setDesignated(false);
-				em.persist(droolsPdpEntity);
-				if(logger.isDebugEnabled()){
-					logger.debug("standDownPdp: PDP={} persisted as non-designated.", pdpId );
-				}
-			} else {
-				logger.error("standDownPdp: Missing record in droolspdpentity for pdpId={}"
-						+ "; cannot stand down PDP", pdpId);
-			}
+    /*
+     * Note: A side effect of this boolean method is that if the PDP is designated but not current, the 
+     * droolspdpentity.DESIGNATED column will be set to false (the PDP will be un-designated, i.e. marked as
+     * being in standby mode)
+     */
+    @Override
+    public boolean isPdpCurrent(DroolsPdp pdp) {
 
-			/*
-			 * End transaction.
-			 */
-			em.getTransaction().commit();
-			cleanup(em, "standDownPdp");
-			em = null;
-			
-			// Keep the election handler in sync with the DB
-			DroolsPdpsElectionHandler.setMyPdpDesignated(false);
+        boolean isCurrent = isCurrent(pdp);
 
-		} catch (Exception e) {
-			logger.error("standDownPdp: Unexpected Exception attempting to mark "
-					+ "DESIGNATED as false for droolspdpentity, pdpId={}"
-					+ ".  Cannot stand down PDP; message={}", pdpId, e.getMessage(), e);
-		} finally {
-			cleanup(em, "standDownPdp");
-		}
-		if(logger.isDebugEnabled()){
-			logger.debug("standDownPdp: Exiting");
-		}
+        EntityManager em = emf.createEntityManager();
+        try {
+            if (!isCurrent && pdp.isDesignated()) {
+                em.getTransaction().begin();
+                Query droolsPdpsListQuery = em.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
+                droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
+                List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(LockModeType.NONE)
+                        .setFlushMode(FlushModeType.COMMIT).getResultList();
+                if (droolsPdpsList.size() == 1 && droolsPdpsList.get(0) instanceof DroolsPdpEntity) {
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("isPdpCurrent: PDP={}  designated but not current; setting designated to false", 
+                                pdp.getPdpId());
+                    }
+                    DroolsPdpEntity droolsPdpEntity = (DroolsPdpEntity)droolsPdpsList.get(0);
+                    droolsPdpEntity.setDesignated(false);
+                    em.getTransaction().commit();
+                } else {
+                    logger.warn("isPdpCurrent: PDP={} is designated but not current; "
+                            + "however it does not have a DB entry, so cannot set DESIGNATED to false!", 
+                            pdp.getPdpId());
+                }
+            } else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("isPdpCurrent: For PDP= {}, "
+                            + "designated={}, isCurrent={}", pdp.getPdpId(), pdp.isDesignated(), isCurrent);
+                }
+            }
+        } catch (Exception e) {
+            logger.error("Could not update expired record marked as designated in the database", e);
+        } finally {
+            cleanup(em, "isPdpCurrent");
+        }
+        return isCurrent;
 
-	}
-	
-	/*
-	 * Determines whether or not a designated PDP has failed.
-	 * 
-	 * Note: The update method, which is run periodically by the
-	 * TimerUpdateClass, will un-designate a PDP that is stale.
-	 */
-	@Override
-	public boolean hasDesignatedPdpFailed(Collection<DroolsPdp> pdps) {
+    }
 
-		if (logger.isDebugEnabled()) {
-			logger.debug("hasDesignatedPdpFailed: Entering, pdps.size()={}", pdps.size());
-		}
+    @Override
+    public void setDesignated(DroolsPdp pdp, boolean designated) {
 
-		boolean failed = true;
-		boolean foundDesignatedPdp = false;
+        if (logger.isDebugEnabled()) {
+            logger.debug("setDesignated: Entering, pdpId={}"
+                    + ", designated={}", pdp.getPdpId(), designated);
+        }
 
-		for (DroolsPdp pdp : pdps) {
+        EntityManager em = null;
+        try {
+            em = emf.createEntityManager();
+            em.getTransaction().begin();
+            Query droolsPdpsListQuery = em
+                    .createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
+            droolsPdpsListQuery.setParameter("pdpId", pdp.getPdpId());
+            List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
+                    LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+            if (droolsPdpsList.size() == 1
+                    && droolsPdpsList.get(0) instanceof DroolsPdpEntity) {
+                DroolsPdpEntity droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList
+                        .get(0);
 
-			/*
-			 * Normally, the update method will un-designate any stale PDP, but
-			 * we check here to see if the PDP has gone stale since the update
-			 * method was run.
-			 * 
-			 * Even if we determine that the designated PDP is current, we keep
-			 * going (we don't break), so we can get visibility into the other
-			 * PDPs, when in DEBUG mode.
-			 */
-			if (pdp.isDesignated() && isCurrent(pdp)) {
-				if (logger.isDebugEnabled()) {
-					logger.debug("hasDesignatedPdpFailed: Designated PDP={} is current", pdp.getPdpId());
-				}
-				failed = false;
-				foundDesignatedPdp = true;
-			} else if (pdp.isDesignated() && !isCurrent(pdp)) {
-				logger.error("hasDesignatedPdpFailed: Designated PDP={} has failed", pdp.getPdpId());
-				foundDesignatedPdp = true;
-			} else {
-				if (logger.isDebugEnabled()) {
-					logger.debug("hasDesignatedPdpFailed: PDP={} is not designated", pdp.getPdpId());
-				}
-			}
-		}
+                if (logger.isDebugEnabled()) {
+                    logger.debug("setDesignated: PDP={}"
+                            + " found, designated= {}"
+                            + ", setting to {}", pdp.getPdpId(), droolsPdpEntity.isDesignated(),
+                            designated);
+                }
+                droolsPdpEntity.setDesignated(designated);
+                if (designated) {
+                    em.refresh(droolsPdpEntity); //make sure we get the DB value
+                    if (!droolsPdpEntity.isDesignated()) { 
+                        droolsPdpEntity.setDesignatedDate(new Date());
+                    }
 
-		if (logger.isDebugEnabled()) {
-			logger.debug("hasDesignatedPdpFailed: Exiting and returning, foundDesignatedPdp={}",
-					foundDesignatedPdp);
-		}
-		return failed;
-	}
-	
-	
-	private boolean isCurrent(DroolsPdp pdp) {
-	
-		if (logger.isDebugEnabled()) {
-			logger.debug("isCurrent: Entering, pdpId={}", pdp.getPdpId());
-		}
-	
-		boolean current = false;
-	
-		// Return if the current PDP is considered "current" based on whatever
-		// time box that may be.
-		// If the the PDP is not current, we should mark it as not primary in
-		// the database
-		Date currentDate = new Date();
-		long difference = currentDate.getTime()
-				- pdp.getUpdatedDate().getTime();
-		// just set some kind of default here
-		long pdpTimeout = 15000;
-		try {
-			pdpTimeout = Long.parseLong(ActiveStandbyProperties
-					.getProperty(ActiveStandbyProperties.PDP_TIMEOUT));
-			if (logger.isDebugEnabled()) {
-				logger.debug("isCurrent: pdp.timeout={}", pdpTimeout);
-			}		
-		} catch (Exception e) {
-			  logger.error
-				("isCurrent: Could not get PDP timeout property, using default.", e);
-		}
-		current = difference < pdpTimeout;
-	
-		if (logger.isDebugEnabled()) {
-			logger.debug("isCurrent: Exiting, difference={}, pdpTimeout={}"
-					+ "; returning current={}", difference, pdpTimeout, current);
-		}
-	
-		return current;
-	}
-	
-	
-	/*
-	 * Currently this method is only used in a JUnit test environment. Gets a
-	 * PDP record from droolspdpentity table.
-	 */
-	@Override
-	public DroolsPdpEntity getPdp(String pdpId) {
-	
-		if (logger.isDebugEnabled()) {
-			logger.debug("getPdp: Entering and getting PDP with pdpId={}", pdpId);
-		}
-	
-		DroolsPdpEntity droolsPdpEntity = null;
-	
-		EntityManager em = null;
-		try {
-			em = emf.createEntityManager();
-			em.getTransaction().begin();
-			Query droolsPdpsListQuery = em
-					.createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
-			droolsPdpsListQuery.setParameter("pdpId", pdpId);
-			List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
-					LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
-			if (droolsPdpsList.size() == 1
-					&& droolsPdpsList.get(0) instanceof DroolsPdpEntity) {
-				droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList.get(0);
-				if (logger.isDebugEnabled()) {
-					logger.debug("getPdp: PDP={}"
-							+ " found, isDesignated={},"
-							+ " updatedDate={}, "
-							+ "priority={}", pdpId,
-							droolsPdpEntity.isDesignated(), droolsPdpEntity.getUpdatedDate(),
-							droolsPdpEntity.getPriority());							
-				}
-				
-				// Make sure the droolsPdpEntity is not a cached version
-				em.refresh(droolsPdpEntity);
-				
-				em.getTransaction().commit();
-			} else {
-				logger.error("getPdp: PDP={} not found!?", pdpId);
-			}
-		} catch (Exception e) {
-			  logger.error
-				("getPdp: Caught Exception attempting to get PDP", e);
-		} finally {
-			cleanup(em, "getPdp");
-		}
-	
-		if (logger.isDebugEnabled()) {
-			logger.debug("getPdp: Returning droolsPdpEntity={}", droolsPdpEntity);
-		}
-		return droolsPdpEntity;
-	
-	}
-	
-	/*
-	 * Normally this method should only be used in a JUnit test environment.
-	 * Manually inserts a PDP record in droolspdpentity table.
-	 */
-	@Override
-	public void insertPdp(DroolsPdp pdp) {
-		if(logger.isDebugEnabled()){
-			logger.debug("insertPdp: Entering and manually inserting PDP");
-		}
+                }
+                em.getTransaction().commit();
+            } else {
+                logger.error("setDesignated: PDP={}"
+                        + " not in DB; cannot update designation", pdp.getPdpId());
+            }
+        } catch (Exception e) {
+            logger.error("setDesignated: Caught Exception", e);
+        } finally {
+            cleanup(em, "setDesignated");
+        }
 
-		/*
-		 * Start transaction
-		 */
-		EntityManager em = emf.createEntityManager();
-		try {
-			em.getTransaction().begin();
+        if (logger.isDebugEnabled()) {
+            logger.debug("setDesignated: Exiting");
+        }
 
-			/*
-			 * Insert record.
-			 */
-			DroolsPdpEntity droolsPdpEntity = new DroolsPdpEntity();
-			em.persist(droolsPdpEntity);
-			droolsPdpEntity.setPdpId(pdp.getPdpId());
-			droolsPdpEntity.setDesignated(pdp.isDesignated());
-			droolsPdpEntity.setPriority(pdp.getPriority());
-			droolsPdpEntity.setUpdatedDate(pdp.getUpdatedDate());
-			droolsPdpEntity.setSiteName(pdp.getSiteName());
+    }
 
-			/*
-			 * End transaction.
-			 */
-			em.getTransaction().commit();
-		} finally {
-			cleanup(em, "insertPdp");
-		}
-		if(logger.isDebugEnabled()){
-			logger.debug("insertPdp: Exiting");
-		}
 
-	}
-	
-	/*
-	 * Normally this method should only be used in a JUnit test environment.
-	 * Manually deletes all PDP records in droolspdpentity table.
-	 */
-	@Override
-	public void deleteAllPdps() {
-	
-		if(logger.isDebugEnabled()){
-			logger.debug("deleteAllPdps: Entering");
-		}
-	
-		/*
-		 * Start transaction
-		 */
-		EntityManager em = emf.createEntityManager();
-		try {
-			em.getTransaction().begin();
-	
-			Query droolsPdpsListQuery = em
-					.createQuery("SELECT p FROM DroolsPdpEntity p");
-			@SuppressWarnings("unchecked")
-			List<DroolsPdp> droolsPdpsList = droolsPdpsListQuery.setLockMode(
-					LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
-			if(logger.isDebugEnabled()){
-				logger.debug("deleteAllPdps: Deleting {} PDPs", droolsPdpsList.size());
-			}
-			for (DroolsPdp droolsPdp : droolsPdpsList) {
-				String pdpId = droolsPdp.getPdpId();
-				deletePdp(pdpId);
-			}
-	
-			/*
-			 * End transaction.
-			 */
-			em.getTransaction().commit();
-		} finally {
-			cleanup(em, "deleteAllPdps");
-		}
-		if(logger.isDebugEnabled()){
-			logger.debug("deleteAllPdps: Exiting");
-		}
-	
-	}
-	
-	/*
-	 * Normally this method should only be used in a JUnit test environment.
-	 * Manually deletes a PDP record in droolspdpentity table.
-	 */
-	@Override
-	public void deletePdp(String pdpId) {
-		if(logger.isDebugEnabled()){
-			logger.debug("deletePdp: Entering and manually deleting pdpId={}", pdpId);
-		}
-	
-		/*
-		 * Start transaction
-		 */
-		EntityManager em = emf.createEntityManager();
-		try {
-			em.getTransaction().begin();
-		
-			/*
-			 * Delete record.
-			 */
-			DroolsPdpEntity droolsPdpEntity = em.find(DroolsPdpEntity.class, pdpId);
-			if (droolsPdpEntity != null) {
-				if(logger.isDebugEnabled()){
-					logger.debug("deletePdp: Removing PDP");
-				}
-				em.remove(droolsPdpEntity);
-			} else {
-				if(logger.isDebugEnabled()){
-					logger.debug("deletePdp: PDP with ID={} not currently in DB", pdpId);
-				}
-			}
+    @Override
+    public void standDownPdp(String pdpId) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("standDownPdp: Entering, pdpId={}", pdpId);
+        }
 
-			/*
-			 * End transaction.
-			 */
-			em.getTransaction().commit();
-		} finally {
-			cleanup(em, "deletePdp");
-		}
-		if(logger.isDebugEnabled()){
-			logger.debug("deletePdp: Exiting");
-		}
-	
-	}
-	
-	/*
-	 * Close the specified EntityManager, rolling back any pending transaction
-	 *
-	 * @param em the EntityManager to close ('null' is OK)
-	 * @param method the invoking Java method (used for log messages)
-	 */
-	private static void cleanup(EntityManager em, String method)
-	{
-		if (em != null && em.isOpen()) {
-			if (em.getTransaction().isActive()) {
-				// there is an active EntityTransaction -- roll it back
-				try {
-					em.getTransaction().rollback();
-				} catch (Exception e) {
-					logger.error(method + ": Caught Exception attempting to rollback EntityTransaction,", e);
-				}
-			}
+        EntityManager em = null;
+        try {
+            /*
+             * Start transaction.
+             */
+            em = emf.createEntityManager();
+            em.getTransaction().begin();
 
-			// now, close the EntityManager
-			try {
-				em.close();
-			} catch (Exception e) {
-				logger.error(method + ": Caught Exception attempting to close EntityManager, ", e);
-			}
-		}
-	}
+            /*
+             * Get droolspdpentity record for this PDP and mark DESIGNATED as
+             * false.
+             */
+            Query droolsPdpsListQuery = em
+                    .createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
+            droolsPdpsListQuery.setParameter("pdpId", pdpId);
+            List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
+                    LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+            DroolsPdpEntity droolsPdpEntity;
+            if (droolsPdpsList.size() == 1
+                    && (droolsPdpsList.get(0) instanceof DroolsPdpEntity)) {
+                droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList.get(0);
+                droolsPdpEntity.setDesignated(false);
+                em.persist(droolsPdpEntity);
+                if (logger.isDebugEnabled()) {
+                    logger.debug("standDownPdp: PDP={} persisted as non-designated.", pdpId );
+                }
+            } else {
+                logger.error("standDownPdp: Missing record in droolspdpentity for pdpId={}"
+                        + "; cannot stand down PDP", pdpId);
+            }
+
+            /*
+             * End transaction.
+             */
+            em.getTransaction().commit();
+            cleanup(em, "standDownPdp");
+            em = null;
+
+            // Keep the election handler in sync with the DB
+            DroolsPdpsElectionHandler.setMyPdpDesignated(false);
+
+        } catch (Exception e) {
+            logger.error("standDownPdp: Unexpected Exception attempting to mark "
+                    + "DESIGNATED as false for droolspdpentity, pdpId={}"
+                    + ".  Cannot stand down PDP; message={}", pdpId, e.getMessage(), e);
+        } finally {
+            cleanup(em, "standDownPdp");
+        }
+        if (logger.isDebugEnabled()) {
+            logger.debug("standDownPdp: Exiting");
+        }
+
+    }
+
+    /*
+     * Determines whether or not a designated PDP has failed.
+     * 
+     * Note: The update method, which is run periodically by the
+     * TimerUpdateClass, will un-designate a PDP that is stale.
+     */
+    @Override
+    public boolean hasDesignatedPdpFailed(Collection<DroolsPdp> pdps) {
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("hasDesignatedPdpFailed: Entering, pdps.size()={}", pdps.size());
+        }
+
+        boolean failed = true;
+        boolean foundDesignatedPdp = false;
+
+        for (DroolsPdp pdp : pdps) {
+
+            /*
+             * Normally, the update method will un-designate any stale PDP, but
+             * we check here to see if the PDP has gone stale since the update
+             * method was run.
+             * 
+             * Even if we determine that the designated PDP is current, we keep
+             * going (we don't break), so we can get visibility into the other
+             * PDPs, when in DEBUG mode.
+             */
+            if (pdp.isDesignated() && isCurrent(pdp)) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("hasDesignatedPdpFailed: Designated PDP={} is current", pdp.getPdpId());
+                }
+                failed = false;
+                foundDesignatedPdp = true;
+            } else if (pdp.isDesignated() && !isCurrent(pdp)) {
+                logger.error("hasDesignatedPdpFailed: Designated PDP={} has failed", pdp.getPdpId());
+                foundDesignatedPdp = true;
+            } else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("hasDesignatedPdpFailed: PDP={} is not designated", pdp.getPdpId());
+                }
+            }
+        }
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("hasDesignatedPdpFailed: Exiting and returning, foundDesignatedPdp={}",
+                    foundDesignatedPdp);
+        }
+        return failed;
+    }
+
+
+    private boolean isCurrent(DroolsPdp pdp) {
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("isCurrent: Entering, pdpId={}", pdp.getPdpId());
+        }
+
+        boolean current = false;
+
+        // Return if the current PDP is considered "current" based on whatever
+        // time box that may be.
+        // If the the PDP is not current, we should mark it as not primary in
+        // the database
+        Date currentDate = new Date();
+        long difference = currentDate.getTime()
+                - pdp.getUpdatedDate().getTime();
+        // just set some kind of default here
+        long pdpTimeout = 15000;
+        try {
+            pdpTimeout = Long.parseLong(ActiveStandbyProperties
+                    .getProperty(ActiveStandbyProperties.PDP_TIMEOUT));
+            if (logger.isDebugEnabled()) {
+                logger.debug("isCurrent: pdp.timeout={}", pdpTimeout);
+            }
+        } catch (Exception e) {
+            logger.error("isCurrent: Could not get PDP timeout property, using default.", e);
+        }
+        current = difference < pdpTimeout;
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("isCurrent: Exiting, difference={}, pdpTimeout={}"
+                    + "; returning current={}", difference, pdpTimeout, current);
+        }
+
+        return current;
+    }
+
+
+    /*
+     * Currently this method is only used in a JUnit test environment. Gets a
+     * PDP record from droolspdpentity table.
+     */
+    @Override
+    public DroolsPdpEntity getPdp(String pdpId) {
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("getPdp: Entering and getting PDP with pdpId={}", pdpId);
+        }
+
+        DroolsPdpEntity droolsPdpEntity = null;
+
+        EntityManager em = null;
+        try {
+            em = emf.createEntityManager();
+            em.getTransaction().begin();
+            Query droolsPdpsListQuery = em
+                    .createQuery("SELECT p FROM DroolsPdpEntity p WHERE p.pdpId=:pdpId");
+            droolsPdpsListQuery.setParameter("pdpId", pdpId);
+            List<?> droolsPdpsList = droolsPdpsListQuery.setLockMode(
+                    LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+            if (droolsPdpsList.size() == 1
+                    && droolsPdpsList.get(0) instanceof DroolsPdpEntity) {
+                droolsPdpEntity = (DroolsPdpEntity) droolsPdpsList.get(0);
+                if (logger.isDebugEnabled()) {
+                    logger.debug("getPdp: PDP={}"
+                            + " found, isDesignated={},"
+                            + " updatedDate={}, "
+                            + "priority={}", pdpId,
+                            droolsPdpEntity.isDesignated(), droolsPdpEntity.getUpdatedDate(),
+                            droolsPdpEntity.getPriority());
+                }
+
+                // Make sure the droolsPdpEntity is not a cached version
+                em.refresh(droolsPdpEntity);
+
+                em.getTransaction().commit();
+            } else {
+                logger.error("getPdp: PDP={} not found!?", pdpId);
+            }
+        } catch (Exception e) {
+            logger.error("getPdp: Caught Exception attempting to get PDP", e);
+        } finally {
+            cleanup(em, "getPdp");
+        }
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("getPdp: Returning droolsPdpEntity={}", droolsPdpEntity);
+        }
+        return droolsPdpEntity;
+
+    }
+
+    /*
+     * Normally this method should only be used in a JUnit test environment.
+     * Manually inserts a PDP record in droolspdpentity table.
+     */
+    @Override
+    public void insertPdp(DroolsPdp pdp) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("insertPdp: Entering and manually inserting PDP");
+        }
+
+        /*
+         * Start transaction
+         */
+        EntityManager em = emf.createEntityManager();
+        try {
+            em.getTransaction().begin();
+
+            /*
+             * Insert record.
+             */
+            DroolsPdpEntity droolsPdpEntity = new DroolsPdpEntity();
+            em.persist(droolsPdpEntity);
+            droolsPdpEntity.setPdpId(pdp.getPdpId());
+            droolsPdpEntity.setDesignated(pdp.isDesignated());
+            droolsPdpEntity.setPriority(pdp.getPriority());
+            droolsPdpEntity.setUpdatedDate(pdp.getUpdatedDate());
+            droolsPdpEntity.setSiteName(pdp.getSiteName());
+
+            /*
+             * End transaction.
+             */
+            em.getTransaction().commit();
+        } finally {
+            cleanup(em, "insertPdp");
+        }
+        if (logger.isDebugEnabled()) {
+            logger.debug("insertPdp: Exiting");
+        }
+
+    }
+
+    /*
+     * Normally this method should only be used in a JUnit test environment.
+     * Manually deletes all PDP records in droolspdpentity table.
+     */
+    @Override
+    public void deleteAllPdps() {
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("deleteAllPdps: Entering");
+        }
+
+        /*
+         * Start transaction
+         */
+        EntityManager em = emf.createEntityManager();
+        try {
+            em.getTransaction().begin();
+
+            Query droolsPdpsListQuery = em
+                    .createQuery("SELECT p FROM DroolsPdpEntity p");
+            @SuppressWarnings("unchecked")
+            List<DroolsPdp> droolsPdpsList = droolsPdpsListQuery.setLockMode(
+                    LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+            if (logger.isDebugEnabled()) {
+                logger.debug("deleteAllPdps: Deleting {} PDPs", droolsPdpsList.size());
+            }
+            for (DroolsPdp droolsPdp : droolsPdpsList) {
+                String pdpId = droolsPdp.getPdpId();
+                deletePdp(pdpId);
+            }
+
+            /*
+             * End transaction.
+             */
+            em.getTransaction().commit();
+        } finally {
+            cleanup(em, "deleteAllPdps");
+        }
+        if (logger.isDebugEnabled()) {
+            logger.debug("deleteAllPdps: Exiting");
+        }
+
+    }
+
+    /*
+     * Normally this method should only be used in a JUnit test environment.
+     * Manually deletes a PDP record in droolspdpentity table.
+     */
+    @Override
+    public void deletePdp(String pdpId) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("deletePdp: Entering and manually deleting pdpId={}", pdpId);
+        }
+
+        /*
+         * Start transaction
+         */
+        EntityManager em = emf.createEntityManager();
+        try {
+            em.getTransaction().begin();
+
+            /*
+             * Delete record.
+             */
+            DroolsPdpEntity droolsPdpEntity = em.find(DroolsPdpEntity.class, pdpId);
+            if (droolsPdpEntity != null) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("deletePdp: Removing PDP");
+                }
+                em.remove(droolsPdpEntity);
+            } else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("deletePdp: PDP with ID={} not currently in DB", pdpId);
+                }
+            }
+
+            /*
+             * End transaction.
+             */
+            em.getTransaction().commit();
+        } finally {
+            cleanup(em, "deletePdp");
+        }
+        if (logger.isDebugEnabled()) {
+            logger.debug("deletePdp: Exiting");
+        }
+
+    }
+
+    /*
+     * Close the specified EntityManager, rolling back any pending transaction
+     *
+     * @param em the EntityManager to close ('null' is OK)
+     * @param method the invoking Java method (used for log messages)
+     */
+    private static void cleanup(EntityManager em, String method) {
+        if (em != null && em.isOpen()) {
+            if (em.getTransaction().isActive()) {
+                // there is an active EntityTransaction -- roll it back
+                try {
+                    em.getTransaction().rollback();
+                } catch (Exception e) {
+                    logger.error(method + ": Caught Exception attempting to rollback EntityTransaction,", e);
+                }
+            }
+
+            // now, close the EntityManager
+            try {
+                em.close();
+            } catch (Exception e) {
+                logger.error(method + ": Caught Exception attempting to close EntityManager, ", e);
+            }
+        }
+    }
 }
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
index 805c4b8..554376c 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
@@ -51,24 +51,32 @@
 
 /*
  * Some background:
+ *
+ * Originally, there was a "StandbyStateChangeNotifier" that belonged to policy-core, and this class's 
+ * handleStateChange() method used to take care of invoking conn.standDownPdp().   
  * 
- * Originally, there was a "StandbyStateChangeNotifier" that belonged to policy-core, and this class's handleStateChange() method
- * used to take care of invoking conn.standDownPdp().   But testing revealed that when a state change to hot standby occurred 
- * from a demote() operation, first the PMStandbyStateChangeNotifier.handleStateChange() method would be invoked and then the 
- * StandbyStateChangeNotifier.handleStateChange() method would be invoked, and this ordering was creating the following problem:
+ * But testing revealed that when a state change to hot standby 
+ * occurred from a demote() operation, first the PMStandbyStateChangeNotifier.handleStateChange() method 
+ * would be invoked and then the StandbyStateChangeNotifier.handleStateChange() method would be invoked, 
+ * and this ordering was creating the following problem:
+ *
+ * When PMStandbyStateChangeNotifier.handleStateChange() was invoked it would take a long time to finish, 
+ * because it would result in SingleThreadedUebTopicSource.stop() being invoked, which can potentially do a 
+ * 5 second sleep for each controller being stopped.
  * 
- * When PMStandbyStateChangeNotifier.handleStateChange() was invoked it would take a long time to finish, because it would result
- * in SingleThreadedUebTopicSource.stop() being invoked, which can potentially do a 5 second sleep for each controller being stopped.   
- * Meanwhile, as these controller stoppages and their associated sleeps were occurring, the election handler would discover the
- * demoted PDP in hotstandby (but still designated!) and promote it, resulting in the standbyStatus going from hotstandby
- * to providingservice.  So then, by the time that PMStandbyStateChangeNotifier.handleStateChange() finished its work and
- * StandbyStateChangeNotifier.handleStateChange() started executing, the standbyStatus was no longer hotstandby (as effected by
- * the demote), but providingservice (as reset by the election handling logic) and conn.standDownPdp() would not get called!
- * 
- * To fix this bug, we consolidated StandbyStateChangeNotifier and PMStandbyStateChangeNotifier, with the standDownPdp() always 
- * being invoked prior to the TopicEndpoint.manager.lock().  In this way, when the election handling logic is invoked 
+ * Meanwhile, as these controller stoppages and their associated sleeps were occurring, the election handler 
+ * would discover the demoted PDP in hotstandby (but still designated!) and promote it, resulting in the 
+ * standbyStatus going from hotstandby to providingservice.  So then, by the time that 
+ * PMStandbyStateChangeNotifier.handleStateChange() finished its work and
+ * StandbyStateChangeNotifier.handleStateChange() started executing, the standbyStatus was no longer hotstandby 
+ * (as effected by the demote), but providingservice (as reset by the election handling logic) and 
+ * conn.standDownPdp() would not get called!
+ *
+ * To fix this bug, we consolidated StandbyStateChangeNotifier and PMStandbyStateChangeNotifier, 
+ * with the standDownPdp() always
+ * being invoked prior to the TopicEndpoint.manager.lock().  In this way, when the election handling logic is invoked
  * during the controller stoppages, the PDP is in hotstandby and the standdown occurs.
- * 
+ *
  */
 public class PMStandbyStateChangeNotifier extends StateChangeNotifier {
     // get an instance of logger
@@ -84,6 +92,10 @@
     public static final String UNSUPPORTED = "unsupported";
     public static final String HOTSTANDBY_OR_COLDSTANDBY = "hotstandby_or_coldstandby";
 
+    /**
+     * Constructor.
+     * 
+     */
     public PMStandbyStateChangeNotifier() {
         pdpUpdateInterval =
                 Integer.parseInt(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_UPDATE_INTERVAL));
@@ -122,8 +134,9 @@
                 // We were just here and did this successfully
                 if (logger.isDebugEnabled()) {
                     logger.debug(
-                            "handleStateChange: Is returning because standbyStatus is null and was previously 'null'; PDP={}",
-                            pdpId);
+                        "handleStateChange: "
+                        + "Is returning because standbyStatus is null and was previously 'null'; PDP={}",
+                        pdpId);
                 }
                 return;
             }
@@ -230,16 +243,16 @@
                     if (waitTimeMs > 3 * waitInterval) {
                         if (logger.isDebugEnabled()) {
                             logger.debug(
-                                    "handleStateChange: PROVIDING_SERVICE looks like the activation wait timer may be hung,"
-                                            + " waitTimeMs = {} and allowable waitInterval = {}"
-                                            + " Checking whether it is currently in activation. isNowActivating = {}",
-                                    waitTimeMs, waitInterval, isNowActivating);
+                                "handleStateChange: PROVIDING_SERVICE looks like the activation wait timer may be hung,"
+                                + " waitTimeMs = {} and allowable waitInterval = {}"
+                                + " Checking whether it is currently in activation. isNowActivating = {}",
+                                waitTimeMs, waitInterval, isNowActivating);
                         }
                         // Now check that it is not currently executing an activation
                         if (!isNowActivating) {
                             if (logger.isDebugEnabled()) {
                                 logger.debug(
-                                        "handleStateChange: PROVIDING_SERVICE looks like the activation wait timer died");
+                                    "handleStateChange: PROVIDING_SERVICE looks like the activation wait timer died");
                             }
                             // This will assure the timer is cancelled and rescheduled.
                             isWaitingForActivation = false;
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java
index b5fe307..373c373 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java
@@ -22,6 +22,6 @@
 
 @FunctionalInterface
 public interface ThreadRunningChecker {
-	public void checkThreadStatus();
+    public void checkThreadStatus();
 
 }
diff --git a/feature-active-standby-management/src/main/resources/META-INF/persistence.xml b/feature-active-standby-management/src/main/resources/META-INF/persistence.xml
index 4a625b5..36f65ad 100644
--- a/feature-active-standby-management/src/main/resources/META-INF/persistence.xml
+++ b/feature-active-standby-management/src/main/resources/META-INF/persistence.xml
@@ -3,7 +3,7 @@
   ============LICENSE_START=======================================================
   feature-active-standby-management
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-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.
@@ -20,14 +20,16 @@
   -->
 
 <persistence version="2.1"
-	xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
-	<persistence-unit name="activeStandbyPU" transaction-type="RESOURCE_LOCAL">
-	<!-- This is for database access by non-drools methods -->
-		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-		<class>org.onap.policy.drools.activestandby.DroolsPdpEntity</class>
-		<properties>
-			<!-- Properties are passed in -->
+    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+    <persistence-unit name="activeStandbyPU"
+        transaction-type="RESOURCE_LOCAL">
+        <!-- This is for database access by non-drools methods -->
+        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+        <class>org.onap.policy.drools.activestandby.DroolsPdpEntity</class>
+        <properties>
+        <!-- Properties are passed in -->
         </properties>
-	</persistence-unit>
+    </persistence-unit>
 </persistence>
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
index 1926520..dfc6930 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-active-standby-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -55,265 +55,280 @@
  * Testing the allSeemsWell interface to verify that it correctly affects the 
  * operational state.
  */ 
- 
+
 public class AllSeemsWellTest {
-	private static final Logger  logger = LoggerFactory.getLogger(AllSeemsWellTest.class);
-	/*
-	 * Currently, the DroolsPdpsElectionHandler.DesignationWaiter is invoked every 1 seconds, starting 
-	 * at the start of the next multiple of pdpUpdateInterval, but with a minimum of 5 sec cushion
-	 * to ensure that we wait for the DesignationWaiter to do its job, before 
-	 * checking the results. Add a few seconds for safety
-	 */ 
-	 
-	long sleepTime = 10000;
-	
-	/*
-	 * DroolsPdpsElectionHandler runs every 1 seconds, so it takes 10 seconds for the
-	 * checkWaitTimer() method to time out and call allSeemsWell which then requires
-	 * the forward progress counter to go stale which should add an additional 5 sec.
-	 */
-	 
-	long stalledElectionHandlerSleepTime = 15000;
-	
-	/*
-	 * As soon as the election hander successfully runs, it will resume the forward progress.
-	 * If the election handler runs ever 1 sec and test transaction is run every 1 sec and
-	 * then fpc is written every 1 sec and then the fpc is checked every 2 sec, that could
-	 * take a total of 5 sec to recognize the resumption of progress.  So, add 1 for safety.
-	 */
-	long resumedElectionHandlerSleepTime = 6000;
-	
-	private static EntityManagerFactory emfx;
-	private static EntityManagerFactory emfd;
-	private static EntityManager emx;
-	private static EntityManager emd;
-	private static EntityTransaction et;
-	
-	private final String configDir = "src/test/resources/asw";
+    private static final Logger  logger = LoggerFactory.getLogger(AllSeemsWellTest.class);
+    /*
+     * Currently, the DroolsPdpsElectionHandler.DesignationWaiter is invoked every 1 seconds, starting 
+     * at the start of the next multiple of pdpUpdateInterval, but with a minimum of 5 sec cushion
+     * to ensure that we wait for the DesignationWaiter to do its job, before 
+     * checking the results. Add a few seconds for safety
+     */ 
 
-	/*
-	 * See the IntegrityMonitor.getJmxUrl() method for the rationale behind this jmx related processing.
-	 */
-	 
-	@BeforeClass
-	public static void setUpClass() throws Exception {
-		
-		String userDir = System.getProperty("user.dir");
-		logger.debug("setUpClass: userDir={}", userDir);
-		System.setProperty("com.sun.management.jmxremote.port", "9980");
-		System.setProperty("com.sun.management.jmxremote.authenticate","false");
-	}
+    long sleepTime = 10000;
 
-	@AfterClass
-	public static void tearDownClass() throws Exception {
-	}
+    /*
+     * DroolsPdpsElectionHandler runs every 1 seconds, so it takes 10 seconds for the
+     * checkWaitTimer() method to time out and call allSeemsWell which then requires
+     * the forward progress counter to go stale which should add an additional 5 sec.
+     */
 
-	@Before
-	public void setUp() throws Exception {
-		//Create teh data access for xaml db
-		Properties stateManagementProperties = new Properties();
-		stateManagementProperties.load(new FileInputStream(new File(
-				configDir + "/feature-state-management.properties")));
+    long stalledElectionHandlerSleepTime = 15000;
 
-		emfx = Persistence.createEntityManagerFactory("junitXacmlPU", stateManagementProperties);
+    /*
+     * As soon as the election hander successfully runs, it will resume the forward progress.
+     * If the election handler runs ever 1 sec and test transaction is run every 1 sec and
+     * then fpc is written every 1 sec and then the fpc is checked every 2 sec, that could
+     * take a total of 5 sec to recognize the resumption of progress.  So, add 1 for safety.
+     */
+    long resumedElectionHandlerSleepTime = 6000;
 
-		// Create an entity manager to use the DB
-		emx = emfx.createEntityManager();
-		
-		//Create the data access for drools db
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
+    private static EntityManagerFactory emfx;
+    private static EntityManagerFactory emfd;
+    private static EntityManager emx;
+    private static EntityManager emd;
+    private static EntityTransaction et;
 
-		emfd = Persistence.createEntityManagerFactory("junitDroolsPU", activeStandbyProperties);
+    private final String configDir = "src/test/resources/asw";
 
-		// Create an entity manager to use the DB
-		emd = emfd.createEntityManager();
-		
-		DroolsPdpsElectionHandler.setIsUnitTesting(true);
-	}
+    /*
+     * See the IntegrityMonitor.getJmxUrl() method for the rationale behind this jmx related processing.
+     */
 
-	@After
-	public void tearDown() throws Exception {
-				
-	}
-	
-	public void cleanXacmlDb(){
-		et = emx.getTransaction();
-		
-		et.begin();
-		// Make sure we leave the DB clean
-		emx.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
-		emx.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
-		emx.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-		emx.flush();
-		et.commit();
-	}
-	
-	public void cleanDroolsDb(){
-		et = emd.getTransaction();
-		
-		et.begin();
-		// Make sure we leave the DB clean
-		emd.createQuery("DELETE FROM DroolsPdpEntity").executeUpdate();
-		emd.flush();
-		et.commit();
-	}
-	
+    /**
+     * Setup the class.
+     * 
+     * @throws Exception exception
+     */
+    @BeforeClass
+    public static void setUpClass() throws Exception {
 
-	// Tests hot standby when there is only one PDP.
-	 
-	//@Ignore
-	@Test
-	public void testAllSeemsWell() throws Exception {
-	
-		logger.debug("\n\ntestAllSeemsWell: Entering\n\n");
-		cleanXacmlDb();
-		cleanDroolsDb();
-		
-		logger.debug("testAllSeemsWell: Reading stateManagementProperties");
-		Properties stateManagementProperties = new Properties();
-		stateManagementProperties.load(new FileInputStream(new File(
-				configDir + "/feature-state-management.properties")));
+        String userDir = System.getProperty("user.dir");
+        logger.debug("setUpClass: userDir={}", userDir);
+        System.setProperty("com.sun.management.jmxremote.port", "9980");
+        System.setProperty("com.sun.management.jmxremote.authenticate","false");
+    }
 
-		logger.debug("testAllSeemsWell: Creating emfXacml");
-		EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
-				"junitXacmlPU", stateManagementProperties);
-		
-		logger.debug("testAllSeemsWell: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties
-				.getProperty(ActiveStandbyProperties.NODE_NAME);
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
 
-		logger.debug("testAllSeemsWell: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
-		
-		logger.debug("testAllSeemsWell: Cleaning up tables");
-		conn.deleteAllPdps();
-					
-		/*
-		 * Insert this PDP as not designated.  Initial standby state will be 
-		 * either null or cold standby.   Demoting should transit state to
-		 * hot standby.
-		 */
-		 
-		logger.debug("testAllSeemsWell: Inserting PDP={} as not designated", thisPdpId);
-		Date yesterday = DateUtils.addDays(new Date(), -1);
-		DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
-		conn.insertPdp(pdp);
-		DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.debug("testAllSeemsWell: After insertion, PDP={} has DESIGNATED={}",
-				thisPdpId, droolsPdpEntity.isDesignated());
-		assertTrue(droolsPdpEntity.isDesignated() == false);
-		
-		logger.debug("testAllSeemsWell: Instantiating stateManagement object");
-		StateManagement sm = new StateManagement(emfXacml, "dummy");
-		sm.deleteAllStateManagementEntities();
-		
-		
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+    /**
+     * Setup.
+     * 
+     * @throws Exception exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        //Create teh data access for xaml db
+        Properties stateManagementProperties = new Properties();
+        stateManagementProperties.load(new FileInputStream(new File(
+                configDir + "/feature-state-management.properties")));
 
-		StateManagementFeatureAPI smf = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			smf = feature;
-			logger.debug("testAllSeemsWell stateManagementFeature.getResourceName(): {}", smf.getResourceName());
-			break;
-		}
-		if(smf == null){
-			logger.error("testAllSeemsWell failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testAllSeemsWell failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
-		// that has been created.
-		ActiveStandbyFeatureAPI activeStandbyFeature = null;
-		for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			activeStandbyFeature = feature;
-			logger.debug("testAllSeemsWell activeStandbyFeature.getResourceName(): {}", activeStandbyFeature.getResourceName());
-			break;
-		}
-		if(activeStandbyFeature == null){
-			logger.error("testAllSeemsWell failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testAllSeemsWell failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
+        emfx = Persistence.createEntityManagerFactory("junitXacmlPU", stateManagementProperties);
 
-		logger.debug("testAllSeemsWell: Demoting PDP={}", thisPdpId);
-		// demoting should cause state to transit to hotstandby
-		smf.demote();
-		
-				
-		logger.debug("testAllSeemsWell: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
-				+ "time to check droolspdpentity table", sleepTime);
-		sleep(sleepTime);
-		
-		
-		// Verify that this formerly un-designated PDP in HOT_STANDBY is now designated and providing service.
-		 
-		droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.debug("testAllSeemsWell: After sm.demote() invoked, DESIGNATED= {} "
-				+ "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
-		assertTrue(droolsPdpEntity.isDesignated() == true);
-		String standbyStatus = smf.getStandbyStatus(thisPdpId);
-		logger.debug("testAllSeemsWell: After demotion, PDP= {} "
-				+ "has standbyStatus= {}", thisPdpId, standbyStatus);
-		assertTrue(standbyStatus != null  &&  standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
-		
-		//Now we want to stall the election handler and see the if AllSeemsWell will make the
-		//standbystatus = coldstandby
-		
-		DroolsPdpsElectionHandler.setIsStalled(true);
-		
-		logger.debug("testAllSeemsWell: Sleeping {} ms, to allow checkWaitTimer to recognize "
-				+ "the election handler has stalled and for the testTransaction to fail to "
-				+ "increment forward progress and for the lack of forward progress to be recognized.",
-				stalledElectionHandlerSleepTime);
+        // Create an entity manager to use the DB
+        emx = emfx.createEntityManager();
+
+        //Create the data access for drools db
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+
+        emfd = Persistence.createEntityManagerFactory("junitDroolsPU", activeStandbyProperties);
+
+        // Create an entity manager to use the DB
+        emd = emfd.createEntityManager();
+
+        DroolsPdpsElectionHandler.setIsUnitTesting(true);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+
+    }
+
+    /**
+     * Clean the xacml database.
+     */
+    public void cleanXacmlDb() {
+        et = emx.getTransaction();
+
+        et.begin();
+        // Make sure we leave the DB clean
+        emx.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+        emx.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
+        emx.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
+        emx.flush();
+        et.commit();
+    }
+
+    /**
+     * Clean the drools database.
+     */
+    public void cleanDroolsDb() {
+        et = emd.getTransaction();
+
+        et.begin();
+        // Make sure we leave the DB clean
+        emd.createQuery("DELETE FROM DroolsPdpEntity").executeUpdate();
+        emd.flush();
+        et.commit();
+    }
 
 
-		//It takes 10x the update interval (1 sec) before the watcher will declare the election handler dead
-		//and that just stops forward progress counter.  So, the fp monitor must then run to determine
-		//if the fpc has stalled.  That will take about another 5 sec.
-		sleep(stalledElectionHandlerSleepTime);
-		
-		logger.debug("testAllSeemsWell: After isStalled=true, PDP= {} "
-				+ "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
-		
-		assertTrue(smf.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
-		
-		//Now lets resume the election handler
-		DroolsPdpsElectionHandler.setIsStalled(false);
-		
-		sleep(resumedElectionHandlerSleepTime);
-		
-		logger.debug("testAllSeemsWell: After isStalled=false, PDP= {} "
-				+ "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
-		
-		assertTrue(smf.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+    // Tests hot standby when there is only one PDP.
 
-		//resumedElectionHandlerSleepTime = 5000;
-		logger.debug("\n\ntestAllSeemsWell: Exiting\n\n");
+    //@Ignore
+    @Test
+    public void testAllSeemsWell() throws Exception {
 
-	}
+        logger.debug("\n\ntestAllSeemsWell: Entering\n\n");
+        cleanXacmlDb();
+        cleanDroolsDb();
 
-	private void sleep(long sleepms) throws InterruptedException {
-		Thread.sleep(sleepms);
-	}
+        logger.debug("testAllSeemsWell: Reading stateManagementProperties");
+        Properties stateManagementProperties = new Properties();
+        stateManagementProperties.load(new FileInputStream(new File(
+                configDir + "/feature-state-management.properties")));
+
+        logger.debug("testAllSeemsWell: Creating emfXacml");
+        final EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
+                "junitXacmlPU", stateManagementProperties);
+
+        logger.debug("testAllSeemsWell: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        final String thisPdpId = activeStandbyProperties
+                .getProperty(ActiveStandbyProperties.NODE_NAME);
+
+        logger.debug("testAllSeemsWell: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
+
+        DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
+
+        logger.debug("testAllSeemsWell: Cleaning up tables");
+        conn.deleteAllPdps();
+
+        /*
+         * Insert this PDP as not designated.  Initial standby state will be 
+         * either null or cold standby.   Demoting should transit state to
+         * hot standby.
+         */
+
+        logger.debug("testAllSeemsWell: Inserting PDP={} as not designated", thisPdpId);
+        Date yesterday = DateUtils.addDays(new Date(), -1);
+        DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
+        conn.insertPdp(pdp);
+        DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.debug("testAllSeemsWell: After insertion, PDP={} has DESIGNATED={}",
+                thisPdpId, droolsPdpEntity.isDesignated());
+        assertTrue(droolsPdpEntity.isDesignated() == false);
+
+        logger.debug("testAllSeemsWell: Instantiating stateManagement object");
+        StateManagement sm = new StateManagement(emfXacml, "dummy");
+        sm.deleteAllStateManagementEntities();
+
+
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
+
+        StateManagementFeatureAPI smf = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            smf = feature;
+            logger.debug("testAllSeemsWell stateManagementFeature.getResourceName(): {}", smf.getResourceName());
+            break;
+        }
+        if (smf == null) {
+            logger.error("testAllSeemsWell failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testAllSeemsWell failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+        // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
+        // that has been created.
+        ActiveStandbyFeatureAPI activeStandbyFeature = null;
+        for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            activeStandbyFeature = feature;
+            logger.debug("testAllSeemsWell activeStandbyFeature.getResourceName(): {}", 
+                    activeStandbyFeature.getResourceName());
+            break;
+        }
+        if (activeStandbyFeature == null) {
+            logger.error("testAllSeemsWell failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testAllSeemsWell failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+
+        logger.debug("testAllSeemsWell: Demoting PDP={}", thisPdpId);
+        // demoting should cause state to transit to hotstandby
+        smf.demote();
+
+
+        logger.debug("testAllSeemsWell: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
+                + "time to check droolspdpentity table", sleepTime);
+        sleep(sleepTime);
+
+
+        // Verify that this formerly un-designated PDP in HOT_STANDBY is now designated and providing service.
+
+        droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.debug("testAllSeemsWell: After sm.demote() invoked, DESIGNATED= {} "
+                + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
+        assertTrue(droolsPdpEntity.isDesignated() == true);
+        String standbyStatus = smf.getStandbyStatus(thisPdpId);
+        logger.debug("testAllSeemsWell: After demotion, PDP= {} "
+                + "has standbyStatus= {}", thisPdpId, standbyStatus);
+        assertTrue(standbyStatus != null  &&  standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
+
+        //Now we want to stall the election handler and see the if AllSeemsWell will make the
+        //standbystatus = coldstandby
+
+        DroolsPdpsElectionHandler.setIsStalled(true);
+
+        logger.debug("testAllSeemsWell: Sleeping {} ms, to allow checkWaitTimer to recognize "
+                + "the election handler has stalled and for the testTransaction to fail to "
+                + "increment forward progress and for the lack of forward progress to be recognized.",
+                stalledElectionHandlerSleepTime);
+
+
+        //It takes 10x the update interval (1 sec) before the watcher will declare the election handler dead
+        //and that just stops forward progress counter.  So, the fp monitor must then run to determine
+        //if the fpc has stalled.  That will take about another 5 sec.
+        sleep(stalledElectionHandlerSleepTime);
+
+        logger.debug("testAllSeemsWell: After isStalled=true, PDP= {} "
+                + "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
+
+        assertTrue(smf.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
+
+        //Now lets resume the election handler
+        DroolsPdpsElectionHandler.setIsStalled(false);
+
+        sleep(resumedElectionHandlerSleepTime);
+
+        logger.debug("testAllSeemsWell: After isStalled=false, PDP= {} "
+                + "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
+
+        assertTrue(smf.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+
+        //resumedElectionHandlerSleepTime = 5000;
+        logger.debug("\n\ntestAllSeemsWell: Exiting\n\n");
+
+    }
+
+    private void sleep(long sleepms) throws InterruptedException {
+        Thread.sleep(sleepms);
+    }
 }
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
index b79deeb..aca2021 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-active-standby-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -69,1473 +69,1545 @@
  */ 
  
 public class StandbyStateManagementTest {
-	private static final Logger  logger = LoggerFactory.getLogger(StandbyStateManagementTest.class);
-	/*
-	 * Currently, the DroolsPdpsElectionHandler.DesignationWaiter is invoked every 1 seconds, starting 
-	 * at the start of the next multiple of pdpUpdateInterval, but with a minimum of 5 sec cushion
-	 * to ensure that we wait for the DesignationWaiter to do its job, before 
-	 * checking the results. Add a few seconds for safety
-	 */ 
-	 
-	long sleepTime = 10000;
-	
-	/*
-	 * DroolsPdpsElectionHandler runs every 1 seconds, so a 6 second sleep should be 
-	 * plenty to ensure it has time to re-promote this PDP.
-	 */
-	 
-	long electionWaitSleepTime = 6000;
-	
-	/*
-	 * Sleep 1 seconds after each test to allow interrupt (shutdown) recovery.
-	 */
-	 
-	long interruptRecoveryTime = 5000;
-	
-	private static EntityManagerFactory emfx;
-	private static EntityManagerFactory emfd;
-	private static EntityManager emx;
-	private static EntityManager emd;
-	private static EntityTransaction et;
-	
-	private final String configDir = "src/test/resources";
+    private static final Logger  logger = LoggerFactory.getLogger(StandbyStateManagementTest.class);
+    /*
+     * Currently, the DroolsPdpsElectionHandler.DesignationWaiter is invoked every 1 seconds, starting 
+     * at the start of the next multiple of pdpUpdateInterval, but with a minimum of 5 sec cushion
+     * to ensure that we wait for the DesignationWaiter to do its job, before 
+     * checking the results. Add a few seconds for safety
+     */ 
 
-	/*
-	 * See the IntegrityMonitor.getJmxUrl() method for the rationale behind this jmx related processing.
-	 */
-	 
-	@BeforeClass
-	public static void setUpClass() throws Exception {
-		
-		String userDir = System.getProperty("user.dir");
-		logger.debug("setUpClass: userDir={}", userDir);
-		System.setProperty("com.sun.management.jmxremote.port", "9980");
-		System.setProperty("com.sun.management.jmxremote.authenticate","false");
-				
-	}
+    long sleepTime = 10000;
 
-	@AfterClass
-	public static void tearDownClass() throws Exception {
-	}
+    /*
+     * DroolsPdpsElectionHandler runs every 1 seconds, so a 6 second sleep should be 
+     * plenty to ensure it has time to re-promote this PDP.
+     */
 
-	@Before
-	public void setUp() throws Exception {
-		//Create teh data access for xaml db
-		Properties stateManagementProperties = new Properties();
-		stateManagementProperties.load(new FileInputStream(new File(
-				"src/test/resources/feature-state-management.properties")));
+    long electionWaitSleepTime = 6000;
 
-		emfx = Persistence.createEntityManagerFactory("junitXacmlPU", stateManagementProperties);
+    /*
+     * Sleep 1 seconds after each test to allow interrupt (shutdown) recovery.
+     */
 
-		// Create an entity manager to use the DB
-		emx = emfx.createEntityManager();
-		
-		//Create the data access for drools db
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				"src/test/resources/feature-active-standby-management.properties")));
+    long interruptRecoveryTime = 5000;
 
-		emfd = Persistence.createEntityManagerFactory("junitDroolsPU", activeStandbyProperties);
+    private static EntityManagerFactory emfx;
+    private static EntityManagerFactory emfd;
+    private static EntityManager emx;
+    private static EntityManager emd;
+    private static EntityTransaction et;
 
-		// Create an entity manager to use the DB
-		emd = emfd.createEntityManager();
-	}
+    private final String configDir = "src/test/resources";
 
-	@After
-	public void tearDown() throws Exception {
-				
-	}
-	
-	public void cleanXacmlDb(){
-		et = emx.getTransaction();
-		
-		et.begin();
-		// Make sure we leave the DB clean
-		emx.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
-		emx.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
-		emx.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-		emx.flush();
-		et.commit();
-	}
-	
-	public void cleanDroolsDb(){
-		et = emd.getTransaction();
-		
-		et.begin();
-		// Make sure we leave the DB clean
-		emd.createQuery("DELETE FROM DroolsPdpEntity").executeUpdate();
-		emd.flush();
-		et.commit();
-	}
-	
-	/*
-	 * These JUnit tests must be run one at a time in an eclipse environment 
-	 * by right-clicking StandbyStateManagementTest and selecting 
-	 * "Run As" -> "JUnit Test". 
-	 * 
-	 * They will run successfully when you run all of them under runAllTests(), 
-	 * however, you will get all sorts of non-fatal errors in the log and on the 
-	 * console that result from overlapping threads that are not terminated at the 
-	 * end of each test. The problem is that the JUnit environment does not terminate 
-	 * all the test threads between tests. This is true even if you break each JUnit
-	 * into a separate file. Consequently, all the tests would have to be refactored 
-	 * so all test object initializations are coordinated.  In other words, you 
-	 * retrieve the ActiveStandbyFeature instance and other class instances only once 
-	 * at the beginning of the JUnits and then reuse them throughout the tests. 
-	 * Initialization of the state of the objects is pretty straight forward as it
-	 * just amounts to manipulating the entries in StateManagementEntity and 
-	 * DroolsPdpEntity tables. However, some thought needs to be given to how to
-	 * "pause" the processing in ActiveStandbyFeature class.  I think we could "pause"
-	 * it by calling globalInit() which will, I think, restart it. So long as it
-	 * does not create a new instance, it will force it to go through an initialization
-	 * cycle which includes a "pause" at the beginning of proecessing.  We just must
-	 * be sure it does not create another instance - which may mean we need to add
-	 * a factory interface instead of calling the constructor directly.
-	 */
+    /*
+     * See the IntegrityMonitor.getJmxUrl() method for the rationale behind this jmx related processing.
+     */
 
-	
-	//@Ignore
-	@Test
-	public void runAllTests() throws Exception {
-		testColdStandby();
-		testHotStandby1();
-		testHotStandby2();
-		testLocking1();
-		testLocking2(); 
-		testPMStandbyStateChangeNotifier();
-		testSanitizeDesignatedList();
-		testComputeMostRecentPrimary();
-		testComputeDesignatedPdp();
-	}
-	
-	//@Ignore
-	//@Test
-	public void testPMStandbyStateChangeNotifier() throws Exception {
-		logger.debug("\n\ntestPMStandbyStateChangeNotifier: Entering\n\n");
-		cleanXacmlDb();
-		
-		logger.debug("testPMStandbyStateChangeNotifier: Reading activeStandbyProperties");
-		
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		
-		String resourceName = "testPMS";
-		activeStandbyProperties.setProperty("resource.name", resourceName);
-		ActiveStandbyProperties.initProperties(activeStandbyProperties);
-		
-		logger.debug("testPMStandbyStateChangeNotifier: Getting StateManagement instance");
-		
-		StateManagement sm = new StateManagement(emfx, resourceName);
+    /**
+     * Setup the class.
+     * 
+     * @throws Exception exception
+     */
+    @BeforeClass
+    public static void setUpClass() throws Exception {
 
-		//Create an instance of the Observer
-		PMStandbyStateChangeNotifier pmNotifier = new PMStandbyStateChangeNotifier();
+        String userDir = System.getProperty("user.dir");
+        logger.debug("setUpClass: userDir={}", userDir);
+        System.setProperty("com.sun.management.jmxremote.port", "9980");
+        System.setProperty("com.sun.management.jmxremote.authenticate","false");
 
-		//Register the PMStandbyStateChangeNotifier Observer
-		sm.addObserver(pmNotifier);
-	
-		//At this point the standbystatus = 'null'
-		sm.lock();
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.NULL_VALUE));
+    }
 
-		sm.unlock();
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.NULL_VALUE));
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
 
-		//Adding standbystatus=hotstandby
-		sm.demote();
-		System.out.println(pmNotifier.getPreviousStandbyStatus());
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+    /**
+     * Setup.
+     * 
+     * @throws Exception exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        //Create teh data access for xaml db
+        Properties stateManagementProperties = new Properties();
+        stateManagementProperties.load(new FileInputStream(new File(
+                "src/test/resources/feature-state-management.properties")));
 
-		//Now making standbystatus=coldstandby
-		sm.lock();
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+        emfx = Persistence.createEntityManagerFactory("junitXacmlPU", stateManagementProperties);
 
-		//standbystatus = hotstandby
-		sm.unlock();
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+        // Create an entity manager to use the DB
+        emx = emfx.createEntityManager();
 
-		//standbystatus = providingservice
-		sm.promote();
-		//The previousStandbyStatus is not updated until after the delay activation expires
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+        //Create the data access for drools db
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                "src/test/resources/feature-active-standby-management.properties")));
 
-		//Sleep long enough for the delayActivationTimer to run
-		sleep(5000);
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+        emfd = Persistence.createEntityManagerFactory("junitDroolsPU", activeStandbyProperties);
 
-		//standbystatus = providingservice
-		sm.promote();
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
-		
-		//standbystatus = coldstandby
-		sm.lock();
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+        // Create an entity manager to use the DB
+        emd = emfd.createEntityManager();
+    }
 
-		//standbystatus = hotstandby
-		sm.unlock();
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+    @After
+    public void tearDown() throws Exception {
 
-		//standbystatus = hotstandby
-		sm.demote();
-		assertTrue(pmNotifier.getPreviousStandbyStatus().equals(PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
-	}
+    }
 
-	//@Ignore
-	//@Test
-	public void testSanitizeDesignatedList() throws Exception {
+    /**
+     * Clean up the xacml database.
+     * 
+     */
+    public void cleanXacmlDb() {
+        et = emx.getTransaction();
 
-		logger.debug("\n\ntestSanitizeDesignatedList: Entering\n\n");
-		
-		// Get a DroolsPdpsConnector
-		
-		logger.debug("testSanitizeDesignatedList: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties
-				.getProperty(ActiveStandbyProperties.NODE_NAME);
+        et.begin();
+        // Make sure we leave the DB clean
+        emx.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+        emx.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
+        emx.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
+        emx.flush();
+        et.commit();
+    }
 
-		logger.debug("testSanitizeDesignatedList: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfDrools);
-		
-		// Create 4 pdpd all not designated
-		
-		DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, new Date());
-		DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, new Date());
-		DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
-		DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
-		
-		List<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
-		listOfDesignated.add(pdp1);
-		listOfDesignated.add(pdp2);
-		listOfDesignated.add(pdp3);
-		listOfDesignated.add(pdp4);
-		
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+    /**
+     * Clean up the drools db.
+     */
+    public void cleanDroolsDb() {
+        et = emd.getTransaction();
 
-		StateManagementFeatureAPI stateManagementFeature = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			stateManagementFeature = feature;
-			logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}", stateManagementFeature.getResourceName());
-			break;
-		}
-		if(stateManagementFeature == null){
-			logger.error("testColdStandby failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testColdStandby failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		
-		DroolsPdpsElectionHandler droolsPdpsElectionHandler =  new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
-		
-		listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
-		
-		logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size = {}\n\n",listOfDesignated.size());
-		
-		assertTrue(listOfDesignated.size()==4);
-		
-		// Now make 2 designated
-		 
-		pdp1.setDesignated(true);
-		pdp2.setDesignated(true);
-		
-		listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
-		
-		logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after 2 designated = {}\n\n", listOfDesignated.size());
-		
-		assertTrue(listOfDesignated.size()==2);
-		assertTrue(listOfDesignated.contains(pdp1));
-		assertTrue(listOfDesignated.contains(pdp2));
-		
-		
-		// Now all are designated.  But, we have to add back the previously non-designated nodes
-		 
-		pdp3.setDesignated(true);
-		pdp4.setDesignated(true);
-		listOfDesignated.add(pdp3);
-		listOfDesignated.add(pdp4);
-		
-		listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
-		
-		logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after all designated = {}\n\n", listOfDesignated.size());
-		
-		assertTrue(listOfDesignated.size()==4);
-		
-	}
+        et.begin();
+        // Make sure we leave the DB clean
+        emd.createQuery("DELETE FROM DroolsPdpEntity").executeUpdate();
+        emd.flush();
+        et.commit();
+    }
+
+    /*
+     * These JUnit tests must be run one at a time in an eclipse environment 
+     * by right-clicking StandbyStateManagementTest and selecting 
+     * "Run As" -> "JUnit Test". 
+     * 
+     * They will run successfully when you run all of them under runAllTests(), 
+     * however, you will get all sorts of non-fatal errors in the log and on the 
+     * console that result from overlapping threads that are not terminated at the 
+     * end of each test. The problem is that the JUnit environment does not terminate 
+     * all the test threads between tests. This is true even if you break each JUnit
+     * into a separate file. Consequently, all the tests would have to be refactored 
+     * so all test object initializations are coordinated.  In other words, you 
+     * retrieve the ActiveStandbyFeature instance and other class instances only once 
+     * at the beginning of the JUnits and then reuse them throughout the tests. 
+     * Initialization of the state of the objects is pretty straight forward as it
+     * just amounts to manipulating the entries in StateManagementEntity and 
+     * DroolsPdpEntity tables. However, some thought needs to be given to how to
+     * "pause" the processing in ActiveStandbyFeature class.  I think we could "pause"
+     * it by calling globalInit() which will, I think, restart it. So long as it
+     * does not create a new instance, it will force it to go through an initialization
+     * cycle which includes a "pause" at the beginning of proecessing.  We just must
+     * be sure it does not create another instance - which may mean we need to add
+     * a factory interface instead of calling the constructor directly.
+     */
+
+
+    //@Ignore
+    @Test
+    public void runAllTests() throws Exception {
+        testColdStandby();
+        testHotStandby1();
+        testHotStandby2();
+        testLocking1();
+        testLocking2(); 
+        testPmStandbyStateChangeNotifier();
+        testSanitizeDesignatedList();
+        testComputeMostRecentPrimary();
+        testComputeDesignatedPdp();
+    }
+
+    /**
+     * Test the standby state change notifier.
+     *  
+     * @throws Exception exception
+     */
+    //@Ignore
+    //@Test
+    public void testPmStandbyStateChangeNotifier() throws Exception {
+        logger.debug("\n\ntestPMStandbyStateChangeNotifier: Entering\n\n");
+        cleanXacmlDb();
+
+        logger.debug("testPMStandbyStateChangeNotifier: Reading activeStandbyProperties");
+
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+
+        String resourceName = "testPMS";
+        activeStandbyProperties.setProperty("resource.name", resourceName);
+        ActiveStandbyProperties.initProperties(activeStandbyProperties);
+
+        logger.debug("testPMStandbyStateChangeNotifier: Getting StateManagement instance");
+
+        StateManagement sm = new StateManagement(emfx, resourceName);
+
+        //Create an instance of the Observer
+        PMStandbyStateChangeNotifier pmNotifier = new PMStandbyStateChangeNotifier();
+
+        //Register the PMStandbyStateChangeNotifier Observer
+        sm.addObserver(pmNotifier);
+
+        //At this point the standbystatus = 'null'
+        sm.lock();
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.NULL_VALUE));
+
+        sm.unlock();
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.NULL_VALUE));
+
+        //Adding standbystatus=hotstandby
+        sm.demote();
+        System.out.println(pmNotifier.getPreviousStandbyStatus());
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
+                PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+
+        //Now making standbystatus=coldstandby
+        sm.lock();
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
+                PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+
+        //standbystatus = hotstandby
+        sm.unlock();
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
+                PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+
+        //standbystatus = providingservice
+        sm.promote();
+        //The previousStandbyStatus is not updated until after the delay activation expires
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
+                PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+
+        //Sleep long enough for the delayActivationTimer to run
+        sleep(5000);
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+
+        //standbystatus = providingservice
+        sm.promote();
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+
+        //standbystatus = coldstandby
+        sm.lock();
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
+                PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+
+        //standbystatus = hotstandby
+        sm.unlock();
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
+                PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+
+        //standbystatus = hotstandby
+        sm.demote();
+        assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
+                PMStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+    }
+
+    /**
+     * Test sanitize designated list.
+     * 
+     * @throws Exception exception
+     */
+    //@Ignore
+    //@Test
+    public void testSanitizeDesignatedList() throws Exception {
+
+        logger.debug("\n\ntestSanitizeDesignatedList: Entering\n\n");
+
+        // Get a DroolsPdpsConnector
+
+        logger.debug("testSanitizeDesignatedList: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        String thisPdpId = activeStandbyProperties
+                .getProperty(ActiveStandbyProperties.NODE_NAME);
+
+        logger.debug("testSanitizeDesignatedList: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
+
+        final DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfDrools);
+
+        // Create 4 pdpd all not designated
+
+        DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, new Date());
+        DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, new Date());
+        DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
+        DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
+
+        List<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
+        listOfDesignated.add(pdp1);
+        listOfDesignated.add(pdp2);
+        listOfDesignated.add(pdp3);
+        listOfDesignated.add(pdp4);
+
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
+
+        StateManagementFeatureAPI stateManagementFeature = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            stateManagementFeature = feature;
+            logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}", 
+                    stateManagementFeature.getResourceName());
+            break;
+        }
+        if (stateManagementFeature == null) {
+            logger.error("testColdStandby failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testColdStandby failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+
+        DroolsPdpsElectionHandler droolsPdpsElectionHandler =  new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
+
+        listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
+
+        logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size = {}\n\n",listOfDesignated.size());
+
+        assertTrue(listOfDesignated.size() == 4);
+
+        // Now make 2 designated
+
+        pdp1.setDesignated(true);
+        pdp2.setDesignated(true);
+
+        listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
+
+        logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after 2 designated = {}\n\n", 
+                listOfDesignated.size());
+
+        assertTrue(listOfDesignated.size() == 2);
+        assertTrue(listOfDesignated.contains(pdp1));
+        assertTrue(listOfDesignated.contains(pdp2));
+
+
+        // Now all are designated.  But, we have to add back the previously non-designated nodes
+
+        pdp3.setDesignated(true);
+        pdp4.setDesignated(true);
+        listOfDesignated.add(pdp3);
+        listOfDesignated.add(pdp4);
+
+        listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
+
+        logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after all designated = {}\n\n", 
+                listOfDesignated.size());
+
+        assertTrue(listOfDesignated.size() == 4);
+
+    }
+
+    /**
+    *  Test Compute most recent primary.
+    *  
+    * @throws Exception exception
+    */
+    //@Ignore
+    //@Test
+    public void testComputeMostRecentPrimary() throws Exception {
+
+        logger.debug("\n\ntestComputeMostRecentPrimary: Entering\n\n");
+
+        logger.debug("testComputeMostRecentPrimary: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        String thisPdpId = activeStandbyProperties
+                .getProperty(ActiveStandbyProperties.NODE_NAME);
+
+        logger.debug("testComputeMostRecentPrimary: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
+
+        final DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfDrools);
+
+
+        // Create 4 pdpd all not designated
+
+
+        long designatedDateMs = new Date().getTime();
+        DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, new Date());
+        pdp1.setDesignatedDate(new Date(designatedDateMs - 2));
+
+        DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, new Date());
+        //oldest
+        pdp2.setDesignatedDate(new Date(designatedDateMs - 3));
+
+        DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
+        pdp3.setDesignatedDate(new Date(designatedDateMs - 1));
+
+        DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
+        //most recent
+        pdp4.setDesignatedDate(new Date(designatedDateMs));
+
+        ArrayList<DroolsPdp> listOfAllPdps = new ArrayList<DroolsPdp>();
+        listOfAllPdps.add(pdp1);
+        listOfAllPdps.add(pdp2);
+        listOfAllPdps.add(pdp3);
+        listOfAllPdps.add(pdp4);
+
+
+        ArrayList<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
+        listOfDesignated.add(pdp1);
+        listOfDesignated.add(pdp2);
+        listOfDesignated.add(pdp3);
+        listOfDesignated.add(pdp4);
+
+        // Because the way we sanitize the listOfDesignated, it will always contain all hot standby 
+        // or all designated members.
+
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
+
+        StateManagementFeatureAPI stateManagementFeature = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            stateManagementFeature = feature;
+            logger.debug("testComputeMostRecentPrimary stateManagementFeature.getResourceName(): {}", 
+                    stateManagementFeature.getResourceName());
+            break;
+        }
+        if (stateManagementFeature == null) {
+            logger.error("testComputeMostRecentPrimary failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testComputeMostRecentPrimary failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+        DroolsPdpsElectionHandler droolsPdpsElectionHandler =  new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
+
+        DroolsPdp mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(
+                listOfAllPdps, listOfDesignated);
+
+        logger.debug("\n\ntestComputeMostRecentPrimary: mostRecentPrimary.getPdpId() = {}\n\n", 
+                mostRecentPrimary.getPdpId());
+
+
+        // If all of the pdps are included in the listOfDesignated and none are designated, it will choose 
+        // the one which has the most recent designated date.
+
+
+        assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+
+
+        // Now let's designate all of those on the listOfDesignated.  It will choose the first one designated
+
+
+        pdp1.setDesignated(true);
+        pdp2.setDesignated(true);
+        pdp3.setDesignated(true);
+        pdp4.setDesignated(true);
+
+        mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
+
+        logger.debug("\n\ntestComputeMostRecentPrimary: All designated all on list, "
+                + "mostRecentPrimary.getPdpId() = {}\n\n", 
+                mostRecentPrimary.getPdpId());
+
+
+        // If all of the pdps are included in the listOfDesignated and all are designated, it will choose 
+        // the one which was designated first
+
+
+        assertTrue(mostRecentPrimary.getPdpId().equals("pdp2"));
+
+
+        // Now we will designate only 2 and put just them in the listOfDesignated.  The algorithm will now
+        // look for the most recently designated pdp which is not currently designated.
+
+
+        pdp3.setDesignated(false);
+        pdp4.setDesignated(false);
+
+        listOfDesignated.remove(pdp3);
+        listOfDesignated.remove(pdp4);
+
+        mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
+
+        logger.debug("\n\ntestComputeMostRecentPrimary: mostRecentPrimary.getPdpId() = {}\n\n", 
+                mostRecentPrimary.getPdpId());
+
+        assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+
+
+
+        // Now we will have none designated and put two of them in the listOfDesignated.  The algorithm will now
+        // look for the most recently designated pdp regardless of whether it is currently marked as designated.
+
+
+        pdp1.setDesignated(false);
+        pdp2.setDesignated(false);
+
+        mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
+
+        logger.debug("\n\ntestComputeMostRecentPrimary: 2 on list mostRecentPrimary.getPdpId() = {}\n\n", 
+                mostRecentPrimary.getPdpId());
+
+        assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+
+
+        // If we have only one pdp on in the listOfDesignated, 
+        // the most recently designated pdp will be chosen, regardless
+        // of its designation status
+
+
+        listOfDesignated.remove(pdp1);
+
+        mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
+
+        logger.debug("\n\ntestComputeMostRecentPrimary: 1 on list mostRecentPrimary.getPdpId() = {}\n\n", 
+                mostRecentPrimary.getPdpId());
+
+        assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+
+
+        // Finally, if none are on the listOfDesignated, it will again choose the most recently designated pdp.
+
+
+        listOfDesignated.remove(pdp2);
+
+        mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
+
+        logger.debug("\n\ntestComputeMostRecentPrimary: 0 on list mostRecentPrimary.getPdpId() = {}\n\n", 
+                mostRecentPrimary.getPdpId());
+
+        assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+
+    }
+
+    /**
+     * Test compute designated PDP.
+     * 
+     * @throws Exception exception
+     */
+    //@Ignore
+    //@Test
+    public void testComputeDesignatedPdp() throws Exception {
+
+        logger.debug("\n\ntestComputeDesignatedPdp: Entering\n\n");
+
+        logger.debug("testComputeDesignatedPdp: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        String thisPdpId = activeStandbyProperties
+                .getProperty(ActiveStandbyProperties.NODE_NAME);
+
+
+        logger.debug("testComputeDesignatedPdp: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
+
+        final DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfDrools);
+
+
+        // Create 4 pdpd all not designated.  Two on site1. Two on site2
+
+
+        long designatedDateMs = new Date().getTime();
+        DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, new Date());
+        pdp1.setDesignatedDate(new Date(designatedDateMs - 2));
+        pdp1.setSiteName("site1");
+
+        DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, new Date());
+        pdp2.setDesignatedDate(new Date(designatedDateMs - 3));
+        pdp2.setSiteName("site1");
+
+        //oldest
+        DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
+        pdp3.setDesignatedDate(new Date(designatedDateMs - 4));
+        pdp3.setSiteName("site2");
+
+        DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
+        //most recent
+        pdp4.setDesignatedDate(new Date(designatedDateMs));
+        pdp4.setSiteName("site2");
+
+        ArrayList<DroolsPdp> listOfAllPdps = new ArrayList<DroolsPdp>();
+        listOfAllPdps.add(pdp1);
+        listOfAllPdps.add(pdp2);
+        listOfAllPdps.add(pdp3);
+        listOfAllPdps.add(pdp4);
+
+
+        ArrayList<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
+
+
+        // We will first test an empty listOfDesignated. As we know from the previous JUnit,
+        // the pdp with the most designated date will be chosen for mostRecentPrimary
+
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
+
+        StateManagementFeatureAPI stateManagementFeature = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            stateManagementFeature = feature;
+            logger.debug("testComputeDesignatedPdp stateManagementFeature.getResourceName(): {}", 
+                    stateManagementFeature.getResourceName());
+            break;
+        }
+        if (stateManagementFeature == null) {
+            logger.error("testComputeDesignatedPdp failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testComputeDesignatedPdp failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+
+        DroolsPdpsElectionHandler droolsPdpsElectionHandler =  new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
+
+        DroolsPdp mostRecentPrimary = pdp4;
+
+        DroolsPdp designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
+
+
+        // The designatedPdp should be null
+
+        assertTrue(designatedPdp == null);
+
+
+        // Now let's try having only one pdp in listOfDesignated, but not in the same site as the most recent primary
+
+        listOfDesignated.add(pdp2);
+
+        designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
+
+
+        // Now the designatedPdp should be the one and only selection in the listOfDesignated
+
+
+        assertTrue(designatedPdp.getPdpId().equals(pdp2.getPdpId()));
+
+
+        // Now let's put 2 pdps in the listOfDesignated, neither in the same site as the mostRecentPrimary
+
+
+        listOfDesignated.add(pdp1);
+
+        designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
+
+
+        // The designatedPdp should now be the one with the lowest lexiographic score - pdp1
+
+
+        assertTrue(designatedPdp.getPdpId().equals(pdp1.getPdpId()));
+
+
+        // Finally, we will have 2 pdps in the listOfDesignated, one in the same site with the mostRecentPrimary
+
+
+        listOfDesignated.remove(pdp1);
+        listOfDesignated.add(pdp3);
+
+        designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
+
+
+        // The designatedPdp should now be the one on the same site as the mostRecentPrimary
+
+
+        assertTrue(designatedPdp.getPdpId().equals(pdp3.getPdpId()));
+    }
+
+    /**
+     * Test cold standby.
+     * 
+     * @throws Exception exception
+     */
+    //@Ignore
+    //@Test
+    public void testColdStandby() throws Exception {
+
+        logger.debug("\n\ntestColdStandby: Entering\n\n");
+        cleanXacmlDb();
+        cleanDroolsDb();
+
+        logger.debug("testColdStandby: Reading stateManagementProperties");
+        Properties stateManagementProperties = new Properties();
+        stateManagementProperties.load(new FileInputStream(new File(
+                configDir + "/feature-state-management.properties")));
+
+        logger.debug("testColdStandby: Creating emfXacml");
+        final EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
+                "junitXacmlPU", stateManagementProperties);
+
+        logger.debug("testColdStandby: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        final String thisPdpId = activeStandbyProperties.getProperty(ActiveStandbyProperties.NODE_NAME);
+
+        logger.debug("testColdStandby: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
+
+        DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
+
+        logger.debug("testColdStandby: Cleaning up tables");
+        conn.deleteAllPdps();
+
+        logger.debug("testColdStandby: Inserting PDP={} as designated", thisPdpId);
+        DroolsPdp pdp = new DroolsPdpImpl(thisPdpId, true, 4, new Date());
+        conn.insertPdp(pdp);
+        DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.debug("testColdStandby: After insertion, DESIGNATED= {} "
+                + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
+        assertTrue(droolsPdpEntity.isDesignated() == true);
+
+        /*
+         * When the Standby Status changes (from providingservice) to hotstandby
+         * or coldstandby,the Active/Standby selection algorithm must stand down
+         * if thePDP-D is currently the lead/active node and allow another PDP-D
+         * to take over.
+         * 
+         * It must also call lock on all engines in the engine management.
+         */
+
+
+        /*
+         * Yes, this is kludgy, but we have a chicken and egg problem here: we
+         * need a StateManagement object to invoke the
+         * deleteAllStateManagementEntities method.
+         */
+        logger.debug("testColdStandby: Instantiating stateManagement object");
+
+        StateManagement sm = new StateManagement(emfXacml, "dummy");
+        sm.deleteAllStateManagementEntities();
+
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
+
+        StateManagementFeatureAPI smf = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            smf = feature;
+            logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}", smf.getResourceName());
+            break;
+        }
+        if (smf == null) {
+            logger.error("testColdStandby failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testColdStandby failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+        // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
+        // that has been created.
+        ActiveStandbyFeatureAPI activeStandbyFeature = null;
+        for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            activeStandbyFeature = feature;
+            logger.debug("testColdStandby activeStandbyFeature.getResourceName(): {}", 
+                    activeStandbyFeature.getResourceName());
+            break;
+        }
+        if (activeStandbyFeature == null) {
+            logger.error("testColdStandby failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID:{}", thisPdpId);
+            logger.debug("testColdStandby failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID:{}", thisPdpId);
+        }
+
+        // Artificially putting a PDP into service is really a two step process, 1)
+        // inserting it as designated and 2) promoting it so that its standbyStatus
+        // is providing service.
+
+        logger.debug("testColdStandby: Runner started; Sleeping "
+                + interruptRecoveryTime + "ms before promoting PDP= {}",
+                thisPdpId);
+        sleep(interruptRecoveryTime);
+
+        logger.debug("testColdStandby: Promoting PDP={}", thisPdpId);
+        smf.promote();
+
+        String standbyStatus = sm.getStandbyStatus(thisPdpId);
+        logger.debug("testColdStandby: Before locking, PDP= {}  has standbyStatus= {}",
+                thisPdpId, standbyStatus);
+
+        logger.debug("testColdStandby: Locking smf");
+        smf.lock();
+
+        sleep(interruptRecoveryTime);
+
+        // Verify that the PDP is no longer designated.
+
+        droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.debug("testColdStandby: After lock sm.lock() invoked, "
+                + "DESIGNATED= {} for PDP={}", droolsPdpEntity.isDesignated(), thisPdpId);
+        assertTrue(droolsPdpEntity.isDesignated() == false);
+
+        logger.debug("\n\ntestColdStandby: Exiting\n\n");
+        sleep(interruptRecoveryTime);
+
+    }
+
+    // Tests hot standby when there is only one PDP.
+
+    /**
+     * Test hot standby 1.
+     * 
+     * @throws Exception exception
+     */
+    //@Ignore
+    //@Test
+    public void testHotStandby1() throws Exception {
+
+        logger.debug("\n\ntestHotStandby1: Entering\n\n");
+        cleanXacmlDb();
+        cleanDroolsDb();
+
+        logger.debug("testHotStandby1: Reading stateManagementProperties");
+        Properties stateManagementProperties = new Properties();
+        stateManagementProperties.load(new FileInputStream(new File(
+                configDir + "/feature-state-management.properties")));
+
+        logger.debug("testHotStandby1: Creating emfXacml");
+        final EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
+                "junitXacmlPU", stateManagementProperties);
+
+        logger.debug("testHotStandby1: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        final String thisPdpId = activeStandbyProperties
+                .getProperty(ActiveStandbyProperties.NODE_NAME);
+
+        logger.debug("testHotStandby1: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
+
+        DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
+
+        logger.debug("testHotStandby1: Cleaning up tables");
+        conn.deleteAllPdps();
+
+        /*
+         * Insert this PDP as not designated.  Initial standby state will be 
+         * either null or cold standby.   Demoting should transit state to
+         * hot standby.
+         */
+
+        logger.debug("testHotStandby1: Inserting PDP={} as not designated", thisPdpId);
+        Date yesterday = DateUtils.addDays(new Date(), -1);
+        DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
+        conn.insertPdp(pdp);
+        DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.debug("testHotStandby1: After insertion, PDP={} has DESIGNATED={}",
+                thisPdpId, droolsPdpEntity.isDesignated());
+        assertTrue(droolsPdpEntity.isDesignated() == false);
+
+        logger.debug("testHotStandby1: Instantiating stateManagement object");
+        StateManagement sm = new StateManagement(emfXacml, "dummy");
+        sm.deleteAllStateManagementEntities();
+
+
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
+
+        StateManagementFeatureAPI smf = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            smf = feature;
+            logger.debug("testHotStandby1 stateManagementFeature.getResourceName(): {}", smf.getResourceName());
+            break;
+        }
+        if (smf == null) {
+            logger.error("testHotStandby1 failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testHotStandby1 failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+        // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
+        // that has been created.
+        ActiveStandbyFeatureAPI activeStandbyFeature = null;
+        for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            activeStandbyFeature = feature;
+            logger.debug("testHotStandby1 activeStandbyFeature.getResourceName(): {}", 
+                    activeStandbyFeature.getResourceName());
+            break;
+        }
+        if (activeStandbyFeature == null) {
+            logger.error("testHotStandby1 failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testHotStandby1 failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+
+        logger.debug("testHotStandby1: Demoting PDP={}", thisPdpId);
+        // demoting should cause state to transit to hotstandby
+        smf.demote();
+
+
+        logger.debug("testHotStandby1: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
+                + "time to check droolspdpentity table", sleepTime);
+        sleep(sleepTime);
+
+
+        // Verify that this formerly un-designated PDP in HOT_STANDBY is now designated and providing service.
+
+        droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.debug("testHotStandby1: After sm.demote() invoked, DESIGNATED= {} "
+                + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
+        assertTrue(droolsPdpEntity.isDesignated() == true);
+        String standbyStatus = smf.getStandbyStatus(thisPdpId);
+        logger.debug("testHotStandby1: After demotion, PDP= {} "
+                + "has standbyStatus= {}", thisPdpId, standbyStatus);
+        assertTrue(standbyStatus != null  &&  standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
+
+        logger.debug("testHotStandby1: Stopping policyManagementRunner");
+
+        logger.debug("\n\ntestHotStandby1: Exiting\n\n");
+        sleep(interruptRecoveryTime);
+
+    }
+
+    /*
+     * Tests hot standby when two PDPs are involved.
+     */
+
+    /**
+     * Test hot standby 2.
+     * 
+     * @throws Exception exception
+     */
+    //@Ignore
+    //@Test
+    public void testHotStandby2() throws Exception {
+
+        logger.info("\n\ntestHotStandby2: Entering\n\n");
+        cleanXacmlDb();
+        cleanDroolsDb();
+
+        logger.info("testHotStandby2: Reading stateManagementProperties");
+        Properties stateManagementProperties = new Properties();
+        stateManagementProperties.load(new FileInputStream(new File(
+                configDir + "/feature-state-management.properties")));
+
+        logger.info("testHotStandby2: Creating emfXacml");
+        final EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
+                "junitXacmlPU", stateManagementProperties);
+
+        logger.info("testHotStandby2: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        final String thisPdpId = activeStandbyProperties
+                .getProperty(ActiveStandbyProperties.NODE_NAME);
+
+        logger.info("testHotStandby2: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
+
+        DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
+
+        logger.info("testHotStandby2: Cleaning up tables");
+        conn.deleteAllPdps();
+
+
+        // Insert a PDP that's designated but not current.
+
+        String activePdpId = "pdp2";
+        logger.info("testHotStandby2: Inserting PDP={} as stale, designated PDP", activePdpId);
+        Date yesterday = DateUtils.addDays(new Date(), -1);
+        DroolsPdp pdp = new DroolsPdpImpl(activePdpId, true, 4, yesterday);
+        conn.insertPdp(pdp);
+        DroolsPdpEntity droolsPdpEntity = conn.getPdp(activePdpId);
+        logger.info("testHotStandby2: After insertion, PDP= {}, which is "
+                + "not current, has DESIGNATED= {}", activePdpId, droolsPdpEntity.isDesignated());
+        assertTrue(droolsPdpEntity.isDesignated() == true);
+
+        /*
+         * Promote the designated PDP.
+         * 
+         * We have a chicken and egg problem here: we need a StateManagement
+         * object to invoke the deleteAllStateManagementEntities method.
+         */
+
+
+        logger.info("testHotStandby2: Promoting PDP={}", activePdpId);
+        StateManagement sm = new StateManagement(emfXacml, "dummy");
+        sm.deleteAllStateManagementEntities();
+
+
+        sm = new StateManagement(emfXacml, activePdpId);//pdp2
+
+        // Artificially putting a PDP into service is really a two step process, 1)
+        // inserting it as designated and 2) promoting it so that its standbyStatus
+        // is providing service.
+
+        /*
+         * Insert this PDP as not designated.  Initial standby state will be 
+         * either null or cold standby.   Demoting should transit state to
+         * hot standby.
+         */
+
+
+        logger.info("testHotStandby2: Inserting PDP= {} as not designated", thisPdpId);
+        pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
+        conn.insertPdp(pdp);
+        droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.info("testHotStandby2: After insertion, PDP={} "
+                + "has DESIGNATED= {}", thisPdpId, droolsPdpEntity.isDesignated());
+        assertTrue(droolsPdpEntity.isDesignated() == false);
+
+
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
+
+        StateManagementFeatureAPI sm2 = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            sm2 = feature;
+            logger.debug("testHotStandby2 stateManagementFeature.getResourceName(): {}", sm2.getResourceName());
+            break;
+        }
+        if (sm2 == null) {
+            logger.error("testHotStandby2 failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testHotStandby2 failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+        // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
+        // that has been created.
+        ActiveStandbyFeatureAPI activeStandbyFeature = null;
+        for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            activeStandbyFeature = feature;
+            logger.debug("testHotStandby2 activeStandbyFeature.getResourceName(): {}", 
+                    activeStandbyFeature.getResourceName());
+            break;
+        }
+        if (activeStandbyFeature == null) {
+            logger.error("testHotStandby2 failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testHotStandby2 failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+        logger.info("testHotStandby2: Runner started; Sleeping {} "
+                + "ms before promoting/demoting", interruptRecoveryTime);
+        sleep(interruptRecoveryTime);
+
+        logger.info("testHotStandby2: Runner started; promoting PDP={}", activePdpId);
+        //At this point, the newly created pdp will have set the state to disabled/failed/cold standby
+        //because it is stale. So, it cannot be promoted.  We need to call sm.enableNotFailed() so we
+        //can promote it and demote the other pdp - else the other pdp will just spring back to providingservice
+        sm.enableNotFailed();//pdp2
+        sm.promote();
+        String standbyStatus = sm.getStandbyStatus(activePdpId);
+        logger.info("testHotStandby2: After promoting, PDP= {} has standbyStatus= {}", activePdpId, standbyStatus);
+
+        // demoting PDP should ensure that state transits to hotstandby
+        logger.info("testHotStandby2: Runner started; demoting PDP= {}", thisPdpId);
+        sm2.demote();//pdp1
+        standbyStatus = sm.getStandbyStatus(thisPdpId);
+        logger.info("testHotStandby2: After demoting, PDP={} has standbyStatus= {}",thisPdpId , standbyStatus);
+
+        logger.info("testHotStandby2: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
+                + "time to check droolspdpentity table", sleepTime);
+        sleep(sleepTime);
+
+        /*
+         * Verify that this PDP, demoted to HOT_STANDBY, is now
+         * re-designated and providing service.
+         */
+
+        droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.info("testHotStandby2: After demoting PDP={}"
+                + ", DESIGNATED= {}"
+                + " for PDP= {}", activePdpId, droolsPdpEntity.isDesignated(), thisPdpId);
+        assertTrue(droolsPdpEntity.isDesignated() == true);
+        standbyStatus = sm2.getStandbyStatus(thisPdpId);
+        logger.info("testHotStandby2: After demoting PDP={}"
+                + ", PDP={} has standbyStatus= {}",
+                activePdpId, thisPdpId, standbyStatus);
+        assertTrue(standbyStatus != null
+                && standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
+
+        logger.info("testHotStandby2: Stopping policyManagementRunner");
+
+        logger.info("\n\ntestHotStandby2: Exiting\n\n");
+        sleep(interruptRecoveryTime);
+
+    }
+
+    /*
+     * 1) Inserts and designates this PDP, then verifies that startTransaction
+     * is successful.
+     * 
+     * 2) Demotes PDP, and verifies that because there is only one PDP, it will
+     * be immediately re-promoted, thus allowing startTransaction to be
+     * successful.
+     * 
+     * 3) Locks PDP and verifies that startTransaction results in
+     * AdministrativeStateException.
+     * 
+     * 4) Unlocks PDP and verifies that startTransaction results in
+     * StandbyStatusException.
+     * 
+     * 5) Promotes PDP and verifies that startTransaction is once again
+     * successful.
+     */
+
+    /**
+     * Test locking.
+     * 
+     * @throws Exception exception
+     */
+    //@Ignore
+    //@Test
+    public void testLocking1() throws Exception {
+        logger.debug("testLocking1: Entry");
+        cleanXacmlDb();
+        cleanDroolsDb();
+
+        logger.debug("testLocking1: Reading stateManagementProperties");
+        Properties stateManagementProperties = new Properties();
+        stateManagementProperties.load(new FileInputStream(new File(
+                configDir + "/feature-state-management.properties")));
+
+        logger.debug("testLocking1: Creating emfXacml");
+        final EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
+                "junitXacmlPU", stateManagementProperties);
+
+        logger.debug("testLocking1: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        final String thisPdpId = activeStandbyProperties
+                .getProperty(ActiveStandbyProperties.NODE_NAME);
+
+        logger.debug("testLocking1: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
+
+        DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
+
+        logger.debug("testLocking1: Cleaning up tables");
+        conn.deleteAllPdps();
+
+        /*
+         * Insert this PDP as designated.  Initial standby state will be 
+         * either null or cold standby.
+         */   
+
+        logger.debug("testLocking1: Inserting PDP= {} as designated", thisPdpId);
+        DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, true, 4, new Date());
+        conn.insertPdp(pdp);
+        DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.debug("testLocking1: After insertion, PDP= {} has DESIGNATED= {}",
+                thisPdpId, droolsPdpEntity.isDesignated());
+        assertTrue(droolsPdpEntity.isDesignated() == true);
+
+        logger.debug("testLocking1: Instantiating stateManagement object");
+        StateManagement smDummy = new StateManagement(emfXacml, "dummy");
+        smDummy.deleteAllStateManagementEntities();
+
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
+
+        StateManagementFeatureAPI sm = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            sm = feature;
+            logger.debug("testLocking1 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
+            break;
+        }
+        if (sm == null) {
+            logger.error("testLocking1 failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testLocking1 failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+        // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
+        // that has been created.
+        ActiveStandbyFeatureAPI activeStandbyFeature = null;
+        for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            activeStandbyFeature = feature;
+            logger.debug("testLocking1 activeStandbyFeature.getResourceName(): {}", 
+                    activeStandbyFeature.getResourceName());
+            break;
+        }
+        if (activeStandbyFeature == null) {
+            logger.error("testLocking1 failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testLocking1 failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
+
+        logger.debug("testLocking1: Runner started; Sleeping "
+                + interruptRecoveryTime + "ms before promoting PDP={}",
+                thisPdpId);
+        sleep(interruptRecoveryTime);
+
+        logger.debug("testLocking1: Promoting PDP={}", thisPdpId);
+        sm.promote();
 
+        logger.debug("testLocking1: Sleeping {} ms, to allow time for "
+                + "policy-management.Main class to come up, designated= {}", 
+                sleepTime, conn.getPdp(thisPdpId).isDesignated());
+        sleep(sleepTime);
 
-	//@Ignore
-	//@Test
-	public void testComputeMostRecentPrimary() throws Exception {
+        logger.debug("testLocking1: Waking up and invoking startTransaction on active PDP={}"
+                + ", designated= {}",thisPdpId, conn.getPdp(thisPdpId).isDesignated());
 
-		logger.debug("\n\ntestComputeMostRecentPrimary: Entering\n\n");
-		
-		logger.debug("testComputeMostRecentPrimary: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties
-				.getProperty(ActiveStandbyProperties.NODE_NAME);
 
-		logger.debug("testComputeMostRecentPrimary: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfDrools);
-		
-		
-		// Create 4 pdpd all not designated
-		 
-		 
-		long designatedDateMS = new Date().getTime();
-		DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, new Date());
-		pdp1.setDesignatedDate(new Date(designatedDateMS - 2));
-		
-		DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, new Date());
-		//oldest
-		pdp2.setDesignatedDate(new Date(designatedDateMS - 3));
-		
-		DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
-		pdp3.setDesignatedDate(new Date(designatedDateMS - 1));
+        IntegrityMonitor droolsPdpIntegrityMonitor = IntegrityMonitor.getInstance();
+        try {
+            droolsPdpIntegrityMonitor.startTransaction();
+            droolsPdpIntegrityMonitor.endTransaction();
+            logger.debug("testLocking1: As expected, transaction successful");
+        } catch (AdministrativeStateException e) {
+            logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
+            assertTrue(false);
+        } catch (StandbyStatusException e) {
+            logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
+            assertTrue(false);
+        } catch (Exception e) {
+            logger.error("testLocking1: Unexpectedly caught Exception, ", e);
+            assertTrue(false);
+        }
 
-		DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
-		//most recent
-		pdp4.setDesignatedDate(new Date(designatedDateMS));
-		
-		ArrayList<DroolsPdp> listOfAllPdps = new ArrayList<DroolsPdp>();
-		listOfAllPdps.add(pdp1);
-		listOfAllPdps.add(pdp2);
-		listOfAllPdps.add(pdp3);
-		listOfAllPdps.add(pdp4);
-				
-		
-		ArrayList<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
-		listOfDesignated.add(pdp1);
-		listOfDesignated.add(pdp2);
-		listOfDesignated.add(pdp3);
-		listOfDesignated.add(pdp4);
-		
-		// Because the way we sanitize the listOfDesignated, it will always contain all hot standby 
-		// or all designated members.
-		 
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+        // demoting should cause state to transit to hotstandby, followed by re-promotion,
+        // since there is only one PDP.
+        logger.debug("testLocking1: demoting PDP={}", thisPdpId);
+        sm.demote();
 
-		StateManagementFeatureAPI stateManagementFeature = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			stateManagementFeature = feature;
-			logger.debug("testComputeMostRecentPrimary stateManagementFeature.getResourceName(): {}", stateManagementFeature.getResourceName());
-			break;
-		}
-		if(stateManagementFeature == null){
-			logger.error("testComputeMostRecentPrimary failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testComputeMostRecentPrimary failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		DroolsPdpsElectionHandler droolsPdpsElectionHandler =  new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
-	
-		DroolsPdp mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-		
-		logger.debug("\n\ntestComputeMostRecentPrimary: mostRecentPrimary.getPdpId() = {}\n\n", mostRecentPrimary.getPdpId());
-		
-		
-		// If all of the pdps are included in the listOfDesignated and none are designated, it will choose 
-		// the one which has the most recent designated date.
-		 
-		 
-		assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
-		
-		
-		// Now let's designate all of those on the listOfDesignated.  It will choose the first one designated
-		 
-		 
-		pdp1.setDesignated(true);
-		pdp2.setDesignated(true);
-		pdp3.setDesignated(true);
-		pdp4.setDesignated(true);
-		
-		mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-		
-		logger.debug("\n\ntestComputeMostRecentPrimary: All designated all on list, mostRecentPrimary.getPdpId() = {}\n\n", mostRecentPrimary.getPdpId());
-		
-		
-		// If all of the pdps are included in the listOfDesignated and all are designated, it will choose 
-		// the one which was designated first
-		 
-		 
-		assertTrue(mostRecentPrimary.getPdpId().equals("pdp2"));
-		
-		
-		// Now we will designate only 2 and put just them in the listOfDesignated.  The algorithm will now
-		// look for the most recently designated pdp which is not currently designated.
-		 
-		 
-		pdp3.setDesignated(false);
-		pdp4.setDesignated(false);
-		
-		listOfDesignated.remove(pdp3);
-		listOfDesignated.remove(pdp4);
-		
-		mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-		
-		logger.debug("\n\ntestComputeMostRecentPrimary: mostRecentPrimary.getPdpId() = {}\n\n", mostRecentPrimary.getPdpId());
-		
-		assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
-		
-		
-		
-		// Now we will have none designated and put two of them in the listOfDesignated.  The algorithm will now
-		// look for the most recently designated pdp regardless of whether it is currently marked as designated.
-		 
-		 
-		pdp1.setDesignated(false);
-		pdp2.setDesignated(false);
-		
-		mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-		
-		logger.debug("\n\ntestComputeMostRecentPrimary: 2 on list mostRecentPrimary.getPdpId() = {}\n\n", mostRecentPrimary.getPdpId());
-		
-		assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
-		
-		
-		// If we have only one pdp on in the listOfDesignated, the most recently designated pdp will be chosen, regardless
-		// of its designation status
-		 
-		 
-		listOfDesignated.remove(pdp1);
-		
-		mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-		
-		logger.debug("\n\ntestComputeMostRecentPrimary: 1 on list mostRecentPrimary.getPdpId() = {}\n\n", mostRecentPrimary.getPdpId());
-		
-		assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
-		
-		
-		// Finally, if none are on the listOfDesignated, it will again choose the most recently designated pdp.
-		 
-		 
-		listOfDesignated.remove(pdp2);
+        logger.debug("testLocking1: sleeping" + electionWaitSleepTime
+                + " to allow election handler to re-promote PDP={}", thisPdpId);
+        sleep(electionWaitSleepTime);
 
-		mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-		
-		logger.debug("\n\ntestComputeMostRecentPrimary: 0 on list mostRecentPrimary.getPdpId() = {}\n\n", mostRecentPrimary.getPdpId());
-		
-		assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
-		
-	}
+        logger.debug("testLocking1: Invoking startTransaction on re-promoted PDP={}"
+                + ", designated={}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
+        try {
+            droolsPdpIntegrityMonitor.startTransaction();
+            droolsPdpIntegrityMonitor.endTransaction();
+            logger.debug("testLocking1: As expected, transaction successful");
+        } catch (AdministrativeStateException e) {
+            logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
+            assertTrue(false);
+        } catch (StandbyStatusException e) {
+            logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
+            assertTrue(false);
+        } catch (Exception e) {
+            logger.error("testLocking1: Unexpectedly caught Exception, ", e);
+            assertTrue(false);
+        }
 
-	//@Ignore
-	//@Test
-	public void testComputeDesignatedPdp() throws Exception{
-		
-		logger.debug("\n\ntestComputeDesignatedPdp: Entering\n\n");
-		
-		logger.debug("testComputeDesignatedPdp: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties
-				.getProperty(ActiveStandbyProperties.NODE_NAME);
-		 
+        // locking should cause state to transit to cold standby
+        logger.debug("testLocking1: locking PDP={}", thisPdpId);
+        sm.lock();
 
-		logger.debug("testComputeDesignatedPdp: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfDrools);
-		
-		
-		// Create 4 pdpd all not designated.  Two on site1. Two on site2
-		 
-		 
-		long designatedDateMS = new Date().getTime();
-		DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, new Date());
-		pdp1.setDesignatedDate(new Date(designatedDateMS - 2));
-		pdp1.setSiteName("site1");
-		
-		DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, new Date());
-		pdp2.setDesignatedDate(new Date(designatedDateMS - 3));
-		pdp2.setSiteName("site1");
+        // Just to avoid any race conditions, sleep a little after locking
+        logger.debug("testLocking1: Sleeping a few millis after locking, to avoid race condition");
+        sleep(100);
 
-		//oldest		
-		DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
-		pdp3.setDesignatedDate(new Date(designatedDateMS - 4));
-		pdp3.setSiteName("site2");
-		
-		DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
-		//most recent
-		pdp4.setDesignatedDate(new Date(designatedDateMS));
-		pdp4.setSiteName("site2");
-		
-		ArrayList<DroolsPdp> listOfAllPdps = new ArrayList<DroolsPdp>();
-		listOfAllPdps.add(pdp1);
-		listOfAllPdps.add(pdp2);
-		listOfAllPdps.add(pdp3);
-		listOfAllPdps.add(pdp4);
-				
-		
-		ArrayList<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
-		
-		
-		// We will first test an empty listOfDesignated. As we know from the previous JUnit,
-		// the pdp with the most designated date will be chosen for mostRecentPrimary
-		
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+        logger.debug("testLocking1: Invoking startTransaction on locked PDP= {}"
+                + ", designated= {}",thisPdpId, conn.getPdp(thisPdpId).isDesignated());
+        try {
+            droolsPdpIntegrityMonitor.startTransaction();
+            logger.error("testLocking1: startTransaction unexpectedly successful");
+            assertTrue(false);
+        } catch (AdministrativeStateException e) {
+            logger.debug("testLocking1: As expected, caught AdministrativeStateException, ", e);
+        } catch (StandbyStatusException e) {
+            logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
+            assertTrue(false);
+        } catch (Exception e) {
+            logger.error("testLocking1: Unexpectedly caught Exception, ", e);
+            assertTrue(false);
+        } finally {
+            droolsPdpIntegrityMonitor.endTransaction();
+        }
 
-		StateManagementFeatureAPI stateManagementFeature = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			stateManagementFeature = feature;
-			logger.debug("testComputeDesignatedPdp stateManagementFeature.getResourceName(): {}", stateManagementFeature.getResourceName());
-			break;
-		}
-		if(stateManagementFeature == null){
-			logger.error("testComputeDesignatedPdp failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testComputeDesignatedPdp failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-	
-		DroolsPdpsElectionHandler droolsPdpsElectionHandler =  new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
-		
-		DroolsPdp mostRecentPrimary = pdp4;
-	
-		DroolsPdp designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-		
-		
-		// The designatedPdp should be null
-		 
-		assertTrue(designatedPdp==null);
-		
-		
-		// Now let's try having only one pdp in listOfDesignated, but not in the same site as the most recent primary
-		 
-		listOfDesignated.add(pdp2);
-		
-		designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-		
-		
-		// Now the designatedPdp should be the one and only selection in the listOfDesignated
-		 
-		 
-		assertTrue(designatedPdp.getPdpId().equals(pdp2.getPdpId()));
-		
-		
-		// Now let's put 2 pdps in the listOfDesignated, neither in the same site as the mostRecentPrimary
-		 
-		 
-		listOfDesignated.add(pdp1);
-		
-		designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-		
-		
-		// The designatedPdp should now be the one with the lowest lexiographic score - pdp1
-		 
-		 
-		assertTrue(designatedPdp.getPdpId().equals(pdp1.getPdpId()));
-		
-		
-		// Finally, we will have 2 pdps in the listOfDesignated, one in the same site with the mostRecentPrimary
-		 
-		 
-		listOfDesignated.remove(pdp1);
-		listOfDesignated.add(pdp3);
-		
-		designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-		
-		
-		// The designatedPdp should now be the one on the same site as the mostRecentPrimary
-		 
-		 
-		assertTrue(designatedPdp.getPdpId().equals(pdp3.getPdpId()));
-	}
-	
-	//@Ignore
-	//@Test
-	public void testColdStandby() throws Exception {
+        // unlocking should cause state to transit to hot standby and then providing service
+        logger.debug("testLocking1: unlocking PDP={}", thisPdpId);
+        sm.unlock();
 
-		logger.debug("\n\ntestColdStandby: Entering\n\n");
-		cleanXacmlDb();
-		cleanDroolsDb();
+        // Just to avoid any race conditions, sleep a little after locking
+        logger.debug("testLocking1: Sleeping a few millis after unlocking, to avoid race condition");
+        sleep(electionWaitSleepTime);
 
-		logger.debug("testColdStandby: Reading stateManagementProperties");
-		Properties stateManagementProperties = new Properties();
-		stateManagementProperties.load(new FileInputStream(new File(
-				configDir + "/feature-state-management.properties")));
-		
-		logger.debug("testColdStandby: Creating emfXacml");
-		EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
-				"junitXacmlPU", stateManagementProperties);
-		
-		logger.debug("testColdStandby: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties.getProperty(ActiveStandbyProperties.NODE_NAME);
+        logger.debug("testLocking1: Invoking startTransaction on unlocked PDP="
+                + thisPdpId
+                + ", designated="
+                + conn.getPdp(thisPdpId).isDesignated());
+        try {
+            droolsPdpIntegrityMonitor.startTransaction();
+            logger.error("testLocking1: startTransaction successful as expected");
+        } catch (AdministrativeStateException e) {
+            logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
+            assertTrue(false);
+        } catch (StandbyStatusException e) {
+            logger.debug("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
+            assertTrue(false);
+        } catch (Exception e) {
+            logger.error("testLocking1: Unexpectedly caught Exception, ", e);
+            assertTrue(false);
+        } finally {
+            droolsPdpIntegrityMonitor.endTransaction();
+        }
 
-		logger.debug("testColdStandby: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
-		
-		logger.debug("testColdStandby: Cleaning up tables");
-		conn.deleteAllPdps();
-	
-		logger.debug("testColdStandby: Inserting PDP={} as designated", thisPdpId);
-		DroolsPdp pdp = new DroolsPdpImpl(thisPdpId, true, 4, new Date());
-		conn.insertPdp(pdp);
-		DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.debug("testColdStandby: After insertion, DESIGNATED= {} "
-				+ "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
-		assertTrue(droolsPdpEntity.isDesignated() == true);
+        // demoting should cause state to transit to hot standby
+        logger.debug("testLocking1: demoting PDP={}", thisPdpId);
+        sm.demote();
 
-		/*
-		 * When the Standby Status changes (from providingservice) to hotstandby
-		 * or coldstandby,the Active/Standby selection algorithm must stand down
-		 * if thePDP-D is currently the lead/active node and allow another PDP-D
-		 * to take over.
-		 * 
-		 * It must also call lock on all engines in the engine management.
-		 */
-		
-		
-		/*
-		 * Yes, this is kludgy, but we have a chicken and egg problem here: we
-		 * need a StateManagement object to invoke the
-		 * deleteAllStateManagementEntities method.
-		 */
-		logger.debug("testColdStandby: Instantiating stateManagement object");
-		
-		StateManagement sm = new StateManagement(emfXacml, "dummy");
-		sm.deleteAllStateManagementEntities();
-			
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+        // Just to avoid any race conditions, sleep a little after promoting
+        logger.debug("testLocking1: Sleeping a few millis after demoting, to avoid race condition");
+        sleep(100);
 
-		StateManagementFeatureAPI smf = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			smf = feature;
-			logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}", smf.getResourceName());
-			break;
-		}
-		if(smf == null){
-			logger.error("testColdStandby failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testColdStandby failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
-		// that has been created.
-		ActiveStandbyFeatureAPI activeStandbyFeature = null;
-		for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			activeStandbyFeature = feature;
-			logger.debug("testColdStandby activeStandbyFeature.getResourceName(): {}", activeStandbyFeature.getResourceName());
-			break;
-		}
-		if(activeStandbyFeature == null){
-			logger.error("testColdStandby failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID:{}", thisPdpId);
-			logger.debug("testColdStandby failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID:{}", thisPdpId);
-		}
+        logger.debug("testLocking1: Invoking startTransaction on demoted PDP={}"
+                + ", designated={}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
+        try {
+            droolsPdpIntegrityMonitor.startTransaction();
+            droolsPdpIntegrityMonitor.endTransaction();
+            logger.debug("testLocking1: Unexpectedly, transaction successful");
+            assertTrue(false);
+        } catch (AdministrativeStateException e) {
+            logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
+            assertTrue(false);
+        } catch (StandbyStatusException e) {
+            logger.error("testLocking1: As expected caught StandbyStatusException, ", e);
+        } catch (Exception e) {
+            logger.error("testLocking1: Unexpectedly caught Exception, ", e);
+            assertTrue(false);
+        }
 
-		// Artificially putting a PDP into service is really a two step process, 1)
-		// inserting it as designated and 2) promoting it so that its standbyStatus
-		// is providing service.
-		
-		logger.debug("testColdStandby: Runner started; Sleeping "
-				+ interruptRecoveryTime + "ms before promoting PDP= {}",
-				thisPdpId);
-		sleep(interruptRecoveryTime);
+        logger.debug("\n\ntestLocking1: Exiting\n\n");
+        sleep(interruptRecoveryTime);
 
-		logger.debug("testColdStandby: Promoting PDP={}", thisPdpId);
-		smf.promote();		
-		
-		String standbyStatus = sm.getStandbyStatus(thisPdpId);
-		logger.debug("testColdStandby: Before locking, PDP= {}  has standbyStatus= {}",
-				 thisPdpId, standbyStatus);
-		
-		logger.debug("testColdStandby: Locking smf");
-		smf.lock();
-		
-		sleep(interruptRecoveryTime);
-		
-		// Verify that the PDP is no longer designated.
-		 
-		droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.debug("testColdStandby: After lock sm.lock() invoked, "
-				+ "DESIGNATED= {} for PDP={}", droolsPdpEntity.isDesignated(), thisPdpId);
-		assertTrue(droolsPdpEntity.isDesignated() == false);
-		
-		logger.debug("\n\ntestColdStandby: Exiting\n\n");
-		sleep(interruptRecoveryTime);
+    }
 
-	}
 
-	// Tests hot standby when there is only one PDP.
-	 
-	//@Ignore
-	//@Test
-	public void testHotStandby1() throws Exception {
-	
-		logger.debug("\n\ntestHotStandby1: Entering\n\n");
-		cleanXacmlDb();
-		cleanDroolsDb();
-		
-		logger.debug("testHotStandby1: Reading stateManagementProperties");
-		Properties stateManagementProperties = new Properties();
-		stateManagementProperties.load(new FileInputStream(new File(
-				configDir + "/feature-state-management.properties")));
+    /*
+     * 1) Inserts and designates this PDP, then verifies that startTransaction
+     * is successful.
+     * 
+     * 2) Inserts another PDP in hotstandby.
+     * 
+     * 3) Demotes this PDP, and verifies 1) that other PDP is not promoted (because one
+     * PDP cannot promote another PDP) and 2) that this PDP is re-promoted.
+     */
 
-		logger.debug("testHotStandby1: Creating emfXacml");
-		EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
-				"junitXacmlPU", stateManagementProperties);
-		
-		logger.debug("testHotStandby1: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties
-				.getProperty(ActiveStandbyProperties.NODE_NAME);
+    /**
+     * Test locking 2.
+     * 
+     * @throws Exception exception
+     */
+    //@Ignore
+    //@Test
+    public void testLocking2() throws Exception {
 
-		logger.debug("testHotStandby1: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
-		
-		logger.debug("testHotStandby1: Cleaning up tables");
-		conn.deleteAllPdps();
-					
-		/*
-		 * Insert this PDP as not designated.  Initial standby state will be 
-		 * either null or cold standby.   Demoting should transit state to
-		 * hot standby.
-		 */
-		 
-		logger.debug("testHotStandby1: Inserting PDP={} as not designated", thisPdpId);
-		Date yesterday = DateUtils.addDays(new Date(), -1);
-		DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
-		conn.insertPdp(pdp);
-		DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.debug("testHotStandby1: After insertion, PDP={} has DESIGNATED={}",
-				thisPdpId, droolsPdpEntity.isDesignated());
-		assertTrue(droolsPdpEntity.isDesignated() == false);
-		
-		logger.debug("testHotStandby1: Instantiating stateManagement object");
-		StateManagement sm = new StateManagement(emfXacml, "dummy");
-		sm.deleteAllStateManagementEntities();
-		
-		
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+        logger.debug("\n\ntestLocking2: Entering\n\n");
+        cleanXacmlDb();
+        cleanDroolsDb();
 
-		StateManagementFeatureAPI smf = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			smf = feature;
-			logger.debug("testHotStandby1 stateManagementFeature.getResourceName(): {}", smf.getResourceName());
-			break;
-		}
-		if(smf == null){
-			logger.error("testHotStandby1 failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testHotStandby1 failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
-		// that has been created.
-		ActiveStandbyFeatureAPI activeStandbyFeature = null;
-		for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			activeStandbyFeature = feature;
-			logger.debug("testHotStandby1 activeStandbyFeature.getResourceName(): {}", activeStandbyFeature.getResourceName());
-			break;
-		}
-		if(activeStandbyFeature == null){
-			logger.error("testHotStandby1 failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testHotStandby1 failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
+        logger.debug("testLocking2: Reading stateManagementProperties");
+        Properties stateManagementProperties = new Properties();
+        stateManagementProperties.load(new FileInputStream(new File(
+                configDir + "/feature-state-management.properties")));
 
-		logger.debug("testHotStandby1: Demoting PDP={}", thisPdpId);
-		// demoting should cause state to transit to hotstandby
-		smf.demote();
-		
-				
-		logger.debug("testHotStandby1: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
-				+ "time to check droolspdpentity table", sleepTime);
-		sleep(sleepTime);
-		
-		
-		// Verify that this formerly un-designated PDP in HOT_STANDBY is now designated and providing service.
-		 
-		droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.debug("testHotStandby1: After sm.demote() invoked, DESIGNATED= {} "
-				+ "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
-		assertTrue(droolsPdpEntity.isDesignated() == true);
-		String standbyStatus = smf.getStandbyStatus(thisPdpId);
-		logger.debug("testHotStandby1: After demotion, PDP= {} "
-				+ "has standbyStatus= {}", thisPdpId, standbyStatus);
-		assertTrue(standbyStatus != null  &&  standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
-				
-		logger.debug("testHotStandby1: Stopping policyManagementRunner");
-		//policyManagementRunner.stopRunner();		
-	
-		logger.debug("\n\ntestHotStandby1: Exiting\n\n");
-		sleep(interruptRecoveryTime);
+        logger.debug("testLocking2: Creating emfXacml");
+        final EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
+                "junitXacmlPU", stateManagementProperties);
 
-	}
+        logger.debug("testLocking2: Reading activeStandbyProperties");
+        Properties activeStandbyProperties = new Properties();
+        activeStandbyProperties.load(new FileInputStream(new File(
+                configDir + "/feature-active-standby-management.properties")));
+        final String thisPdpId = activeStandbyProperties
+                .getProperty(ActiveStandbyProperties.NODE_NAME);
 
-	/*
-	 * Tests hot standby when two PDPs are involved.
-	 */
-		 
-	//@Ignore
-	//@Test
-	public void testHotStandby2() throws Exception {
+        logger.debug("testLocking2: Creating emfDrools");
+        EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
+                "junitDroolsPU", activeStandbyProperties);
 
-		logger.info("\n\ntestHotStandby2: Entering\n\n");
-		cleanXacmlDb();
-		cleanDroolsDb();
-		
-		logger.info("testHotStandby2: Reading stateManagementProperties");
-		Properties stateManagementProperties = new Properties();
-		stateManagementProperties.load(new FileInputStream(new File(
-				configDir + "/feature-state-management.properties")));
-		
-		logger.info("testHotStandby2: Creating emfXacml");
-		EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
-				"junitXacmlPU", stateManagementProperties);
-		
-		logger.info("testHotStandby2: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties
-				.getProperty(ActiveStandbyProperties.NODE_NAME);
+        DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
 
-		logger.info("testHotStandby2: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
-		
-		logger.info("testHotStandby2: Cleaning up tables");
-		conn.deleteAllPdps();
-		
-		
-		// Insert a PDP that's designated but not current.
-		 
-		String activePdpId = "pdp2";
-		logger.info("testHotStandby2: Inserting PDP={} as stale, designated PDP", activePdpId);
-		Date yesterday = DateUtils.addDays(new Date(), -1);
-		DroolsPdp pdp = new DroolsPdpImpl(activePdpId, true, 4, yesterday);
-		conn.insertPdp(pdp);
-		DroolsPdpEntity droolsPdpEntity = conn.getPdp(activePdpId);
-		logger.info("testHotStandby2: After insertion, PDP= {}, which is "
-				+ "not current, has DESIGNATED= {}", activePdpId, droolsPdpEntity.isDesignated());
-		assertTrue(droolsPdpEntity.isDesignated() == true);
-		
-		/*
-		 * Promote the designated PDP.
-		 * 
-		 * We have a chicken and egg problem here: we need a StateManagement
-		 * object to invoke the deleteAllStateManagementEntities method.
-		 */
-		 
-		 
-		logger.info("testHotStandby2: Promoting PDP={}", activePdpId);
-		StateManagement sm = new StateManagement(emfXacml, "dummy");
-		sm.deleteAllStateManagementEntities();
-		
-		
-		sm = new StateManagement(emfXacml, activePdpId);//pdp2
-		
-		// Artificially putting a PDP into service is really a two step process, 1)
-		// inserting it as designated and 2) promoting it so that its standbyStatus
-		// is providing service.
-				
-		/*
-		 * Insert this PDP as not designated.  Initial standby state will be 
-		 * either null or cold standby.   Demoting should transit state to
-		 * hot standby.
-		 */
-		 
-		 
-		logger.info("testHotStandby2: Inserting PDP= {} as not designated", thisPdpId);
-		pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
-		conn.insertPdp(pdp);
-		droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.info("testHotStandby2: After insertion, PDP={} "
-				+ "has DESIGNATED= {}", thisPdpId, droolsPdpEntity.isDesignated());
-		assertTrue(droolsPdpEntity.isDesignated() == false);
-		
-		
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+        logger.debug("testLocking2: Cleaning up tables");
+        conn.deleteAllPdps();
 
-		StateManagementFeatureAPI sm2 = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			sm2 = feature;
-			logger.debug("testHotStandby2 stateManagementFeature.getResourceName(): {}", sm2.getResourceName());
-			break;
-		}
-		if(sm2 == null){
-			logger.error("testHotStandby2 failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testHotStandby2 failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
-		// that has been created.
-		ActiveStandbyFeatureAPI activeStandbyFeature = null;
-		for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			activeStandbyFeature = feature;
-			logger.debug("testHotStandby2 activeStandbyFeature.getResourceName(): {}", activeStandbyFeature.getResourceName());
-			break;
-		}
-		if(activeStandbyFeature == null){
-			logger.error("testHotStandby2 failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testHotStandby2 failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		logger.info("testHotStandby2: Runner started; Sleeping {} "
-				+ "ms before promoting/demoting", interruptRecoveryTime);
-		sleep(interruptRecoveryTime);
+        /*
+         * Insert this PDP as designated.  Initial standby state will be 
+         * either null or cold standby.   Demoting should transit state to
+         * hot standby.
+         */
 
-		logger.info("testHotStandby2: Runner started; promoting PDP={}", activePdpId);
-		//At this point, the newly created pdp will have set the state to disabled/failed/cold standby
-		//because it is stale. So, it cannot be promoted.  We need to call sm.enableNotFailed() so we
-		//can promote it and demote the other pdp - else the other pdp will just spring back to providingservice
-		sm.enableNotFailed();//pdp2
-		sm.promote();
-		String standbyStatus = sm.getStandbyStatus(activePdpId);
-		logger.info("testHotStandby2: After promoting, PDP= {} has standbyStatus= {}", activePdpId, standbyStatus);
-		
-		// demoting PDP should ensure that state transits to hotstandby
-		logger.info("testHotStandby2: Runner started; demoting PDP= {}", thisPdpId);
-		sm2.demote();//pdp1
-		standbyStatus = sm.getStandbyStatus(thisPdpId);
-		logger.info("testHotStandby2: After demoting, PDP={} has standbyStatus= {}",thisPdpId , standbyStatus);
-		
-		logger.info("testHotStandby2: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
-				+ "time to check droolspdpentity table", sleepTime);
-		sleep(sleepTime);
-		
-		/*
-		 * Verify that this PDP, demoted to HOT_STANDBY, is now
-		 * re-designated and providing service.
-		 */
-		 
-		droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.info("testHotStandby2: After demoting PDP={}"
-				+ ", DESIGNATED= {}"
-				+ " for PDP= {}", activePdpId, droolsPdpEntity.isDesignated(), thisPdpId);
-		assertTrue(droolsPdpEntity.isDesignated() == true);
-		standbyStatus = sm2.getStandbyStatus(thisPdpId);
-		logger.info("testHotStandby2: After demoting PDP={}"
-				+ ", PDP={} has standbyStatus= {}",
-				activePdpId, thisPdpId, standbyStatus);
-		assertTrue(standbyStatus != null
-				&& standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
-				
-		logger.info("testHotStandby2: Stopping policyManagementRunner");
-		//policyManagementRunner.stopRunner();		
+        logger.debug("testLocking2: Inserting PDP= {} as designated", thisPdpId);
+        DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, true, 3, new Date());
+        conn.insertPdp(pdp);
+        DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
+        logger.debug("testLocking2: After insertion, PDP= {} has DESIGNATED= {}",
+                thisPdpId, droolsPdpEntity.isDesignated());
+        assertTrue(droolsPdpEntity.isDesignated() == true);
 
-		logger.info("\n\ntestHotStandby2: Exiting\n\n");
-		sleep(interruptRecoveryTime);
+        logger.debug("testLocking2: Instantiating stateManagement object and promoting PDP={}", thisPdpId);
+        StateManagement smDummy = new StateManagement(emfXacml, "dummy");
+        smDummy.deleteAllStateManagementEntities();
 
-	}
-	
-	 /*		 	
-	 * 1) Inserts and designates this PDP, then verifies that startTransaction
-	 * is successful.
-	 * 
-	 * 2) Demotes PDP, and verifies that because there is only one PDP, it will
-	 * be immediately re-promoted, thus allowing startTransaction to be
-	 * successful.
-	 * 
-	 * 3) Locks PDP and verifies that startTransaction results in
-	 * AdministrativeStateException.
-	 * 
-	 * 4) Unlocks PDP and verifies that startTransaction results in
-	 * StandbyStatusException.
-	 * 
-	 * 5) Promotes PDP and verifies that startTransaction is once again
-	 * successful.
-	 */
-	 
-	//@Ignore
-	//@Test
-	public void testLocking1() throws Exception {
-		logger.debug("testLocking1: Entry");
-		cleanXacmlDb();
-		cleanDroolsDb();		
-		
-		logger.debug("testLocking1: Reading stateManagementProperties");
-		Properties stateManagementProperties = new Properties();
-		stateManagementProperties.load(new FileInputStream(new File(
-				configDir + "/feature-state-management.properties")));
+        // Now we want to create a StateManagementFeature and initialize it.  It will be
+        // discovered by the ActiveStandbyFeature when the election handler initializes.
 
-		logger.debug("testLocking1: Creating emfXacml");
-		EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
-				"junitXacmlPU", stateManagementProperties);
-		
-		logger.debug("testLocking1: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties
-				.getProperty(ActiveStandbyProperties.NODE_NAME);
+        StateManagementFeatureAPI sm = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            sm = feature;
+            logger.debug("testLocking2 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
+            break;
+        }
+        if (sm == null) {
+            logger.error("testLocking2 failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testLocking2 failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
 
-		logger.debug("testLocking1: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
-		
-		logger.debug("testLocking1: Cleaning up tables");
-		conn.deleteAllPdps();
-		
-		/*
-		 * Insert this PDP as designated.  Initial standby state will be 
-		 * either null or cold standby.
-		 */   
-		 
-		logger.debug("testLocking1: Inserting PDP= {} as designated", thisPdpId);
-		DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, true, 4, new Date());
-		conn.insertPdp(pdp);
-		DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.debug("testLocking1: After insertion, PDP= {} has DESIGNATED= {}",
-				 thisPdpId, droolsPdpEntity.isDesignated());
-		assertTrue(droolsPdpEntity.isDesignated() == true);
-		
-		logger.debug("testLocking1: Instantiating stateManagement object");
-		StateManagement smDummy = new StateManagement(emfXacml, "dummy");
-		smDummy.deleteAllStateManagementEntities();
-		
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+        // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
+        // that has been created.
+        ActiveStandbyFeatureAPI activeStandbyFeature = null;
+        for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            activeStandbyFeature = feature;
+            logger.debug("testLocking2 activeStandbyFeature.getResourceName(): {}", 
+                    activeStandbyFeature.getResourceName());
+            break;
+        }
+        if (activeStandbyFeature == null) {
+            logger.error("testLocking2 failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+            logger.debug("testLocking2 failed to initialize.  "
+                    + "Unable to get instance of ActiveStandbyFeatureAPI "
+                    + "with resourceID: {}", thisPdpId);
+        }
 
-		StateManagementFeatureAPI sm = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			sm = feature;
-			logger.debug("testLocking1 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
-			break;
-		}
-		if(sm == null){
-			logger.error("testLocking1 failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testLocking1 failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
-		// that has been created.
-		ActiveStandbyFeatureAPI activeStandbyFeature = null;
-		for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			activeStandbyFeature = feature;
-			logger.debug("testLocking1 activeStandbyFeature.getResourceName(): {}", activeStandbyFeature.getResourceName());
-			break;
-		}
-		if(activeStandbyFeature == null){
-			logger.error("testLocking1 failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testLocking1 failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		logger.debug("testLocking1: Runner started; Sleeping "
-				+ interruptRecoveryTime + "ms before promoting PDP={}",
-				thisPdpId);
-		sleep(interruptRecoveryTime);
+        /*
+         * Insert another PDP as not designated.  Initial standby state will be 
+         * either null or cold standby.   Demoting should transit state to
+         * hot standby.
+         */
 
-		logger.debug("testLocking1: Promoting PDP={}", thisPdpId);
-		sm.promote();
+        String standbyPdpId = "pdp2";
+        logger.debug("testLocking2: Inserting PDP= {} as not designated", standbyPdpId);
+        Date yesterday = DateUtils.addDays(new Date(), -1);
+        pdp = new DroolsPdpImpl(standbyPdpId, false, 4, yesterday);
+        conn.insertPdp(pdp);
+        droolsPdpEntity = conn.getPdp(standbyPdpId);
+        logger.debug("testLocking2: After insertion, PDP={} has DESIGNATED= {}", 
+                standbyPdpId, droolsPdpEntity.isDesignated());
+        assertTrue(droolsPdpEntity.isDesignated() == false);
 
-		logger.debug("testLocking1: Sleeping {} ms, to allow time for "
-				+ "policy-management.Main class to come up, designated= {}", 
-				 sleepTime, conn.getPdp(thisPdpId).isDesignated());
-		sleep(sleepTime);
-		
-		logger.debug("testLocking1: Waking up and invoking startTransaction on active PDP={}"
-				+ ", designated= {}",thisPdpId, conn.getPdp(thisPdpId).isDesignated());
+        logger.debug("testLocking2: Demoting PDP= {}", standbyPdpId);
+        final StateManagement sm2 = new StateManagement(emfXacml, standbyPdpId);
 
+        logger.debug("testLocking2: Runner started; Sleeping {} ms "
+                + "before promoting/demoting", interruptRecoveryTime);
+        sleep(interruptRecoveryTime);
 
-		IntegrityMonitor droolsPdpIntegrityMonitor = IntegrityMonitor.getInstance();
-		try {
-			droolsPdpIntegrityMonitor.startTransaction();
-			droolsPdpIntegrityMonitor.endTransaction();
-			logger.debug("testLocking1: As expected, transaction successful");
-		} catch (AdministrativeStateException e) {
-			logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
-			assertTrue(false);
-		} catch (StandbyStatusException e) {
-			logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
-			assertTrue(false);
-		} catch (Exception e) {
-			logger.error("testLocking1: Unexpectedly caught Exception, ", e);
-			assertTrue(false);
-		}
-		
-		// demoting should cause state to transit to hotstandby, followed by re-promotion,
-		// since there is only one PDP.
-		logger.debug("testLocking1: demoting PDP={}", thisPdpId);
-		sm.demote();
-		
-		logger.debug("testLocking1: sleeping" + electionWaitSleepTime
-				+ " to allow election handler to re-promote PDP={}", thisPdpId);
-		sleep(electionWaitSleepTime);
-								
-		logger.debug("testLocking1: Invoking startTransaction on re-promoted PDP={}"
-				+ ", designated={}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
-		try {
-			droolsPdpIntegrityMonitor.startTransaction();
-			droolsPdpIntegrityMonitor.endTransaction();
-			logger.debug("testLocking1: As expected, transaction successful");
-		} catch (AdministrativeStateException e) {
-			logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
-			assertTrue(false);
-		} catch (StandbyStatusException e) {
-			logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
-			assertTrue(false);
-		} catch (Exception e) {
-			logger.error("testLocking1: Unexpectedly caught Exception, ", e);
-			assertTrue(false);
-		}
-		
-		// locking should cause state to transit to cold standby
-		logger.debug("testLocking1: locking PDP={}", thisPdpId);
-		sm.lock();
-		
-		// Just to avoid any race conditions, sleep a little after locking
-		logger.debug("testLocking1: Sleeping a few millis after locking, to avoid race condition");
-		sleep(100);
-		
-		logger.debug("testLocking1: Invoking startTransaction on locked PDP= {}"
-				+ ", designated= {}",thisPdpId, conn.getPdp(thisPdpId).isDesignated());
-		try {
-			droolsPdpIntegrityMonitor.startTransaction();
-			logger.error("testLocking1: startTransaction unexpectedly successful");
-			assertTrue(false);
-		} catch (AdministrativeStateException e) {
-			logger.debug("testLocking1: As expected, caught AdministrativeStateException, ", e);
-		} catch (StandbyStatusException e) {
-			logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
-			assertTrue(false);
-		} catch (Exception e) {
-			logger.error("testLocking1: Unexpectedly caught Exception, ", e);
-			assertTrue(false);
-		} finally {
-			droolsPdpIntegrityMonitor.endTransaction();
-		}		
-		
-		// unlocking should cause state to transit to hot standby and then providing service
-		logger.debug("testLocking1: unlocking PDP={}", thisPdpId);
-		sm.unlock();
-		
-		// Just to avoid any race conditions, sleep a little after locking
-		logger.debug("testLocking1: Sleeping a few millis after unlocking, to avoid race condition");
-		sleep(electionWaitSleepTime);
-		
-		logger.debug("testLocking1: Invoking startTransaction on unlocked PDP="
-				+ thisPdpId
-				+ ", designated="
-				+ conn.getPdp(thisPdpId).isDesignated());
-		try {
-			droolsPdpIntegrityMonitor.startTransaction();
-			logger.error("testLocking1: startTransaction successful as expected");
-		} catch (AdministrativeStateException e) {
-			logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
-			assertTrue(false);
-		} catch (StandbyStatusException e) {
-			logger.debug("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
-			assertTrue(false);
-		} catch (Exception e) {
-			logger.error("testLocking1: Unexpectedly caught Exception, ", e);
-			assertTrue(false);
-		} finally {
-			droolsPdpIntegrityMonitor.endTransaction();
-		}
-		
-		// demoting should cause state to transit to hot standby
-		logger.debug("testLocking1: demoting PDP={}", thisPdpId);
-		sm.demote();
-		
-		// Just to avoid any race conditions, sleep a little after promoting
-		logger.debug("testLocking1: Sleeping a few millis after demoting, to avoid race condition");
-		sleep(100);
-		
-		logger.debug("testLocking1: Invoking startTransaction on demoted PDP={}"
-				+ ", designated={}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
-		try {
-			droolsPdpIntegrityMonitor.startTransaction();
-			droolsPdpIntegrityMonitor.endTransaction();
-			logger.debug("testLocking1: Unexpectedly, transaction successful");
-			assertTrue(false);
-		} catch (AdministrativeStateException e) {
-			logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
-			assertTrue(false);
-		} catch (StandbyStatusException e) {
-			logger.error("testLocking1: As expected caught StandbyStatusException, ", e);
-		} catch (Exception e) {
-			logger.error("testLocking1: Unexpectedly caught Exception, ", e);
-			assertTrue(false);
-		}
-		
-		logger.debug("\n\ntestLocking1: Exiting\n\n");
-		sleep(interruptRecoveryTime);
+        logger.debug("testLocking2: Promoting PDP= {}", thisPdpId);
+        sm.promote();
 
-	}
-	
-	
-	/*
-	 * 1) Inserts and designates this PDP, then verifies that startTransaction
-	 * is successful.
-	 * 
-	 * 2) Inserts another PDP in hotstandby.
-	 * 
-	 * 3) Demotes this PDP, and verifies 1) that other PDP is not promoted (because one
-	 * PDP cannot promote another PDP) and 2) that this PDP is re-promoted.
-	 */
-	 
-	//@Ignore
-	//@Test
-	public void testLocking2() throws Exception {
+        // demoting PDP should ensure that state transits to hotstandby
+        logger.debug("testLocking2: Demoting PDP={}", standbyPdpId);
+        sm2.demote();
 
-		logger.debug("\n\ntestLocking2: Entering\n\n");
-		cleanXacmlDb();
-		cleanDroolsDb();		
-		
-		logger.debug("testLocking2: Reading stateManagementProperties");
-		Properties stateManagementProperties = new Properties();
-		stateManagementProperties.load(new FileInputStream(new File(
-				configDir + "/feature-state-management.properties")));
+        logger.debug("testLocking2: Sleeping {} ms, to allow time for to come up", sleepTime);
+        sleep(sleepTime);
 
-		logger.debug("testLocking2: Creating emfXacml");
-		EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
-				"junitXacmlPU", stateManagementProperties);
-		
-		logger.debug("testLocking2: Reading activeStandbyProperties");
-		Properties activeStandbyProperties = new Properties();
-		activeStandbyProperties.load(new FileInputStream(new File(
-				configDir + "/feature-active-standby-management.properties")));
-		String thisPdpId = activeStandbyProperties
-				.getProperty(ActiveStandbyProperties.NODE_NAME);
+        logger.debug("testLocking2: Waking up and invoking startTransaction on active PDP={}"
+                + ", designated= {}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
 
-		logger.debug("testLocking2: Creating emfDrools");
-		EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
-				"junitDroolsPU", activeStandbyProperties);
-		
-		DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
-		
-		logger.debug("testLocking2: Cleaning up tables");
-		conn.deleteAllPdps();
-		
-		/*
-		 * Insert this PDP as designated.  Initial standby state will be 
-		 * either null or cold standby.   Demoting should transit state to
-		 * hot standby.
-		 */
-		 
-		logger.debug("testLocking2: Inserting PDP= {} as designated", thisPdpId);
-		DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, true, 3, new Date());
-		conn.insertPdp(pdp);
-		DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
-		logger.debug("testLocking2: After insertion, PDP= {} has DESIGNATED= {}",
-				thisPdpId, droolsPdpEntity.isDesignated());
-		assertTrue(droolsPdpEntity.isDesignated() == true);
-		
-		logger.debug("testLocking2: Instantiating stateManagement object and promoting PDP={}", thisPdpId);
-		StateManagement smDummy = new StateManagement(emfXacml, "dummy");
-		smDummy.deleteAllStateManagementEntities();
-		
-		// Now we want to create a StateManagementFeature and initialize it.  It will be
-		// discovered by the ActiveStandbyFeature when the election handler initializes.
+        IntegrityMonitor droolsPdpIntegrityMonitor = IntegrityMonitor.getInstance();
 
-		StateManagementFeatureAPI sm = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			sm = feature;
-			logger.debug("testLocking2 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
-			break;
-		}
-		if(sm == null){
-			logger.error("testLocking2 failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testLocking2 failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
-		// that has been created.
-		ActiveStandbyFeatureAPI activeStandbyFeature = null;
-		for (ActiveStandbyFeatureAPI feature : ActiveStandbyFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			activeStandbyFeature = feature;
-			logger.debug("testLocking2 activeStandbyFeature.getResourceName(): {}", activeStandbyFeature.getResourceName());
-			break;
-		}
-		if(activeStandbyFeature == null){
-			logger.error("testLocking2 failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-			logger.debug("testLocking2 failed to initialize.  "
-					+ "Unable to get instance of ActiveStandbyFeatureAPI "
-					+ "with resourceID: {}", thisPdpId);
-		}
-		
-		/*
-		 * Insert another PDP as not designated.  Initial standby state will be 
-		 * either null or cold standby.   Demoting should transit state to
-		 * hot standby.
-		 */
-		 
-		String standbyPdpId = "pdp2";
-		logger.debug("testLocking2: Inserting PDP= {} as not designated", standbyPdpId);
-		Date yesterday = DateUtils.addDays(new Date(), -1);
-		pdp = new DroolsPdpImpl(standbyPdpId, false, 4, yesterday);
-		conn.insertPdp(pdp);
-		droolsPdpEntity = conn.getPdp(standbyPdpId);
-		logger.debug("testLocking2: After insertion, PDP={} has DESIGNATED= {}", 
-				 standbyPdpId, droolsPdpEntity.isDesignated());
-		assertTrue(droolsPdpEntity.isDesignated() == false);
-		
-		logger.debug("testLocking2: Demoting PDP= {}", standbyPdpId);
-		StateManagement sm2 = new StateManagement(emfXacml, standbyPdpId);
-				
-		logger.debug("testLocking2: Runner started; Sleeping {} ms "
-				+ "before promoting/demoting", interruptRecoveryTime);
-		sleep(interruptRecoveryTime);
+        try {
+            droolsPdpIntegrityMonitor.startTransaction();
+            droolsPdpIntegrityMonitor.endTransaction();
+            logger.debug("testLocking2: As expected, transaction successful");
+        } catch (AdministrativeStateException e) {
+            logger.error("testLocking2: Unexpectedly caught AdministrativeStateException, ", e);
+            assertTrue(false);
+        } catch (StandbyStatusException e) {
+            logger.error("testLocking2: Unexpectedly caught StandbyStatusException, ", e);
+            assertTrue(false);
+        } catch (Exception e) {
+            logger.error("testLocking2: Unexpectedly caught Exception, ", e);
+            assertTrue(false);
+        }
 
-		logger.debug("testLocking2: Promoting PDP= {}", thisPdpId);
-		sm.promote();
+        // demoting should cause state to transit to hotstandby followed by re-promotion.
+        logger.debug("testLocking2: demoting PDP={}", thisPdpId);
+        sm.demote();
 
-		// demoting PDP should ensure that state transits to hotstandby
-		logger.debug("testLocking2: Demoting PDP={}", standbyPdpId);
-		sm2.demote();
-		
-		logger.debug("testLocking2: Sleeping {} ms, to allow time for to come up", sleepTime);
-		sleep(sleepTime);
-		
-		logger.debug("testLocking2: Waking up and invoking startTransaction on active PDP={}"
-				+ ", designated= {}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
+        logger.debug("testLocking2: sleeping {}"
+                + " to allow election handler to re-promote PDP={}", electionWaitSleepTime, thisPdpId);
+        sleep(electionWaitSleepTime);
 
-		IntegrityMonitor droolsPdpIntegrityMonitor = IntegrityMonitor.getInstance();
+        logger.debug("testLocking2: Waking up and invoking startTransaction "
+                + "on re-promoted PDP= {}, designated= {}",
+                thisPdpId, conn.getPdp(thisPdpId).isDesignated());
+        try {
+            droolsPdpIntegrityMonitor.startTransaction();
+            droolsPdpIntegrityMonitor.endTransaction();
+            logger.debug("testLocking2: As expected, transaction successful");
+        } catch (AdministrativeStateException e) {
+            logger.error("testLocking2: Unexpectedly caught AdministrativeStateException, ", e);
+            assertTrue(false);
+        } catch (StandbyStatusException e) {
+            logger.error("testLocking2: Unexpectedly caught StandbyStatusException, ", e);
+            assertTrue(false);
+        } catch (Exception e) {
+            logger.error("testLocking2: Unexpectedly caught Exception, ", e);
+            assertTrue(false);
+        }
 
-		try {
-			droolsPdpIntegrityMonitor.startTransaction();
-			droolsPdpIntegrityMonitor.endTransaction();
-			logger.debug("testLocking2: As expected, transaction successful");
-		} catch (AdministrativeStateException e) {
-			logger.error("testLocking2: Unexpectedly caught AdministrativeStateException, ", e);
-			assertTrue(false);
-		} catch (StandbyStatusException e) {
-			logger.error("testLocking2: Unexpectedly caught StandbyStatusException, ", e);
-			assertTrue(false);
-		} catch (Exception e) {
-			logger.error("testLocking2: Unexpectedly caught Exception, ", e);
-			assertTrue(false);
-		}
-		
-		// demoting should cause state to transit to hotstandby followed by re-promotion.
-		logger.debug("testLocking2: demoting PDP={}", thisPdpId);
-		sm.demote();
-		
-		logger.debug("testLocking2: sleeping {}"
-				+ " to allow election handler to re-promote PDP={}", electionWaitSleepTime, thisPdpId);
-		sleep(electionWaitSleepTime);
-		
-		logger.debug("testLocking2: Waking up and invoking startTransaction "
-				+ "on re-promoted PDP= {}, designated= {}",
-				 thisPdpId, conn.getPdp(thisPdpId).isDesignated());
-		try {
-			droolsPdpIntegrityMonitor.startTransaction();
-			droolsPdpIntegrityMonitor.endTransaction();
-			logger.debug("testLocking2: As expected, transaction successful");
-		} catch (AdministrativeStateException e) {
-			logger.error("testLocking2: Unexpectedly caught AdministrativeStateException, ", e);
-			assertTrue(false);
-		} catch (StandbyStatusException e) {
-			logger.error("testLocking2: Unexpectedly caught StandbyStatusException, ", e);
-			assertTrue(false);
-		} catch (Exception e) {
-			logger.error("testLocking2: Unexpectedly caught Exception, ", e);
-			assertTrue(false);
-		}
-		
-		logger.debug("testLocking2: Verifying designated status for PDP= {}", standbyPdpId);
-		boolean standbyPdpDesignated = conn.getPdp(standbyPdpId).isDesignated();
-		assertTrue(standbyPdpDesignated == false);
+        logger.debug("testLocking2: Verifying designated status for PDP= {}", standbyPdpId);
+        boolean standbyPdpDesignated = conn.getPdp(standbyPdpId).isDesignated();
+        assertTrue(standbyPdpDesignated == false);
 
-		logger.debug("\n\ntestLocking2: Exiting\n\n");
-		sleep(interruptRecoveryTime);
-	}
+        logger.debug("\n\ntestLocking2: Exiting\n\n");
+        sleep(interruptRecoveryTime);
+    }
 
-	private void sleep(long sleepms) throws InterruptedException {
-		Thread.sleep(sleepms);
-	}
+    private void sleep(long sleepms) throws InterruptedException {
+        Thread.sleep(sleepms);
+    }
 }
diff --git a/feature-active-standby-management/src/test/resources/META-INF/persistence.xml b/feature-active-standby-management/src/test/resources/META-INF/persistence.xml
index ff6ac58..549f01d 100644
--- a/feature-active-standby-management/src/test/resources/META-INF/persistence.xml
+++ b/feature-active-standby-management/src/test/resources/META-INF/persistence.xml
@@ -3,7 +3,7 @@
   ============LICENSE_START=======================================================
   feature-active-standby-management
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-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.
@@ -20,28 +20,47 @@
   -->
 
 <persistence version="2.1"
-	xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
-	<persistence-unit name="junitDroolsPU" transaction-type="RESOURCE_LOCAL">
-		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-		<class>org.onap.policy.drools.activestandby.DroolsPdpEntity</class>
-		<properties>
-			<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
-			<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/> 
-            <property name="javax.persistence.schema-generation.scripts.create-target" value="./sql/generatedCreateDrools.ddl"/>
-            <property name="javax.persistence.schema-generation.scripts.drop-target" value="./sql/generatedDropDrools.ddl"/>
+    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+    <persistence-unit name="junitDroolsPU"
+        transaction-type="RESOURCE_LOCAL">
+        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+        <class>org.onap.policy.drools.activestandby.DroolsPdpEntity</class>
+        <properties>
+            <property
+                name="javax.persistence.schema-generation.database.action"
+                value="drop-and-create" />
+            <property
+                name="javax.persistence.schema-generation.scripts.action"
+                value="drop-and-create" />
+            <property
+                name="javax.persistence.schema-generation.scripts.create-target"
+                value="./sql/generatedCreateDrools.ddl" />
+            <property
+                name="javax.persistence.schema-generation.scripts.drop-target"
+                value="./sql/generatedDropDrools.ddl" />
         </properties>
-	</persistence-unit>
-	<persistence-unit name="junitXacmlPU" transaction-type="RESOURCE_LOCAL">
-		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-		<class>org.onap.policy.common.im.jpa.StateManagementEntity</class>
-		<class>org.onap.policy.common.im.jpa.ForwardProgressEntity</class>
-		<class>org.onap.policy.common.im.jpa.ResourceRegistrationEntity</class>
-		<properties>
-			<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
-			<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/> 
-            <property name="javax.persistence.schema-generation.scripts.create-target" value="./sql/generatedCreateXacml.ddl"/>
-            <property name="javax.persistence.schema-generation.scripts.drop-target" value="./sql/generatedDropXacml.ddl"/>
+    </persistence-unit>
+    <persistence-unit name="junitXacmlPU"
+        transaction-type="RESOURCE_LOCAL">
+        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+        <class>org.onap.policy.common.im.jpa.StateManagementEntity</class>
+        <class>org.onap.policy.common.im.jpa.ForwardProgressEntity</class>
+        <class>org.onap.policy.common.im.jpa.ResourceRegistrationEntity</class>
+        <properties>
+            <property
+                name="javax.persistence.schema-generation.database.action"
+                value="drop-and-create" />
+            <property
+                name="javax.persistence.schema-generation.scripts.action"
+                value="drop-and-create" />
+            <property
+                name="javax.persistence.schema-generation.scripts.create-target"
+                value="./sql/generatedCreateXacml.ddl" />
+            <property
+                name="javax.persistence.schema-generation.scripts.drop-target"
+                value="./sql/generatedDropXacml.ddl" />
         </properties>
-	</persistence-unit>
+    </persistence-unit>
 </persistence>
diff --git a/feature-active-standby-management/src/test/resources/logback-test.xml b/feature-active-standby-management/src/test/resources/logback-test.xml
index a36bdb1..583b966 100644
--- a/feature-active-standby-management/src/test/resources/logback-test.xml
+++ b/feature-active-standby-management/src/test/resources/logback-test.xml
@@ -2,7 +2,7 @@
   ============LICENSE_START=======================================================
   feature-state-management
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-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.
@@ -22,25 +22,28 @@
 
 <configuration>
 
-	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
-		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
-			<Pattern>
-				%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
-			</Pattern>
-		</encoder>
-	</appender>
-	<appender name="FILE" class="ch.qos.logback.core.FileAppender">
-		<file>logs/debug.log</file>
-		<encoder>
-			<Pattern>
-				%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
-			</Pattern>
-		</encoder>
-	</appender>
-	
-	<root level="debug">
-		<appender-ref ref="STDOUT" />
-		<appender-ref ref="FILE" />
-	</root>
+    <appender name="STDOUT"
+        class="ch.qos.logback.core.ConsoleAppender">
+        <encoder
+            class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <Pattern>
+                %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+            </Pattern>
+        </encoder>
+    </appender>
+    <appender name="FILE"
+        class="ch.qos.logback.core.FileAppender">
+        <file>logs/debug.log</file>
+        <encoder>
+            <Pattern>
+                %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+            </Pattern>
+        </encoder>
+    </appender>
+
+    <root level="debug">
+        <appender-ref ref="STDOUT" />
+        <appender-ref ref="FILE" />
+    </root>
 
 </configuration>
diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java
index f1c8b68..17f6545 100644
--- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java
+++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java
@@ -17,6 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.distributed.locking;
 
 import java.sql.Connection;
@@ -35,102 +36,105 @@
 import org.slf4j.LoggerFactory;
 
 public class DistributedLockingFeature implements PolicyEngineFeatureAPI, PolicyResourceLockFeatureAPI {
-	
-	/**
-	 * Logger instance
-	 */
-	private static final Logger logger = LoggerFactory.getLogger(DistributedLockingFeature.class);
-	
-	/**
-	 * Properties Configuration Name
-	 */
-	public static final String CONFIGURATION_PROPERTIES_NAME = "feature-distributed-locking";
-	
-	/**
-	 * Properties for locking feature
-	 */
-	private DistributedLockingProperties lockProps;
-	
-	/**
-	 * Data source used to connect to the DB containing locks.
-	 */
-	private BasicDataSource dataSource;
-	
-	/**
-	 * UUID 
-	 */
-	private static final UUID uuid = UUID.randomUUID();
-	
-	@Override
-	public int getSequenceNumber() {
-        return 1000;
-	}
-	
-	@Override
-    public OperResult beforeLock(String resourceId, String owner, int holdSec) {
-		
-		TargetLock tLock = new TargetLock(resourceId, uuid, owner, dataSource);
 
-        return(tLock.lock(holdSec) ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);				
-	}
-    
+    /**
+     * Logger instance.
+     */
+    private static final Logger logger = LoggerFactory.getLogger(DistributedLockingFeature.class);
+
+    /**
+     * Properties Configuration Name.
+     */
+    public static final String CONFIGURATION_PROPERTIES_NAME = "feature-distributed-locking";
+
+    /**
+     * Properties for locking feature.
+     */
+    private DistributedLockingProperties lockProps;
+
+    /**
+     * Data source used to connect to the DB containing locks.
+     */
+    private BasicDataSource dataSource;
+
+    /**
+     * UUID. 
+     */
+    private static final UUID uuid = UUID.randomUUID();
+
     @Override
-    public OperResult beforeRefresh(String resourceId, String owner, int holdSec) {
-        
-        TargetLock tLock = new TargetLock(resourceId, uuid, owner, dataSource);
-
-        return(tLock.refresh(holdSec) ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);                
+    public int getSequenceNumber() {
+        return 1000;
     }
 
-	@Override
-	public OperResult beforeUnlock(String resourceId, String owner) {
-		TargetLock tLock = new TargetLock(resourceId, uuid, owner, dataSource);
-		
-		return(tLock.unlock() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);
-	}
-	
-	@Override
-	public OperResult beforeIsLockedBy(String resourceId, String owner) {
-		TargetLock tLock = new TargetLock(resourceId, uuid, owner, dataSource);
+    @Override
+    public OperResult beforeLock(String resourceId, String owner, int holdSec) {
 
-        return(tLock.isActive() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);
-	}
-	
-	@Override
-	public OperResult beforeIsLocked(String resourceId) {
-		TargetLock tLock = new TargetLock(resourceId, uuid, "dummyOwner", dataSource);
+        TargetLock lock = new TargetLock(resourceId, uuid, owner, dataSource);
 
-        return(tLock.isLocked() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);
-	}
-	
-	@Override
-	public boolean afterStart(PolicyEngine engine) {
+        return (lock.lock(holdSec) ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);
+    }
 
-		try {
-			this.lockProps = new DistributedLockingProperties(SystemPersistence.manager.getProperties(DistributedLockingFeature.CONFIGURATION_PROPERTIES_NAME));
-			this.dataSource = makeDataSource();
-		} catch (PropertyException e) {
-			logger.error("DistributedLockingFeature feature properies have not been loaded", e);
-			throw new DistributedLockingFeatureException(e);
-		} catch(InterruptedException e) {
-            logger.error("DistributedLockingFeature failed to create data source", e);
-		    Thread.currentThread().interrupt();
+    @Override
+    public OperResult beforeRefresh(String resourceId, String owner, int holdSec) {
+
+        TargetLock lock = new TargetLock(resourceId, uuid, owner, dataSource);
+
+        return (lock.refresh(holdSec) ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);                
+    }
+
+    @Override
+    public OperResult beforeUnlock(String resourceId, String owner) {
+        TargetLock lock = new TargetLock(resourceId, uuid, owner, dataSource);
+
+        return (lock.unlock() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);
+    }
+
+    @Override
+    public OperResult beforeIsLockedBy(String resourceId, String owner) {
+        TargetLock lock = new TargetLock(resourceId, uuid, owner, dataSource);
+
+        return (lock.isActive() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);
+    }
+
+    @Override
+    public OperResult beforeIsLocked(String resourceId) {
+        TargetLock lock = new TargetLock(resourceId, uuid, "dummyOwner", dataSource);
+
+        return (lock.isLocked() ? OperResult.OPER_ACCEPTED : OperResult.OPER_DENIED);
+    }
+
+    @Override
+    public boolean afterStart(PolicyEngine engine) {
+
+        try {
+            this.lockProps = new DistributedLockingProperties(
+                    SystemPersistence.manager.getProperties(DistributedLockingFeature.CONFIGURATION_PROPERTIES_NAME));
+            this.dataSource = makeDataSource();
+        } catch (PropertyException e) {
+            logger.error("DistributedLockingFeature feature properies have not been loaded", e);
             throw new DistributedLockingFeatureException(e);
-        } catch(Exception e) {
+        } catch (InterruptedException e) {
+            logger.error("DistributedLockingFeature failed to create data source", e);
+            Thread.currentThread().interrupt();
+            throw new DistributedLockingFeatureException(e);
+        } catch (Exception e) {
             logger.error("DistributedLockingFeature failed to create data source", e);
             throw new DistributedLockingFeatureException(e);
-		}
-		
-		cleanLockTable();
-		
-		return false;
-	}
-	
-	/**
-	 * @return a new, pooled data source
-	 * @throws Exception
-	 */
-	private BasicDataSource makeDataSource() throws Exception {
+        }
+
+        cleanLockTable();
+
+        return false;
+    }
+
+    /**
+     * Make data source.
+     * 
+     * @return a new, pooled data source
+     * @throws Exception exception
+     */
+    private BasicDataSource makeDataSource() throws Exception {
         Properties props = new Properties();
         props.put("driverClassName", lockProps.getDbDriver());
         props.put("url", lockProps.getDbUrl());
@@ -140,36 +144,36 @@
         props.put("poolPreparedStatements", "true");
 
         // additional properties are listed in the GenericObjectPool API
-        
+
         return BasicDataSourceFactory.createDataSource(props);
     }
 
     /**
-	 * This method kills the heartbeat thread and calls refreshLockTable which removes
-	 * any records from the db where the current host is the owner.
-	 */
-	@Override
-	public boolean beforeShutdown(PolicyEngine engine) {
-		cleanLockTable();
-		return false;
-	}
+     * This method kills the heartbeat thread and calls refreshLockTable which removes
+     * any records from the db where the current host is the owner.
+     */
+    @Override
+    public boolean beforeShutdown(PolicyEngine engine) {
+        cleanLockTable();
+        return false;
+    }
 
-	/**
-	 * This method removes all records owned by the current host from the db.
-	 */
-	private void cleanLockTable() {
-		
-	    try (Connection conn = dataSource.getConnection();
-                        PreparedStatement statement = conn.prepareStatement(
-                                        "DELETE FROM pooling.locks WHERE host = ? OR expirationTime < now()");
-	    	){
-			
-				statement.setString(1, uuid.toString());
-				statement.executeUpdate();
-			
-		} catch (SQLException e) {
-			logger.error("error in refreshLockTable()", e);
-		}
-		
-	}	
+    /**
+     * This method removes all records owned by the current host from the db.
+     */
+    private void cleanLockTable() {
+
+        try (Connection conn = dataSource.getConnection();
+                PreparedStatement statement = conn.prepareStatement(
+                        "DELETE FROM pooling.locks WHERE host = ? OR expirationTime < now()");
+                ) {
+
+            statement.setString(1, uuid.toString());
+            statement.executeUpdate();
+
+        } catch (SQLException e) {
+            logger.error("error in refreshLockTable()", e);
+        }
+
+    }
 }
diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeatureException.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeatureException.java
index f28ccbc..55fc4fa 100644
--- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeatureException.java
+++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeatureException.java
@@ -21,14 +21,14 @@
 package org.onap.policy.distributed.locking;
 
 public class DistributedLockingFeatureException extends RuntimeException {
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	/**
-	 * 
-	 * @param e
-	 *            exception to be wrapped
-	 */
-	public DistributedLockingFeatureException(Exception e) {
-		super(e);
-	}
+    /**
+     * Constructor.
+     * 
+     * @param ex exception to be wrapped
+     */
+    public DistributedLockingFeatureException(Exception ex) {
+        super(ex);
+    }
 }
diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingProperties.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingProperties.java
index 1f55a4c..00db573 100644
--- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingProperties.java
+++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingProperties.java
@@ -17,6 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.distributed.locking;
 
 import java.util.Properties;
@@ -42,25 +43,25 @@
     private Properties source;
 
     /**
-     * Database driver
+     * Database driver.
      */
     @Property(name = DB_DRIVER)
     private String dbDriver;
 
     /**
-     * Database url
+     * Database url.
      */
     @Property(name = DB_URL)
     private String dbUrl;
 
     /**
-     * Database user
+     * Database user.
      */
     @Property(name = DB_USER)
     private String dbUser;
 
     /**
-     * Database password
+     * Database password.
      */
     @Property(name = DB_PWD)
     private String dbPwd;
diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/TargetLock.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/TargetLock.java
index 0652897..42e1f92 100644
--- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/TargetLock.java
+++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/TargetLock.java
@@ -17,6 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.distributed.locking;
 
 import java.sql.Connection;
@@ -29,145 +30,149 @@
 import org.slf4j.LoggerFactory;
 
 public class TargetLock {
-	
-	private static final Logger logger = LoggerFactory.getLogger(TargetLock.class);
-	
-	/**
-	 * The Target resource we want to lock
-	 */
-	private String resourceId;
-    
+
+    private static final Logger logger = LoggerFactory.getLogger(TargetLock.class);
+
+    /**
+     * The Target resource we want to lock.
+     */
+    private String resourceId;
+
     /**
      * Data source used to connect to the DB containing locks.
      */
     private BasicDataSource dataSource;
 
-	/**
-	 * UUID 
-	 */
-	private UUID uuid;
-	
-	/**
-	 * Owner
-	 */
-	private String owner;
-	
-	/**
-	 * Constructs a TargetLock object.
-	 * 
-	 * @param resourceId ID of the entity we want to lock
-	 * @param dataSource used to connect to the DB containing locks
-	 */
-	public TargetLock (String resourceId, UUID uuid, String owner, BasicDataSource dataSource) {
-		this.resourceId = resourceId;
-		this.uuid = uuid;
-		this.owner = owner;
-		this.dataSource = dataSource;
-	}
-	
-	/**
-	 * obtain a lock
-     * @param holdSec the amount of time, in seconds, that the lock should be held
-	 */
-	public boolean lock(int holdSec) {
-		
-		return grabLock(holdSec);
-	}
+    /**
+     * UUID .
+     */
+    private UUID uuid;
 
     /**
-     * refresh a lock
+     * Owner.
+     */
+    private String owner;
+
+    /**
+     * Constructs a TargetLock object.
+     * 
+     * @param resourceId ID of the entity we want to lock
+     * @param dataSource used to connect to the DB containing locks
+     */
+    public TargetLock(String resourceId, UUID uuid, String owner, BasicDataSource dataSource) {
+        this.resourceId = resourceId;
+        this.uuid = uuid;
+        this.owner = owner;
+        this.dataSource = dataSource;
+    }
+
+    /**
+     * Obtain a lock.
+     * @param holdSec the amount of time, in seconds, that the lock should be held
+     */
+    public boolean lock(int holdSec) {
+
+        return grabLock(holdSec);
+    }
+
+    /**
+     * Refresh a lock.
      * 
      * @param holdSec the amount of time, in seconds, that the lock should be held
      * @return {@code true} if the lock was refreshed, {@code false} if the resource is
      *         not currently locked by the given owner
      */
-	public boolean refresh(int holdSec) {
-	    return updateLock(holdSec);
-	}
-	
-	/**
-	 * Unlock a resource by deleting it's associated record in the db
-	 */
-	public boolean unlock() {
-		return deleteLock();
-	}
-	
-	/**
-	 * "Grabs" lock by attempting to insert a new record in the db.
-	 *  If the insert fails due to duplicate key error resource is already locked
-	 *  so we call secondGrab. 
+    public boolean refresh(int holdSec) {
+        return updateLock(holdSec);
+    }
+
+    /**
+     * Unlock a resource by deleting it's associated record in the db.
+     */
+    public boolean unlock() {
+        return deleteLock();
+    }
+
+    /**
+     * "Grabs" lock by attempting to insert a new record in the db.
+     *  If the insert fails due to duplicate key error resource is already locked
+     *  so we call secondGrab. 
      * @param holdSec the amount of time, in seconds, that the lock should be held
-	 */
-	private boolean grabLock(int holdSec) {
+     */
+    private boolean grabLock(int holdSec) {
 
-		// try to insert a record into the table(thereby grabbing the lock)
-		try (Connection conn = dataSource.getConnection();
+        // try to insert a record into the table(thereby grabbing the lock)
+        try (Connection conn = dataSource.getConnection();
 
-				PreparedStatement statement = conn.prepareStatement(
-						"INSERT INTO pooling.locks (resourceId, host, owner, expirationTime) values (?, ?, ?, timestampadd(second, ?, now()))")) {
-			
-		    int i = 1;
-			statement.setString(i++, this.resourceId);
-			statement.setString(i++, this.uuid.toString());
-			statement.setString(i++, this.owner);
-			statement.setInt(i++, holdSec);
-			statement.executeUpdate();
-		}
+                PreparedStatement statement = conn.prepareStatement(
+                        "INSERT INTO pooling.locks (resourceId, host, owner, expirationTime) "
+                        + "values (?, ?, ?, timestampadd(second, ?, now()))")) {
 
-		catch (SQLException e) {
-			logger.error("error in TargetLock.grabLock()", e);
-			return secondGrab(holdSec);
-		}
+            int index = 1;
+            statement.setString(index++, this.resourceId);
+            statement.setString(index++, this.uuid.toString());
+            statement.setString(index++, this.owner);
+            statement.setInt(index++, holdSec);
+            statement.executeUpdate();
+        }
 
-		return true;
-	}
+        catch (SQLException e) {
+            logger.error("error in TargetLock.grabLock()", e);
+            return secondGrab(holdSec);
+        }
 
-	/**
-	 * A second attempt at grabbing a lock. It first attempts to update the lock in case it is expired.
-	 * If that fails, it attempts to insert a new record again
+        return true;
+    }
+
+    /**
+     * A second attempt at grabbing a lock. It first attempts to update the lock in case it is expired.
+     * If that fails, it attempts to insert a new record again
      * @param holdSec the amount of time, in seconds, that the lock should be held
-	 */
-	private boolean secondGrab(int holdSec) {
+     */
+    private boolean secondGrab(int holdSec) {
 
-		try (Connection conn = dataSource.getConnection();
+        try (Connection conn = dataSource.getConnection();
 
-				PreparedStatement updateStatement = conn.prepareStatement(
-						"UPDATE pooling.locks SET host = ?, owner = ?, expirationTime = timestampadd(second, ?, now()) WHERE resourceId = ? AND expirationTime < now()");
+                PreparedStatement updateStatement = conn.prepareStatement(
+                        "UPDATE pooling.locks SET host = ?, owner = ?, "
+                        + "expirationTime = timestampadd(second, ?, now()) "
+                        + "WHERE resourceId = ? AND expirationTime < now()");
 
-				PreparedStatement insertStatement = conn.prepareStatement(
-						"INSERT INTO pooling.locks (resourceId, host, owner, expirationTime) values (?, ?, ?, timestampadd(second, ?, now()))");) {
+                PreparedStatement insertStatement = conn.prepareStatement(
+                        "INSERT INTO pooling.locks (resourceId, host, owner, expirationTime) "
+                        + "values (?, ?, ?, timestampadd(second, ?, now()))");) {
 
-		    int i = 1;
-			updateStatement.setString(i++, this.uuid.toString());
-			updateStatement.setString(i++, this.owner);
-			updateStatement.setInt(i++, holdSec);
-            updateStatement.setString(i++, this.resourceId);
+            int index = 1;
+            updateStatement.setString(index++, this.uuid.toString());
+            updateStatement.setString(index++, this.owner);
+            updateStatement.setInt(index++, holdSec);
+            updateStatement.setString(index++, this.resourceId);
 
-			// The lock was expired and we grabbed it.
-			// return true
-			if (updateStatement.executeUpdate() == 1) {
-				return true;
-			}
+            // The lock was expired and we grabbed it.
+            // return true
+            if (updateStatement.executeUpdate() == 1) {
+                return true;
+            }
 
-			// If our update does not return 1 row, the lock either has not expired
-			// or it was removed. Try one last grab
-			else {
-			    i = 1;
-				insertStatement.setString(i++, this.resourceId);
-				insertStatement.setString(i++, this.uuid.toString());
-				insertStatement.setString(i++, this.owner);
-				insertStatement.setInt(i++, holdSec);
+            // If our update does not return 1 row, the lock either has not expired
+            // or it was removed. Try one last grab
+            else {
+                index = 1;
+                insertStatement.setString(index++, this.resourceId);
+                insertStatement.setString(index++, this.uuid.toString());
+                insertStatement.setString(index++, this.owner);
+                insertStatement.setInt(index++, holdSec);
 
-				// If our insert returns 1 we successfully grabbed the lock
-				return (insertStatement.executeUpdate() == 1);
-			}
+                // If our insert returns 1 we successfully grabbed the lock
+                return (insertStatement.executeUpdate() == 1);
+            }
 
-		} catch (SQLException e) {
-			logger.error("error in TargetLock.secondGrab()", e);
-			return false;
-		}
+        } catch (SQLException e) {
+            logger.error("error in TargetLock.secondGrab()", e);
+            return false;
+        }
 
-	}
+    }
 
     /**
      * Updates the DB record associated with the lock.
@@ -179,15 +184,17 @@
 
         try (Connection conn = dataSource.getConnection();
 
-                        PreparedStatement updateStatement = conn.prepareStatement(
-                                        "UPDATE pooling.locks SET host = ?, owner = ?, expirationTime = timestampadd(second, ?, now()) WHERE resourceId = ? AND owner = ? AND expirationTime >= now()")) {
+                PreparedStatement updateStatement = conn.prepareStatement(
+                        "UPDATE pooling.locks SET host = ?, owner = ?, "
+                        + "expirationTime = timestampadd(second, ?, now()) "
+                        + "WHERE resourceId = ? AND owner = ? AND expirationTime >= now()")) {
 
-            int i = 1;
-            updateStatement.setString(i++, this.uuid.toString());
-            updateStatement.setString(i++, this.owner);
-            updateStatement.setInt(i++, holdSec);
-            updateStatement.setString(i++, this.resourceId);
-            updateStatement.setString(i++, this.owner);
+            int index = 1;
+            updateStatement.setString(index++, this.uuid.toString());
+            updateStatement.setString(index++, this.owner);
+            updateStatement.setInt(index++, holdSec);
+            updateStatement.setString(index++, this.resourceId);
+            updateStatement.setString(index++, this.owner);
 
             // refresh succeeded iff a record was updated
             return (updateStatement.executeUpdate() == 1);
@@ -198,80 +205,78 @@
         }
 
     }
-	
-	/**
-	 *To remove a lock we simply delete the record from the db 
-	 */
-	private boolean deleteLock() {
 
-		try (Connection conn = dataSource.getConnection();
+    /**
+     *To remove a lock we simply delete the record from the db .
+     */
+    private boolean deleteLock() {
 
-				PreparedStatement deleteStatement = conn.prepareStatement(
-						"DELETE FROM pooling.locks WHERE resourceId = ? AND owner = ? AND host = ?")) {
+        try (Connection conn = dataSource.getConnection();
 
-			deleteStatement.setString(1, this.resourceId);
-			deleteStatement.setString(2, this.owner);
-			deleteStatement.setString(3, this.uuid.toString());
+                PreparedStatement deleteStatement = conn.prepareStatement(
+                        "DELETE FROM pooling.locks WHERE resourceId = ? AND owner = ? AND host = ?")) {
 
-			return (deleteStatement.executeUpdate() == 1);
+            deleteStatement.setString(1, this.resourceId);
+            deleteStatement.setString(2, this.owner);
+            deleteStatement.setString(3, this.uuid.toString());
 
-		} catch (SQLException e) {
-			logger.error("error in TargetLock.deleteLock()", e);
-			return false;
-		}
+            return (deleteStatement.executeUpdate() == 1);
 
-	}
+        } catch (SQLException e) {
+            logger.error("error in TargetLock.deleteLock()", e);
+            return false;
+        }
 
-	/**
-	 * Is the lock active
-	 */
-	public boolean isActive() {
-		try (Connection conn = dataSource.getConnection();
+    }
 
-				PreparedStatement selectStatement = conn.prepareStatement(
-						"SELECT * FROM pooling.locks WHERE resourceId = ? AND host = ? AND owner= ? AND expirationTime >= now()")) {
+    /**
+     * Is the lock active.
+     */
+    public boolean isActive() {
+        try (Connection conn = dataSource.getConnection();
 
-			selectStatement.setString(1, this.resourceId);
-			selectStatement.setString(2, this.uuid.toString());
-			selectStatement.setString(3, this.owner);
-			try (ResultSet result = selectStatement.executeQuery()) {
+                PreparedStatement selectStatement = conn.prepareStatement(
+                        "SELECT * FROM pooling.locks "
+                        + "WHERE resourceId = ? AND host = ? AND owner= ? AND expirationTime >= now()")) {
 
-				// This will return true if the
-				// query returned at least one row
-				return result.first();
-			}
+            selectStatement.setString(1, this.resourceId);
+            selectStatement.setString(2, this.uuid.toString());
+            selectStatement.setString(3, this.owner);
+            try (ResultSet result = selectStatement.executeQuery()) {
 
-		}
+                // This will return true if the
+                // query returned at least one row
+                return result.first();
+            }
 
-		catch (SQLException e) {
-			logger.error("error in TargetLock.isActive()", e);
-			return false;
-		}
+        }
 
-	}
+        catch (SQLException e) {
+            logger.error("error in TargetLock.isActive()", e);
+            return false;
+        }
 
-	/**
-	 * Is the resource locked
-	 */
-	public boolean isLocked() {
+    }
 
-		try (Connection conn = dataSource.getConnection();
-			
-				PreparedStatement selectStatement = conn
-						.prepareStatement("SELECT * FROM pooling.locks WHERE resourceId = ? AND expirationTime >= now()")) {
+    /**
+     * Is the resource locked.
+     */
+    public boolean isLocked() {
 
-			selectStatement.setString(1, this.resourceId);
-			try (ResultSet result = selectStatement.executeQuery()) {
-				// This will return true if the
-				// query returned at least one row
-				return result.first();
-			}
-		}
+        try (Connection conn = dataSource.getConnection();
+                PreparedStatement selectStatement = conn
+                    .prepareStatement("SELECT * FROM pooling.locks WHERE resourceId = ? AND expirationTime >= now()")) {
 
-		catch (SQLException e) {
-			logger.error("error in TargetLock.isActive()", e);
-			return false;
-		}
-	}
+            selectStatement.setString(1, this.resourceId);
+            try (ResultSet result = selectStatement.executeQuery()) {
+                // This will return true if the
+                // query returned at least one row
+                return result.first();
+            }
+        } catch (SQLException e) {
+            logger.error("error in TargetLock.isActive()", e);
+            return false;
+        }
+    }
 
 }
diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java
index 5bc3ae5..7ba2384 100644
--- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java
+++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java
@@ -26,11 +26,11 @@
 import org.onap.policy.common.utils.test.ExceptionsTester;
 import org.onap.policy.distributed.locking.DistributedLockingFeatureException;
 
-public class DistributedLockingFeatureExceptionTest extends ExceptionsTester{
-	
-	@Test
-	public void test() {
-		assertEquals(1, test(DistributedLockingFeatureException.class)); 
-	}
+public class DistributedLockingFeatureExceptionTest extends ExceptionsTester {
+
+    @Test
+    public void test() {
+        assertEquals(1, test(DistributedLockingFeatureException.class)); 
+    }
 
 }
diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
index 42c8a74..60a721b 100644
--- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
+++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -21,6 +21,7 @@
 package org.onap.policy.distributed.locking;
 
 import static org.junit.Assert.assertEquals;
+
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
@@ -36,191 +37,211 @@
 import org.slf4j.LoggerFactory;
 
 public class TargetLockTest {
-	private static final Logger logger = LoggerFactory.getLogger(TargetLockTest.class);
+    private static final Logger logger = LoggerFactory.getLogger(TargetLockTest.class);
     private static final int MAX_AGE_SEC = 4 * 60;
-	private static final String DB_CONNECTION = "jdbc:h2:mem:pooling;INIT=CREATE SCHEMA IF NOT EXISTS pooling\\;SET SCHEMA pooling";
-	private static final String DB_USER = "user";
-	private static final String DB_PASSWORD = "password";
-	private static Connection conn = null;
-	private static DistributedLockingFeature distLockFeat;
+    private static final String DB_CONNECTION =
+            "jdbc:h2:mem:pooling;INIT=CREATE SCHEMA IF NOT EXISTS pooling\\;SET SCHEMA pooling";
+    private static final String DB_USER = "user";
+    private static final String DB_PASSWORD = "password";
+    private static Connection conn = null;
+    private static DistributedLockingFeature distLockFeat;
 
-	@BeforeClass
-	public static void setup() {
-		getDBConnection();
-		createTable();
-		SystemPersistence.manager.setConfigurationDir("src/test/resources");
-		distLockFeat = new DistributedLockingFeature();
-		distLockFeat.afterStart(null);
-	
-	}
-	
-	@AfterClass
-	public static void cleanUp() {
-		distLockFeat.beforeShutdown(null);
-		try {
-			conn.close();
-		} catch (SQLException e) {
-			logger.error("Error in TargetLockTest.cleanUp()", e);
-		}
-	}
-	
-	@Before
-	public void wipeDb() {
-		try (PreparedStatement lockDelete = conn.prepareStatement("DELETE FROM pooling.locks");){
-			lockDelete.executeUpdate();
-		} catch (SQLException e) {
-			logger.error("Error in TargetLockTest.wipeDb()", e);
-			throw new RuntimeException(e);
-		}
+    /**
+     * Setup the database.
+     */
+    @BeforeClass
+    public static void setup() {
+        getDbConnection();
+        createTable();
+        SystemPersistence.manager.setConfigurationDir("src/test/resources");
+        distLockFeat = new DistributedLockingFeature();
+        distLockFeat.afterStart(null);
+    }
 
-	}
-	
-	@Test
-	public void testGrabLockSuccess() throws InterruptedException, ExecutionException {
-	    assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
-	
-			//attempt to grab expiredLock
-		try (PreparedStatement updateStatement = conn.prepareStatement("UPDATE pooling.locks SET expirationTime = timestampadd(second, -1, now()) WHERE resourceId = ?");)
-		{
-			updateStatement.setString(1, "resource1");
-			updateStatement.executeUpdate();
-				
-		} catch (SQLException e) {
-			logger.error("Error in TargetLockTest.testGrabLockSuccess()", e);
-			throw new RuntimeException(e);
-		}
-		
-		assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
-
-		// cannot re-lock
-        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
-
-        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
-	}
-
-	@Test
-	public void testExpiredLocks() throws Exception {
-			
-			//grab lock
-		distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
-		
-			//force lock to expire
-        try (PreparedStatement lockExpire = conn.prepareStatement("UPDATE pooling.locks SET expirationTime = timestampadd(second, -?, now())");) {
-            lockExpire.setInt(1, MAX_AGE_SEC + 1);
-            lockExpire.executeUpdate();
+    /**
+     * Cleanup the lock.
+     */
+    @AfterClass
+    public static void cleanUp() {
+        distLockFeat.beforeShutdown(null);
+        try {
+            conn.close();
+        } catch (SQLException e) {
+            logger.error("Error in TargetLockTest.cleanUp()", e);
         }
-	
-		assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner2", MAX_AGE_SEC));
-	}
-	
-	@Test
-	public void testGrabLockFail() throws InterruptedException, ExecutionException {
-		
-		distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
-		
-		assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeLock("resource1", "owner2", MAX_AGE_SEC));
+    }
 
-	}
-    
+    /**
+     * Wipe the database.
+     */
+    @Before
+    public void wipeDb() {
+        try (PreparedStatement lockDelete = conn.prepareStatement("DELETE FROM pooling.locks"); ) {
+            lockDelete.executeUpdate();
+        } catch (SQLException e) {
+            logger.error("Error in TargetLockTest.wipeDb()", e);
+            throw new RuntimeException(e);
+        }
+    }
+
     @Test
-    public void testUpdateLock() throws InterruptedException, ExecutionException {
-        // not locked yet - refresh should fail
-        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeRefresh("resource1", "owner1", MAX_AGE_SEC));
-        
-        // now lock it
-        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
+    public void testGrabLockSuccess() throws InterruptedException, ExecutionException {
+        assertEquals(
+                OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
 
-        // refresh should work now
-        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeRefresh("resource1", "owner1", MAX_AGE_SEC));
-        
-        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
-        
-        // expire the lock
-        try (PreparedStatement updateStatement = conn.prepareStatement("UPDATE pooling.locks SET expirationTime = timestampadd(second, -1, now()) WHERE resourceId = ?");)
-        {
+        // attempt to grab expiredLock
+        try (PreparedStatement updateStatement =
+                conn.prepareStatement(
+                  "UPDATE pooling.locks SET expirationTime = timestampadd(second, -1, now()) WHERE resourceId = ?"); ) {
             updateStatement.setString(1, "resource1");
             updateStatement.executeUpdate();
-                
+
         } catch (SQLException e) {
             logger.error("Error in TargetLockTest.testGrabLockSuccess()", e);
             throw new RuntimeException(e);
         }
-        
+
+        assertEquals(
+                OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
+
+        // cannot re-lock
+        assertEquals(
+                OperResult.OPER_DENIED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
+
+        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
+    }
+
+    @Test
+    public void testExpiredLocks() throws Exception {
+
+        // grab lock
+        distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
+
+        // force lock to expire
+        try (PreparedStatement lockExpire =
+                conn.prepareStatement(
+                        "UPDATE pooling.locks SET expirationTime = timestampadd(second, -?, now())"); ) {
+            lockExpire.setInt(1, MAX_AGE_SEC + 1);
+            lockExpire.executeUpdate();
+        }
+
+        assertEquals(
+                OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner2", MAX_AGE_SEC));
+    }
+
+    @Test
+    public void testGrabLockFail() throws InterruptedException, ExecutionException {
+
+        distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
+
+        assertEquals(
+                OperResult.OPER_DENIED, distLockFeat.beforeLock("resource1", "owner2", MAX_AGE_SEC));
+    }
+
+    @Test
+    public void testUpdateLock() throws InterruptedException, ExecutionException {
+        // not locked yet - refresh should fail
+        assertEquals(
+                OperResult.OPER_DENIED, distLockFeat.beforeRefresh("resource1", "owner1", MAX_AGE_SEC));
+
+        // now lock it
+        assertEquals(
+                OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
+
+        // refresh should work now
+        assertEquals(
+                OperResult.OPER_ACCEPTED, distLockFeat.beforeRefresh("resource1", "owner1", MAX_AGE_SEC));
+
+        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
+
+        // expire the lock
+        try (PreparedStatement updateStatement =
+                conn.prepareStatement(
+                  "UPDATE pooling.locks SET expirationTime = timestampadd(second, -1, now()) WHERE resourceId = ?"); ) {
+            updateStatement.setString(1, "resource1");
+            updateStatement.executeUpdate();
+
+        } catch (SQLException e) {
+            logger.error("Error in TargetLockTest.testGrabLockSuccess()", e);
+            throw new RuntimeException(e);
+        }
+
         // refresh should fail now
-        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeRefresh("resource1", "owner1", MAX_AGE_SEC));
+        assertEquals(
+                OperResult.OPER_DENIED, distLockFeat.beforeRefresh("resource1", "owner1", MAX_AGE_SEC));
 
         assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
     }
-	
-	
-	@Test
-	public void testUnlock() throws InterruptedException, ExecutionException {
-		distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
 
-		assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeUnlock("resource1", "owner1"));
-		assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner2", MAX_AGE_SEC));
-	}
-	
-	@Test
-	public void testIsActive() {
-		assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
-		distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
-		assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
-		assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner2"));
+    @Test
+    public void testUnlock() throws InterruptedException, ExecutionException {
+        distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
 
-		// isActive on expiredLock
-		try (PreparedStatement updateStatement = conn
-				.prepareStatement("UPDATE pooling.locks SET expirationTime = timestampadd(second, -5, now()) WHERE resourceId = ?");) {
-			updateStatement.setString(1, "resource1");
-			updateStatement.executeUpdate();
+        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeUnlock("resource1", "owner1"));
+        assertEquals(
+                OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner2", MAX_AGE_SEC));
+    }
 
-		} catch (SQLException e) {
-			logger.error("Error in TargetLockTest.testIsActive()", e);
-			throw new RuntimeException(e);
-		}
+    @Test
+    public void testIsActive() {
+        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
+        distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
+        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
+        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner2"));
 
-		assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
+        // isActive on expiredLock
+        try (PreparedStatement updateStatement =
+                conn.prepareStatement(
+                  "UPDATE pooling.locks SET expirationTime = timestampadd(second, -5, now()) WHERE resourceId = ?"); ) {
+            updateStatement.setString(1, "resource1");
+            updateStatement.executeUpdate();
 
-		distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
-			//Unlock record, next isActive attempt should fail
-		distLockFeat.beforeUnlock("resource1", "owner1");
-		assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
-		
-	}
-	
-	@Test
-	public void unlockBeforeLock() {
-		assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeUnlock("resource1", "owner1"));
-		distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
-		assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeUnlock("resource1", "owner1"));
-		assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeUnlock("resource1", "owner1"));
-	}
-	
-	@Test
-	public void testIsLocked() {
-		assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLocked("resource1"));
-		distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
-		assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLocked("resource1"));
-	
-	}
-	
-	private static void getDBConnection() {
-		try {
-			conn = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD);
-		} catch (SQLException e) {
-			logger.error("Error in TargetLockTest.getDBConnection()", e);
-		}
-	}
+        } catch (SQLException e) {
+            logger.error("Error in TargetLockTest.testIsActive()", e);
+            throw new RuntimeException(e);
+        }
 
-	private static void createTable() {
-		String createString = "create table if not exists pooling.locks (resourceId VARCHAR(128), host VARCHAR(128), owner VARCHAR(128), expirationTime TIMESTAMP DEFAULT 0, PRIMARY KEY (resourceId))";
-		try (PreparedStatement createStmt = conn.prepareStatement(createString);) {
-			createStmt.executeUpdate();
-			
-		} catch (SQLException e) {
-			logger.error("Error in TargetLockTest.createTable()", e);
-		}
-	}	
-	 
+        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
 
+        distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
+        // Unlock record, next isActive attempt should fail
+        distLockFeat.beforeUnlock("resource1", "owner1");
+        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
+    }
+
+    @Test
+    public void unlockBeforeLock() {
+        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeUnlock("resource1", "owner1"));
+        distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
+        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeUnlock("resource1", "owner1"));
+        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeUnlock("resource1", "owner1"));
+    }
+
+    @Test
+    public void testIsLocked() {
+        assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLocked("resource1"));
+        distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC);
+        assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLocked("resource1"));
+    }
+
+    private static void getDbConnection() {
+        try {
+            conn = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD);
+        } catch (SQLException e) {
+            logger.error("Error in TargetLockTest.getDBConnection()", e);
+        }
+    }
+
+    private static void createTable() {
+        String createString =
+                "create table if not exists pooling.locks "
+                + "(resourceId VARCHAR(128), host VARCHAR(128), owner VARCHAR(128), "
+                + "expirationTime TIMESTAMP DEFAULT 0, PRIMARY KEY (resourceId))";
+        try (PreparedStatement createStmt = conn.prepareStatement(createString); ) {
+            createStmt.executeUpdate();
+
+        } catch (SQLException e) {
+            logger.error("Error in TargetLockTest.createTable()", e);
+        }
+    }
 }
diff --git a/feature-eelf/src/main/java/org/onap/policy/drools/eelf/EelfFeature.java b/feature-eelf/src/main/java/org/onap/policy/drools/eelf/EelfFeature.java
index aac456e..bf0f000 100644
--- a/feature-eelf/src/main/java/org/onap/policy/drools/eelf/EelfFeature.java
+++ b/feature-eelf/src/main/java/org/onap/policy/drools/eelf/EelfFeature.java
@@ -31,43 +31,45 @@
 import org.onap.policy.drools.system.PolicyEngine;
 
 /**
- * Feature EELF : Enables EELF Logging Libraries 
+ * Feature EELF : Enables EELF Logging Libraries .
  */
 public class EelfFeature implements PolicyEngineFeatureAPI {
 
-	@Override
-	public final boolean beforeBoot(PolicyEngine engine, String[] cliArgs) {
-		
-		String logback = System.getProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, 
-				                            Main.LOGBACK_CONFIGURATION_FILE_DEFAULT);		
-		Path logbackPath = Paths.get(logback);
-		
-		if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_PATH) == null)
-			System.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, 
-					           logbackPath.toAbsolutePath().getParent().toString());
-		
-		if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_NAME) == null)
-			System.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, 
-					           logbackPath.getFileName().toString());
-		
-		Logger logger = FlexLogger.getLogger(this.getClass(), true);
-		
-		if (logger.isInfoEnabled()) {
-			logProperty(logger, Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY);
-			logProperty(logger, Configuration.PROPERTY_LOGGING_FILE_PATH);
-			logProperty(logger, Configuration.PROPERTY_LOGGING_FILE_NAME);
-		}
-		
-		return false;
-	}
-	
-	private void logProperty(Logger logger, String propnm) {
-		logger.info("eelf-feature: Property " + propnm + "=" + System.getProperty(propnm));
-	}
-	
-	@Override
-	public int getSequenceNumber() {
-		return 0;
-	}
+    @Override
+    public final boolean beforeBoot(PolicyEngine engine, String[] cliArgs) {
+
+        String logback = System.getProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, 
+                Main.LOGBACK_CONFIGURATION_FILE_DEFAULT);
+        Path logbackPath = Paths.get(logback);
+
+        if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_PATH) == null) {
+            System.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, 
+                    logbackPath.toAbsolutePath().getParent().toString());
+        }
+
+        if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_NAME) == null) {
+            System.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, 
+                    logbackPath.getFileName().toString());
+        }
+
+        Logger logger = FlexLogger.getLogger(this.getClass(), true);
+
+        if (logger.isInfoEnabled()) {
+            logProperty(logger, Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY);
+            logProperty(logger, Configuration.PROPERTY_LOGGING_FILE_PATH);
+            logProperty(logger, Configuration.PROPERTY_LOGGING_FILE_NAME);
+        }
+
+        return false;
+    }
+
+    private void logProperty(Logger logger, String propnm) {
+        logger.info("eelf-feature: Property " + propnm + "=" + System.getProperty(propnm));
+    }
+
+    @Override
+    public int getSequenceNumber() {
+        return 0;
+    }
 
 }
diff --git a/feature-eelf/src/test/java/org/onap/policy/drools/eelf/test/EElfTest.java b/feature-eelf/src/test/java/org/onap/policy/drools/eelf/test/EElfTest.java
index f700370..7f9e81c 100644
--- a/feature-eelf/src/test/java/org/onap/policy/drools/eelf/test/EElfTest.java
+++ b/feature-eelf/src/test/java/org/onap/policy/drools/eelf/test/EElfTest.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-eelf
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -17,11 +17,19 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.drools.eelf.test;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import ch.qos.logback.classic.LoggerContext;
+
+import com.att.eelf.configuration.Configuration;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFLogger.Level;
+import com.att.eelf.configuration.EELFManager;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -33,114 +41,108 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.att.eelf.configuration.Configuration;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFLogger.Level;
-import com.att.eelf.configuration.EELFManager;
-
-import ch.qos.logback.classic.LoggerContext;
-
 /**
- * Logger Tests
+ * Logger Tests.
  */
 public class EElfTest {
-	
-	/**
-	 * logback configuration location
-	 */
-	public final static String LOGBACK_CONFIGURATION_FILE_DEFAULT = "src/main/feature/config/logback-eelf.xml";
-	
-	/**
-	 * SLF4J Logger
-	 */
-	private final Logger slf4jLogger = LoggerFactory.getLogger(EElfTest.class);
-	
-	/**
-	 * get all loggers
-	 * @return list of all loggers
-	 */
-	protected List<String> loggers() {
-		List<String> loggers = new ArrayList<String>();
-		LoggerContext context = 
-    			(LoggerContext) org.slf4j.LoggerFactory.getILoggerFactory();
-    	for (org.slf4j.Logger logger: context.getLoggerList()) {
-    		loggers.add(logger.getName());
-    	}
-    	slf4jLogger.info(loggers.toString());
-		return loggers;
-	}
-	
-	/**
-	 * Assert Log Levels are the same between an EELF Logger and an SLF4J Logger
-	 * 
-	 * @param eelfLogger EELF Logger
-	 * @param slf4jLogger SLF4J Logger
-	 */
-	protected void assertLogLevels(EELFLogger eelfLogger, Logger slf4jLogger) {
-		assertTrue(slf4jLogger.isDebugEnabled() == eelfLogger.isDebugEnabled());
-		assertTrue(slf4jLogger.isInfoEnabled() == eelfLogger.isInfoEnabled());
-		assertTrue(slf4jLogger.isErrorEnabled() == eelfLogger.isErrorEnabled());
-		assertTrue(slf4jLogger.isWarnEnabled() == eelfLogger.isWarnEnabled());
-		assertTrue(slf4jLogger.isTraceEnabled() == eelfLogger.isTraceEnabled());
-	}
-	
-	@Test
-	public void slf4jLog() {
-		
-		/* standard slf4j using defaults */
-		
-		slf4jLogger.info("slf4j info");
-		
-		List<String> loggers = loggers();  	
-    	
-		assertFalse(loggers.contains(Configuration.DEBUG_LOGGER_NAME));
-		assertFalse(loggers.contains(Configuration.AUDIT_LOGGER_NAME));
-		assertFalse(loggers.contains(Configuration.ERROR_LOGGER_NAME));
-		assertFalse(loggers.contains(Configuration.METRICS_LOGGER_NAME));
-		
-		/* set logback configuration */
-		
-    	System.setProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, 
-                           LOGBACK_CONFIGURATION_FILE_DEFAULT);
-    	
-    	/* set up eelf throuth common loggings library */
-    	
-		EelfFeature feature = new EelfFeature();
-		feature.beforeBoot(PolicyEngine.manager, null);
-		
-		loggers = loggers();
-		assertTrue(loggers.contains(Configuration.DEBUG_LOGGER_NAME));
-		assertTrue(loggers.contains(Configuration.AUDIT_LOGGER_NAME));
-		assertTrue(loggers.contains(Configuration.ERROR_LOGGER_NAME));
-		assertTrue(loggers.contains(Configuration.METRICS_LOGGER_NAME));
-		
-		EELFLogger eelfAuditLogger = EELFManager.getInstance().getAuditLogger();
-		Logger slf4jAuditLogger = org.slf4j.LoggerFactory.getLogger(Configuration.AUDIT_LOGGER_NAME);
-		org.onap.policy.common.logging.flexlogger.Logger flexLogger = 
-												FlexLogger.getLogger(EElfTest.class, true);
-		
-		/* generate an error entry */
-		
-		Exception testException = new IllegalStateException("exception test");
-		flexLogger.error("flex-logger exception", testException);
-		EELFManager.getInstance().getErrorLogger().error("eelf-logger exception", testException);
-		org.slf4j.LoggerFactory.getLogger(Configuration.ERROR_LOGGER_NAME).error("slf4j-logger", testException);
 
-		
-		/* generate an audit entry through all logs */
-		
-		flexLogger.audit("flexlogger audit");
-		eelfAuditLogger.info("eelf audit");
-		slf4jAuditLogger.info("slf4j audit");
-		
-		/* check log levels in eelf and standard slf4j  change in both directions */
-		
-		/* eelf initiated */
-		eelfAuditLogger.setLevel(Level.ERROR);		
-		assertLogLevels(eelfAuditLogger, slf4jAuditLogger);
-		
-		/* slf4j initiated */
-		((ch.qos.logback.classic.Logger) slf4jLogger).setLevel((ch.qos.logback.classic.Level.INFO));		
-		assertLogLevels(eelfAuditLogger, slf4jAuditLogger);
-	}
+    /**
+     * logback configuration location.
+     */
+    public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "src/main/feature/config/logback-eelf.xml";
+
+    /**
+     * SLF4J Logger.
+     */
+    private final Logger slf4jLogger = LoggerFactory.getLogger(EElfTest.class);
+
+    /**
+     * Get all loggers.
+     * 
+     * @return list of all loggers
+     */
+    protected List<String> loggers() {
+        List<String> loggers = new ArrayList<String>();
+        LoggerContext context = 
+                (LoggerContext) org.slf4j.LoggerFactory.getILoggerFactory();
+        for (org.slf4j.Logger logger: context.getLoggerList()) {
+            loggers.add(logger.getName());
+        }
+        slf4jLogger.info(loggers.toString());
+        return loggers;
+    }
+
+    /**
+     * Assert Log Levels are the same between an EELF Logger and an SLF4J Logger.
+     * 
+     * @param eelfLogger EELF Logger
+     * @param slf4jLogger SLF4J Logger
+     */
+    protected void assertLogLevels(EELFLogger eelfLogger, Logger slf4jLogger) {
+        assertTrue(slf4jLogger.isDebugEnabled() == eelfLogger.isDebugEnabled());
+        assertTrue(slf4jLogger.isInfoEnabled() == eelfLogger.isInfoEnabled());
+        assertTrue(slf4jLogger.isErrorEnabled() == eelfLogger.isErrorEnabled());
+        assertTrue(slf4jLogger.isWarnEnabled() == eelfLogger.isWarnEnabled());
+        assertTrue(slf4jLogger.isTraceEnabled() == eelfLogger.isTraceEnabled());
+    }
+
+    @Test
+    public void slf4jLog() {
+
+        /* standard slf4j using defaults */
+
+        slf4jLogger.info("slf4j info");
+
+        List<String> loggers = loggers();
+
+        assertFalse(loggers.contains(Configuration.DEBUG_LOGGER_NAME));
+        assertFalse(loggers.contains(Configuration.AUDIT_LOGGER_NAME));
+        assertFalse(loggers.contains(Configuration.ERROR_LOGGER_NAME));
+        assertFalse(loggers.contains(Configuration.METRICS_LOGGER_NAME));
+
+        /* set logback configuration */
+
+        System.setProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, 
+                LOGBACK_CONFIGURATION_FILE_DEFAULT);
+
+        /* set up eelf throuth common loggings library */
+
+        EelfFeature feature = new EelfFeature();
+        feature.beforeBoot(PolicyEngine.manager, null);
+
+        loggers = loggers();
+        assertTrue(loggers.contains(Configuration.DEBUG_LOGGER_NAME));
+        assertTrue(loggers.contains(Configuration.AUDIT_LOGGER_NAME));
+        assertTrue(loggers.contains(Configuration.ERROR_LOGGER_NAME));
+        assertTrue(loggers.contains(Configuration.METRICS_LOGGER_NAME));
+
+        final EELFLogger eelfAuditLogger = EELFManager.getInstance().getAuditLogger();
+        final Logger slf4jAuditLogger = org.slf4j.LoggerFactory.getLogger(Configuration.AUDIT_LOGGER_NAME);
+        org.onap.policy.common.logging.flexlogger.Logger flexLogger = 
+                FlexLogger.getLogger(EElfTest.class, true);
+
+        /* generate an error entry */
+
+        Exception testException = new IllegalStateException("exception test");
+        flexLogger.error("flex-logger exception", testException);
+        EELFManager.getInstance().getErrorLogger().error("eelf-logger exception", testException);
+        org.slf4j.LoggerFactory.getLogger(Configuration.ERROR_LOGGER_NAME).error("slf4j-logger", testException);
+
+
+        /* generate an audit entry through all logs */
+
+        flexLogger.audit("flexlogger audit");
+        eelfAuditLogger.info("eelf audit");
+        slf4jAuditLogger.info("slf4j audit");
+
+        /* check log levels in eelf and standard slf4j  change in both directions */
+
+        /* eelf initiated */
+        eelfAuditLogger.setLevel(Level.ERROR);
+        assertLogLevels(eelfAuditLogger, slf4jAuditLogger);
+
+        /* slf4j initiated */
+        ((ch.qos.logback.classic.Logger) slf4jLogger).setLevel((ch.qos.logback.classic.Level.INFO));
+        assertLogLevels(eelfAuditLogger, slf4jAuditLogger);
+    }
 }
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
index f4cb1cc..d35b737 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
@@ -35,41 +35,41 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * Healthcheck
+ * Healthcheck.
  */
 public interface HealthCheck extends Startable {
 
     /**
-     * Healthcheck Monitor
+     * Healthcheck Monitor.
      */
     public static final HealthCheck monitor = new HealthCheckMonitor();
 
     /**
-     * Healthcheck Report
+     * Healthcheck Report.
      */
     public static class Report {
         /**
-         * Named Entity in the report
+         * Named Entity in the report.
          */
         private String name;
 
         /**
-         * URL queried
+         * URL queried.
          */
         private String url;
 
         /**
-         * healthy?
+         * healthy.
          */
         private boolean healthy;
 
         /**
-         * return code
+         * return code.
          */
         private int code;
 
         /**
-         * Message from remote entity
+         * Message from remote entity.
          */
         private String message;
 
@@ -132,7 +132,7 @@
     }
 
     /**
-     * Report aggregation
+     * Report aggregation.
      */
     public static class Reports {
         private boolean healthy;
@@ -167,7 +167,7 @@
     }
 
     /**
-     * perform a healthcheck
+     * Perform a healthcheck.
      * 
      * @return a report
      */
@@ -176,27 +176,27 @@
 
 
 /**
- * Healthcheck Monitor
+ * Healthcheck Monitor.
  */
 class HealthCheckMonitor implements HealthCheck {
 
     /**
-     * Logger
+     * Logger.
      */
     private static Logger logger = LoggerFactory.getLogger(HealthCheckMonitor.class);
 
     /**
-     * attached http servers
+     * attached http servers.
      */
     protected volatile List<HttpServletServer> servers = new ArrayList<>();
 
     /**
-     * attached http clients
+     * attached http clients.
      */
     protected volatile List<HttpClient> clients = new ArrayList<>();
 
     /**
-     * healthcheck configuration
+     * healthcheck configuration.
      */
     protected volatile Properties healthCheckProperties = null;
 
@@ -306,6 +306,8 @@
     }
 
     /**
+     * Get servers.
+     * 
      * @return list of attached Http Servers
      */
     public List<HttpServletServer> getServers() {
@@ -313,6 +315,8 @@
     }
 
     /**
+     * Get clients.
+     * 
      * @return list of attached Http Clients
      */
     public List<HttpClient> getClients() {
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java
index 34c1fe3..3a79a55 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-healthcheck
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -26,53 +26,54 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * This feature provides healthcheck verification of remotely associated RESTful components
+ * This feature provides healthcheck verification of remotely associated RESTful components.
  */
-public class HealthCheckFeature implements PolicyEngineFeatureAPI {	
-	
-	/**
-	 * Logger
-	 */
-	private static Logger logger = LoggerFactory.getLogger(HealthCheckFeature.class); 
-	
-	/**
-	 * Properties Configuration Name
-	 */
-	public static final String CONFIGURATION_PROPERTIES_NAME = "feature-healthcheck";
+public class HealthCheckFeature implements PolicyEngineFeatureAPI {
 
-	@Override
-	public int getSequenceNumber() {
-		return 1000;
-	}
+    /**
+     * Logger.
+     */
+    private static Logger logger = LoggerFactory.getLogger(HealthCheckFeature.class); 
 
-	@Override
-	public boolean afterStart(PolicyEngine engine) {
-		try {
-			HealthCheck.monitor.start();
-		} catch (IllegalStateException e) {
-			logger.error("Healthcheck Monitor cannot be started", e);
-		}
-		
-		return false;
-	}
+    /**
+     * Properties Configuration Name.
+     */
+    public static final String CONFIGURATION_PROPERTIES_NAME = "feature-healthcheck";
 
-	@Override
-	public boolean afterShutdown(PolicyEngine engine) {
-		try {
-			HealthCheck.monitor.stop();
-		} catch (IllegalStateException e) {
-			logger.error("Healthcheck Monitor cannot be stopped", e);
-		}
-		
-		return false;
-	}
-	
-	/**
-	 * gets the monitor
-	 * @return the healthcheck monitor
-	 */
-	public HealthCheck getMonitor() {
-		return HealthCheck.monitor;
-	}
+    @Override
+    public int getSequenceNumber() {
+        return 1000;
+    }
+
+    @Override
+    public boolean afterStart(PolicyEngine engine) {
+        try {
+            HealthCheck.monitor.start();
+        } catch (IllegalStateException e) {
+            logger.error("Healthcheck Monitor cannot be started", e);
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean afterShutdown(PolicyEngine engine) {
+        try {
+            HealthCheck.monitor.stop();
+        } catch (IllegalStateException e) {
+            logger.error("Healthcheck Monitor cannot be stopped", e);
+        }
+
+        return false;
+    }
+
+    /**
+     * Gets the monitor.
+     * 
+     * @return the healthcheck monitor
+     */
+    public HealthCheck getMonitor() {
+        return HealthCheck.monitor;
+    }
 
 }
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
index 3f51ba4..734a75e 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-healthcheck
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -17,8 +17,15 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.drools.healthcheck;
 
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
+
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
@@ -27,12 +34,6 @@
 
 import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Tag;
-
 @Path("/")
 @Api
 @Produces(MediaType.APPLICATION_JSON)
@@ -50,28 +51,29 @@
     }
 )
 public class RestHealthCheck {
-	
+
     @GET
     @Path("healthcheck")
     @Produces(MediaType.APPLICATION_JSON)
     @ApiOperation(
-        	value="Perform a system healthcheck", 
-        	notes="Provides healthy status of the PDP-D plus the components defined in its configuration by using a REST interface",
-        	response=Reports.class
-    )
+            value = "Perform a system healthcheck", 
+            notes = "Provides healthy status of the PDP-D plus the components defined in its "
+                + "configuration by using a REST interface",
+            response = Reports.class
+            )
     public Response healthcheck() {  
-		return Response.status(Response.Status.OK).entity(HealthCheck.monitor.healthCheck()).build();
+        return Response.status(Response.Status.OK).entity(HealthCheck.monitor.healthCheck()).build();
     }
-    
+
     @GET
     @Path("healthcheck/configuration")
     @Produces(MediaType.APPLICATION_JSON)
     @ApiOperation(
-        	value="Configuration", 
-        	notes="Provides the Healthcheck server configuration and monitored REST clients",
-        	response=HealthCheck.class
-    )
+            value = "Configuration", 
+            notes = "Provides the Healthcheck server configuration and monitored REST clients",
+            response = HealthCheck.class
+            )
     public HealthCheck configuration() {  
-    	return HealthCheck.monitor;
+        return HealthCheck.monitor;
     }
 }
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
index 578ce5d..8ae7343 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-healthcheck
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,7 +20,6 @@
 
 package org.onap.policy.drools.healthcheck;
 
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -45,7 +44,7 @@
 public class HealthCheckFeatureTest {
 
     /**
-     * Healthcheck Configuration File
+     * Healthcheck Configuration File.
      */
     private static final String HEALTH_CHECK_PROPERTIES_FILE = "feature-healthcheck.properties";
 
@@ -57,13 +56,15 @@
 
 
     /**
-     * logger
+     * logger.
      */
     private static Logger logger = LoggerFactory.getLogger(HealthCheckFeatureTest.class);
 
     private static Properties httpProperties = new Properties();
 
-
+    /**
+     * Set up. 
+     */
     @BeforeClass
     public static void setup() {
 
@@ -105,6 +106,9 @@
 
     }
 
+    /**
+     * Tear down.
+     */
     @AfterClass
     public static void tearDown() {
         logger.info("-- tearDown() --");
@@ -135,7 +139,7 @@
 
 
     /**
-     * setup up config directory
+     * setup up config directory.
      */
     protected static void configDirSetup() {
 
@@ -161,7 +165,7 @@
     }
 
     /**
-     * cleanup up config directory
+     * cleanup up config directory.
      */
     protected static void configDirCleanup() {
 
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java
index 5b3b82b..8bdad5b 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-healthcheck
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,7 +20,6 @@
 
 package org.onap.policy.drools.healthcheck;
 
-
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
index 278e7fd..27b8150 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
@@ -259,6 +259,8 @@
     public static class Factory {
 
         /**
+         * Get topic source.
+         * 
          * @return the topic sources
          */
         public List<TopicSource> getTopicSources() {
@@ -266,6 +268,8 @@
         }
 
         /**
+         * Get topic sinks.
+         * 
          * @return the topic sinks
          */
         public List<TopicSink> getTopicSinks() {
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
index ad6a1c5..d45bded 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
@@ -46,7 +46,9 @@
 /**
  * Controller/session pooling. Multiple hosts may be launched, all servicing the same
  * controllers/sessions. When this feature is enabled, the requests are divided across the different
- * hosts, instead of all running on a single, active host. <p> With each controller, there is an
+ * hosts, instead of all running on a single, active host. 
+ * 
+ * <p>With each controller, there is an
  * associated DMaaP topic that is used for internal communication between the different hosts
  * serving the controller.
  */
@@ -87,7 +89,7 @@
     private ThreadLocal<OfferArgs> offerArgs = new ThreadLocal<>();
 
     /**
-     * 
+     * Constructor.
      */
     public PoolingFeature() {
         super();
@@ -113,6 +115,8 @@
     }
 
     /**
+     * Get active latch.
+     * 
      * @return a latch that will be decremented when a manager enters the active state
      */
     protected CountDownLatch getActiveLatch() {
@@ -126,7 +130,7 @@
 
     @Override
     public boolean beforeStart(PolicyEngine engine) {
-        logger.info("initializing " + PoolingProperties.FEATURE_NAME);
+        logger.info("initializing {}", PoolingProperties.FEATURE_NAME);
         featProps = factory.getProperties(PoolingProperties.FEATURE_NAME);
 
         // remove any generic pooling topic - always use controller-specific property
@@ -138,6 +142,14 @@
         return false;
     }
 
+    @Override
+    public boolean beforeStart(PolicyController controller) {
+        return doManager(controller, mgr -> {
+            mgr.beforeStart();
+            return false;
+        });
+    }
+
     /**
      * Adds the controller and a new pooling manager to {@link #ctlr2pool}.
      * 
@@ -177,14 +189,6 @@
     }
 
     @Override
-    public boolean beforeStart(PolicyController controller) {
-        return doManager(controller, mgr -> {
-            mgr.beforeStart();
-            return false;
-        });
-    }
-
-    @Override
     public boolean afterStart(PolicyController controller) {
         return doManager(controller, mgr -> {
             mgr.afterStart();
@@ -307,7 +311,7 @@
      * Executes a function using the manager associated with the controller. Catches any exceptions
      * from the function and re-throws it as a runtime exception.
      * 
-     * @param controller
+     * @param controller controller
      * @param func function to be executed
      * @return {@code true} if the function handled the request, {@code false} otherwise
      * @throws PoolingFeatureRtException if an error occurs
@@ -329,7 +333,7 @@
     /**
      * Deletes the manager associated with a controller.
      * 
-     * @param controller
+     * @param controller controller
      * @throws PoolingFeatureRtException if an error occurs
      */
     private void deleteManager(PolicyController controller) {
@@ -347,10 +351,11 @@
     private static interface MgrFunc {
 
         /**
+         * Apply.
          * 
-         * @param mgr
+         * @param mgr manager
          * @return {@code true} if the request was handled by the manager, {@code false} otherwise
-         * @throws PoolingFeatureException
+         * @throws PoolingFeatureException feature exception
          */
         public boolean apply(PoolingManagerImpl mgr) throws PoolingFeatureException;
     }
@@ -376,9 +381,10 @@
         private String event;
 
         /**
+         * Constructor.
          * 
-         * @param protocol
-         * @param topic
+         * @param protocol protocol
+         * @param topic topic
          * @param event the actual event data received on the topic
          */
         public OfferArgs(CommInfrastructure protocol, String topic, String event) {
@@ -394,6 +400,8 @@
     public static class Factory {
 
         /**
+         * Get properties.
+         * 
          * @param featName feature name
          * @return the properties for the specified feature
          */
@@ -405,7 +413,7 @@
          * Makes a pooling manager for a controller.
          * 
          * @param host name/uuid of this host
-         * @param controller
+         * @param controller controller
          * @param props properties to use to configure the manager
          * @param activeLatch decremented when the manager goes Active
          * @return a new pooling manager
@@ -418,7 +426,7 @@
         /**
          * Gets the policy controller associated with a drools controller.
          * 
-         * @param droolsController
+         * @param droolsController drools controller
          * @return the policy controller associated with a drools controller
          */
         public PolicyController getController(DroolsController droolsController) {
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
index c25dc12..94956d6 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
@@ -86,7 +86,7 @@
     /**
      * Handles a {@link Forward} event that was received from the internal topic.
      * 
-     * @param event
+     * @param event event
      */
     public void handle(Forward event);
 
@@ -94,7 +94,7 @@
      * Schedules a timer to fire after a delay.
      * 
      * @param delayMs delay, in milliseconds
-     * @param task
+     * @param task task
      * @return a new scheduled task
      */
     public CancellableScheduledTask schedule(long delayMs, StateTimerTask task);
@@ -104,7 +104,7 @@
      * 
      * @param initialDelayMs initial delay, in milliseconds
      * @param delayMs delay, in milliseconds
-     * @param task
+     * @param task task
      * @return a new scheduled task
      */
     public CancellableScheduledTask scheduleWithFixedDelay(long initialDelayMs, long delayMs, StateTimerTask task);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
index 02ba4ec..17d520a 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
@@ -20,6 +20,7 @@
 
 package org.onap.policy.drools.pooling;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -29,10 +30,10 @@
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-import org.onap.policy.common.utils.properties.SpecProperties;
-import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicListener;
+import org.onap.policy.common.utils.properties.SpecProperties;
+import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.drools.pooling.extractor.ClassExtractors;
 import org.onap.policy.drools.pooling.message.BucketAssignments;
 import org.onap.policy.drools.pooling.message.Forward;
@@ -50,7 +51,6 @@
 import org.onap.policy.drools.system.PolicyController;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.JsonProcessingException;
 
 /**
  * Implementation of a {@link PoolingManager}. Until bucket assignments have been made,
@@ -126,8 +126,8 @@
 
     /**
      * Current state.
-     * <p>
-     * This uses a finite state machine, wherein the state object contains all of the data
+     * 
+     * <p>This uses a finite state machine, wherein the state object contains all of the data
      * relevant to that state. Each state object has a process() method, specific to each
      * type of {@link Message} subclass. The method returns the next state object, or
      * {@code null} if the state is to remain the same.
@@ -417,10 +417,9 @@
     /**
      * Handles an event from the internal topic.
      * 
-     * @param topic2
-     * @param event
-     * @return {@code true} if the event was handled, {@code false} if the controller
-     *         should handle it
+     * @param commType comm infrastructure
+     * @param topic2 topic
+     * @param event event
      */
     @Override
     public void onTopicEvent(CommInfrastructure commType, String topic2, String event) {
@@ -440,14 +439,14 @@
      * Called by the PolicyController before it offers the event to the DroolsController.
      * If the controller is locked, then it isn't processing events. However, they still
      * need to be forwarded, thus in that case, they are decoded and forwarded.
-     * <p>
-     * On the other hand, if the controller is not locked, then we just return immediately
+     * 
+     * <p>On the other hand, if the controller is not locked, then we just return immediately
      * and let {@link #beforeInsert(Object, String, String, Object) beforeInsert()} handle
      * it instead, as it already has the decoded message.
      * 
-     * @param protocol
-     * @param topic2
-     * @param event
+     * @param protocol protocol
+     * @param topic2 topic
+     * @param event event
      * @return {@code true} if the event was handled by the manager, {@code false} if it
      *         must still be handled by the invoker
      */
@@ -464,8 +463,8 @@
     /**
      * Called by the DroolsController before it inserts the event into the rule engine.
      * 
-     * @param protocol
-     * @param topic2
+     * @param protocol protocol
+     * @param topic2 topic
      * @param event original event text, as received from the Bus
      * @param event2 event, as an object
      * @return {@code true} if the event was handled by the manager, {@code false} if it
@@ -484,9 +483,9 @@
     /**
      * Handles an event from an external topic.
      * 
-     * @param protocol
-     * @param topic2
-     * @param event
+     * @param protocol protocol
+     * @param topic2 topic
+     * @param event event
      * @param reqid request id extracted from the event, or {@code null} if it couldn't be
      *        extracted
      * @return {@code true} if the event was handled by the manager, {@code false} if it
@@ -519,7 +518,7 @@
     /**
      * Handles an event from an external topic.
      * 
-     * @param event
+     * @param event event
      * @return {@code true} if the event was handled, {@code false} if the invoker should
      *         handle it
      */
@@ -539,7 +538,7 @@
     /**
      * Handles a {@link Forward} event, possibly forwarding it again.
      * 
-     * @param event
+     * @param event event
      * @return {@code true} if the event was handled, {@code false} if the invoker should
      *         handle it
      */
@@ -595,8 +594,8 @@
     /**
      * Decodes an event from a String into an event Object.
      * 
-     * @param topic2
-     * @param event
+     * @param topic2 topic
+     * @param event event
      * @return the decoded event object, or {@code null} if it can't be decoded
      */
     private Object decodeEvent(String topic2, String event) {
@@ -625,10 +624,10 @@
     /**
      * Makes a {@link Forward}, and validates its contents.
      * 
-     * @param protocol
-     * @param topic2
-     * @param event
-     * @param reqid
+     * @param protocol protocol
+     * @param topic2 topic
+     * @param event event
+     * @param reqid request id
      * @return a new message, or {@code null} if the message was invalid
      */
     private Forward makeForward(CommInfrastructure protocol, String topic2, String event, String reqid) {
@@ -661,7 +660,7 @@
     /**
      * Injects an event into the controller.
      * 
-     * @param event
+     * @param event event
      */
     private void inject(Forward event) {
         logger.info("inject event for request {} from topic {}", event.getRequestId(), event.getTopic());
@@ -760,6 +759,7 @@
         private StateTimerTask task;
 
         /**
+         * Constructor.
          * 
          * @param task task to execute when this timer runs
          */
@@ -832,9 +832,9 @@
          * @param topic topic on which the event was received
          * @param event event text to be decoded
          * @return the decoded event
-         * @throws IllegalArgumentException
-         * @throw UnsupportedOperationException
-         * @throws IllegalStateException
+         * @throws IllegalArgumentException illegal argument
+         * @throw UnsupportedOperationException unsupported operation
+         * @throws IllegalStateException illegal state
          */
         public Object decodeEvent(DroolsController drools, String topic, String event) {
             return EventProtocolCoder.manager.decode(drools.getGroupId(), drools.getArtifactId(), topic, event);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
index 1482366..795bd29 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
@@ -129,6 +129,8 @@
     private long interHeartbeatMs;
 
     /**
+     * Constructor.
+     * 
      * @param controllerName the name of the controller
      * @param props set of properties used to configure this
      * @throws PropertyException if an error occurs
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java
index 63aefb7..b37c33b 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java
@@ -20,11 +20,11 @@
 
 package org.onap.policy.drools.pooling;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.IOException;
 import java.util.Map;
 import org.onap.policy.drools.pooling.message.Message;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 /**
  * Serialization helper functions.
@@ -38,7 +38,7 @@
     private final ObjectMapper mapper = new ObjectMapper();
 
     /**
-     * 
+     * Constructor.
      */
     public Serializer() {
         super();
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/ClassExtractors.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/ClassExtractors.java
index 97e9633..a4d1fb1 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/ClassExtractors.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/ClassExtractors.java
@@ -70,6 +70,7 @@
     private final ConcurrentHashMap<String, Extractor> class2extractor = new ConcurrentHashMap<>();
 
     /**
+     * Constructor.
      * 
      * @param props properties that specify how the data is to be extracted from
      *        a given class
@@ -267,8 +268,8 @@
      * hierarchically, where each name identifies a particular component within
      * the hierarchy. Supports retrieval from {@link Map} objects, as well as
      * via getXxx() methods, or by direct field retrieval.
-     * <p>
-     * Note: this will <i>not</i> work if POJOs are contained within a Map.
+     * 
+     * <p>Note: this will <i>not</i> work if POJOs are contained within a Map.
      */
     private class ComponetizedExtractor implements Extractor {
 
@@ -278,11 +279,12 @@
         private final Extractor[] extractors;
 
         /**
+         * Constructor.
          * 
          * @param clazz the class associated with the object at the root of the
          *        hierarchy
          * @param names name associated with each component
-         * @throws ExtractorException
+         * @throws ExtractorException extractor exception
          */
         public ComponetizedExtractor(Class<?> clazz, String[] names) throws ExtractorException {
             this.extractors = new Extractor[names.length];
@@ -307,15 +309,12 @@
          * @param comp name of the component to extract
          * @return a pair containing the extractor and the extracted object's
          *         type
-         * @throws ExtractorException
+         * @throws ExtractorException extrator exception
          */
         private Pair<Extractor, Class<?>> buildExtractor(Class<?> clazz, String comp) throws ExtractorException {
-            Pair<Extractor, Class<?>> pair = null;
-
-            if (pair == null) {
-                pair = getMethodExtractor(clazz, comp);
-            }
-
+            
+            Pair<Extractor, Class<?>> pair = getMethodExtractor(clazz, comp);
+ 
             if (pair == null) {
                 pair = getFieldExtractor(clazz, comp);
             }
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/FieldExtractor.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/FieldExtractor.java
index d394795..9389ab2 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/FieldExtractor.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/FieldExtractor.java
@@ -37,6 +37,7 @@
     private final Field field;
 
     /**
+     * Constructor.
      * 
      * @param field field containing the object
      */
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/MapExtractor.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/MapExtractor.java
index 032ea47..9c5be5f 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/MapExtractor.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/MapExtractor.java
@@ -37,6 +37,7 @@
     private final String key;
 
     /**
+     * Constructor.
      * 
      * @param key key to the item to extract from the map
      */
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/MethodExtractor.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/MethodExtractor.java
index 20c4a1a..3efef5e 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/MethodExtractor.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/MethodExtractor.java
@@ -38,6 +38,7 @@
     private final Method method;
 
     /**
+     * Constructor.
      * 
      * @param method method to invoke to extract the contained object
      */
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
index ee871cb..b5b6469 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
@@ -20,13 +20,13 @@
 
 package org.onap.policy.drools.pooling.message;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 import org.onap.policy.drools.pooling.PoolingFeatureException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 
 /**
  * Bucket assignments, which is simply an array of host names.
@@ -57,13 +57,14 @@
     private String[] hostArray = null;
 
     /**
-     * 
+     * Constructor.
      */
     public BucketAssignments() {
         super();
     }
 
     /**
+     * Constructor.
      * 
      * @param hostArray maps a bucket number (i.e., array index) to a host. All values
      *        must be non-null
@@ -204,12 +205,15 @@
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         BucketAssignments other = (BucketAssignments) obj;
         return Arrays.equals(hostArray, other.hostArray);
     }
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java
index fb3d4eb..d4037e9 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java
@@ -20,9 +20,9 @@
 
 package org.onap.policy.drools.pooling.message;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.drools.pooling.PoolingFeatureException;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 
 /**
  * Message to forward an event to another host.
@@ -67,12 +67,13 @@
     }
 
     /**
+     * Constructor.
      * 
      * @param source host on which the message originated
-     * @param protocol
-     * @param topic
+     * @param protocol protocol
+     * @param topic topic
      * @param payload the actual event data received on the topic
-     * @param requestId
+     * @param requestId request id
      */
     public Forward(String source, CommInfrastructure protocol, String topic, String payload, String requestId) {
         super(source);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
index 2a63a5b..50a3413 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
@@ -31,7 +31,7 @@
     private long timestampMs;
 
     /**
-     * 
+     * Constructor.
      */
     public Heartbeat() {
         super();
@@ -39,6 +39,7 @@
     }
 
     /**
+     * Constructor.
      * 
      * @param source host on which the message originated
      * @param timestampMs time, in milliseconds, associated with the message
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
index 5de6b8f..6bb8836 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
@@ -26,7 +26,7 @@
 public class Identification extends MessageWithAssignments {
 
     /**
-     * 
+     * Constructor.
      */
     public Identification() {
         super();
@@ -34,9 +34,10 @@
     }
 
     /**
+     * Constructor.
      * 
      * @param source host on which the message originated
-     * @param assignments
+     * @param assignments assignments
      */
     public Identification(String source, BucketAssignments assignments) {
         super(source, assignments);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
index 0fc48c3..7464a53 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
@@ -20,8 +20,8 @@
 
 package org.onap.policy.drools.pooling.message;
 
-import org.onap.policy.drools.pooling.PoolingFeatureException;
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.onap.policy.drools.pooling.PoolingFeatureException;
 
 /**
  * Indicates that the "source" of this message is now the "lead" host.
@@ -29,16 +29,17 @@
 public class Leader extends MessageWithAssignments {
 
     /**
-     * 
+     * Constructor.
      */
     public Leader() {
         super();
     }
 
     /**
+     * Constructor.
      * 
      * @param source host on which the message originated
-     * @param assignments
+     * @param assignments assignments
      */
     public Leader(String source, BucketAssignments assignments) {
         super(source, assignments);
@@ -61,7 +62,7 @@
 
         String leader = getSource();
         
-        if(!assignments.hasAssignment(leader)) {
+        if (!assignments.hasAssignment(leader)) {
             throw new PoolingFeatureException("leader " + leader + " has no bucket assignments");            
         }
         
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java
index e8a4671..215cdae 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java
@@ -20,11 +20,11 @@
 
 package org.onap.policy.drools.pooling.message;
 
-import org.onap.policy.drools.pooling.PoolingFeatureException;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonSubTypes;
 import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
 import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.onap.policy.drools.pooling.PoolingFeatureException;
 
 /**
  * Messages sent on the internal topic.
@@ -53,13 +53,14 @@
     private String channel;
 
     /**
-     * 
+     * Constructor.
      */
     public Message() {
         super();
     }
 
     /**
+     * Constructor.
      * 
      * @param source host on which the message originated
      */
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
index 9fded81..4a0b865 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
@@ -20,8 +20,8 @@
 
 package org.onap.policy.drools.pooling.message;
 
-import org.onap.policy.drools.pooling.PoolingFeatureException;
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.onap.policy.drools.pooling.PoolingFeatureException;
 
 /**
  * A Message that includes bucket assignments.
@@ -34,16 +34,17 @@
     private BucketAssignments assignments;
 
     /**
-     * 
+     * Constructor.
      */
     public MessageWithAssignments() {
         super();
     }
 
     /**
+     * Constructor.
      * 
      * @param source host on which the message originated
-     * @param assignments
+     * @param assignments assignements
      */
     public MessageWithAssignments(String source, BucketAssignments assignments) {
         super(source);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
index 297671a..487c4f3 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
@@ -27,7 +27,7 @@
 public class Offline extends Message {
 
     /**
-     * 
+     * Constructor.
      */
     public Offline() {
         super();
@@ -35,6 +35,7 @@
     }
 
     /**
+     * Constructor.
      * 
      * @param source host on which the message originated
      */
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java
index c995a28..8c9898e 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java
@@ -26,7 +26,7 @@
 public class Query extends Message {
 
     /**
-     * 
+     * Constructor.
      */
     public Query() {
         super();
@@ -34,6 +34,7 @@
     }
 
     /**
+     * Constructor.
      * 
      * @param source host on which the message originated
      */
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
index 8f0a902..58205dd 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
@@ -66,8 +66,9 @@
     private boolean predHeartbeatSeen = false;
 
     /**
+     * Constructor.
      * 
-     * @param mgr
+     * @param mgr pooling manager
      */
     public ActiveState(PoolingManager mgr) {
         super(mgr, mgr.getAssignments().getLeader());
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/FilterUtils.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/FilterUtils.java
index a2da0ea..069ca65 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/FilterUtils.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/FilterUtils.java
@@ -44,7 +44,7 @@
     protected static final String CLASS_EQUALS = "Equals";
 
     /**
-     * 
+     * Constructor.
      */
     private FilterUtils() {
         super();
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java
index f717aa5..579dc16 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java
@@ -35,8 +35,9 @@
     private static final Logger logger = LoggerFactory.getLogger(InactiveState.class);
 
     /**
+     * Constructor.
      * 
-     * @param mgr
+     * @param mgr pooling manager
      */
     public InactiveState(PoolingManager mgr) {
         super(mgr);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
index e9dc032..7fed6a1 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
@@ -48,8 +48,9 @@
     private String leader;
 
     /**
+     * Constructor.
      * 
-     * @param mgr
+     * @param mgr pooling manager
      * @param leader current known leader, which need not be the same as the assignment
      *        leader. Never {@code null}
      * @throws IllegalArgumentException if an argument is invalid
@@ -308,10 +309,10 @@
             }
 
             // move the bucket from the larger to the smaller
-            Integer b = larger.remove();
-            smaller.add(b);
+            Integer bucket = larger.remove();
+            smaller.add(bucket);
 
-            bucket2host[b] = smaller.host;
+            bucket2host[bucket] = smaller.host;
 
             // put the items back, with their new counts
             assignments.add(larger);
@@ -349,8 +350,9 @@
         private Queue<Integer> buckets = new LinkedList<>();
 
         /**
+         * Constructor.
          * 
-         * @param host
+         * @param host host
          */
         public HostBucket(String host) {
             this.host = host;
@@ -375,6 +377,7 @@
         }
 
         /**
+         * Size.
          * 
          * @return the number of buckets assigned to this host
          */
@@ -388,11 +391,11 @@
          */
         @Override
         public final int compareTo(HostBucket other) {
-            int d = buckets.size() - other.buckets.size();
-            if (d == 0) {
-                d = host.compareTo(other.host);
+            int diff = buckets.size() - other.buckets.size();
+            if (diff == 0) {
+                diff = host.compareTo(other.host);
             }
-            return d;
+            return diff;
         }
 
         @Override
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java
index 1a4da15..ea74f03 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java
@@ -51,8 +51,9 @@
     private boolean sawSelfIdent = false;
 
     /**
+     * Constructor.
      * 
-     * @param mgr
+     * @param mgr manager
      */
     public QueryState(PoolingManager mgr) {
         // this host is the leader, until a better candidate identifies itself
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
index 3068cfc..59d264e 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
@@ -25,6 +25,7 @@
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeAnd;
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeEquals;
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeOr;
+
 import java.util.Map;
 import org.onap.policy.drools.pooling.PoolingManager;
 import org.onap.policy.drools.pooling.message.Heartbeat;
@@ -47,14 +48,16 @@
     private long hbTimestampMs = System.currentTimeMillis();
 
     /**
+     * Constructor.
      * 
-     * @param mgr
+     * @param mgr pooling manager
      */
     public StartState(PoolingManager mgr) {
         super(mgr);
     }
 
     /**
+     * Get Heart beat time stamp in milliseconds.
      * 
      * @return the time stamp inserted into the heart beat message
      */
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java
index a1be2a7..edffb3f 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java
@@ -23,6 +23,7 @@
 import static org.onap.policy.drools.pooling.state.FilterUtils.MSG_CHANNEL;
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeEquals;
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeOr;
+
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -42,8 +43,8 @@
 
 /**
  * A state in the finite state machine.
- * <p>
- * A state may have several timers associated with it, which must be cancelled whenever
+ * 
+ * <p>A state may have several timers associated with it, which must be cancelled whenever
  * the state is changed. Assumes that timers are not continuously added to the same state.
  */
 public abstract class State {
@@ -61,8 +62,9 @@
     private final List<CancellableScheduledTask> timers = new LinkedList<>();
 
     /**
+     * Constructor.
      * 
-     * @param mgr
+     * @param mgr pooling manager
      */
     public State(PoolingManager mgr) {
         this.mgr = mgr;
@@ -197,6 +199,28 @@
     }
 
     /**
+     * Processes a message. The default method just returns {@code null}.
+     * 
+     * @param msg message to be processed
+     * @return the new state, or {@code null} if the state is unchanged
+     */
+    public State process(Offline msg) {
+        logger.info("ignored offline message from {} on topic {}", msg.getSource(), getTopic());
+        return null;
+    }
+
+    /**
+     * Processes a message. The default method just returns {@code null}.
+     * 
+     * @param msg message to be processed
+     * @return the new state, or {@code null} if the state is unchanged
+     */
+    public State process(Query msg) {
+        logger.info("ignored Query message from {} on topic {}", msg.getSource(), getTopic());
+        return null;
+    }
+
+    /**
      * Determines if a message is valid and did not originate from this host.
      * 
      * @param msg message to be validated
@@ -227,28 +251,6 @@
     }
 
     /**
-     * Processes a message. The default method just returns {@code null}.
-     * 
-     * @param msg message to be processed
-     * @return the new state, or {@code null} if the state is unchanged
-     */
-    public State process(Offline msg) {
-        logger.info("ignored offline message from {} on topic {}", msg.getSource(), getTopic());
-        return null;
-    }
-
-    /**
-     * Processes a message. The default method just returns {@code null}.
-     * 
-     * @param msg message to be processed
-     * @return the new state, or {@code null} if the state is unchanged
-     */
-    public State process(Query msg) {
-        logger.info("ignored Query message from {} on topic {}", msg.getSource(), getTopic());
-        return null;
-    }
-
-    /**
      * Publishes a message.
      * 
      * @param msg message to be published
@@ -287,7 +289,7 @@
     /**
      * Publishes a message on the specified channel.
      * 
-     * @param channel
+     * @param channel channel
      * @param msg message to be published
      */
     protected final void publish(String channel, Forward msg) {
@@ -297,7 +299,7 @@
     /**
      * Publishes a message on the specified channel.
      * 
-     * @param channel
+     * @param channel channel
      * @param msg message to be published
      */
     protected final void publish(String channel, Heartbeat msg) {
@@ -307,7 +309,7 @@
     /**
      * Starts distributing messages using the specified bucket assignments.
      * 
-     * @param assignments
+     * @param assignments assignments
      */
     protected final void startDistributing(BucketAssignments assignments) {
         if (assignments != null) {
@@ -318,8 +320,8 @@
     /**
      * Schedules a timer to fire after a delay.
      * 
-     * @param delayMs
-     * @param task
+     * @param delayMs delay in ms
+     * @param task task
      */
     protected final void schedule(long delayMs, StateTimerTask task) {
         timers.add(mgr.schedule(delayMs, task));
@@ -328,9 +330,9 @@
     /**
      * Schedules a timer to fire repeatedly.
      * 
-     * @param initialDelayMs
-     * @param delayMs
-     * @param task
+     * @param initialDelayMs initial delay ms
+     * @param delayMs delay ms
+     * @param task task
      */
     protected final void scheduleWithFixedDelay(long initialDelayMs, long delayMs, StateTimerTask task) {
         timers.add(mgr.scheduleWithFixedDelay(initialDelayMs, delayMs, task));
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/DmaapManagerTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/DmaapManagerTest.java
index d48dea5..e554a34 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/DmaapManagerTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/DmaapManagerTest.java
@@ -30,6 +30,7 @@
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.concurrent.CountDownLatch;
@@ -70,6 +71,11 @@
         DmaapManager.setFactory(saveFactory);
     }
 
+    /**
+     * Setup.
+     * 
+     * @throws Exception throws an exception
+     */
     @Before
     public void setUp() throws Exception {
         listener = mock(TopicListener.class);
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
index 3c3466b..709f1b0 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
@@ -27,6 +27,9 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.onap.policy.drools.pooling.PoolingProperties.PREFIX;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Deque;
@@ -51,21 +54,19 @@
 import org.junit.Test;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
-import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.common.endpoints.event.comm.FilterableTopicSource;
 import org.onap.policy.common.endpoints.event.comm.Topic;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicListener;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
+import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.drools.pooling.message.Message;
 import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.drools.system.PolicyEngine;
 import org.onap.policy.drools.utils.Pair;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 /**
  * End-to-end tests of the pooling feature. Launches one or more "hosts", each one having
@@ -118,6 +119,10 @@
      */
     private Context ctx;
 
+    /**
+     * Setup before class.
+     * 
+     */
     @BeforeClass
     public static void setUpBeforeClass() {
         saveFeatureFactory = PoolingFeature.getFactory();
@@ -127,6 +132,9 @@
         // note: invoke runSlow() to slow things down
     }
 
+    /**
+     * Tear down after class.
+     */
     @AfterClass
     public static void tearDownAfterClass() {
         PoolingFeature.setFactory(saveFeatureFactory);
@@ -134,11 +142,17 @@
         DmaapManager.setFactory(saveDmaapFactory);
     }
 
+    /**
+     * Setup.
+     */
     @Before
     public void setUp() {
         ctx = null;
     }
 
+    /**
+     * Tear down.
+     */
     @After
     public void tearDown() {
         if (ctx != null) {
@@ -189,15 +203,15 @@
      * Invoke this to slow the timers down.
      */
     protected static void runSlow() {
-         stdReactivateWaitMs = 10000;
-         stdIdentificationMs = 10000;
-         stdStartHeartbeatMs = 15000;
-         stdActiveHeartbeatMs = 12000;
-         stdInterHeartbeatMs = 5000;
-         stdOfflinePubWaitMs = 2;
-         stdPollMs = 2;
-         stdInterPollMs = 2000;
-         stdEventWaitSec = 1000;
+        stdReactivateWaitMs = 10000;
+        stdIdentificationMs = 10000;
+        stdStartHeartbeatMs = 15000;
+        stdActiveHeartbeatMs = 12000;
+        stdInterHeartbeatMs = 5000;
+        stdOfflinePubWaitMs = 2;
+        stdPollMs = 2;
+        stdInterPollMs = 2000;
+        stdEventWaitSec = 1000;
     }
 
     /**
@@ -232,7 +246,7 @@
         /**
          * Counts the number of decode errors.
          */
-        private final AtomicInteger nDecodeErrors = new AtomicInteger(0);
+        private final AtomicInteger numDecodeErrors = new AtomicInteger(0);
 
         /**
          * Number of events we're still waiting to receive.
@@ -246,14 +260,15 @@
         private Host currentHost = null;
 
         /**
+         * Constructor.
          * 
          * @param nEvents number of events to be processed
          */
-        public Context(int nEvents) {
+        public Context(int events) {
             featureFactory = new FeatureFactory(this);
             managerFactory = new ManagerFactory(this);
             dmaapFactory = new DmaapFactory(this);
-            eventCounter = new CountDownLatch(nEvents);
+            eventCounter = new CountDownLatch(events);
 
             PoolingFeature.setFactory(featureFactory);
             PoolingManagerImpl.setFactory(managerFactory);
@@ -298,10 +313,10 @@
          * Verifies that all hosts processed at least one message.
          */
         public void checkAllSawAMsg() {
-            int x = 0;
+            int msgs = 0;
             for (Host host : hosts) {
-                assertTrue("x=" + x, host.messageSeen());
-                ++x;
+                assertTrue("msgs=" + msgs, host.messageSeen());
+                ++msgs;
             }
         }
 
@@ -309,7 +324,7 @@
          * Sets {@link #currentHost} to the specified host, and then invokes the given
          * function. Resets {@link #currentHost} to {@code null} before returning.
          * 
-         * @param host
+         * @param host host
          * @param func function to invoke
          */
         public void withHost(Host host, VoidFunction func) {
@@ -321,7 +336,7 @@
         /**
          * Offers an event to the external topic.
          * 
-         * @param event
+         * @param event event
          */
         public void offerExternal(String event) {
             externalTopic.offer(event);
@@ -330,7 +345,7 @@
         /**
          * Adds an internal channel to the set of channels.
          * 
-         * @param channel
+         * @param channel channel
          * @param queue the channel's queue
          */
         public void addInternal(String channel, BlockingQueue<String> queue) {
@@ -340,7 +355,7 @@
         /**
          * Offers a message to all internal channels.
          * 
-         * @param message
+         * @param message message
          */
         public void offerInternal(String message) {
             channel2queue.values().forEach(queue -> queue.offer(message));
@@ -349,8 +364,8 @@
         /**
          * Offers amessage to an internal channel.
          * 
-         * @param channel
-         * @param message
+         * @param channel channel
+         * @param message message
          */
         public void offerInternal(String channel, String message) {
             BlockingQueue<String> queue = channel2queue.get(channel);
@@ -362,7 +377,7 @@
         /**
          * Decodes an event.
          * 
-         * @param event
+         * @param event event
          * @return the decoded event, or {@code null} if it cannot be decoded
          */
         public Object decodeEvent(String event) {
@@ -372,15 +387,17 @@
         /**
          * Associates a controller with its drools controller.
          * 
-         * @param controller
-         * @param droolsController
+         * @param controller controller
+         * @param droolsController drools controller
          */
         public void addController(PolicyController controller, DroolsController droolsController) {
             drools2policy.put(droolsController, controller);
         }
 
         /**
-         * @param droolsController
+         * Get controller.
+         * 
+         * @param droolsController drools controller
          * @return the controller associated with a drools controller, or {@code null} if
          *         it has no associated controller
          */
@@ -389,6 +406,8 @@
         }
 
         /**
+         * Constructor.
+         * 
          * @return queue for the external topic
          */
         public BlockingQueue<String> getExternalTopic() {
@@ -396,21 +415,23 @@
         }
 
         /**
+         * Get decode errors.
          * 
          * @return the number of decode errors so far
          */
         public int getDecodeErrors() {
-            return nDecodeErrors.get();
+            return numDecodeErrors.get();
         }
 
         /**
          * Increments the count of decode errors.
          */
         public void bumpDecodeErrors() {
-            nDecodeErrors.incrementAndGet();
+            numDecodeErrors.incrementAndGet();
         }
 
         /**
+         * Get remaining events.
          * 
          * @return the number of events that haven't been processed
          */
@@ -428,10 +449,10 @@
         /**
          * Waits, for a period of time, for all events to be processed.
          * 
-         * @param time
-         * @param units
+         * @param time time
+         * @param units units
          * @return {@code true} if all events have been processed, {@code false} otherwise
-         * @throws InterruptedException
+         * @throws InterruptedException throws interrupted
          */
         public boolean awaitEvents(long time, TimeUnit units) throws InterruptedException {
             return eventCounter.await(time, units);
@@ -478,8 +499,9 @@
         private final DroolsController drools = mock(DroolsController.class);
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          */
         public Host(Context context) {
             this.context = context;
@@ -502,6 +524,8 @@
         }
 
         /**
+         * Get name.
+         * 
          * @return the host name
          */
         public String getName() {
@@ -543,9 +567,9 @@
         /**
          * Offers an event to the feature, before the policy controller handles it.
          * 
-         * @param protocol
-         * @param topic2
-         * @param event
+         * @param protocol protocol
+         * @param topic2 topic
+         * @param event event
          * @return {@code true} if the event was handled, {@code false} otherwise
          */
         public boolean beforeOffer(CommInfrastructure protocol, String topic2, String event) {
@@ -555,10 +579,10 @@
         /**
          * Offers an event to the feature, after the policy controller handles it.
          * 
-         * @param protocol
-         * @param topic
-         * @param event
-         * @param success
+         * @param protocol protocol
+         * @param topic topic
+         * @param event event
+         * @param success success
          * @return {@code true} if the event was handled, {@code false} otherwise
          */
         public boolean afterOffer(CommInfrastructure protocol, String topic, String event, boolean success) {
@@ -569,7 +593,7 @@
         /**
          * Offers an event to the feature, before the drools controller handles it.
          * 
-         * @param fact
+         * @param fact fact
          * @return {@code true} if the event was handled, {@code false} otherwise
          */
         public boolean beforeInsert(Object fact) {
@@ -579,7 +603,7 @@
         /**
          * Offers an event to the feature, after the drools controller handles it.
          * 
-         * @param fact
+         * @param fact fact
          * @param successInsert {@code true} if it was successfully inserted by the drools
          *        controller, {@code false} otherwise
          * @return {@code true} if the event was handled, {@code false} otherwise
@@ -596,6 +620,7 @@
         }
 
         /**
+         * Message seen.
          * 
          * @return {@code true} if a message was seen for this host, {@code false}
          *         otherwise
@@ -605,6 +630,8 @@
         }
 
         /**
+         * Get internal queue.
+         * 
          * @return the queue associated with this host's internal topic
          */
         public BlockingQueue<String> getInternalQueue() {
@@ -628,10 +655,10 @@
 
         @Override
         public Void answer(InvocationOnMock args) throws Throwable {
-            int i = 0;
-            CommInfrastructure commType = args.getArgument(i++);
-            String topic = args.getArgument(i++);
-            String event = args.getArgument(i++);
+            int index = 0;
+            CommInfrastructure commType = args.getArgument(index++);
+            String topic = args.getArgument(index++);
+            String event = args.getArgument(index++);
 
             if (host.beforeOffer(commType, topic, event)) {
                 return null;
@@ -676,8 +703,9 @@
         private final Serializer serializer = new Serializer();
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          */
         public TopicSinkImpl(Context context) {
             this.context = context;
@@ -732,8 +760,9 @@
         private AtomicReference<Pair<CountDownLatch, CountDownLatch>> pair = new AtomicReference<>(null);
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          * @param internal {@code true} if to read from the internal topic, {@code false}
          *        to read from the external topic
          */
@@ -778,7 +807,8 @@
                 try {
                     do {
                         processMessages(newPair.first(), listener);
-                    } while (!newPair.first().await(stdInterPollMs, TimeUnit.MILLISECONDS));
+                    } 
+                    while (!newPair.first().await(stdInterPollMs, TimeUnit.MILLISECONDS));
 
                     logger.info("topic source thread completed");
 
@@ -850,8 +880,8 @@
          * Polls for messages from the topic and offers them to the listener.
          * 
          * @param stopped triggered if processing should stop
-         * @param listener
-         * @throws InterruptedException
+         * @param listener listener
+         * @throws InterruptedException throws interrupted exception
          */
         private void processMessages(CountDownLatch stopped, TopicListener listener) throws InterruptedException {
 
@@ -874,7 +904,7 @@
     private static class TopicImpl implements Topic {
 
         /**
-         * 
+         * Constructor.
          */
         public TopicImpl() {
             super();
@@ -954,8 +984,9 @@
         private final Context context;
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          */
         public FeatureFactory(Context context) {
             this.context = context;
@@ -1029,8 +1060,9 @@
         private final TypeReference<TreeMap<String, String>> typeRef = new TypeReference<TreeMap<String, String>>() {};
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          */
         public ManagerFactory(Context context) {
 
@@ -1065,8 +1097,9 @@
         private final Context context;
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          */
         public DmaapFactory(Context context) {
             this.context = context;
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java
index 70bacb1..050ca61 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java
@@ -70,7 +70,7 @@
  * following are not: <dl> <dt>PolicyEngine, PolicyController, DroolsController</dt> <dd>mocked</dd>
  * </dl>
  * 
- * <p> The following fields must be set before executing this: <ul> <li>UEB_SERVERS</li>
+ * <p>The following fields must be set before executing this: <ul> <li>UEB_SERVERS</li>
  * <li>INTERNAL_TOPIC</li> <li>EXTERNAL_TOPIC</li> </ul>
  */
 public class FeatureTest2 {
@@ -135,7 +135,10 @@
      */
     private Context ctx;
 
-
+    /**
+     * Setup before class.
+     * 
+     */
     @BeforeClass
     public static void setUpBeforeClass() {
         saveFeatureFactory = PoolingFeature.getFactory();
@@ -149,6 +152,10 @@
         internalSink.start();
     }
 
+    /**
+     * Tear down after class.
+     * 
+     */
     @AfterClass
     public static void tearDownAfterClass() {
         PoolingFeature.setFactory(saveFeatureFactory);
@@ -159,11 +166,17 @@
         internalSink.stop();
     }
 
+    /**
+     * Setup.
+     */
     @Before
     public void setUp() {
         ctx = null;
     }
 
+    /**
+     * Tear down.
+     */
     @After
     public void tearDown() {
         if (ctx != null) {
@@ -275,7 +288,7 @@
         /**
          * Counts the number of decode errors.
          */
-        private final AtomicInteger nDecodeErrors = new AtomicInteger(0);
+        private final AtomicInteger decodeErrors = new AtomicInteger(0);
 
         /**
          * Number of events we're still waiting to receive.
@@ -283,13 +296,14 @@
         private final CountDownLatch eventCounter;
 
         /**
+         * Constructor.
          * 
          * @param nEvents number of events to be processed
          */
-        public Context(int nEvents) {
+        public Context(int events) {
             featureFactory = new FeatureFactory(this);
             managerFactory = new ManagerFactory(this);
-            eventCounter = new CountDownLatch(nEvents);
+            eventCounter = new CountDownLatch(events);
 
             PoolingFeature.setFactory(featureFactory);
             PoolingManagerImpl.setFactory(managerFactory);
@@ -333,17 +347,17 @@
          * Verifies that all hosts processed at least one message.
          */
         public void checkAllSawAMsg() {
-            int x = 0;
+            int msgs = 0;
             for (Host host : hosts) {
-                assertTrue("x=" + x, host.messageSeen());
-                ++x;
+                assertTrue("msgs=" + msgs, host.messageSeen());
+                ++msgs;
             }
         }
 
         /**
          * Offers an event to the external topic.
          * 
-         * @param event
+         * @param event event
          */
         public void offerExternal(String event) {
             externalSink.send(event);
@@ -352,7 +366,7 @@
         /**
          * Decodes an event.
          * 
-         * @param event
+         * @param event event
          * @return the decoded event, or {@code null} if it cannot be decoded
          */
         public Object decodeEvent(String event) {
@@ -362,15 +376,17 @@
         /**
          * Associates a controller with its drools controller.
          * 
-         * @param controller
-         * @param droolsController
+         * @param controller controller
+         * @param droolsController drools controller
          */
         public void addController(PolicyController controller, DroolsController droolsController) {
             drools2policy.put(droolsController, controller);
         }
 
         /**
-         * @param droolsController
+         * Get controller.
+         * 
+         * @param droolsController drools controller
          * @return the controller associated with a drools controller, or {@code null} if it has no
          *         associated controller
          */
@@ -379,21 +395,23 @@
         }
 
         /**
+         * Get decode errors.
          * 
          * @return the number of decode errors so far
          */
         public int getDecodeErrors() {
-            return nDecodeErrors.get();
+            return decodeErrors.get();
         }
 
         /**
          * Increments the count of decode errors.
          */
         public void bumpDecodeErrors() {
-            nDecodeErrors.incrementAndGet();
+            decodeErrors.incrementAndGet();
         }
 
         /**
+         * Get remaining events.
          * 
          * @return the number of events that haven't been processed
          */
@@ -411,10 +429,10 @@
         /**
          * Waits, for a period of time, for all events to be processed.
          * 
-         * @param time
-         * @param units
+         * @param time time
+         * @param units units
          * @return {@code true} if all events have been processed, {@code false} otherwise
-         * @throws InterruptedException
+         * @throws InterruptedException throws interrupted exception
          */
         public boolean awaitEvents(long time, TimeUnit units) throws InterruptedException {
             return eventCounter.await(time, units);
@@ -424,7 +442,7 @@
          * Waits, for a period of time, for all hosts to enter the Active state.
          * 
          * @param timeMs maximum time to wait, in milliseconds
-         * @throws InterruptedException
+         * @throws InterruptedException throws interrupted exception
          */
         public void awaitAllActive(long timeMs) throws InterruptedException {
             long tend = timeMs + System.currentTimeMillis();
@@ -457,8 +475,9 @@
         private final DroolsController drools = mock(DroolsController.class);
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          */
         public Host(Context context) {
 
@@ -485,7 +504,7 @@
          * @param timeMs time to wait, in milliseconds
          * @return {@code true} if the host entered the Active state within the given amount of
          *         time, {@code false} otherwise
-         * @throws InterruptedException
+         * @throws InterruptedException throws interrupted exception
          */
         public boolean awaitActive(long timeMs) throws InterruptedException {
             return feature.getActiveLatch().await(timeMs, TimeUnit.MILLISECONDS);
@@ -531,9 +550,9 @@
         /**
          * Offers an event to the feature, before the policy controller handles it.
          * 
-         * @param protocol
-         * @param topic2
-         * @param event
+         * @param protocol protocol
+         * @param topic2 topic
+         * @param event event
          * @return {@code true} if the event was handled, {@code false} otherwise
          */
         public boolean beforeOffer(CommInfrastructure protocol, String topic2, String event) {
@@ -543,10 +562,10 @@
         /**
          * Offers an event to the feature, after the policy controller handles it.
          * 
-         * @param protocol
-         * @param topic
-         * @param event
-         * @param success
+         * @param protocol protocol
+         * @param topic topic
+         * @param event event
+         * @param success success
          * @return {@code true} if the event was handled, {@code false} otherwise
          */
         public boolean afterOffer(CommInfrastructure protocol, String topic, String event, boolean success) {
@@ -557,7 +576,7 @@
         /**
          * Offers an event to the feature, before the drools controller handles it.
          * 
-         * @param fact
+         * @param fact fact
          * @return {@code true} if the event was handled, {@code false} otherwise
          */
         public boolean beforeInsert(Object fact) {
@@ -567,7 +586,7 @@
         /**
          * Offers an event to the feature, after the drools controller handles it.
          * 
-         * @param fact
+         * @param fact fact
          * @param successInsert {@code true} if it was successfully inserted by the drools
          *        controller, {@code false} otherwise
          * @return {@code true} if the event was handled, {@code false} otherwise
@@ -584,6 +603,7 @@
         }
 
         /**
+         * Message seen.
          * 
          * @return {@code true} if a message was seen for this host, {@code false} otherwise
          */
@@ -608,10 +628,10 @@
 
         @Override
         public Void answer(InvocationOnMock args) throws Throwable {
-            int i = 0;
-            CommInfrastructure commType = args.getArgument(i++);
-            String topic = args.getArgument(i++);
-            String event = args.getArgument(i++);
+            int index = 0;
+            CommInfrastructure commType = args.getArgument(index++);
+            String topic = args.getArgument(index++);
+            String event = args.getArgument(index++);
 
             if (host.beforeOffer(commType, topic, event)) {
                 return null;
@@ -649,8 +669,9 @@
         private final Context context;
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          */
         public FeatureFactory(Context context) {
             this.context = context;
@@ -727,8 +748,9 @@
         private final TypeReference<TreeMap<String, String>> typeRef = new TypeReference<TreeMap<String, String>>() {};
 
         /**
+         * Constructor.
          * 
-         * @param context
+         * @param context context
          */
         public ManagerFactory(Context context) {
 
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java
index 34b604c..731736a 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java
@@ -20,7 +20,8 @@
 
 package org.onap.policy.drools.pooling;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 import org.onap.policy.common.utils.test.ExceptionsTester;
 
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java
index cbb2442..fcd2332 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java
@@ -20,7 +20,8 @@
 
 package org.onap.policy.drools.pooling;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 import org.onap.policy.common.utils.test.ExceptionsTester;
 import org.onap.policy.drools.pooling.PoolingFeatureRtException;
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java
index c57a9f6..07fc757 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java
@@ -31,6 +31,7 @@
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Properties;
@@ -38,8 +39,8 @@
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.drools.pooling.PoolingFeature.Factory;
 import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.drools.system.PolicyEngine;
@@ -95,6 +96,11 @@
         PoolingFeature.setFactory(saveFactory);
     }
 
+    /**
+     * Setup.
+     * 
+     * @throws Exception exception
+     */
     @Before
     public void setUp() throws Exception {
         props = initProperties();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java
index d90bac4..e6b6e4c 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java
@@ -34,6 +34,7 @@
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.LinkedList;
 import java.util.Properties;
 import java.util.Queue;
@@ -46,9 +47,9 @@
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
-import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicListener;
+import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.drools.pooling.PoolingManagerImpl.Factory;
 import org.onap.policy.drools.pooling.extractor.ClassExtractors;
 import org.onap.policy.drools.pooling.message.BucketAssignments;
@@ -125,6 +126,11 @@
         PoolingManagerImpl.setFactory(saveFactory);
     }
 
+    /**
+     * Setup.
+     * 
+     * @throws Exception throws exception
+     */
     @Before
     public void setUp() throws Exception {
         plainProps = new Properties();
@@ -202,7 +208,7 @@
         PolicyController ctlr = mock(PolicyController.class);
 
         PoolingFeatureRtException ex = expectException(PoolingFeatureRtException.class,
-                        () -> new PoolingManagerImpl(MY_HOST, ctlr, poolProps, active));
+            () -> new PoolingManagerImpl(MY_HOST, ctlr, poolProps, active));
         assertNotNull(ex.getCause());
         assertTrue(ex.getCause() instanceof ClassCastException);
     }
@@ -214,7 +220,7 @@
         when(factory.makeDmaapManager(any())).thenThrow(ex);
 
         PoolingFeatureRtException ex2 = expectException(PoolingFeatureRtException.class,
-                        () -> new PoolingManagerImpl(MY_HOST, controller, poolProps, active));
+            () -> new PoolingManagerImpl(MY_HOST, controller, poolProps, active));
         assertEquals(ex, ex2.getCause());
     }
 
@@ -304,26 +310,26 @@
 
         Forward msg = new Forward(mgr.getHost(), CommInfrastructure.UEB, TOPIC2, THE_EVENT, REQUEST_ID);
         mgr.handle(msg);
-        verify(dmaap, times(START_PUB+1)).publish(any());
+        verify(dmaap, times(START_PUB + 1)).publish(any());
         
         mgr.beforeStop();
 
         verify(dmaap).stopConsumer(mgr);
         verify(sched).shutdownNow();
-        verify(dmaap, times(START_PUB+2)).publish(any());
+        verify(dmaap, times(START_PUB + 2)).publish(any());
         verify(dmaap).publish(contains("offline"));
 
         assertTrue(mgr.getCurrent() instanceof IdleState);
 
         // verify that next message is handled locally
         mgr.handle(msg);
-        verify(dmaap, times(START_PUB+2)).publish(any());
+        verify(dmaap, times(START_PUB + 2)).publish(any());
         verify(controller).onTopicEvent(CommInfrastructure.UEB, TOPIC2, THE_EVENT);
     }
 
     @Test
     public void testBeforeStop_NotRunning() throws Exception {
-        State st = mgr.getCurrent();
+        final State st = mgr.getCurrent();
 
         mgr.beforeStop();
 
@@ -339,7 +345,7 @@
         // call beforeStart but not afterStart
         mgr.beforeStart();
 
-        State st = mgr.getCurrent();
+        final State st = mgr.getCurrent();
 
         mgr.beforeStop();
 
@@ -624,7 +630,7 @@
         // route the message to this host
         mgr.startDistributing(makeAssignments(true));
 
-        CountDownLatch latch = catchRecursion(false);
+        final CountDownLatch latch = catchRecursion(false);
 
         Forward msg = new Forward(mgr.getHost(), CommInfrastructure.UEB, TOPIC2, THE_EVENT, REQUEST_ID);
         mgr.handle(msg);
@@ -644,7 +650,7 @@
         // route the message to this host
         mgr.startDistributing(makeAssignments(true));
 
-        CountDownLatch latch = catchRecursion(true);
+        final CountDownLatch latch = catchRecursion(true);
 
         Forward msg = new Forward(mgr.getHost(), CommInfrastructure.UEB, TOPIC2, THE_EVENT, REQUEST_ID);
         mgr.handle(msg);
@@ -870,7 +876,7 @@
 
         assertTrue(mgr.beforeInsert(CommInfrastructure.UEB, TOPIC2, THE_EVENT, DECODED_EVENT));
         
-        verify(dmaap, times(START_PUB+1)).publish(any());
+        verify(dmaap, times(START_PUB + 1)).publish(any());
     }
 
     @Test
@@ -921,7 +927,7 @@
         // route the message to this host
         mgr.startDistributing(makeAssignments(true));
 
-        CountDownLatch latch = catchRecursion(true);
+        final CountDownLatch latch = catchRecursion(true);
 
         Forward msg = new Forward(mgr.getHost(), CommInfrastructure.UEB, TOPIC2, THE_EVENT, REQUEST_ID);
         mgr.handle(msg);
@@ -943,7 +949,7 @@
         // generate RuntimeException when onTopicEvent() is invoked
         doThrow(new IllegalArgumentException("expected")).when(controller).onTopicEvent(any(), any(), any());
 
-        CountDownLatch latch = catchRecursion(true);
+        final CountDownLatch latch = catchRecursion(true);
 
         Forward msg = new Forward(mgr.getHost(), CommInfrastructure.UEB, TOPIC2, THE_EVENT, REQUEST_ID);
         mgr.handle(msg);
@@ -975,7 +981,7 @@
     }
 
     @Test
-    public void testHandleInternal_IOEx() throws Exception {
+    public void testHandleInternal_IoEx() throws Exception {
         startMgr();
 
         mgr.onTopicEvent(CommInfrastructure.UEB, MY_TOPIC, "invalid message");
@@ -1028,7 +1034,7 @@
         // route the message to the other host
         mgr.startDistributing(makeAssignments(false));
         assertTrue(mgr.beforeInsert(CommInfrastructure.UEB, TOPIC2, THE_EVENT, DECODED_EVENT));
-        verify(dmaap, times(START_PUB+1)).publish(any());
+        verify(dmaap, times(START_PUB + 1)).publish(any());
     }
 
     @Test
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
index eac8bfb..cc716a2 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
@@ -32,6 +32,7 @@
 import static org.onap.policy.drools.pooling.PoolingProperties.PREFIX;
 import static org.onap.policy.drools.pooling.PoolingProperties.REACTIVATE_MS;
 import static org.onap.policy.drools.pooling.PoolingProperties.START_HEARTBEAT_MS;
+
 import java.util.Properties;
 import java.util.function.Function;
 import org.junit.Before;
@@ -57,6 +58,11 @@
     private Properties plain;
     private PoolingProperties pooling;
 
+    /**
+     * Setup.
+     * 
+     * @throws Exception throws an exception
+     */
     @Before
     public void setUp() throws Exception {
         plain = makeProperties();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java
index 4206a83..0b098c1 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java
@@ -26,6 +26,7 @@
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeAnd;
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeEquals;
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeOr;
+
 import java.util.Map;
 import java.util.TreeMap;
 import org.junit.Test;
@@ -42,7 +43,7 @@
     @Test
     @SuppressWarnings("unchecked")
     public void testEncodeFilter() throws Exception {
-        Serializer ser = new Serializer();
+        final Serializer ser = new Serializer();
 
         /*
          * Ensure raw maps serialize as expected. Use a TreeMap so the field
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTest.java
index e6269a9..c277a00 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTest.java
@@ -23,6 +23,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
+
 import java.util.Map;
 import java.util.Properties;
 import java.util.TreeMap;
@@ -44,6 +45,10 @@
     private Properties props;
     private ClassExtractors map;
 
+    /**
+     * Setup.
+     * 
+     */
     @Before
     public void setUp() {
         props = new Properties();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTestSupport.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTestSupport.java
index 98b679d..df42fe0 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTestSupport.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTestSupport.java
@@ -28,7 +28,7 @@
     private ClassExtractorsTestSupport2 nested = new ClassExtractorsTestSupport2();
 
     /**
-     * 
+     * Constructor.
      */
     public ClassExtractorsTestSupport() {
         super();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ExtractorExceptionTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ExtractorExceptionTest.java
index d1458de..aef0a92 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ExtractorExceptionTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ExtractorExceptionTest.java
@@ -21,6 +21,7 @@
 package org.onap.policy.drools.pooling.extractor;
 
 import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 import org.onap.policy.common.utils.test.ExceptionsTester;
 
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/FieldExtractorTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/FieldExtractorTest.java
index 9794bff..7536d00 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/FieldExtractorTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/FieldExtractorTest.java
@@ -22,6 +22,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+
 import java.lang.reflect.Field;
 import org.junit.Before;
 import org.junit.Test;
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java
index 48985bf..afaa2b6 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java
@@ -20,7 +20,9 @@
 
 package org.onap.policy.drools.pooling.extractor;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
 import java.util.HashMap;
 import java.util.Map;
 import org.junit.Before;
@@ -48,7 +50,7 @@
     public void testExtract_MissingValue() {
 
         Map<String,Object> map = new HashMap<>();
-        map.put(KEY+"x", VALUE+"x");
+        map.put(KEY + "x", VALUE + "x");
         
         // object is a map, but doesn't have the key
         assertNull(ext.extract(map));
@@ -58,7 +60,7 @@
     public void testExtract() {
 
         Map<String,Object> map = new HashMap<>();
-        map.put(KEY+"x", VALUE+"x");
+        map.put(KEY + "x", VALUE + "x");
         map.put(KEY, VALUE);
         
         // object is a map and contains the key
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MethodExtractorTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MethodExtractorTest.java
index ae5858e..41f731f 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MethodExtractorTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MethodExtractorTest.java
@@ -22,6 +22,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+
 import java.lang.reflect.Method;
 import org.junit.Before;
 import org.junit.Test;
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BasicMessageTester.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BasicMessageTester.java
index 69d7e67..2dab38d 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BasicMessageTester.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BasicMessageTester.java
@@ -23,9 +23,10 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
 import org.junit.Test;
 import org.onap.policy.drools.pooling.PoolingFeatureException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 /**
  * Superclass used to test subclasses of {@link Message}.
@@ -49,6 +50,7 @@
     private final Class<T> subclazz;
 
     /**
+     * Constructor.
      * 
      * @param subclazz subclass of {@link Message} being tested
      */
@@ -60,7 +62,6 @@
      * Creates a default Message and verifies that the source and channel are
      * {@code null}.
      * 
-     * @return the default Message
      */
     @Test
     public final void testDefaultConstructor() {
@@ -71,8 +72,6 @@
      * Tests that the Message has the correct source, and that the channel is
      * {@code null}.
      * 
-     * @param msg message to be checked
-     * @param expectedSource what the source is expected to be
      */
     @Test
     public final void testConstructorWithArgs() {
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java
index c14e8db..5788141 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java
@@ -26,6 +26,7 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 import java.util.Arrays;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -41,7 +42,7 @@
 
     @Test
     public void testBucketAssignmentsStringArray() {
-        String arr[] = {"abc", "def"};
+        String[] arr = {"abc", "def"};
         BucketAssignments asgn = new BucketAssignments(arr);
 
         assertNotNull(asgn.getHostArray());
@@ -51,13 +52,13 @@
     @Test
     public void testGetHostArray_testSetHostArray() {
 
-        String arr[] = {"abc", "def"};
+        String[] arr = {"abc", "def"};
         BucketAssignments asgn = new BucketAssignments(arr);
 
         assertNotNull(asgn.getHostArray());
         assertEquals(arr.toString(), asgn.getHostArray().toString());
 
-        String arr2[] = {"xyz"};
+        String[] arr2 = {"xyz"};
         asgn.setHostArray(arr2);
 
         assertNotNull(asgn.getHostArray());
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/ForwardTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/ForwardTest.java
index 2549fa9..c51cafe 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/ForwardTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/ForwardTest.java
@@ -24,6 +24,7 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+
 import org.junit.Test;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java
index 432dcc3..4e683ff 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java
@@ -22,6 +22,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+
 import org.junit.Test;
 
 public class MessageTest extends BasicMessageTester<Message> {
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageWithAssignmentsTester.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageWithAssignmentsTester.java
index 2b670dc..e5dfae9 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageWithAssignmentsTester.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageWithAssignmentsTester.java
@@ -22,6 +22,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+
 import org.junit.Test;
 
 /**
@@ -31,7 +32,7 @@
  */
 public abstract class MessageWithAssignmentsTester<T extends MessageWithAssignments> extends BasicMessageTester<T> {
     // values set by makeValidMessage()
-    public static final String[] VALID_ARRAY = {VALID_HOST, VALID_HOST+"_xxx"};
+    public static final String[] VALID_ARRAY = {VALID_HOST, VALID_HOST + "_xxx"};
     public static final BucketAssignments VALID_ASGN = new BucketAssignments(VALID_ARRAY);
 
     /**
@@ -41,6 +42,7 @@
     private boolean nullAssignments;
 
     /**
+     * Constructor.
      * 
      * @param subclazz subclass of {@link MessageWithAssignments} being tested
      */
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java
index f270103..9cb835c 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java
@@ -33,6 +33,7 @@
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.Arrays;
 import java.util.Map;
 import org.junit.Before;
@@ -50,6 +51,9 @@
 
     private ActiveState state;
 
+    /**
+     * Setup.
+     */
     @Before
     public void setUp() throws Exception {
         super.setUp();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/BasicStateTester.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/BasicStateTester.java
index 75ca756..20f49a0 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/BasicStateTester.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/BasicStateTester.java
@@ -27,6 +27,7 @@
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
@@ -113,6 +114,11 @@
         super();
     }
 
+    /**
+     * Setup.
+     * 
+     * @throws Exception throws exception
+     */
     public void setUp() throws Exception {
         onceSchedules = new LinkedList<>();
         onceTasks = new LinkedList<>();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/FilterUtilsTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/FilterUtilsTest.java
index ba51719..f4eb870 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/FilterUtilsTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/FilterUtilsTest.java
@@ -31,6 +31,7 @@
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeAnd;
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeEquals;
 import static org.onap.policy.drools.pooling.state.FilterUtils.makeOr;
+
 import java.util.Map;
 import org.junit.Test;
 
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
index 497dbbb..cf2c9c7 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
@@ -26,6 +26,7 @@
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
@@ -42,6 +43,9 @@
 
     private IdleState state;
 
+    /**
+     * Setup.
+     */
     @Before
     public void setUp() throws Exception {
         super.setUp();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java
index ae53ce0..ee7fd5e 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java
@@ -27,6 +27,7 @@
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
@@ -41,6 +42,10 @@
 
     private InactiveState state;
 
+    /**
+     * Setup.
+     * 
+     */
     @Before
     public void setUp() throws Exception {
         super.setUp();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
index 7ac5843..4f63451 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
@@ -29,6 +29,7 @@
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.Arrays;
 import java.util.Map;
 import org.junit.Before;
@@ -45,6 +46,9 @@
     private ProcessingState state;
     private HostBucket hostBucket;
 
+    /**
+     * Setup.
+     */
     @Before
     public void setUp() throws Exception {
         super.setUp();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java
index 7cd3758..5601932 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java
@@ -30,6 +30,7 @@
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
@@ -44,6 +45,9 @@
 
     private QueryState state;
 
+    /**
+     * Setup.
+     */
     @Before
     public void setUp() throws Exception {
         super.setUp();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
index 18f12ff..faafb8c 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
@@ -29,6 +29,7 @@
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
@@ -46,6 +47,9 @@
 
     private StartState state;
 
+    /**
+     * Setup.
+     */
     @Before
     public void setUp() throws Exception {
         super.setUp();
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
index e3d383d..42bb35f 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
@@ -29,6 +29,7 @@
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
@@ -47,6 +48,9 @@
 
     private State state;
 
+    /**
+     * Setup.
+     */
     @Before
     public void setUp() throws Exception {
         super.setUp();
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java
index c3f0035..4700e8a 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java
@@ -21,17 +21,17 @@
 package org.onap.policy.drools.persistence;
 
 public class DroolsPersistenceProperties {
-	/*
-	 * feature-session-persistence.properties parameter key values
-	 */
-	public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
-	public static final String DB_URL = "javax.persistence.jdbc.url";
-	public static final String DB_USER = "javax.persistence.jdbc.user";
-	public static final String DB_PWD = "javax.persistence.jdbc.password";
-	public static final String DB_SESSIONINFO_TIMEOUT = "persistence.sessioninfo.timeout";
-	public static final String JTA_OBJECTSTORE_DIR = "persistence.objectstore.dir";
+    /*
+     * feature-session-persistence.properties parameter key values
+     */
+    public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
+    public static final String DB_URL = "javax.persistence.jdbc.url";
+    public static final String DB_USER = "javax.persistence.jdbc.user";
+    public static final String DB_PWD = "javax.persistence.jdbc.password";
+    public static final String DB_SESSIONINFO_TIMEOUT = "persistence.sessioninfo.timeout";
+    public static final String JTA_OBJECTSTORE_DIR = "persistence.objectstore.dir";
 
-	private DroolsPersistenceProperties() {
-		super();
-	}
+    private DroolsPersistenceProperties() {
+        super();
+    }
 }
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSession.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSession.java
index a012f3c..e8b5081 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSession.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSession.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -24,12 +24,19 @@
 
 public interface DroolsSession {
 
-	public String getSessionName();
-	public void setSessionName(String sessionName);
-	public long getSessionId();
-	public void setSessionId(long sessionId);
-	public Date getCreatedDate();
-	public void setCreatedDate(Date createdDate);
-	public Date getUpdatedDate();
-	public void setUpdatedDate(Date updatedDate);
+    public String getSessionName();
+    
+    public void setSessionName(String sessionName);
+    
+    public long getSessionId();
+    
+    public void setSessionId(long sessionId);
+    
+    public Date getCreatedDate();
+    
+    public void setCreatedDate(Date createdDate);
+    
+    public Date getUpdatedDate();
+    
+    public void setUpdatedDate(Date updatedDate);
 }
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionConnector.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionConnector.java
index e2f4ac5..3a8885f 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionConnector.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionConnector.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,19 +20,18 @@
 
 package org.onap.policy.drools.persistence;
 
-public interface DroolsSessionConnector
-{
-	/**
-	 * Gets a session by PDP id and name.
-	 * @param sessName
-	 * @return a session, or {@code null} if it is not found
-	 */
-	public DroolsSession get(String sessName);
-	
-	/**
-	 * Replaces a session, adding it if it does not exist.
-	 * @param sess		session to be replaced
-	 */
-	public void replace(DroolsSession sess);
+public interface DroolsSessionConnector {
+    /**
+     * Gets a session by PDP id and name.
+     * @param sessName session name
+     * @return a session, or {@code null} if it is not found
+     */
+    public DroolsSession get(String sessName);
+
+    /**
+     * Replaces a session, adding it if it does not exist.
+     * @param sess session to be replaced
+     */
+    public void replace(DroolsSession sess);
 
 }
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java
index b3616c4..117e641 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -34,105 +34,101 @@
 @Entity
 public class DroolsSessionEntity implements Serializable, DroolsSession {
 
-	private static final long serialVersionUID = -5495057038819948709L;
+    private static final long serialVersionUID = -5495057038819948709L;
 
-	@Id
-	@Column(name = "sessionName", nullable = false)
-	private String sessionName = "-1";
+    @Id
+    @Column(name = "sessionName", nullable = false)
+    private String sessionName = "-1";
 
-	@Column(name = "sessionId", nullable = false)
-	private long sessionId = -1L;
+    @Column(name = "sessionId", nullable = false)
+    private long sessionId = -1L;
 
-	@Temporal(TemporalType.TIMESTAMP)
-	@Column(name = "createdDate", nullable = false)
-	private Date createdDate;
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "createdDate", nullable = false)
+    private Date createdDate;
 
-	@Temporal(TemporalType.TIMESTAMP)
-	@Column(name = "updatedDate", nullable = false)
-	private Date updatedDate;
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "updatedDate", nullable = false)
+    private Date updatedDate;
 
-	public DroolsSessionEntity() {
+    public DroolsSessionEntity() {}
 
-	}
+    public DroolsSessionEntity(String sessionName, long sessionId) {
+        this.sessionName = sessionName;
+        this.sessionId = sessionId;
+    }
 
-	public DroolsSessionEntity(String sessionName, long sessionId) {
-		this.sessionName = sessionName;
-		this.sessionId = sessionId;
+    @PrePersist
+    public void prePersist() {
+        this.createdDate = new Date();
+        this.updatedDate = new Date();
+    }
 
-	}
+    @PreUpdate
+    public void preUpdate() {
+        this.updatedDate = new Date();
+    }
 
-	@PrePersist
-	public void prePersist() {
-		this.createdDate = new Date();
-		this.updatedDate = new Date();
-	}
+    @Override
+    public String getSessionName() {
+        return sessionName;
+    }
 
-	@PreUpdate
-	public void preUpdate() {
-		this.updatedDate = new Date();
-	}
+    @Override
+    public void setSessionName(String sessionName) {
+        this.sessionName = sessionName;
+    }
 
-	@Override
-	public String getSessionName() {
-		return sessionName;
-	}
+    @Override
+    public long getSessionId() {
+        return sessionId;
+    }
 
-	@Override
-	public void setSessionName(String sessionName) {
-		this.sessionName = sessionName;
-	}
+    @Override
+    public void setSessionId(long sessionId) {
+        this.sessionId = sessionId;
+    }
 
-	@Override
-	public long getSessionId() {
-		return sessionId;
-	}
+    @Override
+    public Date getCreatedDate() {
+        return createdDate;
+    }
 
-	@Override
-	public void setSessionId(long sessionId) {
-		this.sessionId = sessionId;
-	}
+    @Override
+    public void setCreatedDate(Date createdDate) {
+        this.createdDate = createdDate;
+    }
 
-	@Override
-	public Date getCreatedDate() {
-		return createdDate;
-	}
+    @Override
+    public Date getUpdatedDate() {
+        return updatedDate;
+    }
 
-	@Override
-	public void setCreatedDate(Date createdDate) {
-		this.createdDate = createdDate;
-	}
+    @Override
+    public void setUpdatedDate(Date updatedDate) {
+        this.updatedDate = updatedDate;
+    }
 
-	@Override
-	public Date getUpdatedDate() {
-		return updatedDate;
-	}
+    @Override
+    public boolean equals(Object other) {
+        if (other instanceof DroolsSession) {
+            DroolsSession session = (DroolsSession) other;
+            return this.getSessionName().equals(session.getSessionName());
+        } else {
+            return false;
+        }
+    }
 
-	@Override
-	public void setUpdatedDate(Date updatedDate) {
-		this.updatedDate = updatedDate;
-	}
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + getSessionName().hashCode();
+        return result;
+    }
 
-	@Override
-	public boolean equals(Object other) {
-		if (other instanceof DroolsSession) {
-			DroolsSession p = (DroolsSession) other;
-			return this.getSessionName().equals(p.getSessionName());
-		} else {
-			return false;
-		}
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result + getSessionName().hashCode();
-		return result;
-	}
-
-	@Override
-	public String toString() {
-		return "{name=" + getSessionName() + ", id=" + getSessionId() + "}";
-	}
-
+    @Override
+    public String toString() {
+        return "{name=" + getSessionName() + ", id=" + getSessionId() + "}";
+    }
 }
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java
index 47ed221..3d27651 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java
@@ -7,9 +7,9 @@
  * 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.
@@ -32,109 +32,99 @@
 import org.onap.policy.common.utils.jpa.EntityMgrCloser;
 
 /**
- * Wrapper for an <i>EntityManager</i> that creates a JTA transaction that is
- * auto-rolled back when closed.
+ * Wrapper for an <i>EntityManager</i> that creates a JTA transaction that is auto-rolled back when
+ * closed.
  */
 public class EntityMgrTrans extends EntityMgrCloser {
 
-	/**
-	 * Transaction to be rolled back.
-	 */
-	private static UserTransaction userTrans = com.arjuna.ats.jta.UserTransaction.userTransaction();
+    /** Transaction to be rolled back. */
+    private static UserTransaction userTrans = com.arjuna.ats.jta.UserTransaction.userTransaction();
 
-	/**
-	 * 
-	 * @param em
-	 *            entity for which a transaction is to be begun
-	 */
-	public EntityMgrTrans(EntityManager em) {
-		super(em);
+    /**
+     * Constructor.
+     * 
+     *  @param em entity for which a transaction is to be begun */
+    public EntityMgrTrans(EntityManager em) {
+        super(em);
 
-		try {
-			userTrans.begin();
-			em.joinTransaction();
+        try {
+            userTrans.begin();
+            em.joinTransaction();
 
-		} catch (RuntimeException |NotSupportedException | SystemException e) {
-			em.close();
-			throw new EntityMgrException(e);
-		}
-	}
+        } catch (RuntimeException | NotSupportedException | SystemException e) {
+            em.close();
+            throw new EntityMgrException(e);
+        }
+    }
 
-	/**
-	 * Gets the user transaction. For use by junit tests.
-	 * 
-	 * @return the user transaction
-	 */
-	protected static UserTransaction getUserTrans() {
-		return userTrans;
-	}
+    /**
+     * Gets the user transaction. For use by junit tests.
+     *
+     * @return the user transaction
+     */
+    protected static UserTransaction getUserTrans() {
+        return userTrans;
+    }
 
-	/**
-	 * Sets the user transaction. For use by junit tests.
-	 * 
-	 * @param userTrans
-	 *            the new user transaction
-	 */
-	protected static void setUserTrans(UserTransaction userTrans) {
-		EntityMgrTrans.userTrans = userTrans;
-	}
+    /**
+     * Sets the user transaction. For use by junit tests.
+     *
+     * @param userTrans the new user transaction
+     */
+    protected static void setUserTrans(UserTransaction userTrans) {
+        EntityMgrTrans.userTrans = userTrans;
+    }
 
-	/**
-	 * Commits the transaction.
-	 */
-	public void commit() {
-		try {
-			userTrans.commit();
+    /** Commits the transaction. */
+    public void commit() {
+        try {
+            userTrans.commit();
 
-		} catch (SecurityException | IllegalStateException | RollbackException | HeuristicMixedException
-				| HeuristicRollbackException | SystemException e) {
+        } catch (SecurityException
+                | IllegalStateException
+                | RollbackException
+                | HeuristicMixedException
+                | HeuristicRollbackException
+                | SystemException e) {
 
-			throw new EntityMgrException(e);
-		}
-	}
+            throw new EntityMgrException(e);
+        }
+    }
 
-	/**
-	 * Rolls back the transaction.
-	 */
-	public void rollback() {
-		try {
-			userTrans.rollback();
+    /** Rolls back the transaction. */
+    public void rollback() {
+        try {
+            userTrans.rollback();
 
-		} catch (IllegalStateException | SecurityException | SystemException e) {
-			throw new EntityMgrException(e);
-		}
-	}
+        } catch (IllegalStateException | SecurityException | SystemException e) {
+            throw new EntityMgrException(e);
+        }
+    }
 
-	@Override
-	public void close() {
-		try {
-			if (userTrans.getStatus() == Status.STATUS_ACTIVE) {
-				userTrans.rollback();
-			}
+    @Override
+    public void close() {
+        try {
+            if (userTrans.getStatus() == Status.STATUS_ACTIVE) {
+                userTrans.rollback();
+            }
 
-		} catch (IllegalStateException | SecurityException | SystemException e) {
-			throw new EntityMgrException(e);
+        } catch (IllegalStateException | SecurityException | SystemException e) {
+            throw new EntityMgrException(e);
 
-		} finally {
-			super.close();
-		}
-	}
+        } finally {
+            super.close();
+        }
+    }
 
-	/**
-	 * Runtime exceptions generated by this class. Wraps exceptions generated by
-	 * delegated operations, particularly when they are not, themselves, Runtime
-	 * exceptions.
-	 */
-	public static class EntityMgrException extends RuntimeException {
-		private static final long serialVersionUID = 1L;
+    /**
+     * Runtime exceptions generated by this class. Wraps exceptions generated by delegated operations,
+     * particularly when they are not, themselves, Runtime exceptions.
+     */
+    public static class EntityMgrException extends RuntimeException {
+        private static final long serialVersionUID = 1L;
 
-		/**
-		 * 
-		 * @param e
-		 *            exception to be wrapped
-		 */
-		public EntityMgrException(Exception e) {
-			super(e);
-		}
-	}
+        public EntityMgrException(Exception ex) {
+            super(ex);
+        }
+    }
 }
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
index cd76ae8..381a896 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -28,89 +28,84 @@
 
 public class JpaDroolsSessionConnector implements DroolsSessionConnector {
 
-	private static Logger logger = LoggerFactory.getLogger(JpaDroolsSessionConnector.class);
+    private static Logger logger = LoggerFactory.getLogger(JpaDroolsSessionConnector.class);
 
-	private final EntityManagerFactory emf;
+    private final EntityManagerFactory emf;
 
-	public JpaDroolsSessionConnector(EntityManagerFactory emf) {
-		this.emf = emf;
-	}
+    public JpaDroolsSessionConnector(EntityManagerFactory emf) {
+        this.emf = emf;
+    }
 
-	@Override
-	public DroolsSession get(String sessName) {
+    @Override
+    public DroolsSession get(String sessName) {
 
-		EntityManager em = emf.createEntityManager();
-		DroolsSessionEntity s = null;
+        EntityManager em = emf.createEntityManager();
+        DroolsSessionEntity entity = null;
 
-		try (EntityMgrTrans trans = new EntityMgrTrans(em)) {
+        try (EntityMgrTrans trans = new EntityMgrTrans(em)) {
 
-			s = em.find(DroolsSessionEntity.class, sessName);
-			if (s != null) {
-				em.refresh(s);
-			}
+            entity = em.find(DroolsSessionEntity.class, sessName);
+            if (entity != null) {
+                em.refresh(entity);
+            }
 
-			trans.commit();
-		}
+            trans.commit();
+        }
 
-		return s;
-	}
+        return entity;
+    }
 
-	@Override
-	public void replace(DroolsSession sess) {
-		String sessName = sess.getSessionName();
+    @Override
+    public void replace(DroolsSession sess) {
+        String sessName = sess.getSessionName();
 
-		logger.info("replace: Entering and manually updating session name= {}", sessName);
+        logger.info("replace: Entering and manually updating session name= {}", sessName);
 
-		EntityManager em = emf.createEntityManager();
+        EntityManager em = emf.createEntityManager();
 
-		try (EntityMgrTrans trans = new EntityMgrTrans(em)) {
+        try (EntityMgrTrans trans = new EntityMgrTrans(em)) {
 
-			if (!update(em, sess)) {
-				add(em, sess);
-			}
+            if (!update(em, sess)) {
+                add(em, sess);
+            }
 
-			trans.commit();
-		}
+            trans.commit();
+        }
 
-		logger.info("replace: Exiting");
-	}
+        logger.info("replace: Exiting");
+    }
 
-	/**
-	 * Adds a session to the persistent store.
-	 * 
-	 * @param em
-	 *            entity manager
-	 * @param sess
-	 *            session to be added
-	 */
-	private void add(EntityManager em, DroolsSession sess) {
-		logger.info("add: Inserting session id={}", sess.getSessionId());
+    /**
+     * Adds a session to the persistent store.
+     *
+     * @param em entity manager
+     * @param sess session to be added
+     */
+    private void add(EntityManager em, DroolsSession sess) {
+        logger.info("add: Inserting session id={}", sess.getSessionId());
 
-		DroolsSessionEntity ent = new DroolsSessionEntity(sess.getSessionName(), sess.getSessionId());
+        DroolsSessionEntity ent = new DroolsSessionEntity(sess.getSessionName(), sess.getSessionId());
 
-		em.persist(ent);
-	}
+        em.persist(ent);
+    }
 
-	/**
-	 * Updates a session, if it exists within the persistent store.
-	 * 
-	 * @param em
-	 *            entity manager
-	 * @param sess
-	 *            session data to be persisted
-	 * @return {@code true} if a record was updated, {@code false} if it was not
-	 *         found
-	 */
-	private boolean update(EntityManager em, DroolsSession sess) {
+    /**
+     * Updates a session, if it exists within the persistent store.
+     *
+     * @param em entity manager
+     * @param sess session data to be persisted
+     * @return {@code true} if a record was updated, {@code false} if it was not found
+     */
+    private boolean update(EntityManager em, DroolsSession sess) {
 
-		DroolsSessionEntity s = em.find(DroolsSessionEntity.class, sess.getSessionName());
-		if (s == null) {
-			return false;
-		}
+        DroolsSessionEntity s = em.find(DroolsSessionEntity.class, sess.getSessionName());
+        if (s == null) {
+            return false;
+        }
 
-		logger.info("update: Updating session id to {}", sess.getSessionId());
-		s.setSessionId(sess.getSessionId());
+        logger.info("update: Updating session id to {}", sess.getSessionId());
+        s.setSessionId(sess.getSessionId());
 
-		return true;
-	}
+        return true;
+    }
 }
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
index 129be8a..7b17de6 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
@@ -7,9 +7,9 @@
  * 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.
@@ -54,971 +54,898 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * If this feature is supported, there is a single instance of it. It adds
- * persistence to Drools sessions. In addition, if an active-standby feature
- * exists, then that is used to determine the active and last-active PDP. If it
- * does not exist, then the current host name is used as the PDP id.
+ * If this feature is supported, there is a single instance of it. It adds persistence to Drools
+ * sessions. In addition, if an active-standby feature exists, then that is used to determine the
+ * active and last-active PDP. If it does not exist, then the current host name is used as the PDP
+ * id.
  *
- * The bulk of the code here was once in other classes, such as
- * 'PolicyContainer' and 'Main'. It was moved here as part of making this a
- * separate optional feature.
+ * <p>The bulk of the code here was once in other classes, such as 'PolicyContainer' and 'Main'. It
+ * was moved here as part of making this a separate optional feature.
  */
 public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngineFeatureAPI {
 
-	private static final Logger logger = LoggerFactory.getLogger(PersistenceFeature.class);
+    private static final Logger logger = LoggerFactory.getLogger(PersistenceFeature.class);
 
-	/**
-	 * Standard factory used to get various items.
-	 */
-	private static Factory stdFactory = new Factory();
+    /** Standard factory used to get various items. */
+    private static Factory stdFactory = new Factory();
 
-	/**
-	 * Factory used to get various items.
-	 */
-	private Factory fact = stdFactory;
+    /** Factory used to get various items. */
+    private Factory fact = stdFactory;
 
-	/**
-	 * KieService factory.
-	 */
-	private KieServices kieSvcFact;
+    /** KieService factory. */
+    private KieServices kieSvcFact;
 
-	/**
-	 * Persistence properties.
-	 */
-	private Properties persistProps;
+    /** Persistence properties. */
+    private Properties persistProps;
 
-	/**
-	 * Whether or not the SessionInfo records should be cleaned out.
-	 */
-	private boolean sessInfoCleaned;
+    /** Whether or not the SessionInfo records should be cleaned out. */
+    private boolean sessInfoCleaned;
 
-	/**
-	 * SessionInfo timeout, in milli-seconds, as read from
-	 * {@link #persistProps}.
-	 */
-	private long sessionInfoTimeoutMs;
+    /** SessionInfo timeout, in milli-seconds, as read from 
+     * {@link #persistProps}. */
+    private long sessionInfoTimeoutMs;
 
-	/**
-	 * Object used to serialize cleanup of sessioninfo table.
-	 */
-	private Object cleanupLock = new Object();
+    /** Object used to serialize cleanup of sessioninfo table. */
+    private Object cleanupLock = new Object();
 
-	/**
-	 * Sets the factory to be used during junit testing.
-	 * 
-	 * @param fact
-	 *            factory to be used
-	 */
-	protected void setFactory(Factory fact) {
-		this.fact = fact;
-	}
+    /**
+     * Sets the factory to be used during junit testing.
+     *
+     * @param fact factory to be used
+     */
+    protected void setFactory(Factory fact) {
+        this.fact = fact;
+    }
 
-	/**
-	 * Lookup the adjunct for this feature that is associated with the specified
-	 * PolicyContainer. If not found, create one.
-	 * 
-	 * @param policyContainer
-	 *            the container whose adjunct we are looking up, and possibly
-	 *            creating
-	 * @return the associated 'ContainerAdjunct' instance, which may be new
-	 */
-	private ContainerAdjunct getContainerAdjunct(PolicyContainer policyContainer) {
+    /**
+     * Lookup the adjunct for this feature that is associated with the specified PolicyContainer. If
+     * not found, create one.
+     *
+     * @param policyContainer the container whose adjunct we are looking up, and possibly creating
+     * @return the associated 'ContainerAdjunct' instance, which may be new
+     */
+    private ContainerAdjunct getContainerAdjunct(PolicyContainer policyContainer) {
 
-		Object rval = policyContainer.getAdjunct(this);
+        Object rval = policyContainer.getAdjunct(this);
 
-		if (rval == null || !(rval instanceof ContainerAdjunct)) {
-			// adjunct does not exist, or has the wrong type (should never
-			// happen)
-			rval = new ContainerAdjunct(policyContainer);
-			policyContainer.setAdjunct(this, rval);
-		}
+        if (rval == null || !(rval instanceof ContainerAdjunct)) {
+            // adjunct does not exist, or has the wrong type (should never
+            // happen)
+            rval = new ContainerAdjunct(policyContainer);
+            policyContainer.setAdjunct(this, rval);
+        }
 
-		return (ContainerAdjunct) rval;
-	}
+        return (ContainerAdjunct) rval;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public int getSequenceNumber() {
-		return 1;
-	}
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public int getSequenceNumber() {
+        return 1;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void globalInit(String[] args, String configDir) {
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public void globalInit(String[] args, String configDir) {
 
-		kieSvcFact = fact.getKieServices();
+        kieSvcFact = fact.getKieServices();
 
-		try {
-			persistProps = fact.loadProperties(configDir + "/feature-session-persistence.properties");
+        try {
+            persistProps = fact.loadProperties(configDir + "/feature-session-persistence.properties");
 
-		} catch (IOException e1) {
-			logger.error("initializePersistence: ", e1);
-		}
+        } catch (IOException e1) {
+            logger.error("initializePersistence: ", e1);
+        }
 
-		sessionInfoTimeoutMs = getPersistenceTimeout();
-	}
+        sessionInfoTimeoutMs = getPersistenceTimeout();
+    }
 
-	/**
-	 * Creates a persistent KieSession, loading it from the persistent store, or
-	 * creating one, if it does not exist yet.
-	 */
-	@Override
-	public KieSession activatePolicySession(PolicyContainer policyContainer, String name, String kieBaseName) {
+    /**
+     * Creates a persistent KieSession, loading it from the persistent store, or creating one, if it
+     * does not exist yet.
+     */
+    @Override
+    public KieSession activatePolicySession(
+            PolicyContainer policyContainer, String name, String kieBaseName) {
 
-		if (isPersistenceEnabled(policyContainer, name)) {
-			cleanUpSessionInfo();
+        if (isPersistenceEnabled(policyContainer, name)) {
+            cleanUpSessionInfo();
 
-			return getContainerAdjunct(policyContainer).newPersistentKieSession(name, kieBaseName);
-		}
+            return getContainerAdjunct(policyContainer).newPersistentKieSession(name, kieBaseName);
+        }
 
-		return null;
-	}
+        return null;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public PolicySession.ThreadModel selectThreadModel(PolicySession session) {
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public PolicySession.ThreadModel selectThreadModel(PolicySession session) {
 
-		PolicyContainer policyContainer = session.getPolicyContainer();
-		if (isPersistenceEnabled(policyContainer, session.getName())) {
-			return new PersistentThreadModel(session, getProperties(policyContainer));
-		}
-		return null;
-	}
+        PolicyContainer policyContainer = session.getPolicyContainer();
+        if (isPersistenceEnabled(policyContainer, session.getName())) {
+            return new PersistentThreadModel(session, getProperties(policyContainer));
+        }
+        return null;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void disposeKieSession(PolicySession policySession) {
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public void disposeKieSession(PolicySession policySession) {
 
-		ContainerAdjunct contAdj = (ContainerAdjunct) policySession.getPolicyContainer().getAdjunct(this);
-		if (contAdj != null) {
-			contAdj.disposeKieSession(policySession.getName());
-		}
-	}
+        ContainerAdjunct contAdj =
+                (ContainerAdjunct) policySession.getPolicyContainer().getAdjunct(this);
+        if (contAdj != null) {
+            contAdj.disposeKieSession(policySession.getName());
+        }
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void destroyKieSession(PolicySession policySession) {
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public void destroyKieSession(PolicySession policySession) {
 
-		ContainerAdjunct contAdj = (ContainerAdjunct) policySession.getPolicyContainer().getAdjunct(this);
-		if (contAdj != null) {
-			contAdj.destroyKieSession(policySession.getName());
-		}
-	}
+        ContainerAdjunct contAdj =
+                (ContainerAdjunct) policySession.getPolicyContainer().getAdjunct(this);
+        if (contAdj != null) {
+            contAdj.destroyKieSession(policySession.getName());
+        }
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public boolean afterStart(PolicyEngine engine) {
-		return false;
-	}
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public boolean afterStart(PolicyEngine engine) {
+        return false;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public boolean beforeStart(PolicyEngine engine) {
-		synchronized (cleanupLock) {
-			sessInfoCleaned = false;
-		}
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public boolean beforeStart(PolicyEngine engine) {
+        synchronized (cleanupLock) {
+            sessInfoCleaned = false;
+        }
 
-		return false;
-	}
+        return false;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public boolean beforeActivate(PolicyEngine engine) {
-		synchronized (cleanupLock) {
-			sessInfoCleaned = false;
-		}
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public boolean beforeActivate(PolicyEngine engine) {
+        synchronized (cleanupLock) {
+            sessInfoCleaned = false;
+        }
 
-		return false;
-	}
+        return false;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public boolean afterActivate(PolicyEngine engine) {
-		return false;
-	}
+    /** 
+     * {@inheritDoc} */
+    @Override
+    public boolean afterActivate(PolicyEngine engine) {
+        return false;
+    }
 
-	/* ============================================================ */
+    /* ============================================================ */
 
-	/**
-	 * Gets the persistence timeout value for sessioninfo records.
-	 * 
-	 * @return the timeout value, in milli-seconds, or {@code -1} if it is
-	 *         unspecified or invalid
-	 */
-	private long getPersistenceTimeout() {
-		String timeoutString = null;
+    /**
+     * Gets the persistence timeout value for sessioninfo records.
+     *
+     * @return the timeout value, in milli-seconds, or {@code -1} if it is unspecified or invalid
+     */
+    private long getPersistenceTimeout() {
+        String timeoutString = null;
 
-		try {
-			timeoutString = persistProps.getProperty(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT);
+        try {
+            timeoutString = persistProps.getProperty(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT);
 
-			if (timeoutString != null) {
-				// timeout parameter is specified
-				return Long.valueOf(timeoutString) * 1000;
-			}
+            if (timeoutString != null) {
+                // timeout parameter is specified
+                return Long.valueOf(timeoutString) * 1000;
+            }
 
-		} catch (NumberFormatException e) {
-			logger.error("Invalid value for Drools persistence property persistence.sessioninfo.timeout: {}",
-					timeoutString, e);
-		}
+        } catch (NumberFormatException e) {
+            logger.error(
+                    "Invalid value for Drools persistence property persistence.sessioninfo.timeout: {}",
+                    timeoutString,
+                    e);
+        }
 
-		return -1;
-	}
+        return -1;
+    }
 
-	/* ============================================================ */
+    /* ============================================================ */
 
-	/**
-	 * Each instance of this class is a logical extension of a 'PolicyContainer'
-	 * instance. Its reference is stored in the 'adjuncts' table within the
-	 * 'PolicyContainer', and will be garbage-collected with the container.
-	 */
-	protected class ContainerAdjunct {
-		/**
-		 * 'PolicyContainer' instance that this adjunct is extending.
-		 */
-		private PolicyContainer policyContainer;
+    /**
+     * Each instance of this class is a logical extension of a 'PolicyContainer' instance. Its
+     * reference is stored in the 'adjuncts' table within the 'PolicyContainer', and will be
+     * garbage-collected with the container.
+     */
+    protected class ContainerAdjunct {
+        /** 'PolicyContainer' instance that this adjunct is extending. */
+        private PolicyContainer policyContainer;
 
-		/**
-		 * Maps a KIE session name to its data source.
-		 */
-		private Map<String, DsEmf> name2ds = new HashMap<>();
+        /** Maps a KIE session name to its data source. */
+        private Map<String, DsEmf> name2ds = new HashMap<>();
 
-		/**
-		 * Constructor - initialize a new 'ContainerAdjunct'
-		 *
-		 * @param policyContainer
-		 *            the 'PolicyContainer' instance this adjunct is extending
-		 */
-		private ContainerAdjunct(PolicyContainer policyContainer) {
-			this.policyContainer = policyContainer;
-		}
+        /**
+         * Constructor - initialize a new 'ContainerAdjunct'.
+         *
+         * @param policyContainer the 'PolicyContainer' instance this adjunct is extending
+         */
+        private ContainerAdjunct(PolicyContainer policyContainer) {
+            this.policyContainer = policyContainer;
+        }
 
-		/**
-		 * Create a new persistent KieSession. If there is already a
-		 * corresponding entry in the database, it is used to initialize the
-		 * KieSession. If not, a completely new session is created.
-		 * 
-		 * @param name
-		 *            the name of the KieSession (which is also the name of the
-		 *            associated PolicySession)
-		 * @param kieBaseName
-		 *            the name of the 'KieBase' instance containing this session
-		 * @return a new KieSession with persistence enabled
-		 */
-		private KieSession newPersistentKieSession(String name, String kieBaseName) {
+        /**
+         * Create a new persistent KieSession. If there is already a corresponding entry in the
+         * database, it is used to initialize the KieSession. If not, a completely new session is
+         * created.
+         *
+         * @param name the name of the KieSession (which is also the name of the associated
+         *     PolicySession)
+         * @param kieBaseName the name of the 'KieBase' instance containing this session
+         * @return a new KieSession with persistence enabled
+         */
+        private KieSession newPersistentKieSession(String name, String kieBaseName) {
 
-			configureSysProps();
+            configureSysProps();
 
-			BasicDataSource ds = fact.makeDataSource(getDataSourceProperties());
-			DsEmf dsemf = new DsEmf(ds);
+            BasicDataSource ds = fact.makeDataSource(getDataSourceProperties());
+            DsEmf dsemf = new DsEmf(ds);
 
-			try {
-				EntityManagerFactory emf = dsemf.emf;
-				DroolsSessionConnector conn = fact.makeJpaConnector(emf);
+            try {
+                EntityManagerFactory emf = dsemf.emf;
+                DroolsSessionConnector conn = fact.makeJpaConnector(emf);
 
-				long desiredSessionId = getSessionId(conn, name);
+                long desiredSessionId = getSessionId(conn, name);
 
-				logger.info("\n\nThis controller is primary... coming up with session {} \n\n", desiredSessionId);
+                logger.info(
+                        "\n\nThis controller is primary... coming up with session {} \n\n", desiredSessionId);
 
-				// session does not exist -- attempt to create one
-				logger.info("getPolicySession:session does not exist -- attempt to create one with name {}", name);
+                // session does not exist -- attempt to create one
+                logger.info(
+                        "getPolicySession:session does not exist -- attempt to create one with name {}", name);
 
-				Environment env = kieSvcFact.newEnvironment();
+                Environment env = kieSvcFact.newEnvironment();
 
-				configureKieEnv(env, emf);
+                configureKieEnv(env, emf);
 
-				KieSessionConfiguration kConf = kieSvcFact.newKieSessionConfiguration();
+                KieSessionConfiguration kieConf = kieSvcFact.newKieSessionConfiguration();
 
-				KieSession kieSession = (desiredSessionId >= 0
-						? loadKieSession(kieBaseName, desiredSessionId, env, kConf) : null);
+                KieSession kieSession =
+                        (desiredSessionId >= 0
+                        ? loadKieSession(kieBaseName, desiredSessionId, env, kieConf)
+                                : null);
 
-				if (kieSession == null) {
-					// loadKieSession() returned null or desiredSessionId < 0
-					logger.info("LOADING We cannot load session {}. Going to create a new one", desiredSessionId);
+                if (kieSession == null) {
+                    // loadKieSession() returned null or desiredSessionId < 0
+                    logger.info(
+                            "LOADING We cannot load session {}. Going to create a new one", desiredSessionId);
 
-					kieSession = newKieSession(kieBaseName, env);
-				}
+                    kieSession = newKieSession(kieBaseName, env);
+                }
 
-				replaceSession(conn, name, kieSession);
+                replaceSession(conn, name, kieSession);
 
-				name2ds.put(name, dsemf);
+                name2ds.put(name, dsemf);
 
-				return kieSession;
+                return kieSession;
 
-			} catch (RuntimeException e) {
-				dsemf.close();
-				throw e;
-			}
-		}
+            } catch (RuntimeException e) {
+                dsemf.close();
+                throw e;
+            }
+        }
 
-		/**
-		 * Loads an existing KieSession from the persistent store.
-		 * 
-		 * @param kieBaseName
-		 *            the name of the 'KieBase' instance containing this session
-		 * @param desiredSessionId
-		 *            id of the desired KieSession
-		 * @param env
-		 *            Kie Environment for the session
-		 * @param kConf
-		 *            Kie Configuration for the session
-		 * @return the persistent session, or {@code null} if it could not be
-		 *         loaded
-		 */
-		private KieSession loadKieSession(String kieBaseName, long desiredSessionId, Environment env,
-				KieSessionConfiguration kConf) {
-			try {
-				KieSession kieSession = kieSvcFact.getStoreServices().loadKieSession(desiredSessionId,
-						policyContainer.getKieContainer().getKieBase(kieBaseName), kConf, env);
+        /**
+         * Loads an existing KieSession from the persistent store.
+         *
+         * @param kieBaseName the name of the 'KieBase' instance containing this session
+         * @param desiredSessionId id of the desired KieSession
+         * @param env Kie Environment for the session
+         * @param kConf Kie Configuration for the session
+         * @return the persistent session, or {@code null} if it could not be loaded
+         */
+        private KieSession loadKieSession(
+                String kieBaseName, long desiredSessionId, Environment env, KieSessionConfiguration kieConf) {
+            try {
+                KieSession kieSession =
+                        kieSvcFact
+                        .getStoreServices()
+                        .loadKieSession(
+                                desiredSessionId,
+                                policyContainer.getKieContainer().getKieBase(kieBaseName),
+                                kieConf,
+                                env);
 
-				logger.info("LOADING Loaded session {}", desiredSessionId);
+                logger.info("LOADING Loaded session {}", desiredSessionId);
 
-				return kieSession;
+                return kieSession;
 
-			} catch (Exception e) {
-				logger.error("loadKieSession error: ", e);
-				return null;
-			}
-		}
+            } catch (Exception e) {
+                logger.error("loadKieSession error: ", e);
+                return null;
+            }
+        }
 
-		/**
-		 * Creates a new, persistent KieSession.
-		 * 
-		 * @param kieBaseName
-		 *            the name of the 'KieBase' instance containing this session
-		 * @param env
-		 *            Kie Environment for the session
-		 * @return a new, persistent session
-		 */
-		private KieSession newKieSession(String kieBaseName, Environment env) {
-			KieSession kieSession = kieSvcFact.getStoreServices()
-					.newKieSession(policyContainer.getKieContainer().getKieBase(kieBaseName), null, env);
+        /**
+         * Creates a new, persistent KieSession.
+         *
+         * @param kieBaseName the name of the 'KieBase' instance containing this session
+         * @param env Kie Environment for the session
+         * @return a new, persistent session
+         */
+        private KieSession newKieSession(String kieBaseName, Environment env) {
+            KieSession kieSession =
+                    kieSvcFact
+                    .getStoreServices()
+                    .newKieSession(policyContainer.getKieContainer().getKieBase(kieBaseName), null, env);
 
-			logger.info("LOADING CREATED {}", kieSession.getIdentifier());
+            logger.info("LOADING CREATED {}", kieSession.getIdentifier());
 
-			return kieSession;
-		}
+            return kieSession;
+        }
 
-		/**
-		 * Closes the data source associated with a session.
-		 * 
-		 * @param name
-		 *            name of the session being destroyed
-		 */
-		private void destroyKieSession(String name) {
-			closeDataSource(name);
-		}
+        /**
+         * Closes the data source associated with a session.
+         *
+         * @param name name of the session being destroyed
+         */
+        private void destroyKieSession(String name) {
+            closeDataSource(name);
+        }
 
-		/**
-		 * Closes the data source associated with a session.
-		 * 
-		 * @param name
-		 *            name of the session being disposed of
-		 */
-		private void disposeKieSession(String name) {
-			closeDataSource(name);
-		}
+        /**
+         * Closes the data source associated with a session.
+         *
+         * @param name name of the session being disposed of
+         */
+        private void disposeKieSession(String name) {
+            closeDataSource(name);
+        }
 
-		/**
-		 * Closes the data source associated with a session.
-		 * 
-		 * @param name
-		 *            name of the session whose data source is to be closed
-		 */
-		private void closeDataSource(String name) {
-			DsEmf ds = name2ds.remove(name);
-			if (ds != null) {
-				ds.close();
-			}
-		}
+        /**
+         * Closes the data source associated with a session.
+         *
+         * @param name name of the session whose data source is to be closed
+         */
+        private void closeDataSource(String name) {
+            DsEmf ds = name2ds.remove(name);
+            if (ds != null) {
+                ds.close();
+            }
+        }
 
-		/**
-		 * Configures java system properties for JPA/JTA.
-		 */
-		private void configureSysProps() {
-			System.setProperty("com.arjuna.ats.arjuna.coordinator.defaultTimeout", "60");
-			System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir",
-					persistProps.getProperty(DroolsPersistenceProperties.JTA_OBJECTSTORE_DIR));
-			System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir",
-					persistProps.getProperty(DroolsPersistenceProperties.JTA_OBJECTSTORE_DIR));
-		}
+        /** Configures java system properties for JPA/JTA. */
+        private void configureSysProps() {
+            System.setProperty("com.arjuna.ats.arjuna.coordinator.defaultTimeout", "60");
+            System.setProperty(
+                    "com.arjuna.ats.arjuna.objectstore.objectStoreDir",
+                    persistProps.getProperty(DroolsPersistenceProperties.JTA_OBJECTSTORE_DIR));
+            System.setProperty(
+                    "ObjectStoreEnvironmentBean.objectStoreDir",
+                    persistProps.getProperty(DroolsPersistenceProperties.JTA_OBJECTSTORE_DIR));
+        }
 
-		/**
-		 * Configures a Kie Environment
-		 * 
-		 * @param env
-		 *            environment to be configured
-		 * @param emf
-		 *            entity manager factory
-		 */
-		private void configureKieEnv(Environment env, EntityManagerFactory emf) {
-			env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
-			env.set(EnvironmentName.TRANSACTION, fact.getUserTrans());
-			env.set(EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY, fact.getTransSyncReg());
-			env.set(EnvironmentName.TRANSACTION_MANAGER, fact.getTransMgr());
-		}
+        /**
+         * Configures a Kie Environment.
+         *
+         * @param env environment to be configured
+         * @param emf entity manager factory
+         */
+        private void configureKieEnv(Environment env, EntityManagerFactory emf) {
+            env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
+            env.set(EnvironmentName.TRANSACTION, fact.getUserTrans());
+            env.set(EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY, fact.getTransSyncReg());
+            env.set(EnvironmentName.TRANSACTION_MANAGER, fact.getTransMgr());
+        }
 
-		/**
-		 * Gets a session's ID from the persistent store.
-		 * 
-		 * @param conn
-		 *            persistence connector
-		 * @param sessnm
-		 *            name of the session
-		 * @return the session's id, or {@code -1} if the session is not found
-		 */
-		private long getSessionId(DroolsSessionConnector conn, String sessnm) {
-			DroolsSession sess = conn.get(sessnm);
-			return sess != null ? sess.getSessionId() : -1;
-		}
+        /**
+         * Gets a session's ID from the persistent store.
+         *
+         * @param conn persistence connector
+         * @param sessnm name of the session
+         * @return the session's id, or {@code -1} if the session is not found
+         */
+        private long getSessionId(DroolsSessionConnector conn, String sessnm) {
+            DroolsSession sess = conn.get(sessnm);
+            return sess != null ? sess.getSessionId() : -1;
+        }
 
-		/**
-		 * Replaces a session within the persistent store, if it exists. Adds it
-		 * otherwise.
-		 * 
-		 * @param conn
-		 *            persistence connector
-		 * @param sessnm
-		 *            name of session to be updated
-		 * @param kieSession
-		 *            new session information
-		 */
-		private void replaceSession(DroolsSessionConnector conn, String sessnm, KieSession kieSession) {
+        /**
+         * Replaces a session within the persistent store, if it exists. Adds it otherwise.
+         *
+         * @param conn persistence connector
+         * @param sessnm name of session to be updated
+         * @param kieSession new session information
+         */
+        private void replaceSession(DroolsSessionConnector conn, String sessnm, KieSession kieSession) {
 
-			DroolsSessionEntity sess = new DroolsSessionEntity();
+            DroolsSessionEntity sess = new DroolsSessionEntity();
 
-			sess.setSessionName(sessnm);
-			sess.setSessionId(kieSession.getIdentifier());
+            sess.setSessionName(sessnm);
+            sess.setSessionId(kieSession.getIdentifier());
 
-			conn.replace(sess);
-		}
-	}
+            conn.replace(sess);
+        }
+    }
 
-	/* ============================================================ */
+    /* ============================================================ */
 
-	/**
-	 * Gets the data source properties.
-	 * 
-	 * @return the data source properties
-	 */
-	private Properties getDataSourceProperties() {
-		Properties props = new Properties();
-		props.put("driverClassName", persistProps.getProperty(DroolsPersistenceProperties.DB_DRIVER));
-		props.put("url", persistProps.getProperty(DroolsPersistenceProperties.DB_URL));
-		props.put("username", persistProps.getProperty(DroolsPersistenceProperties.DB_USER));
-		props.put("password", persistProps.getProperty(DroolsPersistenceProperties.DB_PWD));
-		props.put("maxActive", "3");
-		props.put("maxIdle", "1");
-		props.put("maxWait", "120000");
-		props.put("whenExhaustedAction", "2");
-		props.put("testOnBorrow", "false");
-		props.put("poolPreparedStatements", "true");
+    /**
+     * Gets the data source properties.
+     *
+     * @return the data source properties
+     */
+    private Properties getDataSourceProperties() {
+        Properties props = new Properties();
+        props.put("driverClassName", persistProps.getProperty(DroolsPersistenceProperties.DB_DRIVER));
+        props.put("url", persistProps.getProperty(DroolsPersistenceProperties.DB_URL));
+        props.put("username", persistProps.getProperty(DroolsPersistenceProperties.DB_USER));
+        props.put("password", persistProps.getProperty(DroolsPersistenceProperties.DB_PWD));
+        props.put("maxActive", "3");
+        props.put("maxIdle", "1");
+        props.put("maxWait", "120000");
+        props.put("whenExhaustedAction", "2");
+        props.put("testOnBorrow", "false");
+        props.put("poolPreparedStatements", "true");
 
-		return props;
-	}
+        return props;
+    }
 
-	/**
-	 * Removes "old" Drools 'sessioninfo' records, so they aren't used to
-	 * restore data to Drools sessions. This also has the useful side-effect of
-	 * removing abandoned records as well.
-	 */
-	private void cleanUpSessionInfo() {
+    /**
+     * Removes "old" Drools 'sessioninfo' records, so they aren't used to restore data to Drools
+     * sessions. This also has the useful side-effect of removing abandoned records as well.
+     */
+    private void cleanUpSessionInfo() {
 
-		synchronized (cleanupLock) {
+        synchronized (cleanupLock) {
+            if (sessInfoCleaned) {
+                logger.info("Clean up of sessioninfo table: already done");
+                return;
+            }
 
-			if (sessInfoCleaned) {
-				logger.info("Clean up of sessioninfo table: already done");
-				return;
-			}
-
-			if (sessionInfoTimeoutMs < 0) {
-				logger.info("Clean up of sessioninfo table: no timeout specified");
-				return;
-			}
+            if (sessionInfoTimeoutMs < 0) {
+                logger.info("Clean up of sessioninfo table: no timeout specified");
+                return;
+            }
 
-			// now do the record deletion
-			try (BasicDataSource ds = fact.makeDataSource(getDataSourceProperties());
-					Connection connection = ds.getConnection();
-					PreparedStatement statement = connection.prepareStatement(
-							"DELETE FROM sessioninfo WHERE timestampdiff(second,lastmodificationdate,now()) > ?")) {
+            // now do the record deletion
+            try (BasicDataSource ds = fact.makeDataSource(getDataSourceProperties());
+                    Connection connection = ds.getConnection();
+                    PreparedStatement statement =
+                            connection.prepareStatement(
+                                "DELETE FROM sessioninfo WHERE timestampdiff(second,lastmodificationdate,now()) > ?")) {
 
-				connection.setAutoCommit(true);
+                connection.setAutoCommit(true);
 
-				statement.setLong(1, sessionInfoTimeoutMs / 1000);
+                statement.setLong(1, sessionInfoTimeoutMs / 1000);
 
-				int count = statement.executeUpdate();
-				logger.info("Cleaning up sessioninfo table -- {} records removed", count);
+                int count = statement.executeUpdate();
+                logger.info("Cleaning up sessioninfo table -- {} records removed", count);
 
-			} catch (SQLException e) {
-				logger.error("Clean up of sessioninfo table failed", e);
-			}
+            } catch (SQLException e) {
+                logger.error("Clean up of sessioninfo table failed", e);
+            }
 
-			// TODO: delete DroolsSessionEntity where sessionId not in
-			// (sessinfo.xxx)
+            // TODO: delete DroolsSessionEntity where sessionId not in
+            // (sessinfo.xxx)
 
-			sessInfoCleaned = true;
-		}
-	}
+            sessInfoCleaned = true;
+        }
+    }
 
-	/**
-	 * Determine whether persistence is enabled for a specific container
-	 * 
-	 * @param container
-	 *            container to be checked
-	 * @param sessionName
-	 *            name of the session to be checked
-	 * @return {@code true} if persistence is enabled for this container, and
-	 *         {@code false} if not
-	 */
-	private boolean isPersistenceEnabled(PolicyContainer container, String sessionName) {
-		Properties properties = getProperties(container);
-		boolean rval = false;
+    /**
+     * Determine whether persistence is enabled for a specific container.
+     *
+     * @param container container to be checked
+     * @param sessionName name of the session to be checked
+     * @return {@code true} if persistence is enabled for this container, and {@code false} if not
+     */
+    private boolean isPersistenceEnabled(PolicyContainer container, String sessionName) {
+        Properties properties = getProperties(container);
+        boolean rval = false;
 
-		if (properties != null) {
-			// fetch the 'type' property
-			String type = getProperty(properties, sessionName, "type");
-			rval = "auto".equals(type) || "native".equals(type);
-		}
+        if (properties != null) {
+            // fetch the 'type' property
+            String type = getProperty(properties, sessionName, "type");
+            rval = "auto".equals(type) || "native".equals(type);
+        }
 
-		return rval;
-	}
+        return rval;
+    }
 
-	/**
-	 * Determine the controller properties associated with the policy container.
-	 * 
-	 * @param container
-	 *            container whose properties are to be retrieved
-	 * @return the container's properties, or {@code null} if not found
-	 */
-	private Properties getProperties(PolicyContainer container) {
-		try {
-			return fact.getPolicyController(container).getProperties();
-		} catch (IllegalArgumentException e) {
-			logger.error("getProperties exception: ", e);
-			return null;
-		}
-	}
+    /**
+     * Determine the controller properties associated with the policy container.
+     *
+     * @param container container whose properties are to be retrieved
+     * @return the container's properties, or {@code null} if not found
+     */
+    private Properties getProperties(PolicyContainer container) {
+        try {
+            return fact.getPolicyController(container).getProperties();
+        } catch (IllegalArgumentException e) {
+            logger.error("getProperties exception: ", e);
+            return null;
+        }
+    }
 
-	/**
-	 * Fetch the persistence property associated with a session. The name may
-	 * have the form:
-	 * <ul>
-	 * <li>persistence.SESSION-NAME.PROPERTY</li>
-	 * <li>persistence.PROPERTY</li>
-	 * </ul>
-	 * 
-	 * @param properties
-	 *            properties from which the value is to be retrieved
-	 * @param sessionName
-	 *            session name of interest
-	 * @param property
-	 *            property name of interest
-	 * @return the property value, or {@code null} if not found
-	 */
-	private String getProperty(Properties properties, String sessionName, String property) {
-		String value = properties.getProperty("persistence." + sessionName + "." + property);
-		if (value == null) {
-			value = properties.getProperty("persistence." + property);
-		}
+    /**
+     * Fetch the persistence property associated with a session. The name may have the form:
+     *
+     * <ul>
+     *   <li>persistence.SESSION-NAME.PROPERTY
+     *   <li>persistence.PROPERTY
+     * </ul>
+     *
+     * @param properties properties from which the value is to be retrieved
+     * @param sessionName session name of interest
+     * @param property property name of interest
+     * @return the property value, or {@code null} if not found
+     */
+    private String getProperty(Properties properties, String sessionName, String property) {
+        String value = properties.getProperty("persistence." + sessionName + "." + property);
+        if (value == null) {
+            value = properties.getProperty("persistence." + property);
+        }
 
-		return value;
-	}
+        return value;
+    }
 
-	/* ============================================================ */
+    /* ============================================================ */
 
-	/**
-	 * This 'ThreadModel' variant periodically calls
-	 * 'KieSession.fireAllRules()', because the 'fireUntilHalt' method isn't
-	 * compatible with persistence.
-	 */
-	public class PersistentThreadModel implements Runnable, PolicySession.ThreadModel {
+    /**
+     * This 'ThreadModel' variant periodically calls 'KieSession.fireAllRules()', because the
+     * 'fireUntilHalt' method isn't compatible with persistence.
+     */
+    public class PersistentThreadModel implements Runnable, PolicySession.ThreadModel {
 
-		/**
-		 * Session associated with this persistent thread.
-		 */
-		private final PolicySession session;
+        /** Session associated with this persistent thread. */
+        private final PolicySession session;
 
-		/**
-		 * The session thread.
-		 */
-		private final Thread thread;
+        /** The session thread. */
+        private final Thread thread;
 
-		/**
-		 * Used to indicate that processing should stop.
-		 */
-		private final CountDownLatch stopped = new CountDownLatch(1);
+        /** Used to indicate that processing should stop. */
+        private final CountDownLatch stopped = new CountDownLatch(1);
 
-		/**
-		 * Minimum time, in milli-seconds, that the thread should sleep before
-		 * firing rules again.
-		 */
-		long minSleepTime = 100;
+        /** Minimum time, in milli-seconds, that the thread should sleep before firing rules again. */
+        long minSleepTime = 100;
 
-		/**
-		 * Maximum time, in milli-seconds, that the thread should sleep before
-		 * firing rules again. This is a "half" time, so that we can multiply it
-		 * by two without overflowing the word size.
-		 */
-		long halfMaxSleepTime = 5000L / 2L;
+        /**
+         * Maximum time, in milli-seconds, that the thread should sleep before firing rules again. This
+         * is a "half" time, so that we can multiply it by two without overflowing the word size.
+         */
+        long halfMaxSleepTime = 5000L / 2L;
 
-		/**
-		 * Constructor - initialize variables and create thread
-		 *
-		 * @param session
-		 *            the 'PolicySession' instance
-		 * @param properties
-		 *            may contain additional session properties
-		 */
-		public PersistentThreadModel(PolicySession session, Properties properties) {
-			this.session = session;
-			this.thread = new Thread(this, getThreadName());
+        /**
+         * Constructor - initialize variables and create thread.
+         *
+         * @param session the 'PolicySession' instance
+         * @param properties may contain additional session properties
+         */
+        public PersistentThreadModel(PolicySession session, Properties properties) {
+            this.session = session;
+            this.thread = new Thread(this, getThreadName());
 
-			if (properties == null) {
-				return;
-			}
+            if (properties == null) {
+                return;
+            }
 
-			// extract 'minSleepTime' and/or 'maxSleepTime'
-			String name = session.getName();
+            // extract 'minSleepTime' and/or 'maxSleepTime'
+            String name = session.getName();
 
-			// fetch 'minSleepTime' value, and update if defined
-			String sleepTimeString = getProperty(properties, name, "minSleepTime");
-			if (sleepTimeString != null) {
-				try {
-					minSleepTime = Math.max(1, Integer.valueOf(sleepTimeString));
-				} catch (Exception e) {
-					logger.error(sleepTimeString + ": Illegal value for 'minSleepTime'", e);
-				}
-			}
+            // fetch 'minSleepTime' value, and update if defined
+            String sleepTimeString = getProperty(properties, name, "minSleepTime");
+            if (sleepTimeString != null) {
+                try {
+                    minSleepTime = Math.max(1, Integer.valueOf(sleepTimeString));
+                } catch (Exception e) {
+                    logger.error(sleepTimeString + ": Illegal value for 'minSleepTime'", e);
+                }
+            }
 
-			// fetch 'maxSleepTime' value, and update if defined
-			long maxSleepTime = 2 * halfMaxSleepTime;
-			sleepTimeString = getProperty(properties, name, "maxSleepTime");
-			if (sleepTimeString != null) {
-				try {
-					maxSleepTime = Math.max(1, Integer.valueOf(sleepTimeString));
-				} catch (Exception e) {
-					logger.error(sleepTimeString + ": Illegal value for 'maxSleepTime'", e);
-				}
-			}
+            // fetch 'maxSleepTime' value, and update if defined
+            long maxSleepTime = 2 * halfMaxSleepTime;
+            sleepTimeString = getProperty(properties, name, "maxSleepTime");
+            if (sleepTimeString != null) {
+                try {
+                    maxSleepTime = Math.max(1, Integer.valueOf(sleepTimeString));
+                } catch (Exception e) {
+                    logger.error(sleepTimeString + ": Illegal value for 'maxSleepTime'", e);
+                }
+            }
 
-			// swap values if needed
-			if (minSleepTime > maxSleepTime) {
-				logger.error("minSleepTime(" + minSleepTime + ") is greater than maxSleepTime(" + maxSleepTime
-						+ ") -- swapping");
-				long tmp = minSleepTime;
-				minSleepTime = maxSleepTime;
-				maxSleepTime = tmp;
-			}
+            // swap values if needed
+            if (minSleepTime > maxSleepTime) {
+                logger.error(
+                        "minSleepTime("
+                                + minSleepTime
+                                + ") is greater than maxSleepTime("
+                                + maxSleepTime
+                                + ") -- swapping");
+                long tmp = minSleepTime;
+                minSleepTime = maxSleepTime;
+                maxSleepTime = tmp;
+            }
 
-			halfMaxSleepTime = Math.max(1, maxSleepTime / 2);
-		}
+            halfMaxSleepTime = Math.max(1, maxSleepTime / 2);
+        }
 
-		/**
-		 * @return the String to use as the thread name
-		 */
-		private String getThreadName() {
-			return "Session " + session.getFullName() + " (persistent)";
-		}
+        /**
+         * Get thread name.
+         *  
+         * @return the String to use as the thread name */
+        private String getThreadName() {
+            return "Session " + session.getFullName() + " (persistent)";
+        }
 
-		/***************************/
-		/* 'ThreadModel' interface */
-		/***************************/
+        /** ************************ */
+        /* 'ThreadModel' interface */
+        /** ************************ */
 
-		/**
-		 * {@inheritDoc}
-		 */
-		@Override
-		public void start() {
-			thread.start();
-		}
+        /** 
+         * {@inheritDoc} */
+        @Override
+        public void start() {
+            thread.start();
+        }
 
-		/**
-		 * {@inheritDoc}
-		 */
-		@Override
-		public void stop() {
-			// tell the thread to stop
-			stopped.countDown();
+        /** 
+         * {@inheritDoc} */
+        @Override
+        public void stop() {
+            // tell the thread to stop
+            stopped.countDown();
 
-			// wait up to 10 seconds for the thread to stop
-			try {
-				thread.join(10000);
+            // wait up to 10 seconds for the thread to stop
+            try {
+                thread.join(10000);
 
-			} catch (InterruptedException e) {
-				logger.error("stopThread exception: ", e);
-				Thread.currentThread().interrupt();
-			}
+            } catch (InterruptedException e) {
+                logger.error("stopThread exception: ", e);
+                Thread.currentThread().interrupt();
+            }
 
-			// verify that it's done
-			if (thread.isAlive()) {
-				logger.error("stopThread: still running");
-			}
-		}
+            // verify that it's done
+            if (thread.isAlive()) {
+                logger.error("stopThread: still running");
+            }
+        }
 
-		/**
-		 * {@inheritDoc}
-		 */
-		@Override
-		public void updated() {
-			// the container artifact has been updated -- adjust the thread name
-			thread.setName(getThreadName());
-		}
+        /** 
+         * {@inheritDoc} */
+        @Override
+        public void updated() {
+            // the container artifact has been updated -- adjust the thread name
+            thread.setName(getThreadName());
+        }
 
-		/************************/
-		/* 'Runnable' interface */
-		/************************/
+        /** ********************* */
+        /* 'Runnable' interface */
+        /** ********************* */
 
-		/**
-		 * {@inheritDoc}
-		 */
-		@Override
-		public void run() {
-			logger.info("PersistentThreadModel running");
+        /** 
+         * {@inheritDoc} */
+        @Override
+        public void run() {
+            logger.info("PersistentThreadModel running");
 
-			// set thread local variable
-			session.setPolicySession();
+            // set thread local variable
+            session.setPolicySession();
 
-			KieSession kieSession = session.getKieSession();
-			long sleepTime = 2 * halfMaxSleepTime;
+            KieSession kieSession = session.getKieSession();
+            long sleepTime = 2 * halfMaxSleepTime;
 
-			// We want to continue, despite any exceptions that occur
-			// while rules are fired.
+            // We want to continue, despite any exceptions that occur
+            // while rules are fired.
 
-			boolean cont = true;
-			while(cont) {
+            boolean cont = true;
+            while (cont) {
 
-				try {
-					if (kieSession.fireAllRules() > 0) {
-						// some rules fired -- reduce poll delay
-						sleepTime = Math.max(minSleepTime, sleepTime / 2);
-					} else {
-						// no rules fired -- increase poll delay
-						sleepTime = 2 * Math.min(halfMaxSleepTime, sleepTime);
-					}
+                try {
+                    if (kieSession.fireAllRules() > 0) {
+                        // some rules fired -- reduce poll delay
+                        sleepTime = Math.max(minSleepTime, sleepTime / 2);
+                    } else {
+                        // no rules fired -- increase poll delay
+                        sleepTime = 2 * Math.min(halfMaxSleepTime, sleepTime);
+                    }
 
-				} catch (Exception | LinkageError e) {
-					logger.error("Exception during kieSession.fireAllRules", e);
-				}
-				
+                } catch (Exception | LinkageError e) {
+                    logger.error("Exception during kieSession.fireAllRules", e);
+                }
 
-				try {
-					if (stopped.await(sleepTime, TimeUnit.MILLISECONDS)) {
-						cont = false;
-					}
+                try {
+                    if (stopped.await(sleepTime, TimeUnit.MILLISECONDS)) {
+                        cont = false;
+                    }
 
-				} catch (InterruptedException e) {
-					logger.error("startThread exception: ", e);
-					Thread.currentThread().interrupt();
-					cont = false;
-				}
-			}
+                } catch (InterruptedException e) {
+                    logger.error("startThread exception: ", e);
+                    Thread.currentThread().interrupt();
+                    cont = false;
+                }
+            }
 
-			logger.info("PersistentThreadModel completed");
-		}
-	}
+            logger.info("PersistentThreadModel completed");
+        }
+    }
 
-	/* ============================================================ */
+    /* ============================================================ */
 
-	/**
-	 * DataSource-EntityManagerFactory pair.
-	 */
-	private class DsEmf {
-		private BasicDataSource bds;
-		private EntityManagerFactory emf;
+    /** DataSource-EntityManagerFactory pair. */
+    private class DsEmf {
+        private BasicDataSource bds;
+        private EntityManagerFactory emf;
 
-		/**
-		 * Makes an entity manager factory for the given data source.
-		 * 
-		 * @param bds
-		 *            pooled data source
-		 */
-		public DsEmf(BasicDataSource bds) {
-			try {
-				Map<String, Object> props = new HashMap<>();
-				props.put(org.hibernate.cfg.Environment.JPA_JTA_DATASOURCE, bds);
+        /**
+         * Makes an entity manager factory for the given data source.
+         *
+         * @param bds pooled data source
+         */
+        public DsEmf(BasicDataSource bds) {
+            try {
+                Map<String, Object> props = new HashMap<>();
+                props.put(org.hibernate.cfg.Environment.JPA_JTA_DATASOURCE, bds);
 
-				this.bds = bds;
-				this.emf = fact.makeEntMgrFact(props);
+                this.bds = bds;
+                this.emf = fact.makeEntMgrFact(props);
 
-			} catch (RuntimeException e) {
-				closeDataSource();
-				throw e;
-			}
-		}
+            } catch (RuntimeException e) {
+                closeDataSource();
+                throw e;
+            }
+        }
 
-		/**
-		 * Closes the entity manager factory and the data source.
-		 */
-		public void close() {
-			try {
-				emf.close();
+        /** Closes the entity manager factory and the data source. */
+        public void close() {
+            try {
+                emf.close();
 
-			} catch (RuntimeException e) {
-				closeDataSource();
-				throw e;
-			}
+            } catch (RuntimeException e) {
+                closeDataSource();
+                throw e;
+            }
 
-			closeDataSource();
-		}
+            closeDataSource();
+        }
 
-		/**
-		 * Closes the data source only.
-		 */
-		private void closeDataSource() {
-			try {
-				bds.close();
+        /** Closes the data source only. */
+        private void closeDataSource() {
+            try {
+                bds.close();
 
-			} catch (SQLException e) {
-				throw new PersistenceFeatureException(e);
-			}
+            } catch (SQLException e) {
+                throw new PersistenceFeatureException(e);
+            }
+        }
+    }
 
-		}
-	}
+    private static class SingletonRegistry {
+        private static final TransactionSynchronizationRegistry transreg =
+                new com.arjuna.ats.internal.jta.transaction.arjunacore
+                .TransactionSynchronizationRegistryImple();
 
-	private static class SingletonRegistry {
-		private static final TransactionSynchronizationRegistry transreg = new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple();
-		
-		private SingletonRegistry() {
-			super();
-		}
-	}
+        private SingletonRegistry() {
+            super();
+        }
+    }
 
-	/**
-	 * Factory for various items. Methods can be overridden for junit testing.
-	 */
-	protected static class Factory {
+    /** Factory for various items. Methods can be overridden for junit testing. */
+    protected static class Factory {
 
-		/**
-		 * Gets the transaction manager.
-		 * 
-		 * @return the transaction manager
-		 */
-		public TransactionManager getTransMgr() {
-			return com.arjuna.ats.jta.TransactionManager.transactionManager();
-		}
+        /**
+         * Gets the transaction manager.
+         *
+         * @return the transaction manager
+         */
+        public TransactionManager getTransMgr() {
+            return com.arjuna.ats.jta.TransactionManager.transactionManager();
+        }
 
-		/**
-		 * Gets the user transaction.
-		 * 
-		 * @return the user transaction
-		 */
-		public UserTransaction getUserTrans() {
-			return com.arjuna.ats.jta.UserTransaction.userTransaction();
-		}
+        /**
+         * Gets the user transaction.
+         *
+         * @return the user transaction
+         */
+        public UserTransaction getUserTrans() {
+            return com.arjuna.ats.jta.UserTransaction.userTransaction();
+        }
 
-		/**
-		 * Gets the transaction synchronization registry.
-		 * 
-		 * @return the transaction synchronization registry
-		 */
-		public TransactionSynchronizationRegistry getTransSyncReg() {
-			return SingletonRegistry.transreg;
-		}
+        /**
+         * Gets the transaction synchronization registry.
+         *
+         * @return the transaction synchronization registry
+         */
+        public TransactionSynchronizationRegistry getTransSyncReg() {
+            return SingletonRegistry.transreg;
+        }
 
-		/**
-		 * Gets the KIE services.
-		 * 
-		 * @return the KIE services
-		 */
-		public KieServices getKieServices() {
-			return KieServices.Factory.get();
-		}
+        /**
+         * Gets the KIE services.
+         *
+         * @return the KIE services
+         */
+        public KieServices getKieServices() {
+            return KieServices.Factory.get();
+        }
 
-		/**
-		 * Loads properties from a file.
-		 * 
-		 * @param filenm
-		 *            name of the file to load
-		 * @return properties, as loaded from the file
-		 * @throws IOException
-		 *             if an error occurs reading from the file
-		 */
-		public Properties loadProperties(String filenm) throws IOException {
-			return PropertyUtil.getProperties(filenm);
-		}
+        /**
+         * Loads properties from a file.
+         *
+         * @param filenm name of the file to load
+         * @return properties, as loaded from the file
+         * @throws IOException if an error occurs reading from the file
+         */
+        public Properties loadProperties(String filenm) throws IOException {
+            return PropertyUtil.getProperties(filenm);
+        }
 
-		/**
-		 * Makes a Data Source.
-		 * 
-		 * @param dsProps
-		 *            data source properties
-		 * @return a new data source
-		 */
-		public BasicDataSource makeDataSource(Properties dsProps) {
-			try {
-				return BasicDataSourceFactory.createDataSource(dsProps);
+        /**
+         * Makes a Data Source.
+         *
+         * @param dsProps data source properties
+         * @return a new data source
+         */
+        public BasicDataSource makeDataSource(Properties dsProps) {
+            try {
+                return BasicDataSourceFactory.createDataSource(dsProps);
 
-			} catch (Exception e) {
-				throw new PersistenceFeatureException(e);
-			}
-		}
+            } catch (Exception e) {
+                throw new PersistenceFeatureException(e);
+            }
+        }
 
-		/**
-		 * Makes a new JPA connector for drools sessions.
-		 * 
-		 * @param emf
-		 *            entity manager factory
-		 * @return a new JPA connector for drools sessions
-		 */
-		public DroolsSessionConnector makeJpaConnector(EntityManagerFactory emf) {
-			return new JpaDroolsSessionConnector(emf);
-		}
+        /**
+         * Makes a new JPA connector for drools sessions.
+         *
+         * @param emf entity manager factory
+         * @return a new JPA connector for drools sessions
+         */
+        public DroolsSessionConnector makeJpaConnector(EntityManagerFactory emf) {
+            return new JpaDroolsSessionConnector(emf);
+        }
 
-		/**
-		 * Makes a new entity manager factory.
-		 * 
-		 * @param props
-		 *            properties with which the factory should be configured
-		 * @return a new entity manager factory
-		 */
-		public EntityManagerFactory makeEntMgrFact(Map<String, Object> props) {
-			return Persistence.createEntityManagerFactory("onapsessionsPU", props);
-		}
+        /**
+         * Makes a new entity manager factory.
+         *
+         * @param props properties with which the factory should be configured
+         * @return a new entity manager factory
+         */
+        public EntityManagerFactory makeEntMgrFact(Map<String, Object> props) {
+            return Persistence.createEntityManagerFactory("onapsessionsPU", props);
+        }
 
-		/**
-		 * Gets the policy controller associated with a given policy container.
-		 * 
-		 * @param container
-		 *            container whose controller is to be retrieved
-		 * @return the container's controller
-		 */
-		public PolicyController getPolicyController(PolicyContainer container) {
-			return PolicyController.factory.get(container.getGroupId(), container.getArtifactId());
-		}
-	}
+        /**
+         * Gets the policy controller associated with a given policy container.
+         *
+         * @param container container whose controller is to be retrieved
+         * @return the container's controller
+         */
+        public PolicyController getPolicyController(PolicyContainer container) {
+            return PolicyController.factory.get(container.getGroupId(), container.getArtifactId());
+        }
+    }
 
-	/**
-	 * Runtime exceptions generated by this class. Wraps exceptions generated by
-	 * delegated operations, particularly when they are not, themselves, Runtime
-	 * exceptions.
-	 */
-	public static class PersistenceFeatureException extends RuntimeException {
-		private static final long serialVersionUID = 1L;
+    /**
+     * Runtime exceptions generated by this class. Wraps exceptions generated by delegated operations,
+     * particularly when they are not, themselves, Runtime exceptions.
+     */
+    public static class PersistenceFeatureException extends RuntimeException {
+        private static final long serialVersionUID = 1L;
 
-		/**
-		 * 
-		 * @param e
-		 *            exception to be wrapped
-		 */
-		public PersistenceFeatureException(Exception e) {
-			super(e);
-		}
-	}
+        /** 
+         * Constructor.
+         * */
+        public PersistenceFeatureException(Exception ex) {
+            super(ex);
+        }
+    }
 }
diff --git a/feature-session-persistence/src/main/resources/META-INF/persistence.xml b/feature-session-persistence/src/main/resources/META-INF/persistence.xml
index 6b8345c..661803a 100644
--- a/feature-session-persistence/src/main/resources/META-INF/persistence.xml
+++ b/feature-session-persistence/src/main/resources/META-INF/persistence.xml
@@ -3,7 +3,7 @@
   ============LICENSE_START=======================================================
   policy-core
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-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.
@@ -20,37 +20,54 @@
   -->
 
 <persistence version="2.1"
-	xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
 
-	<persistence-unit name="onapsessionsPU" transaction-type="JTA">
-	<!-- Used for drools session data access -->
-		<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
-		<class>org.onap.policy.drools.persistence.DroolsSessionEntity</class>
-		<class>org.drools.persistence.info.SessionInfo</class>
-		<class>org.drools.persistence.info.WorkItemInfo</class>
-		<properties>
-			<property name="hibernate.dialect" value="org.hibernate.dialect.MariaDBDialect" />
-			<property name="hibernate.max_fetch_depth" value="3" />
-			<property name="hibernate.hbm2ddl.auto" value="update" />
-			<property name="hibernate.show_sql" value="false" />
-			<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
-			<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
-		</properties>
-	</persistence-unit>
-	
-	<persistence-unit name="schemaDroolsPU" transaction-type="RESOURCE_LOCAL">
-	<!-- Limited use for generating the DB and schema files for drools DB - uses eclipselink for convenience -->
-		<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
-		<class>org.onap.policy.drools.persistence.DroolsSessionEntity</class>
-		<class>org.drools.persistence.info.SessionInfo</class>
-		<class>org.drools.persistence.info.WorkItemInfo</class>
-		<properties>
-			<property name="hibernate.dialect" value="org.hibernate.dialect.MariaDBDialect" />
-			<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/> 
-            <property name="javax.persistence.schema-generation.scripts.create-target" value="sql/generatedCreateDrools.ddl"/>
-            <property name="javax.persistence.schema-generation.scripts.drop-target" value="sql/generatedDropDrools.ddl"/>
+    <persistence-unit name="onapsessionsPU"
+        transaction-type="JTA">
+        <!-- Used for drools session data access -->
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+        <class>org.onap.policy.drools.persistence.DroolsSessionEntity</class>
+        <class>org.drools.persistence.info.SessionInfo</class>
+        <class>org.drools.persistence.info.WorkItemInfo</class>
+        <properties>
+            <property name="hibernate.dialect"
+                value="org.hibernate.dialect.MariaDBDialect" />
+            <property name="hibernate.max_fetch_depth"
+                value="3" />
+            <property name="hibernate.hbm2ddl.auto"
+                value="update" />
+            <property name="hibernate.show_sql" value="false" />
+            <property
+                name="hibernate.transaction.factory_class"
+                value="org.hibernate.transaction.JTATransactionFactory" />
+            <property
+                name="hibernate.transaction.manager_lookup_class"
+                value="org.hibernate.transaction.JBossTransactionManagerLookup" />
         </properties>
-	</persistence-unit>
-	
+    </persistence-unit>
+
+    <persistence-unit name="schemaDroolsPU"
+        transaction-type="RESOURCE_LOCAL">
+        <!-- Limited use for generating the DB and schema files for drools DB - uses eclipselink for convenience -->
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+        <class>org.onap.policy.drools.persistence.DroolsSessionEntity</class>
+        <class>org.drools.persistence.info.SessionInfo</class>
+        <class>org.drools.persistence.info.WorkItemInfo</class>
+        <properties>
+            <property name="hibernate.dialect"
+                value="org.hibernate.dialect.MariaDBDialect" />
+            <property
+                name="javax.persistence.schema-generation.scripts.action"
+                value="drop-and-create" />
+            <property
+                name="javax.persistence.schema-generation.scripts.create-target"
+                value="sql/generatedCreateDrools.ddl" />
+            <property
+                name="javax.persistence.schema-generation.scripts.drop-target"
+                value="sql/generatedDropDrools.ddl" />
+        </properties>
+    </persistence-unit>
+
 </persistence>
diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java
index 7624d04..b2dcfb5 100644
--- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java
+++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -31,173 +31,162 @@
 
 public class DroolsSessionEntityTest {
 
-	@Test
-	public void testHashCode() {
-		DroolsSessionEntity e = makeEnt("mynameA", 1);
+    @Test
+    public void testHashCode() {
+        DroolsSessionEntity entity = makeEnt("mynameA", 1);
 
-		DroolsSessionEntity e2 = makeEnt("mynameA", 2);
+        DroolsSessionEntity e2 = makeEnt("mynameA", 2);
 
-		// session id is not part of hash code
-		assertTrue(e.hashCode() == e2.hashCode());
+        // session id is not part of hash code
+        assertTrue(entity.hashCode() == e2.hashCode());
 
-		// diff sess name
-		e2 = makeEnt("mynameB", 1);
-		assertTrue(e.hashCode() != e2.hashCode());
-	}
+        // diff sess name
+        e2 = makeEnt("mynameB", 1);
+        assertTrue(entity.hashCode() != e2.hashCode());
+    }
 
-	/**
-	 * Ensures that hashCode() functions as expected when the getXxx methods are
-	 * overridden.
-	 */
-	@Test
-	public void testHashCode_Subclass() {
-		DroolsSessionEntity e = makeEnt2("mynameA", 1);
+    /** Ensures that hashCode() functions as expected when the getXxx methods are overridden. */
+    @Test
+    public void testHashCode_Subclass() {
+        DroolsSessionEntity entity = makeEnt2("mynameA", 1);
 
-		DroolsSessionEntity e2 = makeEnt("mynameA", 2);
+        DroolsSessionEntity e2 = makeEnt("mynameA", 2);
 
-		// session id is not part of hash code
-		assertTrue(e.hashCode() == e2.hashCode());
+        // session id is not part of hash code
+        assertTrue(entity.hashCode() == e2.hashCode());
 
-		// diff sess name
-		e2 = makeEnt("mynameB", 1);
-		assertTrue(e.hashCode() != e2.hashCode());
-	}
+        // diff sess name
+        e2 = makeEnt("mynameB", 1);
+        assertTrue(entity.hashCode() != e2.hashCode());
+    }
 
-	@Test
-	public void testGetSessionName_testSetSessionName() {
-		DroolsSessionEntity e = makeEnt("mynameZ", 1);
+    @Test
+    public void testGetSessionName_testSetSessionName() {
+        DroolsSessionEntity entity = makeEnt("mynameZ", 1);
 
-		assertEquals("mynameZ", e.getSessionName());
+        assertEquals("mynameZ", entity.getSessionName());
 
-		e.setSessionName("another");
-		assertEquals("another", e.getSessionName());
+        entity.setSessionName("another");
+        assertEquals("another", entity.getSessionName());
 
-		// others unchanged
-		assertEquals(1, e.getSessionId());
-	}
+        // others unchanged
+        assertEquals(1, entity.getSessionId());
+    }
 
-	@Test
-	public void testGetSessionId_testSetSessionId() {
-		DroolsSessionEntity e = makeEnt("mynameA", 1);
+    @Test
+    public void testGetSessionId_testSetSessionId() {
+        DroolsSessionEntity entity = makeEnt("mynameA", 1);
 
-		assertEquals(1, e.getSessionId());
+        assertEquals(1, entity.getSessionId());
 
-		e.setSessionId(20);
-		assertEquals(20, e.getSessionId());
+        entity.setSessionId(20);
+        assertEquals(20, entity.getSessionId());
 
-		// others unchanged
-		assertEquals("mynameA", e.getSessionName());
-	}
+        // others unchanged
+        assertEquals("mynameA", entity.getSessionName());
+    }
 
-	@Test
-	public void testGetCreatedDate_testSetCreatedDate_testGetUpdatedDate_testSetUpdatedDate() {
-		DroolsSessionEntity e = new DroolsSessionEntity();
+    @Test
+    public void testGetCreatedDate_testSetCreatedDate_testGetUpdatedDate_testSetUpdatedDate() {
+        DroolsSessionEntity entity = new DroolsSessionEntity();
 
-		Date crtdt = new Date(System.currentTimeMillis() - 100);
-		e.setCreatedDate(crtdt);
+        Date crtdt = new Date(System.currentTimeMillis() - 100);
+        entity.setCreatedDate(crtdt);
 
-		Date updt = new Date(System.currentTimeMillis() - 200);
-		e.setUpdatedDate(updt);
+        Date updt = new Date(System.currentTimeMillis() - 200);
+        entity.setUpdatedDate(updt);
 
-		assertEquals(crtdt, e.getCreatedDate());
-		assertEquals(updt, e.getUpdatedDate());
-	}
+        assertEquals(crtdt, entity.getCreatedDate());
+        assertEquals(updt, entity.getUpdatedDate());
+    }
 
-	@Test
-	public void testEqualsObject() {
-		DroolsSessionEntity e = makeEnt("mynameA", 1);
+    @Test
+    public void testEqualsObject() {
+        DroolsSessionEntity entity = makeEnt("mynameA", 1);
 
-		// reflexive
-		assertTrue(e.equals(e));
+        // reflexive
+        assertTrue(entity.equals(entity));
 
-		DroolsSessionEntity e2 = makeEnt("mynameA", 2);
+        DroolsSessionEntity e2 = makeEnt("mynameA", 2);
 
-		// session id is not part of hash code
-		assertTrue(e.equals(e2));
-		assertTrue(e.equals(e2));
+        // session id is not part of hash code
+        assertTrue(entity.equals(e2));
+        assertTrue(entity.equals(e2));
 
-		// diff sess name
-		e2 = makeEnt("mynameB", 1);
-		assertFalse(e.equals(e2));
-		assertFalse(e.equals(e2));
-	}
+        // diff sess name
+        e2 = makeEnt("mynameB", 1);
+        assertFalse(entity.equals(e2));
+        assertFalse(entity.equals(e2));
+    }
 
-	/**
-	 * Ensures that equals() functions as expected when the getXxx methods are
-	 * overridden.
-	 */
-	@Test
-	public void testEqualsObject_Subclass() {
-		DroolsSessionEntity e = makeEnt2("mynameA", 1);
+    /** Ensures that equals() functions as expected when the getXxx methods are overridden. */
+    @Test
+    public void testEqualsObject_Subclass() {
+        DroolsSessionEntity entity = makeEnt2("mynameA", 1);
 
-		// reflexive
-		assertTrue(e.equals(e));
+        // reflexive
+        assertTrue(entity.equals(entity));
 
-		DroolsSessionEntity e2 = makeEnt("mynameA", 2);
+        DroolsSessionEntity e2 = makeEnt("mynameA", 2);
 
-		// session id is not part of hash code
-		assertTrue(e.equals(e2));
-		assertTrue(e.equals(e2));
+        // session id is not part of hash code
+        assertTrue(entity.equals(e2));
+        assertTrue(entity.equals(e2));
 
-		// diff sess name
-		e2 = makeEnt("mynameB", 1);
-		assertFalse(e.equals(e2));
-		assertFalse(e.equals(e2));
-	}
+        // diff sess name
+        e2 = makeEnt("mynameB", 1);
+        assertFalse(entity.equals(e2));
+        assertFalse(entity.equals(e2));
+    }
 
-	@Test
-	public void testToString() {
-		DroolsSessionEntity e = makeEnt("mynameA", 23);
+    @Test
+    public void testToString() {
+        DroolsSessionEntity entity = makeEnt("mynameA", 23);
 
-		assertEquals("{name=mynameA, id=23}", e.toString());
-	}
+        assertEquals("{name=mynameA, id=23}", entity.toString());
+    }
 
-	/**
-	 * Makes a session Entity. The parameters are stored into the Entity object
-	 * via the setXxx methods.
-	 * 
-	 * @param sessnm
-	 *            session name
-	 * @param sessid
-	 *            session id
-	 * @return a new session Entity
-	 */
-	private DroolsSessionEntity makeEnt(String sessnm, long sessid) {
+    /**
+     * Makes a session Entity. The parameters are stored into the Entity object via the setXxx
+     * methods.
+     *
+     * @param sessnm session name
+     * @param sessid session id
+     * @return a new session Entity
+     */
+    private DroolsSessionEntity makeEnt(String sessnm, long sessid) {
 
-		DroolsSessionEntity e = new DroolsSessionEntity();
+        DroolsSessionEntity entity = new DroolsSessionEntity();
 
-		e.setSessionName(sessnm);
-		e.setSessionId(sessid);
+        entity.setSessionName(sessnm);
+        entity.setSessionId(sessid);
 
-		return e;
-	}
+        return entity;
+    }
 
-	/**
-	 * Makes a session Entity that overrides the getXxx methods. The parameters
-	 * that are provided are returned by the overridden methods, but they are
-	 * <i>not</i> stored into the Entity object via the setXxx methods.
-	 * 
-	 * @param sessnm
-	 *            session name
-	 * @param sessid
-	 *            session id
-	 * @return a new session Entity
-	 */
-	@SuppressWarnings("serial")
-	private DroolsSessionEntity makeEnt2(String sessnm, long sessid) {
+    /**
+     * Makes a session Entity that overrides the getXxx methods. The parameters that are provided are
+     * returned by the overridden methods, but they are <i>not</i> stored into the Entity object via
+     * the setXxx methods.
+     *
+     * @param sessnm session name
+     * @param sessid session id
+     * @return a new session Entity
+     */
+    @SuppressWarnings("serial")
+    private DroolsSessionEntity makeEnt2(String sessnm, long sessid) {
 
-		return new DroolsSessionEntity() {
+        return new DroolsSessionEntity() {
 
-			@Override
-			public String getSessionName() {
-				return sessnm;
-			}
+            @Override
+            public String getSessionName() {
+                return sessnm;
+            }
 
-			@Override
-			public long getSessionId() {
-				return sessid;
-			}
-		};
-	}
-
+            @Override
+            public long getSessionId() {
+                return sessid;
+            }
+        };
+    }
 }
diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java
index 9c9a30b..aba1d80 100644
--- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java
+++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,13 +20,14 @@
 
 package org.onap.policy.drools.persistence;
 
+import static org.junit.Assert.assertEquals;
+
+import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doThrow;
 
 import javax.persistence.EntityManager;
 import javax.transaction.HeuristicMixedException;
@@ -47,399 +48,402 @@
 
 public class EntityMgrTransTest {
 
-	private static final Logger logger = LoggerFactory.getLogger(PersistenceFeatureTest.class);
+    private static final Logger logger = LoggerFactory.getLogger(PersistenceFeatureTest.class);
 
-	private static UserTransaction savetrans;
+    private static UserTransaction savetrans;
 
-	private UserTransaction trans;
-	private EntityManager mgr;
+    private UserTransaction trans;
+    private EntityManager mgr;
 
-	@BeforeClass
-	public static void setUpBeforeClass() {
-		System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", "target/tm");
-		System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", "target/tm");
+    /**
+     * Setup before the class.
+     * 
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", "target/tm");
+        System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", "target/tm");
 
-		savetrans = EntityMgrTrans.getUserTrans();
-	}
+        savetrans = EntityMgrTrans.getUserTrans();
+    }
 
-	@AfterClass
-	public static void tearDownAfterClass() {
-		EntityMgrTrans.setUserTrans(savetrans);
-	}
+    @AfterClass
+    public static void tearDownAfterClass() {
+        EntityMgrTrans.setUserTrans(savetrans);
+    }
 
-	@Before
-	public void setUp() throws Exception {
-		trans = mock(UserTransaction.class);
-		mgr = mock(EntityManager.class);
+    /**
+     * Setup.
+     * 
+     * @throws Exception exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        trans = mock(UserTransaction.class);
+        mgr = mock(EntityManager.class);
 
-		EntityMgrTrans.setUserTrans(trans);
-	}
+        EntityMgrTrans.setUserTrans(trans);
+    }
 
-	/**
-	 * Verifies that the constructor starts a transaction, but does not do
-	 * anything extra before being closed.
-	 * 
-	 * @throws Exception
-	 */
-	@Test
-	public void testEntityMgrTrans() throws Exception {
+    /**
+     * Verifies that the constructor starts a transaction, but does not do anything extra before being
+     * closed.
+     *
+     * @throws Exception exception
+     */
+    @Test
+    public void testEntityMgrTrans() throws Exception {
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
 
-		EntityMgrTrans t = new EntityMgrTrans(mgr);
+        final EntityMgrTrans newTrans = new EntityMgrTrans(mgr);
 
-		// verify that transaction was started
-		verify(trans).begin();
+        // verify that transaction was started
+        verify(trans).begin();
 
-		// verify not closed, committed, or rolled back yet
-		verify(trans, never()).commit();
-		verify(trans, never()).rollback();
-		verify(mgr, never()).close();
+        // verify not closed, committed, or rolled back yet
+        verify(trans, never()).commit();
+        verify(trans, never()).rollback();
+        verify(mgr, never()).close();
 
-		t.close();
-	}
+        newTrans.close();
+    }
 
-	@Test(expected = EntityMgrException.class)
-	public void testEntityMgrTrans_RtEx() throws Exception {
+    @Test(expected = EntityMgrException.class)
+    public void testEntityMgrTrans_RtEx() throws Exception {
 
-		doThrow(new IllegalArgumentException("expected exception")).when(trans).begin();
+        doThrow(new IllegalArgumentException("expected exception")).when(trans).begin();
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            // Empty
+        }
+    }
 
-		}
-	}
+    @Test(expected = EntityMgrException.class)
+    public void testEntityMgrTrans_NotSuppEx() throws Exception {
 
-	@Test(expected = EntityMgrException.class)
-	public void testEntityMgrTrans_NotSuppEx() throws Exception {
+        doThrow(new NotSupportedException("expected exception")).when(trans).begin();
 
-		doThrow(new NotSupportedException("expected exception")).when(trans).begin();
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            // Empty
+        }
+    }
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+    @Test(expected = EntityMgrException.class)
+    public void testEntityMgrTrans_SysEx() throws Exception {
 
-		}
-	}
+        doThrow(new SystemException("expected exception")).when(trans).begin();
 
-	@Test(expected = EntityMgrException.class)
-	public void testEntityMgrTrans_SysEx() throws Exception {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            // Empty
+        }
+    }
 
-		doThrow(new SystemException("expected exception")).when(trans).begin();
+    /**
+     * Verifies that the transaction is rolled back and the manager is closed when and a transaction
+     * is active.
+     */
+    @Test
+    public void testClose_Active() throws Exception {
+        EntityMgrTrans newTrans = new EntityMgrTrans(mgr);
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
 
-		}
-	}
+        newTrans.close();
 
-	/**
-	 * Verifies that the transaction is rolled back and the manager is closed
-	 * when and a transaction is active.
-	 */
-	@Test
-	public void testClose_Active() throws Exception {
-		EntityMgrTrans t = new EntityMgrTrans(mgr);
+        // closed and rolled back, but not committed
+        verify(trans, never()).commit();
+        verify(trans).rollback();
+        verify(mgr).close();
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+    /**
+     * Verifies that the manager is closed, but that the transaction is <i>not</i> rolled back when
+     * and no transaction is active.
+     */
+    @Test
+    public void testClose_Inactive() throws Exception {
+        EntityMgrTrans newTrans = new EntityMgrTrans(mgr);
 
-		t.close();
+        when(trans.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION);
 
-		// closed and rolled back, but not committed
-		verify(trans, never()).commit();
-		verify(trans).rollback();
-		verify(mgr).close();
-	}
+        newTrans.close();
 
-	/**
-	 * Verifies that the manager is closed, but that the transaction is
-	 * <i>not</i> rolled back when and no transaction is active.
-	 */
-	@Test
-	public void testClose_Inactive() throws Exception {
-		EntityMgrTrans t = new EntityMgrTrans(mgr);
+        // closed, but not committed or rolled back
+        verify(mgr).close();
+        verify(trans, never()).commit();
+        verify(trans, never()).rollback();
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION);
+    @Test(expected = EntityMgrException.class)
+    public void testClose_IllStateEx() throws Exception {
 
-		t.close();
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new IllegalStateException("expected exception")).when(trans).rollback();
 
-		// closed, but not committed or rolled back
-		verify(mgr).close();
-		verify(trans, never()).commit();
-		verify(trans, never()).rollback();
-	}
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            // Empty
+        }
+    }
 
-	@Test(expected = EntityMgrException.class)
-	public void testClose_IllStateEx() throws Exception {
+    @Test(expected = EntityMgrException.class)
+    public void testClose_SecEx() throws Exception {
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new IllegalStateException("expected exception")).when(trans).rollback();
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new SecurityException("expected exception")).when(trans).rollback();
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            // Empty
+        }
+    }
 
-		}
-	}
+    @Test(expected = EntityMgrException.class)
+    public void testClose_SysEx() throws Exception {
 
-	@Test(expected = EntityMgrException.class)
-	public void testClose_SecEx() throws Exception {
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new SystemException("expected exception")).when(trans).rollback();
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new SecurityException("expected exception")).when(trans).rollback();
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            // Empty
+        }
+    }
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+    /**
+     * Verifies that the manager is closed and the transaction rolled back when "try" block exits
+     * normally and a transaction is active.
+     */
+    @Test
+    public void testClose_TryWithoutExcept_Active() throws Exception {
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
 
-		}
-	}
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            // Empty
+        }
 
-	@Test(expected = EntityMgrException.class)
-	public void testClose_SysEx() throws Exception {
+        // closed and rolled back, but not committed
+        verify(trans, never()).commit();
+        verify(trans).rollback();
+        verify(mgr).close();
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new SystemException("expected exception")).when(trans).rollback();
+    /**
+     * Verifies that the manager is closed, but that the transaction is <i>not</i> rolled back when
+     * "try" block exits normally and no transaction is active.
+     */
+    @Test
+    public void testClose_TryWithoutExcept_Inactive() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+        when(trans.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION);
 
-		}
-	}
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            // Empty
+        }
 
-	/**
-	 * Verifies that the manager is closed and the transaction rolled back when
-	 * "try" block exits normally and a transaction is active.
-	 */
-	@Test
-	public void testClose_TryWithoutExcept_Active() throws Exception {
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        // closed, but not rolled back or committed
+        verify(trans, never()).commit();
+        verify(trans, never()).rollback();
+        verify(mgr).close();
+    }
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+    /**
+     * Verifies that the manager is closed and the transaction rolled back when "try" block throws an
+     * exception and a transaction is active.
+     */
+    @Test
+    public void testClose_TryWithExcept_Active() throws Exception {
 
-		}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
 
-		// closed and rolled back, but not committed
-		verify(trans, never()).commit();
-		verify(trans).rollback();
-		verify(mgr).close();
-	}
+        try {
+            try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+                throw new SystemException("expected exception");
+            }
 
-	/**
-	 * Verifies that the manager is closed, but that the transaction is
-	 * <i>not</i> rolled back when "try" block exits normally and no transaction
-	 * is active.
-	 */
-	@Test
-	public void testClose_TryWithoutExcept_Inactive() throws Exception {
+        } catch (Exception e) {
+            logger.trace("expected exception", e);
+        }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION);
+        // closed and rolled back, but not committed
+        verify(trans, never()).commit();
+        verify(trans).rollback();
+        verify(mgr).close();
+    }
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-
-		}
-
-		// closed, but not rolled back or committed
-		verify(trans, never()).commit();
-		verify(trans, never()).rollback();
-		verify(mgr).close();
-	}
-
-	/**
-	 * Verifies that the manager is closed and the transaction rolled back when
-	 * "try" block throws an exception and a transaction is active.
-	 */
-	@Test
-	public void testClose_TryWithExcept_Active() throws Exception {
-
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-
-		try {
-			try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-				throw new SystemException("expected exception");
-			}
-
-		} catch (Exception e) {
-			logger.trace("expected exception", e);
-		}
-
-		// closed and rolled back, but not committed
-		verify(trans, never()).commit();
-		verify(trans).rollback();
-		verify(mgr).close();
-	}
-
-	/**
-	 * Verifies that the manager is closed, but that the transaction is
-	 * <i>not</i> rolled back when "try" block throws an exception and no
-	 * transaction is active.
-	 */
-	@Test
-	public void testClose_TryWithExcept_Inactive() throws Exception {
-
-		when(trans.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION);
+    /**
+     * Verifies that the manager is closed, but that the transaction is <i>not</i> rolled back when
+     * "try" block throws an exception and no transaction is active.
+     */
+    @Test
+    public void testClose_TryWithExcept_Inactive() throws Exception {
 
-		try {
-			try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-				throw new SystemException("expected exception");
-			}
+        when(trans.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION);
 
-		} catch (Exception e) {
-			logger.trace("expected exception", e);
-		}
+        try {
+            try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+                throw new SystemException("expected exception");
+            }
 
-		// closed, but not rolled back or committed
-		verify(trans, never()).commit();
-		verify(trans, never()).rollback();
-		verify(mgr).close();
-	}
+        } catch (Exception e) {
+            logger.trace("expected exception", e);
+        }
 
-	/**
-	 * Verifies that commit() only commits, and that the subsequent close() does
-	 * not re-commit.
-	 */
-	@Test
-	public void testCommit() throws Exception {
-		EntityMgrTrans t = new EntityMgrTrans(mgr);
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        // closed, but not rolled back or committed
+        verify(trans, never()).commit();
+        verify(trans, never()).rollback();
+        verify(mgr).close();
+    }
 
-		t.commit();
+    /** Verifies that commit() only commits, and that the subsequent close() does not re-commit. */
+    @Test
+    public void testCommit() throws Exception {
+        EntityMgrTrans newTrans = new EntityMgrTrans(mgr);
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_COMMITTED);
+        newTrans.commit();
 
-		// committed, but not closed or rolled back
-		verify(trans).commit();
-		verify(trans, never()).rollback();
-		verify(mgr, never()).close();
+        when(trans.getStatus()).thenReturn(Status.STATUS_COMMITTED);
 
-		// closed, but not re-committed
-		t.close();
+        // committed, but not closed or rolled back
+        verify(trans).commit();
+        verify(trans, never()).rollback();
+        verify(mgr, never()).close();
 
-		verify(trans, times(1)).commit();
-		verify(mgr).close();
-	}
+        // closed, but not re-committed
+        newTrans.close();
 
-	@Test(expected = EntityMgrException.class)
-	public void testCommit_SecEx() throws Exception {
+        verify(trans, times(1)).commit();
+        verify(mgr).close();
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new SecurityException("expected exception")).when(trans).commit();
+    @Test(expected = EntityMgrException.class)
+    public void testCommit_SecEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.commit();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new SecurityException("expected exception")).when(trans).commit();
 
-	@Test(expected = EntityMgrException.class)
-	public void testCommit_IllStateEx() throws Exception {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.commit();
+        }
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new IllegalStateException("expected exception")).when(trans).commit();
+    @Test(expected = EntityMgrException.class)
+    public void testCommit_IllStateEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.commit();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new IllegalStateException("expected exception")).when(trans).commit();
 
-	@Test(expected = EntityMgrException.class)
-	public void testCommit_RbEx() throws Exception {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.commit();
+        }
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new RollbackException("expected exception")).when(trans).commit();
+    @Test(expected = EntityMgrException.class)
+    public void testCommit_RbEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.commit();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new RollbackException("expected exception")).when(trans).commit();
 
-	@Test(expected = EntityMgrException.class)
-	public void testCommit_HmEx() throws Exception {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.commit();
+        }
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new HeuristicMixedException("expected exception")).when(trans).commit();
+    @Test(expected = EntityMgrException.class)
+    public void testCommit_HmEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.commit();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new HeuristicMixedException("expected exception")).when(trans).commit();
 
-	@Test(expected = EntityMgrException.class)
-	public void testCommit_HrbEx() throws Exception {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.commit();
+        }
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new HeuristicRollbackException("expected exception")).when(trans).commit();
+    @Test(expected = EntityMgrException.class)
+    public void testCommit_HrbEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.commit();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new HeuristicRollbackException("expected exception")).when(trans).commit();
 
-	@Test(expected = EntityMgrException.class)
-	public void testCommit_SysEx() throws Exception {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.commit();
+        }
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new SystemException("expected exception")).when(trans).commit();
+    @Test(expected = EntityMgrException.class)
+    public void testCommit_SysEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.commit();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new SystemException("expected exception")).when(trans).commit();
 
-	/**
-	 * Verifies that rollback() only rolls back, and that the subsequent close()
-	 * does not re-roll back.
-	 */
-	@Test
-	public void testRollback() throws Exception {
-		EntityMgrTrans t = new EntityMgrTrans(mgr);
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.commit();
+        }
+    }
 
-		t.rollback();
+    /**
+     * Verifies that rollback() only rolls back, and that the subsequent close() does not re-roll
+     * back.
+     */
+    @Test
+    public void testRollback() throws Exception {
+        EntityMgrTrans newTrans = new EntityMgrTrans(mgr);
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ROLLEDBACK);
+        newTrans.rollback();
 
-		// rolled back, but not closed or committed
-		verify(trans, never()).commit();
-		verify(trans).rollback();
-		verify(mgr, never()).close();
+        when(trans.getStatus()).thenReturn(Status.STATUS_ROLLEDBACK);
 
-		// closed, but not re-rolled back
-		t.close();
+        // rolled back, but not closed or committed
+        verify(trans, never()).commit();
+        verify(trans).rollback();
+        verify(mgr, never()).close();
 
-		verify(trans, times(1)).rollback();
-		verify(mgr).close();
-	}
+        // closed, but not re-rolled back
+        newTrans.close();
 
-	@Test(expected = EntityMgrException.class)
-	public void testRollback_IllStateEx() throws Exception {
+        verify(trans, times(1)).rollback();
+        verify(mgr).close();
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new IllegalStateException("expected exception")).when(trans).rollback();
+    @Test(expected = EntityMgrException.class)
+    public void testRollback_IllStateEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.rollback();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new IllegalStateException("expected exception")).when(trans).rollback();
 
-	@Test(expected = EntityMgrException.class)
-	public void testRollback_SecEx() throws Exception {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.rollback();
+        }
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new SecurityException("expected exception")).when(trans).rollback();
+    @Test(expected = EntityMgrException.class)
+    public void testRollback_SecEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.rollback();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new SecurityException("expected exception")).when(trans).rollback();
 
-	@Test(expected = EntityMgrException.class)
-	public void testRollback_SysEx() throws Exception {
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.rollback();
+        }
+    }
 
-		when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
-		doThrow(new SystemException("expected exception")).when(trans).rollback();
+    @Test(expected = EntityMgrException.class)
+    public void testRollback_SysEx() throws Exception {
 
-		try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
-			t.rollback();
-		}
-	}
+        when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
+        doThrow(new SystemException("expected exception")).when(trans).rollback();
 
-	@Test
-	public void testEntityMgrException() {
-		SecurityException secex = new SecurityException("expected exception");
-		EntityMgrException ex = new EntityMgrException(secex);
+        try (EntityMgrTrans t = new EntityMgrTrans(mgr)) {
+            t.rollback();
+        }
+    }
 
-		assertEquals(secex, ex.getCause());
+    @Test
+    public void testEntityMgrException() {
+        SecurityException secex = new SecurityException("expected exception");
+        EntityMgrException ex = new EntityMgrException(secex);
 
-	}
+        assertEquals(secex, ex.getCause());
+    }
 }
diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java
index a0af2e6..38e3ec2 100644
--- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java
+++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -29,41 +29,38 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * Generates the schema DDL files.
- */
+/** Generates the schema DDL files. */
 public class GenSchema {
 
-	private static final Logger logger = LoggerFactory.getLogger(PersistenceFeatureTest.class);
+    private static final Logger logger = LoggerFactory.getLogger(PersistenceFeatureTest.class);
 
-	private EntityManagerFactory emf;
+    private EntityManagerFactory emf;
 
-	/**
-	 * Opens the EMF, which generates the schema, as a side-effect.
-	 * 
-	 * @throws Exception
-	 */
-	private GenSchema() throws Exception {
-		Map<String, Object> propMap = new HashMap<>();
+    /**
+     * Opens the EMF, which generates the schema, as a side-effect.
+     *
+     * @throws Exception exception
+     */
+    private GenSchema() throws Exception {
+        Map<String, Object> propMap = new HashMap<>();
 
-		propMap.put("javax.persistence.jdbc.driver", "org.h2.Driver");
-		propMap.put("javax.persistence.jdbc.url", "jdbc:h2:mem:JpaDroolsSessionConnectorTest");
+        propMap.put("javax.persistence.jdbc.driver", "org.h2.Driver");
+        propMap.put("javax.persistence.jdbc.url", "jdbc:h2:mem:JpaDroolsSessionConnectorTest");
 
-		emf = Persistence.createEntityManagerFactory("schemaDroolsPU", propMap);
+        emf = Persistence.createEntityManagerFactory("schemaDroolsPU", propMap);
 
-		emf.close();
-	}
+        emf.close();
+    }
 
-	/**
-	 * This is is provided as a utility for producing a basic ddl schema file in
-	 * the sql directory.
-	 */
-	public static void main(String[] args) {
-		try {
-			new GenSchema();
+    /**
+     * This is is provided as a utility for producing a basic ddl schema file in the sql directory.
+     */
+    public static void main(String[] args) {
+        try {
+            new GenSchema();
 
-		} catch (Exception e) {
-			logger.error("failed to generate schema", e);
-		}
-	}
+        } catch (Exception e) {
+            logger.error("failed to generate schema", e);
+        }
+    }
 }
diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnectorTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnectorTest.java
index dd601dd..def8f2e 100644
--- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnectorTest.java
+++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnectorTest.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -45,155 +45,158 @@
 
 public class JpaDroolsSessionConnectorTest {
 
-	private EntityManagerFactory emf;
-	private JpaDroolsSessionConnector conn;
+    private EntityManagerFactory emf;
+    private JpaDroolsSessionConnector conn;
 
-	@BeforeClass
-	public static void setUpBeforeClass() {
-		System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", "target/tm");
-		System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", "target/tm");
-	}
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", "target/tm");
+        System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", "target/tm");
+    }
 
-	@Before
-	public void setUp() throws Exception {
-		Map<String, Object> propMap = new HashMap<>();
+    /**
+     * Setup.
+     * 
+     * @throws Exception exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        Map<String, Object> propMap = new HashMap<>();
 
-		propMap.put("javax.persistence.jdbc.driver", "org.h2.Driver");
-		propMap.put("javax.persistence.jdbc.url", "jdbc:h2:mem:JpaDroolsSessionConnectorTest");
+        propMap.put("javax.persistence.jdbc.driver", "org.h2.Driver");
+        propMap.put("javax.persistence.jdbc.url", "jdbc:h2:mem:JpaDroolsSessionConnectorTest");
 
-		emf = Persistence.createEntityManagerFactory("junitDroolsSessionEntityPU", propMap);
+        emf = Persistence.createEntityManagerFactory("junitDroolsSessionEntityPU", propMap);
 
-		conn = new JpaDroolsSessionConnector(emf);
-	}
+        conn = new JpaDroolsSessionConnector(emf);
+    }
 
-	@After
-	public void tearDown() {
-		// this will cause the memory db to be dropped
-		emf.close();
-	}
+    @After
+    public void tearDown() {
+        // this will cause the memory db to be dropped
+        emf.close();
+    }
 
-	@Test
-	public void testGet() {
-		/*
-		 * Load up the DB with some data.
-		 */
+    @Test
+    public void testGet() {
+        /*
+         * Load up the DB with some data.
+         */
 
-		addSession("nameA", 10);
-		addSession("nameY", 20);
+        addSession("nameA", 10);
+        addSession("nameY", 20);
 
-		/*
-		 * Now test the functionality.
-		 */
+        /*
+         * Now test the functionality.
+         */
 
-		// not found
-		assertNull(conn.get("unknown"));
+        // not found
+        assertNull(conn.get("unknown"));
 
-		assertEquals("{name=nameA, id=10}", conn.get("nameA").toString());
+        assertEquals("{name=nameA, id=10}", conn.get("nameA").toString());
 
-		assertEquals("{name=nameY, id=20}", conn.get("nameY").toString());
-	}
+        assertEquals("{name=nameY, id=20}", conn.get("nameY").toString());
+    }
 
-	@Test(expected = IllegalArgumentException.class)
-	public void testGet_NewEx() {
-		EntityManagerFactory emf = mock(EntityManagerFactory.class);
-		EntityManager em = mock(EntityManager.class);
+    @Test(expected = IllegalArgumentException.class)
+    public void testGet_NewEx() {
+        EntityManagerFactory emf = mock(EntityManagerFactory.class);
+        EntityManager em = mock(EntityManager.class);
 
-		when(emf.createEntityManager()).thenReturn(em);
-		when(em.find(any(), any())).thenThrow(new IllegalArgumentException("expected exception"));
+        when(emf.createEntityManager()).thenReturn(em);
+        when(em.find(any(), any())).thenThrow(new IllegalArgumentException("expected exception"));
 
-		conn = new JpaDroolsSessionConnector(emf);
-		conn.get("xyz");
-	}
+        conn = new JpaDroolsSessionConnector(emf);
+        conn.get("xyz");
+    }
 
-	@Test(expected = IllegalArgumentException.class)
-	public void testGet_FindEx() {
-		EntityManagerFactory emf = mock(EntityManagerFactory.class);
-		EntityManager em = mock(EntityManager.class);
-		EntityTransaction tr = mock(EntityTransaction.class);
+    @Test(expected = IllegalArgumentException.class)
+    public void testGet_FindEx() {
+        EntityManagerFactory emf = mock(EntityManagerFactory.class);
+        EntityManager em = mock(EntityManager.class);
+        EntityTransaction tr = mock(EntityTransaction.class);
 
-		when(emf.createEntityManager()).thenReturn(em);
-		when(em.getTransaction()).thenReturn(tr);
-		when(em.find(any(), any())).thenThrow(new IllegalArgumentException("expected exception"));
+        when(emf.createEntityManager()).thenReturn(em);
+        when(em.getTransaction()).thenReturn(tr);
+        when(em.find(any(), any())).thenThrow(new IllegalArgumentException("expected exception"));
 
-		new JpaDroolsSessionConnector(emf).get("xyz");
-	}
+        new JpaDroolsSessionConnector(emf).get("xyz");
+    }
 
-	@Test(expected = IllegalArgumentException.class)
-	public void testGet_FindEx_CloseEx() {
-		EntityManagerFactory emf = mock(EntityManagerFactory.class);
-		EntityManager em = mock(EntityManager.class);
-		EntityTransaction tr = mock(EntityTransaction.class);
+    @Test(expected = IllegalArgumentException.class)
+    public void testGet_FindEx_CloseEx() {
+        EntityManagerFactory emf = mock(EntityManagerFactory.class);
+        EntityManager em = mock(EntityManager.class);
+        EntityTransaction tr = mock(EntityTransaction.class);
 
-		when(emf.createEntityManager()).thenReturn(em);
-		when(em.getTransaction()).thenReturn(tr);
-		when(em.find(any(), any())).thenThrow(new IllegalArgumentException("expected exception"));
-		doThrow(new IllegalArgumentException("expected exception #2")).when(em).close();
+        when(emf.createEntityManager()).thenReturn(em);
+        when(em.getTransaction()).thenReturn(tr);
+        when(em.find(any(), any())).thenThrow(new IllegalArgumentException("expected exception"));
+        doThrow(new IllegalArgumentException("expected exception #2")).when(em).close();
 
-		new JpaDroolsSessionConnector(emf).get("xyz");
-	}
+        new JpaDroolsSessionConnector(emf).get("xyz");
+    }
 
-	@Test
-	public void testReplace_Existing() {
-		addSession("nameA", 10);
+    @Test
+    public void testReplace_Existing() {
+        addSession("nameA", 10);
 
-		DroolsSessionEntity sess = new DroolsSessionEntity("nameA", 30);
+        DroolsSessionEntity sess = new DroolsSessionEntity("nameA", 30);
 
-		conn.replace(sess);
+        conn.replace(sess);
 
-		// id should be changed
-		assertEquals(sess.toString(), conn.get("nameA").toString());
-	}
+        // id should be changed
+        assertEquals(sess.toString(), conn.get("nameA").toString());
+    }
 
-	@Test
-	public void testReplace_New() {
-		DroolsSessionEntity sess = new DroolsSessionEntity("nameA", 30);
+    @Test
+    public void testReplace_New() {
+        DroolsSessionEntity sess = new DroolsSessionEntity("nameA", 30);
 
-		conn.replace(sess);
+        conn.replace(sess);
 
-		assertEquals(sess.toString(), conn.get("nameA").toString());
-	}
+        assertEquals(sess.toString(), conn.get("nameA").toString());
+    }
 
-	@Test
-	public void testAdd() {
-		DroolsSessionEntity sess = new DroolsSessionEntity("nameA", 30);
+    @Test
+    public void testAdd() {
+        DroolsSessionEntity sess = new DroolsSessionEntity("nameA", 30);
 
-		conn.replace(sess);
+        conn.replace(sess);
 
-		assertEquals(sess.toString(), conn.get("nameA").toString());
-	}
+        assertEquals(sess.toString(), conn.get("nameA").toString());
+    }
 
-	@Test
-	public void testUpdate() {
-		addSession("nameA", 10);
+    @Test
+    public void testUpdate() {
+        addSession("nameA", 10);
 
-		DroolsSessionEntity sess = new DroolsSessionEntity("nameA", 30);
+        DroolsSessionEntity sess = new DroolsSessionEntity("nameA", 30);
 
-		conn.replace(sess);
+        conn.replace(sess);
 
-		// id should be changed
-		assertEquals("{name=nameA, id=30}", conn.get("nameA").toString());
-	}
+        // id should be changed
+        assertEquals("{name=nameA, id=30}", conn.get("nameA").toString());
+    }
 
-	/**
-	 * Adds a session to the DB.
-	 * 
-	 * @param sessnm
-	 *            session name
-	 * @param sessid
-	 *            session id
-	 */
-	private void addSession(String sessnm, int sessid) {
-		EntityManager em = emf.createEntityManager();
+    /**
+     * Adds a session to the DB.
+     *
+     * @param sessnm session name
+     * @param sessid session id
+     */
+    private void addSession(String sessnm, int sessid) {
+        EntityManager em = emf.createEntityManager();
 
-		try (EntityMgrTrans trans = new EntityMgrTrans(em)) {
-			DroolsSessionEntity ent = new DroolsSessionEntity();
+        try (EntityMgrTrans trans = new EntityMgrTrans(em)) {
+            DroolsSessionEntity ent = new DroolsSessionEntity();
 
-			ent.setSessionName(sessnm);
-			ent.setSessionId(sessid);
+            ent.setSessionName(sessnm);
+            ent.setSessionId(sessid);
 
-			em.persist(ent);
+            em.persist(ent);
 
-			trans.commit();
-		}
-	}
+            trans.commit();
+        }
+    }
 }
diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java
index a7c33ab..27ac2cc 100644
--- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java
+++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-session-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -29,12 +29,12 @@
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyLong;
 import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.doThrow;
 
 import java.io.FileNotFoundException;
 import java.io.FileReader;
@@ -83,1335 +83,1332 @@
 
 public class PersistenceFeatureTest {
 
-	private static final Logger logger = LoggerFactory.getLogger(PersistenceFeatureTest.class);
+    private static final Logger logger = LoggerFactory.getLogger(PersistenceFeatureTest.class);
 
-	private static final String JDBC_DRIVER = "fake.driver";
-	private static final String JDBC_URL = "fake.url";
-	private static final String JDBC_USER = "fake.user";
-	private static final String JDBC_PASSWD = "fake.password";
-	private static final String JTA_OSDIR = "target";
-	private static final String SRC_TEST_RESOURCES = "src/test/resources";
+    private static final String JDBC_DRIVER = "fake.driver";
+    private static final String JDBC_URL = "fake.url";
+    private static final String JDBC_USER = "fake.user";
+    private static final String JDBC_PASSWD = "fake.password";
+    private static final String JTA_OSDIR = "target";
+    private static final String SRC_TEST_RESOURCES = "src/test/resources";
 
-	private static Properties stdprops;
+    private static Properties stdprops;
 
-	private JpaDroolsSessionConnector jpa;
-	private DroolsSession sess;
-	private KieSession kiesess;
-	private BasicDataSource bds;
-	private EntityManagerFactory emf;
-	private Connection conn;
-	private Properties props;
-	private KieServices kiesvc;
-	private Environment kieenv;
-	private KieSessionConfiguration kiecfg;
-	private KieBase kiebase;
-	private KieStoreServices kiestore;
-	private KieContainer kiecont;
-	private TransactionManager transmgr;
-	private UserTransaction usertrans;
-	private TransactionSynchronizationRegistry transreg;
-	private PolicyController polctlr;
-	private PolicyContainer polcont;
-	private PolicySession polsess;
-	private PersistenceFeature.Factory fact;
+    private JpaDroolsSessionConnector jpa;
+    private DroolsSession sess;
+    private KieSession kiesess;
+    private BasicDataSource bds;
+    private EntityManagerFactory emf;
+    private Connection conn;
+    private Properties props;
+    private KieServices kiesvc;
+    private Environment kieenv;
+    private KieSessionConfiguration kiecfg;
+    private KieBase kiebase;
+    private KieStoreServices kiestore;
+    private KieContainer kiecont;
+    private TransactionManager transmgr;
+    private UserTransaction usertrans;
+    private TransactionSynchronizationRegistry transreg;
+    private PolicyController polctlr;
+    private PolicyContainer polcont;
+    private PolicySession polsess;
+    private PersistenceFeature.Factory fact;
 
-	private PersistenceFeature feat;
+    private PersistenceFeature feat;
 
-	@BeforeClass
-	public static void setUpBeforeClass() throws Exception {
-		stdprops = new Properties();
+    /**
+     * Setup before class.
+     * 
+     * @throws Exception exception
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        stdprops = new Properties();
 
-		stdprops.put(DroolsPersistenceProperties.DB_DRIVER, JDBC_DRIVER);
-		stdprops.put(DroolsPersistenceProperties.DB_URL, JDBC_URL);
-		stdprops.put(DroolsPersistenceProperties.DB_USER, JDBC_USER);
-		stdprops.put(DroolsPersistenceProperties.DB_PWD, JDBC_PASSWD);
-		stdprops.put(DroolsPersistenceProperties.JTA_OBJECTSTORE_DIR, JTA_OSDIR);
-		stdprops.put(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT, "50");
+        stdprops.put(DroolsPersistenceProperties.DB_DRIVER, JDBC_DRIVER);
+        stdprops.put(DroolsPersistenceProperties.DB_URL, JDBC_URL);
+        stdprops.put(DroolsPersistenceProperties.DB_USER, JDBC_USER);
+        stdprops.put(DroolsPersistenceProperties.DB_PWD, JDBC_PASSWD);
+        stdprops.put(DroolsPersistenceProperties.JTA_OBJECTSTORE_DIR, JTA_OSDIR);
+        stdprops.put(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT, "50");
 
-		System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", "target/tm");
-		System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", "target/tm");
-	}
+        System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", "target/tm");
+        System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", "target/tm");
+    }
 
-	@Before
-	public void setUp() throws Exception {
-		jpa = mock(JpaDroolsSessionConnector.class);
-		sess = mock(DroolsSession.class);
-		bds = mock(BasicDataSource.class);
-		emf = mock(EntityManagerFactory.class);
-		kiesess = mock(KieSession.class);
-		conn = null;
-		props = new Properties();
-		kiesvc = mock(KieServices.class);
-		kieenv = mock(Environment.class);
-		kiecfg = mock(KieSessionConfiguration.class);
-		kiebase = mock(KieBase.class);
-		kiestore = mock(KieStoreServices.class);
-		kiecont = mock(KieContainer.class);
-		transmgr = mock(TransactionManager.class);
-		usertrans = mock(UserTransaction.class);
-		transreg = mock(TransactionSynchronizationRegistry.class);
-		polcont = mock(PolicyContainer.class);
-		polctlr = mock(PolicyController.class);
-		polsess = mock(PolicySession.class);
-		fact = mock(PersistenceFeature.Factory.class);
+    /**
+     * Setup.
+     * 
+     * @throws Exception exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        jpa = mock(JpaDroolsSessionConnector.class);
+        sess = mock(DroolsSession.class);
+        bds = mock(BasicDataSource.class);
+        emf = mock(EntityManagerFactory.class);
+        kiesess = mock(KieSession.class);
+        conn = null;
+        props = new Properties();
+        kiesvc = mock(KieServices.class);
+        kieenv = mock(Environment.class);
+        kiecfg = mock(KieSessionConfiguration.class);
+        kiebase = mock(KieBase.class);
+        kiestore = mock(KieStoreServices.class);
+        kiecont = mock(KieContainer.class);
+        transmgr = mock(TransactionManager.class);
+        usertrans = mock(UserTransaction.class);
+        transreg = mock(TransactionSynchronizationRegistry.class);
+        polcont = mock(PolicyContainer.class);
+        polctlr = mock(PolicyController.class);
+        polsess = mock(PolicySession.class);
+        fact = mock(PersistenceFeature.Factory.class);
 
-		feat = new PersistenceFeature();
-		feat.setFactory(fact);
+        feat = new PersistenceFeature();
+        feat.setFactory(fact);
 
-		props.putAll(stdprops);
+        props.putAll(stdprops);
 
-		System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", "target/tm");
-		System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", "target/tm");
+        System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", "target/tm");
+        System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", "target/tm");
 
-		when(fact.getKieServices()).thenReturn(kiesvc);
-		when(fact.getTransMgr()).thenReturn(transmgr);
-		when(fact.getUserTrans()).thenReturn(usertrans);
-		when(fact.getTransSyncReg()).thenReturn(transreg);
-		when(fact.loadProperties(anyString())).thenReturn(props);
+        when(fact.getKieServices()).thenReturn(kiesvc);
+        when(fact.getTransMgr()).thenReturn(transmgr);
+        when(fact.getUserTrans()).thenReturn(usertrans);
+        when(fact.getTransSyncReg()).thenReturn(transreg);
+        when(fact.loadProperties(anyString())).thenReturn(props);
 
-		when(kiesvc.newEnvironment()).thenReturn(kieenv);
-		when(kiesvc.getStoreServices()).thenReturn(kiestore);
-		when(kiesvc.newKieSessionConfiguration()).thenReturn(kiecfg);
+        when(kiesvc.newEnvironment()).thenReturn(kieenv);
+        when(kiesvc.getStoreServices()).thenReturn(kiestore);
+        when(kiesvc.newKieSessionConfiguration()).thenReturn(kiecfg);
 
-		when(polcont.getKieContainer()).thenReturn(kiecont);
+        when(polcont.getKieContainer()).thenReturn(kiecont);
 
-		when(polsess.getPolicyContainer()).thenReturn(polcont);
+        when(polsess.getPolicyContainer()).thenReturn(polcont);
 
-		when(kiecont.getKieBase(anyString())).thenReturn(kiebase);
-	}
+        when(kiecont.getKieBase(anyString())).thenReturn(kiebase);
+    }
 
-	@After
-	public void tearDown() {
-		// this will cause the in-memory test DB to be dropped
-		if (conn != null) {
-			try {
-				conn.close();
-			} catch (SQLException e) {
-				logger.warn("failed to close connection", e);
-			}
-		}
+    /**
+     * Tear down.
+     */
+    @After
+    public void tearDown() {
+        // this will cause the in-memory test DB to be dropped
+        if (conn != null) {
+            try {
+                conn.close();
+            } catch (SQLException e) {
+                logger.warn("failed to close connection", e);
+            }
+        }
 
-		if (emf != null) {
-			try {
-				emf.close();
-			} catch (IllegalArgumentException e) {
-				logger.trace("ignored exception", e);
-			}
-		}
-	}
+        if (emf != null) {
+            try {
+                emf.close();
+            } catch (IllegalArgumentException e) {
+                logger.trace("ignored exception", e);
+            }
+        }
+    }
 
-	@Test
-	public void testGetContainerAdjunct_New() throws Exception {
+    @Test
+    public void testGetContainerAdjunct_New() throws Exception {
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		// force getContainerAdjunct() to be invoked
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        // force getContainerAdjunct() to be invoked
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
+        verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
 
-		assertNotNull(adjcap.getValue());
-	}
+        assertNotNull(adjcap.getValue());
+    }
 
-	@Test
-	public void testGetContainerAdjunct_Existing() throws Exception {
+    @Test
+    public void testGetContainerAdjunct_Existing() throws Exception {
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		// force getContainerAdjunct() to be invoked
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        // force getContainerAdjunct() to be invoked
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
+        verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
 
-		// return adjunct on next call
-		when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
+        // return adjunct on next call
+        when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
 
-		// force getContainerAdjunct() to be invoked again
-		setUpKie("myname2", 999L, true);
-		feat.activatePolicySession(polcont, "myname2", "mybase");
+        // force getContainerAdjunct() to be invoked again
+        setUpKie("myname2", 999L, true);
+        feat.activatePolicySession(polcont, "myname2", "mybase");
 
-		// ensure it isn't invoked again
-		verify(polcont, times(1)).setAdjunct(any(), any());
-	}
+        // ensure it isn't invoked again
+        verify(polcont, times(1)).setAdjunct(any(), any());
+    }
 
-	@Test
-	public void testGetContainerAdjunct_WrongType() throws Exception {
+    @Test
+    public void testGetContainerAdjunct_WrongType() throws Exception {
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		// return false adjunct on next call
-		when(polcont.getAdjunct(any())).thenReturn("not-a-real-adjunct");
+        // return false adjunct on next call
+        when(polcont.getAdjunct(any())).thenReturn("not-a-real-adjunct");
 
-		// force getContainerAdjunct() to be invoked
-		setUpKie("myname2", 999L, true);
-		feat.activatePolicySession(polcont, "myname2", "mybase");
+        // force getContainerAdjunct() to be invoked
+        setUpKie("myname2", 999L, true);
+        feat.activatePolicySession(polcont, "myname2", "mybase");
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
+        verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
 
-		assertNotNull(adjcap.getValue());
-	}
+        assertNotNull(adjcap.getValue());
+    }
 
-	@Test
-	public void testGetSequenceNumber() {
-		assertEquals(1, feat.getSequenceNumber());
-	}
+    @Test
+    public void testGetSequenceNumber() {
+        assertEquals(1, feat.getSequenceNumber());
+    }
 
-	@Test
-	public void testGlobalInit() throws Exception {
+    @Test
+    public void testGlobalInit() throws Exception {
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		// verify that various factory methods were invoked
-		verify(fact).getKieServices();
-		verify(fact).loadProperties("src/test/resources/feature-session-persistence.properties");
-	}
+        // verify that various factory methods were invoked
+        verify(fact).getKieServices();
+        verify(fact).loadProperties("src/test/resources/feature-session-persistence.properties");
+    }
 
-	@Test(expected = NullPointerException.class)
-	public void testGlobalInit_IOEx() throws Exception {
-		
-		when(fact.loadProperties(anyString())).thenThrow(new IOException("expected exception"));
+    @Test(expected = NullPointerException.class)
+    public void testGlobalInitIoEx() throws Exception {
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
-	}
+        when(fact.loadProperties(anyString())).thenThrow(new IOException("expected exception"));
 
-	@Test
-	public void testActivatePolicySession() throws Exception {
-		PreparedStatement ps = mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
+    }
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
-		feat.beforeActivate(null);
+    @Test
+    public void testActivatePolicySession() throws Exception {
+        final PreparedStatement ps = mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		KieSession s = feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.beforeActivate(null);
 
-		verify(kiestore).loadKieSession(anyLong(), any(), any(), any());
-		verify(kiestore, never()).newKieSession(any(), any(), any());
+        KieSession session = feat.activatePolicySession(polcont, "myname", "mybase");
 
-		assertEquals(s, kiesess);
+        verify(kiestore).loadKieSession(anyLong(), any(), any(), any());
+        verify(kiestore, never()).newKieSession(any(), any(), any());
 
-		verify(ps).executeUpdate();
+        assertEquals(session, kiesess);
 
-		verify(kieenv, times(4)).set(anyString(), any());
+        verify(ps).executeUpdate();
 
-		verify(jpa).get("myname");
-		verify(jpa).replace(any());
-	}
+        verify(kieenv, times(4)).set(anyString(), any());
 
-	@Test
-	public void testActivatePolicySession_NoPersistence() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        verify(jpa).get("myname");
+        verify(jpa).replace(any());
+    }
 
-		PreparedStatement ps = mockDbConn(5);
-		setUpKie("myname", 999L, true);
+    @Test
+    public void testActivatePolicySession_NoPersistence() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		props.remove("persistence.type");
+        final PreparedStatement ps = mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		feat.beforeStart(null);
+        props.remove("persistence.type");
 
-		assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+        feat.beforeStart(null);
 
-		verify(ps, never()).executeUpdate();
-		verify(kiestore, never()).loadKieSession(anyLong(), any(), any(), any());
-		verify(kiestore, never()).newKieSession(any(), any(), any());
-	}
+        assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
 
-	/**
-	 * Verifies that a new KIE session is created when there is no existing
-	 * session entity.
-	 */
-	@Test
-	public void testActivatePolicySession_New() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        verify(ps, never()).executeUpdate();
+        verify(kiestore, never()).loadKieSession(anyLong(), any(), any(), any());
+        verify(kiestore, never()).newKieSession(any(), any(), any());
+    }
 
-		mockDbConn(5);
-		setUpKie("noName", 999L, true);
+    /** Verifies that a new KIE session is created when there is no existing session entity. */
+    @Test
+    public void testActivatePolicySession_New() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		KieSession s = feat.activatePolicySession(polcont, "myname", "mybase");
+        mockDbConn(5);
+        setUpKie("noName", 999L, true);
 
-		verify(kiestore, never()).loadKieSession(anyLong(), any(), any(), any());
-		verify(kiestore).newKieSession(any(), any(), any());
+        KieSession session = feat.activatePolicySession(polcont, "myname", "mybase");
 
-		assertEquals(s, kiesess);
+        verify(kiestore, never()).loadKieSession(anyLong(), any(), any(), any());
+        verify(kiestore).newKieSession(any(), any(), any());
 
-		verify(kieenv, times(4)).set(anyString(), any());
+        assertEquals(session, kiesess);
 
-		verify(jpa).get("myname");
-		verify(jpa).replace(any());
-	}
+        verify(kieenv, times(4)).set(anyString(), any());
 
-	/**
-	 * Verifies that a new KIE session is created when there KIE fails to load
-	 * an existing session.
-	 */
-	@Test
-	public void testActivatePolicySession_LoadFailed() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        verify(jpa).get("myname");
+        verify(jpa).replace(any());
+    }
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+    /**
+     * Verifies that a new KIE session is created when there KIE fails to load an existing session.
+     */
+    @Test
+    public void testActivatePolicySession_LoadFailed() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		KieSession s = feat.activatePolicySession(polcont, "myname", "mybase");
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		verify(kiestore).loadKieSession(anyLong(), any(), any(), any());
-		verify(kiestore).newKieSession(any(), any(), any());
+        KieSession session = feat.activatePolicySession(polcont, "myname", "mybase");
 
-		assertEquals(s, kiesess);
+        verify(kiestore).loadKieSession(anyLong(), any(), any(), any());
+        verify(kiestore).newKieSession(any(), any(), any());
 
-		verify(kieenv, times(4)).set(anyString(), any());
+        assertEquals(session, kiesess);
 
-		verify(jpa).get("myname");
+        verify(kieenv, times(4)).set(anyString(), any());
 
-		ArgumentCaptor<DroolsSession> d = ArgumentCaptor.forClass(DroolsSession.class);
-		verify(jpa).replace(d.capture());
+        verify(jpa).get("myname");
 
-		assertEquals("myname", d.getValue().getSessionName());
-		assertEquals(100L, d.getValue().getSessionId());
-	}
+        ArgumentCaptor<DroolsSession> drools = ArgumentCaptor.forClass(DroolsSession.class);
+        verify(jpa).replace(drools.capture());
 
-	@Test
-	public void testLoadDataSource() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        assertEquals("myname", drools.getValue().getSessionName());
+        assertEquals(100L, drools.getValue().getSessionId());
+    }
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+    @Test
+    public void testLoadDataSource() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		verify(fact).makeEntMgrFact(any());
-	}
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-	@Test
-	public void testConfigureSysProps() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        verify(fact).makeEntMgrFact(any());
+    }
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+    @Test
+    public void testConfigureSysProps() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		assertEquals("60", System.getProperty("com.arjuna.ats.arjuna.coordinator.defaultTimeout"));
-		assertEquals(JTA_OSDIR, System.getProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir"));
-		assertEquals(JTA_OSDIR, System.getProperty("ObjectStoreEnvironmentBean.objectStoreDir"));
-	}
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-	@Test
-	public void testConfigureKieEnv() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        assertEquals("60", System.getProperty("com.arjuna.ats.arjuna.coordinator.defaultTimeout"));
+        assertEquals(JTA_OSDIR, System.getProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir"));
+        assertEquals(JTA_OSDIR, System.getProperty("ObjectStoreEnvironmentBean.objectStoreDir"));
+    }
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+    @Test
+    public void testConfigureKieEnv() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		verify(kieenv, times(4)).set(any(), any());
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		verify(kieenv).set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
-		verify(kieenv).set(EnvironmentName.TRANSACTION, usertrans);
-		verify(kieenv).set(EnvironmentName.TRANSACTION_MANAGER, transmgr);
-		verify(kieenv).set(EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY, transreg);
-		
-		verify(bds, times(1)).close();
-	}
+        verify(kieenv, times(4)).set(any(), any());
 
-	@Test
-	public void testConfigureKieEnv_RtEx() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        verify(kieenv).set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
+        verify(kieenv).set(EnvironmentName.TRANSACTION, usertrans);
+        verify(kieenv).set(EnvironmentName.TRANSACTION_MANAGER, transmgr);
+        verify(kieenv).set(EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY, transreg);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
-		
-		when(fact.getUserTrans()).thenThrow(new IllegalArgumentException("expected exception"));
+        verify(bds, times(1)).close();
+    }
 
-		try {
-			feat.activatePolicySession(polcont, "myname", "mybase");
-			fail("missing exception");
-			
-		} catch(IllegalArgumentException ex) {
-			logger.trace("expected exception", ex);
-		}
+    @Test
+    public void testConfigureKieEnv_RtEx() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		verify(bds, times(2)).close();
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-	@Test
-	public void testLoadKieSession() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        when(fact.getUserTrans()).thenThrow(new IllegalArgumentException("expected exception"));
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        try {
+            feat.activatePolicySession(polcont, "myname", "mybase");
+            fail("missing exception");
 
-		KieSession s = feat.activatePolicySession(polcont, "myname", "mybase");
+        } catch (IllegalArgumentException ex) {
+            logger.trace("expected exception", ex);
+        }
 
-		verify(kiestore).loadKieSession(999L, kiebase, kiecfg, kieenv);
-		verify(kiestore, never()).newKieSession(any(), any(), any());
+        verify(bds, times(2)).close();
+    }
 
-		assertEquals(s, kiesess);
-	}
+    @Test
+    public void testLoadKieSession() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-	/*
-	 * Verifies that loadKieSession() returns null (thus causing newKieSession()
-	 * to be called) when an Exception occurs.
-	 */
-	@Test
-	public void testLoadKieSession_Ex() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+        KieSession session = feat.activatePolicySession(polcont, "myname", "mybase");
 
-		when(kiestore.loadKieSession(anyLong(), any(), any(), any()))
-				.thenThrow(new IllegalArgumentException("expected exception"));
+        verify(kiestore).loadKieSession(999L, kiebase, kiecfg, kieenv);
+        verify(kiestore, never()).newKieSession(any(), any(), any());
 
-		KieSession s = feat.activatePolicySession(polcont, "myname", "mybase");
+        assertEquals(session, kiesess);
+    }
 
-		verify(kiestore).loadKieSession(anyLong(), any(), any(), any());
-		verify(kiestore).newKieSession(any(), any(), any());
+    /*
+     * Verifies that loadKieSession() returns null (thus causing newKieSession()
+     * to be called) when an Exception occurs.
+     */
+    @Test
+    public void testLoadKieSession_Ex() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertEquals(s, kiesess);
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-	@Test
-	public void testNewKieSession() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        when(kiestore.loadKieSession(anyLong(), any(), any(), any()))
+            .thenThrow(new IllegalArgumentException("expected exception"));
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+        KieSession session = feat.activatePolicySession(polcont, "myname", "mybase");
 
-		KieSession s = feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(kiestore).loadKieSession(anyLong(), any(), any(), any());
+        verify(kiestore).newKieSession(any(), any(), any());
 
-		verify(kiestore).newKieSession(kiebase, null, kieenv);
+        assertEquals(session, kiesess);
+    }
 
-		assertEquals(s, kiesess);
-	}
+    @Test
+    public void testNewKieSession() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-	@Test
-	public void testLoadDataSource_DiffSession() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        KieSession session = feat.activatePolicySession(polcont, "myname", "mybase");
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        verify(kiestore).newKieSession(kiebase, null, kieenv);
 
-		verify(polcont).setAdjunct(any(), adjcap.capture());
+        assertEquals(session, kiesess);
+    }
 
-		when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
+    @Test
+    public void testLoadDataSource_DiffSession() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		setUpKie("myname2", 999L, false);
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		// invoke it again
-		feat.activatePolicySession(polcont, "myname2", "mybase");
+        ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		verify(fact, times(2)).makeEntMgrFact(any());
-	}
-	
-	@Test
-	public void testSelectThreadModel_Persistent() throws Exception {
-		setUpKie("myname", 999L, true);
-		
-		ThreadModel m = feat.selectThreadModel(polsess);
-		assertNotNull(m);
-		assertTrue(m instanceof PersistentThreadModel);
-		
-	}
-	
-	@Test
-	public void testSelectThreadModel_NotPersistent() throws Exception {
-		when(fact.getPolicyController(any())).thenReturn(polctlr);
-		assertNull(feat.selectThreadModel(polsess));
-		
-	}
-	
-	@Test
-	public void testSelectThreadModel_Start__Run_Update_Stop() throws Exception {
-		setUpKie("myname", 999L, true);
-		
-		ThreadModel m = feat.selectThreadModel(polsess);
-		assertNotNull(m);
-		assertTrue(m instanceof PersistentThreadModel);
-		
-		when(polsess.getKieSession()).thenReturn(kiesess);
-		
-		m.start();
-		new CountDownLatch(1).await(10, TimeUnit.MILLISECONDS);
-		m.updated();
-		m.stop();
-	}
+        verify(polcont).setAdjunct(any(), adjcap.capture());
 
-	@Test
-	public void testDisposeKieSession() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        setUpKie("myname2", 999L, false);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+        // invoke it again
+        feat.activatePolicySession(polcont, "myname2", "mybase");
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(fact, times(2)).makeEntMgrFact(any());
+    }
 
-		verify(emf, never()).close();
-		verify(polcont).setAdjunct(any(), adjcap.capture());
+    @Test
+    public void testSelectThreadModel_Persistent() throws Exception {
+        setUpKie("myname", 999L, true);
 
-		when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
+        ThreadModel model = feat.selectThreadModel(polsess);
+        assertNotNull(model);
+        assertTrue(model instanceof PersistentThreadModel);
+    }
 
-		feat.disposeKieSession(polsess);
+    @Test
+    public void testSelectThreadModel_NotPersistent() throws Exception {
+        when(fact.getPolicyController(any())).thenReturn(polctlr);
+        assertNull(feat.selectThreadModel(polsess));
+    }
 
-		// call twice to ensure it isn't re-closed
-		feat.disposeKieSession(polsess);
+    @Test
+    public void testSelectThreadModel_Start__Run_Update_Stop() throws Exception {
+        setUpKie("myname", 999L, true);
 
-		verify(emf, times(1)).close();
-	}
+        ThreadModel model = feat.selectThreadModel(polsess);
+        assertNotNull(model);
+        assertTrue(model instanceof PersistentThreadModel);
 
-	@Test
-	public void testDisposeKieSession_NoAdjunct() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        when(polsess.getKieSession()).thenReturn(kiesess);
 
-		feat.disposeKieSession(polsess);
-	}
+        model.start();
+        new CountDownLatch(1).await(10, TimeUnit.MILLISECONDS);
+        model.updated();
+        model.stop();
+    }
 
-	@Test
-	public void testDisposeKieSession_NoPersistence() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+    @Test
+    public void testDisposeKieSession() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        final ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		verify(emf, never()).close();
-		verify(polcont).setAdjunct(any(), adjcap.capture());
+        verify(emf, never()).close();
+        verify(polcont).setAdjunct(any(), adjcap.capture());
 
-		when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
+        when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
 
-		// specify a session that was never loaded
-		when(polsess.getName()).thenReturn("anotherName");
+        feat.disposeKieSession(polsess);
 
-		feat.disposeKieSession(polsess);
+        // call twice to ensure it isn't re-closed
+        feat.disposeKieSession(polsess);
 
-		verify(emf, never()).close();
-	}
+        verify(emf, times(1)).close();
+    }
 
-	@Test
-	public void testDestroyKieSession() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+    @Test
+    public void testDisposeKieSession_NoAdjunct() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        feat.disposeKieSession(polsess);
+    }
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+    @Test
+    public void testDisposeKieSession_NoPersistence() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        final ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		verify(emf, never()).close();
-		verify(polcont).setAdjunct(any(), adjcap.capture());
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		feat.destroyKieSession(polsess);
+        verify(emf, never()).close();
+        verify(polcont).setAdjunct(any(), adjcap.capture());
 
-		// call twice to ensure it isn't re-closed
-		feat.destroyKieSession(polsess);
+        when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
 
-		verify(emf, times(1)).close();
-	}
+        // specify a session that was never loaded
+        when(polsess.getName()).thenReturn("anotherName");
 
-	@Test
-	public void testDestroyKieSession_NoAdjunct() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.disposeKieSession(polsess);
 
-		feat.destroyKieSession(polsess);
-	}
+        verify(emf, never()).close();
+    }
 
-	@Test
-	public void testDestroyKieSession_NoPersistence() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+    @Test
+    public void testDestroyKieSession() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        final ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		verify(emf, never()).close();
-		verify(polcont).setAdjunct(any(), adjcap.capture());
+        verify(emf, never()).close();
+        verify(polcont).setAdjunct(any(), adjcap.capture());
 
-		when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
+        when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
 
-		// specify a session that was never loaded
-		when(polsess.getName()).thenReturn("anotherName");
+        feat.destroyKieSession(polsess);
 
-		feat.destroyKieSession(polsess);
+        // call twice to ensure it isn't re-closed
+        feat.destroyKieSession(polsess);
 
-		verify(emf, never()).close();
-	}
+        verify(emf, times(1)).close();
+    }
 
-	@Test
-	public void testAfterStart() {
-		assertFalse(feat.afterStart(null));
-	}
+    @Test
+    public void testDestroyKieSession_NoAdjunct() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-	@Test
-	public void testBeforeStart() {
-		assertFalse(feat.beforeStart(null));
-	}
+        feat.destroyKieSession(polsess);
+    }
 
-	@Test
-	public void testBeforeShutdown() {
-		assertFalse(feat.beforeShutdown(null));
-	}
+    @Test
+    public void testDestroyKieSession_NoPersistence() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-	@Test
-	public void testAfterShutdown() {
-		assertFalse(feat.afterShutdown(null));
-	}
+        final ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-	@Test
-	public void testBeforeConfigure() {
-		assertFalse(feat.beforeConfigure(null, null));
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-	@Test
-	public void testAfterConfigure() {
-		assertFalse(feat.afterConfigure(null));
-	}
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-	@Test
-	public void testBeforeActivate() {
-		assertFalse(feat.beforeActivate(null));
-	}
+        verify(emf, never()).close();
+        verify(polcont).setAdjunct(any(), adjcap.capture());
 
-	@Test
-	public void testAfterActivate() {
-		assertFalse(feat.afterActivate(null));
-	}
+        when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
 
-	@Test
-	public void testBeforeDeactivate() {
-		assertFalse(feat.beforeDeactivate(null));
-	}
+        // specify a session that was never loaded
+        when(polsess.getName()).thenReturn("anotherName");
 
-	@Test
-	public void testAfterDeactivate() {
-		assertFalse(feat.afterDeactivate(null));
-	}
+        feat.destroyKieSession(polsess);
+
+        verify(emf, never()).close();
+    }
+
+    @Test
+    public void testAfterStart() {
+        assertFalse(feat.afterStart(null));
+    }
+
+    @Test
+    public void testBeforeStart() {
+        assertFalse(feat.beforeStart(null));
+    }
+
+    @Test
+    public void testBeforeShutdown() {
+        assertFalse(feat.beforeShutdown(null));
+    }
+
+    @Test
+    public void testAfterShutdown() {
+        assertFalse(feat.afterShutdown(null));
+    }
+
+    @Test
+    public void testBeforeConfigure() {
+        assertFalse(feat.beforeConfigure(null, null));
+    }
+
+    @Test
+    public void testAfterConfigure() {
+        assertFalse(feat.afterConfigure(null));
+    }
+
+    @Test
+    public void testBeforeActivate() {
+        assertFalse(feat.beforeActivate(null));
+    }
+
+    @Test
+    public void testAfterActivate() {
+        assertFalse(feat.afterActivate(null));
+    }
+
+    @Test
+    public void testBeforeDeactivate() {
+        assertFalse(feat.beforeDeactivate(null));
+    }
+
+    @Test
+    public void testAfterDeactivate() {
+        assertFalse(feat.afterDeactivate(null));
+    }
+
+    @Test
+    public void testBeforeStop() {
+        assertFalse(feat.beforeStop(null));
+    }
+
+    @Test
+    public void testAfterStop() {
+        assertFalse(feat.afterStop(null));
+    }
+
+    @Test
+    public void testBeforeLock() {
+        assertFalse(feat.beforeLock(null));
+    }
+
+    @Test
+    public void testAfterLock() {
+        assertFalse(feat.afterLock(null));
+    }
+
+    @Test
+    public void testBeforeUnlock() {
+        assertFalse(feat.beforeUnlock(null));
+    }
+
+    @Test
+    public void testAfterUnlock() {
+        assertFalse(feat.afterUnlock(null));
+    }
 
-	@Test
-	public void testBeforeStop() {
-		assertFalse(feat.beforeStop(null));
-	}
+    @Test
+    public void testGetPersistenceTimeout_Valid() throws Exception {
+        final PreparedStatement statement = mockDbConn(5);
 
-	@Test
-	public void testAfterStop() {
-		assertFalse(feat.afterStop(null));
-	}
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-	@Test
-	public void testBeforeLock() {
-		assertFalse(feat.beforeLock(null));
-	}
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testAfterLock() {
-		assertFalse(feat.afterLock(null));
-	}
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-	@Test
-	public void testBeforeUnlock() {
-		assertFalse(feat.beforeUnlock(null));
-	}
+        verify(statement).executeUpdate();
+    }
 
-	@Test
-	public void testAfterUnlock() {
-		assertFalse(feat.afterUnlock(null));
-	}
+    @Test
+    public void testGetPersistenceTimeout_Missing() throws Exception {
 
-	@Test
-	public void testGetPersistenceTimeout_Valid() throws Exception {
-		PreparedStatement s = mockDbConn(5);
+        props.remove(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        final PreparedStatement statement = mockDbConn(0);
 
-		setUpKie("myname", 999L, true);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        setUpKie("myname", 999L, true);
 
-		verify(s).executeUpdate();
-	}
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-	@Test
-	public void testGetPersistenceTimeout_Missing() throws Exception {
+        verify(statement, never()).executeUpdate();
+    }
 
-		props.remove(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT);
+    @Test
+    public void testGetPersistenceTimeout_Invalid() throws Exception {
+        props.setProperty(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT, "abc");
+        final PreparedStatement s = mockDbConn(0);
 
-		PreparedStatement s = mockDbConn(0);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        setUpKie("myname", 999L, true);
 
-		setUpKie("myname", 999L, true);
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(s, never()).executeUpdate();
+    }
 
-		verify(s, never()).executeUpdate();
-	}
+    @Test
+    public void testCleanUpSessionInfo() throws Exception {
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testGetPersistenceTimeout_Invalid() throws Exception {
-		props.setProperty(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT, "abc");
-		PreparedStatement s = mockDbConn(0);
+        // use a real DB so we can verify that the "delete" works correctly
+        fact = new PartialFactory();
+        feat.setFactory(fact);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        makeSessionInfoTbl(20000);
 
-		setUpKie("myname", 999L, true);
+        // create mock entity manager for use by JPA connector
+        EntityManager em = mock(EntityManager.class);
+        when(emf.createEntityManager()).thenReturn(em);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		verify(s, never()).executeUpdate();
-	}
+        feat.beforeStart(null);
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-	@Test
-	public void testCleanUpSessionInfo() throws Exception {
-		setUpKie("myname", 999L, true);
+        assertEquals("[1, 4, 5]", getSessions().toString());
+    }
 
-		// use a real DB so we can verify that the "delete" works correctly
-		fact = new PartialFactory();
-		feat.setFactory(fact);
+    @Test
+    public void testCleanUpSessionInfo_WithBeforeStart() throws Exception {
+        final PreparedStatement statement = mockDbConn(0);
 
-		makeSessionInfoTbl(20000);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		// create mock entity manager for use by JPA connector
-		EntityManager em = mock(EntityManager.class);
-		when(emf.createEntityManager()).thenReturn(em);
+        setUpKie("myname", 999L, true);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        // reset
+        feat.beforeStart(null);
 
-		feat.beforeStart(null);
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(statement, times(1)).executeUpdate();
 
-		assertEquals("[1, 4, 5]", getSessions().toString());
-	}
+        // should not clean-up again
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(statement, times(1)).executeUpdate();
 
-	@Test
-	public void testCleanUpSessionInfo_WithBeforeStart() throws Exception {
-		PreparedStatement s = mockDbConn(0);
+        // reset
+        feat.beforeStart(null);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(statement, times(2)).executeUpdate();
 
-		setUpKie("myname", 999L, true);
+        // should not clean-up again
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(statement, times(2)).executeUpdate();
+    }
 
-		// reset
-		feat.beforeStart(null);
+    @Test
+    public void testCleanUpSessionInfo_WithBeforeActivate() throws Exception {
+        final PreparedStatement statement = mockDbConn(0);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		verify(s, times(1)).executeUpdate();
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		// should not clean-up again
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		verify(s, times(1)).executeUpdate();
+        setUpKie("myname", 999L, true);
 
-		// reset
-		feat.beforeStart(null);
+        // reset
+        feat.beforeActivate(null);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		verify(s, times(2)).executeUpdate();
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(statement, times(1)).executeUpdate();
 
-		// should not clean-up again
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		verify(s, times(2)).executeUpdate();
-	}
+        // should not clean-up again
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(statement, times(1)).executeUpdate();
 
-	@Test
-	public void testCleanUpSessionInfo_WithBeforeActivate() throws Exception {
-		PreparedStatement s = mockDbConn(0);
+        // reset
+        feat.beforeActivate(null);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(statement, times(2)).executeUpdate();
 
-		setUpKie("myname", 999L, true);
+        // should not clean-up again
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(statement, times(2)).executeUpdate();
+    }
 
-		// reset
-		feat.beforeActivate(null);
+    @Test
+    public void testCleanUpSessionInfo_NoTimeout() throws Exception {
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		verify(s, times(1)).executeUpdate();
+        props.remove(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT);
 
-		// should not clean-up again
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		verify(s, times(1)).executeUpdate();
+        final PreparedStatement statement = mockDbConn(0);
 
-		// reset
-		feat.beforeActivate(null);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		verify(s, times(2)).executeUpdate();
+        setUpKie("myname", 999L, true);
 
-		// should not clean-up again
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		feat.activatePolicySession(polcont, "myname", "mybase");
-		verify(s, times(2)).executeUpdate();
-	}
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-	@Test
-	public void testCleanUpSessionInfo_NoTimeout() throws Exception {
+        verify(statement, never()).executeUpdate();
+    }
 
-		props.remove(DroolsPersistenceProperties.DB_SESSIONINFO_TIMEOUT);
+    @Test
+    public void testCleanUpSessionInfo_NoUrl() throws Exception {
+        final PreparedStatement statement = mockDbConn(0);
 
-		PreparedStatement s = mockDbConn(0);
+        props.remove(DroolsPersistenceProperties.DB_URL);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		setUpKie("myname", 999L, true);
+        setUpKie("myname", 999L, true);
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        try {
+            feat.activatePolicySession(polcont, "myname", "mybase");
+            fail("missing exception");
+        } catch (RuntimeException e) {
+            logger.trace("expected exception", e);
+        }
 
-		verify(s, never()).executeUpdate();
-	}
+        verify(statement, never()).executeUpdate();
+    }
 
-	@Test
-	public void testCleanUpSessionInfo_NoUrl() throws Exception {
-		PreparedStatement s = mockDbConn(0);
+    @Test
+    public void testCleanUpSessionInfo_NoUser() throws Exception {
+        final PreparedStatement statement = mockDbConn(0);
 
-		props.remove(DroolsPersistenceProperties.DB_URL);
+        props.remove(DroolsPersistenceProperties.DB_USER);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		setUpKie("myname", 999L, true);
+        setUpKie("myname", 999L, true);
 
-		try {
-			feat.activatePolicySession(polcont, "myname", "mybase");
-			fail("missing exception");
-		} catch (RuntimeException e) {
-			logger.trace("expected exception", e);
-		}
+        try {
+            feat.activatePolicySession(polcont, "myname", "mybase");
+            fail("missing exception");
+        } catch (RuntimeException e) {
+            logger.trace("expected exception", e);
+        }
 
-		verify(s, never()).executeUpdate();
-	}
+        verify(statement, never()).executeUpdate();
+    }
 
-	@Test
-	public void testCleanUpSessionInfo_NoUser() throws Exception {
-		PreparedStatement s = mockDbConn(0);
+    @Test
+    public void testCleanUpSessionInfo_NoPassword() throws Exception {
+        final PreparedStatement statement = mockDbConn(0);
 
-		props.remove(DroolsPersistenceProperties.DB_USER);
+        props.remove(DroolsPersistenceProperties.DB_PWD);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		setUpKie("myname", 999L, true);
+        setUpKie("myname", 999L, true);
 
-		try {
-			feat.activatePolicySession(polcont, "myname", "mybase");
-			fail("missing exception");
-		} catch (RuntimeException e) {
-			logger.trace("expected exception", e);
-		}
+        try {
+            feat.activatePolicySession(polcont, "myname", "mybase");
+            fail("missing exception");
+        } catch (RuntimeException e) {
+            logger.trace("expected exception", e);
+        }
 
-		verify(s, never()).executeUpdate();
-	}
+        verify(statement, never()).executeUpdate();
+    }
 
-	@Test
-	public void testCleanUpSessionInfo_NoPassword() throws Exception {
-		PreparedStatement s = mockDbConn(0);
+    @Test
+    public void testCleanUpSessionInfo_SqlEx() throws Exception {
+        final PreparedStatement statement = mockDbConn(-1);
 
-		props.remove(DroolsPersistenceProperties.DB_PWD);
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        setUpKie("myname", 999L, true);
 
-		setUpKie("myname", 999L, true);
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		try {
-			feat.activatePolicySession(polcont, "myname", "mybase");
-			fail("missing exception");
-		} catch (RuntimeException e) {
-			logger.trace("expected exception", e);
-		}
+        verify(statement).executeUpdate();
+    }
 
-		verify(s, never()).executeUpdate();
-	}
+    @Test
+    public void testGetDroolsSessionConnector() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-	@Test
-	public void testCleanUpSessionInfo_SqlEx() throws Exception {
-		PreparedStatement s = mockDbConn(-1);
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		setUpKie("myname", 999L, true);
+        verify(fact).makeJpaConnector(emf);
+    }
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+    @Test
+    public void testReplaceSession() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		verify(s).executeUpdate();
-	}
+        final ArgumentCaptor<DroolsSession> sesscap = ArgumentCaptor.forClass(DroolsSession.class);
 
-	@Test
-	public void testGetDroolsSessionConnector() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        verify(jpa).replace(sesscap.capture());
 
-		verify(fact).makeJpaConnector(emf);
-	}
+        assertEquals("myname", sesscap.getValue().getSessionName());
+        assertEquals(999L, sesscap.getValue().getSessionId());
+    }
 
-	@Test
-	public void testReplaceSession() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+    @Test
+    public void testIsPersistenceEnabled_Auto() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		ArgumentCaptor<DroolsSession> sesscap = ArgumentCaptor.forClass(DroolsSession.class);
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        props.setProperty("persistence.type", "auto");
 
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        assertNotNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		verify(jpa).replace(sesscap.capture());
+    @Test
+    public void testIsPersistenceEnabled_Native() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertEquals("myname", sesscap.getValue().getSessionName());
-		assertEquals(999L, sesscap.getValue().getSessionId());
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testIsPersistenceEnabled_Auto() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        props.setProperty("persistence.type", "native");
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        assertNotNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		props.setProperty("persistence.type", "auto");
+    @Test
+    public void testIsPersistenceEnabled_None() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertNotNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testIsPersistenceEnabled_Native() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        props.remove("persistence.type");
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		props.setProperty("persistence.type", "native");
+    @Test
+    public void testGetProperties_Ex() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertNotNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testIsPersistenceEnabled_None() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        when(fact.getPolicyController(polcont))
+            .thenThrow(new IllegalArgumentException("expected exception"));
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		props.remove("persistence.type");
+    @Test
+    public void testGetProperty_Specific() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testGetProperties_Ex() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        props.remove("persistence.type");
+        props.setProperty("persistence.myname.type", "auto");
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        assertNotNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		when(fact.getPolicyController(polcont)).thenThrow(new IllegalArgumentException("expected exception"));
+    @Test
+    public void testGetProperty_Specific_None() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testGetProperty_Specific() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        props.remove("persistence.type");
+        props.setProperty("persistence.xxx.type", "auto");
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		props.remove("persistence.type");
-		props.setProperty("persistence.myname.type", "auto");
+    @Test
+    public void testGetProperty_Both_SpecificOn() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertNotNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testGetProperty_Specific_None() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        props.setProperty("persistence.type", "other");
+        props.setProperty("persistence.myname.type", "auto");
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        assertNotNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		props.remove("persistence.type");
-		props.setProperty("persistence.xxx.type", "auto");
+    @Test
+    public void testGetProperty_Both_SpecificDisabledOff() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testGetProperty_Both_SpecificOn() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        props.setProperty("persistence.type", "auto");
+        props.setProperty("persistence.myname.type", "other");
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		props.setProperty("persistence.type", "other");
-		props.setProperty("persistence.myname.type", "auto");
+    @Test
+    public void testGetProperty_None() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		assertNotNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, true);
 
-	@Test
-	public void testGetProperty_Both_SpecificDisabledOff() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        props.remove("persistence.type");
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
+    }
 
-		props.setProperty("persistence.type", "auto");
-		props.setProperty("persistence.myname.type", "other");
+    @Test
+    public void testPersistenceFeatureException() {
+        SecurityException secex = new SecurityException("expected exception");
+        PersistenceFeatureException ex = new PersistenceFeatureException(secex);
 
-		assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        assertEquals(secex, ex.getCause());
+    }
 
-	@Test
-	public void testGetProperty_None() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+    @Test
+    public void testDsEmf_RtEx() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, true);
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		props.remove("persistence.type");
+        when(fact.makeEntMgrFact(any())).thenThrow(new IllegalArgumentException("expected exception"));
 
-		assertNull(feat.activatePolicySession(polcont, "myname", "mybase"));
-	}
+        try {
+            feat.activatePolicySession(polcont, "myname", "mybase");
+            fail("missing exception");
 
-	@Test
-	public void testPersistenceFeatureException() {
-		SecurityException secex = new SecurityException("expected exception");
-		PersistenceFeatureException ex = new PersistenceFeatureException(secex);
+        } catch (IllegalArgumentException ex) {
+            logger.trace("expected exception", ex);
+        }
 
-		assertEquals(secex, ex.getCause());
+        verify(bds, times(2)).close();
+    }
 
-	}
+    @Test
+    public void testDsEmf_Close_RtEx() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-	@Test
-	public void testDsEmf_RtEx() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
-		
-		when(fact.makeEntMgrFact(any())).thenThrow(new IllegalArgumentException("expected exception"));
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		try {
-			feat.activatePolicySession(polcont, "myname", "mybase");
-			fail("missing exception");
-			
-		} catch(IllegalArgumentException ex) {
-			logger.trace("expected exception", ex);
-		}
+        ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		verify(bds, times(2)).close();
-	}
+        verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
 
-	@Test
-	public void testDsEmf_Close_RtEx() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        // return adjunct on next call
+        when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
-		
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        try {
+            doThrow(new IllegalArgumentException("expected exception")).when(emf).close();
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+            feat.destroyKieSession(polsess);
+            fail("missing exception");
 
-		verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
+        } catch (IllegalArgumentException ex) {
+            logger.trace("expected exception", ex);
+        }
 
-		// return adjunct on next call
-		when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
+        verify(bds, times(2)).close();
+    }
 
-		try {
-			doThrow(new IllegalArgumentException("expected exception")).when(emf).close();
-			
-			feat.destroyKieSession(polsess);
-			fail("missing exception");
-			
-		} catch(IllegalArgumentException ex) {
-			logger.trace("expected exception", ex);
-		}
+    @Test
+    public void testDsEmf_CloseDataSource_RtEx() throws Exception {
+        feat.globalInit(null, SRC_TEST_RESOURCES);
 
-		verify(bds, times(2)).close();
-	}
+        mockDbConn(5);
+        setUpKie("myname", 999L, false);
 
-	@Test
-	public void testDsEmf_CloseDataSource_RtEx() throws Exception {
-		feat.globalInit(null, SRC_TEST_RESOURCES);
+        feat.activatePolicySession(polcont, "myname", "mybase");
 
-		mockDbConn(5);
-		setUpKie("myname", 999L, false);
-		
-		feat.activatePolicySession(polcont, "myname", "mybase");
+        ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap =
+                ArgumentCaptor.forClass(PersistenceFeature.ContainerAdjunct.class);
 
-		ArgumentCaptor<PersistenceFeature.ContainerAdjunct> adjcap = ArgumentCaptor
-				.forClass(PersistenceFeature.ContainerAdjunct.class);
+        verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
 
-		verify(polcont, times(1)).setAdjunct(any(), adjcap.capture());
+        // return adjunct on next call
+        when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
 
-		// return adjunct on next call
-		when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue());
+        try {
+            doThrow(new SQLException("expected exception")).when(bds).close();
 
-		try {
-			doThrow(new SQLException("expected exception")).when(bds).close();
-			
-			feat.destroyKieSession(polsess);
-			fail("missing exception");
-			
-		} catch(PersistenceFeatureException ex) {
-			logger.trace("expected exception", ex);
-		}
-	}
+            feat.destroyKieSession(polsess);
+            fail("missing exception");
 
-	/**
-	 * Gets an ordered list of ids of the current SessionInfo records.
-	 * 
-	 * @return ordered list of SessInfo IDs
-	 * @throws SQLException
-	 * @throws IOException
-	 */
-	private List<Integer> getSessions() throws SQLException, IOException {
-		attachDb();
+        } catch (PersistenceFeatureException ex) {
+            logger.trace("expected exception", ex);
+        }
+    }
 
-		ArrayList<Integer> lst = new ArrayList<>(5);
+    /**
+     * Gets an ordered list of ids of the current SessionInfo records.
+     *
+     * @return ordered list of SessInfo IDs
+     * @throws SQLException sql exception
+     * @throws IOException io exception
+     */
+    private List<Integer> getSessions() throws SQLException, IOException {
+        attachDb();
 
-		try (PreparedStatement stmt = conn.prepareStatement("SELECT id from sessioninfo order by id");
-				ResultSet rs = stmt.executeQuery()) {
+        ArrayList<Integer> lst = new ArrayList<>(5);
 
-			while (rs.next()) {
-				lst.add(rs.getInt(1));
-			}
-		}
+        try (PreparedStatement stmt = conn.prepareStatement("SELECT id from sessioninfo order by id");
+                ResultSet rs = stmt.executeQuery()) {
 
-		return lst;
-	}
+            while (rs.next()) {
+                lst.add(rs.getInt(1));
+            }
+        }
 
-	/**
-	 * Sets up for doing invoking the newKieSession() method.
-	 * 
-	 * @param sessnm
-	 *            name to which JPA should respond with a session
-	 * @param sessid
-	 *            session id to be returned by the session
-	 * @param loadOk
-	 *            {@code true} if loadKieSession() should return a value,
-	 *            {@code false} to return null
-	 * @throws Exception 
-	 */
-	private void setUpKie(String sessnm, long sessid, boolean loadOk) throws Exception {
+        return lst;
+    }
 
-		when(fact.makeJpaConnector(emf)).thenReturn(jpa);
-		when(fact.makeEntMgrFact(any())).thenReturn(emf);
-		when(fact.getPolicyController(polcont)).thenReturn(polctlr);
+    /**
+     * Sets up for doing invoking the newKieSession() method.
+     *
+     * @param sessnm name to which JPA should respond with a session
+     * @param sessid session id to be returned by the session
+     * @param loadOk {@code true} if loadKieSession() should return a value, {@code false} to return
+     *     null
+     * @throws Exception exception
+     */
+    private void setUpKie(String sessnm, long sessid, boolean loadOk) throws Exception {
 
-		props.setProperty("persistence.type", "auto");
+        when(fact.makeJpaConnector(emf)).thenReturn(jpa);
+        when(fact.makeEntMgrFact(any())).thenReturn(emf);
+        when(fact.getPolicyController(polcont)).thenReturn(polctlr);
 
-		when(polctlr.getProperties()).thenReturn(props);
+        props.setProperty("persistence.type", "auto");
 
-		when(jpa.get(sessnm)).thenReturn(sess);
+        when(polctlr.getProperties()).thenReturn(props);
 
-		when(sess.getSessionId()).thenReturn(sessid);
+        when(jpa.get(sessnm)).thenReturn(sess);
 
-		when(polsess.getPolicyContainer()).thenReturn(polcont);
-		when(polsess.getName()).thenReturn(sessnm);
+        when(sess.getSessionId()).thenReturn(sessid);
 
-		if (loadOk) {
-			when(kiesess.getIdentifier()).thenReturn(sessid);
-			when(kiestore.loadKieSession(anyLong(), any(), any(), any())).thenReturn(kiesess);
+        when(polsess.getPolicyContainer()).thenReturn(polcont);
+        when(polsess.getName()).thenReturn(sessnm);
 
-		} else {
-			// use an alternate id for the new session
-			when(kiesess.getIdentifier()).thenReturn(100L);
-			when(kiestore.loadKieSession(anyLong(), any(), any(), any())).thenReturn(null);
-		}
+        if (loadOk) {
+            when(kiesess.getIdentifier()).thenReturn(sessid);
+            when(kiestore.loadKieSession(anyLong(), any(), any(), any())).thenReturn(kiesess);
 
-		when(kiestore.newKieSession(any(), any(), any())).thenReturn(kiesess);
-	}
+        } else {
+            // use an alternate id for the new session
+            when(kiesess.getIdentifier()).thenReturn(100L);
+            when(kiestore.loadKieSession(anyLong(), any(), any(), any())).thenReturn(null);
+        }
 
-	/**
-	 * Creates the SessionInfo DB table and populates it with some data.
-	 * 
-	 * @param expMs
-	 *            number of milli-seconds for expired sessioninfo records
-	 * @throws SQLException
-	 * @throws IOException
-	 */
-	private void makeSessionInfoTbl(int expMs) throws SQLException, IOException {
+        when(kiestore.newKieSession(any(), any(), any())).thenReturn(kiesess);
+    }
 
-		attachDb();
+    /**
+     * Creates the SessionInfo DB table and populates it with some data.
+     *
+     * @param expMs number of milli-seconds for expired sessioninfo records
+     * @throws SQLException exception
+     * @throws IOException exception
+     */
+    private void makeSessionInfoTbl(int expMs) throws SQLException, IOException {
 
-		try (PreparedStatement stmt = conn
-				.prepareStatement("CREATE TABLE sessioninfo(id int, lastmodificationdate timestamp)")) {
+        attachDb();
 
-			stmt.executeUpdate();
-		}
+        try (PreparedStatement stmt =
+                conn.prepareStatement("CREATE TABLE sessioninfo(id int, lastmodificationdate timestamp)")) {
 
-		try (PreparedStatement stmt = conn
-				.prepareStatement("INSERT into sessioninfo(id, lastmodificationdate) values(?, ?)")) {
+            stmt.executeUpdate();
+        }
 
-			Timestamp ts;
+        try (PreparedStatement stmt =
+                conn.prepareStatement("INSERT into sessioninfo(id, lastmodificationdate) values(?, ?)")) {
 
-			// current data
-			ts = new Timestamp(System.currentTimeMillis());
-			stmt.setTimestamp(2, ts);
+            Timestamp ts;
 
-			stmt.setInt(1, 1);
-			stmt.executeUpdate();
+            // current data
+            ts = new Timestamp(System.currentTimeMillis());
+            stmt.setTimestamp(2, ts);
 
-			stmt.setInt(1, 4);
-			stmt.executeUpdate();
+            stmt.setInt(1, 1);
+            stmt.executeUpdate();
 
-			stmt.setInt(1, 5);
-			stmt.executeUpdate();
+            stmt.setInt(1, 4);
+            stmt.executeUpdate();
 
-			// expired data
-			ts = new Timestamp(System.currentTimeMillis() - expMs);
-			stmt.setTimestamp(2, ts);
+            stmt.setInt(1, 5);
+            stmt.executeUpdate();
 
-			stmt.setInt(1, 2);
-			stmt.executeUpdate();
+            // expired data
+            ts = new Timestamp(System.currentTimeMillis() - expMs);
+            stmt.setTimestamp(2, ts);
 
-			stmt.setInt(1, 3);
-			stmt.executeUpdate();
-		}
-	}
+            stmt.setInt(1, 2);
+            stmt.executeUpdate();
 
-	/**
-	 * Attaches {@link #conn} to the DB, if it isn't already attached.
-	 * 
-	 * @throws SQLException
-	 * @throws IOException
-	 *             if the property file cannot be read
-	 */
-	private void attachDb() throws SQLException, IOException {
-		if (conn == null) {
-			Properties p = loadDbProps();
+            stmt.setInt(1, 3);
+            stmt.executeUpdate();
+        }
+    }
 
-			conn = DriverManager.getConnection(p.getProperty(DroolsPersistenceProperties.DB_URL),
-					p.getProperty(DroolsPersistenceProperties.DB_USER),
-					p.getProperty(DroolsPersistenceProperties.DB_PWD));
-			conn.setAutoCommit(true);
-		}
-	}
+    /**
+     * Attaches {@link #conn} to the DB, if it isn't already attached.
+     *
+     * @throws SQLException sql exception
+     * @throws IOException if the property file cannot be read
+     */
+    private void attachDb() throws SQLException, IOException {
+        if (conn == null) {
+            Properties props = loadDbProps();
 
-	/**
-	 * Loads the DB properties from the file,
-	 * <i>feature-session-persistence.properties</i>.
-	 * 
-	 * @return the properties that were loaded
-	 * @throws IOException
-	 *             if the property file cannot be read
-	 * @throws FileNotFoundException
-	 *             if the property file does not exist
-	 */
-	private Properties loadDbProps() throws IOException, FileNotFoundException {
+            conn =
+                    DriverManager.getConnection(
+                            props.getProperty(DroolsPersistenceProperties.DB_URL),
+                            props.getProperty(DroolsPersistenceProperties.DB_USER),
+                            props.getProperty(DroolsPersistenceProperties.DB_PWD));
+            conn.setAutoCommit(true);
+        }
+    }
 
-		Properties p = new Properties();
+    /**
+     * Loads the DB properties from the file, <i>feature-session-persistence.properties</i>.
+     *
+     * @return the properties that were loaded
+     * @throws IOException if the property file cannot be read
+     * @throws FileNotFoundException if the property file does not exist
+     */
+    private Properties loadDbProps() throws IOException, FileNotFoundException {
 
-		try (FileReader rdr = new FileReader("src/test/resources/feature-session-persistence.properties")) {
-			p.load(rdr);
-		}
+        Properties props = new Properties();
 
-		return p;
-	}
+        try (FileReader rdr =
+                new FileReader("src/test/resources/feature-session-persistence.properties")) {
+            props.load(rdr);
+        }
 
-	/**
-	 * Create a mock DB connection and statement.
-	 * 
-	 * @param retval
-	 *            value to be returned when the statement is executed, or
-	 *            negative to throw an exception
-	 * @return the statement that will be returned by the connection
-	 * @throws SQLException
-	 */
-	private PreparedStatement mockDbConn(int retval) throws SQLException {
-		Connection c = mock(Connection.class);
-		PreparedStatement s = mock(PreparedStatement.class);
+        return props;
+    }
 
-		when(bds.getConnection()).thenReturn(c);
-		when(fact.makeDataSource(any())).thenReturn(bds);
-		when(c.prepareStatement(anyString())).thenReturn(s);
+    /**
+     * Create a mock DB connection and statement.
+     *
+     * @param retval value to be returned when the statement is executed, or negative to throw an
+     *     exception
+     * @return the statement that will be returned by the connection
+     * @throws SQLException sql exception
+     */
+    private PreparedStatement mockDbConn(int retval) throws SQLException {
+        Connection connection = mock(Connection.class);
+        PreparedStatement statement = mock(PreparedStatement.class);
 
-		if (retval < 0) {
-			// should throw an exception
-			when(s.executeUpdate()).thenThrow(new SQLException("expected exception"));
+        when(bds.getConnection()).thenReturn(connection);
+        when(fact.makeDataSource(any())).thenReturn(bds);
+        when(connection.prepareStatement(anyString())).thenReturn(statement);
 
-		} else {
-			// should return the value
-			when(s.executeUpdate()).thenReturn(retval);
-		}
+        if (retval < 0) {
+            // should throw an exception
+            when(statement.executeUpdate()).thenThrow(new SQLException("expected exception"));
 
-		return s;
-	}
+        } else {
+            // should return the value
+            when(statement.executeUpdate()).thenReturn(retval);
+        }
 
-	/**
-	 * A partial factory, which exports a few of the real methods, but overrides
-	 * the rest.
-	 */
-	private class PartialFactory extends PersistenceFeature.Factory {
+        return statement;
+    }
 
-		@Override
-		public TransactionManager getTransMgr() {
-			return transmgr;
-		}
+    /** A partial factory, which exports a few of the real methods, but overrides the rest. */
+    private class PartialFactory extends PersistenceFeature.Factory {
 
-		@Override
-		public UserTransaction getUserTrans() {
-			return usertrans;
-		}
+        @Override
+        public TransactionManager getTransMgr() {
+            return transmgr;
+        }
 
-		@Override
-		public TransactionSynchronizationRegistry getTransSyncReg() {
-			return transreg;
-		}
+        @Override
+        public UserTransaction getUserTrans() {
+            return usertrans;
+        }
 
-		@Override
-		public KieServices getKieServices() {
-			return kiesvc;
-		}
+        @Override
+        public TransactionSynchronizationRegistry getTransSyncReg() {
+            return transreg;
+        }
 
-		@Override
-		public EntityManagerFactory makeEntMgrFact(Map<String, Object> props) {
-			return emf;
-		}
+        @Override
+        public KieServices getKieServices() {
+            return kiesvc;
+        }
 
-		@Override
-		public PolicyController getPolicyController(PolicyContainer container) {
-			return polctlr;
-		}
+        @Override
+        public EntityManagerFactory makeEntMgrFact(Map<String, Object> props) {
+            return emf;
+        }
 
-	}
+        @Override
+        public PolicyController getPolicyController(PolicyContainer container) {
+            return polctlr;
+        }
+    }
 }
diff --git a/feature-session-persistence/src/test/resources/META-INF/persistence.xml b/feature-session-persistence/src/test/resources/META-INF/persistence.xml
index 5cc1bad..0fc695d 100644
--- a/feature-session-persistence/src/test/resources/META-INF/persistence.xml
+++ b/feature-session-persistence/src/test/resources/META-INF/persistence.xml
@@ -3,7 +3,7 @@
   ============LICENSE_START=======================================================
   feature-session-persistence
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-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.
@@ -20,15 +20,19 @@
   -->
 
 <persistence version="2.1"
-	xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
 
-	<persistence-unit name="junitDroolsSessionEntityPU" transaction-type="JTA">
-		<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
-		<class>org.onap.policy.drools.persistence.DroolsSessionEntity</class>
-		<properties>
-			<property name="javax.persistence.schema-generation.database.action" value="create"/>
+    <persistence-unit name="junitDroolsSessionEntityPU"
+        transaction-type="JTA">
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+        <class>org.onap.policy.drools.persistence.DroolsSessionEntity</class>
+        <properties>
+            <property
+                name="javax.persistence.schema-generation.database.action"
+                value="create" />
         </properties>
-	</persistence-unit>
+    </persistence-unit>
 
 </persistence>
diff --git a/feature-session-persistence/src/test/resources/logback-test.xml b/feature-session-persistence/src/test/resources/logback-test.xml
index 6e919eb..7f15117 100644
--- a/feature-session-persistence/src/test/resources/logback-test.xml
+++ b/feature-session-persistence/src/test/resources/logback-test.xml
@@ -2,7 +2,7 @@
   ============LICENSE_START=======================================================
   feature-session-persistence
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-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.
@@ -22,25 +22,28 @@
 
 <configuration>
 
-	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
-		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
-			<Pattern>
-				%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
-			</Pattern>
-		</encoder>
-	</appender>
-	<appender name="FILE" class="ch.qos.logback.core.FileAppender">
-		<file>logs/debug.log</file>
-		<encoder>
-			<Pattern>
-				%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
-			</Pattern>
-		</encoder>
-	</appender>
-	
-	<root level="debug">
-		<appender-ref ref="STDOUT" />
-		<appender-ref ref="FILE" />
-	</root>
+    <appender name="STDOUT"
+        class="ch.qos.logback.core.ConsoleAppender">
+        <encoder
+            class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <Pattern>
+                %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+            </Pattern>
+        </encoder>
+    </appender>
+    <appender name="FILE"
+        class="ch.qos.logback.core.FileAppender">
+        <file>logs/debug.log</file>
+        <encoder>
+            <Pattern>
+                %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+            </Pattern>
+        </encoder>
+    </appender>
+
+    <root level="debug">
+        <appender-ref ref="STDOUT" />
+        <appender-ref ref="FILE" />
+    </root>
 
 </configuration>
diff --git a/feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java b/feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java
index 4470089..5e7861d 100644
--- a/feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java
+++ b/feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java
@@ -22,11 +22,10 @@
 
 import java.io.IOException;
 import java.util.Map;
+import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-import java.util.function.Function;
-import java.util.concurrent.BlockingQueue;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.Consumes;
@@ -44,96 +43,111 @@
 
 @Path("/events")
 public class DMaaPSimulatorJaxRs {
-	private static final String NO_DATA_MSG = "No Data";
-	private static final Map<String, BlockingQueue<String>> queues = new ConcurrentHashMap<>();
-	private static final Logger logger = LoggerFactory.getLogger(DMaaPSimulatorJaxRs.class);
-	private static int responseCode = 200;
+    private static final String NO_DATA_MSG = "No Data";
+    private static final Map<String, BlockingQueue<String>> queues = new ConcurrentHashMap<>();
+    private static final Logger logger = LoggerFactory.getLogger(DMaaPSimulatorJaxRs.class);
+    private static int responseCode = 200;
 
-	@GET
-	@Path("/{topicName}/{consumeGroup}/{consumerId}")
-	public String subscribe(@DefaultValue("0") @QueryParam("timeout") int timeout, @PathParam("topicName") String topicName,
-			@Context final HttpServletResponse httpResponse) {
-		int currentRespCode = responseCode;
-		httpResponse.setStatus(currentRespCode);
-		try {
-			httpResponse.flushBuffer();
-		} catch (IOException e) {
-			logger.error("flushBuffer threw: ", e);
-			return "Got an error";
-		}
+    /**
+     * Get consumer ID.
+     * 
+     * @param timeout timeout value
+     * @param topicName the dmaap topic
+     * @param httpResponse http response object
+     * @return topic or error message
+     */
+    @GET
+    @Path("/{topicName}/{consumeGroup}/{consumerId}")
+    public String subscribe(@DefaultValue("0") @QueryParam("timeout") int timeout, @PathParam("topicName") 
+            String topicName, @Context final HttpServletResponse httpResponse) {
+        int currentRespCode = responseCode;
+        httpResponse.setStatus(currentRespCode);
+        try {
+            httpResponse.flushBuffer();
+        } catch (IOException e) {
+            logger.error("flushBuffer threw: ", e);
+            return "Got an error";
+        }
 
-		if (currentRespCode < 200 || currentRespCode >= 300)
-		{
-			return "You got response code: " + currentRespCode;
-		}
+        if (currentRespCode < 200 || currentRespCode >= 300) {
+            return "You got response code: " + currentRespCode;
+        }
 
-		if (queues.containsKey(topicName)) {
-			return getNextMessageFromQueue(timeout, topicName);
-		}
-		else if (timeout > 0) {
-			return waitForNextMessageFromQueue(timeout, topicName);
-		}
-		return "No topic";
-	}
+        if (queues.containsKey(topicName)) {
+            return getNextMessageFromQueue(timeout, topicName);
+        }
+        else if (timeout > 0) {
+            return waitForNextMessageFromQueue(timeout, topicName);
+        }
+        return "No topic";
+    }
 
-	private String getNextMessageFromQueue(final int timeout, final String topicName) {
-		BlockingQueue<String> queue = queues.get(topicName);
-		String response = NO_DATA_MSG;
-		try {
-			response = queue.poll(timeout, TimeUnit.MILLISECONDS);
-		} catch (InterruptedException e) {
-			logger.debug("error in DMaaP simulator", e);
-			Thread.currentThread().interrupt();
-		}
-		if (response == null) {
-			response = NO_DATA_MSG;
-		}
-		return response;
-	}
+    private String getNextMessageFromQueue(final int timeout, final String topicName) {
+        BlockingQueue<String> queue = queues.get(topicName);
+        String response = NO_DATA_MSG;
+        try {
+            response = queue.poll(timeout, TimeUnit.MILLISECONDS);
+        } catch (InterruptedException e) {
+            logger.debug("error in DMaaP simulator", e);
+            Thread.currentThread().interrupt();
+        }
+        if (response == null) {
+            response = NO_DATA_MSG;
+        }
+        return response;
+    }
 
-	private String waitForNextMessageFromQueue(int timeout, String topicName) {
-		try {
-			Thread.sleep(timeout);
-			if (queues.containsKey(topicName)) {
-				BlockingQueue<String> queue = queues.get(topicName);
-				String response = queue.poll();
-				if (response == null) {
-					response = NO_DATA_MSG;
-				}
-				return response;
-			}
-		} catch (InterruptedException e) {
-			logger.debug("error in DMaaP simulator", e);
-			Thread.currentThread().interrupt();
-		}
-		return "No topic";
-	}
+    private String waitForNextMessageFromQueue(int timeout, String topicName) {
+        try {
+            Thread.sleep(timeout);
+            if (queues.containsKey(topicName)) {
+                BlockingQueue<String> queue = queues.get(topicName);
+                String response = queue.poll();
+                if (response == null) {
+                    response = NO_DATA_MSG;
+                }
+                return response;
+            }
+        } catch (InterruptedException e) {
+            logger.debug("error in DMaaP simulator", e);
+            Thread.currentThread().interrupt();
+        }
+        return "No topic";
+    }
 
-	@POST
-	@Path("/{topicName}")
-	@Consumes(MediaType.TEXT_PLAIN)
-	public String publish(@PathParam("topicName") String topicName, String body) {
-		BlockingQueue<String> queue = queues.computeIfAbsent(topicName, entry -> new LinkedBlockingQueue<>());
-		
-		if (!queue.offer(body)) {
-			logger.warn("error on topic {}, failed to place body {} on queue", topicName, body);
-		}
+    /**
+     * Post to a topic.
+     * 
+     * @param topicName name of the topic
+     * @param body message
+     * @return empty string
+     */
+    @POST
+    @Path("/{topicName}")
+    @Consumes(MediaType.TEXT_PLAIN)
+    public String publish(@PathParam("topicName") String topicName, String body) {
+        BlockingQueue<String> queue = queues.computeIfAbsent(topicName, entry -> new LinkedBlockingQueue<>());
 
-		return "";
-	}
+        if (!queue.offer(body)) {
+            logger.warn("error on topic {}, failed to place body {} on queue", topicName, body);
+        }
 
-	@POST
-	@Path("/setStatus")
-	public String setStatus(@QueryParam("statusCode") int statusCode) {
-		setResponseCode(statusCode);
-		return "Status code set";
-	}
+        return "";
+    }
 
-	/**
-	 * Static method to set static response code, synchronized for multiple possible uses
-	 * @param incomingResponseCode
-	 */
-	private static synchronized void setResponseCode(final int incomingResponseCode) {
-		responseCode = incomingResponseCode; 
-	}
+    @POST
+    @Path("/setStatus")
+    public String setStatus(@QueryParam("statusCode") int statusCode) {
+        setResponseCode(statusCode);
+        return "Status code set";
+    }
+
+    /**
+     * Static method to set static response code, synchronized for multiple possible uses.
+     * 
+     * @param incomingResponseCode the response code to set
+     */
+    private static synchronized void setResponseCode(final int incomingResponseCode) {
+        responseCode = incomingResponseCode; 
+    }
 }
diff --git a/feature-simulators/src/test/java/org/onap/policy/drools/simulators/DMaaPSimulatorTest.java b/feature-simulators/src/test/java/org/onap/policy/drools/simulators/DMaaPSimulatorTest.java
index 1a19284..2a84952 100644
--- a/feature-simulators/src/test/java/org/onap/policy/drools/simulators/DMaaPSimulatorTest.java
+++ b/feature-simulators/src/test/java/org/onap/policy/drools/simulators/DMaaPSimulatorTest.java
@@ -44,6 +44,9 @@
 
     private static final int DMAAPSIM_SERVER_PORT = 6670;
 
+    /**
+     * Setup the simulator.
+     */
     @BeforeClass
     public static void setUpSimulator() {
         LoggerUtil.setLevel("ROOT", "INFO");
@@ -71,8 +74,8 @@
         int timeout = 1000;
         Pair<Integer, String> response = dmaapGet("myTopicNoData", timeout);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals("No topic", response.b);
+        assertNotNull(response.first);
+        assertEquals("No topic", response.second);
     }
 
     @Test
@@ -81,13 +84,13 @@
         String testData = "This is some test data";
         Pair<Integer, String> response = dmaapPost(myTopic, testData);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapGet(myTopic, 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals(testData, response.b);
+        assertNotNull(response.first);
+        assertEquals(testData, response.second);
     }
 
     @Test
@@ -96,118 +99,118 @@
         String myTopic = "myTopicMultiPost";
         Pair<Integer, String> response = dmaapPost(myTopic, data[0]);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapPost(myTopic, data[1]);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapPost(myTopic, data[2]);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapGet(myTopic, 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals(data[0], response.b);
+        assertNotNull(response.first);
+        assertEquals(data[0], response.second);
 
         response = dmaapGet(myTopic, 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals(data[1], response.b);
+        assertNotNull(response.first);
+        assertEquals(data[1], response.second);
 
         response = dmaapGet(myTopic, 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals(data[2], response.b);
+        assertNotNull(response.first);
+        assertEquals(data[2], response.second);
     }
 
     @Test
     public void testMultiTopic() {
         String[][] data = {{"Topic one message one", "Topic one message two"},
-                {"Topic two message one", "Topic two message two"}};
+            {"Topic two message one", "Topic two message two"}};
         String[] topics = {"topic1", "topic2"};
 
         Pair<Integer, String> response = dmaapPost(topics[0], data[0][0]);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapGet(topics[0], 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals(data[0][0], response.b);
+        assertNotNull(response.first);
+        assertEquals(data[0][0], response.second);
 
         response = dmaapGet(topics[1], 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals("No topic", response.b);
+        assertNotNull(response.first);
+        assertEquals("No topic", response.second);
 
         response = dmaapPost(topics[1], data[1][0]);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapPost(topics[1], data[1][1]);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapPost(topics[0], data[0][1]);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapGet(topics[1], 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals(data[1][0], response.b);
+        assertNotNull(response.first);
+        assertEquals(data[1][0], response.second);
 
         response = dmaapGet(topics[0], 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals(data[0][1], response.b);
+        assertNotNull(response.first);
+        assertEquals(data[0][1], response.second);
 
         response = dmaapGet(topics[1], 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals(data[1][1], response.b);
+        assertNotNull(response.first);
+        assertEquals(data[1][1], response.second);
 
         response = dmaapGet(topics[0], 1000);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertEquals("No Data", response.b);
+        assertNotNull(response.first);
+        assertEquals("No Data", response.second);
     }
 
     @Test
     public void testResponseCode() {
         Pair<Integer, String> response = dmaapPost("myTopic", "myTopicData");
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = setStatus(503);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapGet("myTopic", 500);
         assertNotNull(response);
-        assertEquals(503, response.a.intValue());
-        assertEquals("You got response code: 503", response.b);
+        assertEquals(503, response.first.intValue());
+        assertEquals("You got response code: 503", response.second);
 
         response = setStatus(202);
         assertNotNull(response);
-        assertNotNull(response.a);
-        assertNotNull(response.b);
+        assertNotNull(response.first);
+        assertNotNull(response.second);
 
         response = dmaapGet("myTopic", 500);
         assertNotNull(response);
-        assertEquals(202, response.a.intValue());
-        assertEquals("myTopicData", response.b);
+        assertEquals(202, response.first.intValue());
+        assertEquals("myTopicData", response.second);
     }
 
     private static Pair<Integer, String> dmaapGet(String topic, int timeout) {
@@ -345,12 +348,12 @@
     }
 
     private static class Pair<A, B> {
-        public final A a;
-        public final B b;
+        public final A first;
+        public final B second;
 
-        public Pair(A a, B b) {
-            this.a = a;
-            this.b = b;
+        public Pair(A first, B second) {
+            this.first = first;
+            this.second = second;
         }
     }
 }
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
index 33f672c..108ee6b 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-state-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -31,212 +31,203 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * This class audits the database
+/** This class audits the database.
  */
-public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
-{
-	// get an instance of logger 
-  private static Logger  logger = LoggerFactory.getLogger(DbAudit.class);	
-  // single global instance of this audit object
-  private static final DbAudit instance = new DbAudit();
+public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase {
+    // get an instance of logger
+    private static Logger logger = LoggerFactory.getLogger(DbAudit.class);
+    // single global instance of this audit object
+    private static final DbAudit instance = new DbAudit();
 
-  // This indicates if 'CREATE TABLE IF NOT EXISTS Audit ...' should be
-  // invoked -- doing this avoids the need to create the table in advance.
-  private static boolean createTableNeeded = true;
-  
-  private static boolean isJunit = false;
+    // This indicates if 'CREATE TABLE IF NOT EXISTS Audit ...' should be
+    // invoked -- doing this avoids the need to create the table in advance.
+    private static boolean createTableNeeded = true;
 
-  /**
-   * Constructor - set the name to 'Database'
-   */
-  private DbAudit()
-  {
-	super("Database");
-  }
-  
-  private static synchronized void setCreateTableNeeded(boolean b) {
-		DbAudit.createTableNeeded = b;
-  }
-  
-  public static synchronized void setIsJunit(boolean b) {
-		DbAudit.isJunit = b;
-  }
-  
-  public static boolean isJunit(){
-	  return DbAudit.isJunit;
-  }
-  
-  
-  /**
-   * @return the single 'DbAudit' instance
-   */
-  public static DroolsPDPIntegrityMonitor.AuditBase getInstance()
-  {
-	return instance;
-  }
+    private static boolean isJunit = false;
 
-  /**
-   * Invoke the audit
-   *
-   * @param properties properties to be passed to the audit
-   */
-  @Override
-	public void invoke(Properties properties)
-  {
-	logger.debug("Running 'DbAudit.invoke'");
-	boolean doCreate = createTableNeeded && !isJunit;
-	
-	if(!isActive()){		
-		logger.info("DbAudit.invoke: exiting because isActive = false");
-		return;
-	}
-	
-	// fetch DB properties from properties file -- they are already known
-	// to exist, because they were verified by the 'IntegrityMonitor'
-	// constructor
-	String url = properties.getProperty(StateManagementProperties.DB_URL);
-	String user = properties.getProperty(StateManagementProperties.DB_USER);
-	String password = properties.getProperty(StateManagementProperties.DB_PWD);
+    /** Constructor - set the name to 'Database'. */
+    private DbAudit() {
+        super("Database");
+    }
 
-	// operation phase currently running -- used to construct an error
-	// message, if needed
-	String phase = null;
+    private static synchronized void setCreateTableNeeded(boolean isNeeded) {
+        DbAudit.createTableNeeded = isNeeded;
+    }
 
-	// create connection to DB
-	phase = "creating connection";
-	logger.debug("DbAudit: Creating connection to {}", url);
-	try (Connection connection = DriverManager.getConnection(url, user, password))
-	  {
+    public static synchronized void setIsJunit(boolean isJUnit) {
+        DbAudit.isJunit = isJUnit;
+    }
 
-		// create audit table, if needed
-		if (doCreate)
-		  {
-			phase = "create table";
-			createTable(connection);
-		  }
+    public static boolean isJunit() {
+        return DbAudit.isJunit;
+    }
 
-		// insert an entry into the table
-		phase = "insert entry";
-		String key = UUID.randomUUID().toString();
-		insertEntry(connection, key);
-		
-		phase = "fetch entry";
-		findEntry(connection, key);
-		
-		phase = "delete entry";
-		deleteEntry(connection, key);
-	}
-	catch (Exception e)
-	  {
-		String message = "DbAudit: Exception during audit, phase = " + phase;
-		logger.error(message, e);
-		setResponse(message);
-	  }
-  }
+    /**
+     * Get the instance.
+     *  
+     * @return the single 'DbAudit' instance. */
+    public static DroolsPDPIntegrityMonitor.AuditBase getInstance() {
+        return instance;
+    }
 
-  /**
-   * Determines if the DbAudit is active, based on properties.  Defaults to
-   * {@code true}, if not found in the properties.
-   * @return {@code true} if DbAudit is active, {@code false} otherwise
-   */
-  private boolean isActive() {
-	String dbAuditIsActive = StateManagementProperties.getProperty("db.audit.is.active");
-	logger.debug("DbAudit.invoke: dbAuditIsActive = {}", dbAuditIsActive);
-	
-	if (dbAuditIsActive != null) {
-		try {
-			return Boolean.parseBoolean(dbAuditIsActive.trim());
-		} catch (NumberFormatException e) {
-			logger.warn("DbAudit.invoke: Ignoring invalid property: db.audit.is.active = {}", dbAuditIsActive);
-		}
-	}
-	
-	return true;
-  }
+    /**
+     * Invoke the audit.
+     *
+     * @param properties properties to be passed to the audit
+     */
+    @Override
+    public void invoke(Properties properties) {
+        logger.debug("Running 'DbAudit.invoke'");
+        boolean doCreate = createTableNeeded && !isJunit;
 
-  /**
-   * Creates the table.
-   * @param connection
-   * @throws SQLException
-   */
-  private void createTable(Connection connection) throws SQLException {
-		logger.info("DbAudit: Creating 'Audit' table, if needed");
-	try (PreparedStatement statement = connection.prepareStatement
-	  ("CREATE TABLE IF NOT EXISTS Audit (\n"
-	   + " name varchar(64) DEFAULT NULL,\n"
-	   + " UNIQUE KEY name (name)\n"
-	   + ") DEFAULT CHARSET=latin1;")) {
-		statement.execute();
-		DbAudit.setCreateTableNeeded(false);
-	}
-  }
+        if (!isActive()) {
+            logger.info("DbAudit.invoke: exiting because isActive = false");
+            return;
+        }
 
-  /**
-   * Inserts an entry.
-   * @param connection
-   * @param key
-   * @throws SQLException
-   */
-  private void insertEntry(Connection connection, String key) throws SQLException {
-	try (PreparedStatement statement = connection.prepareStatement
-	  ("INSERT INTO Audit (name) VALUES (?)")) {
-		statement.setString(1, key);
-		statement.executeUpdate();
-	}
-  }
+        // fetch DB properties from properties file -- they are already known
+        // to exist, because they were verified by the 'IntegrityMonitor'
+        // constructor
+        String url = properties.getProperty(StateManagementProperties.DB_URL);
+        String user = properties.getProperty(StateManagementProperties.DB_USER);
+        String password = properties.getProperty(StateManagementProperties.DB_PWD);
 
-  /**
-   * Finds an entry.
-   * @param connection
-   * @param key
-   * @throws SQLException
-   */
-  private void findEntry(Connection connection, String key) throws SQLException {
-	try (PreparedStatement statement = connection.prepareStatement
-	  ("SELECT name FROM Audit WHERE name = ?")) {
-		statement.setString(1, key);
-		getEntry(statement, key);
-	}
-  }
+        // operation phase currently running -- used to construct an error
+        // message, if needed
+        String phase = null;
 
-  /**
-   * Executes the query to determine if the entry exists.  Sets the response
-   * if it fails.
-   * @param statement
-   * @param key
-   * @throws SQLException
-   */
-  private void getEntry(PreparedStatement statement, String key) throws SQLException {
-	try (ResultSet rs = statement.executeQuery()) {
-		if (rs.first())
-		  {
-			// found entry
-			if(logger.isDebugEnabled()){
-				logger.debug("DbAudit: Found key {}", rs.getString(1));
-			}
-		  }
-		else
-		  {
-			logger.error
-			  ("DbAudit: can't find newly-created entry with key {}", key);
-			setResponse("Can't find newly-created entry");
-		  }
-	}
-  }
+        // create connection to DB
+        phase = "creating connection";
+        logger.debug("DbAudit: Creating connection to {}", url);
+        try (Connection connection = DriverManager.getConnection(url, user, password)) {
 
-  /**
-   * Deletes an entry.
-   * @param connection
-   * @param key
-   * @throws SQLException
-   */
-  private void deleteEntry(Connection connection, String key) throws SQLException {
-	try (PreparedStatement statement = connection.prepareStatement
-	  ("DELETE FROM Audit WHERE name = ?")) {
-		statement.setString(1, key);
-		statement.executeUpdate();
-	}
-  }
+            // create audit table, if needed
+            if (doCreate) {
+                phase = "create table";
+                createTable(connection);
+            }
 
+            // insert an entry into the table
+            phase = "insert entry";
+            String key = UUID.randomUUID().toString();
+            insertEntry(connection, key);
+
+            phase = "fetch entry";
+            findEntry(connection, key);
+
+            phase = "delete entry";
+            deleteEntry(connection, key);
+        } catch (Exception e) {
+            String message = "DbAudit: Exception during audit, phase = " + phase;
+            logger.error(message, e);
+            setResponse(message);
+        }
+    }
+
+    /**
+     * Determines if the DbAudit is active, based on properties. Defaults to {@code true}, if not
+     * found in the properties.
+     *
+     * @return {@code true} if DbAudit is active, {@code false} otherwise
+     */
+    private boolean isActive() {
+        String dbAuditIsActive = StateManagementProperties.getProperty("db.audit.is.active");
+        logger.debug("DbAudit.invoke: dbAuditIsActive = {}", dbAuditIsActive);
+
+        if (dbAuditIsActive != null) {
+            try {
+                return Boolean.parseBoolean(dbAuditIsActive.trim());
+            } catch (NumberFormatException e) {
+                logger.warn(
+                        "DbAudit.invoke: Ignoring invalid property: db.audit.is.active = {}", dbAuditIsActive);
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Creates the table.
+     *
+     * @param connection connection
+     * @throws SQLException exception
+     */
+    private void createTable(Connection connection) throws SQLException {
+        logger.info("DbAudit: Creating 'Audit' table, if needed");
+        try (PreparedStatement statement =
+                connection.prepareStatement(
+                        "CREATE TABLE IF NOT EXISTS Audit (\n"
+                                + " name varchar(64) DEFAULT NULL,\n"
+                                + " UNIQUE KEY name (name)\n"
+                                + ") DEFAULT CHARSET=latin1;")) {
+            statement.execute();
+            DbAudit.setCreateTableNeeded(false);
+        }
+    }
+
+    /**
+     * Inserts an entry.
+     *
+     * @param connection connection
+     * @param key key
+     * @throws SQLException exception
+     */
+    private void insertEntry(Connection connection, String key) throws SQLException {
+        try (PreparedStatement statement =
+                connection.prepareStatement("INSERT INTO Audit (name) VALUES (?)")) {
+            statement.setString(1, key);
+            statement.executeUpdate();
+        }
+    }
+
+    /**
+     * Finds an entry.
+     *
+     * @param connection connection
+     * @param key key
+     * @throws SQLException exception
+     */
+    private void findEntry(Connection connection, String key) throws SQLException {
+        try (PreparedStatement statement =
+                connection.prepareStatement("SELECT name FROM Audit WHERE name = ?")) {
+            statement.setString(1, key);
+            getEntry(statement, key);
+        }
+    }
+
+    /**
+     * Executes the query to determine if the entry exists. Sets the response if it fails.
+     *
+     * @param statement statement
+     * @param key key
+     * @throws SQLException exception
+     */
+    private void getEntry(PreparedStatement statement, String key) throws SQLException {
+        try (ResultSet rs = statement.executeQuery()) {
+            if (rs.first()) {
+                // found entry
+                if (logger.isDebugEnabled()) {
+                    logger.debug("DbAudit: Found key {}", rs.getString(1));
+                }
+            } else {
+                logger.error("DbAudit: can't find newly-created entry with key {}", key);
+                setResponse("Can't find newly-created entry");
+            }
+        }
+    }
+
+    /**
+     * Deletes an entry.
+     *
+     * @param connection connection
+     * @param key key
+     * @throws SQLException exception
+     */
+    private void deleteEntry(Connection connection, String key) throws SQLException {
+        try (PreparedStatement statement =
+                connection.prepareStatement("DELETE FROM Audit WHERE name = ?")) {
+            statement.setString(1, key);
+            statement.executeUpdate();
+        }
+    }
 }
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
index a7606eb..3cb99f2 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-state-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -54,7 +54,7 @@
     private static final String PROPERTIES_NAME = "feature-state-management.properties";
 
     /**
-     * Constructor - pass arguments to superclass, but remember properties
+     * Constructor - pass arguments to superclass, but remember properties.
      * 
      * @param resourceName unique name of this Integrity Monitor
      * @param url the JMX URL of the MBean server
@@ -81,10 +81,10 @@
 
     /**
      * Static initialization -- create Drools Integrity Monitor, and an HTTP server to handle REST
-     * 'test' requests
+     * 'test' requests.
      * 
-     * @throws StateManagementPropertiesException
-     * @throws IntegrityMonitorException
+     * @throws StateManagementPropertiesException exception
+     * @throws IntegrityMonitorException exception
      */
     public static DroolsPDPIntegrityMonitor init(String configDir) throws IntegrityMonitorException {
 
@@ -125,9 +125,9 @@
         checkPropError(stateManagementProperties, StateManagementProperties.DB_USER);
         checkPropError(stateManagementProperties, StateManagementProperties.DB_PWD);
 
-        String testHost = stateManagementProperties.getProperty(StateManagementProperties.TEST_HOST);
-        String testPort = stateManagementProperties.getProperty(StateManagementProperties.TEST_PORT);
-        String resourceName = stateManagementProperties.getProperty(StateManagementProperties.RESOURCE_NAME);
+        final String testHost = stateManagementProperties.getProperty(StateManagementProperties.TEST_HOST);
+        final String testPort = stateManagementProperties.getProperty(StateManagementProperties.TEST_PORT);
+        final String resourceName = stateManagementProperties.getProperty(StateManagementProperties.RESOURCE_NAME);
 
         subsystemTestProperties = stateManagementProperties;
 
@@ -148,8 +148,8 @@
      * 
      * @param resourceName unique name of this Integrity Monitor
      * @param properties properties used to configure the Integrity Monitor
-     * @return
-     * @throws IntegrityMonitorException
+     * @return monitor object
+     * @throws IntegrityMonitorException exception
      */
     private static DroolsPDPIntegrityMonitor makeMonitor(String resourceName, Properties properties)
             throws IntegrityMonitorException {
@@ -168,7 +168,7 @@
      * @param testHost host name
      * @param testPort port
      * @param properties properties used to configure the rest server
-     * @throws IntegrityMonitorException
+     * @throws IntegrityMonitorException exception
      */
     private static void makeRestServer(String testHost, String testPort, Properties properties)
             throws IntegrityMonitorException {
@@ -190,7 +190,7 @@
      * 
      * @param configDir directory containing the property file
      * @return the properties
-     * @throws IntegrityMonitorException
+     * @throws IntegrityMonitorException exception
      */
     private static Properties getProperties(String configDir) throws IntegrityMonitorException {
         try {
@@ -206,7 +206,7 @@
      * 
      * @param props set of properties
      * @param name name of the property to check
-     * @throws IntegrityMonitorException
+     * @throws IntegrityMonitorException exception
      */
     private static void checkPropError(Properties props, String name) throws IntegrityMonitorException {
         String val = props.getProperty(name);
@@ -260,7 +260,7 @@
     }
 
     /**
-     * Run tests (audits) unique to Drools PDP VM (Database + Repository)
+     * Run tests (audits) unique to Drools PDP VM (Database + Repository).
      */
     @Override
     public void subsystemTest() throws IntegrityMonitorException {
@@ -308,7 +308,7 @@
     /* ============================================================ */
 
     /**
-     * This is the base class for audits invoked in 'subsystemTest'
+     * This is the base class for audits invoked in 'subsystemTest'.
      */
     public abstract static class AuditBase {
         // name of the audit
@@ -318,7 +318,7 @@
         protected String response;
 
         /**
-         * Constructor - initialize the name, and clear the initial response
+         * Constructor - initialize the name, and clear the initial response.
          * 
          * @param name name of the audit
          */
@@ -328,6 +328,8 @@
         }
 
         /**
+         * Get the name.
+         * 
          * @return the name of this audit
          */
         public String getName() {
@@ -335,6 +337,8 @@
         }
 
         /**
+         * Get the response.
+         * 
          * @return the response String (non-null indicates the error message)
          */
         public String getResponse() {
@@ -342,7 +346,7 @@
         }
 
         /**
-         * Set the response string to the specified value
+         * Set the response string to the specified value.
          * 
          * @param value the new value of the response string (null = no errors)
          */
@@ -351,7 +355,7 @@
         }
 
         /**
-         * Abstract method to invoke the audit
+         * Abstract method to invoke the audit.
          * 
          * @param persistenceProperties Used for DB access
          * @throws Exception passed in by the audit
@@ -416,6 +420,12 @@
         }
     }
 
+    /**
+     * Returns the instance.
+     * 
+     * @return DroolsPDPIntegrityMonitor object
+     * @throws IntegrityMonitorException exception
+     */
     public static DroolsPDPIntegrityMonitor getInstance() throws IntegrityMonitorException {
         if (logger.isDebugEnabled()) {
             logger.debug("getInstance() called");
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
index b6491e7..49e4577 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-state-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,6 +20,11 @@
 
 package org.onap.policy.drools.statemanagement;
 
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.core.Response;
@@ -27,84 +32,82 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
 
 @Api(value = "test")
-	@Path("/")
+@Path("/")
 public class IntegrityMonitorRestManager {
-		private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorRestManager.class);	
-		private DroolsPDPIntegrityMonitor im;
-		
-		/**
-		 * Test interface for Integrity Monitor
-		 * 
-		 * @return Exception message if exception, otherwise empty
-		 */
-		@ApiOperation(
-			value = "Test endpoint for integrity monitor",
-			notes = "The TEST command is used to request data from a subcomponent "
-					+ "instance that can be used to determine its operational state. "
-					+ "A 200/success response status code should be returned if the "
-					+ "subcomponent instance is functioning properly and able to respond to requests.",
-			response = String.class)
-		@ApiResponses(value = {
-			@ApiResponse(
-				code = 200,
-				message = "Integrity monitor sanity check passed"),
-			@ApiResponse(
-				code = 500,
-				message = "Integrity monitor sanity check encountered an exception. This can indicate operational state disabled or administrative state locked")
-		})
-		@GET
-		@Path("test")
-		public Response test() {
-			if(logger.isDebugEnabled()){
-				logger.debug("integrity monitor /test accessed");
-			}
-			// The responses are stored within the audit objects, so we need to
-			// invoke the audits and get responses before we handle another
-			// request.
-			synchronized (IntegrityMonitorRestManager.class) {
-				// will include messages associated with subsystem failures
-				StringBuilder body = new StringBuilder();
+    private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorRestManager.class);
+    private DroolsPDPIntegrityMonitor im;
 
-				// 200=SUCCESS, 500=failure
-				int responseValue = 200;
+    /**
+     * Test interface for Integrity Monitor.
+     * 
+     * @return Exception message if exception, otherwise empty
+     */
+    @ApiOperation(
+            value = "Test endpoint for integrity monitor",
+            notes = "The TEST command is used to request data from a subcomponent "
+                    + "instance that can be used to determine its operational state. "
+                    + "A 200/success response status code should be returned if the "
+                    + "subcomponent instance is functioning properly and able to respond to requests.",
+                    response = String.class)
+    @ApiResponses(value = {
+            @ApiResponse(
+                    code = 200,
+                    message = "Integrity monitor sanity check passed"),
+            @ApiResponse(
+                    code = 500,
+                    message = "Integrity monitor sanity check encountered an exception. "
+                        + "This can indicate operational state disabled or administrative state locked")
+    })
+    @GET
+    @Path("test")
+    public Response test() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("integrity monitor /test accessed");
+        }
+        // The responses are stored within the audit objects, so we need to
+        // invoke the audits and get responses before we handle another
+        // request.
+        synchronized (IntegrityMonitorRestManager.class) {
+            // will include messages associated with subsystem failures
+            StringBuilder body = new StringBuilder();
 
-				if (im == null) {
-					try {
-						im = DroolsPDPIntegrityMonitor.getInstance();
-					} catch (Exception e) {
-						logger.error("IntegrityMonitorRestManager: test() interface caught an exception", e);
-						body.append("\nException: " + e + "\n");
-						responseValue = 500;
-					}
-				}
+            // 200=SUCCESS, 500=failure
+            int responseValue = 200;
 
-				if (im != null) {
-					try {
-						// call 'IntegrityMonitor.evaluateSanity()'
-						im.evaluateSanity();
-					} catch (Exception e) {
-						// this exception isn't coming from one of the audits,
-						// because those are caught in 'subsystemTest()'
-						logger.error("DroolsPDPIntegrityMonitor.evaluateSanity()", e);
+            if (im == null) {
+                try {
+                    im = DroolsPDPIntegrityMonitor.getInstance();
+                } catch (Exception e) {
+                    logger.error("IntegrityMonitorRestManager: test() interface caught an exception", e);
+                    body.append("\nException: " + e + "\n");
+                    responseValue = 500;
+                }
+            }
 
-						// include exception in HTTP response
-						body.append("\nException: " + e + "\n");
-						responseValue = 500;
-					}
-				}
+            if (im != null) {
+                try {
+                    // call 'IntegrityMonitor.evaluateSanity()'
+                    im.evaluateSanity();
+                } catch (Exception e) {
+                    // this exception isn't coming from one of the audits,
+                    // because those are caught in 'subsystemTest()'
+                    logger.error("DroolsPDPIntegrityMonitor.evaluateSanity()", e);
 
-				// send response, including the contents of 'body'
-				// (which is empty if everything is successful)
-				if (responseValue == 200)
-					return Response.status(Response.Status.OK).build();
-				else
-					return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(body.toString()).build();
-			}
-		}
+                    // include exception in HTTP response
+                    body.append("\nException: " + e + "\n");
+                    responseValue = 500;
+                }
+            }
+
+            // send response, including the contents of 'body'
+            // (which is empty if everything is successful)
+            if (responseValue == 200) {
+                return Response.status(Response.Status.OK).build();
+            } else {
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(body.toString()).build();
+            }
+        }
+    }
 }
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
index 6ddf0c7..92ec2ac 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-state-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -37,529 +37,456 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * This class audits the Maven repository
+ * This class audits the Maven repository.
  */
-public class RepositoryAudit extends DroolsPDPIntegrityMonitor.AuditBase
-{
-  private static final long DEFAULT_TIMEOUT = 60;	// timeout in 60 seconds
+public class RepositoryAudit extends DroolsPDPIntegrityMonitor.AuditBase {
+    private static final long DEFAULT_TIMEOUT = 60; //timeout in 60 seconds
 
-  // get an instance of logger
-  private static Logger  logger = LoggerFactory.getLogger(RepositoryAudit.class);		
-  // single global instance of this audit object
-  private static RepositoryAudit instance = new RepositoryAudit();
+    // get an instance of logger
+    private static Logger  logger = LoggerFactory.getLogger(RepositoryAudit.class);
+    // single global instance of this audit object
+    private static RepositoryAudit instance = new RepositoryAudit();
 
-  /**
-   * Constructor - set the name to 'Repository'
-   */
-  private RepositoryAudit()
-  {
-	super("Repository");
-  }
+    /**
+     * Constructor - set the name to 'Repository'.
+     */
+    private RepositoryAudit() {
+        super("Repository");
+    }
 
-  /**
-   * @return the single 'RepositoryAudit' instance
-   */
-  public static DroolsPDPIntegrityMonitor.AuditBase getInstance()
-  {
-	return instance;
-  }
+    /**
+     * Get the integrity monitor instance.
+     * 
+     * @return the single 'RepositoryAudit' instance
+     */
+    public static DroolsPDPIntegrityMonitor.AuditBase getInstance() {
+        return instance;
+    }
 
-  /**
-   * Invoke the audit
-   *
-   * @param properties properties to be passed to the audit
-   */
-  @Override
-	public void invoke(Properties properties)
-	throws IOException, InterruptedException
-  {
-	if(logger.isDebugEnabled()){  
-		logger.debug("Running 'RepositoryAudit.invoke'");
-	}
-	
-	boolean isActive = true;
-	boolean ignoreErrors = true;		// ignore errors by default
-	String repoAuditIsActive = StateManagementProperties.getProperty("repository.audit.is.active");
-	String repoAuditIgnoreErrors =
-	  StateManagementProperties.getProperty("repository.audit.ignore.errors");
-	logger.debug("RepositoryAudit.invoke: repoAuditIsActive = {}" 
-				 + ", repoAuditIgnoreErrors = {}",repoAuditIsActive, repoAuditIgnoreErrors);
-	
-	if (repoAuditIsActive != null) {
-		try {
-			isActive = Boolean.parseBoolean(repoAuditIsActive.trim());
-		} catch (NumberFormatException e) {
-			logger.warn("RepositoryAudit.invoke: Ignoring invalid property: repository.audit.is.active = {}", repoAuditIsActive);
-		}
-	}
-	
-	if(!isActive){
-		logger.info("RepositoryAudit.invoke: exiting because isActive = {}", isActive);
-		return;
-	}
+    /**
+     * Invoke the audit.
+     *
+     * @param properties properties to be passed to the audit
+     */
+    @Override
+    public void invoke(Properties properties)
+            throws IOException, InterruptedException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Running 'RepositoryAudit.invoke'");
+        }
 
-	if (repoAuditIgnoreErrors != null)
-	  {
-		try
-		  {
-			ignoreErrors = Boolean.parseBoolean(repoAuditIgnoreErrors.trim());
-		  }
-		catch (NumberFormatException e)
-		  {
-			ignoreErrors = true;
-			logger.warn("RepositoryAudit.invoke: Ignoring invalid property: repository.audit.ignore.errors = {}", repoAuditIgnoreErrors);
-		  }
-	  }else{
-		  ignoreErrors = true;
-	  }
+        boolean isActive = true;
+        // ignore errors by default
+        boolean ignoreErrors = true;
+        String repoAuditIsActive = StateManagementProperties.getProperty("repository.audit.is.active");
+        String repoAuditIgnoreErrors =
+                StateManagementProperties.getProperty("repository.audit.ignore.errors");
+        logger.debug("RepositoryAudit.invoke: repoAuditIsActive = {}" 
+                + ", repoAuditIgnoreErrors = {}",repoAuditIsActive, repoAuditIgnoreErrors);
 
-	// Fetch repository information from 'IntegrityMonitorProperties'
-	String repositoryId =
-	  StateManagementProperties.getProperty("repository.audit.id");
-	String repositoryUrl =
-	  StateManagementProperties.getProperty("repository.audit.url");
-	String repositoryUsername =
-	  StateManagementProperties.getProperty("repository.audit.username");
-	String repositoryPassword =
-	  StateManagementProperties.getProperty("repository.audit.password");
-	boolean upload =
-	   repositoryId != null && repositoryUrl != null
-	   && repositoryUsername != null && repositoryPassword != null;
+        if (repoAuditIsActive != null) {
+            try {
+                isActive = Boolean.parseBoolean(repoAuditIsActive.trim());
+            } catch (NumberFormatException e) {
+                logger.warn("RepositoryAudit.invoke: Ignoring invalid property: repository.audit.is.active = {}", 
+                        repoAuditIsActive);
+            }
+        }
 
-	// used to incrementally construct response as problems occur
-	// (empty = no problems)
-	StringBuilder response = new StringBuilder();
+        if (!isActive) {
+            logger.info("RepositoryAudit.invoke: exiting because isActive = {}", isActive);
+            return;
+        }
 
-	long timeoutInSeconds = DEFAULT_TIMEOUT;
-	String timeoutString =
-	  StateManagementProperties.getProperty("repository.audit.timeout");
-	if (timeoutString != null && !timeoutString.isEmpty())
-	  {
-		try
-		  {
-			timeoutInSeconds = Long.valueOf(timeoutString);
-		  }
-		catch (NumberFormatException e)
-		  {
-			logger.error
-			  ("RepositoryAudit: Invalid 'repository.audit.timeout' value: '{}'", timeoutString, e);
-			if (!ignoreErrors)
-			  {
-				response.append("Invalid 'repository.audit.timeout' value: '")
-				  .append(timeoutString).append("'\n");
-				setResponse(response.toString());
-			  }
-		  }
-	  }
+        if (repoAuditIgnoreErrors != null) {
+            try {
+                ignoreErrors = Boolean.parseBoolean(repoAuditIgnoreErrors.trim());
+            } catch (NumberFormatException e) {
+                ignoreErrors = true;
+                logger.warn("RepositoryAudit.invoke: Ignoring invalid property: repository.audit.ignore.errors = {}", 
+                        repoAuditIgnoreErrors);
+            }
+        } else {
+            ignoreErrors = true;
+        }
 
-	// artifacts to be downloaded
-	LinkedList<Artifact> artifacts = new LinkedList<>();
+        // Fetch repository information from 'IntegrityMonitorProperties'
+        String repositoryId =
+                StateManagementProperties.getProperty("repository.audit.id");
+        String repositoryUrl =
+                StateManagementProperties.getProperty("repository.audit.url");
+        String repositoryUsername =
+                StateManagementProperties.getProperty("repository.audit.username");
+        String repositoryPassword =
+                StateManagementProperties.getProperty("repository.audit.password");
+        boolean upload =
+                repositoryId != null && repositoryUrl != null
+                && repositoryUsername != null && repositoryPassword != null;
 
-	/*
-	 * 1) create temporary directory
-	 */
-	Path dir = Files.createTempDirectory("auditRepo");
-	logger.info("RepositoryAudit: temporary directory = {}", dir);
+        // used to incrementally construct response as problems occur
+        // (empty = no problems)
+        StringBuilder response = new StringBuilder();
 
-	// nested 'pom.xml' file and 'repo' directory
-	Path pom = dir.resolve("pom.xml");
-	Path repo = dir.resolve("repo");
+        long timeoutInSeconds = DEFAULT_TIMEOUT;
+        String timeoutString =
+                StateManagementProperties.getProperty("repository.audit.timeout");
+        if (timeoutString != null && !timeoutString.isEmpty()) {
+            try {
+                timeoutInSeconds = Long.valueOf(timeoutString);
+            } catch (NumberFormatException e) {
+                logger.error("RepositoryAudit: Invalid 'repository.audit.timeout' value: '{}'", 
+                        timeoutString, e);
+                if (!ignoreErrors) {
+                    response.append("Invalid 'repository.audit.timeout' value: '")
+                    .append(timeoutString).append("'\n");
+                    setResponse(response.toString());
+                }
+            }
+        }
 
-	/*
-	 * 2) Create test file, and upload to repository
-	 *    (only if repository information is specified)
-	 */
-	String groupId = null;
-	String artifactId = null;
-	String version = null;
-	if (upload)
-	  {
-		groupId = "org.onap.policy.audit";
-		artifactId = "repository-audit";
-		version = "0." + System.currentTimeMillis();
+        // artifacts to be downloaded
+        LinkedList<Artifact> artifacts = new LinkedList<>();
 
-		if (repositoryUrl.toLowerCase().contains("snapshot"))
-		  {
-			// use SNAPSHOT version
-			version += "-SNAPSHOT";
-		  }
+        /*
+         * 1) create temporary directory
+         */
+        Path dir = Files.createTempDirectory("auditRepo");
+        logger.info("RepositoryAudit: temporary directory = {}", dir);
 
-		// create text file to write
-		FileOutputStream fos =
-		  new FileOutputStream(dir.resolve("repository-audit.txt").toFile());
-		try
-		  {
-			fos.write(version.getBytes());
-		  }
-		finally
-		  {
-			fos.close();
-		  }
+        // nested 'pom.xml' file and 'repo' directory
+        final Path pom = dir.resolve("pom.xml");
+        final Path repo = dir.resolve("repo");
 
-		// try to install file in repository
-		if (runProcess
-			(timeoutInSeconds, dir.toFile(), null,
-			 "mvn", "deploy:deploy-file",
-			 "-DrepositoryId=" + repositoryId,
-			 "-Durl=" + repositoryUrl,
-			 "-Dfile=repository-audit.txt",
-			 "-DgroupId=" + groupId,
-			 "-DartifactId=" + artifactId,
-			 "-Dversion=" + version,
-			 "-Dpackaging=txt",
-			 "-DgeneratePom=false") != 0)
-		  {
-			logger.error
-			  ("RepositoryAudit: 'mvn deploy:deploy-file' failed");
-			if (!ignoreErrors)
-			  {
-				response.append("'mvn deploy:deploy-file' failed\n");
-				setResponse(response.toString());
-			  }
-		  }
-		else
-		  {
-			logger.info
-			  ("RepositoryAudit: 'mvn deploy:deploy-file succeeded");
+        /*
+         * 2) Create test file, and upload to repository
+         *    (only if repository information is specified)
+         */
+        String groupId = null;
+        String artifactId = null;
+        String version = null;
+        if (upload) {
+            groupId = "org.onap.policy.audit";
+            artifactId = "repository-audit";
+            version = "0." + System.currentTimeMillis();
 
-			// we also want to include this new artifact in the download
-			// test (steps 3 and 4)
-			artifacts.add(new Artifact(groupId, artifactId, version, "txt"));
-		  }
-	  }
+            if (repositoryUrl.toLowerCase().contains("snapshot")) {
+                // use SNAPSHOT version
+                version += "-SNAPSHOT";
+            }
 
-	/*
-	 * 3) create 'pom.xml' file in temporary directory
-	 */
-	artifacts.add(new Artifact("org.apache.maven/maven-embedder/3.2.2"));
-	
-	StringBuilder sb = new StringBuilder();
-	sb.append
-	  ("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
-	   + "         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
-	   + "\n"
-	   + "  <modelVersion>4.0.0</modelVersion>\n"
-	   + "  <groupId>empty</groupId>\n"
-	   + "  <artifactId>empty</artifactId>\n"
-	   + "  <version>1.0-SNAPSHOT</version>\n"
-	   + "  <packaging>pom</packaging>\n"
-	   + "\n"
-	   + "  <build>\n"
-	   + "    <plugins>\n"
-	   + "      <plugin>\n"
-	   + "         <groupId>org.apache.maven.plugins</groupId>\n"
-	   + "         <artifactId>maven-dependency-plugin</artifactId>\n"
-	   + "         <version>2.10</version>\n"
-	   + "         <executions>\n"
-	   + "           <execution>\n"
-	   + "             <id>copy</id>\n"
-	   + "             <goals>\n"
-	   + "               <goal>copy</goal>\n"
-	   + "             </goals>\n"
-	   + "             <configuration>\n"
-	   + "               <localRepositoryDirectory>")
-	  .append(repo)
-	  .append("</localRepositoryDirectory>\n")
-	  .append("               <artifactItems>\n");
-	for (Artifact artifact : artifacts)
-	  {
-		// each artifact results in an 'artifactItem' element
-		sb.append
-		  ("                 <artifactItem>\n"
-		   + "                   <groupId>")
-		  .append(artifact.groupId)
-		  .append
-		  ("</groupId>\n"
-		   + "                   <artifactId>")
-		  .append(artifact.artifactId)
-		  .append
-		  ("</artifactId>\n"
-		   + "                   <version>")
-		  .append(artifact.version)
-		  .append
-		  ("</version>\n"
-		   + "                   <type>")
-		  .append(artifact.type)
-		  .append
-		  ("</type>\n"
-		   + "                 </artifactItem>\n");
-	  }
-	sb.append
-	  ("               </artifactItems>\n"
-	   + "             </configuration>\n"
-	   + "           </execution>\n"
-	   + "         </executions>\n"
-	   + "      </plugin>\n"
-	   + "    </plugins>\n"
-	   + "  </build>\n"
-	   + "</project>\n");
-	FileOutputStream fos = new FileOutputStream(pom.toFile());
-	try
-	  {
-		fos.write(sb.toString().getBytes());
-	  }
-	finally
-	  {
-		fos.close();
-	  }
+            // create text file to write
+            try (FileOutputStream fos =
+                    new FileOutputStream(dir.resolve("repository-audit.txt").toFile())) {
+                fos.write(version.getBytes());
+            }
 
-	/*
-	 * 4) Invoke external 'mvn' process to do the downloads
-	 */
+            // try to install file in repository
+            if (runProcess(timeoutInSeconds, dir.toFile(), null,
+                            "mvn", "deploy:deploy-file",
+                            "-DrepositoryId=" + repositoryId,
+                            "-Durl=" + repositoryUrl,
+                            "-Dfile=repository-audit.txt",
+                            "-DgroupId=" + groupId,
+                            "-DartifactId=" + artifactId,
+                            "-Dversion=" + version,
+                            "-Dpackaging=txt",
+                            "-DgeneratePom=false") != 0) {
+                logger.error("RepositoryAudit: 'mvn deploy:deploy-file' failed");
+                if (!ignoreErrors) {
+                    response.append("'mvn deploy:deploy-file' failed\n");
+                    setResponse(response.toString());
+                }
+            }
+            else {
+                logger.info("RepositoryAudit: 'mvn deploy:deploy-file succeeded");
 
-	// output file = ${dir}/out (this supports step '4a')
-	File output = dir.resolve("out").toFile();
+                // we also want to include this new artifact in the download
+                // test (steps 3 and 4)
+                artifacts.add(new Artifact(groupId, artifactId, version, "txt"));
+            }
+        }
 
-	// invoke process, and wait for response
-	int rval = runProcess
-	  (timeoutInSeconds, dir.toFile(), output, "mvn", "compile");
-	logger.info("RepositoryAudit: 'mvn' return value = {}", rval);
-	if (rval != 0)
-	  {
-		logger.error
-		  ("RepositoryAudit: 'mvn compile' invocation failed");
-		if (!ignoreErrors)
-		  {
-			response.append("'mvn compile' invocation failed\n");
-			setResponse(response.toString());
-		  }
-	  }
+        /*
+         * 3) create 'pom.xml' file in temporary directory
+         */
+        artifacts.add(new Artifact("org.apache.maven/maven-embedder/3.2.2"));
 
-	/*
-	 * 4a) Check attempted and successful downloads from output file
-	 *     Note: at present, this step just generates log messages,
-	 *     but doesn't do any verification.
-	 */
-	if (rval == 0 && output != null)
-	  {
-		// place output in 'fileContents' (replacing the Return characters
-		// with Newline)
-		byte[] outputData = new byte[(int)output.length()];
-		String fileContents;
-		try (FileInputStream fis = new FileInputStream(output)) {
-			//
-			// Ideally this should be in a loop or even better use
-			// Java 8 nio functionality.
-			//
-			int bytesRead = fis.read(outputData);
-			logger.info("fileContents read {} bytes", bytesRead);
-			fileContents = new String(outputData).replace('\r','\n');
-		}
-		
-		// generate log messages from 'Downloading' and 'Downloaded'
-		// messages within the 'mvn' output
-		int index = 0;
-		while ((index = fileContents.indexOf("\nDown", index)) > 0)
-		  {
-			index += 5;
-			if (fileContents.regionMatches(index, "loading: ", 0, 9))
-			  {
-				index += 9;
-				int endIndex = fileContents.indexOf('\n', index);
-				logger.info
-				  ("RepositoryAudit: Attempted download: '{}'", fileContents.substring(index, endIndex));
-				index = endIndex;
-			  }
-			else if (fileContents.regionMatches(index, "loaded: ", 0, 8))
-			  {
-				index += 8;
-				int endIndex = fileContents.indexOf(' ', index);
-				logger.info
-				  ("RepositoryAudit: Successful download: '{}'",fileContents.substring(index, endIndex));
-				index = endIndex;
-			  }
-		  }
-	  }
+        StringBuilder sb = new StringBuilder();
+        sb.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+                + "         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
+                + "\n"
+                + "  <modelVersion>4.0.0</modelVersion>\n"
+                + "  <groupId>empty</groupId>\n"
+                + "  <artifactId>empty</artifactId>\n"
+                + "  <version>1.0-SNAPSHOT</version>\n"
+                + "  <packaging>pom</packaging>\n"
+                + "\n"
+                + "  <build>\n"
+                + "    <plugins>\n"
+                + "      <plugin>\n"
+                + "         <groupId>org.apache.maven.plugins</groupId>\n"
+                + "         <artifactId>maven-dependency-plugin</artifactId>\n"
+                + "         <version>2.10</version>\n"
+                + "         <executions>\n"
+                + "           <execution>\n"
+                + "             <id>copy</id>\n"
+                + "             <goals>\n"
+                + "               <goal>copy</goal>\n"
+                + "             </goals>\n"
+                + "             <configuration>\n"
+                + "               <localRepositoryDirectory>")
+            .append(repo)
+            .append("</localRepositoryDirectory>\n")
+            .append("               <artifactItems>\n");
+        
+        for (Artifact artifact : artifacts) {
+            // each artifact results in an 'artifactItem' element
+            sb.append("                 <artifactItem>\n"
+                    + "                   <groupId>")
+                .append(artifact.groupId)
+                .append("</groupId>\n"
+                    + "                   <artifactId>")
+                .append(artifact.artifactId)
+                .append("</artifactId>\n"
+                    + "                   <version>")
+                .append(artifact.version)
+                .append("</version>\n"
+                    + "                   <type>")
+                .append(artifact.type)
+                .append("</type>\n"
+                    + "                 </artifactItem>\n");
+        }
+        sb.append("               </artifactItems>\n"
+                + "             </configuration>\n"
+                + "           </execution>\n"
+                + "         </executions>\n"
+                + "      </plugin>\n"
+                + "    </plugins>\n"
+                + "  </build>\n"
+                + "</project>\n");
 
-	/*
-	 * 5) Check the contents of the directory to make sure the downloads
-	 *    were successful
-	 */
-	for (Artifact artifact : artifacts)
-	  {
-		if (repo.resolve(artifact.groupId.replace('.','/'))
-			.resolve(artifact.artifactId)
-			.resolve(artifact.version)
-			.resolve(artifact.artifactId + "-" + artifact.version + "."
-					 + artifact.type).toFile().exists())
-		  {
-			// artifact exists, as expected
-			logger.info("RepositoryAudit: {} : exists", artifact.toString());
-		  }
-		else
-		  {
-			// Audit ERROR: artifact download failed for some reason
-			logger.error("RepositoryAudit: {}: does not exist", artifact.toString());
-			if (!ignoreErrors)
-			  {
-				response.append("Failed to download artifact: ")
-				  .append(artifact).append('\n');
-				setResponse(response.toString());
-			  }
-		  }
-	  }
+        try (FileOutputStream fos = new FileOutputStream(pom.toFile())) {
+            fos.write(sb.toString().getBytes());
+        }
 
-	/*
-	 * 6) Use 'curl' to delete the uploaded test file
-	 *    (only if repository information is specified)
-	 */
-	if (upload)
-	  {
-		if (runProcess
-			(timeoutInSeconds, dir.toFile(), null,
-			 "curl",
-			 "--request", "DELETE",
-			 "--user", repositoryUsername + ":" + repositoryPassword,
-			 repositoryUrl + "/" + groupId.replace('.', '/') + "/" +
-			  artifactId + "/" + version)
-			!= 0)
-		  {
-			logger.error
-			  ("RepositoryAudit: delete of uploaded artifact failed");
-			if (!ignoreErrors)
-			  {
-				response.append("delete of uploaded artifact failed\n");
-				setResponse(response.toString());
-			  }
-		  }
-		else
-		  {
-			logger.info
-			  ("RepositoryAudit: delete of uploaded artifact succeeded");
-			artifacts.add(new Artifact(groupId, artifactId, version, "txt"));
-		  }
-	  }
+        /*
+         * 4) Invoke external 'mvn' process to do the downloads
+         */
 
-	/*
-	 * 7) Remove the temporary directory
-	 */
-	Files.walkFileTree(dir, new RecursivelyDeleteDirectory());
-  }
+        // output file = ${dir}/out (this supports step '4a')
+        File output = dir.resolve("out").toFile();
 
-  /**
-   * Run a process, and wait for the response
-   *
-   * @param timeoutInSeconds the number of seconds to wait for the
-   *	process to terminate
-   * @param directory the execution directory of the process
-   *	(null = current directory)
-   * @param stdout the file to contain the standard output
-   *	(null = discard standard output)
-   * @param command command and arguments
-   * @return the return value of the process
-   * @throws IOException, InterruptedException
-   */
-  static int runProcess(long timeoutInSeconds,
-						File directory, File stdout, String... command)
-	throws IOException, InterruptedException
-  {
-	ProcessBuilder pb = new ProcessBuilder(command);
-	if (directory != null)
-	  {
-		pb.directory(directory);
-	  }
-	if (stdout != null)
-	  {
-		pb.redirectOutput(stdout);
-	  }
+        // invoke process, and wait for response
+        int rval = runProcess(timeoutInSeconds, dir.toFile(), output, "mvn", "compile");
+        logger.info("RepositoryAudit: 'mvn' return value = {}", rval);
+        if (rval != 0) {
+            logger.error("RepositoryAudit: 'mvn compile' invocation failed");
+            if (!ignoreErrors) {
+                response.append("'mvn compile' invocation failed\n");
+                setResponse(response.toString());
+            }
+        }
 
-	Process process = pb.start();
-	if (process.waitFor(timeoutInSeconds, TimeUnit.SECONDS))
-	  {
-		// process terminated before the timeout
-		return process.exitValue();
-	  }
-	
-	// process timed out -- kill it, and return -1
-	process.destroyForcibly();
-	return -1;
-  }
+        /*
+         * 4a) Check attempted and successful downloads from output file
+         *     Note: at present, this step just generates log messages,
+         *     but doesn't do any verification.
+         */
+        if (rval == 0 && output != null) {
+            // place output in 'fileContents' (replacing the Return characters
+            // with Newline)
+            byte[] outputData = new byte[(int)output.length()];
+            String fileContents;
+            try (FileInputStream fis = new FileInputStream(output)) {
+                //
+                // Ideally this should be in a loop or even better use
+                // Java 8 nio functionality.
+                //
+                int bytesRead = fis.read(outputData);
+                logger.info("fileContents read {} bytes", bytesRead);
+                fileContents = new String(outputData).replace('\r','\n');
+            }
 
-  /**
-   * This class is used to recursively delete a directory and all of its
-   * contents.
-   */
-  private final class RecursivelyDeleteDirectory extends SimpleFileVisitor<Path> {
-	@Override
-	 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
-	   {
-		 file.toFile().delete();
-		 return FileVisitResult.CONTINUE;
-	   }
+            // generate log messages from 'Downloading' and 'Downloaded'
+            // messages within the 'mvn' output
+            int index = 0;
+            while ((index = fileContents.indexOf("\nDown", index)) > 0) {
+                index += 5;
+                if (fileContents.regionMatches(index, "loading: ", 0, 9)) {
+                    index += 9;
+                    int endIndex = fileContents.indexOf('\n', index);
+                    logger.info("RepositoryAudit: Attempted download: '{}'", 
+                            fileContents.substring(index, endIndex));
+                    index = endIndex;
+                } else if (fileContents.regionMatches(index, "loaded: ", 0, 8)) {
+                    index += 8;
+                    int endIndex = fileContents.indexOf(' ', index);
+                    logger.info("RepositoryAudit: Successful download: '{}'",fileContents.substring(index, endIndex));
+                    index = endIndex;
+                }
+            }
+        }
 
-	@Override
-	 public FileVisitResult postVisitDirectory(Path file, IOException e)
-	   throws IOException
-	   {
-		 if (e == null)
-		   {
-			 file.toFile().delete();
-			 return FileVisitResult.CONTINUE;
-		   }
-		 else
-		   {
-			 throw e;
-		   }
-	   }
-  }
+        /*
+         * 5) Check the contents of the directory to make sure the downloads
+         *    were successful
+         */
+        for (Artifact artifact : artifacts) {
+            if (repo.resolve(artifact.groupId.replace('.','/'))
+                    .resolve(artifact.artifactId)
+                    .resolve(artifact.version)
+                    .resolve(artifact.artifactId + "-" + artifact.version + "."
+                            + artifact.type).toFile().exists()) {
+                // artifact exists, as expected
+                logger.info("RepositoryAudit: {} : exists", artifact.toString());
+            } else {
+                // Audit ERROR: artifact download failed for some reason
+                logger.error("RepositoryAudit: {}: does not exist", artifact.toString());
+                if (!ignoreErrors) {
+                    response.append("Failed to download artifact: ")
+                    .append(artifact).append('\n');
+                    setResponse(response.toString());
+                }
+            }
+        }
 
-/* ============================================================ */
+        /*
+         * 6) Use 'curl' to delete the uploaded test file
+         *    (only if repository information is specified)
+         */
+        if (upload) {
+            if (runProcess(timeoutInSeconds, dir.toFile(), null,
+                            "curl",
+                            "--request", "DELETE",
+                            "--user", repositoryUsername + ":" + repositoryPassword,
+                            repositoryUrl + "/" + groupId.replace('.', '/') + "/"
+                                    + artifactId + "/" + version)
+                    != 0) {
+                logger.error("RepositoryAudit: delete of uploaded artifact failed");
+                if (!ignoreErrors) {
+                    response.append("delete of uploaded artifact failed\n");
+                    setResponse(response.toString());
+                }
+            } else {
+                logger.info("RepositoryAudit: delete of uploaded artifact succeeded");
+                artifacts.add(new Artifact(groupId, artifactId, version, "txt"));
+            }
+        }
 
-  /**
-   * An instance of this class exists for each artifact that we are trying
-   * to download.
-   */
-  static class Artifact
-  {
-	String groupId;
-	String artifactId;
-	String version;
-	String type;
+        /*
+         * 7) Remove the temporary directory
+         */
+        Files.walkFileTree(dir, new RecursivelyDeleteDirectory());
+    }
 
-	/**
-	 * Constructor - populate the 'Artifact' instance
-	 *
-	 * @param groupId groupId of artifact
-	 * @param artifactId artifactId of artifact
-	 * @param version version of artifact
-	 * @param type type of the artifact (e.g. "jar")
-	 */
-	Artifact(String groupId, String artifactId, String version, String type)
-	{
-	  this.groupId = groupId;
-	  this.artifactId = artifactId;
-	  this.version = version;
-	  this.type = type;
-	}
+    /**
+     * Run a process, and wait for the response.
+     *
+     * @param timeoutInSeconds the number of seconds to wait for the process to terminate
+     * @param directory the execution directory of the process (null = current directory)
+     * @param stdout the file to contain the standard output (null = discard standard output)
+     * @param command command and arguments
+     * @return the return value of the process
+     * @throws IOException InterruptedException
+     */
+    static int runProcess(long timeoutInSeconds,
+            File directory, File stdout, String... command)
+                    throws IOException, InterruptedException {
+        ProcessBuilder pb = new ProcessBuilder(command);
+        if (directory != null) {
+            pb.directory(directory);
+        }
+        if (stdout != null) {
+            pb.redirectOutput(stdout);
+        }
 
-	/**
-	 * Constructor - populate an 'Artifact' instance
-	 *
-	 * @param artifact a string of the form:
-	 *		"<groupId>/<artifactId>/<version>[/<type>]"
-	 * @throws IllegalArgumentException if 'artifact' has the incorrect format
-	 */
-	Artifact(String artifact)
-	{
-	  String[] segments = artifact.split("/");
-	  if (segments.length != 4 && segments.length != 3)
-		{
-		  throw new IllegalArgumentException("groupId/artifactId/version/type");
-		}
-	  groupId = segments[0];
-	  artifactId = segments[1];
-	  version = segments[2];
-	  type = segments.length == 4 ? segments[3] : "jar";
-	}
+        Process process = pb.start();
+        if (process.waitFor(timeoutInSeconds, TimeUnit.SECONDS)) {
+            // process terminated before the timeout
+            return process.exitValue();
+        }
 
-	/**
-	 * @return the artifact id in the form:
-	 *		"<groupId>/<artifactId>/<version>/<type>"
-	 */
-	@Override
-	public String toString()
-	{
-	  return groupId + "/" + artifactId + "/" + version + "/" + type;
-	}
-  }
+        // process timed out -- kill it, and return -1
+        process.destroyForcibly();
+        return -1;
+    }
+
+    /**
+     * This class is used to recursively delete a directory and all of its
+     * contents.
+     */
+    private final class RecursivelyDeleteDirectory extends SimpleFileVisitor<Path> {
+        @Override
+        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
+            file.toFile().delete();
+            return FileVisitResult.CONTINUE;
+        }
+
+        @Override
+        public FileVisitResult postVisitDirectory(Path file, IOException ex)
+                throws IOException {
+            if (ex == null) {
+                file.toFile().delete();
+                return FileVisitResult.CONTINUE;
+            } else {
+                throw ex;
+            }
+        }
+    }
+
+    /* ============================================================ */
+
+    /**
+     * An instance of this class exists for each artifact that we are trying
+     * to download.
+     */
+    static class Artifact {
+        String groupId;
+        String artifactId;
+        String version;
+        String type;
+
+        /**
+         * Constructor - populate the 'Artifact' instance.
+         *
+         * @param groupId groupId of artifact
+         * @param artifactId artifactId of artifact
+         * @param version version of artifact
+         * @param type type of the artifact (e.g. "jar")
+         */
+        Artifact(String groupId, String artifactId, String version, String type) {
+            this.groupId = groupId;
+            this.artifactId = artifactId;
+            this.version = version;
+            this.type = type;
+        }
+
+        /**
+         * Constructor - populate an 'Artifact' instance.
+         *
+         * @param artifact a string of the form:
+         * {@code"<groupId>/<artifactId>/<version>[/<type>]"}
+         * @throws IllegalArgumentException if 'artifact' has the incorrect format
+         */
+        Artifact(String artifact) {
+            String[] segments = artifact.split("/");
+            if (segments.length != 4 && segments.length != 3) {
+                throw new IllegalArgumentException("groupId/artifactId/version/type");
+            }
+            groupId = segments[0];
+            artifactId = segments[1];
+            version = segments[2];
+            type = segments.length == 4 ? segments[3] : "jar";
+        }
+
+        /**
+         * Returns string representation.
+         * 
+         * @return the artifact id in the form: {@code"<groupId>/<artifactId>/<version>/<type>"}
+         */
+        @Override
+        public String toString() {
+            return groupId + "/" + artifactId + "/" + version + "/" + type;
+        }
+    }
 }
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
index cb1700e..d7f9d10 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-state-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -38,227 +38,218 @@
  * active/standby state management and IntegrityMonitor. For now, they are
  * all treated as a single feature, but it would be nice to separate them.
  *
- * The bulk of the code here was once in other classes, such as
+ * <p>The bulk of the code here was once in other classes, such as
  * 'PolicyContainer' and 'Main'. It was moved here as part of making this
  * a separate optional feature.
  */
 
 public class StateManagementFeature implements StateManagementFeatureAPI, 
-				PolicySessionFeatureAPI, PolicyEngineFeatureAPI
-{
-	// get an instance of logger
-	private static final Logger logger =
-			LoggerFactory.getLogger(StateManagementFeature.class);
-	
-	private DroolsPDPIntegrityMonitor droolsPdpIntegrityMonitor = null;
-	private StateManagement stateManagement = null;
+    PolicySessionFeatureAPI, PolicyEngineFeatureAPI {
+    // get an instance of logger
+    private static final Logger logger =
+            LoggerFactory.getLogger(StateManagementFeature.class);
 
-	/**************************/
-	/* 'FeatureAPI' interface */
-	/**************************/
+    private DroolsPDPIntegrityMonitor droolsPdpIntegrityMonitor = null;
+    private StateManagement stateManagement = null;
 
-	public StateManagementFeature(){
-		logger.debug("StateManagementFeature() constructor");
-	}
-	
-	@Override
-	public void globalInit(String[] args, String configDir)
-	{
-		// Initialization code associated with 'PolicyContainer'
-		logger.debug("StateManagementFeature.globalInit({}) entry", configDir);
+    public StateManagementFeature() {
+        logger.debug("StateManagementFeature() constructor");
+    }
 
-		try
-		{
-			droolsPdpIntegrityMonitor = DroolsPDPIntegrityMonitor.init(configDir);
-		}
-		catch (Exception e)
-		{
-			logger.debug("DroolsPDPIntegrityMonitor initialization exception: ", e);
-			logger.error("DroolsPDPIntegrityMonitor.init()", e);
-		}
+    @Override
+    public void globalInit(String[] args, String configDir) {
+        // Initialization code associated with 'PolicyContainer'
+        logger.debug("StateManagementFeature.globalInit({}) entry", configDir);
 
-		initializeProperties(configDir);
+        try {
+            droolsPdpIntegrityMonitor = DroolsPDPIntegrityMonitor.init(configDir);
+        } catch (Exception e) {
+            logger.debug("DroolsPDPIntegrityMonitor initialization exception: ", e);
+            logger.error("DroolsPDPIntegrityMonitor.init()", e);
+        }
 
-		//At this point the DroolsPDPIntegrityMonitor instance must exist. Let's check it.
-		try {
-			droolsPdpIntegrityMonitor = DroolsPDPIntegrityMonitor.getInstance();
-			stateManagement = droolsPdpIntegrityMonitor.getStateManager();
-			
-			if (stateManagement == null) {
-				logger.debug("StateManagementFeature.globalInit(): stateManagement is NULL!");
-			}
-			else {
-				logger.debug("StateManagementFeature.globalInit(): "
-						+ "stateManagement.getAdminState(): {}", stateManagement.getAdminState());
-			}
-		} catch (Exception e1) {
-			logger.debug("StateManagementFeature.globalInit(): DroolsPDPIntegrityMonitor"
-				+ " initialization failed with exception:", e1);
-			logger.error("DroolsPDPIntegrityMonitor.init(): StateManagementFeature startup failed "
-					+ "to get DroolsPDPIntegrityMonitor instance:", e1);
-		}
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void addObserver(Observer stateChangeObserver) {
-		logger.debug("StateManagementFeature.addObserver() entry\n"
-				+ "StateManagementFeature.addObserver(): "
-				+ "stateManagement.getAdminState(): {}", stateManagement.getAdminState());
-		
-		stateManagement.addObserver(stateChangeObserver);
-		
-		logger.debug("StateManagementFeature.addObserver() exit");
-	}
+        initializeProperties(configDir);
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getAdminState() {
-		return stateManagement.getAdminState();
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getOpState() {
-		return stateManagement.getOpState();
-	}
+        //At this point the DroolsPDPIntegrityMonitor instance must exist. Let's check it.
+        try {
+            droolsPdpIntegrityMonitor = DroolsPDPIntegrityMonitor.getInstance();
+            stateManagement = droolsPdpIntegrityMonitor.getStateManager();
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getAvailStatus() {
-		return stateManagement.getAvailStatus();
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getStandbyStatus() {
-		return stateManagement.getStandbyStatus();
-	}
+            if (stateManagement == null) {
+                logger.debug("StateManagementFeature.globalInit(): stateManagement is NULL!");
+            }
+            else {
+                logger.debug("StateManagementFeature.globalInit(): "
+                        + "stateManagement.getAdminState(): {}", stateManagement.getAdminState());
+            }
+        } catch (Exception e1) {
+            logger.debug("StateManagementFeature.globalInit(): DroolsPDPIntegrityMonitor"
+                    + " initialization failed with exception:", e1);
+            logger.error("DroolsPDPIntegrityMonitor.init(): StateManagementFeature startup failed "
+                    + "to get DroolsPDPIntegrityMonitor instance:", e1);
+        }
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getStandbyStatus(String resourceName) {
-		return stateManagement.getStandbyStatus(resourceName);
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addObserver(Observer stateChangeObserver) {
+        logger.debug("StateManagementFeature.addObserver() entry\n"
+                + "StateManagementFeature.addObserver(): "
+                + "stateManagement.getAdminState(): {}", stateManagement.getAdminState());
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void disableFailed(String resourceName) throws Exception {
-		stateManagement.disableFailed(resourceName);
+        stateManagement.addObserver(stateChangeObserver);
 
-	}
+        logger.debug("StateManagementFeature.addObserver() exit");
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void disableFailed() throws Exception {
-		stateManagement.disableFailed();
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getAdminState() {
+        return stateManagement.getAdminState();
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void promote() throws Exception {
-		stateManagement.promote();		
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getOpState() {
+        return stateManagement.getOpState();
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void demote() throws Exception {
-		stateManagement.demote();
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public String getResourceName() {
-		return StateManagementProperties.getProperty(StateManagementProperties.NODE_NAME);
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 * @return 
-	 */
-	@Override
-	public boolean lock(){
-		try{
-			stateManagement.lock();
-		}catch(Exception e){
-			logger.error("StateManagementFeature.lock() failed with exception: {}", e);
-			return false;
-		}
-		return true;
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 * @throws Exception 
-	 */
-	@Override
-	public boolean unlock(){
-		try{
-			stateManagement.unlock();
-		}catch(Exception e){
-			logger.error("StateManagementFeature.unlock() failed with exception: {}", e);
-			return false;
-		}
-		return true;
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 * @throws Exception 
-	 */
-	@Override
-	public boolean isLocked(){
-		return StateManagement.LOCKED.equals(stateManagement.getAdminState());
-	}
-	
-	@Override
-	public int getSequenceNumber() {
-		return SEQ_NUM;
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getAvailStatus() {
+        return stateManagement.getAvailStatus();
+    }
 
-	/**
-	 * Read in the properties and initialize the StateManagementProperties.
-	 */
-	private static void initializeProperties(String configDir)
-	{
-		//Get the state management properties 
-		try {
-			Properties pIm =
-					PropertyUtil.getProperties(configDir + "/feature-state-management.properties");
-			StateManagementProperties.initProperties(pIm);
-			logger.info("initializeProperties: resourceName= {}", StateManagementProperties.getProperty(StateManagementProperties.NODE_NAME));
-		} catch (IOException e1) {
-			logger.error("initializeProperties", e1);
-		}
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getStandbyStatus() {
+        return stateManagement.getStandbyStatus();
+    }
 
-	@Override
-	public void allSeemsWell(String key, Boolean asw, String msg)
-			throws AllSeemsWellException {
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getStandbyStatus(String resourceName) {
+        return stateManagement.getStandbyStatus(resourceName);
+    }
 
-		droolsPdpIntegrityMonitor.allSeemsWell(key, asw, msg);
-		
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void disableFailed(String resourceName) throws Exception {
+        stateManagement.disableFailed(resourceName);
+
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void disableFailed() throws Exception {
+        stateManagement.disableFailed();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void promote() throws Exception {
+        stateManagement.promote();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void demote() throws Exception {
+        stateManagement.demote();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getResourceName() {
+        return StateManagementProperties.getProperty(StateManagementProperties.NODE_NAME);
+    }
+
+    /**
+     * {@inheritDoc}
+     * @return 
+     */
+    @Override
+    public boolean lock() {
+        try {
+            stateManagement.lock();
+        } catch (Exception e) {
+            logger.error("StateManagementFeature.lock() failed with exception: {}", e);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     * @throws Exception exception
+     */
+    @Override
+    public boolean unlock() {
+        try {
+            stateManagement.unlock();
+        } catch (Exception e) {
+            logger.error("StateManagementFeature.unlock() failed with exception: {}", e);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     * @throws Exception exception 
+     */
+    @Override
+    public boolean isLocked() {
+        return StateManagement.LOCKED.equals(stateManagement.getAdminState());
+    }
+
+    @Override
+    public int getSequenceNumber() {
+        return SEQ_NUM;
+    }
+
+    /**
+     * Read in the properties and initialize the StateManagementProperties.
+     */
+    private static void initializeProperties(String configDir) {
+        //Get the state management properties 
+        try {
+            Properties props =
+                    PropertyUtil.getProperties(configDir + "/feature-state-management.properties");
+            StateManagementProperties.initProperties(props);
+            logger.info("initializeProperties: resourceName= {}", 
+                    StateManagementProperties.getProperty(StateManagementProperties.NODE_NAME));
+        } catch (IOException e1) {
+            logger.error("initializeProperties", e1);
+        }
+    }
+
+    @Override
+    public void allSeemsWell(String key, Boolean asw, String msg)
+            throws AllSeemsWellException {
+
+        droolsPdpIntegrityMonitor.allSeemsWell(key, asw, msg);
+
+    }
 }
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
index 3835622..471745d 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-state-management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -65,15 +65,16 @@
 
     private StateManagementProperties() {}
 
-    /*
-     * Initialize the parameter values from the feature-state-management.properties file values
+    /**
+     * Initialize the parameter values from the feature-state-management.properties file values.
      * 
-     * This is designed so that the Properties object is obtained from the
+     * <p>This is designed so that the Properties object is obtained from the
      * feature-state-management.properties file and then is passed to this method to initialize the
      * value of the parameters. This allows the flexibility of JUnit tests using
      * getProperties(filename) to get the properties while runtime methods can use
      * getPropertiesFromClassPath(filename).
      * 
+     * @param prop properties
      */
     public static void initProperties(Properties prop) {
         logger.info("StateManagementProperties.initProperties(Properties): entry");
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java
index 59802eb..a88bcf2 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Feature-State-Management
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,22 +20,23 @@
 
 package org.onap.policy.drools.statemanagement;
 
-public class StateManagementPropertiesException extends Exception{
-	private static final long serialVersionUID = 1L;
-	
-	public StateManagementPropertiesException() {
-		super();
-	}
-	
-	public StateManagementPropertiesException(String message) {
-		super(message);
-	}
+public class StateManagementPropertiesException extends Exception {
+    private static final long serialVersionUID = 1L;
 
-	public StateManagementPropertiesException(Throwable cause) {
-		super(cause);
-	}
-	public StateManagementPropertiesException(String message, Throwable cause) {
-		super(message, cause);
-	}
+    public StateManagementPropertiesException() {
+        super();
+    }
+
+    public StateManagementPropertiesException(String message) {
+        super(message);
+    }
+
+    public StateManagementPropertiesException(Throwable cause) {
+        super(cause);
+    }
+    
+    public StateManagementPropertiesException(String message, Throwable cause) {
+        super(message, cause);
+    }
 
 }
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
index b33171b..943293c 100644
--- 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
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -28,16 +28,16 @@
 import javax.persistence.Table;
 
 @Entity
-@Table(name="Audit")
+@Table(name = "Audit")
 
 public class Audit implements Serializable {
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	@Id
-	@Column(name="name", length=64, unique=true)
-	private String name;
-	
-	public Audit() {
-		//default constructor
-	}
+    @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 b364ef8..5c69284 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
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * policy-persistence
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -49,215 +49,216 @@
 import org.slf4j.LoggerFactory;
 
 public class StateManagementTest {
-		
-	// get an instance of logger 
-	private static Logger  logger = LoggerFactory.getLogger(StateManagementTest.class);	
-	
-	StateManagementFeatureAPI stateManagementFeature;
-	
-	/*
-	 * All you need to do here is create an instance of StateManagementFeature class.  Then,
-	 * check it initial state and the state after diableFailed() and promote()
-	 */
-	
-	@BeforeClass
-	public static void setUpClass() throws Exception {
-		
-		logger.info("setUpClass: Entering");
 
-		String userDir = System.getProperty("user.dir");
-		logger.debug("setUpClass: userDir=" + userDir);
-		System.setProperty("com.sun.management.jmxremote.port", "9980");
-		System.setProperty("com.sun.management.jmxremote.authenticate","false");
-				
-		initializeDb();
-		
-		logger.info("setUpClass: Exiting");
-	}
+    // get an instance of logger 
+    private static Logger  logger = LoggerFactory.getLogger(StateManagementTest.class);
 
-	@AfterClass
-	public static void tearDownClass() throws Exception {
-				
-	}
+    StateManagementFeatureAPI stateManagementFeature;
 
-	@Before
-	public void setUp() throws Exception {
-		
-	}
+    /**
+     * Setup the class.
+     * All you need to do here is create an instance of StateManagementFeature class.  Then,
+     * check it initial state and the state after diableFailed() and promote()
+     * 
+     * @throws Exception exception
+     */
+    @BeforeClass
+    public static void setUpClass() throws Exception {
 
-	@After
-	public void tearDown() throws Exception {
-		
-	}
-	
-	/*
-	 * Verifies that StateManagementFeature starts and runs successfully.
-	 */
-	 
-	//@Ignore
-	@Test
-	public void testStateManagementOperation() throws Exception {
-		
-		logger.debug("\n\ntestStateManagementOperation: Entering\n\n");
+        logger.info("setUpClass: Entering");
 
-		logger.debug("testStateManagementOperation: Reading StateManagementProperties");
+        String userDir = System.getProperty("user.dir");
+        logger.debug("setUpClass: userDir=" + userDir);
+        System.setProperty("com.sun.management.jmxremote.port", "9980");
+        System.setProperty("com.sun.management.jmxremote.authenticate","false");
 
-		String configDir = "src/test/resources";
-		
-		DbAudit.setIsJunit(true);
-		
-		Properties fsmProperties = new Properties();
-		fsmProperties.load(new FileInputStream(new File(
-				configDir + "/feature-state-management.properties")));
-		String thisPdpId = fsmProperties
-				.getProperty(StateManagementProperties.NODE_NAME);
+        initializeDb();
 
-		StateManagementFeatureAPI stateManagementFeature = null;
-		for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList())
-		{
-			((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
-			stateManagementFeature = feature;
-			logger.debug("testStateManagementOperation stateManagementFeature.getResourceName(): " + stateManagementFeature.getResourceName());
-			break;
-		}
-		if(stateManagementFeature == null){
-			String msg = "testStateManagementOperation failed to initialize.  "
-					+ "Unable to get instance of StateManagementFeatureAPI "
-					+ "with resourceID: " + thisPdpId;
-			logger.error(msg);
-			logger.debug(msg);
-		}
-		
-		String admin = stateManagementFeature.getAdminState();
-		String oper = stateManagementFeature.getOpState();
-		String avail = stateManagementFeature.getAvailStatus();
-		String standby = stateManagementFeature.getStandbyStatus();
-		
-		logger.debug("admin = {}", admin);
-		logger.debug("oper = {}", oper);
-		logger.debug("avail = {}", avail);
-		logger.debug("standby = {}", standby);
-		
-		assertTrue("Admin state not unlocked after initialization", admin.equals(StateManagement.UNLOCKED));
-		assertTrue("Operational state not enabled after initialization", oper.equals(StateManagement.ENABLED));
-		
-		try{
-			stateManagementFeature.disableFailed();
-		}catch(Exception e){
-			logger.error(e.getMessage());
-			assertTrue(e.getMessage(), false);
-		}
-				
-		admin = stateManagementFeature.getAdminState();
-		oper = stateManagementFeature.getOpState();
-		avail = stateManagementFeature.getAvailStatus();
-		standby = stateManagementFeature.getStandbyStatus();
-		
-		logger.debug("after disableFailed()");
-		logger.debug("admin = {}", admin);
-		logger.debug("oper = {}", oper);
-		logger.debug("avail = {}", avail);
-		logger.debug("standby = {}", standby);
-		
-		assertTrue("Operational state not disabled after disableFailed()", oper.equals(StateManagement.DISABLED));
-		assertTrue("Availability status not failed after disableFailed()", avail.equals(StateManagement.FAILED));
-		
-		
-		try{
-			stateManagementFeature.promote();
-		}catch(Exception e){
-			logger.debug(e.getMessage());
-		}
-		
-		admin = stateManagementFeature.getAdminState();
-		oper = stateManagementFeature.getOpState();
-		avail = stateManagementFeature.getAvailStatus();
-		standby = stateManagementFeature.getStandbyStatus();
-		
-		logger.debug("after promote()");
-		logger.debug("admin = {}", admin);
-		logger.debug("oper = {}", oper);
-		logger.debug("avail = {}", avail);
-		logger.debug("standby = {}", standby);
+        logger.info("setUpClass: Exiting");
+    }
 
-		assertTrue("Standby status not coldstandby after promote()", standby.equals(StateManagement.COLD_STANDBY));
+    @AfterClass
+    public static void tearDownClass() throws Exception {
 
-		/**************Repository Audit Test**************/
-		logger.debug("\n\ntestStateManagementOperation: Repository Audit\n\n");
-		try{
-			StateManagementProperties.initProperties(fsmProperties);
-			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");
+    @Before
+    public void setUp() throws Exception {
 
-		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"));
+    @After
+    public void tearDown() throws Exception {
 
-		//All done
-		logger.debug("\n\ntestStateManagementOperation: Exiting\n\n");
-	}	
-	
+    }
+
     /*
+     * Verifies that StateManagementFeature starts and runs successfully.
+     */
+
+    //@Ignore
+    @Test
+    public void testStateManagementOperation() throws Exception {
+
+        logger.debug("\n\ntestStateManagementOperation: Entering\n\n");
+
+        logger.debug("testStateManagementOperation: Reading StateManagementProperties");
+
+        String configDir = "src/test/resources";
+
+        DbAudit.setIsJunit(true);
+
+        Properties fsmProperties = new Properties();
+        fsmProperties.load(new FileInputStream(new File(
+                configDir + "/feature-state-management.properties")));
+        String thisPdpId = fsmProperties
+                .getProperty(StateManagementProperties.NODE_NAME);
+
+        StateManagementFeatureAPI stateManagementFeature = null;
+        for (StateManagementFeatureAPI feature : StateManagementFeatureAPI.impl.getList()) {
+            ((PolicySessionFeatureAPI) feature).globalInit(null, configDir);
+            stateManagementFeature = feature;
+            logger.debug("testStateManagementOperation stateManagementFeature.getResourceName(): " 
+                + stateManagementFeature.getResourceName());
+            break;
+        }
+        if (stateManagementFeature == null) {
+            String msg = "testStateManagementOperation failed to initialize.  "
+                    + "Unable to get instance of StateManagementFeatureAPI "
+                    + "with resourceID: " + thisPdpId;
+            logger.error(msg);
+            logger.debug(msg);
+        }
+
+        String admin = stateManagementFeature.getAdminState();
+        String oper = stateManagementFeature.getOpState();
+        String avail = stateManagementFeature.getAvailStatus();
+        String standby = stateManagementFeature.getStandbyStatus();
+
+        logger.debug("admin = {}", admin);
+        logger.debug("oper = {}", oper);
+        logger.debug("avail = {}", avail);
+        logger.debug("standby = {}", standby);
+
+        assertTrue("Admin state not unlocked after initialization", admin.equals(StateManagement.UNLOCKED));
+        assertTrue("Operational state not enabled after initialization", oper.equals(StateManagement.ENABLED));
+
+        try {
+            stateManagementFeature.disableFailed();
+        } catch (Exception e) {
+            logger.error(e.getMessage());
+            assertTrue(e.getMessage(), false);
+        }
+
+        admin = stateManagementFeature.getAdminState();
+        oper = stateManagementFeature.getOpState();
+        avail = stateManagementFeature.getAvailStatus();
+        standby = stateManagementFeature.getStandbyStatus();
+
+        logger.debug("after disableFailed()");
+        logger.debug("admin = {}", admin);
+        logger.debug("oper = {}", oper);
+        logger.debug("avail = {}", avail);
+        logger.debug("standby = {}", standby);
+
+        assertTrue("Operational state not disabled after disableFailed()", oper.equals(StateManagement.DISABLED));
+        assertTrue("Availability status not failed after disableFailed()", avail.equals(StateManagement.FAILED));
+
+
+        try {
+            stateManagementFeature.promote();
+        } catch (Exception e) {
+            logger.debug(e.getMessage());
+        }
+
+        admin = stateManagementFeature.getAdminState();
+        oper = stateManagementFeature.getOpState();
+        avail = stateManagementFeature.getAvailStatus();
+        standby = stateManagementFeature.getStandbyStatus();
+
+        logger.debug("after promote()");
+        logger.debug("admin = {}", admin);
+        logger.debug("oper = {}", oper);
+        logger.debug("avail = {}", avail);
+        logger.debug("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 {
+            StateManagementProperties.initProperties(fsmProperties);
+            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");
+    }
+
+    /**
      * This method initializes and cleans the DB so that PDP-D will be able to 
      * store fresh records in the DB.
      */
-     
-	public static void initializeDb(){
-		
-		logger.debug("initializeDb: Entering");
-		
-    	Properties cleanProperties = new Properties();
-    	cleanProperties.put(StateManagementProperties.DB_DRIVER,"org.h2.Driver");
-    	cleanProperties.put(StateManagementProperties.DB_URL, "jdbc:h2:file:./sql/statemanagement");
-    	cleanProperties.put(StateManagementProperties.DB_USER, "sa");
-    	cleanProperties.put(StateManagementProperties.DB_PWD, "");
+    public static void initializeDb() {
 
-    	EntityManagerFactory emf = Persistence.createEntityManagerFactory("junitPU", cleanProperties);
-		
-		EntityManager em = emf.createEntityManager();
-		// Start a transaction
-		EntityTransaction et = em.getTransaction();
+        logger.debug("initializeDb: Entering");
 
-		et.begin();
+        Properties cleanProperties = new Properties();
+        cleanProperties.put(StateManagementProperties.DB_DRIVER,"org.h2.Driver");
+        cleanProperties.put(StateManagementProperties.DB_URL, "jdbc:h2:file:./sql/statemanagement");
+        cleanProperties.put(StateManagementProperties.DB_USER, "sa");
+        cleanProperties.put(StateManagementProperties.DB_PWD, "");
 
-		// Clean up the DB
-		em.createQuery("Delete from StateManagementEntity").executeUpdate();
-		em.createQuery("Delete from ForwardProgressEntity").executeUpdate();
-		em.createQuery("Delete from ResourceRegistrationEntity").executeUpdate();
+        EntityManagerFactory emf = Persistence.createEntityManagerFactory("junitPU", cleanProperties);
 
-		// commit transaction
-		et.commit();
-		em.close();
-		
-		logger.debug("initializeDb: Exiting");
-	}	
+        EntityManager em = emf.createEntityManager();
+        // Start a transaction
+        EntityTransaction et = em.getTransaction();
+
+        et.begin();
+
+        // Clean up the DB
+        em.createQuery("Delete from StateManagementEntity").executeUpdate();
+        em.createQuery("Delete from ForwardProgressEntity").executeUpdate();
+        em.createQuery("Delete from ResourceRegistrationEntity").executeUpdate();
+
+        // commit transaction
+        et.commit();
+        em.close();
+
+        logger.debug("initializeDb: Exiting");
+    }
 }
diff --git a/feature-state-management/src/test/resources/META-INF/persistence.xml b/feature-state-management/src/test/resources/META-INF/persistence.xml
index 0214b7f..24dabe1 100644
--- a/feature-state-management/src/test/resources/META-INF/persistence.xml
+++ b/feature-state-management/src/test/resources/META-INF/persistence.xml
@@ -3,7 +3,7 @@
   ============LICENSE_START=======================================================
   feature-state-management
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-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.
@@ -20,21 +20,31 @@
   -->
 
 <persistence version="2.1"
-	xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
 
-	<persistence-unit name="junitPU" transaction-type="RESOURCE_LOCAL">
-		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-		<class>org.onap.policy.common.im.jpa.StateManagementEntity</class>
-		<class>org.onap.policy.common.im.jpa.ForwardProgressEntity</class>
-		<class>org.onap.policy.common.im.jpa.ResourceRegistrationEntity</class>
-		<class>org.onap.policy.drools.statemanagement.test.Audit</class>
-		<properties>
-			<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
-			<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/> 
-            <property name="javax.persistence.schema-generation.scripts.create-target" value="./sql/generatedCreateStateManagement.ddl"/>
-            <property name="javax.persistence.schema-generation.scripts.drop-target" value="./sql/generatedDropStateManagement.ddl"/>
+    <persistence-unit name="junitPU"
+        transaction-type="RESOURCE_LOCAL">
+        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+        <class>org.onap.policy.common.im.jpa.StateManagementEntity</class>
+        <class>org.onap.policy.common.im.jpa.ForwardProgressEntity</class>
+        <class>org.onap.policy.common.im.jpa.ResourceRegistrationEntity</class>
+        <class>org.onap.policy.drools.statemanagement.test.Audit</class>
+        <properties>
+            <property
+                name="javax.persistence.schema-generation.database.action"
+                value="drop-and-create" />
+            <property
+                name="javax.persistence.schema-generation.scripts.action"
+                value="drop-and-create" />
+            <property
+                name="javax.persistence.schema-generation.scripts.create-target"
+                value="./sql/generatedCreateStateManagement.ddl" />
+            <property
+                name="javax.persistence.schema-generation.scripts.drop-target"
+                value="./sql/generatedDropStateManagement.ddl" />
         </properties>
-	</persistence-unit>
+    </persistence-unit>
 
 </persistence>
diff --git a/feature-state-management/src/test/resources/logback-test.xml b/feature-state-management/src/test/resources/logback-test.xml
index 58cabf9..99cdaf9 100644
--- a/feature-state-management/src/test/resources/logback-test.xml
+++ b/feature-state-management/src/test/resources/logback-test.xml
@@ -2,7 +2,7 @@
   ============LICENSE_START=======================================================
   feature-state-management
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-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.
@@ -22,26 +22,29 @@
 
 <configuration>
 
-	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
-		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
-			<Pattern>
-				%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
-			</Pattern>
-		</encoder>
-	</appender>
-	<appender name="FILE" class="ch.qos.logback.core.FileAppender">
-		<file>logs/debug.log</file>
-		<encoder>
-			<Pattern>
-				%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
-			</Pattern>
-		</encoder>
-	</appender>
-	
-	<root level="debug">
-		<appender-ref ref="STDOUT" />
-		<appender-ref ref="FILE" />
-	</root>
+    <appender name="STDOUT"
+        class="ch.qos.logback.core.ConsoleAppender">
+        <encoder
+            class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <Pattern>
+                %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+            </Pattern>
+        </encoder>
+    </appender>
+    <appender name="FILE"
+        class="ch.qos.logback.core.FileAppender">
+        <file>logs/debug.log</file>
+        <encoder>
+            <Pattern>
+                %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+            </Pattern>
+        </encoder>
+    </appender>
+
+    <root level="debug">
+        <appender-ref ref="STDOUT" />
+        <appender-ref ref="FILE" />
+    </root>
 
 </configuration>
 
diff --git a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java
index 5e209fa..3adecdd 100644
--- a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java
+++ b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-test-transaction
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -17,6 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.drools.testtransaction;
 
 import java.util.EventObject;
@@ -29,203 +30,219 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * TestTransaction interface
- *
- */
+/** TestTransaction interface. */
 public interface TestTransaction {
 
-  public static final String TT_FPC = "TT.FPC";
-  public static final String TT_COUNTER = "$ttc";
-  public static final String TT_UUID = "43868e59-d1f3-43c2-bd6f-86f89a61eea5";
-  public static long DEFAULT_TT_TASK_SLEEP = 20000;
+    public static final String TT_FPC = "TT.FPC";
+    public static final String TT_COUNTER = "$ttc";
+    public static final String TT_UUID = "43868e59-d1f3-43c2-bd6f-86f89a61eea5";
+    public static long DEFAULT_TT_TASK_SLEEP = 20000;
 
-  public static final TestTransaction manager = new TTImpl();
+    public static final TestTransaction manager = new TTImpl();
 
-  /**
-   * register a controller for monitoring test transactions
-   *
-   * @param controller policy controller
-   */
-  public void register(PolicyController controller);
+    /**
+     * register a controller for monitoring test transactions.
+     *
+     * @param controller policy controller
+     */
+    public void register(PolicyController controller);
 
-  /**
-   * unregisters a controller for monitoring test transactions
-   *
-   * @param controller policy controller
-   */
-  public void unregister(PolicyController controller);
+    /**
+     * unregisters a controller for monitoring test transactions.
+     *
+     * @param controller policy controller
+     */
+    public void unregister(PolicyController controller);
 }
 
-
 /**
  * Implementation of TestTransaction interface. Controls the registering/unregistering of
  * PolicyController objects and the management of their related TTControllerTask threads.
  */
 class TTImpl implements TestTransaction {
 
-  protected final Map<String, TTControllerTask> controllers = new HashMap<>();
+    protected final Map<String, TTControllerTask> controllers = new HashMap<>();
 
-  @Override
-  public synchronized void register(PolicyController controller) {
-    if (this.controllers.containsValue(controller)) {
-      final TTControllerTask controllerTask = this.controllers.get(controller.getName());
-      if (controllerTask.isAlive())
-        return;
+    @Override
+    public synchronized void register(PolicyController controller) {
+        if (this.controllers.containsValue(controller)) {
+            final TTControllerTask controllerTask = this.controllers.get(controller.getName());
+            if (controllerTask.isAlive()) {
+                return;
+            }
 
-      // continue : unregister, register operation
+            // continue : unregister, register operation
+        }
+
+        final TTControllerTask controllerTask = new TTControllerTask(controller);
+        this.controllers.put(controller.getName(), controllerTask);
     }
 
-    final TTControllerTask controllerTask = new TTControllerTask(controller);
-    this.controllers.put(controller.getName(), controllerTask);
-  }
+    @Override
+    public synchronized void unregister(PolicyController controller) {
+        if (!this.controllers.containsValue(controller)) {
+            return;
+        }
 
-  @Override
-  public synchronized void unregister(PolicyController controller) {
-    if (!this.controllers.containsValue(controller))
-      return;
+        final TTControllerTask controllerTask = this.controllers.get(controller.getName());
+        controllerTask.stop();
 
-    final TTControllerTask controllerTask = this.controllers.get(controller.getName());
-    controllerTask.stop();
-
-    this.controllers.remove(controller.getName());
-  }
+        this.controllers.remove(controller.getName());
+    }
 }
 
-
 /**
  * TTControllerTask implements the Runnabale interface Carries out the injection of an event into a
  * drools session and subsequent query of a counter to ensure that forward progress is occuring.
- *
  */
 class TTControllerTask implements Runnable {
 
-  // get an instance of logger
-  private static final Logger logger = LoggerFactory.getLogger(TTControllerTask.class);
+    // get an instance of logger
+    private static final Logger logger = LoggerFactory.getLogger(TTControllerTask.class);
 
-  protected final PolicyController controller;
+    protected final PolicyController controller;
 
-  protected volatile boolean alive = true;
-  protected final Thread thread = new Thread(this);
+    protected volatile boolean alive = true;
+    protected final Thread thread = new Thread(this);
 
-  public TTControllerTask(PolicyController controller) {
-    this.controller = controller;
-    this.thread.setName("tt-controller-task-" + controller.getName());
-    this.thread.start();
-  }
-
-  public PolicyController getController() {
-    return this.controller;
-  }
-
-  public synchronized boolean isAlive() {
-    return this.alive;
-  }
-
-  public synchronized void stop() {
-    this.alive = false;
-    this.thread.interrupt();
-    try {
-      this.thread.join(1000);
-    } catch (final InterruptedException e) {
-      logger.error("TestTransaction thread threw", e);
-      this.thread.interrupt();
+    public TTControllerTask(PolicyController controller) {
+        this.controller = controller;
+        this.thread.setName("tt-controller-task-" + controller.getName());
+        this.thread.start();
     }
-  }
 
-  public Thread getThread() {
-    return this.thread;
-  }
+    public PolicyController getController() {
+        return this.controller;
+    }
 
-  @Override
-  public void run() {
-    try {
-      final List<String> sessions = this.controller.getDrools().getSessionNames();
+    public synchronized boolean isAlive() {
+        return this.alive;
+    }
 
-      if (!(this.controller.getDrools().isBrained())) {
+    public synchronized void stop() {
         this.alive = false;
-        logger.error(this + ": unknown drools controller");
-        return;
-      }
-
-      final DroolsController drools = this.controller.getDrools();
-
-      final HashMap<String, Long> fpcs = new HashMap<>();
-      for (final String session : sessions) {
-        fpcs.put(session, -1L);
-      }
-
-      while (this.controller.isAlive() && !this.controller.isLocked() && drools.isBrained()
-          && this.alive) {
-
-        injectTxIntoSessions(sessions, fpcs, drools);
-
-        if (!this.alive)
-          return;
-
-        if (!Thread.currentThread().isInterrupted())
-          Thread.sleep(TestTransaction.DEFAULT_TT_TASK_SLEEP);
-      }
-    } catch (final InterruptedException e) {
-      logger.info("{}: stopping ...", this, e);
-      Thread.currentThread().interrupt();
-    } catch (final IllegalArgumentException e) {
-      logger.error("{}: controller {} has not been enabled for testing: ", this,
-          this.controller.getName(), e.getMessage(), e);
-    } catch (final Exception e) {
-      logger.error("Controller: {} is not testable - TestTransaction caught exception: {} ",
-          this.controller.getName(), e.getMessage());
-      logger.error("TestTransaction thread threw", e);
-    } finally {
-      logger.info("Exiting: {}", this);
-      this.alive = false;
-    }
-  }
-  
-  private void injectTxIntoSessions(List<String> sessions, HashMap<String, Long> fpcs, DroolsController drools) {
-
-      for (final String session : sessions) {
-        final List<Object> facts = this.controller.getDrools().factQuery(session,
-            TestTransaction.TT_FPC, TestTransaction.TT_COUNTER, false);
-        if (facts == null || facts.size() != 1) {
-          /*
-           * unexpected something wrong here, can't expect to recover note this exception is
-           * caught right below at the exit of run()
-           */
-          logger.error(
-              "Controller: {}, with rules artifact: (group) {}, (artifact) {}, (version) {} - FPC query failed after EventObject insertion! ",
-              this.controller.getName(), this.controller.getDrools().getGroupId(),
-              this.controller.getDrools().getArtifactId(),
-              this.controller.getDrools().getVersion());
-          break;
+        this.thread.interrupt();
+        try {
+            this.thread.join(1000);
+        } catch (final InterruptedException e) {
+            logger.error("TestTransaction thread threw", e);
+            this.thread.interrupt();
         }
-        logger.debug("Facts: {}", facts);
+    }
 
-        final long fpc = (Long) facts.get(0);
-        if (fpc != fpcs.get(session))
-          logger.info("Controller: {} , session {}  - Forward progress successful: {} -> {}",
-              this.controller.getName(), session, fpcs.get(session), fpc);
-        else
-          logger.error("Controller: {}, session {} - Forward progress failure: {}",
-              this.controller.getName(), session, fpc);
+    public Thread getThread() {
+        return this.thread;
+    }
 
-        fpcs.put(session, fpc);
-        drools.getContainer().insert(session, new EventObject(TestTransaction.TT_UUID));
-      }
-      
-  }
-  
-  
-  @Override
-  public String toString() {
-    final StringBuilder builder = new StringBuilder();
-    builder.append("TTControllerTask [controller=");
-    builder.append(this.controller);
-    builder.append(", alive=");
-    builder.append(this.alive);
-    builder.append(", thread=");
-    builder.append(this.thread.getName());
-    builder.append("]");
-    return builder.toString();
-  }
+    @Override
+    public void run() {
+        try {
+            final List<String> sessions = this.controller.getDrools().getSessionNames();
+
+            if (!(this.controller.getDrools().isBrained())) {
+                this.alive = false;
+                logger.error(this + ": unknown drools controller");
+                return;
+            }
+
+            final DroolsController drools = this.controller.getDrools();
+
+            final HashMap<String, Long> fpcs = new HashMap<>();
+            for (final String session : sessions) {
+                fpcs.put(session, -1L);
+            }
+
+            while (this.controller.isAlive()
+                    && !this.controller.isLocked()
+                    && drools.isBrained()
+                    && this.alive) {
+
+                injectTxIntoSessions(sessions, fpcs, drools);
+
+                if (!this.alive) {
+                    return;
+                }
+
+                if (!Thread.currentThread().isInterrupted()) {
+                    Thread.sleep(TestTransaction.DEFAULT_TT_TASK_SLEEP);
+                }
+            }
+        } catch (final InterruptedException e) {
+            logger.info("{}: stopping ...", this, e);
+            Thread.currentThread().interrupt();
+        } catch (final IllegalArgumentException e) {
+            logger.error(
+                    "{}: controller {} has not been enabled for testing: ",
+                    this,
+                    this.controller.getName(),
+                    e.getMessage(),
+                    e);
+        } catch (final Exception e) {
+            logger.error(
+                    "Controller: {} is not testable - TestTransaction caught exception: {} ",
+                    this.controller.getName(),
+                    e.getMessage());
+            logger.error("TestTransaction thread threw", e);
+        } finally {
+            logger.info("Exiting: {}", this);
+            this.alive = false;
+        }
+    }
+
+    private void injectTxIntoSessions(
+            List<String> sessions, HashMap<String, Long> fpcs, DroolsController drools) {
+
+        for (final String session : sessions) {
+            final List<Object> facts =
+                    this.controller
+                    .getDrools()
+                    .factQuery(session, TestTransaction.TT_FPC, TestTransaction.TT_COUNTER, false);
+            if (facts == null || facts.size() != 1) {
+                /*
+                 * unexpected something wrong here, can't expect to recover note this exception is
+                 * caught right below at the exit of run()
+                 */
+                logger.error(
+                        "Controller: {}, with rules artifact: (group) {}, (artifact) {}, (version) {} "
+                        + "- FPC query failed after EventObject insertion! ",
+                        this.controller.getName(),
+                        this.controller.getDrools().getGroupId(),
+                        this.controller.getDrools().getArtifactId(),
+                        this.controller.getDrools().getVersion());
+                break;
+            }
+            logger.debug("Facts: {}", facts);
+
+            final long fpc = (Long) facts.get(0);
+            if (fpc != fpcs.get(session)) {
+                logger.info(
+                        "Controller: {} , session {}  - Forward progress successful: {} -> {}",
+                        this.controller.getName(),
+                        session,
+                        fpcs.get(session),
+                        fpc);
+            } else {
+                logger.error(
+                        "Controller: {}, session {} - Forward progress failure: {}",
+                        this.controller.getName(),
+                        session,
+                        fpc);
+            }
+            fpcs.put(session, fpc);
+            drools.getContainer().insert(session, new EventObject(TestTransaction.TT_UUID));
+        }
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder builder = new StringBuilder();
+        builder.append("TTControllerTask [controller=");
+        builder.append(this.controller);
+        builder.append(", alive=");
+        builder.append(this.alive);
+        builder.append(", thread=");
+        builder.append(this.thread.getName());
+        builder.append("]");
+        return builder.toString();
+    }
 }
diff --git a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransactionFeature.java b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransactionFeature.java
index e78668a..956304b 100644
--- a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransactionFeature.java
+++ b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransactionFeature.java
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * feature-test-transaction
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -24,55 +24,52 @@
 import org.onap.policy.drools.system.PolicyController;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 /**
- * TestTransactionFeature implements the PolicyControllerFeatureAPI.
- * TestTransactionFeature is the interface to the TestTransaction feature logic.
- * 
+ * TestTransactionFeature implements the PolicyControllerFeatureAPI. TestTransactionFeature is the
+ * interface to the TestTransaction feature logic.
  */
 public class TestTransactionFeature implements PolicyControllerFeatureAPI {
 
-    // get an instance of logger 
-	private static final Logger logger = LoggerFactory.getLogger(TestTransactionFeature.class); 
-	
+    // get an instance of logger
+    private static final Logger logger = LoggerFactory.getLogger(TestTransactionFeature.class);
+
     @Override
-    public boolean afterStart(PolicyController controller){
-        
+    public boolean afterStart(PolicyController controller) {
+
         logger.info("TEST_TRANSACTION FEATURE LOADED");
-        
-        if (controller.isAlive() &&
-            !controller.isLocked() && 
-            controller.getDrools().isBrained())
-        	TestTransaction.manager.register(controller);
-        
+
+        if (controller.isAlive() && !controller.isLocked() && controller.getDrools().isBrained()) {
+            TestTransaction.manager.register(controller);
+        }
         return false;
     }
-    
+
     @Override
     public boolean afterLock(PolicyController controller) {
         logger.info("controller {} locked", controller.getName());
-        
+
         TestTransaction.manager.unregister(controller);
         return false;
     }
-    
+
     @Override
     public boolean afterUnlock(PolicyController controller) {
         logger.info("controller {} unlocked", controller.getName());
-        
-        if (controller.isAlive() &&
-        	!controller.isLocked() && 
-            controller.getDrools().isBrained())
-        	TestTransaction.manager.register(controller);
-        
+
+        if (controller.isAlive() && !controller.isLocked() && controller.getDrools().isBrained()) {
+            TestTransaction.manager.register(controller);
+        }
+
         return false;
     }
 
     @Override
     public boolean beforeStop(PolicyController controller) {
         logger.info("controller {} stopping", controller.getName());
-        
+
         TestTransaction.manager.unregister(controller);
-        
+
         return false;
     }
 
diff --git a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java
index fd373a1..09be93f 100644
--- a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java
+++ b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-test-transaction
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -40,101 +40,93 @@
 import org.slf4j.LoggerFactory;
 
 public class TestTransactionTest {
-  /**
-   * Test JUnit Controller Name
-   */
-  public static final String TEST_CONTROLLER_NAME = "unnamed";
-  /**
-   * Controller Configuration File
-   */
-  public static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
+    /** Test JUnit Controller Name. */
+    public static final String TEST_CONTROLLER_NAME = "unnamed";
+    /** Controller Configuration File. */
+    public static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
 
-  /**
-   * Controller Configuration Backup File
-   */
-  public static final String TEST_CONTROLLER_FILE_BAK =
-      TEST_CONTROLLER_NAME + "-controller.properties.bak";
+    /** Controller Configuration Backup File. */
+    public static final String TEST_CONTROLLER_FILE_BAK =
+            TEST_CONTROLLER_NAME + "-controller.properties.bak";
 
+    /** logger. */
+    private static Logger logger = LoggerFactory.getLogger(TestTransactionTest.class);
 
-  /**
-   * logger
-   */
-  private static Logger logger = LoggerFactory.getLogger(TestTransactionTest.class);
-
-
-
-  @BeforeClass
-  public static void startUp() throws IOException {
-    logger.info("enter");
-
-    cleanUpWorkingDir();
-
-    /* ensure presence of config directory */
-    SystemPersistence.manager.setConfigurationDir(null);
-  }
-
-  @Test
-  public void registerUnregisterTest() throws InterruptedException {
-    final Properties controllerProperties = new Properties();
-    controllerProperties.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
-    final PolicyController controller =
-        PolicyEngine.manager.createPolicyController(TEST_CONTROLLER_NAME, controllerProperties);
-    assertNotNull(PolicyController.factory.get(TEST_CONTROLLER_NAME));
-    logger.info(controller.toString());
-
-    Thread ttThread = null;
-
-    TestTransaction.manager.register(controller);
-    assertNotNull(TestTransaction.manager);
-
-    /*
-     * Unregistering the controller should terminate its TestTransaction thread if it hasn't already
-     * been terminated
+    /**
+     * Start up.
+     * 
+     * @throws IOException exception
      */
-    TestTransaction.manager.unregister(controller);
+    @BeforeClass
+    public static void startUp() throws IOException {
+        logger.info("enter");
 
-    ttThread = this.getThread("tt-controller-task-" + TEST_CONTROLLER_NAME);
-    assertEquals(null, ttThread);
+        cleanUpWorkingDir();
 
-
-  }
-
-  /*
-   * Returns thread object based on String name
-   */
-  public Thread getThread(String threadName) throws InterruptedException {
-    // give a chance to the transaction thread to be spawned/destroyed
-    Thread.sleep(5000L);
-
-    final Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
-    for (final Thread thread : threadSet) {
-      if (thread.getName().equals(threadName)) {
-        return thread;
-      }
-
-    }
-    return null;
-  }
-
-  /**
-   * clean up working directory
-   */
-  protected static void cleanUpWorkingDir() {
-    final Path testControllerPath = Paths
-        .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
-    try {
-      Files.deleteIfExists(testControllerPath);
-    } catch (final Exception e) {
-      logger.info("Problem cleaning {}", testControllerPath, e);
+        /* ensure presence of config directory */
+        SystemPersistence.manager.setConfigurationDir(null);
     }
 
-    final Path testControllerBakPath = Paths
-        .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
-    try {
-      Files.deleteIfExists(testControllerBakPath);
-    } catch (final Exception e) {
-      logger.info("Problem cleaning {}", testControllerBakPath, e);
-    }
-  }
+    @Test
+    public void registerUnregisterTest() throws InterruptedException {
+        final Properties controllerProperties = new Properties();
+        controllerProperties.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
+        final PolicyController controller =
+                PolicyEngine.manager.createPolicyController(TEST_CONTROLLER_NAME, controllerProperties);
+        assertNotNull(PolicyController.factory.get(TEST_CONTROLLER_NAME));
+        logger.info(controller.toString());
 
+        TestTransaction.manager.register(controller);
+        assertNotNull(TestTransaction.manager);
+
+        /*
+         * Unregistering the controller should terminate its TestTransaction thread if it hasn't already
+         * been terminated
+         */
+        TestTransaction.manager.unregister(controller);
+
+        Thread ttThread = this.getThread("tt-controller-task-" + TEST_CONTROLLER_NAME);
+        assertEquals(null, ttThread);
+    }
+
+    /**
+     * Returns thread object based on String name.
+     * 
+     * @param threadName thread name
+     * @return the thread
+     * @throws InterruptedException exception
+     */
+    public Thread getThread(String threadName) throws InterruptedException {
+        // give a chance to the transaction thread to be spawned/destroyed
+        Thread.sleep(5000L);
+
+        final Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
+        for (final Thread thread : threadSet) {
+            if (thread.getName().equals(threadName)) {
+                return thread;
+            }
+        }
+        return null;
+    }
+
+    /** clean up working directory. */
+    protected static void cleanUpWorkingDir() {
+        final Path testControllerPath =
+                Paths.get(
+                        SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
+        try {
+            Files.deleteIfExists(testControllerPath);
+        } catch (final Exception e) {
+            logger.info("Problem cleaning {}", testControllerPath, e);
+        }
+
+        final Path testControllerBakPath =
+                Paths.get(
+                        SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
+        try {
+            Files.deleteIfExists(testControllerBakPath);
+        } catch (final Exception e) {
+            logger.info("Problem cleaning {}", testControllerBakPath, e);
+        }
+    }
 }
