Last active
August 29, 2015 14:03
-
-
Save up1/2d80fee554a895cc5073 to your computer and use it in GitHub Desktop.
Demo :: Working with File system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Rule | |
public TemporaryFolder temporaryFolder = new TemporaryFolder(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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