KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > util > TestTempFile


1 /* ====================================================================
2    Copyright 2002-2004 Apache Software Foundation
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15 ==================================================================== */

16 package org.apache.poi.util;
17
18 import junit.framework.TestCase;
19
20 import java.io.File JavaDoc;
21 import java.io.FileWriter JavaDoc;
22
23 /**
24  * @author Glen Stampoultzis
25  */

26 public class TestTempFile extends TestCase {
27     TempFile tempFile;
28
29     public void testCreateTempFile()
30             throws Exception JavaDoc
31     {
32         File JavaDoc tempFile = TempFile.createTempFile("test", ".txt");
33         FileWriter JavaDoc w = new FileWriter JavaDoc(tempFile);
34         w.write("testing");
35         w.close();
36         assertTrue(tempFile.exists());
37         assertEquals("poifiles", tempFile.getParentFile().getName());
38
39         // Can't think of a good way to check whether a file is actually deleted since it would require the VM to stop.
40
}
41 }
Popular Tags