1 package org.robolectric.shadows; 2 3 import static com.google.common.truth.Truth.assertThat; 4 5 import androidx.test.ext.junit.runners.AndroidJUnit4; 6 import com.google.common.io.Files; 7 import java.io.File; 8 import java.nio.charset.StandardCharsets; 9 import libcore.io.IoUtils; 10 import org.junit.Rule; 11 import org.junit.Test; 12 import org.junit.rules.TemporaryFolder; 13 import org.junit.runner.RunWith; 14 15 @RunWith(AndroidJUnit4.class) 16 public class ShadowIoUtilsTest { 17 18 @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); 19 20 @Test ioUtils()21 public void ioUtils() throws Exception { 22 23 File file = temporaryFolder.newFile("test_file.txt"); 24 Files.asCharSink(file, StandardCharsets.UTF_8).write("some contents"); 25 26 String contents = IoUtils.readFileAsString(file.getAbsolutePath()); 27 assertThat(contents).isEqualTo("some contents"); 28 } 29 } 30