From 621d9e5c413e561293d7484b93882d985b3fe15f Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Sat, 24 Mar 2012 02:27:47 -0500 Subject: Removed unnecessary pki folder. Previously the source code was located inside a pki folder. This folder was created during svn migration and is no longer needed. This folder has now been removed and the contents have been moved up one level. Ticket #131 --- .../selftests/EDuplicateSelfTestException.java | 216 +++++++++++++ .../selftests/EInvalidSelfTestException.java | 216 +++++++++++++ .../selftests/EMissingSelfTestException.java | 225 ++++++++++++++ .../certsrv/selftests/ESelfTestException.java | 118 +++++++ .../com/netscape/certsrv/selftests/ISelfTest.java | 133 ++++++++ .../certsrv/selftests/ISelfTestSubsystem.java | 338 +++++++++++++++++++++ .../certsrv/selftests/SelfTestResources.java | 39 +++ 7 files changed, 1285 insertions(+) create mode 100644 base/common/src/com/netscape/certsrv/selftests/EDuplicateSelfTestException.java create mode 100644 base/common/src/com/netscape/certsrv/selftests/EInvalidSelfTestException.java create mode 100644 base/common/src/com/netscape/certsrv/selftests/EMissingSelfTestException.java create mode 100644 base/common/src/com/netscape/certsrv/selftests/ESelfTestException.java create mode 100644 base/common/src/com/netscape/certsrv/selftests/ISelfTest.java create mode 100644 base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java create mode 100644 base/common/src/com/netscape/certsrv/selftests/SelfTestResources.java (limited to 'base/common/src/com/netscape/certsrv/selftests') diff --git a/base/common/src/com/netscape/certsrv/selftests/EDuplicateSelfTestException.java b/base/common/src/com/netscape/certsrv/selftests/EDuplicateSelfTestException.java new file mode 100644 index 000000000..958919e1e --- /dev/null +++ b/base/common/src/com/netscape/certsrv/selftests/EDuplicateSelfTestException.java @@ -0,0 +1,216 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +// package statement // +/////////////////////// + +package com.netscape.certsrv.selftests; + +/////////////////////// +// import statements // +/////////////////////// + +////////////////////// +// class definition // +////////////////////// + +/** + * This class implements a duplicate self test exception. + * EDuplicateSelfTestExceptions are derived from ESelfTestExceptions + * in order to allow users to easily do self tests without try-catch clauses. + * + * EDuplicateSelfTestExceptions should be caught by SelfTestSubsystem managers. + *

+ * + * @version $Revision$, $Date$ + */ +public class EDuplicateSelfTestException + extends ESelfTestException { + //////////////////////// + // default parameters // + //////////////////////// + + /////////////////////// + // helper parameters // + /////////////////////// + + /** + * + */ + private static final long serialVersionUID = -7484729117186395701L; + private String mInstanceName = null; + private String mInstanceStore = null; + private String mInstanceParameter = null; + private String mInstanceValue = null; + + //////////////////////////////////////////// + // EDuplicateSelfTestException parameters // + //////////////////////////////////////////// + + /////////////////////////////////////////////// + // ESelfTestException parameters (inherited) // + /////////////////////////////////////////////// + + ///////////////////// + // default methods // + ///////////////////// + + /** + * Constructs a "duplicate" self test exception. + *

+ * + * @param instanceName duplicate "instanceName" exception details + */ + public EDuplicateSelfTestException(String instanceName) { + super("The self test plugin property named " + + instanceName + + " already exists."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceName != null) { + instanceName = instanceName.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceName = instanceName; + } + + /** + * Constructs a "duplicate" self test exception where the value is always + * a duplicate from a name/value pair + *

+ * + * @param instanceName duplicate "instanceName" exception details + * @param instanceValue duplicate "instanceValue" exception details + */ + public EDuplicateSelfTestException(String instanceName, + String instanceValue) { + super("The self test plugin property named " + + instanceName + + " contains a value of " + + instanceValue + + " which already exists."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceName != null) { + instanceName = instanceName.trim(); + } + if (instanceValue != null) { + instanceValue = instanceValue.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceName = instanceName; + mInstanceValue = instanceValue; + } + + /** + * Constructs a "duplicate" self test exception where the parameter is a + * duplicate from a substore.parameter/value pair; (the value passed in may + * be null). + *

+ * + * @param instanceStore duplicate "instanceStore" exception details + * @param instanceParameter duplicate "instanceParameter" exception details + * @param instanceValue duplicate "instanceValue" exception details + * (may be null) + */ + public EDuplicateSelfTestException(String instanceStore, + String instanceParameter, + String instanceValue) { + super("The self test plugin property named " + + instanceStore + "." + instanceParameter + + " is a duplicate."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceStore != null) { + instanceStore = instanceStore.trim(); + } + if (instanceParameter != null) { + instanceParameter = instanceParameter.trim(); + } + if (instanceValue != null) { + instanceValue = instanceValue.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceStore = instanceStore; + mInstanceParameter = instanceParameter; + mInstanceValue = instanceValue; + } + + //////////////////// + // helper methods // + //////////////////// + + /** + * Returns the instance name associated with this self test. + *

+ * + * @return name portion of the name/value pair + */ + public String getInstanceName() { + return mInstanceName; + } + + /** + * Returns the store associated with this self test. + *

+ * + * @return substore portion of the substore.parameter/value pair + */ + public String getInstanceStore() { + return mInstanceStore; + } + + /** + * Returns the parameter associated with this self test. + *

+ * + * @return parameter portion of the substore.parameter/value pair + */ + public String getInstanceParameter() { + return mInstanceParameter; + } + + /** + * Returns the value associated with this self test. + *

+ * + * @return value portion of the name/value pair + */ + public String getInstanceValue() { + return mInstanceValue; + } + + ///////////////////////////////////////// + // EDuplicateSelfTestException methods // + ///////////////////////////////////////// + + //////////////////////////////////////////// + // ESelfTestException methods (inherited) // + //////////////////////////////////////////// + + /* Note that all of the following ESelfTestException methods + * are inherited from the ESelfTestException class: + * + * public ESelfTestException( String msg ); + */ +} diff --git a/base/common/src/com/netscape/certsrv/selftests/EInvalidSelfTestException.java b/base/common/src/com/netscape/certsrv/selftests/EInvalidSelfTestException.java new file mode 100644 index 000000000..58592b89b --- /dev/null +++ b/base/common/src/com/netscape/certsrv/selftests/EInvalidSelfTestException.java @@ -0,0 +1,216 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +// package statement // +/////////////////////// + +package com.netscape.certsrv.selftests; + +/////////////////////// +// import statements // +/////////////////////// + +////////////////////// +// class definition // +////////////////////// + +/** + * This class implements an invalid self test exception. + * EInvalidSelfTestExceptions are derived from ESelfTestExceptions + * in order to allow users to easily do self tests without try-catch clauses. + * + * EInvalidSelfTestExceptions should be caught by SelfTestSubsystem managers. + *

+ * + * @version $Revision$, $Date$ + */ +public class EInvalidSelfTestException + extends ESelfTestException { + //////////////////////// + // default parameters // + //////////////////////// + + /////////////////////// + // helper parameters // + /////////////////////// + + /** + * + */ + private static final long serialVersionUID = 942550656371185199L; + private String mInstanceName = null; + private String mInstanceStore = null; + private String mInstanceParameter = null; + private String mInstanceValue = null; + + ////////////////////////////////////////// + // EInvalidSelfTestException parameters // + ////////////////////////////////////////// + + /////////////////////////////////////////////// + // ESelfTestException parameters (inherited) // + /////////////////////////////////////////////// + + ///////////////////// + // default methods // + ///////////////////// + + /** + * Constructs an "invalid" self test exception. + *

+ * + * @param instanceName invalid "instanceName" exception details + */ + public EInvalidSelfTestException(String instanceName) { + super("The self test plugin named " + + instanceName + + " is invalid."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceName != null) { + instanceName = instanceName.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceName = instanceName; + } + + /** + * Constructs a "invalid" self test exception where the value is always + * invalid from a name/value pair + *

+ * + * @param instanceName invalid "instanceName" exception details + * @param instanceValue invalid "instanceValue" exception details + */ + public EInvalidSelfTestException(String instanceName, + String instanceValue) { + super("The self test plugin named " + + instanceName + + " contains a value " + + instanceValue + + " which is invalid."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceName != null) { + instanceName = instanceName.trim(); + } + if (instanceValue != null) { + instanceValue = instanceValue.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceName = instanceName; + mInstanceValue = instanceValue; + } + + /** + * Constructs an "invalid" self test exception where the parameter is always + * invalid from a substore.parameter/value pair; (the value passed in may + * be null). + *

+ * + * @param instanceStore invalid "instanceStore" exception details + * @param instanceParameter invalid "instanceParameter" exception details + * @param instanceValue invalid "instanceValue" exception details + * (may be null) + */ + public EInvalidSelfTestException(String instanceStore, + String instanceParameter, + String instanceValue) { + super("The self test plugin parameter named " + + instanceStore + "." + instanceParameter + + " is invalid."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceStore != null) { + instanceStore = instanceStore.trim(); + } + if (instanceParameter != null) { + instanceParameter = instanceParameter.trim(); + } + if (instanceValue != null) { + instanceValue = instanceValue.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceStore = instanceStore; + mInstanceParameter = instanceParameter; + mInstanceValue = instanceValue; + } + + //////////////////// + // helper methods // + //////////////////// + + /** + * Returns the instance name associated with this self test. + *

+ * + * @return name portion of the name/value pair + */ + public String getInstanceName() { + return mInstanceName; + } + + /** + * Returns the store associated with this self test. + *

+ * + * @return substore portion of the substore.parameter/value pair + */ + public String getInstanceStore() { + return mInstanceStore; + } + + /** + * Returns the parameter associated with this self test. + *

+ * + * @return parameter portion of the substore.parameter/value pair + */ + public String getInstanceParameter() { + return mInstanceParameter; + } + + /** + * Returns the value associated with this self test. + *

+ * + * @return value portion of the name/value pair + */ + public String getInstanceValue() { + return mInstanceValue; + } + + /////////////////////////////////////// + // EInvalidSelfTestException methods // + /////////////////////////////////////// + + //////////////////////////////////////////// + // ESelfTestException methods (inherited) // + //////////////////////////////////////////// + + /* Note that all of the following ESelfTestException methods + * are inherited from the ESelfTestException class: + * + * public ESelfTestException( String msg ); + */ +} diff --git a/base/common/src/com/netscape/certsrv/selftests/EMissingSelfTestException.java b/base/common/src/com/netscape/certsrv/selftests/EMissingSelfTestException.java new file mode 100644 index 000000000..c15852f4f --- /dev/null +++ b/base/common/src/com/netscape/certsrv/selftests/EMissingSelfTestException.java @@ -0,0 +1,225 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +// package statement // +/////////////////////// + +package com.netscape.certsrv.selftests; + +/////////////////////// +// import statements // +/////////////////////// + +////////////////////// +// class definition // +////////////////////// + +/** + * This class implements a missing self test exception. + * EMissingSelfTestExceptions are derived from ESelfTestExceptions + * in order to allow users to easily do self tests without try-catch clauses. + * + * EMissingSelfTestExceptions should be caught by SelfTestSubsystem managers. + *

+ * + * @version $Revision$, $Date$ + */ +public class EMissingSelfTestException + extends ESelfTestException { + //////////////////////// + // default parameters // + //////////////////////// + + /////////////////////// + // helper parameters // + /////////////////////// + + /** + * + */ + private static final long serialVersionUID = -2969459432517671352L; + private String mInstanceName = null; + private String mInstanceStore = null; + private String mInstanceParameter = null; + private String mInstanceValue = null; + + ////////////////////////////////////////// + // EMissingSelfTestException parameters // + ////////////////////////////////////////// + + /////////////////////////////////////////////// + // ESelfTestException parameters (inherited) // + /////////////////////////////////////////////// + + ///////////////////// + // default methods // + ///////////////////// + + /** + * Constructs a "missing" self test exception where the name is null + *

+ * + */ + public EMissingSelfTestException() { + super("The self test plugin property name is null."); + } + + /** + * Constructs a "missing" self test exception where the name is always + * missing from a name/value pair. + *

+ * + * @param instanceName missing "instanceName" exception details + */ + public EMissingSelfTestException(String instanceName) { + super("The self test plugin property named " + + instanceName + + " does not exist."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceName != null) { + instanceName = instanceName.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceName = instanceName; + } + + /** + * Constructs a "missing" self test exception where the value is always + * missing from a name/value pair; (the value passed in is always null). + *

+ * + * @param instanceName missing "instanceName" exception details + * @param instanceValue missing "instanceValue" exception details + * (always null) + */ + public EMissingSelfTestException(String instanceName, + String instanceValue) { + super("The self test plugin property named " + + instanceName + + " contains no values."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceName != null) { + instanceName = instanceName.trim(); + } + if (instanceValue != null) { + instanceValue = instanceValue.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceName = instanceName; + mInstanceValue = instanceValue; + } + + /** + * Constructs a "missing" self test exception where the parameter is always + * missing from a substore.parameter/value pair; (the value passed in may + * be null). + *

+ * + * @param instanceStore missing "instanceStore" exception details + * @param instanceParameter missing "instanceParameter" exception details + * @param instanceValue missing "instanceValue" exception details + * (may be null) + */ + public EMissingSelfTestException(String instanceStore, + String instanceParameter, + String instanceValue) { + super("The self test plugin property named " + + instanceStore + "." + instanceParameter + + " is missing."); + + // strip preceding/trailing whitespace + // from passed-in String parameters + if (instanceStore != null) { + instanceStore = instanceStore.trim(); + } + if (instanceParameter != null) { + instanceParameter = instanceParameter.trim(); + } + if (instanceValue != null) { + instanceValue = instanceValue.trim(); + } + + // store passed-in parameters for use by helper methods + mInstanceStore = instanceStore; + mInstanceParameter = instanceParameter; + mInstanceValue = instanceValue; + } + + //////////////////// + // helper methods // + //////////////////// + + /** + * Returns the instance name associated with this self test. + *

+ * + * @return name portion of the name/value pair + */ + public String getInstanceName() { + return mInstanceName; + } + + /** + * Returns the store associated with this self test. + *

+ * + * @return substore portion of the substore.parameter/value pair + */ + public String getInstanceStore() { + return mInstanceStore; + } + + /** + * Returns the parameter associated with this self test. + *

+ * + * @return parameter portion of the substore.parameter/value pair + */ + public String getInstanceParameter() { + return mInstanceParameter; + } + + /** + * Returns the value associated with this self test. + *

+ * + * @return value portion of the name/value pair + */ + public String getInstanceValue() { + return mInstanceValue; + } + + /////////////////////////////////////// + // EMissingSelfTestException methods // + /////////////////////////////////////// + + //////////////////////////////////////////// + // ESelfTestException methods (inherited) // + //////////////////////////////////////////// + + /* Note that all of the following ESelfTestException methods + * are inherited from the ESelfTestException class: + * + * public ESelfTestException( String msg ); + */ +} diff --git a/base/common/src/com/netscape/certsrv/selftests/ESelfTestException.java b/base/common/src/com/netscape/certsrv/selftests/ESelfTestException.java new file mode 100644 index 000000000..6c4f6bf2f --- /dev/null +++ b/base/common/src/com/netscape/certsrv/selftests/ESelfTestException.java @@ -0,0 +1,118 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +// package statement // +/////////////////////// + +package com.netscape.certsrv.selftests; + +/////////////////////// +// import statements // +/////////////////////// + +import com.netscape.certsrv.base.EBaseException; + +////////////////////// +// class definition // +////////////////////// + +/** + * This class implements a self test exception. ESelfTestExceptions + * are derived from EBaseExceptions in order to allow users + * to easily do self tests without try-catch clauses. + * + * ESelfTestExceptions should be caught by SelfTestSubsystem managers. + *

+ * + * @version $Revision$, $Date$ + */ +public class ESelfTestException + extends EBaseException { + //////////////////////// + // default parameters // + //////////////////////// + + /////////////////////////////////// + // ESelfTestException parameters // + /////////////////////////////////// + + /** + * + */ + private static final long serialVersionUID = -8001373369705595891L; + private static final String SELFTEST_RESOURCES = SelfTestResources.class.getName(); + + /////////////////////////////////////////// + // EBaseException parameters (inherited) // + /////////////////////////////////////////// + + /* Note that all of the following EBaseException parameters + * are inherited from the EBaseException class: + * + * public Object mParams[]; + */ + + ///////////////////// + // default methods // + ///////////////////// + + /** + * Constructs a self test exception. + *

+ * + * @param msg exception details + */ + public ESelfTestException(String msg) { + super(msg); + } + + //////////////////////////////// + // ESelfTestException methods // + //////////////////////////////// + + /** + * Returns the bundle file name. + *

+ * + * @return name of bundle class associated with this exception. + */ + protected String getBundleName() { + return SELFTEST_RESOURCES; + } + + //////////////////////////////////////// + // EBaseException methods (inherited) // + //////////////////////////////////////// + + /* Note that all of the following EBaseException methods + * are inherited from the EBaseException class: + * + * public EBaseException( String msgFormat ); + * + * public EBaseException( String msgFormat, String param ); + * + * public EBaseException( String msgFormat, Exception param ); + * + * public EBaseException( String msgFormat, Object params[] ); + * + * public Object[] getParameters(); + * + * public String toString(); + * + * public String toString( Locale locale ); + */ +} diff --git a/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java b/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java new file mode 100644 index 000000000..04285a9dc --- /dev/null +++ b/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java @@ -0,0 +1,133 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +// package statement // +/////////////////////// + +package com.netscape.certsrv.selftests; + +/////////////////////// +// import statements // +/////////////////////// + +import java.util.Locale; + +import com.netscape.certsrv.base.IConfigStore; +import com.netscape.certsrv.logging.ILogEventListener; + +////////////////////// +// class definition // +////////////////////// + +/** + * This class defines the interface of an individual self test. + *

+ * + * @version $Revision$, $Date$ + */ +public interface ISelfTest { + //////////////////////// + // default parameters // + //////////////////////// + + ////////////////////////// + // ISelfTest parameters // + ////////////////////////// + + public static final String PROP_PLUGIN = "plugin"; + + ///////////////////// + // default methods // + ///////////////////// + + /////////////////////// + // ISelfTest methods // + /////////////////////// + + /** + * Initializes this subsystem with the configuration store + * associated with this instance name. + *

+ * + * @param subsystem the associated subsystem + * @param instanceName the name of this self test instance + * @param parameters configuration store (self test parameters) + * @exception EDuplicateSelfTestException subsystem has duplicate name/value + * @exception EInvalidSelfTestException subsystem has invalid name/value + * @exception EMissingSelfTestException subsystem has missing name/value + */ + public void initSelfTest(ISelfTestSubsystem subsystem, + String instanceName, + IConfigStore parameters) + throws EDuplicateSelfTestException, + EInvalidSelfTestException, + EMissingSelfTestException; + + /** + * Notifies this subsystem if it is in execution mode. + *

+ * + * @exception ESelfTestException failed to start + */ + public void startupSelfTest() + throws ESelfTestException; + + /** + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. + *

+ */ + public void shutdownSelfTest(); + + /** + * Returns the name associated with this self test. This method may + * return null if the self test has not been intialized. + *

+ * + * @return instanceName of this self test + */ + public String getSelfTestName(); + + /** + * Returns the root configuration storage (self test parameters) + * associated with this subsystem. + *

+ * + * @return configuration store (self test parameters) of this subsystem + */ + public IConfigStore getSelfTestConfigStore(); + + /** + * Retrieves description associated with an individual self test. + * This method may return null. + *

+ * + * @param locale locale of the client that requests the description + * @return description of self test + */ + public String getSelfTestDescription(Locale locale); + + /** + * Execute an individual self test. + *

+ * + * @param logger specifies logging subsystem + * @exception ESelfTestException self test exception + */ + public void runSelfTest(ILogEventListener logger) + throws ESelfTestException; +} diff --git a/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java b/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java new file mode 100644 index 000000000..d16627ab5 --- /dev/null +++ b/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java @@ -0,0 +1,338 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +// package statement // +/////////////////////// + +package com.netscape.certsrv.selftests; + +/////////////////////// +// import statements // +/////////////////////// + +import com.netscape.certsrv.base.ISubsystem; +import com.netscape.certsrv.logging.ILogEventListener; + +////////////////////// +// class definition // +////////////////////// + +/** + * This class defines the interface of a container for self tests. + *

+ * + * @version $Revision$, $Date$ + */ +public interface ISelfTestSubsystem + extends ISubsystem { + //////////////////////// + // default parameters // + //////////////////////// + + ////////////////////////////////// + // ISelfTestSubsystem constants // + ////////////////////////////////// + + public static final String ID = "selftests"; + public static final String PROP_CONTAINER = "container"; + public static final String PROP_INSTANCE = "instance"; + public static final String PROP_LOGGER = "logger"; + public static final String PROP_LOGGER_CLASS = "class"; + public static final String PROP_ORDER = "order"; + public static final String PROP_ON_DEMAND = "onDemand"; + public static final String PROP_STARTUP = "startup"; + + /////////////////////////////////////// + // ISubsystem parameters (inherited) // + /////////////////////////////////////// + + ///////////////////// + // default methods // + ///////////////////// + + //////////////////////////////// + // ISelfTestSubsystem methods // + //////////////////////////////// + + // + // methods associated with the list of on demand self tests + // + + /** + * List the instance names of all the self tests enabled to run on demand + * (in execution order); may return null. + *

+ * + * @return list of self test instance names run on demand + */ + public String[] listSelfTestsEnabledOnDemand(); + + /** + * Enable the specified self test to be executed on demand. + *

+ * + * @param instanceName instance name of self test + * @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; + + /** + * Disable the specified self test from being able to be executed on demand. + *

+ * + * @param instanceName instance name of self test + * @exception EMissingSelfTestException subsystem has missing name + */ + // public void disableSelfTestOnDemand( String instanceName ) + // throws EMissingSelfTestException; + + /** + * Determine if the specified self test is enabled to be executed on demand. + *

+ * + * @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; + + /** + * Determine if failure of the specified self test is fatal when + * it is executed on demand. + *

+ * + * @param instanceName instance name of self test + * @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; + + /** + * Execute all self tests specified to be run on demand. + *

+ * + * @exception EMissingSelfTestException subsystem has missing name + * @exception ESelfTestException self test exception + */ + public void runSelfTestsOnDemand() + throws EMissingSelfTestException, ESelfTestException; + + // + // methods associated with the list of startup self tests + // + + /** + * List the instance names of all the self tests enabled to run + * at server startup (in execution order); may return null. + *

+ * + * @return list of self test instance names run at server startup + */ + public String[] listSelfTestsEnabledAtStartup(); + + /** + * Enable the specified self test at server startup. + *

+ * + * @param instanceName instance name of self test + * @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; + + /** + * Disable the specified self test at server startup. + *

+ * + * @param instanceName instance name of self test + * @exception EMissingSelfTestException subsystem has missing name + */ + // public void disableSelfTestAtStartup( String instanceName ) + // throws EMissingSelfTestException; + + /** + * Determine if the specified self test is executed automatically + * at server startup. + *

+ * + * @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; + + /** + * Determine if failure of the specified self test is fatal to + * server startup. + *

+ * + * @param instanceName instance name of self test + * @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; + + /** + * Execute all self tests specified to be run at server startup. + *

+ * + * @exception EMissingSelfTestException subsystem has missing name + * @exception ESelfTestException self test exception + */ + public void runSelfTestsAtStartup() + throws EMissingSelfTestException, ESelfTestException; + + // + // methods associated with the list of self test instances + // + + /** + * Retrieve an individual self test from the instances list + * given its instance name. + *

+ * + * @param instanceName instance name of self test + * @return individual self test + */ + public ISelfTest getSelfTest(String instanceName); + + // + // methods associated with multiple self test lists + // + + /** + * Returns the ILogEventListener of this subsystem. + * This method may return null. + *

+ * + * @return ILogEventListener of this subsystem + */ + public ILogEventListener getSelfTestLogger(); + + /** + * This method represents the log interface for the self test subsystem. + *

+ * + * @param logger log event listener + * @param msg self test log message + */ + public void log(ILogEventListener logger, String 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). + *

+ * + * @param instanceName instance name of self test + * @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, + // EMissingSelfTestException; + + /** + * 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). + *

+ * + * @param instanceName instance name of self test + * @exception EMissingSelfTestException subsystem has missing name + */ + // public void deregisterSelfTestOnDemand( String instanceName ) + // throws EMissingSelfTestException; + + /** + * 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). + *

+ * + * @param instanceName instance name of self test + * @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, + // EMissingSelfTestException; + + /** + * 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). + *

+ * + * @param instanceName instance name of self test + * @exception EMissingSelfTestException subsystem has missing name + */ + // public void deregisterSelfTestAtStartup( String instanceName ) + // throws EMissingSelfTestException; + + //////////////////////////////////// + // ISubsystem methods (inherited) // + //////////////////////////////////// + + /* Note that all of the following ISubsystem methods + * are inherited from the ISubsystem class: + * + * public String getId(); + * + * public void setId( String id ) + * throws EBaseException; + * + * public void init( ISubsystem owner, IConfigStore config ) + * throws EBaseException; + * + * public void startup() + * throws EBaseException; + * + * public void shutdown(); + * + * public IConfigStore getConfigStore(); + */ +} diff --git a/base/common/src/com/netscape/certsrv/selftests/SelfTestResources.java b/base/common/src/com/netscape/certsrv/selftests/SelfTestResources.java new file mode 100644 index 000000000..c7c4d372d --- /dev/null +++ b/base/common/src/com/netscape/certsrv/selftests/SelfTestResources.java @@ -0,0 +1,39 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.selftests; + +import java.util.ListResourceBundle; + +/** + * A class represents a resource bundle for Self Tests. + *

+ * + * @version $Revision$, $Date$ + */ +public class SelfTestResources extends ListResourceBundle { + + /** + * Returns the content of this resource. + */ + public Object[][] getContents() { + return contents; + } + + static final Object[][] contents = { + }; +} -- cgit