Search in sources :

Example 61 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class CLIUtilTest method getUploadFileTest.

@Test
public void getUploadFileTest() {
    BufferedWriter out = null;
    String fileName = null;
    try {
        final File f = File.createTempFile("TestPasswordFile", ".tmp");
        fileName = f.toString();
        f.deleteOnExit();
        out = new BufferedWriter(new FileWriter(f));
        out.write("AS_ADMIN_PASSWORD=adminadmin\n");
        out.write("AS_ADMIN_MASTERPASSWORD=changeit\n");
    } catch (IOException ioe) {
    } finally {
        try {
            if (out != null)
                out.close();
        } catch (final Exception ignore) {
        }
    }
    try {
        Map<String, String> po = CLIUtil.readPasswordFileOptions(fileName, false);
        assertEquals("admin password", "adminadmin", po.get("password"));
        assertEquals("master password", "changeit", po.get("masterpassword"));
        assertEquals("null", null, po.get("foobar"));
    } catch (CommandException ce) {
        ce.printStackTrace();
    }
}
Also used : FileWriter(java.io.FileWriter) IOException(java.io.IOException) CommandException(org.glassfish.api.admin.CommandException) File(java.io.File) CommandException(org.glassfish.api.admin.CommandException) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Aggregations

CommandException (org.glassfish.api.admin.CommandException)61 File (java.io.File)20 CommandValidationException (org.glassfish.api.admin.CommandValidationException)16 IOException (java.io.IOException)13 ParameterMap (org.glassfish.api.admin.ParameterMap)11 InvalidCommandException (org.glassfish.api.admin.InvalidCommandException)10 ActionReport (org.glassfish.api.ActionReport)9 ArrayList (java.util.ArrayList)6 RemoteCLICommand (com.sun.enterprise.admin.cli.remote.RemoteCLICommand)5 MiniXmlParserException (com.sun.enterprise.universal.xml.MiniXmlParserException)5 HostAndPort (com.sun.enterprise.util.HostAndPort)4 BackupException (com.sun.enterprise.backup.BackupException)3 BackupWarningException (com.sun.enterprise.backup.BackupWarningException)3 SmartFile (com.sun.enterprise.universal.io.SmartFile)3 FileNotFoundException (java.io.FileNotFoundException)3 UnknownHostException (java.net.UnknownHostException)3 Logger (java.util.logging.Logger)3 SFTPClient (org.glassfish.cluster.ssh.sftp.SFTPClient)3 CLIProcessExecutor (com.sun.enterprise.admin.cli.CLIProcessExecutor)2 PEDomainsManager (com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager)2