[Title] Fix test case 90/10990/1
authorBon-Yong Lee <bonyong.lee@samsung.com>
Wed, 16 Oct 2013 00:52:37 +0000 (09:52 +0900)
committerBon-Yong Lee <bonyong.lee@samsung.com>
Wed, 16 Oct 2013 00:54:07 +0000 (09:54 +0900)
[Desc.]
[Issue]

org.tizen.common/src/org/tizen/common/core/command/sdb/PullSdbCommand.java [changed mode: 0644->0755]
org.tizen.common/test/src/org/tizen/common/ShellTest.java [deleted file]
org.tizen.common/test/src/org/tizen/common/core/command/sdb/PullSdbCommandTest.java
org.tizen.common/test/src/org/tizen/common/core/command/sdb/PushSdbCommandTest.java [changed mode: 0644->0755]

diff --git a/org.tizen.common/test/src/org/tizen/common/ShellTest.java b/org.tizen.common/test/src/org/tizen/common/ShellTest.java
deleted file mode 100755 (executable)
index 100f6c0..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*\r
- * Common\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: \r
- * BonYong Lee <bonyong.lee@samsung.com>\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * Contributors:\r
- * - S-Core Co., Ltd\r
- *\r
- */\r
-package org.tizen.common;\r
-\r
-import static org.junit.Assert.assertArrayEquals;\r
-import static org.junit.Assert.assertEquals;\r
-import static org.mockito.Matchers.any;\r
-import static org.powermock.api.mockito.PowerMockito.mock;\r
-import static org.powermock.api.mockito.PowerMockito.when;\r
-import static org.powermock.api.mockito.PowerMockito.whenNew;\r
-import static org.tizen.common.Shell.run;\r
-\r
-import org.junit.Test;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-\r
-/**\r
- * ShellTest\r
- *\r
- * Test case for {@link Shell}\r
- * \r
- * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)\r
- * \r
- * @see Shell\r
- */\r
-@PrepareForTest( Shell.class )\r
-public class\r
-ShellTest\r
-{\r
-    @Test\r
-    public\r
-    void\r
-    test_devices() throws Exception\r
-    {\r
-        class Result {\r
-            @Token( from = "emulator", to = "device" ) String range;\r
-            \r
-            @Pattern( pattern = "emulator{0}\t{1}\t{2}", index = 0 ) String pattern;\r
-            \r
-            @Token( from = "emulator", to = "device" ) String[] range2;\r
-            \r
-            @Pattern( pattern = "emulator{0}\t{1}\t{2}", index = 0 ) String[] pattern2;\r
-            \r
-        };\r
-        \r
-        final Shell shell = mock( Shell.class );\r
-        whenNew( Shell.class ).withAnyArguments().thenReturn( shell );\r
-        Result mockResult = new Result();\r
-        mockResult.range = "-26101";\r
-        mockResult.pattern = "-26101";\r
-        mockResult.range2 = new String[] { "-26101" };\r
-        mockResult.pattern2 = new String[] { "-26101" };\r
-        when( shell.expect( any() ) ).thenReturn( mockResult );\r
-        \r
-        final Result r = run( "sdb devices" ).expect( new Result() );\r
-        \r
-        assertEquals( r.range, r.pattern );\r
-        \r
-        assertArrayEquals( r.range2, r.pattern2 );\r
-    }\r
-}\r
index 66b186c..36dfaa2 100755 (executable)
@@ -25,6 +25,9 @@
 */
 package org.tizen.common.core.command.sdb;
 
+import static java.lang.Boolean.TRUE;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
 import static org.powermock.api.mockito.PowerMockito.mock;
 import static org.powermock.api.mockito.PowerMockito.when;
 
@@ -39,6 +42,7 @@ import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.exception.SdbCommandRejectedException;
 import org.tizen.sdblib.exception.TimeoutException;
 import org.tizen.sdblib.service.FileEntry;
+import org.tizen.sdblib.service.NullSyncProgressMonitor;
 import org.tizen.sdblib.service.SyncResult;
 import org.tizen.sdblib.service.SyncService;
 
@@ -61,10 +65,9 @@ extends CommandTest
     public void test_execute() throws Exception {
         final IDevice mockDevice = mock( IDevice.class );
         final SyncService mockService = mock( SyncService.class );
-        final FileEntry file = mock( FileEntry.class );
         SyncResult r = mock( SyncResult.class );
-        when( mockService.pull( file, "localPath" ) )
-        .thenReturn( r );
+        when( mockService.pull( any( FileEntry[].class ) , eq( "localPath" ), eq( NullSyncProgressMonitor.getInstance() ) ) ).thenReturn( r );
+        when( r.isOk() ).thenReturn( TRUE );
 
         PullSdbCommand testCommand = new PullSdbCommand( "remotePath", "localPath" )
         {
@@ -78,8 +81,4 @@ extends CommandTest
         testCommand.run( null, context );
     }
 
-    @Override
-    public String toString() {
-       return getClass().getSimpleName() + ":" + getClass().getClassLoader();
-    }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 8de7eef..2dc553a
 */
 package org.tizen.common.core.command.sdb;
 
+import static java.lang.Boolean.TRUE;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
 
 import java.io.IOException;
-import java.lang.reflect.Constructor;
 
 import org.junit.Test;
 import org.tizen.common.core.command.CommandTest;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.exception.SdbCommandRejectedException;
 import org.tizen.sdblib.exception.TimeoutException;
+import org.tizen.sdblib.service.FileEntry;
+import org.tizen.sdblib.service.NullSyncProgressMonitor;
+import org.tizen.sdblib.service.SyncResult;
 import org.tizen.sdblib.service.SyncService;
 
 /**
@@ -51,14 +57,18 @@ PushSdbCommandTest
 extends CommandTest
 {
     @Test
-    public void test_execute() throws Exception {
-        IDevice mockDevice = mock( IDevice.class );
-        Class<?> serviceClass = SyncService.class;
-        Constructor<?>[] con = serviceClass.getDeclaredConstructors();
-        con[0].setAccessible( true );
-        final SyncService mockService = (SyncService) con[0].newInstance( null, null );
+    public
+    void
+    test_execute()
+    throws Exception
+    {
+        final IDevice mockDevice = mock( IDevice.class );
+        final SyncService mockService = mock( SyncService.class );
+        final SyncResult result = mock( SyncResult.class );
+        when( mockService.push( any( String[].class ), any( FileEntry.class ), eq( NullSyncProgressMonitor.getInstance() ) ) ).thenReturn( result );
+        when( result.isOk() ).thenReturn( TRUE );
 
-        PushSdbCommand testCommand = new PushSdbCommand( "sourcePath", "targetPath" ) {
+        final PushSdbCommand testCommand = new PushSdbCommand( "sourcePath", "targetPath" ) {
             @Override
             protected SyncService getSyncService() throws TimeoutException,
                     SdbCommandRejectedException, IOException {