[Title] Added CLI UNIT TEST and fixed logic.
authorgyeongseok.seo <gyeongseok.seo@samsung.com>
Wed, 11 Jul 2012 08:14:11 +0000 (17:14 +0900)
committergyeongseok.seo <gyeongseok.seo@samsung.com>
Wed, 11 Jul 2012 08:15:43 +0000 (17:15 +0900)
[Type] Enhancement
[Module] webapp-eplugin
[Priority] Major
[Jira#] 5363
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I474bb7067a6d6f627ac6f8f2afb55ed1bf2f3559

org.tizen.cli/src/org/tizen/cli/exec/WRTLauncher.java
org.tizen.cli/src/org/tizen/cli/exec/debug/Main.java
org.tizen.cli/src/org/tizen/cli/exec/install/Main.java
org.tizen.cli/src/org/tizen/cli/exec/run/Main.java
org.tizen.cli/src/org/tizen/cli/exec/uninstall/Main.java
org.tizen.cli/test/src/org/tizen/cli/exec/WRTLauncherTest.java [new file with mode: 0644]
org.tizen.cli/test/src/org/tizen/cli/exec/debug/MainTest.java [new file with mode: 0644]
org.tizen.cli/test/src/org/tizen/cli/exec/install/MainTest.java [new file with mode: 0644]
org.tizen.cli/test/src/org/tizen/cli/exec/query/MainTest.java [new file with mode: 0644]
org.tizen.cli/test/src/org/tizen/cli/exec/run/MainTest.java [new file with mode: 0644]
org.tizen.cli/test/src/org/tizen/cli/exec/uninstall/MainTest.java [new file with mode: 0644]

index e98b626..cd68d0a 100644 (file)
@@ -55,7 +55,7 @@ extends AbstractLauncher
      * Option for select device
      * </p>
      */
-    protected static final String OPT_DEVICE = "select device";
+    protected static final String OPT_DEVICE = "device";
 
     /**
      * <p>
index bbb6be0..74c6f0c 100644 (file)
@@ -56,7 +56,7 @@ extends WRTLauncher
      * Option for target widget file
      * </p>
      */
-    protected static final String OPT_WIDGETFILE = "target widget file";
+    protected static final String OPT_WIDGETFILE = "widget";
 
     /**
      * <p>
@@ -74,7 +74,7 @@ extends WRTLauncher
      * Option for target widget id
      * </p>
      */
-    protected static final String OPT_WIDGETID = "target widget id";
+    protected static final String OPT_WIDGETID = "id";
 
     /**
      * <p>
index 8688384..7cff754 100644 (file)
@@ -51,7 +51,7 @@ extends WRTLauncher
      * Option for target widget file
      * </p>
      */
-    protected static final String OPT_WIDGETFILE = "target widget file";
+    protected static final String OPT_WIDGETFILE = "widget";
 
     /**
      * <p>
index c0d9f32..17a0e50 100644 (file)
@@ -55,7 +55,7 @@ extends WRTLauncher
      * Option for target widget file
      * </p>
      */
-    protected static final String OPT_WIDGETFILE = "target widget file";
+    protected static final String OPT_WIDGETFILE = "widget";
 
     /**
      * <p>
@@ -73,7 +73,7 @@ extends WRTLauncher
      * Option for target widget id
      * </p>
      */
-    protected static final String OPT_WIDGETID = "target widget id";
+    protected static final String OPT_WIDGETID = "id";
 
     /**
      * <p>
index 349fa16..2d6c412 100644 (file)
@@ -52,7 +52,7 @@ extends WRTLauncher
      * Option for target widget id
      * </p>
      */
-    protected static final String OPT_WIDGETID = "target widget id";
+    protected static final String OPT_WIDGETID = "id";
 
     /**
      * <p>
diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/WRTLauncherTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/WRTLauncherTest.java
new file mode 100644 (file)
index 0000000..8968c03
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+* 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;
+
+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.common.core.command.Executor;
+
+/**
+ * WRTLauncherTest
+ *
+ * Test case for {@link WRTLauncher}
+ * 
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ * 
+ * @see WRTLauncher
+ */
+public class
+WRTLauncherTest
+extends AbstractMainTest
+{
+    /**
+     * Test {@link WRTLauncher#getOptions()}
+     * 
+     * @throws Exception in case of failure in test
+     * 
+     * @see WRTLauncher#getOptions()
+     */
+    @Test
+    public void
+    test_getOptions()
+    throws Exception
+    {
+        WRTLauncher testClass = new WRTLauncher();
+        final Options opts = testClass.getOptions();
+        final PosixParser parser = new PosixParser();
+
+        parser.parse( opts, new String[] {
+                "-help", "-quiet", "-device", "deviceName"
+        } );
+
+        parser.parse( opts, new String[] {
+                "--help", "--quiet", "--device", "deviceName"
+        } );
+
+        parser.parse( opts, new String[] {
+                "-h", "-q", "-d", "deviceName"
+        } );
+
+        try {
+            parser.parse( opts, new String[] {
+                    "-verbose", "-quiet"
+            } );
+            fail();
+        } catch ( final UnrecognizedOptionException e ) {
+        }
+
+        {
+            final CommandLine cmd = parser.parse( opts, new String[] { "--log=trace", "--device", "TestDevice" } );
+            final String[] args = cmd.getOptionValues( WRTLauncher.OPT_DEVICE );
+            assertEquals( 1, args.length );
+            assertEquals( "TestDevice", args[0] );
+            final String[] shortArgs = cmd.getOptionValues( "d" );
+            assertEquals( 1, shortArgs.length );
+            assertEquals( "TestDevice", shortArgs[0] );
+        }
+
+        {
+            final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-d", "TestDevice" } );
+            final String[] args = cmd.getOptionValues( WRTLauncher.OPT_DEVICE );
+            assertNotNull( args );
+        }
+    }
+
+    /**
+     * Test {@link WRTLauncher#run(String...)}
+     * 
+     * @throws Exception in case of failure in test
+     * 
+     * @see WRTLauncher#run(String...)
+     */
+    @Test
+    public
+    void
+    test_run()
+    throws Exception
+    {
+        final AtomicBoolean result = new AtomicBoolean( false );
+
+        final WRTLauncher testClass = new WRTLauncher()
+        {
+            protected Executor getExecutor() {
+                return WRTLauncherTest.this.executor;
+            }
+            
+            protected void execute( final CommandLine cmdLine ) throws Exception {
+                result.set( true );
+            }
+        };
+
+        testClass.run( "-d", "TestDevice" );
+        assertTrue( result.get() );
+    }
+}
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
new file mode 100644 (file)
index 0000000..d83da99
--- /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.debug;
+
+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", "-device", "deviceName", "-widget", "test.wgt", "-id", "http://test.com"
+        } );
+
+        parser.parse( opts, new String[] {
+                "--help", "--quiet", "--device", "deviceName", "--widget", "test.wgt", "--id", "http://test.com"
+        } );
+
+        parser.parse( opts, new String[] {
+                "-h", "-q", "-d", "deviceName", "-w", "test.wgt",  "-i", "http://test.com"
+        } );
+
+        try {
+            parser.parse( opts, new String[] {
+                    "-verbose", "-quiet"
+            } );
+            fail();
+        } catch ( final UnrecognizedOptionException e ) {
+        }
+
+        {
+            final CommandLine cmd = parser.parse( opts, new String[] {
+                    "--log=trace", "--device", "TestDevice", "--id", "http://test.com", "--widget", "test.wgt"
+                    } );
+            final String[] args1 = cmd.getOptionValues( Main.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"
+                    } );
+            final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID );
+            assertNotNull( args1 );
+            final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE );
+            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( "-d", "TestDevice", "-i", "http://test.com", "-w", "test.wgt" );
+        assertTrue( result.get() );
+    }
+}
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
new file mode 100644 (file)
index 0000000..00101c5
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+* 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.install;
+
+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", "-device", "deviceName", "-widget", "test.wgt"
+        } );
+
+        parser.parse( opts, new String[] {
+                "--help", "--quiet", "--device", "deviceName", "--widget", "test.wgt"
+        } );
+
+        parser.parse( opts, new String[] {
+                "-h", "-q", "-d", "deviceName", "-w", "test.wgt"
+        } );
+
+        try {
+            parser.parse( opts, new String[] {
+                    "-verbose", "-quiet"
+            } );
+            fail();
+        } catch ( final UnrecognizedOptionException e ) {
+        }
+
+        {
+            final CommandLine cmd = parser.parse( opts, new String[] { "--log=trace", "--device", "TestDevice", "--widget", "test.wgt" } );
+            final String[] args = cmd.getOptionValues( Main.OPT_WIDGETFILE );
+            assertEquals( 1, args.length );
+            assertEquals( "test.wgt", args[0] );
+            final String[] shortArgs = cmd.getOptionValues( "w" );
+            assertEquals( 1, shortArgs.length );
+            assertEquals( "test.wgt", shortArgs[0] );
+        }
+
+        {
+            final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-w", "test.wgt" } );
+            final String[] args = cmd.getOptionValues( Main.OPT_WIDGETFILE );
+            assertNotNull( args );
+        }
+    }
+
+    /**
+     * 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( "-d", "TestDevice", "-w", "test.wgt" );
+        assertTrue( result.get() );
+    }
+}
diff --git a/org.tizen.cli/test/src/org/tizen/cli/exec/query/MainTest.java b/org.tizen.cli/test/src/org/tizen/cli/exec/query/MainTest.java
new file mode 100644 (file)
index 0000000..0aea6cd
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+* 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.query;
+
+import static org.junit.Assert.*;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.commons.cli.CommandLine;
+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#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( "-d", "TestDevice" );
+        assertTrue( result.get() );
+    }
+}
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
new file mode 100644 (file)
index 0000000..241a4ac
--- /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.run;
+
+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", "-device", "deviceName", "-widget", "test.wgt", "-id", "http://test.com"
+        } );
+
+        parser.parse( opts, new String[] {
+                "--help", "--quiet", "--device", "deviceName", "--widget", "test.wgt", "--id", "http://test.com"
+        } );
+
+        parser.parse( opts, new String[] {
+                "-h", "-q", "-d", "deviceName", "-w", "test.wgt",  "-i", "http://test.com"
+        } );
+
+        try {
+            parser.parse( opts, new String[] {
+                    "-verbose", "-quiet"
+            } );
+            fail();
+        } catch ( final UnrecognizedOptionException e ) {
+        }
+
+        {
+            final CommandLine cmd = parser.parse( opts, new String[] {
+                    "--log=trace", "--device", "TestDevice", "--id", "http://test.com", "--widget", "test.wgt"
+                    } );
+            final String[] args1 = cmd.getOptionValues( Main.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"
+                    } );
+            final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID );
+            assertNotNull( args1 );
+            final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE );
+            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( "-d", "TestDevice", "-i", "http://test.com", "-w", "test.wgt" );
+        assertTrue( result.get() );
+    }
+}
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
new file mode 100644 (file)
index 0000000..c23a067
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+* 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.uninstall;
+
+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", "-device", "deviceName", "-id", "http://test.com"
+        } );
+
+        parser.parse( opts, new String[] {
+                "--help", "--quiet", "--device", "deviceName", "--id", "http://test.com"
+        } );
+
+        parser.parse( opts, new String[] {
+                "-h", "-q", "-d", "deviceName", "-i", "http://test.com"
+        } );
+
+        try {
+            parser.parse( opts, new String[] {
+                    "-verbose", "-quiet"
+            } );
+            fail();
+        } catch ( final UnrecognizedOptionException e ) {
+        }
+
+        {
+            final CommandLine cmd = parser.parse( opts, new String[] { "--log=trace", "--device", "TestDevice", "--id", "http://test.com" } );
+            final String[] args = cmd.getOptionValues( Main.OPT_WIDGETID );
+            assertEquals( 1, args.length );
+            assertEquals( "http://test.com", args[0] );
+            final String[] shortArgs = cmd.getOptionValues( "i" );
+            assertEquals( 1, shortArgs.length );
+            assertEquals( "http://test.com", shortArgs[0] );
+        }
+
+        {
+            final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-i", "http://test.com" } );
+            final String[] args = cmd.getOptionValues( Main.OPT_WIDGETID );
+            assertNotNull( args );
+        }
+    }
+
+    /**
+     * 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( "-d", "TestDevice", "-i", "http://test.com" );
+        assertTrue( result.get() );
+    }
+}