diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java | 879 |
1 files changed, 518 insertions, 361 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java b/pki/base/common/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java index 5a8c61b2b..209be47df 100644 --- a/pki/base/common/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java +++ b/pki/base/common/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java @@ -20,6 +20,7 @@ package com.netscape.cmscore.selftests; + /////////////////////// // import statements // /////////////////////// @@ -48,6 +49,7 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTest; import com.netscape.certsrv.selftests.ISelfTestSubsystem; + ////////////////////// // class definition // ////////////////////// @@ -60,18 +62,23 @@ import com.netscape.certsrv.selftests.ISelfTestSubsystem; * @author thomask * @version $Revision$, $Date$ */ -public class SelfTestSubsystem implements ISelfTestSubsystem { - // ////////////////////// +public class SelfTestSubsystem + implements ISelfTestSubsystem { + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// + - // ///////////////////// + + /////////////////////// // helper parameters // - // ///////////////////// + /////////////////////// + - // //////////////////////////////// + + ////////////////////////////////// // SelfTestSubsystem parameters // - // //////////////////////////////// + ////////////////////////////////// private ISubsystem mOwner = null; private IConfigStore mConfig = null; @@ -85,31 +92,34 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { public Vector mOnDemandOrder = new Vector(); public Vector mStartupOrder = new Vector(); - // ///////////////////////// + /////////////////////////// // ISubsystem parameters // - // ///////////////////////// + /////////////////////////// private static final String LIST_DELIMITER = ","; private static final String ELEMENT_DELIMITER = ":"; private static final String CRITICAL = "critical"; - private static final String LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION = "LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION_2"; + private static final String LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION = + "LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION_2"; - // /////////////////// + ///////////////////// // default methods // - // /////////////////// + ///////////////////// + + - // ////////////////// + //////////////////// // helper methods // - // ////////////////// + //////////////////// /** * Signed Audit Log - * + * * This helper method is called to store messages to the signed audit log. * <P> - * + * * @param msg signed audit log message */ private void audit(String msg) { @@ -120,8 +130,11 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { return; } - mSignedAuditLogger.log(ILogger.EV_SIGNED_AUDIT, null, - ILogger.S_SIGNED_AUDIT, ILogger.LL_SECURITY, msg); + mSignedAuditLogger.log(ILogger.EV_SIGNED_AUDIT, + null, + ILogger.S_SIGNED_AUDIT, + ILogger.LL_SECURITY, + msg); } /** @@ -129,12 +142,13 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { * substore name prepended in front of the plugin/parameter name). This * method may return null. * <P> - * + * * @param instancePrefix full name of configuration store * @param instanceName instance name of self test * @return fullname of this self test plugin */ - private String getFullName(String instancePrefix, String instanceName) { + private String getFullName(String instancePrefix, + String instanceName) { String instanceFullName = null; // strip preceding/trailing whitespace @@ -146,9 +160,13 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { instanceName = instanceName.trim(); } - if ((instancePrefix != null) && (instancePrefix != "")) { - if ((instanceName != null) && (instanceName != "")) { - instanceFullName = instancePrefix + "." + instanceName; + if ((instancePrefix != null) && + (instancePrefix != "")) { + if ((instanceName != null) && + (instanceName != "")) { + instanceFullName = instancePrefix + + "." + + instanceName; } } else { instanceFullName = instanceName; @@ -158,16 +176,16 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } /** - * This helper method checks to see if an instance name/value pair exists - * for the corresponding ordered list element. + * This helper method checks to see if an instance name/value + * pair exists for the corresponding ordered list element. * <P> - * + * * @param element owner of this subsystem * @param instanceName instance name of self test * @exception EMissingSelfTestException subsystem has missing name/value */ private void checkInstance(SelfTestOrderedInstance element) - throws EInvalidSelfTestException, EMissingSelfTestException { + throws EInvalidSelfTestException, EMissingSelfTestException { String instanceFullName = null; String instanceName = null; String instanceValue = null; @@ -178,10 +196,12 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { instanceName = element.getSelfTestName(); if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -190,14 +210,17 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // extract the self test plugin value(s) instanceValue = instanceConfig.getString(instanceName); - if ((instanceValue == null) || (instanceValue.equals(""))) { + if ((instanceValue == null) || + (instanceValue.equals(""))) { // self test plugin instance property name exists, // but it contains no value(s) - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_MISSING_VALUES", instanceFullName)); - throw new EMissingSelfTestException(instanceFullName, + throw new + EMissingSelfTestException(instanceFullName, instanceValue); } else { instanceValue = instanceValue.trim(); @@ -206,24 +229,27 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } catch (EPropertyNotFound e) { // self test plugin instance property name is not present log(mLogger, - CMS.getLogMessage( - "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", - instanceFullName)); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", + instanceFullName)); throw new EMissingSelfTestException(instanceFullName); } catch (EBaseException e) { // self test plugin instance EBaseException - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_THREW_EBASEEXCEPTION", - instanceFullName, instanceValue)); + instanceFullName, + instanceValue)); - throw new EInvalidSelfTestException(instanceFullName, instanceValue); + throw new EInvalidSelfTestException(instanceFullName, + instanceValue); } } - // ///////////////////////////// + /////////////////////////////// // SelfTestSubsystem methods // - // ///////////////////////////// + /////////////////////////////// // // methods associated with the list of on demand self tests @@ -233,7 +259,7 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { * List the instance names of all the self tests enabled to run on demand * (in execution order); may return null. * <P> - * + * * @return list of self test instance names run on demand */ public String[] listSelfTestsEnabledOnDemand() { @@ -245,7 +271,7 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { mList = new String[numElements]; } else { return null; - } + } // loop through all self test plugin instances // specified to be executed on demand @@ -254,8 +280,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { int i = 0; while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); mList[i] = instance.getSelfTestName(); if (mList[i] != null) { @@ -270,22 +296,24 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * Enable the specified self test to be executed on demand. * <P> - * + * * @param instanceName instance name of self test - * @param isCritical isCritical is either a critical failure (true) or a - * non-critical failure (false) + * @param isCritical isCritical is either a critical failure (true) or + * a non-critical failure (false) * @exception EInvalidSelfTestException subsystem has invalid name/value * @exception EMissingSelfTestException subsystem has missing name/value */ - public void enableSelfTestOnDemand(String instanceName, boolean isCritical) - throws EInvalidSelfTestException, EMissingSelfTestException { + public void enableSelfTestOnDemand(String instanceName, + boolean isCritical) + throws EInvalidSelfTestException, EMissingSelfTestException { // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -295,8 +323,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mOnDemandOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); if (instanceName.equals(instance.getSelfTestName())) { instance.setSelfTestCriticalMode(isCritical); @@ -308,7 +336,9 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { String elementName = null; if (isCritical) { - elementName = instanceName + ELEMENT_DELIMITER + CRITICAL; + elementName = instanceName + + ELEMENT_DELIMITER + + CRITICAL; } else { elementName = instanceName; } @@ -317,8 +347,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { element = new SelfTestOrderedInstance(elementName); - // SANITY CHECK: find the corresponding instance property - // name for this self test plugin + // SANITY CHECK: find the corresponding instance property + // name for this self test plugin checkInstance(element); // store this self test plugin in on-demand order @@ -328,22 +358,24 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * Disable the specified self test from being able to be executed on demand. * <P> - * + * * @param instanceName instance name of self test * @exception EMissingSelfTestException subsystem has missing name */ public void disableSelfTestOnDemand(String instanceName) - throws EMissingSelfTestException { + throws EMissingSelfTestException { String instanceFullName = null; // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -353,8 +385,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mOnDemandOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); if (instanceName.equals(instance.getSelfTestName())) { mOnDemandOrder.remove(instance); @@ -363,8 +395,10 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } // self test plugin instance property name is not present - log(mLogger, CMS.getLogMessage( - "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", instanceFullName)); + log(mLogger, + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", + instanceFullName)); throw new EMissingSelfTestException(instanceFullName); } @@ -372,20 +406,21 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * Determine if the specified self test is enabled to be executed on demand. * <P> - * + * * @param instanceName instance name of self test * @return true if the specified self test is enabled on demand * @exception EMissingSelfTestException subsystem has missing name */ public boolean isSelfTestEnabledOnDemand(String instanceName) - throws EMissingSelfTestException { + throws EMissingSelfTestException { // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -395,8 +430,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mOnDemandOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); if (instanceName.equals(instance.getSelfTestName())) { return true; @@ -407,27 +442,29 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } /** - * Determine if failure of the specified self test is fatal when it is - * executed on demand. + * Determine if failure of the specified self test is fatal when + * it is executed on demand. * <P> - * + * * @param instanceName instance name of self test - * @return true if failure of the specified self test is fatal when it is - * executed on demand + * @return true if failure of the specified self test is fatal when + * it is executed on demand * @exception EMissingSelfTestException subsystem has missing name */ public boolean isSelfTestCriticalOnDemand(String instanceName) - throws EMissingSelfTestException { + throws EMissingSelfTestException { String instanceFullName = null; // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -437,8 +474,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mOnDemandOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); if (instanceName.equals(instance.getSelfTestName())) { if (instance.isSelfTestCritical()) { @@ -450,8 +487,10 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } // self test plugin instance property name is not present - log(mLogger, CMS.getLogMessage( - "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", instanceFullName)); + log(mLogger, + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", + instanceFullName)); throw new EMissingSelfTestException(instanceFullName); } @@ -459,15 +498,15 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * Execute all self tests specified to be run on demand. * <P> - * + * * @exception EMissingSelfTestException subsystem has missing name * @exception ESelfTestException self test exception */ - public void runSelfTestsOnDemand() throws EMissingSelfTestException, - ESelfTestException { + public void runSelfTestsOnDemand() + throws EMissingSelfTestException, ESelfTestException { if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::runSelfTestsOnDemand():" - + " ENTERING . . ."); + + " ENTERING . . ."); } // loop through all self test plugin instances @@ -475,38 +514,42 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mOnDemandOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); String instanceFullName = null; String instanceName = instance.getSelfTestName(); if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } if (mSelfTestInstances.containsKey(instanceName)) { - ISelfTest test = (ISelfTest) mSelfTestInstances - .get(instanceName); + ISelfTest test = (ISelfTest) + mSelfTestInstances.get(instanceName); try { if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::runSelfTestsOnDemand():" - + " running \"" + test.getSelfTestName() - + "\""); + + " running \"" + + test.getSelfTestName() + + "\""); } test.runSelfTest(mLogger); } catch (ESelfTestException e) { // Check to see if the self test was critical: if (isSelfTestCriticalOnDemand(instanceName)) { - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_RUN_ON_DEMAND_FAILED", instanceFullName)); @@ -518,7 +561,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } } else { // self test plugin instance property name is not present - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", instanceFullName)); @@ -528,7 +572,7 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::runSelfTestsOnDemand():" - + " EXITING."); + + " EXITING."); } } @@ -537,10 +581,10 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // /** - * List the instance names of all the self tests enabled to run at server - * startup (in execution order); may return null. + * List the instance names of all the self tests enabled to run + * at server startup (in execution order); may return null. * <P> - * + * * @return list of self test instance names run at server startup */ public String[] listSelfTestsEnabledAtStartup() { @@ -552,7 +596,7 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { mList = new String[numElements]; } else { return null; - } + } // loop through all self test plugin instances // specified to be executed at server startup @@ -561,8 +605,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { int i = 0; while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); mList[i] = instance.getSelfTestName(); if (mList[i] != null) { @@ -577,22 +621,24 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * Enable the specified self test at server startup. * <P> - * + * * @param instanceName instance name of self test - * @param isCritical isCritical is either a critical failure (true) or a - * non-critical failure (false) + * @param isCritical isCritical is either a critical failure (true) or + * a non-critical failure (false) * @exception EInvalidSelfTestException subsystem has invalid name/value * @exception EMissingSelfTestException subsystem has missing name/value */ - public void enableSelfTestAtStartup(String instanceName, boolean isCritical) - throws EInvalidSelfTestException, EMissingSelfTestException { + public void enableSelfTestAtStartup(String instanceName, + boolean isCritical) + throws EInvalidSelfTestException, EMissingSelfTestException { // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -602,8 +648,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mStartupOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); if (instanceName.equals(instance.getSelfTestName())) { instance.setSelfTestCriticalMode(isCritical); @@ -615,7 +661,9 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { String elementName = null; if (isCritical) { - elementName = instanceName + ELEMENT_DELIMITER + CRITICAL; + elementName = instanceName + + ELEMENT_DELIMITER + + CRITICAL; } else { elementName = instanceName; } @@ -624,8 +672,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { element = new SelfTestOrderedInstance(elementName); - // SANITY CHECK: find the corresponding instance property - // name for this self test plugin + // SANITY CHECK: find the corresponding instance property + // name for this self test plugin checkInstance(element); // store this self test plugin in startup order @@ -635,22 +683,24 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * Disable the specified self test at server startup. * <P> - * + * * @param instanceName instance name of self test * @exception EMissingSelfTestException subsystem has missing name */ public void disableSelfTestAtStartup(String instanceName) - throws EMissingSelfTestException { + throws EMissingSelfTestException { String instanceFullName = null; // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -660,8 +710,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mStartupOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); if (instanceName.equals(instance.getSelfTestName())) { mStartupOrder.remove(instance); @@ -670,30 +720,33 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } // self test plugin instance property name is not present - log(mLogger, CMS.getLogMessage( - "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", instanceFullName)); + log(mLogger, + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", + instanceFullName)); throw new EMissingSelfTestException(instanceFullName); } /** - * Determine if the specified self test is executed automatically at server - * startup. + * Determine if the specified self test is executed automatically + * at server startup. * <P> - * + * * @param instanceName instance name of self test * @return true if the specified self test is executed at server startup * @exception EMissingSelfTestException subsystem has missing name */ public boolean isSelfTestEnabledAtStartup(String instanceName) - throws EMissingSelfTestException { + throws EMissingSelfTestException { // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -703,8 +756,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mStartupOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); if (instanceName.equals(instance.getSelfTestName())) { return true; @@ -715,27 +768,29 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } /** - * Determine if failure of the specified self test is fatal to server - * startup. + * Determine if failure of the specified self test is fatal to + * server startup. * <P> - * + * * @param instanceName instance name of self test - * @return true if failure of the specified self test is fatal to server - * startup + * @return true if failure of the specified self test is fatal to + * server startup * @exception EMissingSelfTestException subsystem has missing name */ public boolean isSelfTestCriticalAtStartup(String instanceName) - throws EMissingSelfTestException { + throws EMissingSelfTestException { String instanceFullName = null; // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -745,8 +800,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mStartupOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); if (instanceName.equals(instance.getSelfTestName())) { if (instance.isSelfTestCritical()) { @@ -758,8 +813,10 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } // self test plugin instance property name is not present - log(mLogger, CMS.getLogMessage( - "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", instanceFullName)); + log(mLogger, + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", + instanceFullName)); throw new EMissingSelfTestException(instanceFullName); } @@ -767,17 +824,16 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * Execute all self tests specified to be run at server startup. * <P> - * + * * <ul> * <li>signed.audit LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION used when self * tests are run at server startup * </ul> - * * @exception EMissingSelfTestException subsystem has missing name * @exception ESelfTestException self test exception */ - public void runSelfTestsAtStartup() throws EMissingSelfTestException, - ESelfTestException { + public void runSelfTestsAtStartup() + throws EMissingSelfTestException, ESelfTestException { String auditMessage = null; // ensure that any low-level exceptions are reported @@ -785,7 +841,7 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { try { if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::runSelfTestsAtStartup():" - + " ENTERING . . ."); + + " ENTERING . . ."); } // loop through all self test plugin instances @@ -793,23 +849,26 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { Enumeration instances = mStartupOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = (SelfTestOrderedInstance) instances - .nextElement(); + SelfTestOrderedInstance instance = (SelfTestOrderedInstance) + instances.nextElement(); String instanceFullName = null; String instanceName = instance.getSelfTestName(); if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); // store a message in the signed audit log file auditMessage = CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, - ILogger.SYSTEM_UID, ILogger.FAILURE); + LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, + ILogger.SYSTEM_UID, + ILogger.FAILURE); audit(auditMessage); @@ -817,29 +876,31 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } if (mSelfTestInstances.containsKey(instanceName)) { - ISelfTest test = (ISelfTest) mSelfTestInstances - .get(instanceName); + ISelfTest test = (ISelfTest) + mSelfTestInstances.get(instanceName); try { if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::runSelfTestsAtStartup():" - + " running \"" - + test.getSelfTestName() - + "\""); + + " running \"" + + test.getSelfTestName() + + "\""); } test.runSelfTest(mLogger); } catch (ESelfTestException e) { // Check to see if the self test was critical: if (isSelfTestCriticalAtStartup(instanceName)) { - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_RUN_AT_STARTUP_FAILED", instanceFullName)); // store a message in the signed audit log file auditMessage = CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, - ILogger.SYSTEM_UID, ILogger.FAILURE); + LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, + ILogger.SYSTEM_UID, + ILogger.FAILURE); audit(auditMessage); @@ -851,14 +912,16 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } } else { // self test plugin instance property name is not present - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", instanceFullName)); // store a message in the signed audit log file auditMessage = CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, - ILogger.SYSTEM_UID, ILogger.FAILURE); + LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, + ILogger.SYSTEM_UID, + ILogger.FAILURE); audit(auditMessage); @@ -868,20 +931,22 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // store a message in the signed audit log file auditMessage = CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, - ILogger.SYSTEM_UID, ILogger.SUCCESS); + LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, + ILogger.SYSTEM_UID, + ILogger.SUCCESS); audit(auditMessage); if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::runSelfTestsAtStartup():" - + " EXITING."); + + " EXITING."); } } catch (EMissingSelfTestException eAudit1) { // store a message in the signed audit log file auditMessage = CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, - ILogger.SYSTEM_UID, ILogger.FAILURE); + LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, + ILogger.SYSTEM_UID, + ILogger.FAILURE); audit(auditMessage); @@ -890,8 +955,9 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } catch (ESelfTestException eAudit2) { // store a message in the signed audit log file auditMessage = CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, - ILogger.SYSTEM_UID, ILogger.FAILURE); + LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION, + ILogger.SYSTEM_UID, + ILogger.FAILURE); audit(auditMessage); @@ -908,10 +974,10 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // /** - * Retrieve an individual self test from the instances list given its - * instance name. This method may return null. + * Retrieve an individual self test from the instances list + * given its instance name. This method may return null. * <P> - * + * * @param instanceName instance name of self test * @return individual self test */ @@ -943,10 +1009,10 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // /** - * Returns the ILogEventListener of this subsystem. This method may return - * null. + * Returns the ILogEventListener of this subsystem. + * This method may return null. * <P> - * + * * @return ILogEventListener of this subsystem */ public ILogEventListener getSelfTestLogger() { @@ -956,7 +1022,7 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * This method represents the log interface for the self test subsystem. * <P> - * + * * @param logger log event listener * @param msg self test log message */ @@ -972,35 +1038,43 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { ev.setLevel(ILogger.LL_INFO); try { logger.log(ev); - } catch (ELogException le) { + } catch( ELogException le ) { // log the message to the "transactions" log - mErrorLogger.log(ILogger.EV_AUDIT, null, ILogger.S_OTHER, - ILogger.LL_INFO, msg + " - " + le.toString()); + mErrorLogger.log(ILogger.EV_AUDIT, + null, + ILogger.S_OTHER, + ILogger.LL_INFO, + msg + " - " + le.toString() ); } } else { // log the message to the "transactions" log - mErrorLogger.log(ILogger.EV_AUDIT, null, ILogger.S_OTHER, - ILogger.LL_INFO, msg); + mErrorLogger.log(ILogger.EV_AUDIT, + null, + ILogger.S_OTHER, + ILogger.LL_INFO, + msg); } } /** - * Register an individual self test on the instances list AND on the - * "on demand" list (note that the specified self test will be appended to - * the end of each list). + * Register an individual self test on the instances list AND + * on the "on demand" list (note that the specified self test + * will be appended to the end of each list). * <P> - * + * * @param instanceName instance name of self test - * @param isCritical isCritical is either a critical failure (true) or a - * non-critical failure (false) + * @param isCritical isCritical is either a critical failure (true) or + * a non-critical failure (false) * @param instance individual self test * @exception EDuplicateSelfTestException subsystem has duplicate name * @exception EInvalidSelfTestException subsystem has invalid name/value * @exception EMissingSelfTestException subsystem has missing name/value */ public void registerSelfTestOnDemand(String instanceName, - boolean isCritical, ISelfTest instance) - throws EDuplicateSelfTestException, EInvalidSelfTestException, + boolean isCritical, + ISelfTest instance) + throws EDuplicateSelfTestException, + EInvalidSelfTestException, EMissingSelfTestException { String instanceFullName = null; @@ -1008,17 +1082,20 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } if (mSelfTestInstances.containsKey(instanceName)) { // self test plugin instance property name is a duplicate - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_DUPLICATE_NAME", instanceFullName)); @@ -1033,26 +1110,28 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } /** - * Deregister an individual self test on the instances list AND on the - * "on demand" list (note that the specified self test will be removed from - * each list). + * Deregister an individual self test on the instances list AND + * on the "on demand" list (note that the specified self test + * will be removed from each list). * <P> - * + * * @param instanceName instance name of self test * @exception EMissingSelfTestException subsystem has missing name */ public void deregisterSelfTestOnDemand(String instanceName) - throws EMissingSelfTestException { + throws EMissingSelfTestException { String instanceFullName = null; // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -1063,9 +1142,9 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { if (test == null) { // self test plugin instance property name is not present log(mLogger, - CMS.getLogMessage( - "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", - instanceFullName)); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", + instanceFullName)); throw new EMissingSelfTestException(instanceFullName); } else { @@ -1078,22 +1157,24 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } /** - * Register an individual self test on the instances list AND on the - * "startup" list (note that the specified self test will be appended to the - * end of each list). + * Register an individual self test on the instances list AND + * on the "startup" list (note that the specified self test + * will be appended to the end of each list). * <P> - * + * * @param instanceName instance name of self test - * @param isCritical isCritical is either a critical failure (true) or a - * non-critical failure (false) + * @param isCritical isCritical is either a critical failure (true) or + * a non-critical failure (false) * @param instance individual self test * @exception EDuplicateSelfTestException subsystem has duplicate name * @exception EInvalidSelfTestException subsystem has invalid name/value * @exception EMissingSelfTestException subsystem has missing name/value */ public void registerSelfTestAtStartup(String instanceName, - boolean isCritical, ISelfTest instance) - throws EDuplicateSelfTestException, EInvalidSelfTestException, + boolean isCritical, + ISelfTest instance) + throws EDuplicateSelfTestException, + EInvalidSelfTestException, EMissingSelfTestException { String instanceFullName = null; @@ -1101,17 +1182,20 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } if (mSelfTestInstances.containsKey(instanceName)) { // self test plugin instance property name is a duplicate - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_DUPLICATE_NAME", instanceFullName)); @@ -1126,26 +1210,28 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } /** - * Deregister an individual self test on the instances list AND on the - * "startup" list (note that the specified self test will be removed from - * each list). + * Deregister an individual self test on the instances list AND + * on the "startup" list (note that the specified self test + * will be removed from each list). * <P> - * + * * @param instanceName instance name of self test * @exception EMissingSelfTestException subsystem has missing name */ public void deregisterSelfTestAtStartup(String instanceName) - throws EMissingSelfTestException { + throws EMissingSelfTestException { String instanceFullName = null; // strip preceding/trailing whitespace // from passed-in String parameters if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -1156,9 +1242,9 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { if (test == null) { // self test plugin instance property name is not present log(mLogger, - CMS.getLogMessage( - "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", - instanceFullName)); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME", + instanceFullName)); throw new EMissingSelfTestException(instanceFullName); } else { @@ -1170,15 +1256,15 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { disableSelfTestAtStartup(instanceName); } - // ////////////////////// + //////////////////////// // ISubsystem methods // - // ////////////////////// + //////////////////////// /** - * This method retrieves the name of this subsystem. This method may return - * null. + * This method retrieves the name of this subsystem. This method + * may return null. * <P> - * + * * @return identification of this subsystem */ public String getId() { @@ -1188,18 +1274,20 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * This method sets information specific to this subsystem. * <P> - * + * * @param id identification of this subsystem * @exception EBaseException base CMS exception */ - public void setId(String id) throws EBaseException { + public void setId(String id) + throws EBaseException { // strip preceding/trailing whitespace // from passed-in String parameters if (id != null) { id = id.trim(); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EBaseException("id is null"); } @@ -1210,43 +1298,45 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { /** * This method initializes this subsystem. * <P> - * + * * @param owner owner of this subsystem * @param config configuration store * @exception EBaseException base CMS exception */ public void init(ISubsystem owner, IConfigStore config) - throws EBaseException { + throws EBaseException { if (CMS.debugOn()) { - CMS.debug("SelfTestSubsystem::init():" + " ENTERING . . ."); + CMS.debug("SelfTestSubsystem::init():" + + " ENTERING . . ."); } - if (config == null) { - CMS.debug("SelfTestSubsystem::init() - config is null!"); - throw new EBaseException("config is null"); + if( config == null ) { + CMS.debug( "SelfTestSubsystem::init() - config is null!" ); + throw new EBaseException( "config is null" ); } mOwner = owner; mConfig = config; - if ((mConfig != null) && (mConfig.getName() != null) - && (mConfig.getName() != "")) { + if ((mConfig != null) && + (mConfig.getName() != null) && + (mConfig.getName() != "")) { mRootPrefix = mConfig.getName().trim(); } int loadStatus = 0; - // NOTE: Obviously, we must load the self test logger parameters - // first, since the "selftests.log" log file does not - // exist until this is accomplished!!! + // NOTE: Obviously, we must load the self test logger parameters + // first, since the "selftests.log" log file does not + // exist until this is accomplished!!! - // ////////////////////////////////// + //////////////////////////////////// // loggerPropertyName=loggerValue // - // ////////////////////////////////// + //////////////////////////////////// if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::init():" - + " loading self test logger parameters"); + + " loading self test logger parameters"); } String loggerPrefix = null; @@ -1258,17 +1348,20 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { String loggerPath = PROP_CONTAINER + "." + PROP_LOGGER; IConfigStore loggerConfig = mConfig.getSubStore(loggerPath); - if ((loggerConfig != null) && (loggerConfig.getName() != null) - && (loggerConfig.getName() != "")) { + if ((loggerConfig != null) && + (loggerConfig.getName() != null) && + (loggerConfig.getName() != "")) { loggerPrefix = loggerConfig.getName().trim(); } else { - // NOTE: These messages can only be logged to the "transactions" - // log, since the "selftests.log" will not exist! + // NOTE: These messages can only be logged to the "transactions" + // log, since the "selftests.log" will not exist! log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -1279,7 +1372,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { loadStatus++; try { - loggerFullName = getFullName(loggerPrefix, loggerName); + loggerFullName = getFullName(loggerPrefix, + loggerName); // retrieve the associated logger class loggerValue = loggerConfig.getString(loggerName); @@ -1289,29 +1383,34 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // self test plugin instance property name exists, // but it contains no value(s) - // NOTE: This message can only be logged to the - // "transactions" log, since the "selftests.log" - // will not exist! - log(mLogger, CMS.getLogMessage( + // NOTE: This message can only be logged to the + // "transactions" log, since the "selftests.log" + // will not exist! + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_MISSING_VALUES", loggerFullName)); - throw new EMissingSelfTestException(loggerFullName, + throw new + EMissingSelfTestException(loggerFullName, loggerValue); } Object o = Class.forName(loggerValue).newInstance(); if (!(o instanceof ILogEventListener)) { - // NOTE: These messages can only be logged to the - // "transactions" log, since the "selftests.log" - // will not exist! + // NOTE: These messages can only be logged to the + // "transactions" log, since the "selftests.log" + // will not exist! log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_INVALID_INSTANCE", - loggerFullName, loggerValue)); + loggerFullName, + loggerValue)); throw new EInvalidSelfTestException(loggerFullName, loggerValue); @@ -1323,72 +1422,86 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } catch (EBaseException e) { // self test property name EBaseException - // NOTE: These messages can only be logged to the - // "transactions" log, since the "selftests.log" - // will not exist! + // NOTE: These messages can only be logged to the + // "transactions" log, since the "selftests.log" + // will not exist! log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_THREW_EBASEEXCEPTION", - loggerFullName, loggerValue)); + loggerFullName, + loggerValue)); - throw new EInvalidSelfTestException(loggerFullName, loggerValue); + throw new EInvalidSelfTestException(loggerFullName, + loggerValue); } catch (Exception e) { - // NOTE: These messages can only be logged to the - // "transactions" log, since the "selftests.log" - // will not exist! + // NOTE: These messages can only be logged to the + // "transactions" log, since the "selftests.log" + // will not exist! log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_THREW_EXCEPTION", - loggerFullName, loggerValue)); + loggerFullName, + loggerValue)); CMS.debugStackTrace(); - throw new EInvalidSelfTestException(loggerFullName, loggerValue); + throw new EInvalidSelfTestException(loggerFullName, + loggerValue); } } // Barring any exceptions thrown above, we begin logging messages // to either the "transactions" log, or the "selftests.log" log. if (loadStatus == 0) { - // NOTE: These messages can only be logged to the - // "transactions" log, since the "selftests.log" - // will not exist! + // NOTE: These messages can only be logged to the + // "transactions" log, since the "selftests.log" + // will not exist! log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_DONT_LOAD_LOGGER_PARAMETERS")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_DONT_LOAD_LOGGER_PARAMETERS")); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_INITIALIZATION_NOTIFICATION")); log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_LOAD_LOGGER_PARAMETERS")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_LOAD_LOGGER_PARAMETERS")); } - // ////////////////////////////////////// + //////////////////////////////////////// // instancePropertyName=instanceValue // - // ////////////////////////////////////// + //////////////////////////////////////// if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::init():" - + " loading self test plugins"); + + " loading self test plugins"); } // compose self test plugins instance property prefix String instancePath = PROP_CONTAINER + "." + PROP_INSTANCE; IConfigStore instanceConfig = mConfig.getSubStore(instancePath); - if ((instanceConfig != null) && (instanceConfig.getName() != null) - && (instanceConfig.getName() != "")) { + if ((instanceConfig != null) && + (instanceConfig.getName() != null) && + (instanceConfig.getName() != "")) { mPrefix = instanceConfig.getName().trim(); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } @@ -1397,11 +1510,12 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { if (instances.hasMoreElements()) { loadStatus++; - - log(mLogger, CMS.getLogMessage("CMSCORE_SELFTESTS_LOAD_PLUGINS")); + + log(mLogger, + CMS.getLogMessage("CMSCORE_SELFTESTS_LOAD_PLUGINS")); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_DONT_LOAD_PLUGINS")); + CMS.getLogMessage("CMSCORE_SELFTESTS_DONT_LOAD_PLUGINS")); } // load all self test plugin instances @@ -1415,17 +1529,20 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { instanceName = (String) instances.nextElement(); if (instanceName != null) { instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, instanceName); + instanceFullName = getFullName(mPrefix, + instanceName); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); throw new EMissingSelfTestException(); } if (mSelfTestInstances.containsKey(instanceName)) { // self test plugin instance property name is a duplicate - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_DUPLICATE_NAME", instanceFullName)); @@ -1440,18 +1557,22 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } else { // self test plugin instance property name exists, // but it contains no value(s) - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_MISSING_VALUES", instanceFullName)); - throw new EMissingSelfTestException(instanceFullName, + throw new + EMissingSelfTestException(instanceFullName, instanceValue); } } catch (EBaseException e) { // self test property name EBaseException - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_THREW_EBASEEXCEPTION", - instanceFullName, instanceValue)); + instanceFullName, + instanceValue)); throw new EInvalidSelfTestException(instanceFullName, instanceValue); @@ -1464,17 +1585,21 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { o = Class.forName(instanceValue).newInstance(); if (!(o instanceof ISelfTest)) { - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_INVALID_INSTANCE", - instanceFullName, instanceValue)); + instanceFullName, + instanceValue)); throw new EInvalidSelfTestException(instanceFullName, instanceValue); } } catch (Exception e) { - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_THREW_EXCEPTION", - instanceFullName, instanceValue)); + instanceFullName, + instanceValue)); CMS.debugStackTrace(); @@ -1489,11 +1614,12 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::init():" - + " loading self test plugin parameters"); + + " loading self test plugin parameters"); } log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_LOAD_PLUGIN_PARAMETERS")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_LOAD_PLUGIN_PARAMETERS")); } ISelfTest test = (ISelfTest) o; @@ -1503,38 +1629,45 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // store this self test plugin instance mSelfTestInstances.put(instanceName, test); } catch (EDuplicateSelfTestException e) { - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PLUGIN_DUPLICATE_PARAMETER", - instanceFullName, e.getInstanceParameter())); + instanceFullName, + e.getInstanceParameter())); throw e; } catch (EMissingSelfTestException e) { - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PLUGIN_MISSING_PARAMETER", - instanceFullName, e.getInstanceParameter())); + instanceFullName, + e.getInstanceParameter())); throw e; } catch (EInvalidSelfTestException e) { - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PLUGIN_INVALID_PARAMETER", - instanceFullName, e.getInstanceParameter())); + instanceFullName, + e.getInstanceParameter())); throw e; } } - // //////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////// // onDemandOrderPropertyName=onDemandOrderValue1, . . . // - // //////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////// if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::init():" - + " loading on demand self tests"); + + " loading on demand self tests"); } // compose self test plugins on-demand ordering property name - String onDemandOrderName = PROP_CONTAINER + "." + PROP_ORDER + "." - + PROP_ON_DEMAND; + String onDemandOrderName = PROP_CONTAINER + "." + + PROP_ORDER + "." + + PROP_ON_DEMAND; String onDemandOrderFullName = getFullName(mRootPrefix, onDemandOrderName); String onDemandOrderValues = null; @@ -1550,21 +1683,23 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { loadStatus++; log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_LOAD_PLUGINS_ON_DEMAND")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_LOAD_PLUGINS_ON_DEMAND")); - if ((onDemandOrderValues == null) - || (onDemandOrderValues.equals(""))) { + if ((onDemandOrderValues == null) || + (onDemandOrderValues.equals(""))) { // self test plugins on-demand ordering property name // exists, but it contains no values, which means that // no self tests are configured to run on-demand - if ((onDemandOrderFullName != null) - && (!onDemandOrderFullName.equals(""))) { - log(mLogger, CMS.getLogMessage( + if( ( onDemandOrderFullName != null ) && + ( !onDemandOrderFullName.equals( "" ) ) ) { + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_MISSING_ON_DEMAND_VALUES", onDemandOrderFullName)); } - throw new EBaseException("onDemandOrderValues is null " - + "or empty"); + throw new EBaseException( "onDemandOrderValues is null " + + "or empty" ); } StringTokenizer tokens = new StringTokenizer(onDemandOrderValues, @@ -1574,10 +1709,11 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // create a new element in the on-demand ordered list SelfTestOrderedInstance element; - element = new SelfTestOrderedInstance(tokens.nextToken().trim()); + element = new SelfTestOrderedInstance( + tokens.nextToken().trim()); - // SANITY CHECK: find the corresponding instance property - // name for this self test plugin + // SANITY CHECK: find the corresponding instance property + // name for this self test plugin checkInstance(element); // store this self test plugin in on-demand order @@ -1590,32 +1726,37 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // presently, we merely log this fact log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_DONT_LOAD_PLUGINS_ON_DEMAND")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_DONT_LOAD_PLUGINS_ON_DEMAND")); // throw new EMissingSelfTestException( onDemandOrderFullName ); } catch (EBaseException e) { // self test property name EBaseException - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_THREW_EBASEEXCEPTION", - onDemandOrderFullName, onDemandOrderValues)); + onDemandOrderFullName, + onDemandOrderValues)); throw new EInvalidSelfTestException(onDemandOrderFullName, onDemandOrderValues); } - // ////////////////////////////////////////////////////// + //////////////////////////////////////////////////////// // startupOrderPropertyName=startupOrderValue1, . . . // - // ////////////////////////////////////////////////////// + //////////////////////////////////////////////////////// if (CMS.debugOn()) { CMS.debug("SelfTestSubsystem::init():" - + " loading startup self tests"); + + " loading startup self tests"); } // compose self test plugins startup ordering property name - String startupOrderName = PROP_CONTAINER + "." + PROP_ORDER + "." - + PROP_STARTUP; - String startupOrderFullName = getFullName(mRootPrefix, startupOrderName); + String startupOrderName = PROP_CONTAINER + "." + + PROP_ORDER + "." + + PROP_STARTUP; + String startupOrderFullName = getFullName(mRootPrefix, + startupOrderName); String startupOrderValues = null; try { @@ -1629,15 +1770,18 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { loadStatus++; log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_LOAD_PLUGINS_AT_STARTUP")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_LOAD_PLUGINS_AT_STARTUP")); - if ((startupOrderValues == null) || (startupOrderValues.equals(""))) { + if ((startupOrderValues == null) || + (startupOrderValues.equals(""))) { // self test plugins startup ordering property name // exists, but it contains no values, which means that // no self tests are configured to run at server startup - if ((startupOrderFullName != null) - && (!startupOrderFullName.equals(""))) { - log(mLogger, CMS.getLogMessage( + if( ( startupOrderFullName != null ) && + ( !startupOrderFullName.equals( "" ) ) ) { + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_MISSING_STARTUP_VALUES", startupOrderFullName)); } @@ -1650,10 +1794,11 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // create a new element in the startup ordered list SelfTestOrderedInstance element; - element = new SelfTestOrderedInstance(tokens.nextToken().trim()); + element = new SelfTestOrderedInstance( + tokens.nextToken().trim()); - // SANITY CHECK: find the corresponding instance property - // name for this self test plugin + // SANITY CHECK: find the corresponding instance property + // name for this self test plugin checkInstance(element); // store this self test plugin in startup order @@ -1666,14 +1811,17 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // presently, we merely log this fact log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_DONT_LOAD_PLUGINS_AT_STARTUP")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_DONT_LOAD_PLUGINS_AT_STARTUP")); // throw new EMissingSelfTestException( startupOrderFullName ); } catch (EBaseException e) { // self test property name EBaseException - log(mLogger, CMS.getLogMessage( + log(mLogger, + CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_THREW_EBASEEXCEPTION", - startupOrderFullName, startupOrderValues)); + startupOrderFullName, + startupOrderValues)); throw new EInvalidSelfTestException(startupOrderFullName, startupOrderValues); @@ -1682,23 +1830,28 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // notify user whether or not self test plugins have been loaded if (loadStatus == 0) { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_PLUGINS_NONE_LOADED")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PLUGINS_NONE_LOADED")); } else { - log(mLogger, CMS.getLogMessage("CMSCORE_SELFTESTS_PLUGINS_LOADED")); + log(mLogger, + CMS.getLogMessage( + "CMSCORE_SELFTESTS_PLUGINS_LOADED")); } if (CMS.debugOn()) { - CMS.debug("SelfTestSubsystem::init():" + " EXITING."); + CMS.debug("SelfTestSubsystem::init():" + + " EXITING."); } } /** * Notifies this subsystem if owner is in running mode. * <P> - * + * * @exception EBaseException base CMS exception */ - public void startup() throws EBaseException { + public void startup() + throws EBaseException { // loop through all self test plugin instances Enumeration instances = mSelfTestInstances.elements(); @@ -1715,7 +1868,8 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { if (selftests.hasMoreElements()) { // log that execution of startup self tests has begun log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_RUN_AT_STARTUP")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_RUN_AT_STARTUP")); // execute all startup self tests runSelfTestsAtStartup(); @@ -1723,22 +1877,24 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { // log that execution of all "critical" startup self tests // has completed "successfully" log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_RUN_AT_STARTUP_SUCCEEDED")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_RUN_AT_STARTUP_SUCCEEDED")); } else { log(mLogger, - CMS.getLogMessage("CMSCORE_SELFTESTS_NOT_RUN_AT_STARTUP")); + CMS.getLogMessage( + "CMSCORE_SELFTESTS_NOT_RUN_AT_STARTUP")); } } } /** - * Stops this subsystem. The owner may call shutdown anytime after - * initialization. + * Stops this subsystem. The owner may call shutdown + * anytime after initialization. * <P> */ public void shutdown() { // reverse order of all self test plugin instances - Collection collection = mSelfTestInstances.values(); + Collection collection = mSelfTestInstances.values(); Vector list = new Vector(collection); Collections.reverse(list); @@ -1754,13 +1910,14 @@ public class SelfTestSubsystem implements ISelfTestSubsystem { } /** - * Returns the root configuration storage of this subsystem. This method may - * return null. + * Returns the root configuration storage of this subsystem. + * This method may return null. * <P> - * + * * @return configuration store of this subsystem */ public IConfigStore getConfigStore() { return mConfig; } } + |