1 17 package org.apache.tools.ant.util; 18 19 import java.io.File ; 20 import java.io.IOException ; 21 import junit.framework.TestCase; 22 23 26 public class LazyFileOutputStreamTest extends TestCase { 27 private LazyFileOutputStream los; 28 private final static File f = new File ("test.txt"); 29 30 public LazyFileOutputStreamTest(String s) { 31 super(s); 32 } 33 34 public void setUp() { 35 los = new LazyFileOutputStream(f); 36 } 37 38 public void tearDown() throws IOException { 39 try { 40 los.close(); 41 } finally { 42 f.delete(); 43 } 44 } 45 46 public void testNoFileWithoutWrite() throws IOException { 47 los.close(); 48 assertTrue(f + " has not been written.", !f.exists()); 49 } 50 51 public void testOpen() throws IOException { 52 los.open(); 53 los.close(); 54 assertTrue(f + " has been written.", f.exists()); 55 } 56 57 public void testSingleByte() throws IOException { 58 los.write(0); 59 los.close(); 60 assertTrue(f + " has been written.", f.exists()); 61 } 62 63 public void testByteArray() throws IOException { 64 los.write(new byte[] {0}); 65 los.close(); 66 assertTrue(f + " has been written.", f.exists()); 67 } 68 } 69 | Popular Tags |