}
public void testCreateTempFile() throws IOException {
SimpleTempStorage man = new SimpleTempStorage();
TempPath path = man.getRootTempPath().createTempPath();
TempFile file = path.createTempFile();
assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
String fileName = file.getAbsolutePath().substring(
file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
assertTrue("Unexpected chars in file name " + fileName,
fileName.matches("^[0-9]+\\.tmp$"));
assertTrue("Temp file doesn't exist",
new File(file.getAbsolutePath()).exists());
String s = "A short string";
OutputStream out = file.getOutputStream();
out.write(s.getBytes());
out.close();
byte[] buffer = new byte[s.length() * 2];
InputStream in = file.getInputStream();
int i = 0;
for (int data; (data = in.read()) != -1; i++) {
buffer[i] = (byte) data;
}
in.close();