Skip to content

Instantly share code, notes, and snippets.

@up1
Last active August 29, 2015 14:03
Show Gist options
  • Save up1/2d80fee554a895cc5073 to your computer and use it in GitHub Desktop.
Save up1/2d80fee554a895cc5073 to your computer and use it in GitHub Desktop.
Demo :: Working with File system
@Before
public void createCSVFile() throws Exception {
file = temporaryFolder.newFile("input.txt");
PrintWriter out = new PrintWriter(file);
out.print("1,2,3,4,5");
out.close();
}
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Test
public void fileExistInTemporaryFolder() throws Exception {
FileUtility.read(file);
}
@Test
public void readFileThatContentShouldNotNull() throws Exception {
String output = FileUtility.read(file);
assertTrue(output.length() > 0);
}
@Test
public void readCSVFileAndSubStringWithCommaShouldHaveSizeEqualFive() throws Exception {
String output = FileUtility.read(file);
SplitData splitData = new SplitData();
assertEquals(5, splitData.process(output).length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment