From 034c2fa8795250e12c29954dd3f7cf03e74776f7 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Fri, 17 Aug 2007 19:23:08 +0000
Subject: [PATCH] New tests for messaging plumbing to replace old ones:

---
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java |  102 ++++++++++++
 opendj-sdk/opends/src/messages/messages/backend.properties                                                  |    7 
 opendj-sdk/opends/src/messages/messages/extension.properties                                                |    7 
 opendj-sdk/opends/src/messages/messages/core.properties                                                     |    7 
 opendj-sdk/opends/src/messages/messages/user_defined.properties                                             |    7 
 opendj-sdk/opends/src/messages/messages/access_control.properties                                           |    7 
 opendj-sdk/opends/src/messages/messages/protocol.properties                                                 |    7 
 opendj-sdk/opends/src/messages/messages/util.properties                                                     |    6 
 opendj-sdk/opends/src/messages/messages/config.properties                                                   |    7 
 opendj-sdk/opends/src/messages/messages/admin_tool.properties                                               |   49 +++++
 opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptor.java                               |   10 +
 opendj-sdk/opends/src/messages/messages/sync.properties                                                     |    6 
 opendj-sdk/opends/src/messages/messages/tools.properties                                                    |    7 
 opendj-sdk/opends/src/messages/messages/replication.properties                                              |   23 +-
 opendj-sdk/opends/src/messages/messages/jeb.properties                                                      |    7 
 opendj-sdk/opends/src/messages/messages/schema.properties                                                   |    7 
 opendj-sdk/opends/src/messages/messages/task.properties                                                     |    7 
 opendj-sdk/opends/src/messages/messages/quicksetup.properties                                               |   45 +++++
 opendj-sdk/opends/src/messages/messages/log.properties                                                      |    7 
 opendj-sdk/opends/build.xml                                                                                 |    8 +
 opendj-sdk/opends/src/messages/messages/version.properties                                                  |    7 
 opendj-sdk/opends/src/messages/messages/admin.properties                                                    |    7 
 opendj-sdk/opends/src/messages/messages/utility.properties                                                  |   11 -
 opendj-sdk/opends/src/messages/messages/third_party.properties                                              |    7 
 opendj-sdk/opends/src/messages/src/org/opends/messages/Category.java                                        |    5 
 opendj-sdk/opends/src/messages/messages/plugin.properties                                                   |    7 
 opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java                       |   53 ++++++
 27 files changed, 290 insertions(+), 140 deletions(-)

diff --git a/opendj-sdk/opends/build.xml b/opendj-sdk/opends/build.xml
index c48487b..fa45d3c 100644
--- a/opendj-sdk/opends/build.xml
+++ b/opendj-sdk/opends/build.xml
@@ -707,6 +707,10 @@
       <fileset dir="${msg.prop.dir}"/>
     </copy>
 
+    <!-- copy the message descriptor registry file -->
+    <copy todir="${classes.dir}/org/opends/messages"
+          file="${msg.javagen.dir}/org/opends/messages/descriptors.reg" />
+
     <!-- Generate the OpenDS.jar file -->
     <jar jarfile="${pdir}/lib/${SHORT_NAME}.jar"
          basedir="${classes.dir}"
@@ -801,6 +805,10 @@
       <fileset dir="${msg.prop.dir}"/>
     </copy>
 
+    <!-- copy the message descriptor registry file -->
+    <copy todir="${classes.dir}/org/opends/messages"
+          file="${msg.javagen.dir}/org/opends/messages/descriptors.reg" />
+
     <jar jarfile="${pdir}/lib/${SHORT_NAME}.jar"
          basedir="${classes.dir}" 
          excludes="${ads.classes.dir}, ${quicksetup.globalcompile.classes.dir}"    
diff --git a/opendj-sdk/opends/src/messages/messages/access_control.properties b/opendj-sdk/opends/src/messages/messages/access_control.properties
index a6129b5..042bfdb 100644
--- a/opendj-sdk/opends/src/messages/messages/access_control.properties
+++ b/opendj-sdk/opends/src/messages/messages/access_control.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/admin.properties b/opendj-sdk/opends/src/messages/messages/admin.properties
index 265e1d4..328a882 100644
--- a/opendj-sdk/opends/src/messages/messages/admin.properties
+++ b/opendj-sdk/opends/src/messages/messages/admin.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/admin_tool.properties b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
index 294092a..e2ff970 100644
--- a/opendj-sdk/opends/src/messages/messages/admin_tool.properties
+++ b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
@@ -1,6 +1,51 @@
-global.category=QUICKSETUP
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE
+# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+# add the following below this CDDL HEADER, with the fields enclosed
+# by brackets "[]" replaced with your own identifying information:
+#      Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+
+
+
+#
+# Global directives
+#
+global.category=ADMIN_TOOL
 global.ordinal=-1
 
+#
+# Format string definitions
+#
+# Keys must be formatted as follows:
+#
+# [SEVERITY]_[DESCRIPTION]
+#
+# where:
+#
+# SEVERITY is one of:
+# [INFO, MILD_WARN, SEVERE_WARN, MILD_ERR, SEVERE_ERR, FATAL_ERR, DEBUG, NOTICE]
+#
+# DESCRIPTION is an upper case string providing a hint as to the context of
+# the message in upper case with the underscore ('_') character serving as
+# word separator
+#
 INFO_ADDRESS_PORT_COLUMN=Address:Port
 INFO_ADMINISTRATIVE_USERS_LABEL=Administrative Users:
 INFO_AGE_OF_OLDEST_MISSING_CHANGE_COLUMN=<html>Age of Oldest<br>Missing \
@@ -315,4 +360,4 @@
 INFO_UNINSTALLDS_DESCRIPTION_REMOVE_BACKUP_FILES=Remove backup files
 INFO_UNINSTALLDS_DESCRIPTION_REMOVE_LDIF_FILES=Remove LDIF files
 INFO_DESCRIPTION_ADMINUID=Specifies the User ID of the Global Administrator to \
-use to bind to the server
\ No newline at end of file
+use to bind to the server
diff --git a/opendj-sdk/opends/src/messages/messages/backend.properties b/opendj-sdk/opends/src/messages/messages/backend.properties
index 6992dd0..1a680dd 100644
--- a/opendj-sdk/opends/src/messages/messages/backend.properties
+++ b/opendj-sdk/opends/src/messages/messages/backend.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/config.properties b/opendj-sdk/opends/src/messages/messages/config.properties
index 979febe..51b3003 100644
--- a/opendj-sdk/opends/src/messages/messages/config.properties
+++ b/opendj-sdk/opends/src/messages/messages/config.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/core.properties b/opendj-sdk/opends/src/messages/messages/core.properties
index b55eac9..4731b81 100644
--- a/opendj-sdk/opends/src/messages/messages/core.properties
+++ b/opendj-sdk/opends/src/messages/messages/core.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/extension.properties b/opendj-sdk/opends/src/messages/messages/extension.properties
index adbbdf2..21b4c4e 100644
--- a/opendj-sdk/opends/src/messages/messages/extension.properties
+++ b/opendj-sdk/opends/src/messages/messages/extension.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/jeb.properties b/opendj-sdk/opends/src/messages/messages/jeb.properties
index 85e5bdf..accc77d 100644
--- a/opendj-sdk/opends/src/messages/messages/jeb.properties
+++ b/opendj-sdk/opends/src/messages/messages/jeb.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/log.properties b/opendj-sdk/opends/src/messages/messages/log.properties
index 29c8a98..9c650bb 100644
--- a/opendj-sdk/opends/src/messages/messages/log.properties
+++ b/opendj-sdk/opends/src/messages/messages/log.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/plugin.properties b/opendj-sdk/opends/src/messages/messages/plugin.properties
index ae6f147..8b7e6d2 100644
--- a/opendj-sdk/opends/src/messages/messages/plugin.properties
+++ b/opendj-sdk/opends/src/messages/messages/plugin.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/protocol.properties b/opendj-sdk/opends/src/messages/messages/protocol.properties
index 5e048f2..0c80603 100644
--- a/opendj-sdk/opends/src/messages/messages/protocol.properties
+++ b/opendj-sdk/opends/src/messages/messages/protocol.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/quicksetup.properties b/opendj-sdk/opends/src/messages/messages/quicksetup.properties
index 640a6f9..1e92225 100644
--- a/opendj-sdk/opends/src/messages/messages/quicksetup.properties
+++ b/opendj-sdk/opends/src/messages/messages/quicksetup.properties
@@ -1,6 +1,51 @@
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE
+# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+# add the following below this CDDL HEADER, with the fields enclosed
+# by brackets "[]" replaced with your own identifying information:
+#      Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+
+
+
+#
+# Global directives
+#
 global.category=QUICKSETUP
 global.ordinal=-1
 
+#
+# Format string definitions
+#
+# Keys must be formatted as follows:
+#
+# [SEVERITY]_[DESCRIPTION]
+#
+# where:
+#
+# SEVERITY is one of:
+# [INFO, MILD_WARN, SEVERE_WARN, MILD_ERR, SEVERE_ERR, FATAL_ERR, DEBUG, NOTICE]
+#
+# DESCRIPTION is an upper case string providing a hint as to the context of
+# the message in upper case with the underscore ('_') character serving as
+# word separator
+#
 INFO_ADMINISTRATOR_ALREADY_REGISTERED=Administrator already registered.
 INFO_ADS_EXCEPTION=An unexpected error occurred managing the registration \
  information.%nThe error is: %s
diff --git a/opendj-sdk/opends/src/messages/messages/replication.properties b/opendj-sdk/opends/src/messages/messages/replication.properties
index df5d831..c71f537 100644
--- a/opendj-sdk/opends/src/messages/messages/replication.properties
+++ b/opendj-sdk/opends/src/messages/messages/replication.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
@@ -85,7 +80,7 @@
 NOTICE_EXCEPTION_STARTING_SESSION_20=Caught Exception during initial \
  communication with replication server :
 NOTICE_CANNOT_RECOVER_CHANGES_21=Error when searching old changes from the \
- database.
+ database
 NOTICE_COULD_NOT_FIND_CHANGELOG_WITH_MY_CHANGES_22=Could not find a \
  replication server that has seen all the local changes. Going to replay \
  changes
@@ -95,23 +90,23 @@
 SEVERE_ERR_EXCEPTION_DECODING_OPERATION_25=Error trying to replay %s, \
  operation could not be decoded :
 FATAL_ERR_CHANGELOG_SHUTDOWN_DATABASE_ERROR_26=Error Trying to use the \
- underlying database. The Changelog Service is going to shut down.
+ underlying database. The Changelog Service is going to shut down
 SEVERE_ERR_IGNORE_BAD_DN_IN_DATABASE_IDENTIFIER_27=A badly formatted DN was \
  found in the list of database known By this changelog service :%s. This \
- Identifier will be ignored.
+ Identifier will be ignored
 SEVERE_ERR_ERROR_CLOSING_CHANGELOG_ENV_28=Error closing the changelog \
  database :
 SEVERE_ERR_EXCEPTION_CHANGELOG_TRIM_FLUSH_29=Error during the changelog \
  database trimming or flush process. The Changelog service is going to \
- shutdown.
+ shutdown
 SEVERE_ERR_CHANGELOG_CONNECTION_ERROR_30=Error during Changelog service \
- message processing . Connection from %s is rejected.
+ message processing . Connection from %s is rejected
 SEVERE_ERR_UNKNOWN_MESSAGE_31=%s has sent an unknown message. Closing the \
- connection.
+ connection
 SEVERE_ERR_WRITER_UNEXPECTED_EXCEPTION_32=An unexpected error happened \
- handling connection with %s.  This connection is going to be closed.
+ handling connection with %s.  This connection is going to be closed
 SEVERE_ERR_CHANGELOG_ERROR_SENDING_ACK_33=An unexpected error occurred  while \
- sending an ack to %s.  This connection is going to be closed and reopened.
+ sending an ack to %s.  This connection is going to be closed and reopened
 SEVERE_ERR_EXCEPTION_RECEIVING_REPLICATION_MESSAGE_34=An Exception was caught \
  while receiving replication message : %s
 MILD_ERR_LOOP_REPLAYING_OPERATION_35=A loop was detected while replaying \
diff --git a/opendj-sdk/opends/src/messages/messages/schema.properties b/opendj-sdk/opends/src/messages/messages/schema.properties
index 268a071..ec7c510 100644
--- a/opendj-sdk/opends/src/messages/messages/schema.properties
+++ b/opendj-sdk/opends/src/messages/messages/schema.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/sync.properties b/opendj-sdk/opends/src/messages/messages/sync.properties
index 50d35ff..3c05f88 100644
--- a/opendj-sdk/opends/src/messages/messages/sync.properties
+++ b/opendj-sdk/opends/src/messages/messages/sync.properties
@@ -21,12 +21,6 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
 
 
 
diff --git a/opendj-sdk/opends/src/messages/messages/task.properties b/opendj-sdk/opends/src/messages/messages/task.properties
index 05a6238..dcbcaea 100644
--- a/opendj-sdk/opends/src/messages/messages/task.properties
+++ b/opendj-sdk/opends/src/messages/messages/task.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/third_party.properties b/opendj-sdk/opends/src/messages/messages/third_party.properties
index aa7960a..6723819 100644
--- a/opendj-sdk/opends/src/messages/messages/third_party.properties
+++ b/opendj-sdk/opends/src/messages/messages/third_party.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/tools.properties b/opendj-sdk/opends/src/messages/messages/tools.properties
index d632bdb..84f22e3 100644
--- a/opendj-sdk/opends/src/messages/messages/tools.properties
+++ b/opendj-sdk/opends/src/messages/messages/tools.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/user_defined.properties b/opendj-sdk/opends/src/messages/messages/user_defined.properties
index 501a233..4b4827d 100644
--- a/opendj-sdk/opends/src/messages/messages/user_defined.properties
+++ b/opendj-sdk/opends/src/messages/messages/user_defined.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/messages/util.properties b/opendj-sdk/opends/src/messages/messages/util.properties
index 4d27c60..752c042 100644
--- a/opendj-sdk/opends/src/messages/messages/util.properties
+++ b/opendj-sdk/opends/src/messages/messages/util.properties
@@ -21,12 +21,6 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
 
 
 
diff --git a/opendj-sdk/opends/src/messages/messages/utility.properties b/opendj-sdk/opends/src/messages/messages/utility.properties
index 4e5cad1..4f02a3b 100644
--- a/opendj-sdk/opends/src/messages/messages/utility.properties
+++ b/opendj-sdk/opends/src/messages/messages/utility.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
@@ -134,7 +129,7 @@
  record entry. Invalid value "%s" for the changetype specified. Expecting one \
  of the following values "%s"
 SEVERE_ERR_LDIF_INVALID_MODIFY_ATTRIBUTE_VAL_31=Error in the LDIF change \
- record entry. Invalid value for the "%s" attribute specified.
+ record entry. Invalid value for the "%s" attribute specified
 SEVERE_ERR_SCHEMANAME_EMPTY_VALUE_32=The provided value could not be parsed \
  to determine whether it contained a valid schema element name or OID because \
  it was null or empty
@@ -427,4 +422,4 @@
  be started because it is already running
 INFO_SUBCMDPARSER_OPTIONS_168={options}
 INFO_SUBCMDPARSER_SUBCMD_AND_OPTIONS_169={subcommand} {options}
-INFO_SUBCMDPARSER_WHERE_OPTIONS_INCLUDE_170=\        where {options} include:
\ No newline at end of file
+INFO_SUBCMDPARSER_WHERE_OPTIONS_INCLUDE_170=\        where {options} include:
diff --git a/opendj-sdk/opends/src/messages/messages/version.properties b/opendj-sdk/opends/src/messages/messages/version.properties
index 4f9ce52..de1da26 100644
--- a/opendj-sdk/opends/src/messages/messages/version.properties
+++ b/opendj-sdk/opends/src/messages/messages/version.properties
@@ -21,12 +21,7 @@
 # CDDL HEADER END
 #
 #      Portions Copyright 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration.  It must not
-# be directly edited while the server is online.  The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
+
 
 
 #
diff --git a/opendj-sdk/opends/src/messages/src/org/opends/messages/Category.java b/opendj-sdk/opends/src/messages/src/org/opends/messages/Category.java
index 30803f1..99685b9 100644
--- a/opendj-sdk/opends/src/messages/src/org/opends/messages/Category.java
+++ b/opendj-sdk/opends/src/messages/src/org/opends/messages/Category.java
@@ -134,9 +134,10 @@
   QUICKSETUP(0x01000000),
 
   /**
-   * The category used for messages associated with the status panel.
+   * The category used for messages associated with the tool like the
+   * offline installer and unintaller.
    */
-  STATUS_PANEL(0x01100000),
+  ADMIN_TOOL(0x01100000),
 
   /**
    * The category that will be used for messages associated with
diff --git a/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptor.java b/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
index 1dbe91c..f220aad 100644
--- a/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
+++ b/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
@@ -872,6 +872,16 @@
 
   /**
    * Obtains the format string for constructing the string
+   * value of this message according to the default
+   * locale.
+   * @return format string
+   */
+  String getFormatString() {
+    return getFormatString(Locale.getDefault());
+  }
+
+  /**
+   * Obtains the format string for constructing the string
    * value of this message according to the requested
    * locale.
    * @param locale for the returned format string
diff --git a/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java b/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java
index eb5e7ac..0a2306b 100644
--- a/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java
+++ b/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageDescriptorRegistry.java
@@ -29,6 +29,11 @@
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.List;
+import java.util.LinkedList;
 import java.io.InputStream;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
@@ -36,17 +41,27 @@
 import java.lang.reflect.Field;
 
 /**
- * Serves as a registry for messages providing access to
- * descriptors by ID.
+ * Serves as a registry for messages providing access to message descriptors
+ * by ID and class in which they are defined.  Classes containing message
+ * descriptors are stored in the text file "descriptors.reg" which is
+ * generated during the OpenDS build process.
  */
 public class MessageDescriptorRegistry {
 
   private static final String REGISTRY_FILE = "descriptors.reg";
 
+  private static final Set<Class> REGISTERED_MESSAGE_CLASSES =
+                  new HashSet<Class>();
+
   private static final Map<Integer, MessageDescriptor>
           ID_TO_DESCRIPTORS =
                   new HashMap<Integer,MessageDescriptor>();
 
+  private static final Map<Class, List<MessageDescriptor>>
+          CLASS_TO_DESCRIPTORS =
+                  new HashMap<Class,List<MessageDescriptor>>();
+
+
   static {
     InputStream is = MessageDescriptor.class
             .getResourceAsStream(REGISTRY_FILE);
@@ -59,12 +74,16 @@
         Class descClass;
         try {
           descClass = Class.forName(descClassName);
+          List<MessageDescriptor> mdList = new LinkedList<MessageDescriptor>();
+          CLASS_TO_DESCRIPTORS.put(descClass,  mdList);
+          REGISTERED_MESSAGE_CLASSES.add(descClass);
           Field[] fa = descClass.getFields();
           if (fa != null) {
             for (Field f : fa) {
-              Class<?> c = f.getDeclaringClass();
-              if (c.isAssignableFrom(MessageDescriptor.class)) {
+              Class<?> c = f.getType();
+              if (MessageDescriptor.class.isAssignableFrom(c)) {
                 MessageDescriptor md = (MessageDescriptor)f.get(null);
+                mdList.add(md);
                 int id = md.getId();
                 if (id != MessageDescriptor.NULL_ID) {
                   ID_TO_DESCRIPTORS.put(id, md);
@@ -88,6 +107,7 @@
 
   /**
    * Returns a message descriptor given its unique OpenDS system-wide ID.
+   *
    * @param id integer value of the message to retreive
    * @return MessageDescriptor having the ID of <code>id</code>
    */
@@ -95,4 +115,29 @@
     return ID_TO_DESCRIPTORS.get(id);
   }
 
+  /**
+   * Given a registered class containing message descriptors, returns a
+   * list of all message descriptors defined by that class.
+   *
+   * @param mdClass registered class containing message descriptors
+   * @return unmodifiable list of message descriptors declared in
+   *         <code>mdClass</code>
+   */
+
+  public static List<MessageDescriptor> getMessageDescriptorsForClass(
+          Class mdClass)
+  {
+    return Collections.unmodifiableList(CLASS_TO_DESCRIPTORS.get(mdClass));
+  }
+
+  /**
+   * Returns a set of classes registered as having message descriptor
+   * declarations.
+   *
+   * @return list of classes
+   */
+  public static Set<Class> getRegisteredClasses() {
+    return Collections.unmodifiableSet(REGISTERED_MESSAGE_CLASSES);
+  }
+
 }
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java
index b3d0136..49aec35 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessageDescriptorRegistryTest.java
@@ -30,6 +30,17 @@
 import static org.testng.Assert.*;
 import org.testng.annotations.*;
 
+import java.util.Set;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.EnumSet;
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Field;
+
 /**
  * MessageDescriptorRegistry Tester.
  *
@@ -46,8 +57,95 @@
 
   @Test(dataProvider = "message descriptors")
   public void testGetMessageDescriptor(MessageDescriptor md) {
-    assertEquals(md,
-            MessageDescriptorRegistry.getMessageDescriptor(md.getId()));
+    MessageDescriptor md2 = MessageDescriptorRegistry.getMessageDescriptor(md.getId());
+    assertEquals(md, md2);
   }
 
+  @DataProvider(name = "message classes")
+  public Object[][] getMessageClasses() {
+    Set<Class> mdClasses = MessageDescriptorRegistry.getRegisteredClasses();
+    List<Class> classesToTest = new ArrayList<Class>(mdClasses);
+
+    // These newer message files don't comply
+    classesToTest.remove(AdminToolMessages.class);
+    classesToTest.remove(QuickSetupMessages.class);
+
+    Object[][] ret = new Object[classesToTest.size()][1];
+    for (int i = 0; i < ret.length; i++) {
+      ret[i] = new Object[] { classesToTest.get(i) };
+    }
+    return ret;
+  }
+
+  /**
+   * Tests that messages don't end with a period (.) excluding those that end
+   * with an ellipsis (...)
+   * 
+   * @param  messagesClass containing definitions of MessageDescriptor objects
+   * @throws IllegalAccessException if there is a problem accessing the
+   *         class through reflection
+   */
+  @Test(dataProvider = "message classes")
+  public void testFormatStringsDontEndWithPeriod(Class messagesClass)
+          throws IllegalAccessException
+  {
+    Field[] fa = messagesClass.getFields();
+    if (fa != null) {
+      for (Field f : fa) {
+        Class<?> c = f.getType();
+        if (MessageDescriptor.class.isAssignableFrom(c)) {
+          MessageDescriptor md = (MessageDescriptor)f.get(null);
+          String fmtString = md.getFormatString(Locale.getDefault());
+          boolean bad = fmtString.endsWith(".") && !fmtString.endsWith("...");
+          assertFalse(bad,
+                  "Format string for message descriptor " + f.getName() +
+                  " obtained through key " + md.getKey() + 
+                  " defined in class " + messagesClass.getName() +
+                  " \'" + md.getFormatString(Locale.getDefault()) +
+                  "\' ends with a '.'");
+        }
+      }
+    }
+  }
+
+  /**
+   * Tests that messages for each category are restricted to a single
+   * messages file and that each file only contains messages from a
+   * single category.
+   */
+  @Test
+  public void testCategoriesDontSpanFiles() {
+    Map<Category,Class> categoriesToClass = new HashMap<Category,Class>();
+    Set categories = EnumSet.allOf(Category.class);
+    Set<Class> msgClasses = MessageDescriptorRegistry.getRegisteredClasses();
+    for (Class msgClass : msgClasses) {
+      List<MessageDescriptor> mds =
+              MessageDescriptorRegistry.getMessageDescriptorsForClass(msgClass);
+      Category currentCategory = null;
+      for (MessageDescriptor md : mds) {
+        if (currentCategory == null) {
+          currentCategory = md.getCategory();
+          if (categories.contains(currentCategory)) {
+            categories.remove(currentCategory);
+            categoriesToClass.put(currentCategory, msgClass);
+          } else {
+            assertTrue(false,
+                    "Message file " + msgClass + " defines descriptors " +
+                    "for category " + currentCategory + " but message file " +
+                    categoriesToClass.get(currentCategory) + " defines descriptors " +
+                    "of " + currentCategory + ".  Descriptors for a particular " +
+                    "category can only be defined in a single messages file.");
+          }
+        } else {
+          boolean categoriesMatch = currentCategory.equals(md.getCategory());
+          assertTrue(categoriesMatch,
+                  "Message file " + msgClass + " contains descriptors from at least " +
+                          "two different categories: descriptor of key " +
+                          md.getFormatString() + " is of category " + md.getCategory() +
+                          " but expected category was " + currentCategory);
+
+        }
+      }
+    }
+  }
 }

--
Gitblit v1.10.0