From: gyeongseok.seo Date: Wed, 26 Dec 2012 06:01:07 +0000 (+0900) Subject: [Title] CLI's logic change( add exit function, run/debug logic change ) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=091857e7fdce32664d52f5aef9ca5b6cdae248f3;p=sdk%2Ftools%2Fcli.git [Title] CLI's logic change( add exit function, run/debug logic change ) [Desc.] run/debug not include transfer and install logic [Issue] 7825 Change-Id: Ib7fdd4c77eed2e3708226d4349b2eaaeeefb70bd --- diff --git a/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java b/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java index e103724..b435368 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java @@ -583,7 +583,22 @@ AbstractLauncher { return getExecutionContext().getPrompter(); } - + + /** + * Terminates the currently running command line interface.

+ * The argument serves as a status code
+ * by convention, a nonzero status code indicates abnormal termination.
+ * This method calls the System.exit method. + * + * @param status exit status. + */ + protected + void + exit(int status) + { + System.exit( status ); + } + /** * Execute command * diff --git a/org.tizen.cli/src/org/tizen/cli/exec/ILaunchOptions.java b/org.tizen.cli/src/org/tizen/cli/exec/ILaunchOptions.java deleted file mode 100755 index db295ef..0000000 --- a/org.tizen.cli/src/org/tizen/cli/exec/ILaunchOptions.java +++ /dev/null @@ -1,142 +0,0 @@ -package org.tizen.cli.exec; - -public interface ILaunchOptions -{ - - /** - *

- * Description for target widget id - * - * This is printed out in usage - *

- * - * @see #OPT_WIDGETID - */ - String DESC_WIDGETID = "Command is performed of running widget kill in target, widget id is user written id in config.xml"; - - /** - *

- * Option for target widget file - *

- */ - String OPT_WIDGETFILE = "widget"; - - /** - *

- * Description for target widget file - * - * This is printed out in usage - *

- * - * @see #OPT_WIDGETFILE - */ - String DESC_WIDGETFILE = "Command is performed of widget file install in target"; - - /** - *

- * Option for target widget id - *

- */ - String OPT_WIDGETID = "id"; - - /** - *

- * Option for project name - *

- */ - String OPT_NAME = "name"; - - /** - *

- * Description for project name - * - * This is printed out in usage - *

- * - * @see #OPT_WIDGETFILE - */ - String DESC_NAME = "generation project name"; - - /** - *

- * Option for project name - *

- */ - String OPT_PATH = "path"; - - /** - *

- * Description for project name - * - * This is printed out in usage - *

- * - * @see #OPT_WIDGETFILE - */ - String DESC_PATH = "generation project path"; - - - /** - *

- * Option for include file pattern - *

- */ - String OPT_INCLUDE = "include"; - - /** - *

- * Description for include file pattern option - * - * It is printed out in usage - *

- */ - String DESC_INCLUDE = "file name pattern to include"; - - /** - *

- * Option for exclude file pattern - *

- */ - String OPT_EXCLUDE = "exclude"; - - /** - *

- * Description for exclude file pattern option - * - * It is printed out in usage - *

- */ - String DESC_EXCLUDE = "file name pattern to exclude"; - - /** - *

- * Option for no check of validation - *

- */ - String OPT_NOCHECK = "nocheck"; - - /** - *

- * Description for no check option - * - * It is printed out in usage - *

- */ - String DESC_NOCHECK = "skip validation check"; - - /** - *

- * Option for over-writing of output file - *

- */ - String OPT_OVERWRITE = "overwrite"; - - /** - *

- * Description for overwrite option - * - * It is printed out in usage - *

- */ - String DESC_OVERWRITE = "overwrite output file if it exists"; -} diff --git a/org.tizen.cli/src/org/tizen/cli/exec/LaunchOptionConstants.java b/org.tizen.cli/src/org/tizen/cli/exec/LaunchOptionConstants.java new file mode 100755 index 0000000..eae722c --- /dev/null +++ b/org.tizen.cli/src/org/tizen/cli/exec/LaunchOptionConstants.java @@ -0,0 +1,180 @@ +package org.tizen.cli.exec; + +public class LaunchOptionConstants +{ + private LaunchOptionConstants() {} + + /** + *

+ *Description for failed operation + * + * This is printed when widget ID is empty + *

+ */ + public static final String DESC_FAILED_CANNOT_FIND_WIDGET_ID = "can't find application ID"; + + /** + *

+ *Description for failed operation + * + * This is printed when device is not connected + *

+ */ + public static final String DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE = "can't find connected device"; + + /** + *

+ *Description for failed operation + * + * This is printed when device is not connected + *

+ */ + public static final String DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE = "can't find selected device"; + + /** + *

+ *Description for failed operation + * + * This is printed when mode setting operation failed + *

+ */ + public static final String DESC_FAILED_MODE_SETTING = "development mode setting failed"; + + + /** + *

+ * Description for target widget id + * + * This is printed out in usage + *

+ * + * @see #OPT_WIDGETID + */ + public static final String DESC_WIDGETID = "Command is performed of running widget kill in target, widget id is user written id in config.xml"; + + /** + *

+ * Option for target widget file + *

+ */ + public static final String OPT_WIDGETFILE = "widget"; + + /** + *

+ * Description for target widget file + * + * This is printed out in usage + *

+ * + * @see #OPT_WIDGETFILE + */ + public static final String DESC_WIDGETFILE = "Command is performed of widget file install in target"; + + /** + *

+ * Option for target widget id + *

+ */ + public static final String OPT_WIDGETID = "id"; + + /** + *

+ * Option for project name + *

+ */ + public static final String OPT_NAME = "name"; + + /** + *

+ * Description for project name + * + * This is printed out in usage + *

+ * + * @see #OPT_WIDGETFILE + */ + public static final String DESC_NAME = "generation project name"; + + /** + *

+ * Option for project name + *

+ */ + public static final String OPT_PATH = "path"; + + /** + *

+ * Description for project name + * + * This is printed out in usage + *

+ * + * @see #OPT_WIDGETFILE + */ + public static final String DESC_PATH = "generation project path"; + + + /** + *

+ * Option for include file pattern + *

+ */ + public static final String OPT_INCLUDE = "include"; + + /** + *

+ * Description for include file pattern option + * + * It is printed out in usage + *

+ */ + public static final String DESC_INCLUDE = "file name pattern to include"; + + /** + *

+ * Option for exclude file pattern + *

+ */ + public static final String OPT_EXCLUDE = "exclude"; + + /** + *

+ * Description for exclude file pattern option + * + * It is printed out in usage + *

+ */ + public static final String DESC_EXCLUDE = "file name pattern to exclude"; + + /** + *

+ * Option for no check of validation + *

+ */ + public static final String OPT_NOCHECK = "nocheck"; + + /** + *

+ * Description for no check option + * + * It is printed out in usage + *

+ */ + public static final String DESC_NOCHECK = "skip validation check"; + + /** + *

+ * Option for over-writing of output file + *

+ */ + public static final String OPT_OVERWRITE = "overwrite"; + + /** + *

+ * Description for overwrite option + * + * It is printed out in usage + *

+ */ + public static final String DESC_OVERWRITE = "overwrite output file if it exists"; +} diff --git a/org.tizen.cli/src/org/tizen/cli/exec/WRTLauncher.java b/org.tizen.cli/src/org/tizen/cli/exec/WRTLauncher.java index 4701384..d63145e 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/WRTLauncher.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/WRTLauncher.java @@ -185,6 +185,27 @@ extends AbstractLauncher SmartDevelopmentBridge.getBridge().terminate(); } + /** + * Terminates the currently running command line interface.

+ * The argument serves as a status code, by convention, a nonzero status code indicates abnormal termination.
+ * Before the exit, this method terminate SDB bridge. + * This method calls the System.exit method. + * + * @param status exit status. + */ + @Override + protected void exit(int status) { + endSDB(); + super.exit(status); + } + + protected String getDeviceNotConnectedMessage() { + return "Device is not connected. Process is canceled."; + } + protected String getDeviceNotSelectedMessage() { + return "Process is stoped, please select connect device."; + } + /* (non-Javadoc) * @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine) */ @@ -206,9 +227,8 @@ extends AbstractLauncher logger.trace("check connected devices"); if ( !deviceSelector.isDeviceConnected() ) { - prompter.notify( "Device is not connected. Process is canceled." ); - endSDB(); - return ; + prompter.notify( getDeviceNotConnectedMessage() ); + exit( 1 ); } String deviceName = cmdLine.getOptionValue( OPT_DEVICE ); @@ -217,7 +237,8 @@ extends AbstractLauncher if ( !StringUtil.isEmpty( deviceName ) ) { setDevice( deviceSelector.getDevice( deviceName ) ); if ( getDevice() == null ) { - prompter.notify( "Process is stoped, please select connect device." ); + prompter.notify( getDeviceNotSelectedMessage() ); + exit( 1 ); } } else { // user not using device select option diff --git a/org.tizen.cli/src/org/tizen/cli/exec/debug/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/debug/Main.java index c80aa05..757e3d4 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/debug/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/debug/Main.java @@ -25,21 +25,22 @@ */ package org.tizen.cli.exec.debug; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETID; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_MODE_SETTING; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_WIDGETID; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_WIDGET_ID; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; -import org.tizen.cli.exec.ILaunchOptions; import org.tizen.cli.exec.WRTLauncher; import org.tizen.common.core.command.Executor; import org.tizen.common.core.command.Prompter; -import org.tizen.common.core.command.sdb.PushSdbCommand; -import org.tizen.common.file.FileHandler; -import org.tizen.common.file.FileHandler.Attribute; -import org.tizen.common.util.FilenameUtil; import org.tizen.common.util.StringUtil; import org.tizen.web.zimlaunch.cli.command.CheckInstallCommand; import org.tizen.web.zimlaunch.cli.command.DebugCommand; -import org.tizen.web.zimlaunch.cli.command.InstallCommand; import org.tizen.web.zimlaunch.cli.command.KillCommand; import org.tizen.web.zimlaunch.cli.command.ModeCommnad; @@ -52,19 +53,8 @@ import org.tizen.web.zimlaunch.cli.command.ModeCommnad; public class Main extends WRTLauncher -implements ILaunchOptions { - - /** - *

- * Description for target widget id - * - * This is printed out in usage - *

- * - * @see #OPT_WIDGETID - */ - protected static final String DESC_WIDGETID = "Command is performed of widget id uninstall in target, widget id is user written id in config.xml"; + protected String FAILED_LAUNCH = "Failed to launch: "; /** * Entry point for cli main @@ -98,88 +88,58 @@ implements ILaunchOptions super.execute( cmdLine ); final Prompter prompter = getPrompter(); - final FileHandler fileHandler = getFileHandler(); final Executor exec = getExecutor(); - // device not connect then exit - if ( getDevice() == null ) { - endSDB(); - return ; - } - - // local widget file path control - String inputName = cmdLine.getOptionValue( OPT_WIDGETFILE ); - logger.trace("input file name : {} ", inputName); - if ( StringUtil.isEmpty( inputName ) ) { - prompter.notify( "Widget file is not selected." ); - printHelp(); - endSDB(); - } + // get widget AppID + logger.trace( "application id value input check" ); String widgetId = cmdLine.getOptionValue( OPT_WIDGETID ); + if ( StringUtil.isEmpty( widgetId ) ) { + prompter.error( FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_WIDGET_ID ); + exit( 1 ); + } - String filePath = (String)fileHandler.get( inputName, Attribute.PATH ); - logger.trace( "local widget file path : {}", filePath ); - - String fileName = FilenameUtil.getFilename( inputName ); - logger.trace( "local widget file name : {}", fileName ); - - // core operation - InstallCommand install_command = new InstallCommand(); - install_command.setWidget( fileName ); - install_command.setDevice( getDevice() ); - install_command.setTime( getTime() ); - install_command.setPrintOption( false ); - String remotePath = install_command.getRemotePath() + fileName; - logger.trace( "remote widget file path : {}", remotePath ); - - PushSdbCommand push_command = new PushSdbCommand( filePath, remotePath ); - push_command.setDevice( getDevice() ); - + // mode command ModeCommnad mode_command = new ModeCommnad(); mode_command.setDevice( getDevice() ); mode_command.setTime( getTime() ); - - // widget push - logger.trace( "push command"); - exec.execute( push_command ); - if ( "failed".equals( push_command.getResult() ) ) { - endSDB(); - } + mode_command.setPrintOption( false ); // widget mode logger.trace( "mode command"); exec.execute( mode_command ); - if ( mode_command.getResult().contains( "failed" ) ) { - endSDB(); + if ( mode_command.getResult().contains( "Failed" ) ) { + prompter.error( FAILED_LAUNCH + DESC_FAILED_MODE_SETTING ); + exit( 1 ); } - if ( !StringUtil.isEmpty( widgetId ) ) { - logger.trace( "same widget's pre-install check and kill process" ); - CheckInstallCommand check_install_cmd = new CheckInstallCommand( widgetId ); - check_install_cmd.setDevice( getDevice() ); - check_install_cmd.setTime( getTime() ); - check_install_cmd.setPrintOption( false ); - exec.execute( check_install_cmd ); - if ( check_install_cmd.isInstalled() ) { - KillCommand kill_cmd = new KillCommand( widgetId ); - kill_cmd.setPrintOption( false ); - kill_cmd.setDevice( getDevice() ); - kill_cmd.setTime( getTime() ); - exec.execute( kill_cmd ); - } + // already run check and kill + logger.trace( "same widget's pre-install check and kill process" ); + CheckInstallCommand check_install_cmd = new CheckInstallCommand( widgetId ); + check_install_cmd.setDevice( getDevice() ); + check_install_cmd.setTime( getTime() ); + check_install_cmd.setPrintOption( false ); + exec.execute( check_install_cmd ); + if ( check_install_cmd.isInstalled() ) { + KillCommand kill_cmd = new KillCommand( widgetId ); + kill_cmd.setPrintOption( false ); + kill_cmd.setDevice( getDevice() ); + kill_cmd.setTime( getTime() ); + exec.execute( kill_cmd ); } - // widget install - logger.trace( "install command"); - exec.execute( install_command ); - // widget debug run DebugCommand run_command = new DebugCommand( widgetId ); run_command.setDevice( getDevice() ); run_command.setTime( getTime() ); + run_command.setPrintOption( false ); exec.execute( run_command ); - endSDB(); + prompter.notify( run_command.getResult() ); + if ( run_command.getResult().contains( "failed" ) ) { + exit( 1 ); + } else { + exit( 0 ); + } } /* (non-Javadoc) @@ -192,9 +152,24 @@ implements ILaunchOptions getOptions() { final Options opts = super.getOptions(); - opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETFILE ).withDescription( DESC_WIDGETFILE ).create( OPT_WIDGETFILE.substring( 0, 1 ) ) ); opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETID ).withDescription( DESC_WIDGETID ).create( OPT_WIDGETID.substring( 0, 1 ) ) ); return opts; } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage() + */ + @Override + protected String getDeviceNotConnectedMessage() { + return FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; + } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage() + */ + @Override + protected String getDeviceNotSelectedMessage() { + return FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; + } } diff --git a/org.tizen.cli/src/org/tizen/cli/exec/gen/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/gen/Main.java index 2a126cc..60a8e7b 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/gen/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/gen/Main.java @@ -29,11 +29,15 @@ package org.tizen.cli.exec.gen; import java.text.MessageFormat; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_NAME; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_PATH; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_NAME; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_PATH; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.tizen.cli.exec.AbstractLauncher; -import org.tizen.cli.exec.ILaunchOptions; import org.tizen.common.core.command.Prompter; import org.tizen.common.core.command.prompter.ChoiceOption; import org.tizen.common.core.command.prompter.Option; @@ -51,7 +55,6 @@ import org.tizen.web.project.wizard.cli.command.ProjectGenCommand; public class Main extends AbstractLauncher -implements ILaunchOptions { diff --git a/org.tizen.cli/src/org/tizen/cli/exec/gen/NativeMain.java b/org.tizen.cli/src/org/tizen/cli/exec/gen/NativeMain.java index c97236f..6ff78fd 100644 --- a/org.tizen.cli/src/org/tizen/cli/exec/gen/NativeMain.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/gen/NativeMain.java @@ -34,7 +34,6 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.tizen.cli.exec.AbstractLauncher; -import org.tizen.cli.exec.ILaunchOptions; import org.tizen.common.core.application.InstallPathConfig; import org.tizen.common.core.command.Prompter; import org.tizen.common.core.command.prompter.ChoiceOption; @@ -45,7 +44,7 @@ import org.tizen.nativecommon.templateengine.TizenTemplateEngine; import org.tizen.nativecommon.templateengine.TizenTemplateEngine.WizardMode; import org.tizen.nativecommon.templateengine.model.TizenTemplate; -public class NativeMain extends AbstractLauncher implements ILaunchOptions{ +public class NativeMain extends AbstractLauncher { private static final String OPTION_PROJECTPATH = "path"; private static final String OPTION_PROJECTNAME = "name"; diff --git a/org.tizen.cli/src/org/tizen/cli/exec/install/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/install/Main.java index 3a17271..e7efd5b 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/install/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/install/Main.java @@ -29,7 +29,13 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; -import org.tizen.cli.exec.ILaunchOptions; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETFILE; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETID; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_WIDGETID; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_WIDGETFILE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; + import org.tizen.cli.exec.WRTLauncher; import org.tizen.common.core.command.Executor; import org.tizen.common.core.command.Prompter; @@ -52,19 +58,17 @@ import org.tizen.web.zimlaunch.cli.command.ModeCommnad; public class Main extends WRTLauncher -implements ILaunchOptions { + protected String FAILED_INSTALL = "Failed to install: "; /** *

- * Description for target widget id + *Description for failed operation * - * This is printed out in usage + * This is printed when device is not connected *

- * - * @see #OPT_WIDGETID */ - protected static final String DESC_WIDGETID = "Command is performed of running widget kill in target, widget id is user written id in config.xml"; + String DESC_FAILED_CANNOT_FIND_SELECTED_WIDGET = "can't find selected widget file"; /** * Entry point for cli main @@ -101,19 +105,12 @@ implements ILaunchOptions final FileHandler fileHandler = getFileHandler(); final Executor exec = getExecutor(); - // device not connect then exit - if ( getDevice() == null ) { - endSDB(); - return ; - } - // local widget file path control String inputName = cmdLine.getOptionValue( OPT_WIDGETFILE ); logger.trace("input file name : {} ", inputName); if ( StringUtil.isEmpty( inputName ) ) { - prompter.notify( "Widget file is not selected." ); - printHelp(); - endSDB(); + prompter.notify( FAILED_INSTALL + DESC_FAILED_CANNOT_FIND_SELECTED_WIDGET ); + exit( 1 ); } String widgetId = cmdLine.getOptionValue( OPT_WIDGETID ); @@ -141,15 +138,15 @@ implements ILaunchOptions // widget push logger.trace( "push command"); exec.execute( push_command ); - if ( "failed".equals( push_command.getResult() ) ) { - endSDB(); + if ( "Failed".equals( push_command.getResult() ) ) { + exit ( 1 ); } // widget mode logger.trace( "mode command"); exec.execute( mode_command ); - if ( mode_command.getResult().contains( "failed" ) ) { - endSDB(); + if ( mode_command.getResult().contains( "Failed" ) ) { + exit ( 1 ); } if ( !StringUtil.isEmpty( widgetId ) ) { @@ -172,7 +169,7 @@ implements ILaunchOptions logger.trace( "install command"); exec.execute( install_command ); - endSDB(); + exit( 0 ); } /* (non-Javadoc) @@ -190,4 +187,20 @@ implements ILaunchOptions return opts; } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage() + */ + @Override + protected String getDeviceNotConnectedMessage() { + return FAILED_INSTALL + DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; + } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage() + */ + @Override + protected String getDeviceNotSelectedMessage() { + return FAILED_INSTALL + DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; + } } diff --git a/org.tizen.cli/src/org/tizen/cli/exec/query/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/query/Main.java index 40866e6..c06de54 100644 --- a/org.tizen.cli/src/org/tizen/cli/exec/query/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/query/Main.java @@ -27,6 +27,9 @@ package org.tizen.cli.exec.query; import org.apache.commons.cli.CommandLine; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; + import org.tizen.cli.exec.WRTLauncher; import org.tizen.web.zimlaunch.cli.command.QueryCommand; @@ -40,6 +43,8 @@ public class Main extends WRTLauncher { + protected String FAILED_FIND_LIST = "Failed to find list: "; + /** * Entry point for cli main * @@ -73,8 +78,7 @@ extends WRTLauncher // device not connect then exit if ( getDevice() == null ) { - endSDB(); - return ; + exit( 1 ); } // core operation @@ -83,6 +87,22 @@ extends WRTLauncher command.setTime( getTime() ); getExecutor().execute( command ); - endSDB(); + exit( 0 ); + } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage() + */ + @Override + protected String getDeviceNotConnectedMessage() { + return FAILED_FIND_LIST + DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; + } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage() + */ + @Override + protected String getDeviceNotSelectedMessage() { + return FAILED_FIND_LIST + DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; } } diff --git a/org.tizen.cli/src/org/tizen/cli/exec/run/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/run/Main.java index 9802526..f483215 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/run/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/run/Main.java @@ -28,17 +28,19 @@ package org.tizen.cli.exec.run; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; -import org.tizen.cli.exec.ILaunchOptions; + +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETID; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_WIDGETID; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_MODE_SETTING; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_WIDGET_ID; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; + import org.tizen.cli.exec.WRTLauncher; import org.tizen.common.core.command.Executor; import org.tizen.common.core.command.Prompter; -import org.tizen.common.core.command.sdb.PushSdbCommand; -import org.tizen.common.file.FileHandler; -import org.tizen.common.file.FileHandler.Attribute; -import org.tizen.common.util.FilenameUtil; import org.tizen.common.util.StringUtil; import org.tizen.web.zimlaunch.cli.command.CheckInstallCommand; -import org.tizen.web.zimlaunch.cli.command.InstallCommand; import org.tizen.web.zimlaunch.cli.command.KillCommand; import org.tizen.web.zimlaunch.cli.command.ModeCommnad; import org.tizen.web.zimlaunch.cli.command.RunCommand; @@ -52,18 +54,8 @@ import org.tizen.web.zimlaunch.cli.command.RunCommand; public class Main extends WRTLauncher -implements ILaunchOptions { - /** - *

- * Description for target widget id - * - * This is printed out in usage - *

- * - * @see #OPT_WIDGETID - */ - protected static final String DESC_WIDGETID = "Command is performed of widget id uninstall in target, widget id is user written id in config.xml"; + protected String FAILED_LAUNCH = "Failed to launch: "; /** * Entry point for cli main @@ -97,61 +89,31 @@ implements ILaunchOptions super.execute( cmdLine ); final Prompter prompter = getPrompter(); - final FileHandler fileHandler = getFileHandler(); final Executor exec = getExecutor(); - // device not connect then exit - if ( getDevice() == null ) { - endSDB(); - return ; - } - - // local widget file path control - String inputName = cmdLine.getOptionValue( OPT_WIDGETFILE ); - logger.trace("input file name : {} ", inputName); - if ( StringUtil.isEmpty( inputName ) ) { - prompter.notify( "Widget file is not selected." ); - printHelp(); - endSDB(); - } + // get widget AppID + logger.trace( "application id value input check" ); String widgetId = cmdLine.getOptionValue( OPT_WIDGETID ); + if ( StringUtil.isEmpty( widgetId ) ) { + prompter.error( FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_WIDGET_ID ); + exit( 1 ); + } - String filePath = (String)fileHandler.get( inputName, Attribute.PATH ); - logger.trace( "local widget file path : {}", filePath ); - - String fileName = FilenameUtil.getFilename( inputName ); - logger.trace( "local widget file name : {}", fileName ); - - // core operation - InstallCommand install_command = new InstallCommand(); - install_command.setWidget( fileName ); - install_command.setDevice( getDevice() ); - install_command.setTime( getTime() ); - install_command.setPrintOption( false ); - String remotePath = install_command.getRemotePath() + fileName; - logger.trace( "remote widget file path : {}", remotePath ); - - PushSdbCommand push_command = new PushSdbCommand( filePath, remotePath ); - push_command.setDevice( getDevice() ); - + // mode command ModeCommnad mode_command = new ModeCommnad(); mode_command.setDevice( getDevice() ); mode_command.setTime( getTime() ); - - // widget push - logger.trace( "push command"); - exec.execute( push_command ); - if ( "failed".equals( push_command.getResult() ) ) { - endSDB(); - } + mode_command.setPrintOption( false ); // widget mode logger.trace( "mode command"); exec.execute( mode_command ); if ( mode_command.getResult().contains( "failed" ) ) { - endSDB(); + prompter.error( FAILED_LAUNCH + DESC_FAILED_MODE_SETTING ); + exit( 1 ); } + // already run check and kill if ( !StringUtil.isEmpty( widgetId ) ) { logger.trace( "same widget's pre-install check and kill process" ); CheckInstallCommand check_install_cmd = new CheckInstallCommand( widgetId ); @@ -168,17 +130,19 @@ implements ILaunchOptions } } - // widget install - logger.trace( "install command"); - exec.execute( install_command ); - // widget run RunCommand run_command = new RunCommand( widgetId ); run_command.setDevice( getDevice() ); run_command.setTime( getTime() ); + run_command.setPrintOption( false ); exec.execute( run_command ); - endSDB(); + prompter.notify( run_command.getResult() ); + if ( run_command.getResult().contains( "failed" ) ) { + exit( 1 ); + } else { + exit( 0 ); + } } /* (non-Javadoc) @@ -191,9 +155,24 @@ implements ILaunchOptions getOptions() { final Options opts = super.getOptions(); - opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETFILE ).withDescription( DESC_WIDGETFILE ).create( OPT_WIDGETFILE.substring( 0, 1 ) ) ); opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETID ).withDescription( DESC_WIDGETID ).create( OPT_WIDGETID.substring( 0, 1 ) ) ); return opts; } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage() + */ + @Override + protected String getDeviceNotConnectedMessage() { + return FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; + } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage() + */ + @Override + protected String getDeviceNotSelectedMessage() { + return FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; + } } diff --git a/org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java index d465f89..50d7d1d 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java @@ -35,8 +35,15 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; + +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_NOCHECK; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_NOCHECK; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_INCLUDE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_INCLUDE; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_EXCLUDE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_EXCLUDE; + import org.tizen.cli.exec.AbstractLauncher; -import org.tizen.cli.exec.ILaunchOptions; import org.tizen.common.core.command.Prompter; import org.tizen.common.core.command.prompter.ChoiceOption; import org.tizen.common.core.command.prompter.Option; @@ -56,7 +63,6 @@ import org.tizen.web.sign.command.SignCommand; public class Main extends AbstractLauncher -implements ILaunchOptions { /** diff --git a/org.tizen.cli/src/org/tizen/cli/exec/template/ClientMain.java b/org.tizen.cli/src/org/tizen/cli/exec/template/ClientMain.java index feccf85..b8abcbf 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/template/ClientMain.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/template/ClientMain.java @@ -37,7 +37,6 @@ import org.tizen.cli.command.CreateTemplate; import org.tizen.cli.command.PluginConstants; import org.tizen.cli.command.SearchTemplate; import org.tizen.cli.exec.AbstractLauncher; -import org.tizen.cli.exec.ILaunchOptions; import org.tizen.cli.util.TemplateModelProvider; import org.tizen.common.config.Preference; import org.tizen.common.verrari.Realm; @@ -52,7 +51,6 @@ import org.tizen.common.verrari.TemplateContext; public class ClientMain extends AbstractLauncher -implements ILaunchOptions { protected static final String OPT_REALM = "realm"; diff --git a/org.tizen.cli/src/org/tizen/cli/exec/uninstall/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/uninstall/Main.java index caa9a04..2a31bae 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/uninstall/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/uninstall/Main.java @@ -27,10 +27,13 @@ package org.tizen.cli.exec.uninstall; import java.text.MessageFormat; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETID; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; -import org.tizen.cli.exec.ILaunchOptions; import org.tizen.cli.exec.WRTLauncher; import org.tizen.common.core.command.Executor; import org.tizen.common.core.command.Prompter; @@ -47,8 +50,9 @@ import org.tizen.web.zimlaunch.cli.command.UninstallCommand; public class Main extends WRTLauncher -implements ILaunchOptions { + protected String FAILED_UNINSTALL = "Failed to uninstall: "; + /** *

* Description for target widget id @@ -94,12 +98,6 @@ implements ILaunchOptions final Prompter prompter = getPrompter(); final Executor exec = getExecutor(); - // device not connect then exit - if ( getDevice() == null ) { - endSDB(); - return ; - } - // core operation String widgetID = cmdLine.getOptionValue( OPT_WIDGETID ); @@ -113,8 +111,7 @@ implements ILaunchOptions prompter.notify( MessageFormat.format( "Uninstall failed, ''{0}'' widget is not installed.", widgetID ) ); - endSDB(); - return ; + exit( 1 ); } // kill @@ -129,7 +126,7 @@ implements ILaunchOptions uninstall_command.setTime( getTime() ); exec.execute( uninstall_command ); - endSDB(); + exit( 0 ); } /* (non-Javadoc) @@ -146,4 +143,20 @@ implements ILaunchOptions return opts; } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage() + */ + @Override + protected String getDeviceNotConnectedMessage() { + return FAILED_UNINSTALL+ DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE; + } + + /* (non-Javadoc) + * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage() + */ + @Override + protected String getDeviceNotSelectedMessage() { + return FAILED_UNINSTALL+ DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE; + } } diff --git a/org.tizen.cli/src/org/tizen/cli/exec/wgt/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/wgt/Main.java index e771df9..8275641 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/wgt/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/wgt/Main.java @@ -32,8 +32,18 @@ import java.util.List; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; + +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_NOCHECK; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_NOCHECK; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_INCLUDE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_INCLUDE; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_EXCLUDE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_EXCLUDE; +import static org.tizen.cli.exec.LaunchOptionConstants.OPT_OVERWRITE; +import static org.tizen.cli.exec.LaunchOptionConstants.DESC_OVERWRITE; + import org.tizen.cli.exec.AbstractLauncher; -import org.tizen.cli.exec.ILaunchOptions; +import org.tizen.cli.exec.LaunchOptionConstants; import org.tizen.common.core.command.Executor; import org.tizen.common.core.command.Prompter; import org.tizen.common.core.command.prompter.ChoiceOption; @@ -53,7 +63,6 @@ import org.tizen.web.common.WebConstant; public class Main extends AbstractLauncher -implements ILaunchOptions { diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/debug/MainTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/debug/MainTest.java index 4b0e2a9..d1c74ce 100644 --- a/org.tizen.cli/test/src/org/tizen/cli/exec/debug/MainTest.java +++ b/org.tizen.cli/test/src/org/tizen/cli/exec/debug/MainTest.java @@ -29,6 +29,8 @@ import static org.junit.Assert.*; import java.util.concurrent.atomic.AtomicBoolean; +import static org.tizen.cli.exec.LaunchOptionConstants.*; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; @@ -72,15 +74,15 @@ extends AbstractMainTest final PosixParser parser = new PosixParser(); parser.parse( opts, new String[] { - "-help", "-quiet", "-device", "deviceName", "-widget", "test.wgt", "-id", "http://test.com" + "-help", "-quiet", "-device", "deviceName", "-id", "http://test.com" } ); parser.parse( opts, new String[] { - "--help", "--quiet", "--device", "deviceName", "--widget", "test.wgt", "--id", "http://test.com" + "--help", "--quiet", "--device", "deviceName", "--id", "http://test.com" } ); parser.parse( opts, new String[] { - "-h", "-q", "-d", "deviceName", "-w", "test.wgt", "-i", "http://test.com" + "-h", "-q", "-d", "deviceName", "-i", "http://test.com" } ); try { @@ -94,31 +96,22 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { - "--log=trace", "--device", "TestDevice", "--id", "http://test.com", "--widget", "test.wgt" + "--log=trace", "--device", "TestDevice", "--id", "http://test.com" } ); - final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID ); + final String[] args1 = cmd.getOptionValues( OPT_WIDGETID ); assertEquals( 1, args1.length ); assertEquals( "http://test.com", args1[0] ); final String[] shortArgs1 = cmd.getOptionValues( "i" ); assertEquals( 1, shortArgs1.length ); assertEquals( "http://test.com", shortArgs1[0] ); - - final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE ); - assertEquals( 1, args2.length ); - assertEquals( "test.wgt", args2[0] ); - final String[] shortArgs2 = cmd.getOptionValues( "w" ); - assertEquals( 1, shortArgs2.length ); - assertEquals( "test.wgt", shortArgs2[0] ); } { final CommandLine cmd = parser.parse( opts, new String[] { - "--log=debug", "-i", "http://test.com", "-w", "test.wgt" + "--log=debug", "-i", "http://test.com" } ); - final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID ); + final String[] args1 = cmd.getOptionValues( OPT_WIDGETID ); assertNotNull( args1 ); - final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE ); - assertNotNull( args2 ); } } @@ -148,7 +141,7 @@ extends AbstractMainTest } }; - testClass.run( "-d", "TestDevice", "-i", "http://test.com", "-w", "test.wgt" ); + testClass.run( "-d", "TestDevice", "-i", "http://test.com" ); assertTrue( result.get() ); } } diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/gen/MainTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/gen/MainTest.java index 2e06bdb..ab629cc 100644 --- a/org.tizen.cli/test/src/org/tizen/cli/exec/gen/MainTest.java +++ b/org.tizen.cli/test/src/org/tizen/cli/exec/gen/MainTest.java @@ -29,6 +29,8 @@ import static org.junit.Assert.*; import java.util.concurrent.atomic.AtomicBoolean; +import static org.tizen.cli.exec.LaunchOptionConstants.*; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; @@ -95,14 +97,14 @@ extends AbstractMainTest final CommandLine cmd = parser.parse( opts, new String[] { "--log=trace", "--name", "myproject", "--path", "/home/myproject" } ); - final String[] args1 = cmd.getOptionValues( Main.OPT_NAME ); + final String[] args1 = cmd.getOptionValues( OPT_NAME ); assertEquals( 1, args1.length ); assertEquals( "myproject", args1[0] ); final String[] shortArgs1 = cmd.getOptionValues( "n" ); assertEquals( 1, shortArgs1.length ); assertEquals( "myproject", shortArgs1[0] ); - final String[] args2 = cmd.getOptionValues( Main.OPT_PATH ); + final String[] args2 = cmd.getOptionValues( OPT_PATH ); assertEquals( 1, args2.length ); assertEquals( "/home/myproject", args2[0] ); final String[] shortArgs2 = cmd.getOptionValues( "p" ); @@ -114,9 +116,9 @@ extends AbstractMainTest final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-n", "myproject", "-p", "/home/myproject" } ); - final String[] args1 = cmd.getOptionValues( Main.OPT_NAME ); + final String[] args1 = cmd.getOptionValues( OPT_NAME ); assertNotNull( args1 ); - final String[] args2 = cmd.getOptionValues( Main.OPT_PATH ); + final String[] args2 = cmd.getOptionValues( OPT_PATH ); assertNotNull( args2 ); } } diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/install/MainTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/install/MainTest.java index 46155f6..0f9a271 100644 --- a/org.tizen.cli/test/src/org/tizen/cli/exec/install/MainTest.java +++ b/org.tizen.cli/test/src/org/tizen/cli/exec/install/MainTest.java @@ -29,6 +29,8 @@ import static org.junit.Assert.*; import java.util.concurrent.atomic.AtomicBoolean; +import static org.tizen.cli.exec.LaunchOptionConstants.*; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; @@ -37,6 +39,7 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.tizen.cli.exec.AbstractMainTest; +import org.tizen.cli.exec.install.Main; import org.tizen.common.core.command.Executor; /** @@ -94,7 +97,7 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { "--log=trace", "--device", "TestDevice", "--widget", "test.wgt" } ); - final String[] args = cmd.getOptionValues( Main.OPT_WIDGETFILE ); + final String[] args = cmd.getOptionValues( OPT_WIDGETFILE ); assertEquals( 1, args.length ); assertEquals( "test.wgt", args[0] ); final String[] shortArgs = cmd.getOptionValues( "w" ); @@ -104,7 +107,7 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-w", "test.wgt" } ); - final String[] args = cmd.getOptionValues( Main.OPT_WIDGETFILE ); + final String[] args = cmd.getOptionValues( OPT_WIDGETFILE ); assertNotNull( args ); } } diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/run/MainTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/run/MainTest.java index 01271ac..4db3425 100644 --- a/org.tizen.cli/test/src/org/tizen/cli/exec/run/MainTest.java +++ b/org.tizen.cli/test/src/org/tizen/cli/exec/run/MainTest.java @@ -29,6 +29,8 @@ import static org.junit.Assert.*; import java.util.concurrent.atomic.AtomicBoolean; +import static org.tizen.cli.exec.LaunchOptionConstants.*; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; @@ -72,15 +74,15 @@ extends AbstractMainTest final PosixParser parser = new PosixParser(); parser.parse( opts, new String[] { - "-help", "-quiet", "-device", "deviceName", "-widget", "test.wgt", "-id", "http://test.com" + "-help", "-quiet", "-device", "deviceName", "-id", "http://test.com" } ); parser.parse( opts, new String[] { - "--help", "--quiet", "--device", "deviceName", "--widget", "test.wgt", "--id", "http://test.com" + "--help", "--quiet", "--device", "deviceName", "--id", "http://test.com" } ); parser.parse( opts, new String[] { - "-h", "-q", "-d", "deviceName", "-w", "test.wgt", "-i", "http://test.com" + "-h", "-q", "-d", "deviceName", "-i", "http://test.com" } ); try { @@ -94,31 +96,22 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { - "--log=trace", "--device", "TestDevice", "--id", "http://test.com", "--widget", "test.wgt" + "--log=trace", "--device", "TestDevice", "--id", "http://test.com" } ); - final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID ); + final String[] args1 = cmd.getOptionValues( OPT_WIDGETID ); assertEquals( 1, args1.length ); assertEquals( "http://test.com", args1[0] ); final String[] shortArgs1 = cmd.getOptionValues( "i" ); assertEquals( 1, shortArgs1.length ); assertEquals( "http://test.com", shortArgs1[0] ); - - final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE ); - assertEquals( 1, args2.length ); - assertEquals( "test.wgt", args2[0] ); - final String[] shortArgs2 = cmd.getOptionValues( "w" ); - assertEquals( 1, shortArgs2.length ); - assertEquals( "test.wgt", shortArgs2[0] ); } { final CommandLine cmd = parser.parse( opts, new String[] { - "--log=debug", "-i", "http://test.com", "-w", "test.wgt" + "--log=debug", "-i", "http://test.com" } ); - final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID ); + final String[] args1 = cmd.getOptionValues( OPT_WIDGETID ); assertNotNull( args1 ); - final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE ); - assertNotNull( args2 ); } } @@ -148,7 +141,7 @@ extends AbstractMainTest } }; - testClass.run( "-d", "TestDevice", "-i", "http://test.com", "-w", "test.wgt" ); + testClass.run( "-d", "TestDevice", "-i", "http://test.com" ); assertTrue( result.get() ); } } diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/sign/MainTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/sign/MainTest.java index 91c72a1..4b35f33 100755 --- a/org.tizen.cli/test/src/org/tizen/cli/exec/sign/MainTest.java +++ b/org.tizen.cli/test/src/org/tizen/cli/exec/sign/MainTest.java @@ -31,6 +31,8 @@ import static org.junit.Assert.fail; import java.util.concurrent.atomic.AtomicBoolean; +import static org.tizen.cli.exec.LaunchOptionConstants.*; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; @@ -97,7 +99,7 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { "--exclude", "hello", "--log=trace", "--exclude", "message2", "--profile", "test:/test/prfiles.xml" } ); - final String[] args = cmd.getOptionValues( Main.OPT_EXCLUDE ); + final String[] args = cmd.getOptionValues( OPT_EXCLUDE ); assertEquals( 2, args.length ); assertEquals( "hello", args[0] ); assertEquals( "message2", args[1] ); @@ -109,7 +111,7 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-p", "test:/test/prfiles.xml" } ); - final String[] args = cmd.getOptionValues( Main.OPT_EXCLUDE ); + final String[] args = cmd.getOptionValues( OPT_EXCLUDE ); assertNull( args ); } } diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/uninstall/MainTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/uninstall/MainTest.java index d5404e0..8881887 100644 --- a/org.tizen.cli/test/src/org/tizen/cli/exec/uninstall/MainTest.java +++ b/org.tizen.cli/test/src/org/tizen/cli/exec/uninstall/MainTest.java @@ -29,6 +29,8 @@ import static org.junit.Assert.*; import java.util.concurrent.atomic.AtomicBoolean; +import static org.tizen.cli.exec.LaunchOptionConstants.*; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; @@ -94,7 +96,7 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { "--log=trace", "--device", "TestDevice", "--id", "http://test.com" } ); - final String[] args = cmd.getOptionValues( Main.OPT_WIDGETID ); + final String[] args = cmd.getOptionValues( OPT_WIDGETID ); assertEquals( 1, args.length ); assertEquals( "http://test.com", args[0] ); final String[] shortArgs = cmd.getOptionValues( "i" ); @@ -104,7 +106,7 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-i", "http://test.com" } ); - final String[] args = cmd.getOptionValues( Main.OPT_WIDGETID ); + final String[] args = cmd.getOptionValues( OPT_WIDGETID ); assertNotNull( args ); } } diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/wgt/MainTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/wgt/MainTest.java index b78a859..533b3d7 100755 --- a/org.tizen.cli/test/src/org/tizen/cli/exec/wgt/MainTest.java +++ b/org.tizen.cli/test/src/org/tizen/cli/exec/wgt/MainTest.java @@ -35,6 +35,8 @@ import static org.tizen.common.util.ArrayUtil.size; import static org.tizen.common.util.IOUtil.getBytes; import static org.tizen.common.util.IOUtil.tryClose; +import static org.tizen.cli.exec.LaunchOptionConstants.*; + import java.io.InputStream; import java.util.concurrent.atomic.AtomicBoolean; import java.util.zip.ZipEntry; @@ -213,7 +215,7 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { "--exclude", "hello", "--log=trace", "--exclude", "message2" } ); - final String[] args = cmd.getOptionValues( Main.OPT_EXCLUDE ); + final String[] args = cmd.getOptionValues( OPT_EXCLUDE ); assertArrayEquals( new String[] { "hello", "message2" }, args ); final String[] shortArgs = cmd.getOptionValues( "e" ); assertArrayEquals( new String[] { "hello", "message2" }, shortArgs ); @@ -221,7 +223,7 @@ extends AbstractMainTest { final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug" } ); - final String[] args = cmd.getOptionValues( Main.OPT_EXCLUDE ); + final String[] args = cmd.getOptionValues( OPT_EXCLUDE ); assertNull( args ); } @@ -229,7 +231,7 @@ extends AbstractMainTest final CommandLine cmd = parser.parse( opts, new String[] { "--include", "*.html" } ); final String[] args = cmd.getArgs(); assertTrue( isEmpty( args ) ); - assertArrayEquals( new String[] { "*.html" }, cmd.getOptionValues( Main.OPT_INCLUDE ) ); + assertArrayEquals( new String[] { "*.html" }, cmd.getOptionValues( OPT_INCLUDE ) ); } }