summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/certsrv/selftests
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/certsrv/selftests')
-rw-r--r--pki/base/common/src/com/netscape/certsrv/selftests/EDuplicateSelfTestException.java225
-rw-r--r--pki/base/common/src/com/netscape/certsrv/selftests/EInvalidSelfTestException.java225
-rw-r--r--pki/base/common/src/com/netscape/certsrv/selftests/EMissingSelfTestException.java234
-rw-r--r--pki/base/common/src/com/netscape/certsrv/selftests/ESelfTestException.java123
-rw-r--r--pki/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java140
-rw-r--r--pki/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java358
-rw-r--r--pki/base/common/src/com/netscape/certsrv/selftests/SelfTestResources.java41
7 files changed, 1346 insertions, 0 deletions
diff --git a/pki/base/common/src/com/netscape/certsrv/selftests/EDuplicateSelfTestException.java b/pki/base/common/src/com/netscape/certsrv/selftests/EDuplicateSelfTestException.java
new file mode 100644
index 000000000..697646493
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/selftests/EDuplicateSelfTestException.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 //
+///////////////////////
+
+import com.netscape.certsrv.base.*;
+
+
+//////////////////////
+// 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.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class EDuplicateSelfTestException
+ extends ESelfTestException {
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ ///////////////////////
+ // helper parameters //
+ ///////////////////////
+
+ 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.
+ * <P>
+ *
+ * @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
+ * <P>
+ *
+ * @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).
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @return name portion of the name/value pair
+ */
+ public String getInstanceName() {
+ return mInstanceName;
+ }
+
+ /**
+ * Returns the store associated with this self test.
+ * <P>
+ *
+ * @return substore portion of the substore.parameter/value pair
+ */
+ public String getInstanceStore() {
+ return mInstanceStore;
+ }
+
+ /**
+ * Returns the parameter associated with this self test.
+ * <P>
+ *
+ * @return parameter portion of the substore.parameter/value pair
+ */
+ public String getInstanceParameter() {
+ return mInstanceParameter;
+ }
+
+ /**
+ * Returns the value associated with this self test.
+ * <P>
+ *
+ * @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/pki/base/common/src/com/netscape/certsrv/selftests/EInvalidSelfTestException.java b/pki/base/common/src/com/netscape/certsrv/selftests/EInvalidSelfTestException.java
new file mode 100644
index 000000000..b38b574cf
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/selftests/EInvalidSelfTestException.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 //
+///////////////////////
+
+import com.netscape.certsrv.base.*;
+
+
+//////////////////////
+// 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.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class EInvalidSelfTestException
+ extends ESelfTestException {
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ ///////////////////////
+ // helper parameters //
+ ///////////////////////
+
+ 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.
+ * <P>
+ *
+ * @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
+ * <P>
+ *
+ * @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).
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @return name portion of the name/value pair
+ */
+ public String getInstanceName() {
+ return mInstanceName;
+ }
+
+ /**
+ * Returns the store associated with this self test.
+ * <P>
+ *
+ * @return substore portion of the substore.parameter/value pair
+ */
+ public String getInstanceStore() {
+ return mInstanceStore;
+ }
+
+ /**
+ * Returns the parameter associated with this self test.
+ * <P>
+ *
+ * @return parameter portion of the substore.parameter/value pair
+ */
+ public String getInstanceParameter() {
+ return mInstanceParameter;
+ }
+
+ /**
+ * Returns the value associated with this self test.
+ * <P>
+ *
+ * @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/pki/base/common/src/com/netscape/certsrv/selftests/EMissingSelfTestException.java b/pki/base/common/src/com/netscape/certsrv/selftests/EMissingSelfTestException.java
new file mode 100644
index 000000000..8c2353287
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/selftests/EMissingSelfTestException.java
@@ -0,0 +1,234 @@
+// --- 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.*;
+
+
+//////////////////////
+// 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.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class EMissingSelfTestException
+ extends ESelfTestException {
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ ///////////////////////
+ // helper parameters //
+ ///////////////////////
+
+ 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
+ * <P>
+ *
+ */
+ 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.
+ * <P>
+ *
+ * @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).
+ * <P>
+ *
+ * @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).
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @return name portion of the name/value pair
+ */
+ public String getInstanceName() {
+ return mInstanceName;
+ }
+
+ /**
+ * Returns the store associated with this self test.
+ * <P>
+ *
+ * @return substore portion of the substore.parameter/value pair
+ */
+ public String getInstanceStore() {
+ return mInstanceStore;
+ }
+
+ /**
+ * Returns the parameter associated with this self test.
+ * <P>
+ *
+ * @return parameter portion of the substore.parameter/value pair
+ */
+ public String getInstanceParameter() {
+ return mInstanceParameter;
+ }
+
+ /**
+ * Returns the value associated with this self test.
+ * <P>
+ *
+ * @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/pki/base/common/src/com/netscape/certsrv/selftests/ESelfTestException.java b/pki/base/common/src/com/netscape/certsrv/selftests/ESelfTestException.java
new file mode 100644
index 000000000..2124e5d4a
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/selftests/ESelfTestException.java
@@ -0,0 +1,123 @@
+// --- 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.*;
+
+
+//////////////////////
+// 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.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class ESelfTestException
+ extends EBaseException {
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ ///////////////////////////////////
+ // ESelfTestException parameters //
+ ///////////////////////////////////
+
+ 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.
+ * <P>
+ *
+ * @param msg exception details
+ */
+ public ESelfTestException(String msg) {
+ super(msg);
+ }
+
+
+ ////////////////////////////////
+ // ESelfTestException methods //
+ ////////////////////////////////
+
+ /**
+ * Returns the bundle file name.
+ * <P>
+ * @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/pki/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java b/pki/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java
new file mode 100644
index 000000000..783f8955d
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java
@@ -0,0 +1,140 @@
+// --- 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.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.selftests.*;
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class defines the interface of an individual self test.
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @exception ESelfTestException failed to start
+ */
+ public void startupSelfTest()
+ throws ESelfTestException;
+
+ /**
+ * Stops this subsystem. The subsystem may call shutdownSelfTest
+ * anytime after initialization.
+ * <P>
+ */
+ public void shutdownSelfTest();
+
+ /**
+ * Returns the name associated with this self test. This method may
+ * return null if the self test has not been intialized.
+ * <P>
+ *
+ * @return instanceName of this self test
+ */
+ public String getSelfTestName();
+
+ /**
+ * Returns the root configuration storage (self test parameters)
+ * associated with this subsystem.
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @param logger specifies logging subsystem
+ * @exception ESelfTestException self test exception
+ */
+ public void runSelfTest(ILogEventListener logger)
+ throws ESelfTestException;
+}
+
diff --git a/pki/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java b/pki/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java
new file mode 100644
index 000000000..a44626b64
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java
@@ -0,0 +1,358 @@
+// --- 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.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.selftests.*;
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class defines the interface of a container for self tests.
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @return list of self test instance names run on demand
+ */
+ public String[] listSelfTestsEnabledOnDemand();
+
+ /**
+ * 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)
+ * @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.
+ * <P>
+ *
+ * @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.
+ * <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;
+
+ /**
+ * 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
+ * @exception EMissingSelfTestException subsystem has missing name
+ */
+ public boolean isSelfTestCriticalOnDemand(String instanceName)
+ throws EMissingSelfTestException;
+
+ /**
+ * 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;
+
+ //
+ // 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.
+ * <P>
+ *
+ * @return list of self test instance names run at server startup
+ */
+ public String[] listSelfTestsEnabledAtStartup();
+
+ /**
+ * 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)
+ * @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.
+ * <P>
+ *
+ * @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.
+ * <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;
+
+ /**
+ * 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
+ * @exception EMissingSelfTestException subsystem has missing name
+ */
+ public boolean isSelfTestCriticalAtStartup(String instanceName)
+ throws EMissingSelfTestException;
+
+ /**
+ * Execute all self tests specified to be run at server startup.
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @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.
+ * <P>
+ *
+ * @return ILogEventListener of this subsystem
+ */
+ public ILogEventListener getSelfTestLogger();
+
+ /**
+ * This method represents the log interface for the self test subsystem.
+ * <P>
+ *
+ * @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).
+ * <P>
+ *
+ * @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).
+ * <P>
+ *
+ * @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).
+ * <P>
+ *
+ * @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).
+ * <P>
+ *
+ * @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/pki/base/common/src/com/netscape/certsrv/selftests/SelfTestResources.java b/pki/base/common/src/com/netscape/certsrv/selftests/SelfTestResources.java
new file mode 100644
index 000000000..1c1551c5a
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/selftests/SelfTestResources.java
@@ -0,0 +1,41 @@
+// --- 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.*;
+
+
+/**
+ * A class represents a resource bundle for Self Tests.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class SelfTestResources extends ListResourceBundle {
+
+ /**
+ * Returns the content of this resource.
+ */
+ public Object[][] getContents() {
+ return contents;
+ }
+
+ static final Object[][] contents = {
+ };
+}