[Title] Added CLI gen command - build script, unit test, command script.
authorgyeongseok.seo <gyeongseok.seo@samsung.com>
Tue, 21 Aug 2012 09:25:51 +0000 (18:25 +0900)
committergyeongseok.seo <gyeongseok.seo@samsung.com>
Tue, 21 Aug 2012 09:25:51 +0000 (18:25 +0900)
[Type] Enhancement
[Module] cli
[Priority] Major
[Jira#]
[Redmine#] 6364
[Problem] gen command - not include buildscript, total command, test code.
[Cause]
[Solution] implements
[TestCase] unit test

Change-Id: I0c8ddbba960fb9ca29901c979154cfbcafe9fd06

org.tizen.cli/doc/install/bin_/web-gen.bat [new file with mode: 0644]
org.tizen.cli/doc/install/bin_/webtizen
org.tizen.cli/doc/install/bin_/webtizen.bat
org.tizen.cli/test/src/org/tizen/cli/exec/gen/MainTest.java [new file with mode: 0644]
package/build.ubuntu-32
package/build.ubuntu-64

diff --git a/org.tizen.cli/doc/install/bin_/web-gen.bat b/org.tizen.cli/doc/install/bin_/web-gen.bat
new file mode 100644 (file)
index 0000000..e8b45bd
--- /dev/null
@@ -0,0 +1,55 @@
+@echo off
+set SCRIPT=%0
+
+:: delims is a TAB followed by a space
+set KEY=TIZEN_SDK_INSTALLED_PATH
+
+REM find sdk path
+set rkey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
+set rval="Local AppData"
+FOR /f "tokens=3*" %%a IN ('reg query %rkey% /v %rval%') DO (
+    set sdk_conf_path=%%b
+)
+
+REM find cli path
+FOR /f "tokens=1,2 delims==" %%i IN (%sdk_conf_path%\tizen-sdk-data\tizensdkpath) DO IF %%i==%KEY% (set SDK_PATH=%%j)
+set CLI_HOME=%SDK_PATH%\tools\ide
+
+set MAIN=org.tizen.cli.exec.gen.Main
+
+set OPT_TRACE=
+set OPT_LOGGING=-Dlog4j.configuration=log4j.xml
+set OPT_PRG_NAME=-Dcli.name=%SCRIPT%
+
+set READ_ARG=n
+
+FOR %%W IN ( %* ) DO ( call:parseArg %%W )
+
+set OPT=%OPT_TRACE% %OPT_LOGGING% %OPT_PRG_NAME%
+set EXEC=java -cp %CLI_HOME%\conf -Djava.ext.dirs=%CLI_HOME%\lib %OPT% %MAIN% %*
+
+IF NOT "" == "%OPT_TRACE%" ( echo Command :%EXEC% )
+
+%EXEC%
+goto:eof
+
+:parseArg
+        IF y == %READ_ARG% goto SET_LOGGING
+
+:SECOND_STEP
+    IF %~1 == --log goto SET_READY
+    IF %~1 == -l goto SET_READY
+:END_STEP
+goto:eof
+
+:SET_LOGGING
+    set OPT_LOGGING=-Dlog4j.configuration=log4j-%~1.xml
+    IF %~1 == trace set OPT_TRACE=-Dlog4j.debug=true
+    set READ_ARG=n
+
+    goto SECOND_STEP
+
+:SET_READY
+    set READ_ARG=y
+    goto END_STEP
+
index 0c9e61f..b1f5d84 100755 (executable)
@@ -35,6 +35,7 @@ _print_usage()
     echo "The most frequently used commands are run and debug."
     echo ""
     echo "Commands:"
+    echo "  gen          :     Generation widget project"
     echo "  packaging    :     Packaging widget project"
     echo "  signing      :     Signing widget project"
     echo "  list         :     Display installed widgets handle and name list"
@@ -44,6 +45,7 @@ _print_usage()
     echo "  debug        :     Install wdiget package for target And Launch widget And activate debug mode"
     echo ""
     echo "Short Commands:"
+    echo "  -g           :     gen command"
     echo "  -p           :     packaging command"
     echo "  -s           :     signing command"
     echo "  -l           :     list command"
@@ -73,6 +75,10 @@ _select_option()
         help|-h)
             _print_usage 0
             ;;
+        gen|-g)
+            MAIN=org.tizen.cli.exec.gen.Main
+            SCRIPT="web-gen"
+            ;;
         packaging|-p)
             MAIN=org.tizen.cli.exec.wgt.Main
             SCRIPT="web-packaging"
index cfe2236..faee54a 100644 (file)
@@ -54,6 +54,7 @@ REM print usages method
     echo. The most frequently used commands are run and debug.
     echo. 
     echo. Commands:
+    echo.   gen          :     Generation widget project
     echo.   packaging    :     Packaging widget project
     echo.   signing      :     Signing widget project
     echo.   list         :     Display installed widgets handle and name list
@@ -63,6 +64,7 @@ REM print usages method
     echo.   debug        :     Install wdiget package for target And Launch widget And activate debug mode
     echo. 
     echo. Short Commands:
+    echo.   -g           :     gen command
     echo.   -p           :     packaging command
     echo.   -s           :     signing command
     echo.   -l           :     list command
@@ -85,6 +87,8 @@ REM option select method
 :_select_option
     IF %1 == -h goto:_print_usage
     IF %1 == help goto:_print_usage
+    IF %1 == -g set MAIN=org.tizen.cli.exec.gen.Main
+    IF %1 == gen set MAIN=org.tizen.cli.exec.gen.Main
     IF %1 == -p set MAIN=org.tizen.cli.exec.wgt.Main
     IF %1 == packaging set MAIN=org.tizen.cli.exec.wgt.Main
     IF %1 == -s set MAIN=org.tizen.cli.exec.sign.Main
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
new file mode 100644 (file)
index 0000000..0299b5f
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+* Web IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* GyeongSeok Seo <gyeongseok.seo@samsung.com>
+* BonYong Lee <bonyong.lee@samsung.com>
+* 
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+package org.tizen.cli.exec.gen;
+
+import static org.junit.Assert.*;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+import org.apache.commons.cli.UnrecognizedOptionException;
+import org.junit.Test;
+import org.tizen.cli.exec.AbstractMainTest;
+import org.tizen.common.core.command.Executor;
+
+/**
+ * MainTest
+ *
+ * Test case for {@link Main}
+ * 
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ * 
+ * @see Main
+ */
+public class
+MainTest
+extends AbstractMainTest
+{
+       /**
+        * Test {@link Main#getOptions()}
+        * 
+        * @throws Exception in case of failure in test
+        * 
+        * @see Main#getOptions()
+        */
+       @Test
+       public void
+       test_getOptions()
+       throws Exception
+       {
+               Main testClass = new Main();
+               final Options opts = testClass.getOptions();
+               final PosixParser parser = new PosixParser();
+
+               parser.parse( opts, new String[] {
+                               "-help", "-quiet", "-name", "myproject", "-path", "/home/myproject"
+               } );
+
+               parser.parse( opts, new String[] {
+                               "--help", "--quiet", "--name", "myproject", "--path", "/home/myproject"
+               } );
+
+               parser.parse( opts, new String[] {
+                               "-h", "-q", "-n", "myproject", "-p", "/home/myproject"
+               } );
+
+               try {
+                       parser.parse( opts, new String[] {
+                                       "-verbose", "-quiet"
+                       } );
+                       fail();
+               } catch ( final UnrecognizedOptionException e ) {
+               }
+
+               {
+                       final CommandLine cmd = parser.parse( opts, new String[] {
+                                       "--log=trace", "--name", "myproject", "--path", "/home/myproject"
+                       } );
+                       final String[] args1 = cmd.getOptionValues( Main.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 );
+                       assertEquals( 1, args2.length );
+                       assertEquals( "/home/myproject", args2[0] );
+                       final String[] shortArgs2 = cmd.getOptionValues( "p" );
+                       assertEquals( 1, shortArgs2.length );
+                       assertEquals( "/home/myproject", shortArgs2[0] );
+               }
+
+               {
+                       final CommandLine cmd = parser.parse( opts, new String[] {
+                                       "--log=debug", "-n", "myproject", "-p", "/home/myproject"
+                       } );
+                       final String[] args1 = cmd.getOptionValues( Main.OPT_NAME );
+                       assertNotNull( args1 );
+                       final String[] args2 = cmd.getOptionValues( Main.OPT_PATH );
+                       assertNotNull( args2 );
+               }
+       }
+
+       /**
+        * Test {@link Main#run(String...)}
+        * 
+        * @throws Exception in case of failure in test
+        * 
+        * @see Main#run(String...)
+        */
+       @Test
+       public
+       void
+       test_run()
+       throws Exception
+       {
+               final AtomicBoolean result = new AtomicBoolean( false );
+
+               final Main testClass = new Main()
+               {
+                       protected Executor getExecutor() {
+                               return MainTest.this.executor;
+                       }
+
+                       protected void execute( final CommandLine cmdLine ) throws Exception {
+                               result.set( true );
+                       }
+               };
+
+               testClass.run( "-n", "myproject", "-p", "/home/myproject" );
+               assertTrue( result.get() );
+       }
+}
index 1dcab8b..a463f9f 100755 (executable)
@@ -33,6 +33,10 @@ build()
        cp $SRC $LIB
        jar -xvf $SRC lib
 
+    SRC=`find $ROOTDIR -name "org.tizen.web.project.wizard_*" | head -1`
+       cp $SRC $LIB
+       jar -xvf $SRC lib
+
        SRC=`find $ROOTDIR -name "org.tizen.web.sign_*" | head -1`
        cp $SRC $LIB
        jar -xvf $SRC lib
index 1dcab8b..a463f9f 100755 (executable)
@@ -33,6 +33,10 @@ build()
        cp $SRC $LIB
        jar -xvf $SRC lib
 
+    SRC=`find $ROOTDIR -name "org.tizen.web.project.wizard_*" | head -1`
+       cp $SRC $LIB
+       jar -xvf $SRC lib
+
        SRC=`find $ROOTDIR -name "org.tizen.web.sign_*" | head -1`
        cp $SRC $LIB
        jar -xvf $SRC lib