Skip to content

Instantly share code, notes, and snippets.

@vyazelenko
Created October 15, 2011 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyazelenko/1289406 to your computer and use it in GitHub Desktop.
Save vyazelenko/1289406 to your computer and use it in GitHub Desktop.
Test file to reproduce IllegalStateException on TemporaryFolder.newFile(String)
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class TemporaryFolderTest {
@Test
public void canCreateTemporaryFileWithGivenName() throws IOException {
TemporaryFolder tempFolder = new TemporaryFolder();
File file = tempFolder.newFile("MyFile.txt");
assertThat("File", file, is(notNullValue()));
assertThat("File doesn't exist", file.exists(), is(true));
assertThat("File name", file.getName(), is("MyFile.txt"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment