+++ /dev/null
-/*\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
*/
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;
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;
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" )
{
testCommand.run( null, context );
}
- @Override
- public String toString() {
- return getClass().getSimpleName() + ":" + getClass().getClassLoader();
- }
}
*/
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;
/**
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 {