import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
import static org.tizen.common.util.IOUtil.tryClose;
import java.io.ByteArrayInputStream;
import java.util.Stack;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
/**
* FileUtilTest
*
* @see FileUtil
*/
+@RunWith( PowerMockRunner.class )
+@PrepareForTest( FileUtil.class )
public class
FileUtilTest
{
{
assertFalse( FileUtil.isExist( null ) );
assertFalse( FileUtil.isExist( "" ) );
+
+ final File textAbc = mock( File.class );
+ when( textAbc.exists() ).thenReturn( Boolean.FALSE );
+ final File resource = mock( File.class );
+ when( resource.exists() ).thenReturn( Boolean.TRUE );
+ final File textTxt = mock( File.class );
+ when( textTxt.exists() ).thenReturn( Boolean.TRUE );
+ whenNew( File.class ).withArguments( "test/test_files/resource/text.abc" ).thenReturn( textAbc );
+ whenNew( File.class ).withArguments( "test/test_files/resource" ).thenReturn( resource );
+ whenNew( File.class ).withArguments( "test/test_files/resource/" ).thenReturn( resource );
+ whenNew( File.class ).withArguments( "test/test_files/resource/text.txt" ).thenReturn( textTxt );
assertFalse( FileUtil.isExist( "test/test_files/resource/text.abc" ) );
assertTrue( FileUtil.isExist( "test/test_files/resource" ) );
assertTrue( FileUtil.isExist( "test/test_files/resource/" ) );