From 35f4c9400e583aa53856c929a5fbcb52f66cd96b Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 11 Feb 2014 13:38:53 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1306 - Added javadoc / unit tests. - Replaced CLIException calls.

---
 opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java                   |   59 +++++-
 opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ListenerSettingsTestCase.java |    2 
 opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/ListenerSettings.java         |  211 +++++++++++++++++++++++++-
 opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupLog.java                   |   10 
 opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java                    |  119 ++++++++++++--
 opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ModelTestCase.java            |    2 
 opendj-server/src/test/java/org/forgerock/opendj/server/setup/cli/SetupCliTestCase.java           |   42 ++++
 7 files changed, 394 insertions(+), 51 deletions(-)

diff --git a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java
index 2b09329..efe9f52 100644
--- a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java
+++ b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java
@@ -28,6 +28,7 @@
 import static com.forgerock.opendj.cli.Utils.LINE_SEPARATOR;
 import static com.forgerock.opendj.cli.Utils.checkJavaVersion;
 import static com.forgerock.opendj.cli.CliMessages.*;
+import static com.forgerock.opendj.cli.CliConstants.*;
 
 import java.io.PrintStream;
 import java.util.ArrayList;
@@ -43,8 +44,7 @@
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
 import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.CLIException;
-import com.forgerock.opendj.cli.CliConstants;
+import com.forgerock.opendj.cli.ClientException;
 import com.forgerock.opendj.cli.CommonArguments;
 import com.forgerock.opendj.cli.ConsoleApplication;
 import com.forgerock.opendj.cli.FileBasedArgument;
@@ -113,7 +113,7 @@
     private StringArgument usePkcs12;
     private StringArgument keyStorePassword;
     private StringArgument certNickname;
-    private IntegerArgument connectTimeout = null;
+    private IntegerArgument connectTimeout;
     private BooleanArgument acceptLicense;
 
     // Sub-commands
@@ -155,7 +155,7 @@
 
         try {
             checkJavaVersion();
-        } catch (CLIException e) {
+        } catch (ClientException e) {
             errPrintln(e.getMessageObject());
             return ReturnCode.JAVA_VERSION_INCOMPATIBLE.get();
         }
@@ -200,11 +200,26 @@
         }
 
         // Starts setup process.
+        try {
+            fillSetupSettings();
+            runSetupInstallation();
+        } catch (ClientException ex) {
+            return ex.getReturnCode();
+        } catch (Exception ex) {
+            // TODO
+            //println(Style.ERROR, LocalizableMessage.raw("...?"));
+            return ReturnCode.ERROR_UNEXPECTED.get();
+        }
         return ReturnCode.SUCCESS.get();
     }
 
+    /**
+     * Initialize setup's arguments by default.
+     *
+     * @throws ArgumentException
+     *             If an exception occurs during the initialization of the arguments.
+     */
     private void initializeArguments() throws ArgumentException {
-
         // Options.
         acceptLicense = CommonArguments.getAcceptLicense();
         cli = CommonArguments.getCLI();
@@ -214,9 +229,9 @@
         rejectedImportFile = CommonArguments.getRejectedImportLdif();
         skippedImportFile = CommonArguments.getSkippedImportFile();
         sampleData = CommonArguments.getSampleData();
-        ldapPort = CommonArguments.getLDAPPort(CliConstants.DEFAULT_LDAP_PORT);
-        adminConnectorPort = CommonArguments.getAdminLDAPPort(CliConstants.DEFAULT_ADMIN_PORT);
-        jmxPort = CommonArguments.getJMXPort(CliConstants.DEFAULT_JMX_PORT);
+        ldapPort = CommonArguments.getLDAPPort(DEFAULT_LDAP_PORT);
+        adminConnectorPort = CommonArguments.getAdminLDAPPort(DEFAULT_ADMIN_PORT);
+        jmxPort = CommonArguments.getJMXPort(DEFAULT_JMX_PORT);
         skipPortCheck = CommonArguments.getSkipPortCheck();
         directoryManagerDN = CommonArguments.getRootDN();
         directoryManagerPwdString = CommonArguments.getRootDNPwd();
@@ -224,7 +239,7 @@
         enableWindowsService = CommonArguments.getEnableWindowsService();
         doNotStart = CommonArguments.getDoNotStart();
         enableStartTLS = CommonArguments.getEnableTLS();
-        ldapsPort = CommonArguments.getLDAPSPort(CliConstants.DEFAULT_LDAPS_PORT);
+        ldapsPort = CommonArguments.getLDAPSPort(DEFAULT_LDAPS_PORT);
         generateSelfSignedCertificate = CommonArguments.getGenerateSelfSigned();
         hostName = CommonArguments.getHostName(Utils.getDefaultHostName());
         usePkcs11 = CommonArguments.getUsePKCS11Keystore();
@@ -234,7 +249,7 @@
         keyStorePassword = CommonArguments.getKeyStorePassword();
         keyStorePasswordFile = CommonArguments.getKeyStorePasswordFile();
         certNickname = CommonArguments.getCertNickName();
-        connectTimeout = CommonArguments.getConnectTimeOut(30000);
+        connectTimeout = CommonArguments.getConnectTimeOut(DEFAULT_LDAP_CONNECT_TIMEOUT);
 
         // Utility Input Output Options.
         noPrompt = CommonArguments.getNoPrompt();
@@ -475,20 +490,20 @@
             if (!generateSelfSignedCertificate.isPresent()) {
                 // Check that we have only a password.
                 if (keyStorePassword.isPresent() && keyStorePasswordFile.isPresent()) {
-                    LocalizableMessage message = ERR_TWO_CONFLICTING_ARGUMENTS.get(
+                    final LocalizableMessage message = ERR_TWO_CONFLICTING_ARGUMENTS.get(
                             keyStorePassword.getLongIdentifier(), keyStorePasswordFile.getLongIdentifier());
                     errorMessages.add(message);
                 }
 
                 // Check that we have one password in no prompt mode.
                 if (noPrompt.isPresent() && !keyStorePassword.isPresent() && !keyStorePasswordFile.isPresent()) {
-                    LocalizableMessage message = ERR_NO_KEYSTORE_PASSWORD.get(keyStorePassword.getLongIdentifier(),
-                            keyStorePasswordFile.getLongIdentifier());
+                    final LocalizableMessage message = ERR_NO_KEYSTORE_PASSWORD.get(
+                            keyStorePassword.getLongIdentifier(), keyStorePasswordFile.getLongIdentifier());
                     errorMessages.add(message);
                 }
             }
             if (noPrompt.isPresent() && !ldapsPort.isPresent() && !enableStartTLS.isPresent()) {
-                LocalizableMessage message = ERR_SSL_OR_STARTTLS_REQUIRED.get(ldapsPort.getLongIdentifier(),
+                final LocalizableMessage message = ERR_SSL_OR_STARTTLS_REQUIRED.get(ldapsPort.getLongIdentifier(),
                         enableStartTLS.getLongIdentifier());
                 errorMessages.add(message);
             }
@@ -543,4 +558,20 @@
             return mb.toMessage();
         }
     }
+
+    /**
+     * Fills the setup components according to the arguments provided by the user.
+     * @throws ArgumentException
+     */
+    private void fillSetupSettings() throws ArgumentException {
+        // TODO ...
+    }
+
+    /**
+     * Launches the setup process.
+     * @throws ClientException
+     */
+    private void runSetupInstallation() throws ClientException {
+        // TODO move that function to another class.
+    }
 }
diff --git a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupLog.java b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupLog.java
index b030e6f..53bdcbc 100644
--- a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupLog.java
+++ b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupLog.java
@@ -38,8 +38,9 @@
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
-import com.forgerock.opendj.cli.CLIException;
+import com.forgerock.opendj.cli.ClientException;
 import com.forgerock.opendj.cli.CliMessages;
+import com.forgerock.opendj.cli.ReturnCode;
 
 /**
  * Creates a historical log about the setup. If file does not exist an attempt will be made to create it.
@@ -100,14 +101,15 @@
      * Returns the print stream of the current logger.
      *
      * @return the print stream of the current logger.
-     * @throws CLIException
+     * @throws ClientException
      *             If the file defined by the logger is not found or invalid.
      */
-    static PrintStream getPrintStream() throws CLIException {
+    static PrintStream getPrintStream() throws ClientException {
         try {
             return new PrintStream(new FileOutputStream(logFile, true));
         } catch (FileNotFoundException e) {
-            throw new CLIException(CliMessages.ERR_INVALID_LOG_FILE.get(e.getMessage()));
+            throw new ClientException(ReturnCode.ERROR_UNEXPECTED,
+                    CliMessages.ERR_INVALID_LOG_FILE.get(e.getMessage()));
         }
     }
 
diff --git a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/ListenerSettings.java b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/ListenerSettings.java
index 3882404..4f76e52 100644
--- a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/ListenerSettings.java
+++ b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/ListenerSettings.java
@@ -34,13 +34,13 @@
 /**
  * This class provides listener settings for the OpenDJ3 setup.
  */
-class ListenerSettings {
+public class ListenerSettings {
 
     private String hostName;
     private int ldapPort;
     private int ldapsPort;
     private int adminPort;
-    private boolean isJMXConnectionHandlerEnbled;
+    private boolean isJMXConnectionHandlerEnabled;
     private int jmxPort;
     private boolean isHTTPConnectionHandlerEnabled;
     private int httpPort;
@@ -54,13 +54,16 @@
     private int sslPortNumber;
     private Certificate certificate;
 
-    ListenerSettings() {
+    /**
+     * Default constructor.
+     */
+    public ListenerSettings() {
         hostName = "";
         ldapPort = DEFAULT_LDAP_PORT;
         ldapsPort = DEFAULT_LDAPS_PORT;
         adminPort = DEFAULT_ADMIN_PORT;
         jmxPort = DEFAULT_JMX_PORT;
-        isJMXConnectionHandlerEnbled = false;
+        isJMXConnectionHandlerEnabled = false;
         httpPort = DEFAULT_HTTP_PORT;
         isHTTPConnectionHandlerEnabled = true;
         snmpPort = DEFAULT_SNMP_PORT;
@@ -72,94 +75,220 @@
         certificate = null;
     }
 
+    /**
+     * Returns the host name.
+     *
+     * @return The host name of the local machine.
+     */
     public String getHostName() {
         return hostName;
     }
 
+    /**
+     * Sets the host name of the machine.
+     *
+     * @param hostName
+     *            The host name of the current machine.
+     */
     public void setHostName(String hostName) {
         this.hostName = hostName;
     }
 
+    /**
+     * Returns the value of the LDAP port.
+     *
+     * @return The value of the LDAP port.
+     */
     public int getLdapPort() {
         return ldapPort;
     }
 
+    /**
+     * Sets the value of the LDAP port.
+     *
+     * @param ldapPort
+     *            The LDAP port's value to set.
+     */
     public void setLdapPort(int ldapPort) {
         this.ldapPort = ldapPort;
     }
 
+    /**
+     * Return the LDAPs port.
+     *
+     * @return The LDAPs port's value.
+     */
     public int getLdapsPort() {
         return ldapsPort;
     }
 
+    /**
+     * Sets the LDAPs port value.
+     *
+     * @param ldapsPort
+     *            The LDAPs port's value to set.
+     */
     public void setLdapsPort(int ldapsPort) {
         this.ldapsPort = ldapsPort;
     }
 
+    /**
+     * Returns the administration connector port.
+     *
+     * @return The administration connector's port
+     */
     public int getAdminPort() {
         return adminPort;
     }
 
+    /**
+     * Sets the administration connector 's port.
+     *
+     * @param adminPort
+     *            The administration connector.
+     */
     public void setAdminPort(int adminPort) {
         this.adminPort = adminPort;
     }
 
+    /**
+     * Returns the JMX's port value.
+     *
+     * @return The JMX's port value.
+     */
     public int getJMXPort() {
         return jmxPort;
     }
 
+    /**
+     * Sets the JMX port's value.
+     *
+     * @param jmxPort
+     *            The JMX port's value.
+     */
     public void setJMXPort(int jmxPort) {
         this.jmxPort = jmxPort;
     }
 
-    public boolean isJMXConnectionHandlerEnbled() {
-        return isJMXConnectionHandlerEnbled;
+    /**
+     * Returns {@code true} if the JMX connection handler is enabled.
+     *
+     * @return {@code true} if the JMX connection handler is enabled.
+     */
+    public boolean isJMXConnectionHandlerEnabled() {
+        return isJMXConnectionHandlerEnabled;
     }
 
-    public void setJMXConnectionHandlerEnbled(boolean isJMXConnectionHandlerEnbled) {
-        this.isJMXConnectionHandlerEnbled = isJMXConnectionHandlerEnbled;
+    /**
+     * Sets the status of the JMX connection handler.
+     *
+     * @param isJMXConnectionHandlerEnabled
+     *            true} if the JMX connection handler is enabled.
+     */
+    public void setJMXConnectionHandlerEnabled(boolean isJMXConnectionHandlerEnabled) {
+        this.isJMXConnectionHandlerEnabled = isJMXConnectionHandlerEnabled;
     }
 
+    /**
+     * Returns the value of the HTTP connection handler port.
+     *
+     * @return The value of the HTTP connection handler port.
+     */
     public int getHTTPPort() {
         return httpPort;
     }
 
+    /**
+     * Sets the value of the port which is going to be used bu the HTTP connection handler.
+     *
+     * @param httpPort
+     *            The value of the HTTP port.
+     */
     public void setHTTPPort(int httpPort) {
         this.httpPort = httpPort;
     }
 
+    /**
+     * Returns {@code true} if the HTTP connection handler is enabled.
+     *
+     * @return {@code true} if the HTTP connection handler is enabled.
+     */
     public boolean isHTTPConnectionHandlerEnabled() {
         return isHTTPConnectionHandlerEnabled;
     }
 
+    /**
+     * Sets the status of the HTTP connection handler.
+     *
+     * @param isHTTPConnectionHandlerEnabled
+     *            true} if the HTTP connection handler is enabled.
+     */
     public void setHTTPConnectionHandlerEnabled(boolean isHTTPConnectionHandlerEnabled) {
         this.isHTTPConnectionHandlerEnabled = isHTTPConnectionHandlerEnabled;
     }
 
+    /**
+     * Returns the value of the port used by SNMP.
+     *
+     * @return The value of the port used by SNMP.
+     */
     public int getSNMPPort() {
         return snmpPort;
     }
 
+    /**
+     * Sets the value of the port used by SNMP.
+     *
+     * @param snmpPort
+     *            The value of the port used by SNMP.
+     */
     public void setSNMPPort(int snmpPort) {
         this.snmpPort = snmpPort;
     }
 
+    /**
+     * Returns {@code true} if the SNMP connection handler is enabled.
+     *
+     * @return {@code true} if the SNMP connection handler is enabled. {@code false} otherwise.
+     */
     public boolean isSNMPConnectionHandlerEnabled() {
         return isSNMPConnectionHandlerEnabled;
     }
 
+    /**
+     * Sets the status of the HTTP connection handler.
+     *
+     * @param isSNMPConnectionHandlerEnabled
+     *            {@code true} if the HTTP connection handler is enabled.
+     */
     public void setSNMPConnectionHandlerEnabled(boolean isSNMPConnectionHandlerEnabled) {
         this.isSNMPConnectionHandlerEnabled = isSNMPConnectionHandlerEnabled;
     }
 
+    /**
+     * Returns the root user DN.
+     *
+     * @return The root user DN.
+     */
     public String getRootUserDN() {
         return rootUserDN;
     }
 
+    /**
+     * Sets the root user DN.
+     *
+     * @param rootUserDN
+     *            The root user DN.
+     */
     public void setRootUserDN(String rootUserDN) {
         this.rootUserDN = rootUserDN;
     }
 
+    /**
+     * Returns the password linked to this root user DN.
+     *
+     * @return The password linked to this root user DN.
+     */
     public String getPassword() {
         if (password == null) {
             return null;
@@ -167,50 +296,116 @@
         return String.valueOf(password);
     }
 
+    /**
+     * Sets the user root's password.
+     *
+     * @param password
+     *            The password to set to this user root DN.
+     */
     public void setPassword(String password) {
         this.password = password.toCharArray();
     }
 
+    /**
+     * The file containing the password for the initial root user for the directory server.
+     *
+     * @return The file containing the password for the initial root user.
+     */
     public File getPasswordFile() {
         return passwordFile;
     }
 
+    /**
+     * Sets the file containing the password for the initial root user for the directory server.
+     *
+     * @param pwdFile
+     *            The file containing the password for the initial root user for the directory server.
+     */
     public void setPasswordFile(File pwdFile) {
         this.passwordFile = pwdFile;
     }
 
+    /**
+     * Returns {@code true} is SSL is enabled.
+     *
+     * @return {@code true} is SSL is enabled, {@code false} otherwise.
+     */
     public boolean isSSLEnabled() {
         return isSSLEnabled;
     }
 
+    /**
+     * Sets a flag is SSL is enabled.
+     *
+     * @param isSSLEnabled
+     *            {@code true} is SSL is enabled, {@code false} otherwise.
+     */
     public void setSSLEnabled(boolean isSSLEnabled) {
         this.isSSLEnabled = isSSLEnabled;
     }
 
+    /**
+     * Returns {@code true} is TLS is enabled.
+     *
+     * @return {@code true} is TLS is enabled, {@code false} otherwise.
+     */
     public boolean isTLSEnabled() {
         return isTLSEnabled;
     }
 
+    /**
+     * Sets a flag is TLS is enabled.
+     *
+     * @param isTLSEnabled
+     *            {@code true} is TLS is enabled, {@code false} otherwise.
+     */
     public void setTLSEnabled(boolean isTLSEnabled) {
         this.isTLSEnabled = isTLSEnabled;
     }
 
+    /**
+     * Returns the port number which is used with SSL.
+     *
+     * @return The SSL port's number.
+     */
     public int getSSLPortNumber() {
         return sslPortNumber;
     }
 
+    /**
+     * Sets the SSL's port number.
+     *
+     * @param sslPortNumber
+     *            The port number which should be used with SSL.
+     */
     public void setSSLPortNumber(int sslPortNumber) {
         this.sslPortNumber = sslPortNumber;
     }
 
+    /**
+     * Returns the certificate linked to this setup.
+     *
+     * @return The certificate linked to this setup.
+     */
     public Certificate getCertificate() {
         return certificate;
     }
 
+    /**
+     * Sets the certificate used in this setup.
+     *
+     * @param certificate
+     *            The certificate used in this setup.
+     */
     public void setCertificate(Certificate certificate) {
         this.certificate = certificate;
     }
 
+    /**
+     * Returns the port number which is currently free.
+     * @param startPortNumber The port number to start with.
+     * @return The port number which is currently free.
+     */
     static int getFreeSocketPort(int startPortNumber) {
         return getFreeSocketPort(startPortNumber, new TestPortImpl());
     }
diff --git a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java
index 99a7420..e0578e9 100644
--- a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java
+++ b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/Model.java
@@ -32,7 +32,7 @@
 /**
  * This class provides configuration's model for the OpenDJ3 setup.
  */
-abstract class Model {
+public abstract class Model {
 
     /**
      * This enumeration is used to know what kind of server we want to set up.
@@ -122,14 +122,13 @@
     }
 
     /**
-     * Returns {@code true} if this configuration has a certificate linked to it.
-     * That generally means SSL and/or SSL are activated.
+     * Returns {@code true} if this configuration has a certificate linked to it. That generally means SSL and/or SSL
+     * are activated.
      *
      * @return {@code true} if this configuration has a certificate linked to it.
      */
     boolean isSecure() {
-        return (this.getListenerSettings() != null
-                && this.getListenerSettings().getCertificate() != null);
+        return (this.getListenerSettings() != null && this.getListenerSettings().getCertificate() != null);
     }
 
     /**
@@ -140,16 +139,14 @@
     }
 
     /**
-     * Sets the type of this server as : replication activated
-     * and this is the first server in topology.
+     * Sets the type of this server as : replication activated and this is the first server in topology.
      */
     void setFirstInTopology() {
         this.setType(Type.FIRST_IN_TOPOLOGY);
     }
 
     /**
-     * Sets the type of this server as : replication activated
-     * and this is a server in an existing topology.
+     * Sets the type of this server as : replication activated and this is a server in an existing topology.
      */
     void setInExistingTopology() {
         this.setType(Type.IN_EXISTING_TOPOLOGY);
@@ -193,68 +190,154 @@
         startingServerAfterSetup = startServerAfterSetup;
     }
 
+    /**
+     * Returns {@code true} if the directory server should start as a service.
+     *
+     * @return {@code true} if the directory server should start as a service, {@code false} otherwise.
+     */
     public boolean isService() {
         return isService;
     }
 
+    /**
+     * Sets the directory server as a service.
+     *
+     * @param isAService
+     *            {@code true} if the directory server should start as a service, {@code false} otherwise.
+     */
     public void setService(boolean isAService) {
         isService = isAService;
     }
 
+    /**
+     * Returns the instance path.
+     *
+     * @return The instance path where the binaries are installed.
+     */
     public String getInstancePath() {
         return instancePath;
     }
 
+    /**
+     * Sets the current instance path location.
+     *
+     * @param iPath
+     *            The instance path.
+     */
     public void setInstancePath(String iPath) {
         instancePath = iPath;
     }
 
+    /**
+     * Returns the license.
+     *
+     * @return The license.
+     */
     public String getLicense() {
         return license;
     }
 
+    /**
+     * Sets the license linked to this installation.
+     *
+     * @param theLicense
+     *            The license to set.
+     */
     public void setLicense(String theLicense) {
         license = theLicense;
     }
 
+    /**
+     * Returns the runtime options that apply to this installation.
+     *
+     * @return The runtime options that apply to this installation.
+     */
     public RuntimeOptions getServerRuntimeSettings() {
         return serverRuntimeSettings;
     }
 
+    /**
+     * Sets the runtime options that apply to this installation.
+     *
+     * @param settings
+     *            The runtime options that apply to this installation.
+     */
     public void setServerRuntimeOptions(RuntimeOptions settings) {
         serverRuntimeSettings = settings;
     }
 
+    /**
+     * Returns the runtime options that apply to the current import LDIF.
+     *
+     * @return The runtime options that apply to the current import LDIF.
+     */
     public RuntimeOptions getImportLdifRuntimeOptions() {
         return importLdifRuntimeSettings;
     }
 
+    /**
+     * Sets the runtime options that apply to the current import LDIF.
+     *
+     * @param settings
+     *            The runtime options that apply to the current import LDIF.
+     */
     public void setImportLdifRuntimeOptions(RuntimeOptions settings) {
         importLdifRuntimeSettings = settings;
     }
 
+    /**
+     * Returns the data configuration of this model.
+     *
+     * @return The data configuration of this model.
+     */
     public DataConfiguration getDataConfiguration() {
         return dataConfiguration;
     }
 
+    /**
+     * Sets the data configuration of this model.
+     *
+     * @param dConfiguration
+     *            The data configuration to set for this model.
+     */
     public void setDataConfiguration(DataConfiguration dConfiguration) {
         dataConfiguration = dConfiguration;
     }
 
+    /**
+     * Returns the replication configuration of this model.
+     *
+     * @return The replication configuration of this model.
+     */
     public ReplicationConfiguration getReplicationConfiguration() {
         return replicationConfiguration;
     }
 
+    /**
+     * Sets the replication configuration of this model.
+     *
+     * @param replicationConfiguration
+     *            The replication configuration to set for this model.
+     */
     public void setReplicationConfiguration(ReplicationConfiguration replicationConfiguration) {
         this.replicationConfiguration = replicationConfiguration;
     }
 
-
-
+    /**
+     * Returns the installation path of this model.
+     *
+     * @return The installation path of this model.
+     */
     public String getInstallationPath() {
         return installationPath;
     }
 
+    /**
+     * Sets the installation path of this model.
+     *
+     * @param installationPath
+     *            The installation path of this model.
+     */
     public void setInstallationPath(String installationPath) {
         this.installationPath = installationPath;
     }
@@ -262,8 +345,11 @@
     /**
      * Creates a basic data store model configuration for setup.
      */
-    static class DataStoreModel extends Model {
-        DataStoreModel() {
+    public static class DataStoreModel extends Model {
+        /**
+         * The default data store model.
+         */
+        public DataStoreModel() {
             setStandAloneDS();
             setDataConfiguration(new DataConfiguration());
             setListenerSettings(new ListenerSettings());
@@ -287,8 +373,7 @@
             if (isPartOfReplicationTopology()) {
                 Reject.ifNull(this.getReplicationConfiguration().getAdministrator(),
                         "Administrator name should not be null");
-                Reject.ifNull(this.getReplicationConfiguration().getPassword(),
-                        "Admin password should not be null");
+                Reject.ifNull(this.getReplicationConfiguration().getPassword(), "Admin password should not be null");
                 Reject.ifNull(this.getReplicationConfiguration().getGlobalAdministrator(),
                         "Global administrator should not be null");
                 Reject.ifNull(this.getReplicationConfiguration().getGlobalAdministratorPassword(),
@@ -296,8 +381,8 @@
                 if (getReplicationConfiguration().getSuffixes() == null
                         || getReplicationConfiguration().getSuffixes().size() == 0) {
                     throw new ConfigException(
-                            LocalizableMessage.raw(
-                                    "At least one base DN should be selected to replicate content with"));
+                            LocalizableMessage.raw("At least one base DN should be selected "
+                                    + "to replicate content with"));
                 }
             }
         }
diff --git a/opendj-server/src/test/java/org/forgerock/opendj/server/setup/cli/SetupCliTestCase.java b/opendj-server/src/test/java/org/forgerock/opendj/server/setup/cli/SetupCliTestCase.java
index 1a339b3..9af3166 100644
--- a/opendj-server/src/test/java/org/forgerock/opendj/server/setup/cli/SetupCliTestCase.java
+++ b/opendj-server/src/test/java/org/forgerock/opendj/server/setup/cli/SetupCliTestCase.java
@@ -58,6 +58,9 @@
                 "--adminConnectorPort", "4444",
                 "-D", "cn=Directory Manager", "-w", "password", "-b", "dc=example,dc=com",
                 "-a"), expectedErrOutput(LocalizableMessage.EMPTY) },
+            { args("--cli", "--doNotStart", "--ldapPort", "1389", "--adminConnectorPort", "4444",
+                    "-D", "cn=Directory Manager", "-w", "password", "-b", "dc=example,dc=com",
+                    "-a", "--ldapsPort", "1636", "--generateSelfSignedCertificate"), null },
         };
         return data;
     }
@@ -79,8 +82,13 @@
         Object[][] data = new Object[][] {
             { args("--cli", "--doNotStart", "--ldapPort", "1389", "--adminConnectorPort", "4444",
                     "-D", "cn=Directory Manager", "-w", "password", "-b", "dc=example,dc=com",
-                    "-a"),
-                null },
+                    "-a"), null },
+            { args("--cli", "--doNotStart", "--ldapPort", "1389", "--adminConnectorPort", "4444",
+                    "-D", "cn=Directory Manager", "-w", "password", "-b", "dc=example,dc=com",
+                    "-a", "--ldapsPort", "1636"), null },
+            { args("--cli", "--doNotStart", "--ldapPort", "1389", "--adminConnectorPort", "4444",
+                    "-D", "cn=Directory Manager", "-w", "password", "-b", "dc=example,dc=com",
+                    "-a", "--jmxPort", "1689"), null },
         };
         return data;
     }
@@ -158,10 +166,21 @@
                 assertThat(resultCode).isEqualTo(ReturnCode.SUCCESS.get());
             } else {
                 assertThat(resultCode).isNotEqualTo(ReturnCode.SUCCESS.get());
-                assertThat(err.size()).isGreaterThan(0);
-                final String errorMsg = err.toString("UTF-8").replaceAll(Utils.LINE_SEPARATOR, " ");
-                final String expectedMsg = expectedErrOutput.toString().replaceAll(Utils.LINE_SEPARATOR, " ");
-                assertTrue(errorMsg.contains(expectedMsg), errorMsg + "\n >---< \n" + expectedMsg);
+                String errMsg = null;
+                String expectedMsg = getUnWrappedMessage(expectedErrOutput.toString());
+                /**
+                 * If an application is interactive, all messages should be redirect to the stdout. (info, warnings,
+                 * errors). Otherwise, standard messages should be displayed in the stdout(info) and errors to the
+                 * stderr (warnings, errors).
+                 */
+                if (setup.isInteractive()) {
+                    assertThat(out.size()).isGreaterThan(0);
+                    errMsg = getUnWrappedMessage(out.toString("UTF-8"));
+                } else {
+                    assertThat(err.size()).isGreaterThan(0);
+                    errMsg = getUnWrappedMessage(err.toString("UTF-8"));
+                }
+                assertTrue(errMsg.contains(expectedMsg), errMsg + "\n >---< \n" + expectedMsg);
             }
         } finally {
             closeSilently(outStream, errStream);
@@ -177,4 +196,15 @@
     private LocalizableMessage expectedErrOutput(LocalizableMessage val) {
         return val;
     }
+
+    /**
+     * Returns the message to its unwrapped form.
+     *
+     * @param st
+     *            The message which need to be unwrapped.
+     * @return The unwrapped message.
+     */
+    private String getUnWrappedMessage(final String st) {
+        return st.replaceAll(Utils.LINE_SEPARATOR, " ");
+    }
 }
diff --git a/opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ListenerSettingsTestCase.java b/opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ListenerSettingsTestCase.java
index 7424572..cda9940 100644
--- a/opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ListenerSettingsTestCase.java
+++ b/opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ListenerSettingsTestCase.java
@@ -58,7 +58,7 @@
         assertFalse(dsSettings.isSSLEnabled());
         assertThat(dsSettings.getCertificate()).isNull();
         assertFalse(dsSettings.isTLSEnabled());
-        assertFalse(dsSettings.isJMXConnectionHandlerEnbled());
+        assertFalse(dsSettings.isJMXConnectionHandlerEnabled());
         assertFalse(dsSettings.isSNMPConnectionHandlerEnabled());
         assertTrue(dsSettings.isHTTPConnectionHandlerEnabled());
     }
diff --git a/opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ModelTestCase.java b/opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ModelTestCase.java
index 98996b1..4a26887 100644
--- a/opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ModelTestCase.java
+++ b/opendj-server/src/test/java/org/forgerock/opendj/server/setup/model/ModelTestCase.java
@@ -63,7 +63,7 @@
         assertTrue(dsSettings.isHTTPConnectionHandlerEnabled());
         assertFalse(dsSettings.isSSLEnabled());
         assertFalse(dsSettings.isTLSEnabled());
-        assertFalse(dsSettings.isJMXConnectionHandlerEnbled());
+        assertFalse(dsSettings.isJMXConnectionHandlerEnabled());
         ds.getListenerSettings().setPassword("password");
 
         // Verify ports

--
Gitblit v1.10.0